editPolicy.vue 32 KB

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