editPolicy.vue 31 KB

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