engin_list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :get-list="getList"
  5. :operation="operation()"
  6. :options-evens-group="optionsEvensGroup"
  7. :export-list="exportList"
  8. :column-parsing="columnParsing"
  9. :table-attributes="tableAttributes"
  10. :table-events="tableEvents"
  11. :operation-column-width="200"
  12. :replace-or-not-map="false"
  13. >
  14. <ExamineDialog :is-show.sync="isShowExamineDialog" :examine-form.sync="examineForm" @submit="submitExamineForm" />
  15. <Popu v-if="isShowDetail || isShowForm || isShowExamine || isShowReturnForm">
  16. <EnginDetail v-if="isShowDetail" ref="refDetail" :list-item="queryItem" @backListFormDetail="backList" />
  17. <EnginExamine v-if="isShowExamine" :list-item="queryItem" @backListFormDetail="backList" />
  18. <EnginForm v-if="isShowForm" :list-item="queryItem" @backListFormDetail="backList" />
  19. <EnginReturnForm v-if="isShowReturnForm" :is-show="isShow" :list-item="queryItem" @backListFormDetail="backList" />
  20. </Popu>
  21. </template-page>
  22. </template>
  23. <script>
  24. import TemplatePage from '@/components/template/template-page-1.vue'
  25. import Popu from '@/components/template/popu.vue'
  26. import { invoiceListProjectV2, invoiceListProjectV2Export } from '@/api/supply/deliver'
  27. import { getEnginList, submitEngin, deleteEngin, abandonEngin, examineBatchEngin } from '@/api/supply/apply'
  28. import { getCategoryList, getSalesmanList } from '@/api/common'
  29. import EnginDetail from '@/views/supply/apply/components/engin_detail'
  30. import EnginExamine from '@/views/supply/apply/components/engin_examine'
  31. import EnginForm from '@/views/supply/apply/components/engin_form'
  32. import EnginReturnForm from '@/views/supply/apply/components/engin_return_form'
  33. import ExamineDialog from '@/components/Common/examine-dialog'
  34. let that
  35. export default {
  36. components: {
  37. EnginDetail,
  38. EnginExamine,
  39. EnginForm,
  40. EnginReturnForm,
  41. ExamineDialog,
  42. TemplatePage,
  43. Popu
  44. },
  45. filters: {
  46. statusFilter(val) {
  47. const obj = that.statusList.find(o => o.value == val)
  48. return obj ? obj.label : ''
  49. },
  50. orderTypeFilter(val) {
  51. const obj = that.orderTypeList.find(o => o.value == val)
  52. return obj ? obj.label : ''
  53. }
  54. },
  55. data() {
  56. return {
  57. // 事件组合
  58. optionsEvensGroup: [
  59. [
  60. [
  61. {
  62. name: '发货申请',
  63. click: () => {
  64. this.toForm()
  65. },
  66. isRole: this.$checkBtnRole('add', this.$route.meta.roles)
  67. }
  68. ]
  69. ],
  70. [
  71. [
  72. {
  73. name: '退货申请',
  74. click: () => {
  75. this.toReturnForm()
  76. },
  77. isRole: this.$checkBtnRole('refund', this.$route.meta.roles)
  78. }
  79. ]
  80. ],
  81. [
  82. [
  83. {
  84. name: '批量审批',
  85. click: async() => {
  86. if (this.recordSelected.length === 0) {
  87. this.$message.error('请选择需要批量审批的数据')
  88. return
  89. }
  90. this.batchExamine()
  91. },
  92. isRole: this.$checkBtnRole('examine', this.$route.meta.roles)
  93. }
  94. ]
  95. ]
  96. ],
  97. // 表格属性
  98. tableAttributes: {
  99. // 启用勾选列
  100. selectColumn: true
  101. },
  102. // 表格事件
  103. tableEvents: {
  104. 'selection-change': this.selectionChange
  105. },
  106. recordSelected: [],
  107. currentPage: 1, // 当前页码
  108. pageSize: 10, // 每页数量
  109. listTotal: 0, // 列表总数
  110. dataList: null, // 列表数据
  111. listLoading: false, // 列表加载loading
  112. screenForm: {
  113. // 筛选表单数据
  114. status: '',
  115. orderNum: '',
  116. warehouse: '',
  117. jxsNum: '',
  118. jxsName: '',
  119. date: [],
  120. chName: '',
  121. model: '',
  122. salesMan: '',
  123. orderType: '',
  124. mainOrderId: '',
  125. refEnginRecordNo: '',
  126. refUseUnit: '',
  127. k3ServiceId: '',
  128. categoryId: '',
  129. approvalName: '',
  130. refRegionWork: '',
  131. automaticStatus: '',
  132. createBy: ''
  133. },
  134. statusList: [
  135. { label: '已保存', value: 'SAVE' },
  136. { label: '待审核', value: 'WAIT' },
  137. { label: '审核通过', value: 'OK' },
  138. { label: '审核驳回', value: 'FAIL' },
  139. { label: '已关闭', value: 'CLOSE' }
  140. ],
  141. orderTypeList: [
  142. { label: '发货申请单', value: 1 },
  143. { label: '退货申请单', value: 2 },
  144. { label: '直调发货单', value: 3 }
  145. ],
  146. salesmanList: [],
  147. queryItem: {},
  148. isShowDetail: false,
  149. isShowExamine: false,
  150. isShowForm: false,
  151. isShowReturnForm: false,
  152. selectRow: [],
  153. multipleSelection: [],
  154. isShowExamineDialog: false,
  155. examineForm: {
  156. status: '',
  157. remark: ''
  158. },
  159. isShow: false,
  160. categoryList: [],
  161. isCustomer: JSON.parse(localStorage.getItem('supply_user')).isCustomer
  162. }
  163. },
  164. computed: {
  165. exParams() {
  166. return {
  167. id: this.screenForm.orderNum,
  168. correspondName: this.screenForm.warehouse,
  169. customerNumber: this.screenForm.jxsNum,
  170. customerName: this.screenForm.jxsName,
  171. productName: this.screenForm.chName,
  172. specification: this.screenForm.model,
  173. automaticStatus: this.screenForm.automaticStatus,
  174. startTime: this.screenForm.date ? this.screenForm.date[0] : '',
  175. endTime: this.screenForm.date ? this.screenForm.date[1] : '',
  176. examineStatus: this.screenForm.status,
  177. serviceId: this.screenForm.salesMan,
  178. k3ServiceId: this.screenForm.k3ServiceId,
  179. type: this.screenForm.orderType,
  180. mainOrderId: this.screenForm.mainOrderId,
  181. createBy: this.screenForm.createBy,
  182. refEnginRecordNo: this.screenForm.refEnginRecordNo,
  183. refUseUnit: this.screenForm.refUseUnit,
  184. categoryId: this.screenForm.categoryId,
  185. approvalName: this.screenForm.approvalName,
  186. refRegionWork: this.screenForm.refRegionWork
  187. }
  188. }
  189. },
  190. watch: {
  191. multipleSelection(data) {
  192. // 监听选中状态
  193. this.selectRow = []
  194. if (data.length > 0) {
  195. data.forEach((item, index) => {
  196. this.selectRow.push(item.id)
  197. })
  198. }
  199. }
  200. },
  201. beforeCreate() {
  202. that = this
  203. },
  204. created() {
  205. // this.getSalesmanList()
  206. // this.getList()
  207. // this.getCategoryList()
  208. // this.isShow = false
  209. // if (this.$route.query && this.$route.query.isShow) {
  210. // this.isShow = this.$route.query.isShow
  211. // this.toReturnForm()
  212. // }
  213. },
  214. // activated() {
  215. // // keepAlice activated 主要是从发货单汇总调用退货申请按钮
  216. // this.isShow = false
  217. // if(this.$route.query && this.$route.query.isShow){
  218. // this.isShow = this.$route.query.isShow
  219. // this.toReturnForm()
  220. // }
  221. // },
  222. methods: {
  223. // 列表请求函数
  224. getList(...p) {
  225. const params = {
  226. ...p[0]
  227. }
  228. return invoiceListProjectV2(params)
  229. },
  230. // 列表导出函数
  231. exportList: invoiceListProjectV2Export,
  232. // 表格列解析渲染数据更改
  233. columnParsing(item, defaultData) {
  234. return defaultData
  235. },
  236. // 监听勾选变化
  237. selectionChange(data) {
  238. this.recordSelected = data
  239. },
  240. fieldBeansHook(val) {
  241. if (this.isCustomer !== '') {
  242. const res = val.filter(
  243. v => v.jname !== 'refPowerCategory' && v.jname !== 'geLiInerNote' && v.jname !== 'geLiNote'
  244. )
  245. return res
  246. } else {
  247. return val
  248. }
  249. },
  250. operation() {
  251. return (h, { row, index, column }) => {
  252. return (
  253. <div class='operation-btns'>
  254. {this.$checkBtnRole('apply', this.$route.meta.roles) &&
  255. ((!this.isCustomer &&
  256. !row.automaticStatus &&
  257. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL')) ||
  258. (this.isCustomer &&
  259. !row.automaticStatus &&
  260. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  261. row.type != 2) ||
  262. (!this.isCustomer &&
  263. row.automaticStatus &&
  264. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  265. row.type === 2)) ? (
  266. <el-popconfirm
  267. onOnConfirm={async() => {
  268. this.handleSubmit(row.id, 'WAIT')
  269. }}
  270. title='是否确定需要申请该项内容?'
  271. >
  272. <el-button slot='reference' size='mini' type='text'>
  273. 申请
  274. </el-button>
  275. </el-popconfirm>
  276. ) : (
  277. ''
  278. )}
  279. {this.$checkBtnRole('apply', this.$route.meta.roles) &&
  280. ((!this.isCustomer && !row.automaticStatus && row.examineStatus === 'WAIT') ||
  281. (this.isCustomer && !row.automaticStatus && row.examineStatus === 'WAIT' && row.type != 2) ||
  282. (!this.isCustomer && row.automaticStatus && row.examineStatus === 'WAIT' && row.type == 2)) ? (
  283. <el-popconfirm
  284. onOnConfirm={async() => {
  285. this.handleSubmit(row.id, 'SAVE')
  286. }}
  287. title='是否确定需要撤回该项内容?'
  288. >
  289. <el-button slot='reference' size='mini' type='text'>
  290. 撤回
  291. </el-button>
  292. </el-popconfirm>
  293. ) : (
  294. ''
  295. )}
  296. {this.$checkBtnRole('examine', this.$route.meta.roles) &&
  297. ((!this.isCustomer && !row.automaticStatus && row.examineStatus === 'OK') ||
  298. (this.isCustomer && !row.automaticStatus && row.examineStatus === 'OK' && row.type != 2) ||
  299. (!this.isCustomer && row.automaticStatus && row.examineStatus === 'OK' && row.type == 2)) ? (
  300. <el-popconfirm
  301. onOnConfirm={async() => {
  302. this.handleAbandon(row.id)
  303. }}
  304. title='是否确定需要弃审该项内容?'
  305. >
  306. <el-button slot='reference' size='mini' type='text'>
  307. 弃审
  308. </el-button>
  309. </el-popconfirm>
  310. ) : (
  311. ''
  312. )}
  313. {this.$checkBtnRole('edit', this.$route.meta.roles) &&
  314. (!row.automaticStatus &&
  315. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  316. row.type === 1) || (this.isCustomer &&
  317. !row.automaticStatus &&
  318. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  319. row.type != 2 &&
  320. row.type !== 1) ? (
  321. <el-button
  322. size='mini'
  323. type='text'
  324. onClick={async() => {
  325. this.toForm(row)
  326. }}
  327. >
  328. 编辑
  329. </el-button>
  330. ) : (
  331. ''
  332. )}
  333. {this.$checkBtnRole('edit', this.$route.meta.roles) &&
  334. ((!this.isCustomer &&
  335. !row.automaticStatus &&
  336. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  337. row.type === 2) ||
  338. (!this.isCustomer &&
  339. row.automaticStatus &&
  340. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  341. row.type === 2)) ? (
  342. <el-button
  343. size='mini'
  344. type='text'
  345. onClick={async() => {
  346. this.toReturnForm(row)
  347. }}
  348. >
  349. 编辑
  350. </el-button>
  351. ) : (
  352. ''
  353. )}
  354. {this.$checkBtnRole('examine', this.$route.meta.roles) &&
  355. ((!this.isCustomer && !row.automaticStatus && row.examineStatus === 'WAIT') ||
  356. (this.isCustomer && !row.automaticStatus && row.examineStatus === 'WAIT' && row.type != 2) ||
  357. (!this.isCustomer && row.automaticStatus && row.examineStatus === 'WAIT' && row.type == 2)) ? (
  358. <el-button
  359. size='mini'
  360. type='text'
  361. onClick={async() => {
  362. this.toExamine(row)
  363. }}
  364. >
  365. 审核
  366. </el-button>
  367. ) : (
  368. ''
  369. )}
  370. <el-button
  371. size='mini'
  372. type='text'
  373. onClick={async() => {
  374. this.toDetail(row)
  375. }}
  376. >
  377. 详情
  378. </el-button>
  379. {this.$checkBtnRole('del', this.$route.meta.roles) &&
  380. ((!this.isCustomer && !row.automaticStatus && row.examineStatus !== 'OK') ||
  381. (this.isCustomer && !row.automaticStatus && row.examineStatus !== 'OK' && row.type != 2) ||
  382. (!this.isCustomer && row.automaticStatus && row.examineStatus !== 'OK' && row.type == 2)) ? (
  383. <el-popconfirm
  384. onOnConfirm={async() => {
  385. this.handleDelete(row.id)
  386. }}
  387. title='是否确定需要删除该项内容?'
  388. >
  389. <el-button slot='reference' size='mini' type='text'>
  390. 删除
  391. </el-button>
  392. </el-popconfirm>
  393. ) : (
  394. ''
  395. )}
  396. </div>
  397. )
  398. }
  399. },
  400. // 获取业务员列表
  401. getSalesmanList() {
  402. getSalesmanList({
  403. pageNum: 1,
  404. pageSize: -1,
  405. isCustomer: 0,
  406. status: true
  407. }).then(res => {
  408. this.salesmanList = res.data.records
  409. })
  410. },
  411. // 查询列表
  412. // getList() {
  413. // this.listLoading = true
  414. // const params = {
  415. // pageNum: this.currentPage,
  416. // pageSize: this.pageSize,
  417. // id: this.screenForm.orderNum,
  418. // correspondName: this.screenForm.warehouse,
  419. // customerNumber: this.screenForm.jxsNum,
  420. // customerName: this.screenForm.jxsName,
  421. // productName: this.screenForm.chName,
  422. // specification: this.screenForm.model,
  423. // startTime: this.screenForm.date ? this.screenForm.date[0] : '',
  424. // endTime: this.screenForm.date ? this.screenForm.date[1] : '',
  425. // examineStatus: this.screenForm.status,
  426. // createBy: this.screenForm.createBy,
  427. // automaticStatus: this.screenForm.automaticStatus,
  428. // serviceId: this.screenForm.salesMan,
  429. // k3ServiceId: this.screenForm.k3ServiceId,
  430. // type: this.screenForm.orderType,
  431. // mainOrderId: this.screenForm.mainOrderId,
  432. // refEnginRecordNo: this.screenForm.refEnginRecordNo,
  433. // refUseUnit: this.screenForm.refUseUnit,
  434. // categoryId: this.screenForm.categoryId,
  435. // approvalName: this.screenForm.approvalName,
  436. // refRegionWork: this.screenForm.refRegionWork
  437. // }
  438. // getEnginList(params).then(res => {
  439. // res.data.records.forEach(item => {
  440. // item.sums1 = ['refundableQty']
  441. // item.sums2 = ['singlePayPrice', 'payAmount', 'payRebateAmount', 'totalDiscAmount']
  442. // })
  443. // this.dataList = res.data.records
  444. // this.listTotal = res.data.total
  445. // this.listLoading = false
  446. // })
  447. // },
  448. // 提交筛选表单
  449. submitScreenForm() {
  450. this.currentPage = 1
  451. this.getList()
  452. },
  453. // 重置筛选表单
  454. resetScreenForm() {
  455. this.$refs.screenForm.resetFields()
  456. this.currentPage = 1
  457. this.getList()
  458. },
  459. // 更改每页数量
  460. handleSizeChange(val) {
  461. this.pageSize = val
  462. this.currentPage = 1
  463. this.getList()
  464. },
  465. // 更改当前页
  466. handleCurrentChange(val) {
  467. this.currentPage = val
  468. this.getList()
  469. },
  470. // 进入表单
  471. toForm(item) {
  472. this.queryItem = item
  473. this.isShowForm = true
  474. },
  475. // 进入表单
  476. toReturnForm(item) {
  477. this.queryItem = item
  478. this.isShowReturnForm = true
  479. },
  480. // 进入审批
  481. toExamine(item) {
  482. this.queryItem = item
  483. this.isShowExamine = true
  484. },
  485. // 进入详情
  486. toDetail(item) {
  487. this.queryItem = item
  488. this.isShowDetail = true
  489. this.$nextTick(() => {
  490. this.$refs.refDetail.initPrint()
  491. })
  492. },
  493. backList() {
  494. this.queryItem = {}
  495. this.isShowDetail = false
  496. this.isShowExamine = false
  497. this.isShowForm = false
  498. this.isShowReturnForm = false
  499. this.$refs.pageRef.refreshList()
  500. },
  501. handleDelete(id) {
  502. deleteEngin({ id }).then(res => {
  503. this.$successMsg()
  504. // this.getList()
  505. this.$refs.pageRef.refreshList()
  506. })
  507. },
  508. // 申请/撤回
  509. handleSubmit(id, examineStatus) {
  510. submitEngin({ id, examineStatus }).then(res => {
  511. this.$successMsg()
  512. // this.getList()
  513. this.$refs.pageRef.refreshList()
  514. })
  515. },
  516. // 弃审
  517. handleAbandon(id) {
  518. abandonEngin({ id }).then(res => {
  519. this.$successMsg()
  520. // this.getList()
  521. this.$refs.pageRef.refreshList()
  522. })
  523. },
  524. handleSelectionChange(val) {
  525. this.multipleSelection = val
  526. if (val) {
  527. this.selections = val
  528. } else {
  529. this.selections = []
  530. }
  531. },
  532. rowClass({ row, rowIndex }) {
  533. if (this.selectRow.includes(row.id)) {
  534. return { 'background-color': '#ecf5ff' }
  535. }
  536. },
  537. // 打开 批量审批
  538. batchExamine() {
  539. this.isShowExamineDialog = true
  540. },
  541. // 提交 批量审批
  542. submitExamineForm() {
  543. let ids = this.recordSelected.map(item => {
  544. return item.id
  545. })
  546. ids = Array.from(new Set(ids))
  547. examineBatchEngin({
  548. ids: ids.join(','),
  549. examineStatus: this.examineForm.status === 'FAIL' ? 'SAVE' : 'OK',
  550. approvalRemark: this.examineForm.remark
  551. }).then(res => {
  552. this.isShowExamineDialog = false
  553. // this.getList()
  554. this.$refs.pageRef.refreshList()
  555. this.$successMsg('审批成功')
  556. })
  557. },
  558. // 获取存货类别列表
  559. getCategoryList() {
  560. getCategoryList({
  561. pageNum: 1,
  562. pageSize: -1
  563. }).then(res => {
  564. this.categoryList = res.data.records
  565. })
  566. },
  567. /**
  568. * 根据条件禁用行复选框
  569. * 函数返回值为false则禁用选择(反之亦然)
  570. * @param {Object} row - 行数据
  571. * @param {String} index - 索引值
  572. * @return Boolean
  573. */
  574. selectable: function(row, index) {
  575. if (row.automaticStatus) {
  576. return false
  577. }
  578. return true
  579. // 函数必须有返回值且是布尔值
  580. // 页面刷新后该函数会执行 N 次进行判断(N 为表格行数)
  581. // 如果没有返回值则默认返回false(全部无法选中)
  582. }
  583. }
  584. }
  585. </script>
  586. <style lang="scss" scoped></style>