AddPolicy.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  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. :rules="rules"
  18. ref="searchForm"
  19. label-width="120px"
  20. size="small"
  21. class="demo-searchForm"
  22. >
  23. <el-row>
  24. <el-col :xs="24" :ms="12" :lg="12">
  25. <el-form-item label="销售政策编号" prop="code">
  26. <el-input
  27. disabled
  28. v-model="searchForm.code"
  29. placeholder="如未填写,则系统自动生成"
  30. ></el-input>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :ms="12" :lg="12">
  34. <el-form-item label="销售政策说明" prop="title">
  35. <el-input
  36. v-model="searchForm.title"
  37. placeholder="销售政策说明"
  38. ></el-input>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :xs="24" :ms="12" :lg="12">
  42. <el-form-item label="销售政策类型" prop="type">
  43. <el-select
  44. size="small"
  45. v-model="searchForm.type"
  46. placeholder="销售政策类型"
  47. class="select_height"
  48. >
  49. <el-option
  50. v-for="(item, index) in typeOptions"
  51. :key="index"
  52. :label="item.label"
  53. :value="item.value"
  54. >
  55. </el-option>
  56. </el-select>
  57. </el-form-item>
  58. </el-col>
  59. <el-col :xs="24" :ms="12" :lg="12">
  60. <el-form-item label="产品品类" prop="mainId">
  61. <el-select
  62. v-model="searchForm.mainId"
  63. :disabled="dataList.length ? true : false"
  64. placeholder="请选择"
  65. @change="handelStop"
  66. >
  67. <el-option
  68. v-for="item in dictList"
  69. :label="item.dictValue"
  70. :value="item.sysDictId"
  71. ></el-option>
  72. </el-select>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :xs="24" :ms="12" :lg="12">
  76. <el-form-item label="生效日期" prop="startTime">
  77. <el-date-picker
  78. v-model="searchForm.startTime"
  79. type="datetime"
  80. placeholder="生效日期"
  81. default-time="00:00:00"
  82. value-format="yyyy-MM-dd HH:mm:ss"
  83. >
  84. </el-date-picker> </el-form-item
  85. ></el-col>
  86. <el-col :xs="24" :ms="12" :lg="12">
  87. <el-form-item label="失效日期" prop="endTime">
  88. <el-date-picker
  89. v-model="searchForm.endTime"
  90. type="datetime"
  91. placeholder="失效日期"
  92. default-time="00:00:00"
  93. value-format="yyyy-MM-dd HH:mm:ss"
  94. >
  95. </el-date-picker> </el-form-item
  96. ></el-col>
  97. <el-col :xs="24" :ms="24" :lg="24">
  98. <el-form-item label="表头备注" prop="remark">
  99. <el-input
  100. v-model="searchForm.remark"
  101. placeholder="新风机变频挂机。按提货数量1:3开单"
  102. ></el-input>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :xs="24" :ms="24" :lg="24">
  106. <el-form-item label="政策封面图" prop="imgSrc">
  107. <ImageUpload :fileList="fileList" :multiple="false" />
  108. </el-form-item>
  109. </el-col>
  110. </el-row>
  111. </el-form>
  112. </div>
  113. <div class="mymian-container">
  114. <el-row>
  115. <el-divider></el-divider>
  116. <el-row type="flex">
  117. <el-col :span="12">
  118. <h4 style="display: inline-block; margin-right: 20px">
  119. 货品信息
  120. </h4>
  121. <template>
  122. <el-upload
  123. v-show="fang == true"
  124. class="import-btn"
  125. :action="baseURL + 'student/import'"
  126. :http-request="handleImport"
  127. :file-list="importFileList"
  128. :show-file-list="false"
  129. >
  130. <el-button size="small">导入货品价格表</el-button>
  131. </el-upload>
  132. </template>
  133. <el-button
  134. size="small"
  135. class="import-btn"
  136. v-show="fang == false"
  137. @click="handelStop"
  138. >导入货品价格表</el-button
  139. >
  140. <el-button size="small" @click="hanleDownloadFiles"
  141. >下载模板</el-button
  142. >
  143. </el-col>
  144. </el-row>
  145. <el-divider></el-divider>
  146. </el-row>
  147. <el-table
  148. v-loading="listLoading"
  149. :data="dataList"
  150. element-loading-text="Loading"
  151. border
  152. fit
  153. highlight-current-row
  154. stripe
  155. >
  156. <el-table-column
  157. type="index"
  158. label="序号"
  159. width="50"
  160. align="center"
  161. >
  162. </el-table-column>
  163. <el-table-column
  164. prop="materialNumber"
  165. label="货品编码"
  166. align="center"
  167. >
  168. </el-table-column>
  169. <el-table-column
  170. prop="materialName"
  171. label="货品名称"
  172. align="center"
  173. >
  174. </el-table-column>
  175. <el-table-column
  176. prop="specification"
  177. label="规格型号"
  178. align="center"
  179. >
  180. </el-table-column>
  181. <el-table-column
  182. prop="saleTypeCode"
  183. label="销售类型编码"
  184. align="center"
  185. >
  186. </el-table-column>
  187. <el-table-column
  188. prop="saleTypeName"
  189. label="销售类型"
  190. align="center"
  191. >
  192. </el-table-column>
  193. <el-table-column prop="discAmount" label="格力折扣" align="center">
  194. </el-table-column>
  195. <el-table-column prop="price" label="单价" align="center">
  196. </el-table-column>
  197. <el-table-column label="支付钱包" align="center">
  198. <template slot-scope="scope">
  199. <el-tag
  200. style="margin: 5px"
  201. type="success"
  202. size="small"
  203. v-for="item in scope.row.walletRelaList"
  204. >{{ item.walletName }}</el-tag
  205. >
  206. </template>
  207. </el-table-column>
  208. <el-table-column fixed="right" label="操作" align="center">
  209. <template slot-scope="scope">
  210. <el-popconfirm
  211. confirm-button-text="好的"
  212. cancel-button-text="不用了"
  213. icon="el-icon-info"
  214. icon-color="red"
  215. title="内容确定删除吗?"
  216. @onConfirm="hanleDelete(scope.row.id)"
  217. >
  218. <el-button
  219. slot="reference"
  220. type="text"
  221. class="textColor el-popover-left"
  222. >删除</el-button
  223. >
  224. </el-popconfirm>
  225. </template>
  226. </el-table-column>
  227. </el-table>
  228. <!-- 分页 -->
  229. <div style="margin: 20px">
  230. <el-pagination
  231. @size-change="handleSizeChange"
  232. @current-change="handleCurrentChange"
  233. :current-page="currentPage"
  234. :page-sizes="[10, 20, 30, 50]"
  235. :page-size="10"
  236. layout="total, sizes, prev, pager, next, jumper"
  237. :total="listTotal"
  238. >
  239. </el-pagination>
  240. </div>
  241. <el-row>
  242. <el-divider></el-divider>
  243. <el-row type="flex">
  244. <el-col :span="12">
  245. <h4 style="display: inline-block; margin-right: 20px">
  246. 条件信息
  247. </h4>
  248. <el-button size="small" @click="isCondition = 1"
  249. >添加</el-button
  250. ></el-col
  251. >
  252. </el-row>
  253. <el-divider></el-divider>
  254. </el-row>
  255. <el-table
  256. v-loading="listLoading"
  257. :data="conditionList"
  258. element-loading-text="Loading"
  259. border
  260. fit
  261. highlight-current-row
  262. stripe
  263. >
  264. <el-table-column
  265. fixed
  266. type="index"
  267. label="序号"
  268. width="50"
  269. align="center"
  270. >
  271. </el-table-column>
  272. <el-table-column prop="name" label="限定条件" align="center">
  273. <template slot-scope="scope">
  274. <el-input v-model="scope.row.name" style="text-align: center;" placeholder="请输入名称" :disabled="scope.row.fang" @blur="handleConditionName(scope.row)"></el-input>
  275. </template>
  276. </el-table-column>
  277. <el-table-column
  278. fixed="right"
  279. width="150"
  280. label="操作"
  281. align="center"
  282. >
  283. <template slot-scope="scope">
  284. <el-button
  285. type="text"
  286. size="small"
  287. @click="scope.row.fang=false"
  288. >编辑</el-button
  289. >
  290. <el-button
  291. type="text"
  292. size="small"
  293. @click="handleCondition(scope.row.id, scope.$index)"
  294. >删除</el-button
  295. >
  296. </template>
  297. </el-table-column>
  298. </el-table>
  299. </div>
  300. <div>
  301. <el-row>
  302. <el-divider></el-divider>
  303. <el-row type="flex" align="middle">
  304. <el-col :span="2">
  305. <h4>经销商信息</h4>
  306. </el-col>
  307. </el-row>
  308. <el-divider></el-divider>
  309. </el-row>
  310. <Transfer @handleAddPolicy="handleAddPolicy" />
  311. </div>
  312. </div>
  313. </div>
  314. <AddCondition
  315. v-show="isCondition == 1"
  316. @handleSubmitCon="handleSubmitCon"
  317. />
  318. </div>
  319. </template>
  320. <script>
  321. import { mapState, mapMutations } from "vuex";
  322. import Minxin from "@/mixin";
  323. import {
  324. addPoliy,
  325. getTypeList,
  326. getWalletList,
  327. getMaterialList,
  328. deleteCondition,
  329. getConditionList,
  330. deleteMaterialPolicy,
  331. updateCondition
  332. } from "@/api/policy_list";
  333. import { getDictList } from "@/api/common";
  334. import { downloadFiles, handleImport } from "@/utils/util";
  335. import Transfer from "./Transfer";
  336. import AddCondition from "./AddCondition";
  337. import ImageUpload from "@/components/Common/image-upload.vue";
  338. export default {
  339. mixins: [Minxin],
  340. data() {
  341. return {
  342. fang: false,
  343. input: "",
  344. baseURL: "",
  345. isCondition: 0,
  346. searchForm: {
  347. code: "",
  348. endTime: "",
  349. imgSrc: "",
  350. remark: "",
  351. startTime: "",
  352. title: "",
  353. mainId: "",
  354. mainName: "",
  355. type: "",
  356. },
  357. listLoading: false,
  358. rules: {
  359. name: [
  360. { required: true, message: "", trigger: "click" },
  361. { min: 3, max: 5, message: "", trigger: "click" },
  362. ],
  363. },
  364. importFileList: [],
  365. fileList: [],
  366. options: {},
  367. value: "",
  368. typeList: [],
  369. walletList: [],
  370. typeOptions: [
  371. {
  372. value: "PROVISION",
  373. label: "配提",
  374. },
  375. {
  376. value: "LIMIT",
  377. label: "限量",
  378. },
  379. ],
  380. conditionList: [],
  381. dictList: [],
  382. };
  383. },
  384. computed: mapState({
  385. comCode: (state) => {
  386. console.log(state, "kkkk");
  387. return state.sales.code;
  388. },
  389. // newForm:(state) => {
  390. // return state.sales.searchForm;
  391. // },
  392. // imgFile:(state) => {
  393. // return state.sales.fileList;
  394. // },
  395. }),
  396. mounted() {
  397. // console.log(this.comCode, "kkjk");
  398. this.searchForm.code = this.comCode;
  399. },
  400. updated() {
  401. console.log(this.comCode, "kkjk");
  402. this.searchForm.code = this.comCode;
  403. },
  404. created() {
  405. this.getCommonApi();
  406. if (this.$parent.isFlag) {
  407. // this.handletwoList()
  408. }
  409. },
  410. methods: {
  411. ...mapMutations("sales", ["initData"]),
  412. //下载excel模板
  413. hanleDownloadFiles() {
  414. downloadFiles("/policy/download");
  415. },
  416. handleCondition(id, index) {
  417. deleteCondition({ id }).then((res) => {
  418. this.conditionList.splice(index, 1);
  419. Object.assign(
  420. this.$children[9].$data,
  421. this.$children[9].$options.data()
  422. );
  423. this.$successMsg("删除成功");
  424. });
  425. },
  426. getCommonApi() {
  427. // this.handletwoList()
  428. const params = {
  429. pageNum: 1,
  430. pageSize: 10,
  431. saleCode: "",
  432. saleName: "",
  433. status: "",
  434. };
  435. const walletParams = {
  436. pageNum: 1,
  437. pageSize: 10,
  438. mainName: "",
  439. saleTypeCode: "",
  440. saleTypeName: "",
  441. status: "",
  442. };
  443. // 获取销售类型列表
  444. getTypeList(params).then((res) => {
  445. this.typeList = res.data.records;
  446. console.log(this.typeList, "type");
  447. });
  448. // 获取钱包列表
  449. getWalletList(walletParams).then((res) => {
  450. this.walletList = res.data.records;
  451. });
  452. getDictList({ sysDictEnum: "PRODUCT_TYPE" }).then((res) => {
  453. this.dictList = res.data;
  454. });
  455. },
  456. handleConditionName(row){
  457. console.log(row.name);
  458. updateCondition({id:row.id,name:row.name}).then(res=>{
  459. this.$successMsg('修改成功')
  460. row.fang = true
  461. })
  462. },
  463. handleSubmitCon() {
  464. const params = {
  465. policyId: this.comCode,
  466. };
  467. // 获取条件政策
  468. getConditionList(params).then((res) => {
  469. for (let i = 0; i < res.data.length; i++) {
  470. res.data[i].name = ''
  471. res.data[i].fang = true
  472. }
  473. this.conditionList = res.data;
  474. });
  475. },
  476. handelStop() {
  477. if (this.searchForm.mainId) {
  478. this.fang = true;
  479. } else {
  480. this.$errorMsg("请选择产品品类");
  481. }
  482. },
  483. // 导入
  484. async handleImport(param) {
  485. this.importLoading = true;
  486. const file = param.file;
  487. console.log(file, 123);
  488. const formData = new FormData();
  489. formData.append("file", file);
  490. formData.append("policyId", this.searchForm.code);
  491. formData.append("mainId", this.searchForm.mainId);
  492. let result = await handleImport("/policy/material/import", formData);
  493. this.importLoading = false;
  494. this.importFileList = [];
  495. if (result.code == 200) {
  496. this.$alert(result.message, "导入成功", {
  497. confirmButtonText: "确定",
  498. });
  499. this.handletwoList();
  500. } else {
  501. this.$alert(result.message, "导入失败", {
  502. confirmButtonText: "确定",
  503. });
  504. }
  505. },
  506. getList() {
  507. if (this.$parent.isFlag) {
  508. this.handletwoList();
  509. }
  510. },
  511. // 获取货品信息
  512. handletwoList() {
  513. // this.searchForm.type
  514. const paramss = {
  515. pageNum: this.currentPage,
  516. pageSize: this.pageSize,
  517. policyId: this.comCode,
  518. saleTypeCode: "",
  519. };
  520. console.log(45454);
  521. getMaterialList(paramss)
  522. .then((result) => {
  523. this.dataList = result.data.records;
  524. this.listTotal = result.data.total;
  525. })
  526. .catch((err) => {
  527. console.error(err);
  528. });
  529. },
  530. // 提交审核
  531. handleAddPolicy(policyCustomers) {
  532. if (!this.conditionList.length) {
  533. this.$errorMsg("请添加条件信息 ");
  534. return
  535. }
  536. if (policyCustomers.length) {
  537. var arr = [];
  538. policyCustomers.forEach((el) => {
  539. arr.push({
  540. customerId: el.id,
  541. customerName: el.name,
  542. customerNumber: el.number,
  543. lastOrderTime: "",
  544. limitTakeNum: 0,
  545. policyId: this.comCode,
  546. policyTitle: "",
  547. remark: "",
  548. });
  549. });
  550. this.dictList.forEach((k) => {
  551. if (k.sysDictId == this.searchForm.mainId) {
  552. this.searchForm.mainName = k.dictValue;
  553. }
  554. });
  555. const params = {
  556. adminCompanyId: "",
  557. code: "",
  558. customerCount: 0,
  559. examineBy: "",
  560. examineRemark: "",
  561. examineStatus: "",
  562. id: "",
  563. imgSrc: this.fileList.length ? this.fileList[0].url : "",
  564. policyCustomers: arr,
  565. remark: "",
  566. status: true,
  567. title: "",
  568. type: "",
  569. ...this.searchForm,
  570. };
  571. addPoliy(params).then((res) => {
  572. console.log(res);
  573. this.$successMsg("新增成功");
  574. this.fileList = [];
  575. this.$parent.getList();
  576. this.$parent.isShow = 1;
  577. });
  578. return;
  579. }
  580. this.$errorMsg("选择经销商 ");
  581. },
  582. //删除
  583. hanleDelete(id) {
  584. const params = { policyMaterialId: id };
  585. deleteMaterialPolicy(params).then((res) => {
  586. this.$successMsg("删除成功");
  587. this.handletwoList();
  588. });
  589. },
  590. },
  591. components: {
  592. Transfer,
  593. AddCondition,
  594. ImageUpload,
  595. },
  596. };
  597. </script>
  598. <style lang="scss" scoped>
  599. h4 {
  600. margin: 0;
  601. }
  602. .pdt {
  603. padding-top: 20px;
  604. }
  605. .import-btn {
  606. margin-right: 10px;
  607. display: inline-block;
  608. }
  609. .radio {
  610. padding: 20px 0;
  611. }
  612. .el-divider--horizontal {
  613. margin: 20px 0;
  614. }
  615. .el-container .el-divider--horizontal {
  616. margin: 10px;
  617. }
  618. .el-select {
  619. width: 100%;
  620. }
  621. .footer {
  622. margin-bottom: 20px;
  623. }
  624. </style>