AddPolicy.vue 16 KB

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