policy_list.vue 16 KB

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