difference_modify_list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  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. exportFields: p[0].exportFields,
  262. moduleId: p[0].moduleId,
  263. orderBy: p[0].orderBy,
  264. pageNum: p[0].pageNum,
  265. pageSize: p[0].pageSize,
  266. params: [...p[0].params, { param: 'a.bill_type', compare: '=', value: 'DIFF' }]
  267. }
  268. return v2ProductUpdPriceListExport(params, p[1])
  269. },
  270. // 表格列解析渲染数据更改
  271. columnParsing(item, defaultData) {
  272. return defaultData
  273. },
  274. // 监听勾选变化
  275. selectionChange(data) {
  276. this.recordSelected = data
  277. },
  278. operation() {
  279. return (h, { row, index, column }) => {
  280. return (
  281. <div class="operation-btns">
  282. {row.examineStatus == '保存' ? (
  283. <el-popconfirm
  284. onOnConfirm={async () => {
  285. this.handleGetPriceSubmit(row.updPriceBillId)
  286. }}
  287. title="是否确定需要提审该项内容?"
  288. >
  289. <el-button slot="reference" size="mini" type="text">
  290. 提审
  291. </el-button>
  292. </el-popconfirm>
  293. ) : (
  294. ''
  295. )}
  296. {row.examineStatus == '待审核' ? (
  297. <el-popconfirm
  298. onOnConfirm={async () => {
  299. this.approvalFn(row.updPriceBillId)
  300. }}
  301. title="是否确定需要审批该项内容?"
  302. >
  303. <el-button slot="reference" size="mini" type="text">
  304. 审批
  305. </el-button>
  306. </el-popconfirm>
  307. ) : (
  308. ''
  309. )}
  310. {row.examineStatus == '保存' ? (
  311. <el-button
  312. size="mini"
  313. type="text"
  314. onClick={async () => {
  315. this.editFn(row.updPriceBillId, row)
  316. }}
  317. >
  318. 编辑
  319. </el-button>
  320. ) : (
  321. ''
  322. )}
  323. <el-button
  324. size="mini"
  325. type="text"
  326. onClick={async () => {
  327. this.detailFn(row.updPriceBillId)
  328. }}
  329. >
  330. 详情
  331. </el-button>
  332. </div>
  333. )
  334. }
  335. },
  336. formatterType(row) {
  337. for (let i = 0; i < this.typeList.length; i++) {
  338. if (this.typeList[i].id == row.saleTypeId) {
  339. return this.typeList[i].saleName
  340. }
  341. }
  342. },
  343. addFn() {
  344. this.show = 2
  345. },
  346. hanleDeleteAllPromise(id) {
  347. return new Promise((resolve, reject) => {
  348. const ids = id ? [id] : this.recordSelected.map(v => v.updPriceBillId)
  349. if (!ids.length) {
  350. this.$errorMsg('请选择删除内容')
  351. return
  352. }
  353. resolve(ids)
  354. })
  355. },
  356. hanleDeleteAll(id) {
  357. this.hanleDeleteAllPromise(id).then(ids => {
  358. getProductRricedel(ids).then(res => {
  359. this.$successMsg('删除成功')
  360. // this.getList()
  361. this.$refs.pageRef.refreshList()
  362. })
  363. })
  364. },
  365. // 打开 批量审批
  366. batchExamine() {
  367. if (this.recordSelected.length) {
  368. this.isShowExamineDialog = true
  369. return
  370. }
  371. this.$errorMsg('请选择审核项')
  372. },
  373. // 提交 批量审批
  374. submitExamineForm() {
  375. // let ids = this.dis.map(item => {
  376. // return item
  377. // });
  378. const ids = [...new Set(this.recordSelected.map(v => v.updPriceBillId))]
  379. examineData({
  380. ids: ids.join(','),
  381. examineStatus: this.examineForm.status,
  382. examineRemark: this.examineForm.remark
  383. }).then(res => {
  384. this.isShowExamineDialog = false
  385. this.$successMsg('修改成功')
  386. // this.getList()
  387. this.$refs.pageRef.refreshList()
  388. })
  389. },
  390. handleGetPriceSubmit(id) {
  391. // console.log(id)
  392. getPriceSubmit({ ids: id }).then(res => {
  393. this.$successMsg('已提审')
  394. // this.getList()
  395. this.$refs.pageRef.refreshList()
  396. })
  397. },
  398. approvalFn(id) {
  399. getProductRriceDetail({ id }).then(res => {
  400. this.detail = res.data
  401. this.show = 3
  402. })
  403. },
  404. detailFn(id) {
  405. getProductRriceDetail({ id }).then(res => {
  406. this.detail = res.data
  407. this.show = 4
  408. })
  409. },
  410. // getList() {
  411. // this.listLoading = true
  412. // console.log(456654)
  413. // let params = {
  414. // pageNum: this.currentPage,
  415. // pageSize: this.pageSize,
  416. // materialName: this.screenForm.materialName,
  417. // materialNumber: this.screenForm.materialNumber,
  418. // startDate: this.screenForm.startDate,
  419. // materialOldNumber: this.screenForm.materialOldNumber,
  420. // saleTypeId: this.screenForm.saleTypeId,
  421. // k3CategoryNumber: this.screenForm.k3CategoryNumber,
  422. // specification: this.screenForm.specification,
  423. // remark: this.screenForm.remark,
  424. // billType: 'DIFF'
  425. // }
  426. // getProductRriceList(params).then(res => {
  427. // this.dataList = res.data.records
  428. // this.listTotal = res.data.total
  429. // this.listLoading = false
  430. // })
  431. // },
  432. editFn(id, row) {
  433. this.cid = id
  434. this.show = 5
  435. // this.diaLogForm = {
  436. // id,
  437. // composeNumber: row.composeNumber,
  438. // items: row.items === undefined ? [] : row.items,
  439. // materialId: row.materialId,
  440. // orgNumber: row.orgNumber,
  441. // productModel: row.productModel,
  442. // productVolume: row.productVolume,
  443. // };
  444. // this.showDialogForm = true;
  445. },
  446. hanleInfo() {
  447. if (this.type === 1) {
  448. getProductAdd(this.diaLogForm).then(res => {
  449. this.$successMsg('保存成功')
  450. console.log(params, 123)
  451. this.getList()
  452. })
  453. } else if (this.type === 2) {
  454. const params = {
  455. ...this.diaLogForm
  456. }
  457. console.log(params, 123)
  458. getProductEdit(params).then(res => {
  459. this.$successMsg('编辑成功')
  460. this.getList()
  461. })
  462. this.diaLogForm.id = null
  463. }
  464. this.showDialogForm = false
  465. },
  466. hanleDelete(id) {
  467. this.hanleDeleteAllPromise(id).then(ids => {
  468. getProductDel(ids).then(res => {
  469. this.$successMsg('删除成功')
  470. })
  471. })
  472. },
  473. handleExport() {
  474. let screenData = {
  475. customerName: this.screenForm.customerName,
  476. freeDay: this.screenForm.freeDay,
  477. toll: this.screenForm.toll,
  478. remark: this.screenForm.remark,
  479. billType: 'DIFF'
  480. }
  481. downloadFiles('product-compose/export', screenData)
  482. },
  483. resetInfo() {
  484. this.diaLogForm = {
  485. composeNumber: '',
  486. id: '',
  487. items: [],
  488. materialId: '',
  489. orgNumber: 0,
  490. productModel: '',
  491. productVolume: ''
  492. }
  493. },
  494. // 导入
  495. async handleImport(param) {
  496. this.importLoading = true
  497. const file = param.file
  498. const formData = new FormData()
  499. formData.append('file', file)
  500. formData.append('billType', 'DIFF')
  501. const result = await handleImport('/product-upd-price/material/import', formData)
  502. this.importLoading = false
  503. this.importFileList = []
  504. if (result.code === 200) {
  505. this.$alert('成功处理记录数:' + result.data, '导入成功', {
  506. confirmButtonText: '确定'
  507. })
  508. this.getList()
  509. } else {
  510. this.$alert(result.message, '导入失败', {
  511. confirmButtonText: '确定'
  512. })
  513. }
  514. },
  515. // 下载经销商模板
  516. hanleDownloadFiles() {
  517. downloadFiles('product-upd-price/download', {
  518. billType: 'DIFF'
  519. })
  520. },
  521. tableRowClassName({ row, rowIndex }) {
  522. // || row.examineStatus=='FAIL'
  523. if (this.ids.includes(row.updPriceBillId)) {
  524. return 'warning-row'
  525. }
  526. return ''
  527. }
  528. }
  529. }
  530. </script>
  531. <style lang="scss" scoped>
  532. ::v-deep .el-table .warning-row {
  533. background: oldlace;
  534. }
  535. ::v-deep .el-select--small {
  536. width: 100%;
  537. }
  538. .import-btn {
  539. display: inline-block;
  540. margin: 0 10px;
  541. }
  542. </style>