policy_list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :get-list="getList"
  5. :operation="operation()"
  6. :options-evens-group="optionsEvensGroup"
  7. :export-list="exportList"
  8. :column-parsing="columnParsing"
  9. :table-attributes="tableAttributes"
  10. :table-events="tableEvents"
  11. :replace-or-not-map="false"
  12. :operation-column-width="200"
  13. :field-beans-hook="fieldBeansHook"
  14. >
  15. <popu v-if="isShow !== 1">
  16. <el-page-header slot="head" :content="content" @back="handleClose" />
  17. <add-policy
  18. v-if="isShow === 2"
  19. :is-show="isShow"
  20. :is-flag="isFlag"
  21. @close="handleClose"
  22. @upDataIsFlag="upDataIsFlag"
  23. />
  24. <edit-policy
  25. v-if="isShow === 3"
  26. :id="id"
  27. :is-show="isShow"
  28. :is-flag="isFlag"
  29. @close="handleClose"
  30. @upDataIsFlag="upDataIsFlag"
  31. />
  32. <Details v-if="isShow === 4" :id="id" :is-show="isShow" @close="handleClose" />
  33. <examine v-if="isShow === 5" :id="id" :is-show="isShow" @close="handleClose" />
  34. </popu>
  35. <el-dialog
  36. title="批量修改机型"
  37. :visible.sync="replaceVisible"
  38. width="80%"
  39. :append-to-body="true"
  40. :close-on-click-modal="false"
  41. @close="handleDialogClose"
  42. >
  43. <replace-record-form v-if="replaceVisible" :record-selected="recordSelected" @close="handleDialogClose" />
  44. </el-dialog>
  45. <el-dialog
  46. title="批量修改延期"
  47. :visible.sync="delayVisible"
  48. width="80%"
  49. :append-to-body="true"
  50. :close-on-click-modal="false"
  51. @close="handleDialogClose"
  52. >
  53. <delay-record-form v-if="delayVisible" :record-selected="recordSelected" @close="handleDialogClose" />
  54. </el-dialog>
  55. <el-dialog
  56. title="批量作废机型"
  57. :visible.sync="cancalVisible"
  58. width="80%"
  59. :append-to-body="true"
  60. :close-on-click-modal="false"
  61. @close="handleDialogClose"
  62. >
  63. <Cancal v-if="cancalVisible" :record-selected="recordSelected" @close="handleDialogClose" />
  64. </el-dialog>
  65. </template-page>
  66. </template>
  67. <script>
  68. import TemplatePage from '@/components/template/template-page-1.vue'
  69. import Popu from '@/components/template/popu.vue'
  70. import add_callback_mixin from '@/components/template/add_callback_mixin.js'
  71. import DelayRecordForm from './components/delayRecordForm.vue'
  72. import ReplaceRecordForm from './components/replaceRecordForm.vue'
  73. import Cancal from './components/cancal.vue';
  74. import {
  75. cancelPolicy,
  76. cloneList,
  77. deletePolicy,
  78. getCrList,
  79. getId,
  80. getpolicySubmit,
  81. toExamine,
  82. setAbandon,
  83. policyListV2,
  84. policyListV2Export
  85. } from '@/api/policy_list'
  86. import { downloadFiles, handleImport } from '@/utils/util'
  87. import AddPolicy from './components/AddPolicy'
  88. import EditPolicy from './components/editPolicy'
  89. import Details from './components/details.vue'
  90. import Examine from './components/Examine'
  91. import { mapState } from 'vuex'
  92. export default {
  93. mixins: [add_callback_mixin],
  94. data() {
  95. return {
  96. replaceVisible: false,
  97. delayVisible: false,
  98. cancalVisible: false,
  99. showPage: true,
  100. // 事件组合
  101. optionsEvensGroup: [
  102. [
  103. [
  104. {
  105. name: '新增',
  106. click: this.addOn(() => {
  107. this.hanlenewInfo()
  108. })
  109. }
  110. ]
  111. ],
  112. [
  113. [
  114. {
  115. name: '批量修改机型',
  116. click: () => {
  117. this.replaceVisible = true
  118. }
  119. }
  120. ]
  121. ],
  122. [
  123. [
  124. {
  125. name: '批量作废机型',
  126. click: () => {
  127. if (!this.recordSelected.length) {
  128. this.$errorMsg('请选择内容')
  129. return
  130. }
  131. this.cancalVisible = true
  132. }
  133. }
  134. ]
  135. ],
  136. [
  137. [
  138. {
  139. name: '批量修改延期',
  140. isRole: this.$checkBtnRole('yanqi', this.$route.meta.roles),
  141. click: () => {
  142. if (!this.recordSelected.length) {
  143. this.$errorMsg('请选择内容')
  144. return
  145. }
  146. for (let i = 0; i < this.recordSelected.length; i++) {
  147. if (this.recordSelected[i].examineStatus !== 'OK') {
  148. this.$errorMsg('请选择审核通过的政策')
  149. return
  150. }
  151. }
  152. this.delayVisible = true
  153. }
  154. }
  155. ]
  156. ]
  157. ],
  158. // 表格属性
  159. tableAttributes: {
  160. // 启用勾选列
  161. selectColumn: true
  162. },
  163. // 表格事件
  164. tableEvents: {
  165. 'selection-change': this.selectionChange
  166. },
  167. recordSelected: [],
  168. //
  169. id: '',
  170. code: '',
  171. codeId: '',
  172. listLoading: false,
  173. policyId: '',
  174. CrList: [],
  175. isShow: 1,
  176. dataList: [],
  177. screenForm: {
  178. code: '',
  179. createBy: '',
  180. endCreateTime: '',
  181. endTime1: '',
  182. endTime2: '',
  183. examineBy: '',
  184. remark: '',
  185. startCreateTime: '',
  186. startTime1: '',
  187. startTime2: '',
  188. status: '',
  189. title: '',
  190. type: '',
  191. customerId: '',
  192. specification: '',
  193. customerNumber: ''
  194. },
  195. fileList: [],
  196. statusOptions: [
  197. {
  198. value: true,
  199. label: '已生效'
  200. },
  201. {
  202. value: false,
  203. label: '未生效'
  204. }
  205. ],
  206. typeOptions: [
  207. {
  208. vlaue: 'PROVISION',
  209. label: '配提'
  210. },
  211. {
  212. value: 'LIMIT',
  213. label: '限量'
  214. }
  215. ],
  216. typeList: [],
  217. value: '',
  218. imageUrl: '',
  219. baseURL: '',
  220. isFlag: '',
  221. isCollapse: true
  222. }
  223. },
  224. created() {
  225. const customerParams = {
  226. pageNum: 1,
  227. pageSize: -1,
  228. keyword: '',
  229. region: ''
  230. }
  231. // 获取经销商列表
  232. getCrList(customerParams).then(res => {
  233. this.CrList = res.data.records
  234. })
  235. },
  236. computed: mapState({
  237. comCode: state => state.sales.code,
  238. content() {
  239. const textArr = ['新增', '编辑', '详情', '审核']
  240. return textArr[this.isShow - 2]
  241. }
  242. }),
  243. methods: {
  244. handleDialogClose() {
  245. this.replaceVisible = false
  246. this.delayVisible = false
  247. this.cancalVisible = false
  248. this.$refs.pageRef.refreshList()
  249. },
  250. fieldBeansHook(list) {
  251. return [
  252. ...list,
  253. {
  254. adminUserId: null,
  255. colName: 'specification',
  256. enumMap: '{}',
  257. frontCode: '',
  258. hide: false,
  259. isCopy: false,
  260. isQuery: true,
  261. isShow: false,
  262. isTotal: false,
  263. jname: 'specification',
  264. label: '机型规格',
  265. multiple: false,
  266. pk: false,
  267. sortNum: 0,
  268. tbName: '',
  269. type: 'input',
  270. noUse: true
  271. },
  272. {
  273. adminUserId: null,
  274. colName: 'specification2',
  275. enumMap: '{}',
  276. frontCode: '',
  277. hide: false,
  278. isCopy: false,
  279. isQuery: true,
  280. isShow: false,
  281. isTotal: false,
  282. jname: 'specification2',
  283. label: '已作废机型',
  284. multiple: false,
  285. pk: false,
  286. sortNum: 0,
  287. tbName: '',
  288. type: 'input',
  289. noUse: true
  290. },
  291. {
  292. adminUserId: null,
  293. colName: 'customer_id',
  294. enumMap: '{}',
  295. frontCode: 'CUSTOMER',
  296. hide: false,
  297. isCopy: false,
  298. isQuery: true,
  299. isShow: false,
  300. isTotal: false,
  301. jname: 'customerId',
  302. label: '经销商',
  303. multiple: false,
  304. pk: false,
  305. sortNum: 0,
  306. tbName: '',
  307. type: 'select',
  308. noUse: true
  309. }
  310. ]
  311. },
  312. // 列表请求函数
  313. getList(p) {
  314. var pm = JSON.parse(JSON.stringify(p))
  315. var specification, customerId, specification2
  316. for (let i = 0; i < pm.params.length; i++) {
  317. if (pm.params[i].param === 'specification') {
  318. specification = pm.params[i].value
  319. pm.params.splice(i, 1)
  320. }
  321. }
  322. for (let i = 0; i < pm.params.length; i++) {
  323. if (pm.params[i].param === 'customer_id') {
  324. customerId = pm.params[i].value
  325. pm.params.splice(i, 1)
  326. }
  327. }
  328. for (let i = 0; i < pm.params.length; i++) {
  329. if (pm.params[i].param === 'specification2') {
  330. specification2 = pm.params[i].value
  331. pm.params.splice(i, 1)
  332. }
  333. }
  334. return policyListV2({ ...pm, specification, customerId, specification2 })
  335. },
  336. // 列表导出函数
  337. exportList: policyListV2Export,
  338. // 表格列解析渲染数据更改
  339. columnParsing(item, defaultData) {
  340. return defaultData
  341. },
  342. // 监听勾选变化
  343. selectionChange(data) {
  344. this.recordSelected = data
  345. },
  346. upDataIsFlag() {
  347. this.isFlag = 1
  348. },
  349. handleClose() {
  350. this.addOff(() => {
  351. this.isShow = 1
  352. this.showPage = true
  353. this.$refs.pageRef.refreshList()
  354. })()
  355. },
  356. operation() {
  357. return (h, { row, index, column }) => {
  358. return (
  359. <div class='operation-btns'>
  360. {row.examineStatus == 'SAVE' ? (
  361. <el-button
  362. size='mini'
  363. type='text'
  364. onClick={async() => {
  365. this.isShow = 3
  366. this.id = row.id
  367. }}
  368. >
  369. 编辑
  370. </el-button>
  371. ) : (
  372. ''
  373. )}
  374. <el-button
  375. size='mini'
  376. type='text'
  377. onClick={async() => {
  378. this.isShow = 4
  379. this.id = row.id
  380. this.code = row.code
  381. }}
  382. >
  383. 详情
  384. </el-button>
  385. {row.examineStatus == 'WAIT' && this.$checkBtnRole('examine', this.$route.meta.roles) ? (
  386. <el-button
  387. size='mini'
  388. type='text'
  389. onClick={async() => {
  390. this.isShow = 5
  391. this.id = row.id
  392. this.code = row.code
  393. this.policyId = row.policyId
  394. }}
  395. >
  396. 审核
  397. </el-button>
  398. ) : (
  399. ''
  400. )}
  401. {row.examineStatus == 'SAVE' ? (
  402. <el-popconfirm
  403. onConfirm={async() => {
  404. this.handlesubmit(row)
  405. }}
  406. title='是否确定需要提审该项内容?'
  407. >
  408. <el-button slot='reference' size='mini' type='text'>
  409. 提审
  410. </el-button>
  411. </el-popconfirm>
  412. ) : (
  413. ''
  414. )}
  415. {row.examineStatus == 'OK' && row.status ? (
  416. <el-popconfirm
  417. onConfirm={async() => {
  418. this.handleNullify(row)
  419. }}
  420. title='是否确定需要作废该项内容?'
  421. >
  422. <el-button slot='reference' size='mini' type='text'>
  423. 作废
  424. </el-button>
  425. </el-popconfirm>
  426. ) : (
  427. ''
  428. )}
  429. {(
  430. <el-popconfirm
  431. onConfirm={async() => {
  432. this.handleClone(row)
  433. }}
  434. title='是否确定需要克隆该项内容?'
  435. >
  436. <el-button slot='reference' size='mini' type='text'>
  437. 克隆
  438. </el-button>
  439. </el-popconfirm>
  440. ) }
  441. {row.examineStatus != 'OK' ? (
  442. <el-popconfirm
  443. onConfirm={async() => {
  444. this.hanleDelete(row.id)
  445. }}
  446. title='是否确定需要删除该项内容?'
  447. >
  448. <el-button slot='reference' size='mini' type='text'>
  449. 删除
  450. </el-button>
  451. </el-popconfirm>
  452. ) : (
  453. ''
  454. )}
  455. {row.examineStatus == 'OK' ? (
  456. <el-popconfirm
  457. onConfirm={async() => {
  458. this.hanleAbandon(row.id)
  459. }}
  460. title='是否确定需要弃审该项内容?'
  461. >
  462. <el-button slot='reference' size='mini' type='text'>
  463. 弃审
  464. </el-button>
  465. </el-popconfirm>
  466. ) : (
  467. ''
  468. )}
  469. </div>
  470. )
  471. }
  472. },
  473. tableRowClassName({ row, rowIndex }) {
  474. // || row.examineStatus=='FAIL'
  475. if (row.status == 0) {
  476. return 'warning-row'
  477. }
  478. return ''
  479. },
  480. hanlenewInfo() {
  481. console.log()
  482. getId().then(res => {
  483. this.$store.commit('sales/setId', res.data)
  484. this.isShow = 2
  485. })
  486. },
  487. handleClone(row) {
  488. cloneList({ policyId: row.id }).then(res => {
  489. this.$refs.pageRef.refreshList()
  490. this.$message.success('克隆成功')
  491. })
  492. },
  493. // getList() {
  494. // this.listLoading = true
  495. // const params = {
  496. // pageNum: this.currentPage,
  497. // pageSize: this.pageSize,
  498. // code: this.screenForm.code,
  499. // type: this.screenForm.type,
  500. // createBy: this.screenForm.createBy,
  501. // endCreateTime: this.screenForm.endCreateTime,
  502. // endTime1: this.screenForm.endTime1,
  503. // endTime2: this.screenForm.endTime2,
  504. // examineBy: this.screenForm.examineBy,
  505. // remark: this.screenForm.remark,
  506. // startCreateTime: this.screenForm.startCreateTime,
  507. // startTime1: this.screenForm.startTime1,
  508. // startTime2: this.screenForm.startTime2,
  509. // status: this.screenForm.status,
  510. // title: this.screenForm.title,
  511. // customerId: this.screenForm.customerId,
  512. // customerNumber: this.screenForm.customerNumber,
  513. // specification: this.screenForm.specification
  514. // }
  515. // getList(params).then(res => {
  516. // this.dataList = res.data.records
  517. // console.log(this.dataList)
  518. // this.listTotal = res.data.total
  519. // this.listLoading = false
  520. // })
  521. // // 产品类型
  522. // // const paramsType = {
  523. // // pageNum: 1,
  524. // // pageSize: 10,
  525. // // saleCdoe: '',
  526. // // saleName: '',
  527. // // stauts: ''
  528. // // }
  529. // // getTypeList(paramsType).then(res => {
  530. // // this.typeList = res.data.records
  531. // // })
  532. // },
  533. hanleAbandon(id) {
  534. setAbandon({ policyId: id }).then(res => {
  535. this.$refs.pageRef.refreshList()
  536. this.$message.success('弃审成功')
  537. })
  538. },
  539. hanleDelete(id) {
  540. this.hanleDeleteAllPromise(id).then(ids => {
  541. deletePolicy({
  542. id: ids[0]
  543. }).then(res => {
  544. this.$refs.pageRef.refreshList()
  545. this.$message.success('删除成功')
  546. })
  547. })
  548. },
  549. hanleDeleteAllPromise(id) {
  550. return new Promise((resolve, reject) => {
  551. const ids = id ? [id] : this.ids
  552. if (!ids.length) {
  553. this.$errorMsg('请选择删除内容')
  554. return
  555. }
  556. resolve(ids)
  557. })
  558. },
  559. // 作废
  560. handleNullify(row) {
  561. cancelPolicy({ id: row.id }).then(res => {
  562. this.$refs.pageRef.refreshList()
  563. this.$message.success('作废成功')
  564. })
  565. },
  566. // 导出文档
  567. handleExport() {
  568. const screenData = {
  569. customerTel: this.diaLogForm.customerTel,
  570. logisticsCompany: this.diaLogForm.logisticsCompany
  571. }
  572. downloadFiles('policy/export', screenData)
  573. },
  574. // 导入
  575. async handleImport(param) {
  576. this.importLoading = true
  577. const file = param.file
  578. console.log(file, 123)
  579. const formData = new FormData()
  580. formData.append('file', file)
  581. const result = await handleImport('/policy/material/import', formData)
  582. this.importLoading = false
  583. this.importFileList = []
  584. if (result.code == 200) {
  585. this.$alert('导入成功', '导入成功', {
  586. confirmButtonText: '确定'
  587. })
  588. this.getList()
  589. } else {
  590. this.$alert('导入失败', '导入失败', {
  591. confirmButtonText: '确定'
  592. })
  593. }
  594. },
  595. handlesubmit(e) {
  596. getpolicySubmit({ policyId: e.id }).then(res => {
  597. this.$refs.pageRef.refreshList()
  598. this.$message.success('提审成功')
  599. })
  600. },
  601. hanleExamine(e) {
  602. if (e.examineStatus == 'WAIT') {
  603. toExamine({
  604. examineRemark: e.id,
  605. examineStatus: 'WAIT',
  606. policyId: e.id
  607. }).then(res => {
  608. this.$successMsg('已提交')
  609. })
  610. } else {
  611. this.$errorMsg('未满足条件')
  612. }
  613. }
  614. },
  615. // eslint-disable-next-line vue/order-in-components
  616. components: {
  617. TemplatePage,
  618. Popu,
  619. Cancal,
  620. Examine,
  621. Details,
  622. AddPolicy,
  623. EditPolicy,
  624. DelayRecordForm,
  625. ReplaceRecordForm
  626. }
  627. }
  628. </script>
  629. <style lang="scss" scoped>
  630. ::v-deep .el-table .warning-row {
  631. background: oldlace;
  632. }
  633. // ::v-deep .el-table .success-row {
  634. // background: #f0f9eb;
  635. // }
  636. .btn {
  637. width: 80px;
  638. }
  639. .mpd {
  640. padding: 20px 0 0 0;
  641. }
  642. .select_height {
  643. width: 100%;
  644. }
  645. .import-btn {
  646. margin: 0 10px;
  647. }
  648. .header {
  649. display: flex;
  650. height: 50px;
  651. align-items: center;
  652. }
  653. .fr {
  654. margin: 20px 0;
  655. }
  656. </style>