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. linshi.push(j.saleTypeId)
  655. }
  656. })
  657. })
  658. if (rebateList.length) {
  659. this.$set(row, 'rebateWalletIds', [...new Set([...row.rebateWalletIds, rebateList[0].walletRebateId])])
  660. }
  661. this.$set(row, 'saleTypeCode', item.saleCode)
  662. this.$set(row, 'saleTypeName', item.saleName)
  663. // this.$set(row,'saleTypeId',item.id)
  664. },
  665. // 修改条件名称
  666. handleConditionName(row) {
  667. console.log(row.name)
  668. updateCondition({ id: row.id, name: row.name }).then((res) => {
  669. this.$successMsg('修改成功')
  670. row.fang = true
  671. })
  672. },
  673. // 提交信息
  674. handleSubmitCon() {
  675. const params = {
  676. policyId: this.searchForm.code
  677. }
  678. // 获取条件政策
  679. getConditionList(params).then((res) => {
  680. for (let i = 0; i < res.data.length; i++) {
  681. res.data[i].fang = true
  682. }
  683. this.conditionList = res.data
  684. })
  685. },
  686. // 视图部分已注释,废弃的功能 fucn
  687. handelStop() {
  688. if (this.searchForm.mainId) {
  689. this.fang = true
  690. } else {
  691. this.$errorMsg('请选择产品品类')
  692. }
  693. },
  694. // 导入
  695. async handleImport(param) {
  696. this.importLoading = true
  697. const file = param.file
  698. console.log(file, 123)
  699. const formData = new FormData()
  700. formData.append('file', file)
  701. formData.append('policyId', this.searchForm.code)
  702. // formData.append("mainId", this.searchForm.mainId);
  703. const result = await handleImport('/policy/material/import', formData)
  704. this.importLoading = false
  705. this.importFileList = []
  706. if (result.code === 200) {
  707. this.$alert(result.message, '导入成功', {
  708. confirmButtonText: '确定'
  709. })
  710. this.dataList = []
  711. this.listTotal = 0
  712. this.sleectBox.currentPage = 1
  713. this.handletwoList()
  714. } else {
  715. this.$alert(result.message, '导入失败', {
  716. confirmButtonText: '确定'
  717. })
  718. }
  719. },
  720. getList() {
  721. getPolicyDetail({ policyId: this.$parent.id }).then((res) => {
  722. this.detail = res.data
  723. this.searchForm = {
  724. code: this.detail.code,
  725. endTime: this.detail.endTime,
  726. imgSrc: this.detail.imgSrc,
  727. remark: this.detail.remark,
  728. startTime: this.detail.startTime,
  729. title: this.detail.title,
  730. type: this.detail.type
  731. },
  732. this.srcList = [this.$imageUrl + this.detail.imgSrc]
  733. if (this.$parent.isShow === 5 && this.detail.imgSrc) {
  734. this.fileList = [
  735. {
  736. hover: '',
  737. url: this.detail.imgSrc
  738. }
  739. ]
  740. }
  741. this.handletwoList()
  742. // 获取条件政策
  743. this.handleSubmitCon()
  744. })
  745. if (this.$parent.isFlag) {
  746. this.handletwoList()
  747. }
  748. },
  749. // 更改每页数量
  750. handleSizeChange1(val) {
  751. this.pageSize = val
  752. this.currentPage = 1
  753. this.handletwoList()
  754. },
  755. // 更改当前页
  756. handleCurrentChange1(val) {
  757. this.currentPage = val
  758. this.handletwoList()
  759. },
  760. // 更改每页数量
  761. handleSizeChange2(val) {
  762. this.dpageSize = val
  763. this.dcurrentPage = 1
  764. this.handletwoList()
  765. },
  766. // 更改当前页
  767. handleCurrentChange2(val) {
  768. this.dcurrentPage = val
  769. this.handletwoList()
  770. },
  771. // 获取货品信息
  772. handletwoList() {
  773. // this.searchForm.type
  774. this.listLoading = true
  775. const paramss = {
  776. pageNum: this.dcurrentPage,
  777. pageSize: this.dpageSize,
  778. policyId: this.searchForm.code,
  779. saleTypeCode: ''
  780. }
  781. getMaterialList(paramss)
  782. .then((result) => {
  783. result.data.records.forEach((k) => {
  784. k.walletIds = []
  785. k.rebateWalletIds = []
  786. if (!k.specification) {
  787. k.materialNumber = k.materialId
  788. k.specification = k.materialId
  789. }
  790. k.walletRelaList.forEach((l) => {
  791. l.id = l.walletId
  792. l.name = l.walletName
  793. if (l.type === 'REBATE') {
  794. k.rebateWalletIds = [...k.rebateWalletIds, l.walletId]
  795. } else {
  796. k.walletIds = [...k.walletIds, l.walletId]
  797. }
  798. })
  799. })
  800. // this.dataList=[]
  801. this.dataList = result.data.records
  802. this.listTotal = result.data.total
  803. this.listLoading = false
  804. })
  805. .catch((err) => {
  806. console.error(err)
  807. })
  808. },
  809. // 提交审核
  810. handlEditPolicy(policyCustomers) {
  811. if (!this.searchForm.title) {
  812. this.$errorMsg('请输入说明')
  813. return
  814. }
  815. if (!this.searchForm.type) {
  816. this.$errorMsg('请选择类型')
  817. return
  818. }
  819. if (!this.searchForm.startTime) {
  820. this.$errorMsg('请选择生效日期')
  821. return
  822. }
  823. if (policyCustomers.length) {
  824. var arr = []
  825. policyCustomers.forEach((el) => {
  826. arr.push({
  827. customerId: el.customerId || el.customerId,
  828. customerName: el.name || el.customerName,
  829. customerNumber: el.number || el.customerNumber,
  830. lastOrderTime: '',
  831. limitTakeNum: 0,
  832. policyId: this.searchForm.code,
  833. policyTitle: '',
  834. remark: ''
  835. })
  836. })
  837. // this.dictList.forEach((k) => {
  838. // if (k.dictCode == this.searchForm.mainId) {
  839. // this.searchForm.mainName = k.dictValue;
  840. // }
  841. // });
  842. const params = {
  843. ...this.detail,
  844. ...this.searchForm,
  845. endTime: this.searchForm.endTime || '2100-01-01 00:00:00',
  846. policyCustomers: arr,
  847. imgSrc: this.fileList.length ? this.fileList[0].url : ''
  848. }
  849. console.log(this.fileList)
  850. updatePolicy(params).then((res) => {
  851. console.log(res)
  852. this.$successMsg('编辑成功')
  853. this.$parent.getList()
  854. this.$parent.isShow = 1
  855. })
  856. } else {
  857. this.$errorMsg('选择经销商 ')
  858. }
  859. },
  860. // 删除
  861. hanleDelete(id, index) {
  862. if (id) {
  863. const params = { policyMaterialId: id }
  864. deleteMaterialPolicy(params).then((res) => {
  865. this.dataList.splice(index, 1)
  866. })
  867. return
  868. }
  869. this.dataList.splice(index, 1)
  870. if (!this.dataList.length) {
  871. this.dcurrentPage !== 1 ? this.dcurrentPage -= 1 : this.dcurrentPage = 1
  872. }
  873. // this.listTotal -= 1;
  874. this.$successMsg('删除成功')
  875. },
  876. handleNewInfo() {
  877. // 物料列表
  878. this.dataList.push({
  879. id: '',
  880. discAmount: '',
  881. materialId: '',
  882. materialName: '',
  883. materialNumber: '',
  884. policyId: this.searchForm.code,
  885. price: '',
  886. remark: '',
  887. saleTypeCode: '',
  888. saleTypeId: '',
  889. saleTypeName: '',
  890. specification: '',
  891. walletIds: [this.NoRebateWalletList[0].id],
  892. walletRelaList: []
  893. })
  894. this.sleectBox.currentPage = 1
  895. // this.listTotal += 1;
  896. // this.dataList.push(this.addList[this.addList.length-1])
  897. },
  898. handleSave() {
  899. if (!this.dataList.length) {
  900. return
  901. }
  902. for (let i = 0; i < this.dataList.length; i++) {
  903. if (!this.dataList[i].materialId) {
  904. this.$errorMsg('请选择货品')
  905. return
  906. }
  907. if (!this.dataList[i].saleTypeId) {
  908. this.$errorMsg('请选择销售类型')
  909. return
  910. }
  911. if (!this.dataList[i].price) {
  912. this.$errorMsg('请输入单价')
  913. return
  914. }
  915. if (!this.dataList[i].walletIds.length) {
  916. this.$errorMsg('请选择支付钱包')
  917. return
  918. }
  919. }
  920. savePolicy(this.dataList).then((res) => {
  921. this.dataList = []
  922. this.sleectBox.currentPage = 1
  923. this.dcurrentPage = 1
  924. this.$successMsg('保存成功')
  925. this.handletwoList()
  926. })
  927. },
  928. handleK3List(e, row) {
  929. const item = this.k3List.filter((k) => {
  930. return k.id == e
  931. })[0]
  932. this.$set(row, 'materialNumber', item.number)
  933. this.$set(row, 'materialName', item.name)
  934. this.$set(row, 'specification', item.specification)
  935. this.$set(row, 'materialId', item.id)
  936. this.getK3List()
  937. },
  938. handleReset() {
  939. Object.assign(this.$data, this.$options.data())
  940. this.getCommonApi()
  941. }
  942. },
  943. components: {
  944. // Transfer,
  945. AddCondition,
  946. ImageUpload,
  947. TabelTransfer
  948. }
  949. }
  950. </script>
  951. <style lang="scss" scoped>
  952. h4 {
  953. margin: 0;
  954. }
  955. .pdt {
  956. padding-top: 20px;
  957. }
  958. .import-btn {
  959. margin-right: 10px;
  960. display: inline-block;
  961. }
  962. .radio {
  963. padding: 20px 0;
  964. }
  965. .el-divider--horizontal {
  966. margin: 20px 0;
  967. }
  968. .el-container .el-divider--horizontal {
  969. margin: 10px;
  970. }
  971. .el-select {
  972. width: 100%;
  973. }
  974. .footer {
  975. margin-bottom: 20px;
  976. }
  977. </style>