AddPolicy.vue 15 KB

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