index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <template-page v-if="showTable" ref="pageRef" :get-list="[getList, getList1, getList2][pageLevel]"
  3. :exportList="[undefined, exportList1, exportList2][pageLevel]"
  4. :options-evens-group="[optionsEvensGroup0, optionsEvensGroup1, optionsEvensGroup2][pageLevel]"
  5. :operation="([operation0, operation1, operation2][pageLevel])()"
  6. :expCode="['', 'workerExp', 'detailExp'][pageLevel]" :table-attributes="tableAttributes" :table-events="tableEvents"
  7. :moreParameters="moreParameters" :column-parsing="columnParsing">
  8. <div class="cartographer_big">
  9. <el-dialog title="发放" width="100%" :modal="false" :visible.sync="formBool" :before-close="handleClose">
  10. <zj-page-container v-if="formBool">
  11. <zj-page-fill class="neibuview">
  12. <zj-form-container ref="formRef" :form-data="formData" :form-attributes="{ size: 'mini' }">
  13. <zj-form-module title="发放信息" label-width="130px" :form-data="formData" :form-items="formItems" />
  14. </zj-form-container>
  15. </zj-page-fill>
  16. <div>
  17. <div style="box-sizing: border-box; padding: 10px">
  18. <el-button size="mini" @click="handleClose">取 消</el-button>
  19. <el-button size="mini" @click="formConfirm" type="primary">确 定</el-button>
  20. </div>
  21. </div>
  22. </zj-page-container>
  23. </el-dialog>
  24. </div>
  25. </template-page>
  26. </template>
  27. <script>
  28. import TemplatePage from '@/components/template/template-page-1.vue'
  29. import import_mixin from '@/components/template/import_mixin.js'
  30. import operation_mixin from '@/components/template/operation_mixin.js'
  31. import ImageUpload from '@/components/file-upload'
  32. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  33. import {
  34. settleExpenseList,
  35. settleExpenseListExport,
  36. settleMonthWagesGatherList,
  37. settleMonthWagesList,
  38. settleMonthWagesListExport,
  39. settleMonthWagesBatchReject,
  40. settleMonthWagesBatchSend,
  41. settleMonthWagesWorkerBatchSend
  42. } from "@/api/costPerDimension";
  43. import { tableDataParsing } from "@/utils/common.js"
  44. export default {
  45. components: { TemplatePage, ImageUpload },
  46. mixins: [import_mixin, operation_mixin],
  47. data() {
  48. return {
  49. // 表格属性
  50. tableAttributes: {
  51. // 启用勾选列
  52. selectColumn: true,
  53. selectable: this.selectable
  54. },
  55. // 表格事件
  56. tableEvents: {
  57. 'selection-change': this.selectionChange
  58. },
  59. // 勾选选中行
  60. recordSelected: [],
  61. pageLevel: 0,
  62. showTable: true,
  63. monthItem: {},
  64. workerItem: {},
  65. formData: {
  66. sendDate: "",
  67. fileUrl: [],
  68. remark: ""
  69. },
  70. formBool: false,
  71. evaluationColumns: [],
  72. evaluationData: []
  73. }
  74. },
  75. computed: {
  76. optionsEvensGroup0() {
  77. return [
  78. [
  79. [
  80. this.optionsEvensAuth("monthBatchRelease", {
  81. click: () => {
  82. if (this.recordSelected.length === 0) {
  83. this.$message.warning('请勾选工单')
  84. return
  85. }
  86. this.getTableJieGou()
  87. this.formBool = true
  88. }
  89. })
  90. ],
  91. [
  92. this.optionsEvensAuth("monthBatchRejection", {
  93. click: () => {
  94. if (this.recordSelected.length === 0) {
  95. this.$message.warning('请勾选工单')
  96. return
  97. }
  98. this.$confirm('是否确定驳回', '提示', {
  99. confirmButtonText: '确定',
  100. cancelButtonText: '取消',
  101. type: 'warning'
  102. }).then(() => {
  103. settleMonthWagesBatchReject(this.recordSelected.map(item => item.id)).then(res => {
  104. this.$message({
  105. type: 'success',
  106. message: '操作成功!'
  107. })
  108. this.$refs?.pageRef?.refreshList()
  109. })
  110. }).catch(() => {
  111. });
  112. }
  113. })
  114. ],
  115. ]
  116. ]
  117. },
  118. optionsEvensGroup1() {
  119. return [
  120. [
  121. [
  122. {
  123. name: "返回月度汇总页面",
  124. click: () => {
  125. this.pageLevel = 0
  126. }
  127. }
  128. ],
  129. ],
  130. [
  131. [
  132. this.optionsEvensAuth("workerBatchRelease", {
  133. click: () => {
  134. if (this.recordSelected.length === 0) {
  135. this.$message.warning('请勾选工单')
  136. return
  137. }
  138. this.getTableJieGou()
  139. this.formBool = true
  140. }
  141. })
  142. ],
  143. ]
  144. ]
  145. },
  146. optionsEvensGroup2() {
  147. return [
  148. [
  149. [
  150. {
  151. name: "返回师傅汇总页面",
  152. click: () => {
  153. this.pageLevel = 1
  154. }
  155. }
  156. ],
  157. ],
  158. ]
  159. },
  160. // 更多参数
  161. moreParameters() {
  162. return []
  163. },
  164. formItems() {
  165. return [{
  166. name: 'el-date-picker',
  167. md: 6,
  168. attributes: {
  169. type: "date",
  170. 'value-format': 'yyyy-MM-dd HH:mm:ss',
  171. },
  172. formItemAttributes: {
  173. label: '发放日期',
  174. prop: 'sendDate',
  175. rules: [...required]
  176. }
  177. }, {
  178. md: 24,
  179. name: 'slot-component',
  180. formItemAttributes: {
  181. label: '发放凭证',
  182. prop: 'fileUrl',
  183. rules: []
  184. },
  185. attributes: {},
  186. render: (h, { props, onInput }) => {
  187. return (
  188. <ImageUpload fileList={this.formData.fileUrl} limit={1} fileType={["image"]} />
  189. )
  190. }
  191. }, {
  192. name: 'el-input',
  193. md: 24,
  194. attributes: {},
  195. formItemAttributes: {
  196. label: '备注',
  197. prop: 'remark',
  198. rules: []
  199. }
  200. }, {
  201. md: 24,
  202. name: 'slot-component',
  203. attributes: {},
  204. formItemAttributes: {
  205. label: '',
  206. 'label-width': '0px',
  207. prop: '',
  208. },
  209. render: (h, { props, onInput }) => {
  210. return <hr />
  211. }
  212. }, {
  213. md: 6,
  214. name: 'slot-component',
  215. attributes: {},
  216. formItemAttributes: {
  217. label: '结算金额合计',
  218. prop: '',
  219. },
  220. render: (h, { props, onInput }) => {
  221. return <div>{this.evaluationData.map(item => Number(item.settleAmount)).reduce((accumulator, currentValue) => accumulator + currentValue, 0)}</div>
  222. }
  223. }, {
  224. md: 6,
  225. name: 'slot-component',
  226. attributes: {},
  227. formItemAttributes: {
  228. label: '发放人数',
  229. prop: '',
  230. },
  231. render: (h, { props, onInput }) => {
  232. return <div>{this.pageLevel ? this.evaluationData.length : this.evaluationData.map(item => Number(item.settleByCount)).reduce((accumulator, currentValue) => accumulator + currentValue, 0)}</div>
  233. }
  234. }, {
  235. md: 24,
  236. name: 'slot-component',
  237. attributes: {},
  238. formItemAttributes: {
  239. label: '',
  240. 'label-width': '0px',
  241. prop: '',
  242. },
  243. render: (h, { props, onInput }) => {
  244. return <zj-table
  245. columns={this.evaluationColumns}
  246. table-data={this.evaluationData}
  247. />
  248. }
  249. }]
  250. }
  251. },
  252. watch: {
  253. pageLevel() {
  254. this.showTable = false
  255. this.$nextTick(() => {
  256. this.showTable = true
  257. })
  258. }
  259. },
  260. methods: {
  261. getList: settleMonthWagesGatherList,
  262. getList1(p, cb) {
  263. var pam = JSON.parse(JSON.stringify(p))
  264. try {
  265. pam.params.push({ "param": "a.settle_month_wages_id", "compare": "=", "value": this.monthItem.id })
  266. cb && cb(pam)
  267. return settleMonthWagesList(pam)
  268. } catch (err) {
  269. }
  270. },
  271. exportList1: settleMonthWagesListExport,
  272. getList2(p, cb) {
  273. var pam = JSON.parse(JSON.stringify(p))
  274. try {
  275. pam.params.push(
  276. { "param": "a.settle_month_wages_id", "compare": "=", "value": this.monthItem.id },
  277. { "param": "month_settle_worker_id", "compare": "=", "value": this.workerItem.workerId }
  278. )
  279. cb && cb(pam)
  280. return settleExpenseList(pam)
  281. } catch (err) {
  282. }
  283. },
  284. exportList2: settleExpenseListExport,
  285. selectable(row, index) {
  286. return !["END"].includes(Object.entries(row.selectMapData.status).find(([key, val]) => val == row.status)?.[0])
  287. },
  288. operation0() {
  289. return this.operationBtn({
  290. monthRelease: {
  291. conditions: ({ row, index, column }) => {
  292. return row.status != "END"
  293. },
  294. click: ({ row, index, column }) => {
  295. this.recordSelected = [{ ...row }]
  296. this.getTableJieGou()
  297. this.formBool = true
  298. }
  299. },
  300. monthRejection: {
  301. prompt: "是否确定驳回?",
  302. conditions: ({ row, index, column }) => {
  303. return row.status == "NOT"
  304. },
  305. click: ({ row, index, column }) => {
  306. settleMonthWagesBatchReject([row.id]).then(res => {
  307. this.$message({
  308. type: 'success',
  309. message: '操作成功!'
  310. })
  311. this.$refs?.pageRef?.refreshList()
  312. })
  313. }
  314. },
  315. monthDetails: {
  316. click: ({ row, index, column }) => {
  317. this.monthItem = row
  318. this.pageLevel = 1
  319. }
  320. }
  321. })
  322. },
  323. operation1() {
  324. return this.operationBtn({
  325. workerRelease: {
  326. conditions: ({ row, index, column }) => {
  327. return row.status != "END"
  328. },
  329. click: ({ row, index, column }) => {
  330. this.recordSelected = [{ ...row }]
  331. this.getTableJieGou()
  332. this.formBool = true
  333. }
  334. },
  335. workerDetails: {
  336. click: ({ row, index, column }) => {
  337. this.workerItem = row
  338. this.pageLevel = 2
  339. }
  340. },
  341. })
  342. },
  343. operation2() {
  344. return undefined
  345. },
  346. // 表格列解析渲染数据更改
  347. columnParsing(item, defaultData) {
  348. return defaultData
  349. },
  350. // 监听勾选变化
  351. selectionChange(data) {
  352. this.recordSelected = data
  353. },
  354. handleClose() {
  355. this.recordSelected = []
  356. this.evaluationColumns = []
  357. this.evaluationColumns = []
  358. this.$refs?.pageRef?.refreshList()
  359. this.$data.formData = this.$options.data().formData
  360. this.formBool = false
  361. },
  362. formConfirm() {
  363. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  364. if (valid) {
  365. ; ([settleMonthWagesBatchSend, settleMonthWagesWorkerBatchSend][this.pageLevel])({
  366. ...this.formData,
  367. fileUrl: this.formData.fileUrl.length ? this.formData.fileUrl[0]?.url : "",
  368. ids: this.recordSelected.map(item => item.id),
  369. settleMonthWagesId: this.monthItem.id || undefined
  370. }).then(res => {
  371. this.$message({
  372. type: 'success',
  373. message: '发放成功!'
  374. })
  375. this.handleClose()
  376. })
  377. }
  378. })
  379. },
  380. getTableJieGou() {
  381. ; (([settleMonthWagesGatherList, settleMonthWagesList])[this.pageLevel])({ "pageNum": 1, "pageSize": 1, "params": [] }).then(res => {
  382. this.evaluationColumns = tableDataParsing(res.fieldBeans.filter(item => !~(([["aaa"], ["id", "settleMonthWagesId", "settleMonthWagesDetailId", "workerId"]])[this.pageLevel]).indexOf(item.jname))).map(item => {
  383. return item
  384. })
  385. this.$nextTick(() => {
  386. this.evaluationData = this.recordSelected.map(item => {
  387. Object.keys(item).map(key => {
  388. var val = JSON.parse(res?.fieldBeans?.find(val => val.jname == key)?.enumMap || "{}")[item[key]];
  389. if (val) item[key] = val;
  390. })
  391. return item
  392. })
  393. })
  394. })
  395. }
  396. }
  397. }
  398. </script>
  399. <style lang="scss" scoped>
  400. .neibuview {
  401. box-sizing: border-box;
  402. padding-left: 16px;
  403. ::v-deep &>.zj-page-fill-scroll {
  404. box-sizing: border-box;
  405. padding-right: 16px;
  406. &>div:nth-child(1) {
  407. margin-top: 20px;
  408. }
  409. }
  410. }
  411. </style>