editPolicy.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. <template>
  2. <div>
  3. <div v-show="isCondition == 0">
  4. <el-header height="50px" class="header">
  5. <el-page-header
  6. content="编辑"
  7. @back="($parent.isShow = 1), ($parent.isFlag = '')"
  8. />
  9. </el-header>
  10. <div class="app-container">
  11. <div class="screen-container">
  12. <h4>销售政策信息</h4>
  13. <el-divider />
  14. <el-form
  15. ref="form"
  16. :model="searchForm"
  17. label-width="120px"
  18. size="small"
  19. class="demo-searchForm"
  20. >
  21. <el-row>
  22. <el-col :xs="24" :ms="12" :lg="12">
  23. <el-form-item label="销售政策编号">
  24. <el-input
  25. v-model="searchForm.code"
  26. disabled
  27. placeholder="如未填写,则系统自动生成"
  28. />
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xs="24" :ms="12" :lg="12">
  32. <el-form-item label="销售政策名称" prop="title">
  33. <el-input
  34. v-model="searchForm.title"
  35. placeholder="销售政策名称"
  36. />
  37. </el-form-item>
  38. </el-col>
  39. <el-col :xs="24" :ms="12" :lg="12">
  40. <el-form-item label="销售政策类型" prop="type">
  41. <el-select
  42. v-model="searchForm.type"
  43. size="small"
  44. placeholder="销售政策类型"
  45. class="select_height"
  46. >
  47. <el-option
  48. v-for="(item, index) in typeOptions"
  49. :key="index"
  50. :label="item.label"
  51. :value="item.value"
  52. />
  53. </el-select>
  54. </el-form-item>
  55. </el-col>
  56. <!-- <el-col :xs="24" :ms="12" :lg="12">
  57. <el-form-item label="产品品类" prop="mainId">
  58. <el-select
  59. v-model="searchForm.mainId"
  60. :disabled="dataList.length ? true : false"
  61. placeholder="请选择"
  62. @change="handelStop"
  63. >
  64. <el-option
  65. v-for="item in dictList"
  66. :label="item.dictValue"
  67. :value="item.dictCode"
  68. ></el-option>
  69. </el-select>
  70. </el-form-item>
  71. </el-col> -->
  72. <el-col :xs="24" :ms="12" :lg="12">
  73. <el-form-item label="生效日期" prop="startTime">
  74. <el-date-picker
  75. v-model="searchForm.startTime"
  76. type="datetime"
  77. placeholder="生效日期"
  78. default-time="00:00:00"
  79. value-format="yyyy-MM-dd HH:mm:ss"
  80. /> </el-form-item></el-col>
  81. <el-col :xs="24" :ms="12" :lg="12">
  82. <el-form-item label="失效日期" prop="endTime">
  83. <el-date-picker
  84. v-model="searchForm.endTime"
  85. type="datetime"
  86. placeholder="失效日期"
  87. default-time="00:00:00"
  88. value-format="yyyy-MM-dd HH:mm:ss"
  89. /> </el-form-item></el-col>
  90. <el-col :xs="24" :ms="24" :lg="24">
  91. <el-form-item label="销售政策说明" prop="remark">
  92. <el-input
  93. v-model="searchForm.remark"
  94. placeholder="新风机变频挂机。按提货数量1:3开单"
  95. />
  96. </el-form-item>
  97. </el-col>
  98. <el-col :xs="24" :ms="24" :lg="24">
  99. <el-form-item label="政策封面图">
  100. <ImageUpload :file-list="fileList" :multiple="false" />
  101. </el-form-item>
  102. </el-col>
  103. </el-row>
  104. </el-form>
  105. </div>
  106. <div class="mymian-container">
  107. <el-row>
  108. <el-divider />
  109. <el-row type="flex">
  110. <el-col :span="12">
  111. <h4 style="display: inline-block; margin-right: 20px">
  112. 货品信息
  113. </h4>
  114. <template>
  115. <el-upload
  116. class="import-btn"
  117. :action="baseURL + 'student/import'"
  118. :http-request="handleImport"
  119. :file-list="importFileList"
  120. :show-file-list="false"
  121. >
  122. <el-button
  123. type="primary"
  124. size="small"
  125. >导入货品价格表</el-button>
  126. </el-upload>
  127. </template>
  128. <el-button
  129. type="primary"
  130. size="small"
  131. @click="hanleDownloadFiles"
  132. >下载模板</el-button>
  133. </el-col>
  134. </el-row>
  135. <el-divider />
  136. </el-row>
  137. <el-table
  138. v-loading="listLoading"
  139. :data="dataList"
  140. element-loading-text="Loading"
  141. border
  142. fit
  143. highlight-current-row
  144. stripe
  145. >
  146. <el-table-column
  147. type="index"
  148. label="序号"
  149. width="50"
  150. align="center"
  151. />
  152. <el-table-column
  153. prop="materialNumber"
  154. label="货品编码"
  155. align="center"
  156. >
  157. <template slot-scope="scope">
  158. <el-select
  159. v-model="scope.row.materialNumber"
  160. v-el-select-loadmore="loadmore"
  161. size="small"
  162. :remote-method="(query)=>remoteMethod(query,'number')"
  163. filterable
  164. remote
  165. @change="handleK3List($event, scope.row)"
  166. >
  167. <el-option
  168. v-for="item in k3List"
  169. :key="item.id"
  170. :label="item.number"
  171. :value="item.id"
  172. />
  173. </el-select>
  174. </template>
  175. </el-table-column>
  176. <el-table-column
  177. prop="materialName"
  178. label="货品名称"
  179. align="center"
  180. />
  181. <el-table-column
  182. prop="specification"
  183. label="规格型号"
  184. align="center"
  185. >
  186. <template slot-scope="scope">
  187. <el-select
  188. v-model="scope.row.specification"
  189. size="small"
  190. :remote-method="(query)=>remoteMethod(query,'specification')"
  191. filterable
  192. remote
  193. @change="handleK3List($event, scope.row)"
  194. >
  195. <el-option
  196. v-for="item in k3List"
  197. :key="item.id"
  198. :label="item.specification"
  199. :value="item.id"
  200. />
  201. </el-select>
  202. </template>
  203. </el-table-column>
  204. <el-table-column
  205. prop="saleTypeName"
  206. label="销售类型"
  207. align="center"
  208. >
  209. <template slot-scope="scope">
  210. <el-select
  211. v-model="scope.row.saleTypeId"
  212. size="small"
  213. filterable
  214. @change="handleSalesType($event, scope.row)"
  215. >
  216. <el-option
  217. v-for="item in typeList"
  218. :key="item.id"
  219. :label="item.saleName"
  220. :value="item.id"
  221. />
  222. </el-select>
  223. </template>
  224. </el-table-column>
  225. <el-table-column
  226. prop="saleTypeCode"
  227. label="销售类型编码"
  228. align="center"
  229. />
  230. <el-table-column prop="discAmount" label="格力折扣" align="center">
  231. <template slot-scope="scope">
  232. <el-input
  233. v-model.number="scope.row.discAmount"
  234. type="number"
  235. placeholder="请输入格力折扣"
  236. size="small"
  237. />
  238. </template>
  239. </el-table-column>
  240. <el-table-column prop="price" label="单价" align="center">
  241. <template slot-scope="scope">
  242. <el-input
  243. v-model.number="scope.row.price"
  244. type="number"
  245. placeholder="请输入单价"
  246. size="small"
  247. />
  248. </template>
  249. </el-table-column>
  250. <el-table-column label="支付钱包" align="center">
  251. <template slot-scope="scope">
  252. <el-select
  253. v-model="scope.row.walletIds"
  254. size="small"
  255. multiple
  256. filterable
  257. >
  258. <el-option
  259. v-for="item in NoRebateWalletList"
  260. :key="item.id"
  261. :label="item.name"
  262. :value="item.id"
  263. />
  264. </el-select>
  265. <!-- <el-tag
  266. style="margin: 5px"
  267. type="success"
  268. size="small"
  269. v-for="item in scope.row.walletRelaList"
  270. >{{ item.walletName }}</el-tag
  271. > -->
  272. </template>
  273. </el-table-column>
  274. <el-table-column prop="remark" label="备注" align="center">
  275. <template slot-scope="scope">
  276. <el-input
  277. v-model="scope.row.remark"
  278. placeholder="备注"
  279. size="small"
  280. />
  281. </template>
  282. </el-table-column>
  283. <el-table-column fixed="right" label="操作" align="center">
  284. <template slot-scope="scope">
  285. <el-popconfirm
  286. confirm-button-text="好的"
  287. cancel-button-text="不用了"
  288. icon="el-icon-info"
  289. icon-color="red"
  290. title="内容确定删除吗?"
  291. @onConfirm="hanleDelete(scope.row.id, scope.$index)"
  292. >
  293. <el-button
  294. slot="reference"
  295. type="text"
  296. class="textColor el-popover-left"
  297. >删除</el-button>
  298. </el-popconfirm>
  299. </template>
  300. </el-table-column>
  301. </el-table>
  302. <!-- 分页 -->
  303. <div
  304. style="
  305. margin: 20px 20px 20px 0;
  306. display: flex;
  307. justify-content: space-between;
  308. "
  309. >
  310. <div>
  311. <el-button
  312. type="primary"
  313. size="small"
  314. @click="handleNewInfo"
  315. >添加</el-button>
  316. <el-button
  317. type="primary"
  318. size="small"
  319. @click="handleSave"
  320. >保存</el-button>
  321. </div>
  322. <el-pagination
  323. :current-page="dcurrentPage"
  324. :page-sizes="pageSizeArr"
  325. :page-size="size"
  326. layout="total, sizes, prev, pager, next, jumper"
  327. :total="listTotal"
  328. @size-change="handleSizeChange2"
  329. @current-change="handleCurrentChange2"
  330. />
  331. </div>
  332. <el-row>
  333. <el-divider />
  334. <el-row type="flex">
  335. <el-col :span="12">
  336. <h4 style="display: inline-block; margin-right: 20px">
  337. 条件信息
  338. </h4>
  339. <el-button
  340. type="primary"
  341. size="small"
  342. @click="addCondition"
  343. >添加</el-button></el-col>
  344. </el-row>
  345. <el-divider />
  346. </el-row>
  347. <el-table
  348. v-loading="listLoading"
  349. :data="conditionList"
  350. element-loading-text="Loading"
  351. border
  352. fit
  353. highlight-current-row
  354. stripe
  355. >
  356. <el-table-column
  357. fixed
  358. type="index"
  359. label="序号"
  360. width="50"
  361. align="center"
  362. />
  363. <el-table-column prop="name" label="限定条件" align="center">
  364. <template slot-scope="scope">
  365. <el-input
  366. v-model="scope.row.name"
  367. style="text-align: center"
  368. placeholder="请输入名称"
  369. :disabled="scope.row.fang"
  370. @blur="handleConditionName(scope.row)"
  371. />
  372. </template>
  373. </el-table-column>
  374. <el-table-column
  375. fixed="right"
  376. width="150"
  377. label="操作"
  378. align="center"
  379. >
  380. <template slot-scope="scope">
  381. <el-button
  382. type="text"
  383. size="small"
  384. @click="scope.row.fang = false"
  385. >编辑</el-button>
  386. <el-button
  387. type="text"
  388. size="small"
  389. @click="handleCondition(scope.row.id, scope.$index)"
  390. >删除</el-button>
  391. </template>
  392. </el-table-column>
  393. </el-table>
  394. </div>
  395. <div>
  396. <el-row>
  397. <el-divider />
  398. <el-row type="flex" align="middle">
  399. <el-col :span="2">
  400. <h4>经销商信息</h4>
  401. </el-col>
  402. </el-row>
  403. <el-divider />
  404. </el-row>
  405. <TabelTransfer v-if="detail && detail.code" :code="detail.code" @handlEditPolicy="handlEditPolicy" @handleReset="handleReset" />
  406. </div>
  407. </div>
  408. </div>
  409. <AddCondition
  410. v-show="isCondition === 1"
  411. @handleSubmitCon="handleSubmitCon"
  412. />
  413. </div>
  414. </template>
  415. <script>
  416. import { mapGetters, mapMutations } from 'vuex'
  417. import Minxin from '@/mixin'
  418. import {
  419. deleteCondition,
  420. deleteMaterialPolicy,
  421. getConditionList,
  422. getK3List,
  423. getMaterialList,
  424. getNoRebateWalletList,
  425. getPolicyDetail,
  426. getTypeList,
  427. savePolicy,
  428. updateCondition,
  429. updatePolicy
  430. } from '@/api/policy_list'
  431. import { downloadFiles, handleImport } from '@/utils/util'
  432. // import Transfer from './Transfer'
  433. import TabelTransfer from './TabelTransfer'
  434. import AddCondition from './AddCondition'
  435. import ImageUpload from '@/components/Common/image-upload.vue'
  436. export default {
  437. directives: {
  438. 'el-select-loadmore': {
  439. bind(el, binding) {
  440. // 获取element-ui定义好的scroll盒⼦
  441. const SELECTWRAP_DOM = el.querySelector(
  442. '.el-select-dropdown .el-select-dropdown__wrap'
  443. )
  444. SELECTWRAP_DOM.addEventListener('scroll', function() {
  445. /**
  446. * scrollHeight 获取元素内容⾼度(只读)
  447. * scrollTop 获取或者设置元素的偏移值,常⽤于, 计算滚动条的位置, 当⼀个元素的容器没有产⽣垂直⽅向的滚动条, 那它的scrollTop的值默认为0.
  448. * clientHeight 读取元素的可见⾼度(只读)
  449. * 如果元素滚动到底, 下⾯等式返回true, 没有则返回false:
  450. * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
  451. */
  452. const condition =
  453. this.scrollHeight - this.scrollTop <= this.clientHeight
  454. if (condition) {
  455. binding.value()
  456. }
  457. })
  458. }
  459. }
  460. },
  461. mixins: [Minxin],
  462. data() {
  463. return {
  464. fang: false,
  465. input: '',
  466. baseURL: '',
  467. isCondition: 0,
  468. searchForm: {
  469. code: '',
  470. endTime: '',
  471. imgSrc: '',
  472. remark: '',
  473. startTime: '',
  474. title: '',
  475. mainId: '',
  476. mainName: '',
  477. type: ''
  478. },
  479. dataList: [],
  480. addList: [],
  481. pageSizeArr: [10, 20, 30, 50],
  482. size: 10,
  483. listLoading: false,
  484. dialogVisible: false,
  485. importFileList: [],
  486. fileList: [],
  487. options: {},
  488. value: '',
  489. typeList: [],
  490. walletList: [],
  491. typeOptions: [
  492. {
  493. value: 'PROVISION',
  494. label: '配提'
  495. },
  496. {
  497. value: 'LIMIT',
  498. label: '限量'
  499. }
  500. ],
  501. conditionList: [],
  502. dictList: [],
  503. k3List: [],
  504. NoRebateWalletList: [],
  505. sleectBox: { currentPage: 1 },
  506. dpageSize: 10,
  507. dcurrentPage: 1,
  508. detail:{}
  509. }
  510. },
  511. computed: {
  512. ...mapGetters({
  513. comCode: 'code'
  514. })
  515. },
  516. created() {
  517. this.getCommonApi()
  518. // console.log(this.$store.code);
  519. if (this.$parent.isFlag) {
  520. // this.handletwoList()
  521. }
  522. },
  523. methods: {
  524. ...mapMutations('sales', ['initData']),
  525. // 下载excel模板
  526. hanleDownloadFiles() {
  527. downloadFiles('/policy/download')
  528. },
  529. handleCondition(id, index) {
  530. deleteCondition({ id }).then((res) => {
  531. this.conditionList.splice(index, 1)
  532. Object.assign(
  533. this.$children[9].$data,
  534. this.$children[9].$options.data()
  535. )
  536. this.$successMsg('删除成功')
  537. })
  538. },
  539. addCondition() {
  540. this.isCondition = 1
  541. this.$store.commit('sales/setId', this.searchForm.code)
  542. },
  543. loadmore() {
  544. this.sleectBox.currentPage++
  545. this.getK3List()
  546. },
  547. getK3List() {
  548. getK3List({
  549. pageNum: this.sleectBox.currentPage,
  550. pageSize: 10,
  551. keyword: ''
  552. }).then((res) => {
  553. this.k3List = [...this.k3List, ...res.data.records]
  554. })
  555. },
  556. remoteMethod(query, type) {
  557. console.log(query, type)
  558. if (query !== '') {
  559. getK3List({
  560. pageNum: 1,
  561. pageSize: -1,
  562. keyword: '',
  563. number: type === 'number' ? query : '',
  564. oldNumber: '',
  565. specification: type === 'specification' ? query : ''
  566. }).then((res) => {
  567. this.k3List = res.data.records
  568. })
  569. } else {
  570. this.sleectBox.currentPage = 1
  571. this.getK3List()
  572. }
  573. },
  574. getCommonApi() {
  575. this.getK3List()
  576. // 非返利钱包
  577. getNoRebateWalletList({ walletName: '' }).then((res) => {
  578. this.NoRebateWalletList = res.data
  579. console.log(this.NoRebateWalletList, 'kkkk')
  580. })
  581. const params = {
  582. pageNum: 1,
  583. pageSize: -1,
  584. saleCode: '',
  585. saleName: '',
  586. status: ''
  587. }
  588. // 获取销售类型列表
  589. getTypeList(params).then((res) => {
  590. this.typeList = res.data.records
  591. })
  592. // this.handletwoList()
  593. // const params = {
  594. // pageNum: 1,
  595. // pageSize: 10,
  596. // saleCode: "",
  597. // saleName: "",
  598. // status: "",
  599. // };
  600. // const walletParams = {
  601. // pageNum: 1,
  602. // pageSize: 10,
  603. // mainName: "",
  604. // saleTypeCode: "",
  605. // saleTypeName: "",
  606. // status: "",
  607. // };
  608. // // 获取钱包列表
  609. // getWalletList(walletParams).then((res) => {
  610. // this.walletList = res.data.records;
  611. // });
  612. // getDictList({ sysDictEnum: "PRODUCT_TYPE" }).then((res) => {
  613. // this.dictList = res.data;
  614. // });
  615. },
  616. handleSalesType(e, row) {
  617. const item = this.typeList.filter((k) => {
  618. return k.id == e
  619. })[0]
  620. this.$set(row, 'saleTypeCode', item.saleCode)
  621. this.$set(row, 'saleTypeName', item.saleName)
  622. // this.$set(row,'saleTypeId',item.id)
  623. },
  624. // 修改条件名称
  625. handleConditionName(row) {
  626. console.log(row.name)
  627. updateCondition({ id: row.id, name: row.name }).then((res) => {
  628. this.$successMsg('修改成功')
  629. row.fang = true
  630. })
  631. },
  632. // 提交信息
  633. handleSubmitCon() {
  634. const params = {
  635. policyId: this.searchForm.code
  636. }
  637. // 获取条件政策
  638. getConditionList(params).then((res) => {
  639. for (let i = 0; i < res.data.length; i++) {
  640. res.data[i].fang = true
  641. }
  642. this.conditionList = res.data
  643. })
  644. },
  645. // 视图部分已注释,废弃的功能 fucn
  646. handelStop() {
  647. if (this.searchForm.mainId) {
  648. this.fang = true
  649. } else {
  650. this.$errorMsg('请选择产品品类')
  651. }
  652. },
  653. // 导入
  654. async handleImport(param) {
  655. this.importLoading = true
  656. const file = param.file
  657. console.log(file, 123)
  658. const formData = new FormData()
  659. formData.append('file', file)
  660. formData.append('policyId', this.searchForm.code)
  661. // formData.append("mainId", this.searchForm.mainId);
  662. const result = await handleImport('/policy/material/import', formData)
  663. this.importLoading = false
  664. this.importFileList = []
  665. if (result.code == 200) {
  666. this.$alert(result.message, '导入成功', {
  667. confirmButtonText: '确定'
  668. })
  669. this.dataList = []
  670. this.listTotal = 0
  671. this.sleectBox.currentPage = 1
  672. this.handletwoList()
  673. } else {
  674. this.$alert(result.message, '导入失败', {
  675. confirmButtonText: '确定'
  676. })
  677. }
  678. },
  679. getList() {
  680. getPolicyDetail({ policyId: this.$parent.id }).then((res) => {
  681. this.detail = res.data
  682. this.searchForm = {
  683. code: this.detail.code,
  684. endTime: this.detail.endTime,
  685. imgSrc: this.detail.imgSrc,
  686. remark: this.detail.remark,
  687. startTime: this.detail.startTime,
  688. title: this.detail.title,
  689. type: this.detail.type
  690. },
  691. this.srcList = [this.$imageUrl + this.detail.imgSrc]
  692. if (this.$parent.isShow == 5 && this.detail.imgSrc) {
  693. this.fileList = [
  694. {
  695. hover: '',
  696. url: this.detail.imgSrc
  697. }
  698. ]
  699. }
  700. this.handletwoList()
  701. // 获取条件政策
  702. this.handleSubmitCon()
  703. })
  704. if (this.$parent.isFlag) {
  705. this.handletwoList()
  706. }
  707. },
  708. // 更改每页数量
  709. handleSizeChange1(val) {
  710. this.pageSize = val
  711. this.currentPage = 1
  712. this.handletwoList()
  713. },
  714. // 更改当前页
  715. handleCurrentChange1(val) {
  716. this.currentPage = val
  717. this.handletwoList()
  718. },
  719. // 更改每页数量
  720. handleSizeChange2(val) {
  721. this.dpageSize = val
  722. this.dcurrentPage = 1
  723. this.handletwoList()
  724. },
  725. // 更改当前页
  726. handleCurrentChange2(val) {
  727. this.dcurrentPage = val
  728. this.handletwoList()
  729. },
  730. // 获取货品信息
  731. handletwoList() {
  732. // this.searchForm.type
  733. const paramss = {
  734. pageNum: this.dcurrentPage,
  735. pageSize: this.dpageSize,
  736. policyId: this.searchForm.code,
  737. saleTypeCode: ''
  738. }
  739. getMaterialList(paramss)
  740. .then((result) => {
  741. result.data.records.forEach((k) => {
  742. k.walletIds = []
  743. if (!k.specification) {
  744. k.materialNumber = k.materialId
  745. k.specification = k.materialId
  746. } else {
  747. k.materialNumber = k.materialNumber
  748. k.specification = k.specification
  749. }
  750. k.materialId = k.materialId
  751. k.walletRelaList.forEach((l) => {
  752. l.id = l.walletId
  753. l.name = l.walletName
  754. k.walletIds = [...k.walletIds, l.walletId]
  755. })
  756. })
  757. // this.dataList=[]
  758. this.dataList = result.data.records
  759. this.listTotal = result.data.total
  760. })
  761. .catch((err) => {
  762. console.error(err)
  763. })
  764. },
  765. // 提交审核
  766. handlEditPolicy(policyCustomers) {
  767. if (!this.searchForm.title) {
  768. this.$errorMsg('请输入说明')
  769. return
  770. }
  771. if (!this.searchForm.type) {
  772. this.$errorMsg('请选择类型')
  773. return
  774. }
  775. if (!this.searchForm.startTime) {
  776. this.$errorMsg('请选择生效日期')
  777. return
  778. }
  779. if (policyCustomers.length) {
  780. var arr = []
  781. policyCustomers.forEach((el) => {
  782. arr.push({
  783. customerId: el.customerId || el.customerId,
  784. customerName: el.name || el.customerName,
  785. customerNumber: el.number || el.customerNumber,
  786. lastOrderTime: '',
  787. limitTakeNum: 0,
  788. policyId: this.searchForm.code,
  789. policyTitle: '',
  790. remark: ''
  791. })
  792. })
  793. // this.dictList.forEach((k) => {
  794. // if (k.dictCode == this.searchForm.mainId) {
  795. // this.searchForm.mainName = k.dictValue;
  796. // }
  797. // });
  798. const params = {
  799. ...this.detail,
  800. ...this.searchForm,
  801. endTime: this.searchForm.endTime || '2100-01-01 00:00:00',
  802. policyCustomers: arr,
  803. imgSrc: this.fileList.length ? this.fileList[0].url : ''
  804. }
  805. console.log(this.fileList)
  806. updatePolicy(params).then((res) => {
  807. console.log(res)
  808. this.$successMsg('编辑成功')
  809. this.$parent.getList()
  810. this.$parent.isShow = 1
  811. })
  812. } else {
  813. this.$errorMsg('选择经销商 ')
  814. }
  815. },
  816. // 删除
  817. hanleDelete(id, index) {
  818. if (id) {
  819. const params = { policyMaterialId: id }
  820. deleteMaterialPolicy(params).then((res) => {
  821. this.dataList.splice(index, 1)
  822. })
  823. return
  824. }
  825. this.dataList.splice(index, 1)
  826. if (!this.dataList.length) {
  827. this.dcurrentPage !== 1 ? this.dcurrentPage -= 1 : this.dcurrentPage = 1
  828. }
  829. // this.listTotal -= 1;
  830. this.$successMsg('删除成功')
  831. },
  832. handleNewInfo() {
  833. // 物料列表
  834. this.dataList.push({
  835. id: '',
  836. discAmount: '',
  837. materialId: '',
  838. materialName: '',
  839. materialNumber: '',
  840. policyId: this.searchForm.code,
  841. price: '',
  842. remark: '',
  843. saleTypeCode: '',
  844. saleTypeId: '',
  845. saleTypeName: '',
  846. specification: '',
  847. walletIds: [this.NoRebateWalletList[0].id],
  848. walletRelaList: []
  849. })
  850. this.sleectBox.currentPage = 1
  851. // this.listTotal += 1;
  852. // this.dataList.push(this.addList[this.addList.length-1])
  853. },
  854. handleSave() {
  855. if (!this.dataList.length) {
  856. return
  857. }
  858. for (let i = 0; i < this.dataList.length; i++) {
  859. if (!this.dataList[i].materialId) {
  860. this.$errorMsg('请选择货品')
  861. return
  862. }
  863. if (!this.dataList[i].saleTypeId) {
  864. this.$errorMsg('请选择销售类型')
  865. return
  866. }
  867. if (!this.dataList[i].price) {
  868. this.$errorMsg('请输入单价')
  869. return
  870. }
  871. if (!this.dataList[i].walletIds.length) {
  872. this.$errorMsg('请选择钱包')
  873. return
  874. }
  875. }
  876. savePolicy(this.dataList).then((res) => {
  877. this.dataList = []
  878. this.sleectBox.currentPage = 1
  879. this.dcurrentPage = 1
  880. this.$successMsg('保存成功')
  881. this.handletwoList()
  882. })
  883. },
  884. handleK3List(e, row) {
  885. const item = this.k3List.filter((k) => {
  886. return k.id == e
  887. })[0]
  888. // this.$set(row,'materialNumber',item.number)
  889. this.$set(row, 'materialName', item.name)
  890. this.$set(row, 'specification', item.specification)
  891. this.$set(row, 'materialId', item.id)
  892. this.getK3List()
  893. },
  894. handleReset() {
  895. Object.assign(this.$data, this.$options.data())
  896. }
  897. },
  898. components: {
  899. // Transfer,
  900. AddCondition,
  901. ImageUpload,
  902. TabelTransfer
  903. }
  904. }
  905. </script>
  906. <style lang="scss" scoped>
  907. h4 {
  908. margin: 0;
  909. }
  910. .pdt {
  911. padding-top: 20px;
  912. }
  913. .import-btn {
  914. margin-right: 10px;
  915. display: inline-block;
  916. }
  917. .radio {
  918. padding: 20px 0;
  919. }
  920. .el-divider--horizontal {
  921. margin: 20px 0;
  922. }
  923. .el-container .el-divider--horizontal {
  924. margin: 10px;
  925. }
  926. .el-select {
  927. width: 100%;
  928. }
  929. .footer {
  930. margin-bottom: 20px;
  931. }
  932. </style>