editPolicy.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  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. <el-table
  146. v-loading="listLoading"
  147. :data="dataList"
  148. element-loading-text="Loading"
  149. max-height="600"
  150. border
  151. fit
  152. highlight-current-row
  153. stripe
  154. >
  155. <el-table-column
  156. type="index"
  157. label="序号"
  158. width="50"
  159. align="left"
  160. />
  161. <el-table-column
  162. min-width="200"
  163. prop="materialNumber"
  164. label="物料编码"
  165. align="left"
  166. >
  167. <template slot-scope="scope">
  168. <CopyButton :copyText="scope.row.materialNumber" />
  169. <el-select
  170. v-model="scope.row.materialNumber"
  171. v-el-select-loadmore="loadmore"
  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. // 获取element-ui定义好的scroll盒⼦
  503. const SELECTWRAP_DOM = el.querySelector(
  504. '.el-select-dropdown .el-select-dropdown__wrap'
  505. )
  506. SELECTWRAP_DOM.addEventListener('scroll', function() {
  507. /**
  508. * scrollHeight 获取元素内容⾼度(只读)
  509. * scrollTop 获取或者设置元素的偏移值,常⽤于, 计算滚动条的位置, 当⼀个元素的容器没有产⽣垂直⽅向的滚动条, 那它的scrollTop的值默认为0.
  510. * clientHeight 读取元素的可见⾼度(只读)
  511. * 如果元素滚动到底, 下⾯等式返回true, 没有则返回false:
  512. * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
  513. */
  514. const condition =
  515. this.scrollHeight - this.scrollTop <= this.clientHeight
  516. if (condition) {
  517. binding.value()
  518. }
  519. })
  520. }
  521. }
  522. },
  523. mixins: [Minxin],
  524. data() {
  525. return {
  526. fang: false,
  527. input: '',
  528. baseURL: '',
  529. isCondition: 0,
  530. searchForm: {
  531. code: '',
  532. endTime: '',
  533. imgSrc: '',
  534. remark: '',
  535. startTime: '',
  536. title: '',
  537. mainId: '',
  538. mainName: '',
  539. type: '',
  540. isFullRebate: false,
  541. },
  542. conditName:'',
  543. dataList: [],
  544. addList: [],
  545. pageSizeArr: [10, 20, 30, 50],
  546. size: 10,
  547. listLoading: false,
  548. dialogVisible: false,
  549. importFileList: [],
  550. fileList: [],
  551. options: {},
  552. value: '',
  553. typeList: [],
  554. walletList: [],
  555. typeOptions: [
  556. {
  557. value: 'PROVISION',
  558. label: '配提'
  559. },
  560. {
  561. value: 'LIMIT',
  562. label: '限量'
  563. }
  564. ],
  565. conditionList: [],
  566. dictList: [],
  567. k3List: [],
  568. NoRebateWalletList: [],
  569. sleectBox: { currentPage: 1 },
  570. dpageSize: 10,
  571. dcurrentPage: 1,
  572. detail: {},
  573. rebateList: [],
  574. cid:'',
  575. cpolicyId:'',
  576. region:0
  577. }
  578. },
  579. computed: {
  580. ...mapGetters({
  581. comCode: 'code'
  582. })
  583. },
  584. created() {
  585. this.getCommonApi()
  586. // console.log(this.$store.code);
  587. if (this.$parent.isFlag) {
  588. // this.handletwoList()
  589. }
  590. },
  591. methods: {
  592. ...mapMutations('sales', ['initData']),
  593. // 下载excel模板
  594. hanleDownloadFiles() {
  595. downloadFiles('policy/download')
  596. },
  597. handleCondition(id, index) {
  598. deleteCondition({ id }).then((res) => {
  599. this.conditionList.splice(index, 1)
  600. Object.assign(
  601. this.$children[9].$data,
  602. this.$children[9].$options.data()
  603. )
  604. this.$successMsg('删除成功')
  605. })
  606. },
  607. catCond(row){
  608. this.cid = row.id
  609. this.$refs.cond.getCommonApi()
  610. this.isCondition = 2
  611. // $refs.cond.getCommonApi(),
  612. // (), (cid = scope.row.id)
  613. },
  614. handleAddCondition() {
  615. this.isCondition = 1
  616. console.log(this.conditionList[0].id,this.searchForm.code);
  617. this.$refs.comDom.getCommonApi(this.conditionList[0].id)
  618. this.$store.commit('sales/setId', this.searchForm.code)
  619. },
  620. loadmore() {
  621. this.sleectBox.currentPage++
  622. this.getK3List()
  623. },
  624. getK3List() {
  625. getK3List({
  626. pageNum: this.sleectBox.currentPage,
  627. pageSize: 10,
  628. keyword: ''
  629. }).then((res) => {
  630. this.k3List = [...this.k3List, ...res.data.records]
  631. })
  632. },
  633. remoteMethod(query, type) {
  634. console.log(query, type)
  635. if (query !== '') {
  636. getK3List({
  637. pageNum: 1,
  638. pageSize: 100,
  639. keyword: '',
  640. number: type === 'number' ? query : '',
  641. oldNumber: '',
  642. specification: type === 'specification' ? query : ''
  643. }).then((res) => {
  644. this.k3List = res.data.records
  645. })
  646. } else {
  647. this.sleectBox.currentPage = 1
  648. this.getK3List()
  649. }
  650. },
  651. getCommonApi() {
  652. this.getK3List()
  653. // 非返利钱包
  654. getNoRebateWalletList({ walletName: '' }).then((res) => {
  655. this.NoRebateWalletList = res.data
  656. console.log(this.NoRebateWalletList, 'kkkk')
  657. })
  658. getWalletRebateList({
  659. pageNum: 1,
  660. pageSize: -2,
  661. name: '',
  662. status: true
  663. }).then(res => {
  664. this.rebateList = res.data.records
  665. console.log(this.rebateList, 'fanlie')
  666. })
  667. const params = {
  668. pageNum: 1,
  669. pageSize: -1,
  670. saleCode: '',
  671. saleName: '',
  672. status: ''
  673. }
  674. // 获取销售类型列表
  675. getTypeList(params).then((res) => {
  676. this.typeList = res.data.records
  677. })
  678. // this.handletwoList()
  679. // const params = {
  680. // pageNum: 1,
  681. // pageSize: 10,
  682. // saleCode: "",
  683. // saleName: "",
  684. // status: "",
  685. // };
  686. // const walletParams = {
  687. // pageNum: 1,
  688. // pageSize: 10,
  689. // mainName: "",
  690. // saleTypeCode: "",
  691. // saleTypeName: "",
  692. // status: "",
  693. // };
  694. // // 获取钱包列表
  695. // getWalletList(walletParams).then((res) => {
  696. // this.walletList = res.data.records;
  697. // });
  698. // getDictList({ sysDictEnum: "PRODUCT_TYPE" }).then((res) => {
  699. // this.dictList = res.data;
  700. // });
  701. },
  702. handleSalesType(e, row) {
  703. const item = this.typeList.filter((k) => {
  704. return k.id === e
  705. })[0]
  706. const linshi = []
  707. const rebateList = []
  708. this.rebateList.forEach((k) => {
  709. k.saleTypes.forEach((j) => {
  710. if (!linshi.includes(j.saleTypeId) && j.saleTypeId == e) {
  711. rebateList.push(k)
  712. linshi.push(j.saleTypeId)
  713. }
  714. })
  715. })
  716. if (rebateList.length) {
  717. this.$set(row, 'rebateWalletIds', [...new Set([...row.rebateWalletIds, rebateList[0].walletRebateId])])
  718. }
  719. this.$set(row, 'saleTypeCode', item.saleCode)
  720. this.$set(row, 'saleTypeName', item.saleName)
  721. // this.$set(row,'saleTypeId',item.id)
  722. },
  723. // 修改条件名称
  724. handleConditionName(row) {
  725. console.log(row.name)
  726. if (this.conditName !== row.name){
  727. updateCondition({ id: row.id, name: row.name }).then((res) => {
  728. this.$successMsg('修改成功')
  729. })
  730. }
  731. row.fang = true
  732. },
  733. // 提交信息
  734. handleSubmitCon() {
  735. const params = {
  736. policyId: this.searchForm.code
  737. }
  738. // 获取条件政策
  739. getConditionList(params).then((res) => {
  740. for (let i = 0; i < res.data.length; i++) {
  741. res.data[i].fang = true
  742. }
  743. this.conditionList = res.data
  744. Object.assign( this.$refs.comDom.$data,this.$refs.comDom.$options.data())
  745. })
  746. },
  747. // 视图部分已注释,废弃的功能 fucn
  748. handelStop() {
  749. if (this.searchForm.mainId) {
  750. this.fang = true
  751. } else {
  752. this.$errorMsg('请选择产品类别')
  753. }
  754. },
  755. // 导入
  756. async handleImport(param) {
  757. this.importLoading = true
  758. const file = param.file
  759. console.log(file, 123)
  760. const formData = new FormData()
  761. formData.append('file', file)
  762. formData.append('policyId', this.searchForm.code)
  763. // formData.append("mainId", this.searchForm.mainId);
  764. const result = await handleImport('/policy/material/import', formData)
  765. this.importLoading = false
  766. this.importFileList = []
  767. if (result.code === 200) {
  768. this.$alert(result.message, '导入成功', {
  769. confirmButtonText: '确定'
  770. })
  771. this.dataList = []
  772. this.listTotal = 0
  773. this.sleectBox.currentPage = 1
  774. this.handletwoList()
  775. } else {
  776. this.$alert(result.message, '导入失败', {
  777. confirmButtonText: '确定'
  778. })
  779. }
  780. },
  781. getList() {
  782. getPolicyDetail({ policyId: this.$parent.id }).then((res) => {
  783. this.detail = res.data
  784. this.searchForm = {
  785. code: this.detail.code,
  786. endTime: this.detail.endTime,
  787. imgSrc: this.detail.imgSrc,
  788. remark: this.detail.remark,
  789. startTime: this.detail.startTime,
  790. title: this.detail.title,
  791. type: this.detail.type
  792. },
  793. this.region = res.data.flag
  794. this.srcList = [this.$imageUrl + this.detail.imgSrc]
  795. if (this.$parent.isShow === 5 && this.detail.imgSrc) {
  796. this.fileList = [
  797. {
  798. hover: '',
  799. url: this.detail.imgSrc
  800. }
  801. ]
  802. }
  803. this.handletwoList()
  804. // 获取条件政策
  805. this.handleSubmitCon()
  806. })
  807. if (this.$parent.isFlag) {
  808. this.handletwoList()
  809. }
  810. },
  811. // 更改每页数量
  812. handleSizeChange1(val) {
  813. this.pageSize = val
  814. this.currentPage = 1
  815. this.handletwoList()
  816. },
  817. // 更改当前页
  818. handleCurrentChange1(val) {
  819. this.currentPage = val
  820. this.handletwoList()
  821. },
  822. // 更改每页数量
  823. handleSizeChange2(val) {
  824. this.dpageSize = val
  825. this.dcurrentPage = 1
  826. this.handletwoList()
  827. },
  828. // 更改当前页
  829. handleCurrentChange2(val) {
  830. this.dcurrentPage = val
  831. this.handletwoList()
  832. },
  833. // 获取货品信息
  834. handletwoList() {
  835. // this.searchForm.type
  836. this.listLoading = true
  837. const paramss = {
  838. pageNum: this.dcurrentPage,
  839. pageSize: -1,
  840. policyId: this.searchForm.code,
  841. saleTypeCode: ''
  842. }
  843. getMaterialList(paramss)
  844. .then((result) => {
  845. result.data.records.forEach((k) => {
  846. k.walletIds = []
  847. k.rebateWalletIds = []
  848. if (!k.specification) {
  849. k.materialNumber = k.materialId
  850. k.specification = k.materialId
  851. }
  852. k.walletRelaList.forEach((l) => {
  853. l.id = l.walletId
  854. l.name = l.walletName
  855. if (l.type === 'REBATE') {
  856. k.rebateWalletIds = [...k.rebateWalletIds, l.walletId]
  857. } else {
  858. k.walletIds = [...k.walletIds, l.walletId]
  859. }
  860. })
  861. })
  862. // this.dataList=[]
  863. this.dataList = result.data.records
  864. this.listTotal = result.data.total
  865. this.listLoading = false
  866. })
  867. .catch((err) => {
  868. console.error(err)
  869. })
  870. },
  871. // 提交审核
  872. handlEditPolicy(policyCustomers,region) {
  873. if (!this.searchForm.title) {
  874. this.$errorMsg('请输入说明')
  875. return
  876. }
  877. if (!this.searchForm.type) {
  878. this.$errorMsg('请选择类型')
  879. return
  880. }
  881. if (!this.searchForm.startTime) {
  882. this.$errorMsg('请选择生效日期')
  883. return
  884. }
  885. const formtData = ()=>{
  886. var arr = []
  887. policyCustomers.forEach((el) => {
  888. arr.push({
  889. customerId: el.customerId || el.customerId,
  890. customerName: el.name || el.customerName,
  891. customerNumber: el.number || el.customerNumber,
  892. lastOrderTime: '',
  893. limitTakeNum: 0,
  894. policyId: this.searchForm.code || this.detail.code,
  895. policyTitle: '',
  896. remark: ''
  897. })
  898. })
  899. // this.dictList.forEach((k) => {
  900. // if (k.dictCode == this.searchForm.mainId) {
  901. // this.searchForm.mainName = k.dictValue;
  902. // }
  903. // });
  904. const params = {
  905. ...this.detail,
  906. ...this.searchForm,
  907. flag:region,
  908. endTime: this.searchForm.endTime || '2100-01-01 00:00:00',
  909. policyCustomers: arr,
  910. imgSrc: this.fileList.length ? this.fileList[0].url : ''
  911. }
  912. console.log(this.fileList)
  913. updatePolicy(params).then((res) => {
  914. console.log(res)
  915. this.$successMsg('编辑成功')
  916. this.$parent.getList()
  917. this.$parent.isShow = 1
  918. })
  919. }
  920. if(region ==0){
  921. if (policyCustomers.length) {
  922. formtData()
  923. } else {
  924. this.$errorMsg('选择经销商 ')
  925. }
  926. }else{
  927. formtData()
  928. }
  929. },
  930. // 删除
  931. hanleDelete(id, index) {
  932. if (id) {
  933. const params = { policyMaterialId: id }
  934. deleteMaterialPolicy(params).then((res) => {
  935. this.dataList.splice(index, 1)
  936. })
  937. return
  938. }
  939. this.dataList.splice(index, 1)
  940. if (!this.dataList.length) {
  941. this.dcurrentPage !== 1 ? this.dcurrentPage -= 1 : this.dcurrentPage = 1
  942. }
  943. // this.listTotal -= 1;
  944. this.$successMsg('删除成功')
  945. },
  946. handleNewInfo() {
  947. // 物料列表
  948. this.dataList.push({
  949. id: '',
  950. discAmount: '',
  951. materialId: '',
  952. materialName: '',
  953. materialNumber: '',
  954. policyId: this.searchForm.code,
  955. price: '',
  956. remark: '',
  957. saleTypeCode: '',
  958. saleTypeId: '',
  959. saleTypeName: '',
  960. specification: '',
  961. walletIds: [this.NoRebateWalletList[0].id],
  962. walletRelaList: []
  963. })
  964. this.sleectBox.currentPage = 1
  965. // this.listTotal += 1;
  966. // this.dataList.push(this.addList[this.addList.length-1])
  967. },
  968. handleSave() {
  969. if (!this.dataList.length) {
  970. return
  971. }
  972. for (let i = 0; i < this.dataList.length; i++) {
  973. if (!this.dataList[i].materialId) {
  974. this.$errorMsg('请选择货品')
  975. return
  976. }
  977. if (!this.dataList[i].saleTypeId) {
  978. this.$errorMsg('请选择销售类型')
  979. return
  980. }
  981. if (!this.dataList[i].price) {
  982. this.$errorMsg('请输入单价')
  983. return
  984. }
  985. if (!this.dataList[i].walletIds.length) {
  986. this.$errorMsg('请选择现金钱包')
  987. return
  988. }
  989. }
  990. savePolicy(this.dataList).then((res) => {
  991. this.dataList = []
  992. this.sleectBox.currentPage = 1
  993. this.dcurrentPage = 1
  994. this.$successMsg('保存成功')
  995. this.handletwoList()
  996. })
  997. },
  998. handleK3List(e, row) {
  999. const item = this.k3List.filter((k) => {
  1000. return k.id == e
  1001. })[0]
  1002. this.$set(row, 'materialNumber', item.number)
  1003. this.$set(row, 'materialName', item.name)
  1004. this.$set(row, 'specification', item.specification)
  1005. this.$set(row, 'materialId', item.id)
  1006. this.getK3List()
  1007. },
  1008. handleReset() {
  1009. Object.assign(this.$data, this.$options.data())
  1010. this.getCommonApi()
  1011. }
  1012. },
  1013. components: {
  1014. // Transfer,
  1015. AddCondition,
  1016. ImageUpload,
  1017. EditCondition,
  1018. TabelTransfer
  1019. }
  1020. }
  1021. </script>
  1022. <style lang="scss" scoped>
  1023. h4 {
  1024. margin: 0;
  1025. }
  1026. .yinput{
  1027. ::v-deep input{
  1028. text-align: right;
  1029. }
  1030. }
  1031. .pdt {
  1032. padding-top: 20px;
  1033. }
  1034. .import-btn {
  1035. margin-right: 10px;
  1036. display: inline-block;
  1037. }
  1038. .radio {
  1039. padding: 20px 0;
  1040. }
  1041. .el-divider--horizontal {
  1042. margin: 20px 0;
  1043. }
  1044. .el-container .el-divider--horizontal {
  1045. margin: 10px;
  1046. }
  1047. .el-select {
  1048. width: 100%;
  1049. }
  1050. .footer {
  1051. margin-bottom: 20px;
  1052. }
  1053. </style>