difference_modify_list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :operation="operation()"
  6. :optionsEvensGroup="optionsEvensGroup"
  7. :exportList="exportList"
  8. :columnParsing="columnParsing"
  9. :tableAttributes="tableAttributes"
  10. :tableEvents="tableEvents"
  11. >
  12. <ExamineDialog @submit="submitExamineForm" :isShow.sync="isShowExamineDialog" :examineForm.sync="examineForm" />
  13. <Popu v-if="show !== 1">
  14. <!-- <el-page-header slot="head" :content="content" @back="handleClose" /> -->
  15. <ModifyListApply v-if="show === 2 || show == 5" :cid="cid" :show="show" @back="handleClose" />
  16. <ModifyListApproval v-if="show === 3" :detail="detail" @back="handleClose" />
  17. <ModifyListDetail v-if="show === 4" :detail="detail" @back="handleClose" />
  18. </Popu>
  19. </template-page>
  20. </template>
  21. <script>
  22. import TemplatePage from '@/components/template/template-page-1.vue'
  23. import Popu from '@/components/template/popu.vue'
  24. import import_mixin from '@/components/template/import_mixin.js'
  25. import add_callback_mixin from '@/components/template/add_callback_mixin.js'
  26. import ModifyListApply from './components/modify_list-apply.vue'
  27. import ModifyListApproval from './components/modify_list-approval.vue'
  28. import ModifyListDetail from './components/modify_list-detail.vue'
  29. import ExamineDialog from '@/components/Common/examine-dialog'
  30. // import Mixin from '@/mixin/index'
  31. import {
  32. getPriceSubmit,
  33. getProductRricedel,
  34. getProductRriceDetail,
  35. getProductRriceList,
  36. getTypeList,
  37. examineData,
  38. v2ProductUpdPriceList,
  39. v2ProductUpdPriceListExport,
  40. productUpdPriceDownload,
  41. productUpdPriceMaterialImport
  42. } from '@/api/basic_data/material'
  43. // import { downloadFiles, handleImport } from '@/utils/util'
  44. import { getCategoryList } from '@/api/common'
  45. export default {
  46. mixins: [import_mixin, add_callback_mixin],
  47. data() {
  48. return {
  49. handleClose: this.addOff(() => {
  50. if (this.show === 2 || this.show === 5) {
  51. this.cid = ''
  52. this.show = 1
  53. }
  54. this.show = 1
  55. this.$refs.pageRef.refreshList()
  56. }),
  57. // 事件组合
  58. optionsEvensGroup: [
  59. [
  60. [
  61. {
  62. name: '新增',
  63. click: this.addOn(() => {
  64. this.addFn()
  65. })
  66. }
  67. ]
  68. ],
  69. [
  70. [
  71. {
  72. name: '批量删除',
  73. click: async () => {
  74. if (this.recordSelected.length === 0) {
  75. this.$message.error('请选择需要删除的数据')
  76. return
  77. }
  78. this.hanleDeleteAll()
  79. },
  80. isRole: this.$checkBtnRole('del', this.$route.meta.roles)
  81. }
  82. ]
  83. ],
  84. [
  85. [
  86. {
  87. name: '批量审批',
  88. click: async () => {
  89. this.batchExamine()
  90. }
  91. }
  92. ]
  93. ],
  94. [
  95. [
  96. {
  97. name: '',
  98. render: this.importButton(productUpdPriceMaterialImport, '导入', {
  99. billType: 'GENERAL'
  100. })
  101. }
  102. ]
  103. ],
  104. [
  105. [
  106. {
  107. name: '导入模版',
  108. click: () => {
  109. productUpdPriceDownload({}, `${this.$route.meta.title}`)
  110. .then(res => {
  111. this.$message({
  112. message: '下载成功',
  113. type: 'success'
  114. })
  115. })
  116. .catch(err => {
  117. this.$message.error('下载失败')
  118. })
  119. }
  120. }
  121. ]
  122. ]
  123. ],
  124. // 表格属性
  125. tableAttributes: {
  126. // 启用勾选列
  127. selectColumn: true
  128. },
  129. // 表格事件
  130. tableEvents: {
  131. 'selection-change': this.selectionChange
  132. },
  133. recordSelected: [],
  134. baseURL: '',
  135. importFileList: [],
  136. show: 1,
  137. currentPage: 1, // 当前页码
  138. pageSize: 10, // 每页数量
  139. listTotal: 0, // 列表总数
  140. dataList: [
  141. {
  142. baseUnitId: '',
  143. batchPrice: '',
  144. billId: '',
  145. endDate: '',
  146. id: null,
  147. isPromote: '',
  148. isPublish: '',
  149. materialId: '',
  150. materialName: '',
  151. materialNumber: '',
  152. parentId: '',
  153. qty: '',
  154. rebateUseRate: '',
  155. retailPrice: '',
  156. saleTypeId: '',
  157. specification: '',
  158. startDate: '',
  159. wallets: []
  160. }
  161. ],
  162. screenForm: {
  163. materialName: '',
  164. materialNumber: '',
  165. startDate: '',
  166. materialOldNumber: '',
  167. saleTypeId: '',
  168. k3CategoryNumber: '',
  169. specification: '',
  170. remark: ''
  171. },
  172. liDetail: {},
  173. detail: {},
  174. obj: {
  175. baseUnitId: '',
  176. batchPrice: '',
  177. billId: '',
  178. endDate: '',
  179. id: null,
  180. isPromote: '',
  181. isPublish: '',
  182. materialId: '4',
  183. materialName: '',
  184. materialNumber: '',
  185. parentId: '',
  186. qty: '',
  187. rebateUseRate: '',
  188. retailPrice: '',
  189. saleTypeId: '',
  190. specification: '',
  191. startDate: '',
  192. wallets: []
  193. },
  194. cid: '',
  195. typeList: [],
  196. dictList: [],
  197. isCollapse: true,
  198. importLoading: false,
  199. isShowExamineDialog: false,
  200. examineForm: {
  201. status: 'OK',
  202. remark: ''
  203. }
  204. }
  205. },
  206. components: {
  207. ExamineDialog,
  208. ModifyListApply,
  209. ModifyListApproval,
  210. ModifyListDetail,
  211. TemplatePage,
  212. Popu
  213. },
  214. computed: {
  215. exParams() {
  216. return {
  217. materialName: this.screenForm.materialName,
  218. materialNumber: this.screenForm.materialNumber,
  219. startDate: this.screenForm.startDate,
  220. materialOldNumber: this.screenForm.materialOldNumber,
  221. saleTypeId: this.screenForm.saleTypeId,
  222. k3CategoryNumber: this.screenForm.k3CategoryNumber,
  223. specification: this.screenForm.specification,
  224. remark: this.screenForm.remark,
  225. billType: 'DIFF'
  226. }
  227. }
  228. },
  229. mounted() {
  230. let params = {
  231. pageNum: 1,
  232. pageSize: -1,
  233. saleCode: '',
  234. saleName: '',
  235. status: ''
  236. }
  237. getTypeList(params).then(res => {
  238. this.typeList = res.data.records
  239. })
  240. getCategoryList({ pageNum: 1, pageSize: -1 }).then(res => {
  241. this.dictList = res.data.records
  242. console.log(this.dictList, 777777)
  243. })
  244. },
  245. methods: {
  246. // 列表请求函数
  247. getList(...p) {
  248. let params = {
  249. moduleId: p[0].moduleId,
  250. orderBy: p[0].orderBy,
  251. pageNum: p[0].pageNum,
  252. pageSize: p[0].pageSize,
  253. params: [...p[0].params, { param: 'a.bill_type', compare: '=', value: 'DIFF' }]
  254. }
  255. return v2ProductUpdPriceList(params)
  256. },
  257. // 列表导出函数
  258. // exportList: v2ProductUpdPriceListExport,
  259. exportList(...p) {
  260. let params = {
  261. moduleId: p[0].moduleId,
  262. orderBy: p[0].orderBy,
  263. pageNum: p[0].pageNum,
  264. pageSize: p[0].pageSize,
  265. params: [...p[0].params, { param: 'a.bill_type', compare: '=', value: 'DIFF' }]
  266. }
  267. return v2ProductUpdPriceListExport(params, p[1])
  268. },
  269. // 表格列解析渲染数据更改
  270. columnParsing(item, defaultData) {
  271. return defaultData
  272. },
  273. // 监听勾选变化
  274. selectionChange(data) {
  275. this.recordSelected = data
  276. },
  277. operation() {
  278. return (h, { row, index, column }) => {
  279. return (
  280. <div class="operation-btns">
  281. {row.examineStatus == '保存' ? (
  282. <el-popconfirm
  283. onOnConfirm={async () => {
  284. this.handleGetPriceSubmit(row.updPriceBillId)
  285. }}
  286. title="是否确定需要提审该项内容?"
  287. >
  288. <el-button slot="reference" size="mini" type="text">
  289. 提审
  290. </el-button>
  291. </el-popconfirm>
  292. ) : (
  293. ''
  294. )}
  295. {row.examineStatus == '待审核' ? (
  296. <el-popconfirm
  297. onOnConfirm={async () => {
  298. this.approvalFn(row.updPriceBillId)
  299. }}
  300. title="是否确定需要审批该项内容?"
  301. >
  302. <el-button slot="reference" size="mini" type="text">
  303. 审批
  304. </el-button>
  305. </el-popconfirm>
  306. ) : (
  307. ''
  308. )}
  309. {row.examineStatus == '保存' ? (
  310. <el-button
  311. size="mini"
  312. type="text"
  313. onClick={async () => {
  314. this.editFn(row.updPriceBillId, row)
  315. }}
  316. >
  317. 编辑
  318. </el-button>
  319. ) : (
  320. ''
  321. )}
  322. <el-button
  323. size="mini"
  324. type="text"
  325. onClick={async () => {
  326. this.detailFn(row.updPriceBillId)
  327. }}
  328. >
  329. 详情
  330. </el-button>
  331. </div>
  332. )
  333. }
  334. },
  335. formatterType(row) {
  336. for (let i = 0; i < this.typeList.length; i++) {
  337. if (this.typeList[i].id == row.saleTypeId) {
  338. return this.typeList[i].saleName
  339. }
  340. }
  341. },
  342. addFn() {
  343. this.show = 2
  344. },
  345. hanleDeleteAllPromise(id) {
  346. return new Promise((resolve, reject) => {
  347. const ids = id ? [id] : this.recordSelected.map(v => v.updPriceBillId)
  348. if (!ids.length) {
  349. this.$errorMsg('请选择删除内容')
  350. return
  351. }
  352. resolve(ids)
  353. })
  354. },
  355. hanleDeleteAll(id) {
  356. this.hanleDeleteAllPromise(id).then(ids => {
  357. getProductRricedel(ids).then(res => {
  358. this.$successMsg('删除成功')
  359. // this.getList()
  360. this.$refs.pageRef.refreshList()
  361. })
  362. })
  363. },
  364. // 打开 批量审批
  365. batchExamine() {
  366. if (this.recordSelected.length) {
  367. this.isShowExamineDialog = true
  368. return
  369. }
  370. this.$errorMsg('请选择审核项')
  371. },
  372. // 提交 批量审批
  373. submitExamineForm() {
  374. // let ids = this.dis.map(item => {
  375. // return item
  376. // });
  377. const ids = [...new Set(this.recordSelected.map(v => v.updPriceBillId))]
  378. examineData({
  379. ids: ids.join(','),
  380. examineStatus: this.examineForm.status,
  381. examineRemark: this.examineForm.remark
  382. }).then(res => {
  383. this.isShowExamineDialog = false
  384. this.$successMsg('修改成功')
  385. // this.getList()
  386. this.$refs.pageRef.refreshList()
  387. })
  388. },
  389. handleGetPriceSubmit(id) {
  390. // console.log(id)
  391. getPriceSubmit({ ids: id }).then(res => {
  392. this.$successMsg('已提审')
  393. // this.getList()
  394. this.$refs.pageRef.refreshList()
  395. })
  396. },
  397. approvalFn(id) {
  398. getProductRriceDetail({ id }).then(res => {
  399. this.detail = res.data
  400. this.show = 3
  401. })
  402. },
  403. detailFn(id) {
  404. getProductRriceDetail({ id }).then(res => {
  405. this.detail = res.data
  406. this.show = 4
  407. })
  408. },
  409. // getList() {
  410. // this.listLoading = true
  411. // console.log(456654)
  412. // let params = {
  413. // pageNum: this.currentPage,
  414. // pageSize: this.pageSize,
  415. // materialName: this.screenForm.materialName,
  416. // materialNumber: this.screenForm.materialNumber,
  417. // startDate: this.screenForm.startDate,
  418. // materialOldNumber: this.screenForm.materialOldNumber,
  419. // saleTypeId: this.screenForm.saleTypeId,
  420. // k3CategoryNumber: this.screenForm.k3CategoryNumber,
  421. // specification: this.screenForm.specification,
  422. // remark: this.screenForm.remark,
  423. // billType: 'DIFF'
  424. // }
  425. // getProductRriceList(params).then(res => {
  426. // this.dataList = res.data.records
  427. // this.listTotal = res.data.total
  428. // this.listLoading = false
  429. // })
  430. // },
  431. editFn(id, row) {
  432. this.cid = id
  433. this.show = 5
  434. // this.diaLogForm = {
  435. // id,
  436. // composeNumber: row.composeNumber,
  437. // items: row.items === undefined ? [] : row.items,
  438. // materialId: row.materialId,
  439. // orgNumber: row.orgNumber,
  440. // productModel: row.productModel,
  441. // productVolume: row.productVolume,
  442. // };
  443. // this.showDialogForm = true;
  444. },
  445. hanleInfo() {
  446. if (this.type === 1) {
  447. getProductAdd(this.diaLogForm).then(res => {
  448. this.$successMsg('保存成功')
  449. console.log(params, 123)
  450. this.getList()
  451. })
  452. } else if (this.type === 2) {
  453. const params = {
  454. ...this.diaLogForm
  455. }
  456. console.log(params, 123)
  457. getProductEdit(params).then(res => {
  458. this.$successMsg('编辑成功')
  459. this.getList()
  460. })
  461. this.diaLogForm.id = null
  462. }
  463. this.showDialogForm = false
  464. },
  465. hanleDelete(id) {
  466. this.hanleDeleteAllPromise(id).then(ids => {
  467. getProductDel(ids).then(res => {
  468. this.$successMsg('删除成功')
  469. })
  470. })
  471. },
  472. handleExport() {
  473. let screenData = {
  474. customerName: this.screenForm.customerName,
  475. freeDay: this.screenForm.freeDay,
  476. toll: this.screenForm.toll,
  477. remark: this.screenForm.remark,
  478. billType: 'DIFF'
  479. }
  480. downloadFiles('product-compose/export', screenData)
  481. },
  482. resetInfo() {
  483. this.diaLogForm = {
  484. composeNumber: '',
  485. id: '',
  486. items: [],
  487. materialId: '',
  488. orgNumber: 0,
  489. productModel: '',
  490. productVolume: ''
  491. }
  492. },
  493. // 导入
  494. async handleImport(param) {
  495. this.importLoading = true
  496. const file = param.file
  497. const formData = new FormData()
  498. formData.append('file', file)
  499. formData.append('billType', 'DIFF')
  500. const result = await handleImport('/product-upd-price/material/import', formData)
  501. this.importLoading = false
  502. this.importFileList = []
  503. if (result.code === 200) {
  504. this.$alert('成功处理记录数:' + result.data, '导入成功', {
  505. confirmButtonText: '确定'
  506. })
  507. this.getList()
  508. } else {
  509. this.$alert(result.message, '导入失败', {
  510. confirmButtonText: '确定'
  511. })
  512. }
  513. },
  514. // 下载经销商模板
  515. hanleDownloadFiles() {
  516. downloadFiles('product-upd-price/download', {
  517. billType: 'DIFF'
  518. })
  519. },
  520. tableRowClassName({ row, rowIndex }) {
  521. // || row.examineStatus=='FAIL'
  522. if (this.ids.includes(row.updPriceBillId)) {
  523. return 'warning-row'
  524. }
  525. return ''
  526. }
  527. }
  528. }
  529. </script>
  530. <style lang="scss" scoped>
  531. ::v-deep .el-table .warning-row {
  532. background: oldlace;
  533. }
  534. ::v-deep .el-select--small {
  535. width: 100%;
  536. }
  537. .import-btn {
  538. display: inline-block;
  539. margin: 0 10px;
  540. }
  541. </style>