AddPolicy.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  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.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. endTime: this.searchForm.endTime || "2100-01-01 00:00:00",
  893. imgSrc: this.fileList.length ? this.fileList[0].url : "",
  894. };
  895. console.log(this.fileList);
  896. addPoliy(params).then((res) => {
  897. console.log(res);
  898. this.$successMsg("新增成功");
  899. this.$parent.getList();
  900. this.$parent.isShow = 1;
  901. });
  902. }
  903. if (region == 0) {
  904. if (policyCustomers.length) {
  905. fomrtData()
  906. } else {
  907. this.$errorMsg("选择经销商 ");
  908. }
  909. }else{
  910. fomrtData()
  911. }
  912. },
  913. // 删除
  914. hanleDelete(id, index) {
  915. if (id) {
  916. const params = { policyMaterialId: id };
  917. deleteMaterialPolicy(params).then((res) => {
  918. this.dataList.splice(index, 1);
  919. });
  920. return;
  921. }
  922. this.dataList.splice(index, 1);
  923. // this.listTotal -= 1;
  924. this.$successMsg("删除成功");
  925. },
  926. handleNewInfo() {
  927. // 物料列表
  928. this.dataList.push({
  929. id: "",
  930. discAmount: 0,
  931. materialId: "",
  932. materialName: "",
  933. materialNumber: "",
  934. policyId: this.comCode,
  935. price: "",
  936. remark: "",
  937. saleTypeCode: "",
  938. saleTypeId: "",
  939. saleTypeName: "",
  940. specification: "",
  941. rebateWalletIds: [],
  942. walletIds: [this.NoRebateWalletList[0].id],
  943. walletRelaList: [],
  944. });
  945. this.sleectBox.currentPage = 1;
  946. // this.listTotal += 1;
  947. // this.dataList.push(this.addList[this.addList.length-1])
  948. },
  949. handleSave() {
  950. if (!this.dataList.length) {
  951. return;
  952. }
  953. for (let i = 0; i < this.dataList.length; i++) {
  954. if (!this.dataList[i].materialId) {
  955. this.$errorMsg("请选择货品");
  956. return;
  957. }
  958. if (!this.dataList[i].saleTypeId) {
  959. this.$errorMsg("请选择销售类型");
  960. return;
  961. }
  962. if (!this.dataList[i].price) {
  963. this.$errorMsg("请输入单价");
  964. return;
  965. }
  966. if (!this.dataList[i].walletIds.length) {
  967. this.$errorMsg("请选择现金钱包");
  968. return;
  969. }
  970. }
  971. savePolicy(this.dataList).then((res) => {
  972. this.dataList = [];
  973. this.sleectBox.currentPage = 1;
  974. this.$successMsg("保存成功");
  975. this.handletwoList();
  976. });
  977. },
  978. handleK3List(e, row) {
  979. const item = this.k3List.filter((k) => {
  980. return k.id == e;
  981. })[0];
  982. this.$set(row, "materialNumber", item.number);
  983. this.$set(row, "materialName", item.name);
  984. this.$set(row, "specification", item.specification);
  985. this.$set(row, "materialId", item.id);
  986. this.getK3List();
  987. },
  988. handleReset() {
  989. Object.assign(this.$data, this.$options.data());
  990. this.getCommonApi();
  991. },
  992. },
  993. components: {
  994. TabelTransfer,
  995. AddCondition,
  996. ImageUpload,
  997. },
  998. };
  999. </script>
  1000. <style lang="scss" scoped>
  1001. h4 {
  1002. margin: 0;
  1003. }
  1004. .yinput{
  1005. ::v-deep input{
  1006. text-align: right;
  1007. }
  1008. }
  1009. .pdt {
  1010. padding-top: 20px;
  1011. }
  1012. .import-btn {
  1013. margin-right: 10px;
  1014. display: inline-block;
  1015. }
  1016. .radio {
  1017. padding: 20px 0;
  1018. }
  1019. .el-divider--horizontal {
  1020. margin: 20px 0;
  1021. }
  1022. .el-container .el-divider--horizontal {
  1023. margin: 10px;
  1024. }
  1025. .el-select {
  1026. width: 100%;
  1027. }
  1028. .footer {
  1029. margin-bottom: 20px;
  1030. }
  1031. </style>