editPolicy.vue 30 KB

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