AddPolicy.vue 29 KB

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