editPolicy.vue 29 KB

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