apply_list.vue 18 KB

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