editPolicy.vue 32 KB

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