AddPolicy.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  1. <template>
  2. <div class="app-container">
  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 >
  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;conditName=scope.row.name"
  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. conditName:'',
  513. conditionList: [],
  514. dictList: [],
  515. k3List: [],
  516. NoRebateWalletList: [],
  517. sleectBox: { currentPage: 1 },
  518. dpageSize: 10,
  519. dcurrentPage: 1,
  520. rebateList: []
  521. }
  522. },
  523. computed: {
  524. ...mapGetters({
  525. comCode: 'code'
  526. })
  527. },
  528. mounted() {
  529. this.searchForm.code = this.comCode
  530. },
  531. updated() {
  532. this.searchForm.code = this.comCode
  533. },
  534. created() {
  535. this.getCommonApi()
  536. // console.log(this.$store.code);
  537. if (this.$parent.isFlag) {
  538. // this.handletwoList()
  539. }
  540. },
  541. methods: {
  542. ...mapMutations('sales', ['initData']),
  543. // 下载excel模板
  544. hanleDownloadFiles() {
  545. downloadFiles('/policy/download')
  546. },
  547. handleCondition(id, index) {
  548. deleteCondition({ id }).then((res) => {
  549. this.conditionList.splice(index, 1)
  550. Object.assign(
  551. this.$children[9].$data,
  552. this.$children[9].$options.data()
  553. )
  554. this.$successMsg('删除成功')
  555. })
  556. },
  557. loadmore() {
  558. this.sleectBox.currentPage++
  559. this.getK3List()
  560. },
  561. getK3List() {
  562. getK3List({
  563. pageNum: this.sleectBox.currentPage,
  564. pageSize: 10,
  565. keyword: ''
  566. }).then((res) => {
  567. this.k3List = [...this.k3List, ...res.data.records]
  568. })
  569. },
  570. remoteMethod(query, type) {
  571. console.log(query, type)
  572. if (query !== '') {
  573. getK3List({
  574. pageNum: 1,
  575. pageSize: 100,
  576. keyword: '',
  577. number: type === 'number' ? query : '',
  578. oldNumber: '',
  579. specification: type === 'specification' ? query : ''
  580. }).then((res) => {
  581. this.k3List = res.data.records
  582. })
  583. } else {
  584. this.sleectBox.currentPage = 1
  585. this.getK3List()
  586. }
  587. },
  588. getCommonApi() {
  589. this.getK3List()
  590. // 非返利钱包
  591. getNoRebateWalletList({ walletName: '' }).then((res) => {
  592. this.NoRebateWalletList = res.data
  593. console.log(this.NoRebateWalletList, 'kkkk')
  594. })
  595. getWalletRebateList({
  596. pageNum: 1,
  597. pageSize: -2,
  598. name: '',
  599. status: true
  600. }).then(res => {
  601. this.rebateList = res.data.records
  602. console.log(this.rebateList, 'fanlie')
  603. })
  604. const params = {
  605. pageNum: 1,
  606. pageSize: -1,
  607. saleCode: '',
  608. saleName: '',
  609. status: ''
  610. }
  611. // 获取销售类型列表
  612. getTypeList(params).then((res) => {
  613. this.typeList = res.data.records
  614. console.log(this.typeList, 'xioahsou')
  615. })
  616. // this.handletwoList()
  617. // const params = {
  618. // pageNum: 1,
  619. // pageSize: 10,
  620. // saleCode: "",
  621. // saleName: "",
  622. // status: "",
  623. // };
  624. // const walletParams = {
  625. // pageNum: 1,
  626. // pageSize: 10,
  627. // mainName: "",
  628. // saleTypeCode: "",
  629. // saleTypeName: "",
  630. // status: "",
  631. // };
  632. // // 获取钱包列表
  633. // getWalletList(walletParams).then((res) => {
  634. // this.walletList = res.data.records;
  635. // });
  636. // getDictList({ sysDictEnum: "PRODUCT_TYPE" }).then((res) => {
  637. // this.dictList = res.data;
  638. // });
  639. },
  640. handleSalesType(e, row) {
  641. const item = this.typeList.filter((k) => {
  642. return k.id === e
  643. })[0]
  644. const linshi = []
  645. const rebateList = []
  646. this.rebateList.forEach((k) => {
  647. k.saleTypes.forEach((j) => {
  648. if (!linshi.includes(j.saleTypeId) && j.saleTypeId === e) {
  649. rebateList.push(k)
  650. linshi.push(j.saleTypeId)
  651. }
  652. })
  653. })
  654. if (rebateList.length){
  655. this.$set(row,'rebateWalletIds',[...new Set([...row.rebateWalletIds,rebateList[0].walletRebateId])])
  656. }
  657. this.$set(row, 'saleTypeCode', item.saleCode)
  658. this.$set(row, 'saleTypeName', item.saleName)
  659. // this.$set(row,'saleTypeId',item.id)
  660. },
  661. // 修改条件名称
  662. handleConditionName(row) {
  663. console.log(row.name)
  664. if (this.conditName !== row.name){
  665. updateCondition({ id: row.id, name: row.name }).then((res) => {
  666. this.$successMsg('修改成功')
  667. })
  668. }
  669. row.fang = true
  670. },
  671. // 提交信息
  672. handleSubmitCon() {
  673. const params = {
  674. policyId: this.comCode
  675. }
  676. // 获取条件政策
  677. getConditionList(params).then((res) => {
  678. for (let i = 0; i < res.data.length; i++) {
  679. res.data[i].fang = true
  680. }
  681. this.conditionList = res.data
  682. })
  683. },
  684. // 视图部分已注释,废弃的功能 fucn
  685. handelStop() {
  686. if (this.searchForm.mainId) {
  687. this.fang = true
  688. } else {
  689. this.$errorMsg('请选择产品品类')
  690. }
  691. },
  692. // 导入
  693. async handleImport(param) {
  694. this.importLoading = true
  695. const file = param.file
  696. console.log(file, 123)
  697. const formData = new FormData()
  698. formData.append('file', file)
  699. formData.append('policyId', this.searchForm.code)
  700. // formData.append("mainId", this.searchForm.mainId);
  701. const result = await handleImport('/policy/material/import', formData)
  702. this.importLoading = false
  703. this.importFileList = []
  704. if (result.code === 200) {
  705. this.$alert(result.message, '导入成功', {
  706. confirmButtonText: '确定'
  707. })
  708. this.dataList = []
  709. this.listTotal = 0
  710. this.sleectBox.currentPage = 1
  711. this.handletwoList()
  712. } else {
  713. this.$alert(result.message, '导入失败', {
  714. confirmButtonText: '确定'
  715. })
  716. }
  717. },
  718. getList() {
  719. if (this.$parent.isFlag) {
  720. this.handletwoList()
  721. }
  722. },
  723. // 更改每页数量
  724. handleSizeChange1(val) {
  725. this.pageSize = val
  726. this.currentPage = 1
  727. this.handletwoList()
  728. },
  729. // 更改当前页
  730. handleCurrentChange1(val) {
  731. this.currentPage = val
  732. this.handletwoList()
  733. },
  734. // 更改每页数量
  735. handleSizeChange2(val) {
  736. this.dpageSize = val
  737. this.dcurrentPage = 1
  738. this.handletwoList()
  739. },
  740. // 更改当前页
  741. handleCurrentChange2(val) {
  742. this.dcurrentPage = val
  743. this.handletwoList()
  744. },
  745. // 获取货品信息
  746. handletwoList() {
  747. // this.searchForm.type
  748. this.listLoading = true
  749. const paramss = {
  750. pageNum: this.dcurrentPage,
  751. pageSize: this.dpageSize,
  752. policyId: this.comCode,
  753. saleTypeCode: ''
  754. }
  755. getMaterialList(paramss)
  756. .then((result) => {
  757. result.data.records.forEach((k) => {
  758. k.walletIds = []
  759. k.rebateWalletIds = []
  760. if (!k.specification) {
  761. k.materialNumber = k.materialId
  762. k.specification = k.materialId
  763. }
  764. k.walletRelaList.forEach((l) => {
  765. l.id = l.walletId
  766. l.name = l.walletName
  767. if (l.type==='REBATE'){
  768. k.rebateWalletIds = [...k.rebateWalletIds, l.walletId]
  769. }else {
  770. k.walletIds = [...k.walletIds, l.walletId]
  771. }
  772. // k.walletIds = [...k.walletIds, l.walletId]
  773. })
  774. })
  775. // this.dataList=[]
  776. this.dataList = result.data.records
  777. this.listTotal = result.data.total
  778. this.listLoading = false
  779. })
  780. .catch((err) => {
  781. console.error(err)
  782. // this.listLoading = false
  783. })
  784. },
  785. // 提交审核
  786. handleAddPolicy(policyCustomers) {
  787. if (!this.searchForm.title) {
  788. this.$errorMsg('请输入说明')
  789. return
  790. }
  791. if (!this.searchForm.type) {
  792. this.$errorMsg('请选择类型')
  793. return
  794. }
  795. if (!this.searchForm.startTime) {
  796. this.$errorMsg('请选择生效日期')
  797. return
  798. }
  799. if (policyCustomers.length) {
  800. var arr = []
  801. policyCustomers.forEach((el) => {
  802. arr.push({
  803. customerId: el.id,
  804. customerName: el.name,
  805. customerNumber: el.number,
  806. lastOrderTime: '',
  807. limitTakeNum: 0,
  808. policyId: this.comCode,
  809. policyTitle: '',
  810. remark: ''
  811. })
  812. })
  813. // this.dictList.forEach((k) => {
  814. // if (k.dictCode == this.searchForm.mainId) {
  815. // this.searchForm.mainName = k.dictValue;
  816. // }
  817. // });
  818. const params = {
  819. adminCompanyId: '',
  820. code: '',
  821. customerCount: 0,
  822. examineBy: '',
  823. examineRemark: '',
  824. examineStatus: '',
  825. id: '',
  826. policyCustomers: arr,
  827. remark: '',
  828. status: true,
  829. title: '',
  830. type: '',
  831. ...this.searchForm,
  832. endTime: this.searchForm.endTime || '2100-01-01 00:00:00',
  833. imgSrc: this.fileList.length ? this.fileList[0].url : ''
  834. }
  835. console.log(this.fileList)
  836. addPoliy(params).then((res) => {
  837. console.log(res)
  838. this.$successMsg('新增成功')
  839. this.$parent.getList()
  840. this.$parent.isShow = 1
  841. })
  842. } else {
  843. this.$errorMsg('选择经销商 ')
  844. }
  845. },
  846. // 删除
  847. hanleDelete(id, index) {
  848. if (id) {
  849. const params = { policyMaterialId: id }
  850. deleteMaterialPolicy(params).then((res) => {
  851. this.dataList.splice(index, 1)
  852. })
  853. return
  854. }
  855. this.dataList.splice(index, 1)
  856. // this.listTotal -= 1;
  857. this.$successMsg('删除成功')
  858. },
  859. handleNewInfo() {
  860. // 物料列表
  861. this.dataList.push({
  862. id: '',
  863. discAmount: 0,
  864. materialId: '',
  865. materialName: '',
  866. materialNumber: '',
  867. policyId: this.comCode,
  868. price: '',
  869. remark: '',
  870. saleTypeCode: '',
  871. saleTypeId: '',
  872. saleTypeName: '',
  873. specification: '',
  874. rebateWalletIds: [],
  875. walletIds: [this.NoRebateWalletList[0].id],
  876. walletRelaList: []
  877. })
  878. this.sleectBox.currentPage = 1
  879. // this.listTotal += 1;
  880. // this.dataList.push(this.addList[this.addList.length-1])
  881. },
  882. handleSave() {
  883. if (!this.dataList.length) {
  884. return
  885. }
  886. for (let i = 0; i < this.dataList.length; i++) {
  887. if (!this.dataList[i].materialId) {
  888. this.$errorMsg('请选择货品')
  889. return
  890. }
  891. if (!this.dataList[i].saleTypeId) {
  892. this.$errorMsg('请选择销售类型')
  893. return
  894. }
  895. if (!this.dataList[i].price) {
  896. this.$errorMsg('请输入单价')
  897. return
  898. }
  899. if (!this.dataList[i].walletIds.length) {
  900. this.$errorMsg('请选择支付钱包')
  901. return
  902. }
  903. }
  904. savePolicy(this.dataList).then((res) => {
  905. this.dataList = []
  906. this.sleectBox.currentPage = 1
  907. this.$successMsg('保存成功')
  908. this.handletwoList()
  909. })
  910. },
  911. handleK3List(e, row) {
  912. const item = this.k3List.filter((k) => {
  913. return k.id == e
  914. })[0]
  915. this.$set(row, 'materialNumber', item.number)
  916. this.$set(row, 'materialName', item.name)
  917. this.$set(row, 'specification', item.specification)
  918. this.$set(row, 'materialId', item.id)
  919. this.getK3List()
  920. },
  921. handleReset() {
  922. Object.assign(this.$data, this.$options.data())
  923. this.getCommonApi()
  924. }
  925. },
  926. components: {
  927. TabelTransfer,
  928. AddCondition,
  929. ImageUpload
  930. }
  931. }
  932. </script>
  933. <style lang="scss" scoped>
  934. h4 {
  935. margin: 0;
  936. }
  937. .pdt {
  938. padding-top: 20px;
  939. }
  940. .import-btn {
  941. margin-right: 10px;
  942. display: inline-block;
  943. }
  944. .radio {
  945. padding: 20px 0;
  946. }
  947. .el-divider--horizontal {
  948. margin: 20px 0;
  949. }
  950. .el-container .el-divider--horizontal {
  951. margin: 10px;
  952. }
  953. .el-select {
  954. width: 100%;
  955. }
  956. .footer {
  957. margin-bottom: 20px;
  958. }
  959. </style>