apply_list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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. console.log(row)
  236. return (
  237. <div class="operation-btns">
  238. {this.$checkBtnRole('apply', this.$route.meta.roles) &&
  239. ((!this.isCustomer &&
  240. !row.automaticStatus &&
  241. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL')) ||
  242. (this.isCustomer &&
  243. !row.automaticStatus &&
  244. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  245. row.type != 2) ||
  246. (!this.isCustomer &&
  247. row.automaticStatus &&
  248. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  249. row.type === 2)) ? (
  250. <el-popconfirm
  251. style="margin-right: 10px"
  252. title="确定申请吗?"
  253. onOnConfirm={() => {
  254. this.handleSubmit(row.id, 'WAIT')
  255. }}
  256. >
  257. <el-button slot="reference" type="text">
  258. 申请
  259. </el-button>
  260. </el-popconfirm>
  261. ) : null}
  262. {this.$checkBtnRole('apply', this.$route.meta.roles) &&
  263. ((!this.isCustomer && !row.automaticStatus && row.examineStatus === 'WAIT') ||
  264. (this.isCustomer && !row.automaticStatus && row.examineStatus === 'WAIT' && row.type != 2) ||
  265. (!this.isCustomer && row.automaticStatus && row.examineStatus === 'WAIT' && row.type == 2)) ? (
  266. <el-popconfirm
  267. style="margin-right: 10px"
  268. title="确定撤回吗?"
  269. onOnConfirm={() => {
  270. this.handleSubmit(row.id, 'SAVE')
  271. }}
  272. >
  273. <el-button slot="reference" type="text">
  274. 撤回
  275. </el-button>
  276. </el-popconfirm>
  277. ) : null}
  278. {this.$checkBtnRole('examine', this.$route.meta.roles) &&
  279. ((!this.isCustomer && !row.automaticStatus && row.examineStatus === 'OK') ||
  280. (this.isCustomer && !row.automaticStatus && row.examineStatus === 'OK' && row.type != 2) ||
  281. (!this.isCustomer && row.automaticStatus && row.examineStatus === 'OK' && row.type == 2)) ? (
  282. <el-popconfirm
  283. style="margin-right: 10px"
  284. title="确定弃审吗?"
  285. onOnConfirm={() => {
  286. this.handleAbandon(row.id)
  287. }}
  288. >
  289. <el-button slot="reference" type="text">
  290. 弃审
  291. </el-button>
  292. </el-popconfirm>
  293. ) : null}
  294. {this.$checkBtnRole('edit', this.$route.meta.roles) &&
  295. !row.automaticStatus &&
  296. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  297. row.type === 1 ? (
  298. <el-button
  299. type="text"
  300. onClick={() => {
  301. this.toForm(row)
  302. }}
  303. >
  304. 编辑
  305. </el-button>
  306. ) : null}
  307. {this.$checkBtnRole('edit', this.$route.meta.roles) &&
  308. ((!this.isCustomer &&
  309. !row.automaticStatus &&
  310. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  311. row.type === 2) ||
  312. (this.isCustomer &&
  313. !row.automaticStatus &&
  314. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  315. row.type != 2 &&
  316. row.type !== 1) ||
  317. (!this.isCustomer &&
  318. row.automaticStatus &&
  319. (row.examineStatus === 'SAVE' || row.examineStatus === 'FAIL') &&
  320. row.type === 2)) ? (
  321. <el-button
  322. type="text"
  323. onClick={() => {
  324. this.toReturnForm(row)
  325. }}
  326. >
  327. 编辑
  328. </el-button>
  329. ) : null}
  330. {this.$checkBtnRole('examine', this.$route.meta.roles) &&
  331. ((!this.isCustomer && !row.automaticStatus && row.examineStatus === 'WAIT') ||
  332. (this.isCustomer && !row.automaticStatus && row.examineStatus !== 'WAIT' && row.type != 2) ||
  333. (!this.isCustomer && row.automaticStatus && row.examineStatus === 'WAIT' && row.type == 2)) ? (
  334. <el-button
  335. type="text"
  336. onClick={() => {
  337. this.toExamine(row)
  338. }}
  339. >
  340. 审核
  341. </el-button>
  342. ) : null}
  343. {this.$checkBtnRole('del', this.$route.meta.roles) &&
  344. ((!this.isCustomer && !row.automaticStatus && row.examineStatus !== 'OK') ||
  345. (this.isCustomer && !row.automaticStatus && row.examineStatus !== 'OK' && row.type != 2) ||
  346. (!this.isCustomer && row.automaticStatus && row.examineStatus !== 'OK' && row.type == 2)) ? (
  347. <el-popconfirm
  348. style="margin-left: 10px"
  349. title="确定删除吗?"
  350. onOnConfirm={() => {
  351. this.handleDelete(row.id)
  352. }}
  353. >
  354. <el-button slot="reference" type="text" style="color: #f56c6c">
  355. 删除
  356. </el-button>
  357. </el-popconfirm>
  358. ) : null}
  359. <el-button
  360. type="text"
  361. onClick={() => {
  362. this.toDetail(row)
  363. }}
  364. >
  365. 详情
  366. </el-button>
  367. </div>
  368. )
  369. }
  370. },
  371. // 获取业务员列表
  372. getSalesmanList() {
  373. getSalesmanList({
  374. pageNum: 1,
  375. pageSize: -1,
  376. isCustomer: 0,
  377. status: true
  378. }).then(res => {
  379. this.salesmanList = res.data.records
  380. })
  381. },
  382. // // 查询列表
  383. // getList() {
  384. // this.listLoading = true
  385. // const params = {
  386. // pageNum: this.currentPage,
  387. // pageSize: this.pageSize,
  388. // id: this.screenForm.orderNum,
  389. // correspondName: this.screenForm.warehouse,
  390. // customerNumber: this.screenForm.jxsNum,
  391. // createBy: this.screenForm.createBy,
  392. // automaticStatus: this.screenForm.automaticStatus,
  393. // customerName: this.screenForm.jxsName,
  394. // productName: this.screenForm.chName,
  395. // specification: this.screenForm.model,
  396. // startTime: this.screenForm.date ? this.screenForm.date[0] : '',
  397. // endTime: this.screenForm.date ? this.screenForm.date[1] : '',
  398. // examineStatus: this.screenForm.status,
  399. // serviceId: this.screenForm.serviceId,
  400. // type: this.screenForm.orderType,
  401. // k3ServiceId: this.screenForm.k3ServiceId,
  402. // mainOrderId: this.screenForm.mainOrderId,
  403. // categoryId: this.screenForm.categoryId,
  404. // approvalName: this.screenForm.approvalName
  405. // }
  406. // getApplyList(params).then(res => {
  407. // res.data.records.forEach(item => {
  408. // item.sums1 = ['refundableQty', 'retiredQty']
  409. // item.sums2 = ['singlePayPrice', 'payAmount', 'payRebateAmount', 'totalDiscAmount']
  410. // })
  411. // this.dataList = res.data.records
  412. // this.listTotal = res.data.total
  413. // this.listLoading = false
  414. // })
  415. // },
  416. // 提交筛选表单
  417. submitScreenForm() {
  418. this.currentPage = 1
  419. this.getList()
  420. },
  421. // 重置筛选表单
  422. resetScreenForm() {
  423. this.$refs.screenForm.resetFields()
  424. this.currentPage = 1
  425. this.getList()
  426. },
  427. // 更改每页数量
  428. handleSizeChange(val) {
  429. this.pageSize = val
  430. this.currentPage = 1
  431. this.getList()
  432. },
  433. // 更改当前页
  434. handleCurrentChange(val) {
  435. this.currentPage = val
  436. this.getList()
  437. },
  438. // 进入表单
  439. toForm(item) {
  440. this.queryItem = item
  441. this.isShowForm = true
  442. },
  443. // 进入表单
  444. toReturnForm(item) {
  445. this.queryItem = item
  446. this.isShowReturnForm = true
  447. },
  448. // 进入审批
  449. toExamine(item) {
  450. this.queryItem = item
  451. this.isShowExamine = true
  452. },
  453. // 进入详情
  454. toDetail(item) {
  455. this.queryItem = item
  456. this.isShowDetail = true
  457. this.$nextTick(() => {
  458. this.$refs.refDetail.initPrint()
  459. })
  460. // this.$refs.refDetail.initPrint()
  461. },
  462. backList() {
  463. this.queryItem = {}
  464. this.isShowDetail = false
  465. this.isShowExamine = false
  466. this.isShowForm = false
  467. this.isShowReturnForm = false
  468. },
  469. handleDelete(id) {
  470. deleteApply({ id }).then(res => {
  471. this.$successMsg()
  472. this.$refs.pageRef.refreshList()
  473. })
  474. },
  475. // 申请/撤回
  476. handleSubmit(id, examineStatus) {
  477. submitApply({ id, examineStatus }).then(res => {
  478. this.$successMsg()
  479. this.$refs.pageRef.refreshList()
  480. })
  481. },
  482. // 弃审
  483. handleAbandon(id) {
  484. abandonApply({ id }).then(res => {
  485. this.$successMsg()
  486. this.$refs.pageRef.refreshList()
  487. })
  488. },
  489. handleSelectionChange(val) {
  490. this.multipleSelection = val
  491. if (val) {
  492. this.selections = val
  493. } else {
  494. this.selections = []
  495. }
  496. },
  497. rowClass({ row, rowIndex }) {
  498. if (this.selectRow.includes(row.id)) {
  499. return { 'background-color': '#ecf5ff' }
  500. }
  501. },
  502. // 打开 批量审批
  503. batchExamine() {
  504. this.isShowExamineDialog = true
  505. },
  506. // 提交 批量审批
  507. submitExamineForm() {
  508. let ids = this.multipleSelection.map(item => {
  509. return item.id
  510. })
  511. ids = Array.from(new Set(ids))
  512. examineBatchApply({
  513. ids: ids.join(','),
  514. examineStatus: this.examineForm.status === 'FAIL' ? 'SAVE' : 'OK',
  515. approvalRemark: this.examineForm.remark
  516. }).then(res => {
  517. this.isShowExamineDialog = false
  518. this.$refs.pageRef.refreshList()
  519. this.$successMsg('审批成功')
  520. })
  521. },
  522. // 获取存货类别列表
  523. getCategoryList() {
  524. getCategoryList({
  525. pageNum: 1,
  526. pageSize: -1
  527. }).then(res => {
  528. this.categoryList = res.data.records
  529. })
  530. },
  531. /**
  532. * 根据条件禁用行复选框
  533. * 函数返回值为false则禁用选择(反之亦然)
  534. * @param {Object} row - 行数据
  535. * @param {String} index - 索引值
  536. * @return Boolean
  537. */
  538. selectable: function (row, index) {
  539. if (row.automaticStatus) {
  540. return false
  541. }
  542. return true
  543. // 函数必须有返回值且是布尔值
  544. // 页面刷新后该函数会执行 N 次进行判断(N 为表格行数)
  545. // 如果没有返回值则默认返回false(全部无法选中)
  546. }
  547. }
  548. }
  549. </script>
  550. <style lang="scss" scoped></style>