AddPolicy.vue 31 KB

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