modify_list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  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. productUpdPriceReview,
  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. //
  135. baseURL: '',
  136. importFileList: [],
  137. importLoading: false,
  138. show: 1,
  139. currentPage: 1, // 当前页码
  140. pageSize: 10, // 每页数量
  141. listTotal: 0, // 列表总数
  142. dataList: [
  143. {
  144. baseUnitId: '',
  145. batchPrice: '',
  146. billId: '',
  147. endDate: '',
  148. id: null,
  149. isPromote: '',
  150. isPublish: '',
  151. materialId: '',
  152. materialName: '',
  153. materialNumber: '',
  154. parentId: '',
  155. qty: '',
  156. rebateUseRate: '',
  157. retailPrice: '',
  158. saleTypeId: '',
  159. specification: '',
  160. startDate: '',
  161. wallets: []
  162. }
  163. ],
  164. screenForm: {
  165. materialName: '',
  166. materialNumber: '',
  167. startDate: '',
  168. materialOldNumber: '',
  169. saleTypeId: '',
  170. k3CategoryNumber: '',
  171. specification: ''
  172. },
  173. liDetail: {},
  174. detail: {},
  175. obj: {
  176. baseUnitId: '',
  177. batchPrice: '',
  178. billId: '',
  179. endDate: '',
  180. id: null,
  181. isPromote: '',
  182. isPublish: '',
  183. materialId: '4',
  184. materialName: '',
  185. materialNumber: '',
  186. parentId: '',
  187. qty: '',
  188. rebateUseRate: '',
  189. retailPrice: '',
  190. saleTypeId: '',
  191. specification: '',
  192. startDate: '',
  193. wallets: []
  194. },
  195. cid: '',
  196. typeList: [],
  197. dictList: [],
  198. isCollapse: true,
  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. }
  221. },
  222. comWallets() {
  223. return e => {
  224. let map = new Map()
  225. for (const item of e) {
  226. map.set(item.walletId, item)
  227. }
  228. return [...map.values()]
  229. }
  230. }
  231. },
  232. mounted() {
  233. let params = {
  234. pageNum: 1,
  235. pageSize: -1,
  236. saleCode: '',
  237. saleName: '',
  238. status: ''
  239. }
  240. getTypeList(params).then(res => {
  241. this.typeList = res.data.records
  242. })
  243. getCategoryList({ pageNum: 1, pageSize: -1 }).then(res => {
  244. this.dictList = res.data.records
  245. console.log(this.dictList, 777777)
  246. })
  247. },
  248. methods: {
  249. // 列表请求函数
  250. getList: v2ProductUpdPriceList,
  251. // 列表导出函数
  252. exportList: v2ProductUpdPriceListExport,
  253. // 表格列解析渲染数据更改
  254. columnParsing(item, defaultData) {
  255. return defaultData
  256. },
  257. // 监听勾选变化
  258. selectionChange(data) {
  259. this.recordSelected = data
  260. },
  261. operation() {
  262. return (h, { row, index, column }) => {
  263. return (
  264. <div class="operation-btns">
  265. {row.examineStatus == '保存' ? (
  266. <el-popconfirm
  267. onConfirm={async () => {
  268. this.handleGetPriceSubmit(row.updPriceBillId)
  269. }}
  270. title="是否确定需要提审该项内容?"
  271. >
  272. <el-button slot="reference" size="mini" type="text">
  273. 提审
  274. </el-button>
  275. </el-popconfirm>
  276. ) : (
  277. ''
  278. )}
  279. {row.examineStatus == '待审核' ? (
  280. <el-popconfirm
  281. onConfirm={async () => {
  282. this.approvalFn(row.updPriceBillId)
  283. }}
  284. title="是否确定需要审批该项内容?"
  285. >
  286. <el-button slot="reference" size="mini" type="text">
  287. 审批
  288. </el-button>
  289. </el-popconfirm>
  290. ) : (
  291. ''
  292. )}
  293. {row.examineStatus == '保存' ? (
  294. <el-button
  295. size="mini"
  296. type="text"
  297. onClick={async () => {
  298. this.editFn(row.updPriceBillId, row)
  299. }}
  300. >
  301. 编辑
  302. </el-button>
  303. ) : (
  304. ''
  305. )}
  306. {row.examineStatus == '审核通过' ? (
  307. <el-popconfirm
  308. onConfirm={async() => {
  309. productUpdPriceReview({ id: row.updPriceBillId }).then(() => {
  310. this.$successMsg('弃审成功')
  311. this.$refs.pageRef.refreshList()
  312. })
  313. }}
  314. title='是否确定需要审批该项内容?'
  315. >
  316. <el-button slot='reference' size='mini' type='text'>
  317. 弃审
  318. </el-button>
  319. </el-popconfirm>
  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. // }
  424. // getProductRriceList(params).then(res => {
  425. // this.dataList = res.data.records
  426. // this.listTotal = res.data.total
  427. // this.listLoading = false
  428. // })
  429. // },
  430. editFn(id, row) {
  431. this.cid = id
  432. this.show = 5
  433. // this.diaLogForm = {
  434. // id,
  435. // composeNumber: row.composeNumber,
  436. // items: row.items === undefined ? [] : row.items,
  437. // materialId: row.materialId,
  438. // orgNumber: row.orgNumber,
  439. // productModel: row.productModel,
  440. // productVolume: row.productVolume,
  441. // };
  442. // this.showDialogForm = true;
  443. },
  444. hanleInfo() {
  445. if (this.type === 1) {
  446. getProductAdd(this.diaLogForm).then(res => {
  447. this.$successMsg('保存成功')
  448. console.log(params, 123)
  449. this.getList()
  450. })
  451. } else if (this.type === 2) {
  452. const params = {
  453. ...this.diaLogForm
  454. }
  455. console.log(params, 123)
  456. getProductEdit(params).then(res => {
  457. this.$successMsg('编辑成功')
  458. this.getList()
  459. })
  460. this.diaLogForm.id = null
  461. }
  462. this.showDialogForm = false
  463. },
  464. hanleDelete(id) {
  465. this.hanleDeleteAllPromise(id).then(ids => {
  466. getProductDel(ids).then(res => {
  467. this.$successMsg('删除成功')
  468. })
  469. })
  470. },
  471. handleExport() {
  472. let screenData = {
  473. customerName: this.screenForm.customerName,
  474. freeDay: this.screenForm.freeDay,
  475. toll: this.screenForm.toll
  476. }
  477. downloadFiles('product-compose/export', screenData)
  478. },
  479. resetInfo() {
  480. this.diaLogForm = {
  481. composeNumber: '',
  482. id: '',
  483. items: [],
  484. materialId: '',
  485. orgNumber: 0,
  486. productModel: '',
  487. productVolume: ''
  488. }
  489. },
  490. // 导入
  491. async handleImport(param) {
  492. this.importLoading = true
  493. const file = param.file
  494. const formData = new FormData()
  495. formData.append('file', file)
  496. const result = await handleImport('/product-upd-price/material/import', formData)
  497. this.importLoading = false
  498. this.importFileList = []
  499. if (result.code === 200) {
  500. this.$alert('成功处理记录数:' + result.data, '导入成功', {
  501. confirmButtonText: '确定'
  502. })
  503. this.getList()
  504. } else {
  505. this.$alert(result.message, '导入失败', {
  506. confirmButtonText: '确定'
  507. })
  508. }
  509. },
  510. // 下载经销商模板
  511. hanleDownloadFiles() {
  512. downloadFiles('product-upd-price/download')
  513. },
  514. tableRowClassName({ row, rowIndex }) {
  515. // || row.examineStatus=='FAIL'
  516. if (this.ids.includes(row.updPriceBillId)) {
  517. return 'warning-row'
  518. }
  519. return ''
  520. }
  521. }
  522. }
  523. </script>
  524. <style lang="scss" scoped>
  525. ::v-deep .el-select--small {
  526. width: 100%;
  527. }
  528. ::v-deep .el-table .warning-row {
  529. background: oldlace;
  530. }
  531. .import-btn {
  532. display: inline-block;
  533. margin: 0 10px;
  534. }
  535. </style>