index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <div>
  3. <basic-container v-show="isShow">
  4. <el-row>
  5. <el-col :span="5">
  6. <div class="box">
  7. <el-scrollbar>
  8. <basic-container>
  9. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"
  10. style="height: 80vh;" />
  11. </basic-container>
  12. </el-scrollbar>
  13. </div>
  14. </el-col>
  15. <el-col :span="19">
  16. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page"
  17. :search.sync="query" v-model="form" id="out-table" :header-cell-class-name="headerClassName"
  18. ref="crud" @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset"
  19. @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
  20. @refresh-change="refreshChange" @resetColumn="resetColumn('crud', 'option', 'optionBack', 441)"
  21. @saveColumn="saveColumn('crud', 'option', 'optionBack', 441)" @on-load="onLoad">
  22. <template slot="menu" slot-scope="{ row, index }">
  23. <el-button size="small" icon="el-icon-edit" type="text" @click="rowEdit(row)">编辑</el-button>
  24. <el-button size="small" icon="el-icon-delete" type="text"
  25. @click="rowDel(row, index)">删除</el-button>
  26. </template>
  27. <template slot="billNo" slot-scope="{ row }">
  28. <span style="color: #1e9fff;cursor: pointer;" @click="rowEdit(row)">{{ row.billNo }}</span>
  29. </template>
  30. <template slot="menuLeft">
  31. <el-button type="warning" size="small" @click="outExport">导 出
  32. </el-button>
  33. </template>
  34. </avue-crud>
  35. </el-col>
  36. </el-row>
  37. </basic-container>
  38. <detailsPage v-if="!isShow" :detailData="detailData" @goBack="goBack"></detailsPage>
  39. </div>
  40. </template>
  41. <script>
  42. import { getList, remove } from "@/api/iosBasicData/humanResources/employees";
  43. import detailsPage from "./detailsPage";
  44. import { getDeptLazyTree } from "@/api/system/dept";
  45. import { getToken } from "@/util/auth";
  46. export default {
  47. data() {
  48. return {
  49. detailData: {},
  50. isShow: true,
  51. form: {},
  52. query: {},
  53. loading: false,
  54. page: {
  55. pageSize: 10,
  56. currentPage: 1,
  57. total: 0,
  58. },
  59. treeDeptName: '',
  60. treeData: [],
  61. treeOption: {
  62. nodeKey: 'id',
  63. lazy: true,
  64. treeLoad: function (node, resolve) {
  65. const parentId = (node.level === 0) ? 0 : node.data.id;
  66. getDeptLazyTree(parentId).then(res => {
  67. resolve(res.data.data.map(item => {
  68. return {
  69. ...item,
  70. leaf: !item.hasChildren
  71. }
  72. }))
  73. });
  74. },
  75. addBtn: false,
  76. menu: false,
  77. size: 'small',
  78. props: {
  79. labelText: '标题',
  80. label: 'title',
  81. value: 'value',
  82. children: 'children'
  83. }
  84. },
  85. selectionList: [],
  86. option: {},
  87. optionBack: {
  88. height: 'auto',
  89. calcHeight: 30,
  90. menuWidth: 120,
  91. searchShow: true,
  92. searchMenuSpan: 6,
  93. border: true,
  94. index: true,
  95. addBtn: false,
  96. viewBtn: false,
  97. editBtn: false,
  98. delBtn: false,
  99. searchIcon: true,
  100. searchIndex: 3,
  101. column: [
  102. {
  103. label: "单据编号",
  104. prop: "billNo",
  105. overHidden: true,
  106. },
  107. {
  108. label: "制单日期",
  109. prop: "createTime",
  110. type: "date",
  111. // search: true,
  112. searchProp: "createTimeList",
  113. unlinkPanels: true,
  114. searchRange: true,
  115. format: "yyyy-MM-dd",
  116. valueFormat: "yyyy-MM-dd HH:mm:ss",
  117. searchDefaultTime: ["00:00:00", "23:59:59"],
  118. overHidden: true,
  119. },
  120. {
  121. label: '员工编号',
  122. prop: "staffNo",
  123. search: true,
  124. overHidden: true,
  125. },
  126. {
  127. label: '员工姓名',
  128. prop: "cname",
  129. search: true,
  130. overHidden: true,
  131. },
  132. // {
  133. // label: "*部门*",
  134. // prop: "goodsValue",
  135. // overHidden: true,
  136. // },
  137. // {
  138. // label: '*就职日期*',
  139. // prop: "paymentInUsd",
  140. // overHidden: true,
  141. // },
  142. {
  143. label: '性别',
  144. prop: "gender",
  145. overHidden: true,
  146. },
  147. {
  148. label: '年龄',
  149. prop: "age",
  150. overHidden: true,
  151. },
  152. {
  153. label: '出生日期',
  154. prop: "dateOfBirth",
  155. overHidden: true,
  156. },
  157. {
  158. label: '身份证号',
  159. prop: "idNumber",
  160. search: true,
  161. overHidden: true,
  162. },
  163. {
  164. label: '学历',
  165. prop: "educationalBackground",
  166. overHidden: true,
  167. },
  168. {
  169. label: "专业",
  170. prop: "major",
  171. overHidden: true
  172. },
  173. {
  174. label: "职务",
  175. prop: "position",
  176. overHidden: true,
  177. type: 'select',
  178. filterable: true,
  179. dicUrl: "/api/blade-system/dict-biz/dictionary?code=position",
  180. props: {
  181. label: 'dictValue',
  182. value: 'dictKey',
  183. },
  184. },
  185. // {
  186. // label: "*何时参加工作*",
  187. // prop: "participateInWorkDate",
  188. // width:100,
  189. // overHidden: true
  190. // },
  191. {
  192. label: "家庭住址",
  193. prop: "homeAddress",
  194. overHidden: true
  195. },
  196. {
  197. label: "家庭电话",
  198. prop: "homePhone",
  199. overHidden: true
  200. },
  201. {
  202. label: "民族",
  203. prop: "nationality",
  204. overHidden: true
  205. },
  206. {
  207. label: "政治面貌",
  208. prop: "politicalStatus",
  209. overHidden: true
  210. },
  211. // {
  212. // label: "*人员身份*",
  213. // prop: "remarks",
  214. // overHidden: true
  215. // },
  216. {
  217. label: "社保编号",
  218. prop: "socialSecurityNo",
  219. overHidden: true
  220. },
  221. {
  222. label: "房屋公积金",
  223. prop: "providentFund",
  224. width: 100,
  225. overHidden: true
  226. },
  227. {
  228. label: "合同起始日",
  229. prop: "contractPeriodStart",
  230. width: 100,
  231. overHidden: true
  232. },
  233. {
  234. label: "合同截止日",
  235. prop: "contractPeriodEnd",
  236. width: 100,
  237. overHidden: true
  238. },
  239. {
  240. label: "参加工作时间",
  241. prop: "participateInWorkDate",
  242. width: 100,
  243. overHidden: true
  244. },
  245. {
  246. label: "行政部门",
  247. prop: "administrativeDepartmentName",
  248. overHidden: true
  249. }
  250. ]
  251. },
  252. data: [],
  253. };
  254. },
  255. components: {
  256. detailsPage,
  257. },
  258. async created() {
  259. this.option = await this.getColumnData(this.getColumnName(440), this.optionBack);
  260. },
  261. activated() {
  262. setTimeout(() => {
  263. if (this.$route.query.billNo || this.$route.query.params) {
  264. this.isShow = false
  265. this.$store.commit("IN_FIRSTSET_DETAIL");
  266. }
  267. }, 100);
  268. },
  269. methods: {
  270. outExport() {
  271. this.$confirm('是否导出当前所有数据?', '提示', {
  272. confirmButtonText: '确定',
  273. cancelButtonText: '取消',
  274. type: 'warning'
  275. }).then(() => {
  276. let obj = {}
  277. obj = {
  278. ...this.query,
  279. whetherEmployedOrNot: 0,
  280. }
  281. const routeData = this.$router.resolve({
  282. path: '/api/blade-los/bstaffinformation/exportStaff', //跳转目标窗口的地址
  283. query: {
  284. 'Blade-Auth': getToken(),
  285. ...obj //括号内是要传递给新窗口的参数
  286. }
  287. })
  288. window.open(routeData.href.slice(1, routeData.href.length));
  289. })
  290. },
  291. nodeClick(data) {
  292. this.query.administrativeDepartmentName = data.title;
  293. this.page.currentPage = 1;
  294. this.onLoad(this.page, this.query);
  295. },
  296. addButton() {
  297. this.isShow = false
  298. },
  299. rowEdit(row) {
  300. this.detailData = {
  301. id: row.id
  302. };
  303. this.isShow = false
  304. },
  305. // 编辑
  306. inEdit(row) {
  307. },
  308. // 删除
  309. rowDel(row, index) {
  310. this.$confirm("确定将选择数据删除?", {
  311. confirmButtonText: "确定",
  312. cancelButtonText: "取消",
  313. type: "warning"
  314. }).then(() => {
  315. remove({ ids: row.id }).then(res => {
  316. this.onLoad(this.page, this.query);
  317. this.$message.success("成功删除");
  318. })
  319. })
  320. },
  321. searchReset() {
  322. this.query = this.$options.data().query;
  323. this.onLoad(this.page);
  324. },
  325. // 搜索按钮点击
  326. searchChange(params, done) {
  327. this.page.currentPage = 1;
  328. this.onLoad(this.page, this.query);
  329. done();
  330. },
  331. selectionChange(list) {
  332. this.selectionList = list;
  333. },
  334. currentChange(currentPage) {
  335. this.page.currentPage = currentPage;
  336. },
  337. sizeChange(pageSize) {
  338. this.page.pageSize = pageSize;
  339. },
  340. refreshChange() {
  341. this.onLoad(this.page, this.query);
  342. },
  343. onLoad(page, params = {}) {
  344. let obj = {}
  345. obj = {
  346. ...Object.assign(params, this.query),
  347. whetherEmployedOrNot: 0,
  348. }
  349. this.loading = true;
  350. getList(page.currentPage, page.pageSize, obj).then(res => {
  351. this.data = res.data.data.records;
  352. this.page.total = res.data.data.total;
  353. this.$nextTick(() => {
  354. this.$refs.crud.doLayout();
  355. this.$refs.crud.dicInit();
  356. });
  357. }).finally(() => {
  358. this.loading = false;
  359. })
  360. },
  361. // 详情的返回列表
  362. goBack() {
  363. // 初始化数据
  364. if (JSON.stringify(this.$route.query) != "{}") {
  365. this.$router.$avueRouter.closeTag();
  366. this.$router.push({
  367. path: "/iosBasicData/humanResources/employees/index"
  368. });
  369. }
  370. this.detailData = {}
  371. this.isShow = true;
  372. this.onLoad(this.page, this.search);
  373. },
  374. //自定义列保存
  375. async saveColumn(ref, option, optionBack, code) {
  376. /**
  377. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  378. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  379. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  380. */
  381. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  382. if (inSave) {
  383. this.$message.success("保存成功");
  384. //关闭窗口
  385. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  386. this.searchReset()
  387. }
  388. },
  389. //自定义列重置
  390. async resetColumn(ref, option, optionBack, code) {
  391. this[option] = this[optionBack];
  392. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  393. if (inSave) {
  394. this.$message.success("重置成功");
  395. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  396. this.searchReset()
  397. }
  398. },
  399. // 更改表格颜色
  400. headerClassName(tab) {
  401. //颜色间隔
  402. let back = ""
  403. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  404. if (tab.columnIndex % 2 === 0) {
  405. back = "back-one"
  406. } else if (tab.columnIndex % 2 === 1) {
  407. back = "back-two"
  408. }
  409. }
  410. return back;
  411. },
  412. }
  413. }
  414. </script>
  415. <style scoped>
  416. ::v-deep#out-table .back-one {
  417. background: #ecf5ff !important;
  418. text-align: center;
  419. }
  420. ::v-deep#out-table .back-two {
  421. background: #ecf5ff !important;
  422. text-align: center;
  423. }
  424. .pointerClick {
  425. cursor: pointer;
  426. color: #1e9fff;
  427. }
  428. ::v-deep .el-col-md-8 {
  429. width: 24.33333%;
  430. }
  431. </style>