securitystaffInfo.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <div>
  3. <div class="header_container">
  4. <el-breadcrumb
  5. class="info"
  6. separator-class="el-icon-arrow-right"
  7. >
  8. <el-breadcrumb-item>{{itemInfo.parentData.label}}</el-breadcrumb-item>
  9. <el-breadcrumb-item>{{itemInfo.data.label}}</el-breadcrumb-item>
  10. </el-breadcrumb>
  11. </div>
  12. <div class="func_container">
  13. <el-button
  14. class="create"
  15. @click="createNewPeople"
  16. >新建</el-button>
  17. <el-button
  18. class="history"
  19. type="text"
  20. @click="openHistory"
  21. >历史记录</el-button>
  22. </div>
  23. <div class="people_table">
  24. <el-table
  25. :data="tableData"
  26. tooltip-effect="dark"
  27. :header-cell-style="{ textAlign: 'center' }"
  28. :cell-style="{ textAlign: 'center' }"
  29. height="650"
  30. style="width: 100%"
  31. >
  32. <el-table-column
  33. type="index"
  34. width="50"
  35. label="序号"
  36. >
  37. </el-table-column>
  38. <el-table-column
  39. prop="name"
  40. label="姓名"
  41. >
  42. </el-table-column>
  43. <el-table-column
  44. prop="work_number"
  45. label="工号"
  46. >
  47. </el-table-column>
  48. <el-table-column
  49. prop="phone"
  50. label="联系方式"
  51. >
  52. </el-table-column>
  53. <el-table-column
  54. prop="responsibility_range"
  55. label="职责范围"
  56. >
  57. </el-table-column>
  58. <el-table-column label="照片">
  59. <template slot-scope="scope">
  60. <el-image
  61. :src="scope.row.photo"
  62. style="width: 40px; height: 40px;"
  63. :preview-src-list="[scope.row.photo]"
  64. ></el-image>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="状态">
  68. <template slot-scope="scope">
  69. <span v-if="scope.row.status == 1">正常</span>
  70. <span v-if="scope.row.status == 2">离职</span>
  71. <span v-if="scope.row.status == 3">暂时冻结</span>
  72. </template>
  73. x
  74. </el-table-column>
  75. <el-table-column
  76. label="值班日期"
  77. width="400"
  78. >
  79. <template slot-scope="scope">
  80. <!-- <el-button
  81. @click="handleClick(scope.row)"
  82. type="text"
  83. size="small"
  84. >查看</el-button>
  85. <el-button
  86. type="text"
  87. size="small"
  88. >编辑</el-button> -->
  89. <span v-if="scope.row.duty_time">
  90. {{$dayjs(scope.row.duty_time.start_time).format("YYYY-MM-DD HH:mm:ss").replace("-","年").replace("-","月").replace(" ","日 ")}} 至 {{$dayjs(scope.row.duty_time.end_time).format("YYYY-MM-DD HH:mm:ss").replace("-","年").replace("-","月").replace(" ","日 ")}}
  91. </span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column
  95. fixed="right"
  96. label="操作"
  97. width="160"
  98. >
  99. <template slot-scope="scope">
  100. <el-button
  101. type="text"
  102. size="small"
  103. @click="updatePeo(scope.row)"
  104. >
  105. 编辑
  106. </el-button>
  107. <el-button
  108. type="text"
  109. size="small"
  110. @click="deletePeo(scope.row)"
  111. >删除</el-button>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. </div>
  116. <div class="footer">
  117. <page :paginationData="paginationData"></page>
  118. </div>
  119. <createPeople
  120. ref="createPeople"
  121. v-bind="{
  122. }"
  123. ></createPeople>
  124. <createUpdatePeople
  125. ref="createUpdatePeople"
  126. v-bind="{
  127. editData:editData,
  128. update:getListAfterUpdate
  129. }"
  130. ></createUpdatePeople>
  131. <historyPeople
  132. ref="historyPeople"
  133. v-bind="{
  134. itemInfo:itemInfo
  135. }"
  136. ></historyPeople>
  137. </div>
  138. </template>
  139. <script>
  140. import page from "@/components/pagination/index";
  141. import createPeople from "./dialog/createPeople.vue";
  142. import createUpdatePeople from "./dialog/createUpdatePeople.vue";
  143. import historyPeople from "./dialog/historyPeople.vue";
  144. import api from "@/api/infoConfig/api";
  145. export default {
  146. props: {
  147. itemInfo: {
  148. type: Object,
  149. },
  150. },
  151. components: {
  152. page,
  153. createPeople,
  154. createUpdatePeople,
  155. historyPeople,
  156. },
  157. data() {
  158. return {
  159. // 正常 已离职 暂时冻结
  160. currentPageSize: 10,
  161. currentPage: 1,
  162. paginationData: {
  163. pageSize: 10,
  164. pagerCount: 5,
  165. currentPage: 1,
  166. pageSizes: [5, 10, 20, 30],
  167. total: 0,
  168. currentChange: (val) => {
  169. that.handlePageChange(val);
  170. },
  171. handleSizeChange: (val) => {
  172. that.handleSizeChange(val);
  173. },
  174. },
  175. tableData: [],
  176. editData: null,
  177. };
  178. },
  179. mounted() {
  180. this.resetPageConfig({
  181. currentPage: 1,
  182. });
  183. this.handlePageChange(1);
  184. },
  185. methods: {
  186. createNewPeople() {
  187. this.$refs.createPeople.dialogVisible = true;
  188. },
  189. updatePeo(data) {
  190. this.editData = data;
  191. this.$refs.createUpdatePeople.dialogVisible = true;
  192. },
  193. deletePeo(data) {
  194. this.$confirm("此操作将删除该条信息, 是否继续?", "提示", {
  195. confirmButtonText: "确定",
  196. cancelButtonText: "取消",
  197. type: "warning",
  198. })
  199. .then(() => {
  200. const loading = this.$loading({
  201. lock: true,
  202. text: "删除中,请稍后!",
  203. spinner: "el-icon-loading",
  204. background: "rgba(0, 0, 0, 0.7)",
  205. customClass: "systemConfigLoading",
  206. });
  207. api
  208. .delPerson({
  209. id: this.itemInfo.data.id,
  210. staff: data.id,
  211. })
  212. .then((result) => {
  213. loading.close();
  214. if (result.data.code == 0) {
  215. this.resetPageConfig({
  216. currentPage: 1,
  217. });
  218. this.handlePageChange(1);
  219. this.$message({
  220. type: "success",
  221. message: "删除成功!",
  222. });
  223. } else {
  224. this.$message({
  225. type: "error",
  226. message: "删除失败!",
  227. });
  228. }
  229. })
  230. .catch((err) => {
  231. loading.close();
  232. this.$message({
  233. type: "error",
  234. message: "删除失败!",
  235. });
  236. });
  237. })
  238. .catch(() => {
  239. this.$message({
  240. type: "info",
  241. message: "已取消删除",
  242. });
  243. });
  244. },
  245. handlePageChange(val) {
  246. this.paginationData.currentPage = val;
  247. this.getListData({
  248. id: String(this.itemInfo.data.id),
  249. page_size: this.paginationData.pageSize,
  250. page: val,
  251. })
  252. .then((result) => {})
  253. .catch((err) => {});
  254. },
  255. handleSizeChange(val) {
  256. this.paginationData.pageSize = val;
  257. this.getListData({
  258. id: String(this.itemInfo.data.id),
  259. page_size: val,
  260. page: this.paginationData.currentPage,
  261. })
  262. .then((result) => {})
  263. .catch((err) => {});
  264. },
  265. resetPageConfig(obj) {
  266. let t = {
  267. pageSize: 10,
  268. pagerCount: 5,
  269. currentPage: 1,
  270. pageSizes: [5, 10, 20, 30],
  271. total: 0,
  272. currentChange: (val) => {
  273. this.handlePageChange(val);
  274. },
  275. handleSizeChange: (val) => {
  276. this.handleSizeChange(val);
  277. },
  278. };
  279. if (obj != null || obj != undefined) {
  280. for (const key in obj) {
  281. t[key] = obj[key];
  282. }
  283. this.paginationData = t;
  284. }
  285. },
  286. getListData(obj) {
  287. let that = this;
  288. return new Promise((resolve, reject) => {
  289. api
  290. .getSecurityInfoConfiguration(obj)
  291. .then((result) => {
  292. if (result.data.code == 0) {
  293. // "company": null,
  294. // "company_id": null,
  295. // "department": null,
  296. // "dept_id": null,
  297. // "duty_time": "{'start_time': '2023-1-10 20:00:00', end_time: '2023-1-20 20:00:00'}",
  298. // "id": 2,
  299. // "name": "\u5f20\u707f",
  300. // "phone": "010-68799999-6688",
  301. // "photo": "/images/0399.png",
  302. // "register_time": "2023-03-08 13:45:34",
  303. // "responsibility_range": "\u5b89\u9632\u4eba\u5458",
  304. // "scope": null,
  305. // "status": "1",
  306. // "type": 1,
  307. // "work_number": "0399"
  308. let tableData = result.data.data.staff_list;
  309. this.tableData = tableData.map((item) => {
  310. // item.photo = "/api" + item.photo;
  311. item.photo =
  312. "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png";
  313. return item;
  314. });
  315. that.paginationData.total = tableData.length;
  316. resolve();
  317. } else {
  318. reject();
  319. }
  320. })
  321. .catch((err) => {
  322. reject();
  323. });
  324. });
  325. },
  326. getListAfterUpdate() {
  327. this.resetPageConfig({
  328. currentPage: 1,
  329. });
  330. this.handlePageChange(1);
  331. },
  332. openHistory() {
  333. this.$refs.historyPeople.dialogVisible = true;
  334. },
  335. },
  336. watch: {
  337. itemInfo() {
  338. this.resetPageConfig({
  339. currentPage: 1,
  340. });
  341. this.handlePageChange(1);
  342. },
  343. },
  344. };
  345. </script>
  346. <style lang="less" scoped>
  347. .header_container {
  348. position: relative;
  349. width: 100%;
  350. height: 60px;
  351. margin-top: 10px;
  352. .el-breadcrumb {
  353. line-height: 60px;
  354. font-size: 20px;
  355. }
  356. .el-button {
  357. height: 30px;
  358. width: 100px;
  359. padding: 5px;
  360. }
  361. }
  362. .func_container {
  363. width: 100%;
  364. height: 40px;
  365. margin-top: 10px;
  366. .create {
  367. float: left;
  368. }
  369. .history {
  370. float: right;
  371. }
  372. }
  373. .people_table {
  374. height: 650px;
  375. width: 100%;
  376. margin-top: 10px;
  377. }
  378. </style>