modify_list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  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. <ModifyListApply v-if="show === 2 || show == 5" :cid="cid" :show="show" @back="handleClose" />
  15. <ModifyListApproval v-if="show === 3" :detail="detail" @back="handleClose" />
  16. <ModifyListDetail v-if="show === 4" :detail="detail" @back="handleClose" />
  17. </Popu>
  18. </template-page>
  19. </template>
  20. <script>
  21. import TemplatePage from '@/components/template/template-page-1.vue'
  22. import Popu from '@/components/template/popu.vue'
  23. import import_mixin from '@/components/template/import_mixin.js'
  24. import add_callback_mixin from '@/components/template/add_callback_mixin.js'
  25. import ModifyListApply from './components/modify_list-apply.vue'
  26. import ModifyListApproval from './components/modify_list-approval.vue'
  27. import ModifyListDetail from './components/modify_list-detail.vue'
  28. import ExamineDialog from '@/components/Common/examine-dialog'
  29. // import Mixin from '@/mixin/index'
  30. import {
  31. getPriceSubmit,
  32. getProductRricedel,
  33. getProductRriceDetail,
  34. getProductRriceList,
  35. getTypeList,
  36. examineData,
  37. v2ProductUpdPriceList,
  38. v2ProductUpdPriceListExport,
  39. productUpdPriceDownload,
  40. productUpdPriceMaterialImport
  41. } from '@/api/basic_data/material'
  42. // import { downloadFiles, handleImport } from '@/utils/util'
  43. import { getCategoryList } from '@/api/common'
  44. export default {
  45. mixins: [import_mixin, add_callback_mixin],
  46. data() {
  47. return {
  48. handleClose: this.addOff(() => {
  49. if (this.show === 2 || this.show === 5) {
  50. this.cid = ''
  51. this.show = 1
  52. }
  53. this.show = 1
  54. this.$refs.pageRef.refreshList()
  55. }),
  56. // 事件组合
  57. optionsEvensGroup: [
  58. [
  59. [
  60. {
  61. name: '新增',
  62. click: this.addOn(() => {
  63. this.addFn()
  64. })
  65. }
  66. ]
  67. ],
  68. [
  69. [
  70. {
  71. name: '批量删除',
  72. click: async () => {
  73. if (this.recordSelected.length === 0) {
  74. this.$message.error('请选择需要删除的数据')
  75. return
  76. }
  77. this.hanleDeleteAll()
  78. },
  79. isRole: this.$checkBtnRole('del', this.$route.meta.roles)
  80. }
  81. ]
  82. ],
  83. [
  84. [
  85. {
  86. name: '批量审批',
  87. click: async () => {
  88. this.batchExamine()
  89. }
  90. }
  91. ]
  92. ],
  93. [
  94. [
  95. {
  96. name: '',
  97. render: this.importButton(productUpdPriceMaterialImport, '导入', {
  98. billType: 'GENERAL'
  99. })
  100. }
  101. ]
  102. ],
  103. [
  104. [
  105. {
  106. name: '导入模版',
  107. click: () => {
  108. productUpdPriceDownload({}, `${this.$route.meta.title}`)
  109. .then(res => {
  110. this.$message({
  111. message: '下载成功',
  112. type: 'success'
  113. })
  114. })
  115. .catch(err => {
  116. this.$message.error('下载失败')
  117. })
  118. }
  119. }
  120. ]
  121. ]
  122. ],
  123. // 表格属性
  124. tableAttributes: {
  125. // 启用勾选列
  126. selectColumn: true
  127. },
  128. // 表格事件
  129. tableEvents: {
  130. 'selection-change': this.selectionChange
  131. },
  132. recordSelected: [],
  133. baseURL: '',
  134. importFileList: [],
  135. show: 1,
  136. currentPage: 1, // 当前页码
  137. pageSize: 10, // 每页数量
  138. listTotal: 0, // 列表总数
  139. dataList: [
  140. {
  141. baseUnitId: '',
  142. batchPrice: '',
  143. billId: '',
  144. endDate: '',
  145. id: null,
  146. isPromote: '',
  147. isPublish: '',
  148. materialId: '',
  149. materialName: '',
  150. materialNumber: '',
  151. parentId: '',
  152. qty: '',
  153. rebateUseRate: '',
  154. retailPrice: '',
  155. saleTypeId: '',
  156. specification: '',
  157. startDate: '',
  158. wallets: []
  159. }
  160. ],
  161. screenForm: {
  162. materialName: '',
  163. materialNumber: '',
  164. startDate: '',
  165. materialOldNumber: '',
  166. saleTypeId: '',
  167. k3CategoryNumber: '',
  168. specification: '',
  169. remark: ''
  170. },
  171. liDetail: {},
  172. detail: {},
  173. obj: {
  174. baseUnitId: '',
  175. batchPrice: '',
  176. billId: '',
  177. endDate: '',
  178. id: null,
  179. isPromote: '',
  180. isPublish: '',
  181. materialId: '4',
  182. materialName: '',
  183. materialNumber: '',
  184. parentId: '',
  185. qty: '',
  186. rebateUseRate: '',
  187. retailPrice: '',
  188. saleTypeId: '',
  189. specification: '',
  190. startDate: '',
  191. wallets: []
  192. },
  193. cid: '',
  194. typeList: [],
  195. dictList: [],
  196. isCollapse: true,
  197. importLoading: false,
  198. isShowExamineDialog: false,
  199. examineForm: {
  200. status: 'OK',
  201. remark: ''
  202. }
  203. }
  204. },
  205. components: {
  206. ExamineDialog,
  207. ModifyListApply,
  208. ModifyListApproval,
  209. ModifyListDetail,
  210. TemplatePage,
  211. Popu
  212. },
  213. computed: {
  214. exParams() {
  215. return {
  216. materialName: this.screenForm.materialName,
  217. materialNumber: this.screenForm.materialNumber,
  218. startDate: this.screenForm.startDate,
  219. materialOldNumber: this.screenForm.materialOldNumber,
  220. saleTypeId: this.screenForm.saleTypeId,
  221. k3CategoryNumber: this.screenForm.k3CategoryNumber,
  222. specification: this.screenForm.specification,
  223. remark: this.screenForm.remark,
  224. billType: 'HOME'
  225. }
  226. }
  227. },
  228. mounted() {
  229. let params = {
  230. pageNum: 1,
  231. pageSize: -1,
  232. saleCode: '',
  233. saleName: '',
  234. status: ''
  235. }
  236. getTypeList(params).then(res => {
  237. this.typeList = res.data.records
  238. })
  239. getCategoryList({ pageNum: 1, pageSize: -1 }).then(res => {
  240. this.dictList = res.data.records
  241. console.log(this.dictList, 777777)
  242. })
  243. },
  244. methods: {
  245. // 列表请求函数
  246. getList(...p) {
  247. let params = {
  248. moduleId: p[0].moduleId,
  249. orderBy: p[0].orderBy,
  250. pageNum: p[0].pageNum,
  251. pageSize: p[0].pageSize,
  252. params: [...p[0].params, { param: 'a.bill_type', compare: '=', value: 'HOME' }]
  253. }
  254. return v2ProductUpdPriceList(params)
  255. },
  256. // 列表导出函数
  257. // exportList: v2ProductUpdPriceListExport,
  258. exportList(...p) {
  259. let params = {
  260. exportFields: p[0].exportFields,
  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: 'HOME' }]
  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: 'HOME'
  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: 'HOME'
  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', 'HOME')
  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. },
  518. tableRowClassName({ row, rowIndex }) {
  519. // || row.examineStatus=='FAIL'
  520. if (this.ids.includes(row.updPriceBillId)) {
  521. return 'warning-row'
  522. }
  523. return ''
  524. }
  525. }
  526. }
  527. </script>
  528. <style lang="scss" scoped>
  529. ::v-deep .el-table .warning-row {
  530. background: oldlace;
  531. }
  532. ::v-deep .el-select--small {
  533. width: 100%;
  534. }
  535. .import-btn {
  536. display: inline-block;
  537. margin: 0 10px;
  538. }
  539. </style>