AddPolicy.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. <template>
  2. <div>
  3. <div v-show="isCondition == 0">
  4. <el-header height="50px" class="header">
  5. <el-page-header
  6. @back="($parent.isShow = 1), ($parent.isFlag = '')"
  7. content="新增"
  8. >
  9. </el-page-header>
  10. </el-header>
  11. <div class="app-container">
  12. <div class="screen-container">
  13. <h4>销售政策信息</h4>
  14. <el-divider></el-divider>
  15. <el-form
  16. :model="searchForm"
  17. ref="form"
  18. label-width="120px"
  19. size="small"
  20. class="demo-searchForm"
  21. >
  22. <el-row>
  23. <el-col :xs="24" :ms="12" :lg="12">
  24. <el-form-item label="销售政策编号">
  25. <el-input
  26. disabled
  27. v-model="searchForm.code"
  28. placeholder="如未填写,则系统自动生成"
  29. ></el-input>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :xs="24" :ms="12" :lg="12">
  33. <el-form-item label="销售政策说明" prop="title">
  34. <el-input
  35. v-model="searchForm.title"
  36. placeholder="销售政策说明"
  37. ></el-input>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :xs="24" :ms="12" :lg="12">
  41. <el-form-item label="销售政策类型" prop="type">
  42. <el-select
  43. size="small"
  44. v-model="searchForm.type"
  45. placeholder="销售政策类型"
  46. class="select_height"
  47. >
  48. <el-option
  49. v-for="(item, index) in typeOptions"
  50. :key="index"
  51. :label="item.label"
  52. :value="item.value"
  53. >
  54. </el-option>
  55. </el-select>
  56. </el-form-item>
  57. </el-col>
  58. <!-- <el-col :xs="24" :ms="12" :lg="12">
  59. <el-form-item label="产品品类" prop="mainId">
  60. <el-select
  61. v-model="searchForm.mainId"
  62. :disabled="dataList.length ? true : false"
  63. placeholder="请选择"
  64. @change="handelStop"
  65. >
  66. <el-option
  67. v-for="item in dictList"
  68. :label="item.dictValue"
  69. :value="item.dictCode"
  70. ></el-option>
  71. </el-select>
  72. </el-form-item>
  73. </el-col> -->
  74. <el-col :xs="24" :ms="12" :lg="12">
  75. <el-form-item label="生效日期" prop="startTime">
  76. <el-date-picker
  77. v-model="searchForm.startTime"
  78. type="datetime"
  79. placeholder="生效日期"
  80. default-time="00:00:00"
  81. value-format="yyyy-MM-dd HH:mm:ss"
  82. >
  83. </el-date-picker> </el-form-item
  84. ></el-col>
  85. <el-col :xs="24" :ms="12" :lg="12">
  86. <el-form-item label="失效日期" prop="endTime">
  87. <el-date-picker
  88. v-model="searchForm.endTime"
  89. type="datetime"
  90. placeholder="失效日期"
  91. default-time="00:00:00"
  92. value-format="yyyy-MM-dd HH:mm:ss"
  93. >
  94. </el-date-picker> </el-form-item
  95. ></el-col>
  96. <el-col :xs="24" :ms="24" :lg="24">
  97. <el-form-item label="表头备注" prop="remark">
  98. <el-input
  99. v-model="searchForm.remark"
  100. placeholder="新风机变频挂机。按提货数量1:3开单"
  101. ></el-input>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :xs="24" :ms="24" :lg="24">
  105. <el-form-item label="政策封面图">
  106. <ImageUpload :fileList="fileList" :multiple="false" />
  107. </el-form-item>
  108. </el-col>
  109. </el-row>
  110. </el-form>
  111. </div>
  112. <div class="mymian-container">
  113. <el-row>
  114. <el-divider></el-divider>
  115. <el-row type="flex">
  116. <el-col :span="12">
  117. <h4 style="display: inline-block; margin-right: 20px">
  118. 货品信息
  119. </h4>
  120. <template>
  121. <el-upload
  122. class="import-btn"
  123. :action="baseURL + 'student/import'"
  124. :http-request="handleImport"
  125. :file-list="importFileList"
  126. :show-file-list="false"
  127. >
  128. <el-button type="primary" size="small"
  129. >导入货品价格表</el-button
  130. >
  131. </el-upload>
  132. </template>
  133. <el-button
  134. type="primary"
  135. size="small"
  136. @click="hanleDownloadFiles"
  137. >下载模板</el-button
  138. >
  139. </el-col>
  140. </el-row>
  141. <el-divider></el-divider>
  142. </el-row>
  143. <el-table
  144. v-loading="listLoading"
  145. :data="dataList"
  146. element-loading-text="Loading"
  147. border
  148. fit
  149. highlight-current-row
  150. stripe
  151. >
  152. <el-table-column
  153. type="index"
  154. label="序号"
  155. width="50"
  156. align="center"
  157. >
  158. </el-table-column>
  159. <el-table-column
  160. prop="materialNumber"
  161. label="货品编码"
  162. align="center"
  163. >
  164. <template slot-scope="scope">
  165. <el-select
  166. size="small"
  167. v-model="scope.row.materialNumber"
  168. @change="handleK3List($event, scope.row)"
  169. v-el-select-loadmore="loadmore"
  170. filterable
  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-option>
  179. </el-select>
  180. </template>
  181. </el-table-column>
  182. <el-table-column
  183. prop="materialName"
  184. label="货品名称"
  185. align="center"
  186. >
  187. </el-table-column>
  188. <el-table-column
  189. prop="specification"
  190. label="规格型号"
  191. align="center"
  192. >
  193. <template slot-scope="scope">
  194. <el-select
  195. size="small"
  196. v-model="scope.row.specification"
  197. @change="handleK3List($event, scope.row)"
  198. filterable
  199. >
  200. <el-option
  201. v-for="item in k3List"
  202. :key="item.id"
  203. :label="item.specification"
  204. :value="item.id"
  205. >
  206. </el-option>
  207. </el-select>
  208. </template>
  209. </el-table-column>
  210. <el-table-column
  211. prop="saleTypeName"
  212. label="销售类型"
  213. align="center"
  214. >
  215. <template slot-scope="scope">
  216. <el-select
  217. size="small"
  218. v-model="scope.row.saleTypeId"
  219. @change="handleSalesType($event, scope.row)"
  220. filterable
  221. >
  222. <el-option
  223. v-for="item in typeList"
  224. :key="item.id"
  225. :label="item.saleName"
  226. :value="item.id"
  227. >
  228. </el-option>
  229. </el-select>
  230. </template>
  231. </el-table-column>
  232. <el-table-column
  233. prop="saleTypeCode"
  234. label="销售类型编码"
  235. align="center"
  236. >
  237. </el-table-column>
  238. <el-table-column prop="discAmount" label="格力折扣" align="center">
  239. <template slot-scope="scope">
  240. <el-input
  241. type="number"
  242. v-model.number="scope.row.discAmount"
  243. placeholder="请输入格力折扣"
  244. size="small"
  245. ></el-input>
  246. </template>
  247. </el-table-column>
  248. <el-table-column prop="price" label="单价" align="center">
  249. <template slot-scope="scope">
  250. <el-input
  251. type="number"
  252. v-model.number="scope.row.price"
  253. placeholder="请输入单价"
  254. size="small"
  255. ></el-input>
  256. </template>
  257. </el-table-column>
  258. <el-table-column label="支付钱包" align="center">
  259. <template slot-scope="scope">
  260. <el-select
  261. size="small"
  262. multiple
  263. v-model="scope.row.walletIds"
  264. filterable
  265. >
  266. <el-option
  267. v-for="item in NoRebateWalletList"
  268. :key="item.id"
  269. :label="item.name"
  270. :value="item.id"
  271. >
  272. </el-option>
  273. </el-select>
  274. <!-- <el-tag
  275. style="margin: 5px"
  276. type="success"
  277. size="small"
  278. v-for="item in scope.row.walletRelaList"
  279. >{{ item.walletName }}</el-tag
  280. > -->
  281. </template>
  282. </el-table-column>
  283. <el-table-column prop="remark" label="备注" align="center">
  284. <template slot-scope="scope">
  285. <el-input
  286. v-model="scope.row.remark"
  287. placeholder="备注"
  288. size="small"
  289. ></el-input>
  290. </template>
  291. </el-table-column>
  292. <el-table-column fixed="right" label="操作" align="center">
  293. <template slot-scope="scope">
  294. <el-popconfirm
  295. confirm-button-text="好的"
  296. cancel-button-text="不用了"
  297. icon="el-icon-info"
  298. icon-color="red"
  299. title="内容确定删除吗?"
  300. @onConfirm="hanleDelete(scope.row.id, scope.$index)"
  301. >
  302. <el-button
  303. slot="reference"
  304. type="text"
  305. class="textColor el-popover-left"
  306. >删除</el-button
  307. >
  308. </el-popconfirm>
  309. </template>
  310. </el-table-column>
  311. </el-table>
  312. <!-- 分页 -->
  313. <div
  314. style="
  315. margin: 20px 20px 20px 0;
  316. display: flex;
  317. justify-content: space-between;
  318. "
  319. >
  320. <div>
  321. <el-button type="primary" size="small" @click="handleNewInfo"
  322. >添加</el-button
  323. >
  324. <el-button type="primary" size="small" @click="handleSave"
  325. >保存</el-button
  326. >
  327. </div>
  328. <el-pagination
  329. @size-change="handleSizeChange"
  330. @current-change="handleCurrentChange"
  331. :current-page="currentPage"
  332. :page-sizes="[10, 20, 30, 50]"
  333. :page-size="10"
  334. layout="total, sizes, prev, pager, next, jumper"
  335. :total="listTotal"
  336. >
  337. </el-pagination>
  338. </div>
  339. <el-row>
  340. <el-divider></el-divider>
  341. <el-row type="flex">
  342. <el-col :span="12">
  343. <h4 style="display: inline-block; margin-right: 20px">
  344. 条件信息
  345. </h4>
  346. <el-button type="primary" size="small" @click="isCondition = 1"
  347. >添加</el-button
  348. ></el-col
  349. >
  350. </el-row>
  351. <el-divider></el-divider>
  352. </el-row>
  353. <el-table
  354. v-loading="listLoading"
  355. :data="conditionList"
  356. element-loading-text="Loading"
  357. border
  358. fit
  359. highlight-current-row
  360. stripe
  361. >
  362. <el-table-column
  363. fixed
  364. type="index"
  365. label="序号"
  366. width="50"
  367. align="center"
  368. >
  369. </el-table-column>
  370. <el-table-column prop="name" label="限定条件" align="center">
  371. <template slot-scope="scope">
  372. <el-input
  373. v-model="scope.row.name"
  374. style="text-align: center"
  375. placeholder="请输入名称"
  376. :disabled="scope.row.fang"
  377. @blur="handleConditionName(scope.row)"
  378. ></el-input>
  379. </template>
  380. </el-table-column>
  381. <el-table-column
  382. fixed="right"
  383. width="150"
  384. label="操作"
  385. align="center"
  386. >
  387. <template slot-scope="scope">
  388. <el-button
  389. type="text"
  390. size="small"
  391. @click="scope.row.fang = false"
  392. >编辑</el-button
  393. >
  394. <el-button
  395. type="text"
  396. size="small"
  397. @click="handleCondition(scope.row.id, scope.$index)"
  398. >删除</el-button
  399. >
  400. </template>
  401. </el-table-column>
  402. </el-table>
  403. </div>
  404. <div>
  405. <el-row>
  406. <el-divider></el-divider>
  407. <el-row type="flex" align="middle">
  408. <el-col :span="2">
  409. <h4>经销商信息</h4>
  410. </el-col>
  411. </el-row>
  412. <el-divider></el-divider>
  413. </el-row>
  414. <Transfer @handleAddPolicy="handleAddPolicy" />
  415. </div>
  416. </div>
  417. </div>
  418. <AddCondition
  419. v-show="isCondition == 1"
  420. @handleSubmitCon="handleSubmitCon"
  421. />
  422. </div>
  423. </template>
  424. <script>
  425. import { mapGetters, mapMutations } from "vuex";
  426. import Minxin from "@/mixin";
  427. import {
  428. addPoliy,
  429. getK3List,
  430. savePolicy,
  431. getTypeList,
  432. getWalletList,
  433. updateCondition,
  434. getMaterialList,
  435. deleteCondition,
  436. getConditionList,
  437. deleteMaterialPolicy,
  438. getNoRebateWalletList,
  439. } from "@/api/policy_list";
  440. import { getDictList } from "@/api/common";
  441. import { downloadFiles, handleImport } from "@/utils/util";
  442. import Transfer from "./Transfer";
  443. import AddCondition from "./AddCondition";
  444. import ImageUpload from "@/components/Common/image-upload.vue";
  445. import { type } from "os";
  446. export default {
  447. mixins: [Minxin],
  448. directives: {
  449. "el-select-loadmore": {
  450. bind(el, binding) {
  451. // 获取element-ui定义好的scroll盒⼦
  452. const SELECTWRAP_DOM = el.querySelector(
  453. ".el-select-dropdown .el-select-dropdown__wrap"
  454. );
  455. SELECTWRAP_DOM.addEventListener("scroll", function () {
  456. /**
  457. * scrollHeight 获取元素内容⾼度(只读)
  458. * scrollTop 获取或者设置元素的偏移值,常⽤于, 计算滚动条的位置, 当⼀个元素的容器没有产⽣垂直⽅向的滚动条, 那它的scrollTop的值默认为0.
  459. * clientHeight 读取元素的可见⾼度(只读)
  460. * 如果元素滚动到底, 下⾯等式返回true, 没有则返回false:
  461. * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
  462. */
  463. const condition =
  464. this.scrollHeight - this.scrollTop <= this.clientHeight;
  465. if (condition) {
  466. binding.value();
  467. }
  468. });
  469. },
  470. },
  471. },
  472. data() {
  473. return {
  474. fang: false,
  475. input: "",
  476. baseURL: "",
  477. isCondition: 0,
  478. searchForm: {
  479. code: "",
  480. endTime: "",
  481. imgSrc: "",
  482. remark: "",
  483. startTime: "",
  484. title: "",
  485. mainId: "",
  486. mainName: "",
  487. type: "",
  488. },
  489. dataList: [],
  490. addList: [],
  491. listLoading: false,
  492. dialogVisible: false,
  493. importFileList: [],
  494. fileList: [],
  495. options: {},
  496. value: "",
  497. typeList: [],
  498. walletList: [],
  499. typeOptions: [
  500. {
  501. value: "PROVISION",
  502. label: "配提",
  503. },
  504. {
  505. value: "LIMIT",
  506. label: "限量",
  507. },
  508. ],
  509. conditionList: [],
  510. dictList: [],
  511. k3List: [],
  512. NoRebateWalletList: [],
  513. sleectBox:{currentPage:1}
  514. };
  515. },
  516. computed: {
  517. ...mapGetters({
  518. comCode: "code",
  519. }),
  520. },
  521. mounted() {
  522. this.searchForm.code = this.comCode;
  523. },
  524. updated() {
  525. this.searchForm.code = this.comCode;
  526. },
  527. created() {
  528. this.getCommonApi();
  529. // console.log(this.$store.code);
  530. if (this.$parent.isFlag) {
  531. // this.handletwoList()
  532. }
  533. },
  534. methods: {
  535. ...mapMutations("sales", ["initData"]),
  536. //下载excel模板
  537. hanleDownloadFiles() {
  538. downloadFiles("/policy/download");
  539. },
  540. handleCondition(id, index) {
  541. deleteCondition({ id }).then((res) => {
  542. this.conditionList.splice(index, 1);
  543. Object.assign(
  544. this.$children[9].$data,
  545. this.$children[9].$options.data()
  546. );
  547. this.$successMsg("删除成功");
  548. });
  549. },
  550. loadmore() {
  551. this.sleectBox.currentPage++;
  552. this.getK3List();
  553. },
  554. getK3List(){
  555. getK3List({
  556. pageNum: this.sleectBox.currentPage,
  557. pageSize: 10,
  558. keyword: "",
  559. }).then((res) => {
  560. this.k3List = [...this.k3List,...res.data.records];
  561. });
  562. },
  563. getCommonApi() {
  564. this.getK3List()
  565. // 非返利钱包
  566. getNoRebateWalletList({ walletName: "" }).then((res) => {
  567. this.NoRebateWalletList = res.data;
  568. console.log(this.NoRebateWalletList, "kkkk");
  569. });
  570. const params = {
  571. pageNum: 1,
  572. pageSize: -1,
  573. saleCode: "",
  574. saleName: "",
  575. status: "",
  576. };
  577. // 获取销售类型列表
  578. getTypeList(params).then((res) => {
  579. this.typeList = res.data.records;
  580. });
  581. // this.handletwoList()
  582. // const params = {
  583. // pageNum: 1,
  584. // pageSize: 10,
  585. // saleCode: "",
  586. // saleName: "",
  587. // status: "",
  588. // };
  589. // const walletParams = {
  590. // pageNum: 1,
  591. // pageSize: 10,
  592. // mainName: "",
  593. // saleTypeCode: "",
  594. // saleTypeName: "",
  595. // status: "",
  596. // };
  597. // // 获取钱包列表
  598. // getWalletList(walletParams).then((res) => {
  599. // this.walletList = res.data.records;
  600. // });
  601. // getDictList({ sysDictEnum: "PRODUCT_TYPE" }).then((res) => {
  602. // this.dictList = res.data;
  603. // });
  604. },
  605. handleSalesType(e, row) {
  606. const item = this.typeList.filter((k) => {
  607. return k.id == e;
  608. })[0];
  609. this.$set(row, "saleTypeCode", item.saleCode);
  610. this.$set(row, "saleTypeName", item.saleName);
  611. // this.$set(row,'saleTypeId',item.id)
  612. },
  613. //修改条件名称
  614. handleConditionName(row) {
  615. console.log(row.name);
  616. updateCondition({ id: row.id, name: row.name }).then((res) => {
  617. this.$successMsg("修改成功");
  618. row.fang = true;
  619. });
  620. },
  621. //提交信息
  622. handleSubmitCon() {
  623. const params = {
  624. policyId: this.comCode,
  625. };
  626. // 获取条件政策
  627. getConditionList(params).then((res) => {
  628. for (let i = 0; i < res.data.length; i++) {
  629. res.data[i].fang = true;
  630. }
  631. this.conditionList = res.data;
  632. });
  633. },
  634. // 视图部分已注释,废弃的功能 fucn
  635. handelStop() {
  636. if (this.searchForm.mainId) {
  637. this.fang = true;
  638. } else {
  639. this.$errorMsg("请选择产品品类");
  640. }
  641. },
  642. // 导入
  643. async handleImport(param) {
  644. this.importLoading = true;
  645. const file = param.file;
  646. console.log(file, 123);
  647. const formData = new FormData();
  648. formData.append("file", file);
  649. formData.append("policyId", this.searchForm.code);
  650. // formData.append("mainId", this.searchForm.mainId);
  651. let result = await handleImport("/policy/material/import", formData);
  652. this.importLoading = false;
  653. this.importFileList = [];
  654. if (result.code == 200) {
  655. this.$alert(result.message, "导入成功", {
  656. confirmButtonText: "确定",
  657. });
  658. this.dataList = [];
  659. this.listTotal = 0;
  660. this.sleectBox.currentPage=1
  661. this.handletwoList();
  662. } else {
  663. this.$alert(result.message, "导入失败", {
  664. confirmButtonText: "确定",
  665. });
  666. }
  667. },
  668. getList() {
  669. if (this.$parent.isFlag) {
  670. this.handletwoList();
  671. }
  672. },
  673. // 获取货品信息
  674. handletwoList() {
  675. // this.searchForm.type
  676. const paramss = {
  677. pageNum: this.currentPage,
  678. pageSize: this.pageSize,
  679. policyId: this.comCode,
  680. saleTypeCode: "",
  681. };
  682. getMaterialList(paramss)
  683. .then((result) => {
  684. result.data.records.forEach((k) => {
  685. k.walletIds = [];
  686. if (!k.specification) {
  687. k.materialNumber = k.materialId;
  688. k.specification = k.materialId;
  689. }else{
  690. k.materialNumber = k.materialNumber;
  691. k.specification = k.specification;
  692. }
  693. k.materialId = k.materialId;
  694. k.walletRelaList.forEach((l) => {
  695. l.id = l.walletId;
  696. l.name = l.walletName;
  697. k.walletIds = [...k.walletIds, l.walletId];
  698. });
  699. });
  700. this.dataList = [...this.dataList, ...result.data.records];
  701. this.listTotal = result.data.total;
  702. })
  703. .catch((err) => {
  704. console.error(err);
  705. });
  706. },
  707. // 提交审核
  708. handleAddPolicy(policyCustomers) {
  709. if (!this.searchForm.title) {
  710. this.$errorMsg("请输入说明");
  711. return;
  712. }
  713. if (!this.searchForm.type) {
  714. this.$errorMsg("请选择类型");
  715. return;
  716. }
  717. if (!this.searchForm.startTime) {
  718. this.$errorMsg("请选择生效日期");
  719. return;
  720. }
  721. if (policyCustomers.length) {
  722. var arr = [];
  723. policyCustomers.forEach((el) => {
  724. arr.push({
  725. customerId: el.id,
  726. customerName: el.name,
  727. customerNumber: el.number,
  728. lastOrderTime: "",
  729. limitTakeNum: 0,
  730. policyId: this.comCode,
  731. policyTitle: "",
  732. remark: "",
  733. });
  734. });
  735. // this.dictList.forEach((k) => {
  736. // if (k.dictCode == this.searchForm.mainId) {
  737. // this.searchForm.mainName = k.dictValue;
  738. // }
  739. // });
  740. const params = {
  741. adminCompanyId: "",
  742. code: "",
  743. customerCount: 0,
  744. examineBy: "",
  745. examineRemark: "",
  746. examineStatus: "",
  747. id: "",
  748. policyCustomers: arr,
  749. remark: "",
  750. status: true,
  751. title: "",
  752. type: "",
  753. ...this.searchForm,
  754. endTime: this.searchForm.endTime || "2100-01-01 00:00:00",
  755. imgSrc: this.fileList.length ? this.fileList[0].url : "",
  756. };
  757. console.log(this.fileList);
  758. addPoliy(params).then((res) => {
  759. console.log(res);
  760. this.$successMsg("新增成功");
  761. this.$parent.getList();
  762. this.$parent.isShow = 1;
  763. });
  764. return;
  765. } else {
  766. this.$errorMsg("选择经销商 ");
  767. }
  768. },
  769. //删除
  770. hanleDelete(id, index) {
  771. if (id) {
  772. const params = { policyMaterialId: id };
  773. deleteMaterialPolicy(params).then((res) => {
  774. this.dataList.splice(index, 1);
  775. });
  776. }
  777. this.dataList.splice(index, 1);
  778. this.listTotal -= 1;
  779. this.$successMsg("删除成功");
  780. },
  781. handleNewInfo() {
  782. // 物料列表
  783. this.dataList.push({
  784. id: "",
  785. discAmount: "",
  786. materialId: "",
  787. materialName: "",
  788. materialNumber: "",
  789. policyId: this.comCode,
  790. price: "",
  791. remark: "",
  792. saleTypeCode: "",
  793. saleTypeId: "",
  794. saleTypeName: "",
  795. specification: "",
  796. walletIds: "",
  797. walletRelaList: [],
  798. });
  799. this.sleectBox.currentPage =1
  800. this.listTotal += 1;
  801. // this.dataList.push(this.addList[this.addList.length-1])
  802. },
  803. handleSave() {
  804. if (!this.dataList.length) {
  805. return
  806. }
  807. for (let i = 0; i < this.dataList.length; i++) {
  808. if (!this.dataList[i].materialId) {
  809. this.$errorMsg("请选择货品");
  810. return
  811. }
  812. if (!this.dataList[i].saleTypeId) {
  813. this.$errorMsg("请选择销售类型");
  814. return
  815. }
  816. if (!this.dataList[i].discAmount) {
  817. this.$errorMsg("请输入格力折扣");
  818. return
  819. }
  820. if (!this.dataList[i].price) {
  821. this.$errorMsg("请输入单价");
  822. return
  823. }
  824. if (!this.dataList[i].walletIds.length) {
  825. this.$errorMsg("请选择钱包");
  826. return
  827. }
  828. }
  829. savePolicy(this.dataList).then((res) => {
  830. this.dataList = [];
  831. this.sleectBox.currentPage =1
  832. this.$successMsg("保存成功");
  833. this.handletwoList();
  834. });
  835. },
  836. handleK3List(e, row) {
  837. const item = this.k3List.filter((k) => {
  838. return k.id == e;
  839. })[0];
  840. // this.$set(row,'materialNumber',item.number)
  841. this.$set(row, "materialName", item.name);
  842. this.$set(row, "specification", item.specification);
  843. this.$set(row, "materialId", item.id);
  844. },
  845. },
  846. components: {
  847. Transfer,
  848. AddCondition,
  849. ImageUpload,
  850. },
  851. };
  852. </script>
  853. <style lang="scss" scoped>
  854. h4 {
  855. margin: 0;
  856. }
  857. .pdt {
  858. padding-top: 20px;
  859. }
  860. .import-btn {
  861. margin-right: 10px;
  862. display: inline-block;
  863. }
  864. .radio {
  865. padding: 20px 0;
  866. }
  867. .el-divider--horizontal {
  868. margin: 20px 0;
  869. }
  870. .el-container .el-divider--horizontal {
  871. margin: 10px;
  872. }
  873. .el-select {
  874. width: 100%;
  875. }
  876. .footer {
  877. margin-bottom: 20px;
  878. }
  879. </style>