AddCondition.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. <template>
  2. <el-container>
  3. <el-header height="50px" class="header">
  4. <el-page-header @back="handleBack" :content="!id? '添加页面':'详情页面'"> </el-page-header>
  5. </el-header>
  6. <div class="line">
  7. <el-divider></el-divider>
  8. <h4>限定条件</h4>
  9. <el-divider></el-divider>
  10. </div>
  11. <el-main v-if="!id">
  12. <el-row>
  13. <el-row :gutter="50">
  14. <el-col
  15. :xs="24"
  16. :sm="24"
  17. :lg="24"
  18. class="mgb"
  19. v-for="(item, index) in conditionBox"
  20. :key="index"
  21. >
  22. <el-row>
  23. <el-row class="pdt">
  24. <el-button
  25. type="primary"
  26. size="small"
  27. @click="(VisibleModle = true), getMaterialLists(index)"
  28. >添加机型</el-button
  29. >
  30. <el-button
  31. type="primary"
  32. size="small"
  33. @click="handleDeleteRow(index)"
  34. >删除机型</el-button
  35. >
  36. </el-row>
  37. <el-row>
  38. <el-table
  39. style="width: 100%"
  40. :data="item"
  41. border
  42. @select="hanleSelectAll($event, index)"
  43. @select-all="hanleSelectAll($event, index)"
  44. >
  45. <el-table-column type="selection" width="55" align="center">
  46. </el-table-column>
  47. <el-table-column
  48. label="货品名称"
  49. width="300"
  50. align="center"
  51. prop="materialName"
  52. >
  53. </el-table-column>
  54. <el-table-column
  55. prop="specification"
  56. label="规格型号"
  57. align="center"
  58. >
  59. </el-table-column>
  60. </el-table>
  61. </el-row>
  62. </el-row>
  63. </el-col>
  64. </el-row>
  65. <el-row>
  66. <el-form label-width="120px" :inline="false" size="small">
  67. <el-row>
  68. <el-form-item label="配置比例设置"> </el-form-item>
  69. </el-row>
  70. <el-col :xs="24" :sm="8" :lg="8">
  71. <el-form-item label="限定机型">
  72. <el-input size="small" v-model="limit"></el-input>
  73. </el-form-item>
  74. </el-col>
  75. <el-col
  76. :xs="24"
  77. :sm="8"
  78. :lg="8"
  79. v-for="(len, index) in conditionBox.length - 1"
  80. >
  81. <el-form-item :label="'配提' + (index + 1) + '比例'">
  82. <el-input
  83. size="small"
  84. v-model="popArr['line_' + index]"
  85. ></el-input>
  86. </el-form-item>
  87. </el-col>
  88. </el-form>
  89. </el-row>
  90. <el-divider></el-divider>
  91. </el-row>
  92. </el-main>
  93. <el-main v-else>
  94. <el-row>
  95. <el-row :gutter="50">
  96. <el-col
  97. :xs="24"
  98. :sm="24"
  99. :lg="24"
  100. class="mgb"
  101. v-for="(item, index) in conditionBoxs"
  102. :key="index"
  103. >
  104. <el-row>
  105. <el-row>
  106. <el-table style="width: 100%" :data="item" border>
  107. <el-table-column type="selection" width="55" align="center" v-if="!id">
  108. </el-table-column>
  109. <el-table-column type="index" label="序号" width="55" align="center" v-else>
  110. </el-table-column>
  111. <el-table-column
  112. label="货品名称"
  113. width="300"
  114. align="center"
  115. prop="materialName"
  116. >
  117. <template slot-scope="scope">{{ scope.row.materialName }}</template>
  118. </el-table-column>
  119. <el-table-column
  120. prop="specification"
  121. label="规格型号"
  122. align="center"
  123. >
  124. </el-table-column>
  125. </el-table>
  126. </el-row>
  127. </el-row>
  128. </el-col>
  129. </el-row>
  130. <el-row v-if="conditionBoxs.length">
  131. <el-form label-width="120px" :inline="false" size="small">
  132. <el-row>
  133. <el-form-item label="配置比例设置"> </el-form-item>
  134. </el-row>
  135. <el-col :xs="24" :sm="8" :lg="8">
  136. <el-form-item label="限定机型">
  137. <el-input size="small" v-model="limit" :readonly="!id?false:true"></el-input>
  138. </el-form-item>
  139. </el-col>
  140. <el-col
  141. :xs="24"
  142. :sm="8"
  143. :lg="8"
  144. v-for="(len, index) in conditionBoxs.length - 1"
  145. >
  146. <el-form-item :label="'配提' + (index + 1) + '比例'">
  147. <!-- {{index}}-->
  148. <el-input
  149. size="small"
  150. :readonly="!id?false:true"
  151. v-model="popArr['line_' + index]"
  152. ></el-input>
  153. </el-form-item>
  154. </el-col>
  155. </el-form>
  156. <el-col class="text_rihgt" v-if="false">
  157. <el-button type="primary" size="small" @click=""
  158. >添加限定条件</el-button
  159. ></el-col
  160. >
  161. </el-row>
  162. <el-divider></el-divider>
  163. </el-row>
  164. </el-main>
  165. <el-footer height="100px" v-if="!id">
  166. <el-row :gutter="20">
  167. <el-col :xs="24" :sm="12" :lg="12" :offset="0">
  168. <el-button type="primary" size="small" @click="handleSubmit"
  169. >保存</el-button
  170. >
  171. </el-col>
  172. <el-col :xs="24" :sm="12" :lg="12" :offset="0" class="tr">
  173. <el-button type="primary" size="small" @click="hanleAddModel"
  174. >添加</el-button
  175. >
  176. <el-button type="primary" size="small" @click="handleresale">重置</el-button>
  177. </el-col>
  178. </el-row>
  179. </el-footer>
  180. <el-dialog :visible.sync="VisibleModle" width="70%" center>
  181. <div>
  182. <el-container>
  183. <el-header height="">
  184. <el-form label-width="0" :inline="false" size="small">
  185. <el-col :xs="24" :sm="8" :lg="8" :offset="0">
  186. <el-form-item label="">
  187. <el-input
  188. v-model="saleTypeCode"
  189. placeholder="类型编号"
  190. ></el-input>
  191. </el-form-item>
  192. </el-col>
  193. </el-form>
  194. </el-header>
  195. <el-main height="">
  196. <el-row>
  197. <el-row :gutter="50">
  198. <el-col :xs="10" :ms="10" :lg="10">
  199. <el-row>
  200. <el-row> </el-row>
  201. <el-row>
  202. <el-row class="title"> 可选产品列表 </el-row>
  203. <el-table
  204. style="width: 100%"
  205. :data="conditList"
  206. border
  207. height="400"
  208. @select-all="handleSelectionAllChange"
  209. @selection-change="handleSelectionChange"
  210. >
  211. <el-table-column
  212. type="selection"
  213. width="55"
  214. align="center"
  215. >
  216. </el-table-column>
  217. <el-table-column
  218. label="产品编码"
  219. prop="materialNumber"
  220. width="120"
  221. align="center"
  222. >
  223. </el-table-column>
  224. <el-table-column
  225. prop="materialName"
  226. label="产品名称"
  227. align="center"
  228. >
  229. </el-table-column>
  230. <el-table-column
  231. prop="specification"
  232. label="产品型号"
  233. align="center"
  234. >
  235. </el-table-column>
  236. <el-table-column
  237. prop="price"
  238. label="产品价格"
  239. align="center"
  240. >
  241. </el-table-column>
  242. </el-table>
  243. <el-row class="mg">
  244. <div>
  245. <el-pagination
  246. @size-change="handleSizeChange"
  247. @current-change="handleCurrentChange"
  248. :current-page="currentPage"
  249. :page-sizes="[10, 20, 30, 50]"
  250. :page-size="10"
  251. layout="total, sizes, prev, pager, next, jumper"
  252. :total="listTotal"
  253. >
  254. </el-pagination>
  255. </div>
  256. </el-row>
  257. </el-row>
  258. </el-row>
  259. </el-col>
  260. <el-col :xs="4" :ms="4" :lg="4" class="middle">
  261. <el-row :gutter="20" justify="center" align="middle">
  262. <el-row class="btn">
  263. <el-button
  264. type="primary"
  265. size="small "
  266. @click="handleAllAdd"
  267. :disabled="type == 2"
  268. >全部添加</el-button
  269. >
  270. </el-row>
  271. <el-row class="btn">
  272. <el-button
  273. type="primary"
  274. size="small "
  275. @click="handleAdd"
  276. :disabled="type == 2"
  277. >增加</el-button
  278. >
  279. </el-row>
  280. <el-row class="btn">
  281. <el-button
  282. type="primary"
  283. size="small "
  284. @click="handleDelete"
  285. :disabled="type == 1"
  286. >删除</el-button
  287. ></el-row
  288. >
  289. <el-row class="btn"
  290. ><el-button
  291. :disabled="type == 1"
  292. type="primary"
  293. size="small "
  294. @click="handleAllDelete"
  295. >全部删除</el-button
  296. ></el-row
  297. >
  298. </el-row>
  299. </el-col>
  300. <el-col :xs="10" :ms="10" :lg="10">
  301. <el-row>
  302. <el-row> </el-row>
  303. <el-row>
  304. <el-row class="title"> 已选产品列表 </el-row>
  305. <el-table
  306. style="width: 100%"
  307. :data="conditList2"
  308. @select-all="handleSelectionAllChange2"
  309. @selection-change="handleSelectionChange2"
  310. border
  311. height="400"
  312. >
  313. <el-table-column
  314. type="selection"
  315. width="55"
  316. align="center"
  317. >
  318. </el-table-column>
  319. <el-table-column
  320. label="产品编码"
  321. prop="materialNumber"
  322. width="120"
  323. align="center"
  324. >
  325. </el-table-column>
  326. <el-table-column
  327. prop="materialName"
  328. label="产品名称"
  329. align="center"
  330. >
  331. </el-table-column>
  332. <el-table-column
  333. prop="specification"
  334. label="产品型号"
  335. align="center"
  336. >
  337. </el-table-column>
  338. <el-table-column
  339. prop="price"
  340. label="产品价格"
  341. align="center"
  342. >
  343. </el-table-column>
  344. </el-table>
  345. <el-row class="mg">
  346. <!-- <Pagination /> -->
  347. </el-row>
  348. </el-row>
  349. </el-row>
  350. </el-col>
  351. </el-row>
  352. </el-row>
  353. </el-main>
  354. </el-container>
  355. </div>
  356. <span slot="footer" class="dialog-footer">
  357. <el-button @click="VisibleModle = false">取 消</el-button>
  358. <el-button type="primary" @click="handleDiaSubmit">确 定</el-button>
  359. </span>
  360. </el-dialog>
  361. </el-container>
  362. </template>
  363. <script>
  364. import {
  365. getId,
  366. addPoliyCondition,
  367. getConditionMaterialList,
  368. getMaterialList,
  369. getConditionMaterialDetail,
  370. } from "@/api/policy_list";
  371. import TabelTransfer from "./TabelTransfer.vue";
  372. import { mapState } from "vuex";
  373. import AddModel from "./AddModel";
  374. import Minxin from "@/mixin";
  375. export default {
  376. mixins: [Minxin],
  377. props: {
  378. id: {
  379. type: String,
  380. default: "",
  381. },
  382. policyId:{
  383. type:String,
  384. default:""
  385. }
  386. },
  387. data() {
  388. return {
  389. base: {
  390. id: null,
  391. policyConditionMaterials: [
  392. {
  393. id: null,
  394. materialId: "",
  395. materialName: "",
  396. materialNumber: "",
  397. policyConditionId: "",
  398. policyId: "",
  399. policyMaterialId: "",
  400. popType: 0,
  401. specification: "",
  402. walletType: "",
  403. },
  404. ],
  405. policyId: "",
  406. policyName: "",
  407. pop: "",
  408. },
  409. limit: "",
  410. VisibleModle: false,
  411. conditionBox: [[], []],
  412. conditionBoxs: [],
  413. multipleSelection: [],
  414. searchForm: {
  415. code: "",
  416. },
  417. pop: "",
  418. conditList: [],
  419. leftData: [],
  420. rightData: [],
  421. conditList2: [],
  422. type: "",
  423. saleTypeCode: "",
  424. arrIndex: 0,
  425. popArr: {},
  426. };
  427. },
  428. created() {
  429. this.getCommonApi();
  430. },
  431. computed: mapState({
  432. comCode: (state) => state.sales.code,
  433. }),
  434. updated() {},
  435. methods: {
  436. getList() {},
  437. handleBack() {
  438. if (this.$parent.isShow == 10) {
  439. this.$parent.isShow = 8;
  440. } else {
  441. this.$parent.isCondition = 0;
  442. }
  443. },
  444. getCommonApi() {
  445. if (this.id) {
  446. getConditionMaterialDetail({ id: this.policyId }).then((res) => {
  447. this.pop = res.data.pop
  448. let pop = res.data.pop.split(":");
  449. for (let i = 0; i < pop.length; i++) {
  450. if (i == 0) {
  451. this.limit = pop[i];
  452. continue
  453. }
  454. this.$set(this.popArr,`line_${i-1}`,pop[i])
  455. }
  456. console.log(this.popArr);
  457. for (let k = 0; k <pop.length ; k++) {
  458. getConditionMaterialList({
  459. pageNum: 1,
  460. pageSize: -1,
  461. policyConditionId:res.data.id,
  462. popType: k+1,
  463. }).then((res) => {
  464. this.conditionBoxs.push(res.data.records);
  465. });
  466. }
  467. console.log(this.conditionBoxs);
  468. })
  469. }
  470. },
  471. toggleSelection(rows) {
  472. if (rows) {
  473. rows.forEach((row) => {
  474. this.$refs.multipleTable.toggleRowSelection(row);
  475. });
  476. } else {
  477. this.$refs.multipleTable.clearSelection();
  478. }
  479. },
  480. hanleAddModel() {
  481. this.conditionBox.push([{}]);
  482. },
  483. handleSubmit() {
  484. var tableData = [];
  485. for (let i = 0; i < this.conditionBox.length; i++) {
  486. for (let j = 0; j < this.conditionBox[i].length; j++) {
  487. this.conditionBox[i][j].popType = i + 1;
  488. this.conditionBox[i][j].policyId = this.comCode;
  489. this.conditionBox[i][j].id = "";
  490. // this.conditionBox[i][j].policyMaterialId =this.conditionBox[i][j].materialId
  491. }
  492. tableData = [...tableData, ...this.conditionBox[i]];
  493. }
  494. if (!tableData.length) {
  495. this.$errorMsg("请选择机型");
  496. return;
  497. }
  498. var pop = [this.limit];
  499. for (const key in this.popArr) {
  500. pop.push(this.popArr[key]);
  501. }
  502. console.log(pop.join(":"));
  503. const params = {
  504. id: "",
  505. policyConditionMaterials: tableData,
  506. policyId: this.comCode,
  507. policyName: "",
  508. pop: pop.join(":"),
  509. };
  510. addPoliyCondition(params).then((res) => {
  511. this.$successMsg("添加成功");
  512. this.$parent.isCondition = 0;
  513. this.$parent.isFlag = 1;
  514. this.$emit("handleSubmitCon", this.comCode);
  515. });
  516. },
  517. handleSelectionChange(val) {
  518. this.multipleSelection = val;
  519. },
  520. // 筛选全部数据
  521. hanleSelectAll(selection, index) {
  522. this.arrIndex = index;
  523. this.ids = selection.map((k) => {
  524. return k.id;
  525. });
  526. console.log(this.ids);
  527. },
  528. handleDeleteRow(index) {
  529. if (this.arrIndex == index && this.ids.length) {
  530. for (let i = 0; i < this.conditionBox[index].length; i++) {
  531. for (let j = 0; j < this.ids.length; j++) {
  532. if (this.conditionBox[index][i].id == this.ids[j]) {
  533. this.conditionBox[index].splice(i, 1);
  534. }
  535. }
  536. }
  537. }
  538. console.log(index, this.arrIndex);
  539. },
  540. getMaterialLists(index) {
  541. this.arrIndex = index;
  542. getMaterialList({
  543. pageNum: this.currentPage,
  544. pageSize: this.pageSize,
  545. saleTypeCode: this.saleTypeCode,
  546. policyId: this.comCode,
  547. }).then((res) => {
  548. this.conditList = res.data.records;
  549. console.log(4545, this.conditList);
  550. this.listTotal = res.data.total;
  551. });
  552. },
  553. handleSelectionAllChange(e) {
  554. this.leftData = e;
  555. this.type = 1;
  556. },
  557. handleSelectionChange(e) {
  558. this.leftData = e;
  559. this.type = 1;
  560. },
  561. handleSelectionAllChange2(e) {
  562. this.rightData = e;
  563. this.type = 2;
  564. },
  565. handleSelectionChange2(e) {
  566. this.rightData = e;
  567. this.type = 2;
  568. },
  569. handleAllAdd() {
  570. this.conditList2 = this.leftData;
  571. this.leftData = [];
  572. },
  573. handleAllDelete() {
  574. this.conditList2 = [];
  575. },
  576. handleAdd() {
  577. this.conditList2 = this.leftData;
  578. },
  579. handleDelete() {
  580. if (this.type == 2) {
  581. for (let k = 0; k < this.conditList2.length; k++) {
  582. for (let i = 0; i < this.rightData.length; i++) {
  583. if (this.rightData[i].id == this.rightData[k].id) {
  584. this.conditList2.splice(i, 1);
  585. }
  586. }
  587. }
  588. }
  589. },
  590. handleDiaSubmit() {
  591. if (this.conditList2.length) {
  592. for (let i = 0; i < this.conditionBox.length; i++) {
  593. console.log(this.conditionBox[i]);
  594. if (i == this.arrIndex) {
  595. this.$set(this.conditionBox, i, [
  596. ...this.conditList2,
  597. ...this.conditionBox[i],
  598. ]);
  599. console.log(this.conditionBox);
  600. }
  601. }
  602. this.VisibleModle = false;
  603. this.conditList2 = [];
  604. } else {
  605. this.$errorMsg("请选择内容");
  606. }
  607. },
  608. handleresale(){
  609. Object.assign(this.$data, this.$options.data());
  610. }
  611. },
  612. components: {
  613. AddModel,
  614. TabelTransfer,
  615. },
  616. };
  617. </script>
  618. <style lang="scss" scoped>
  619. .line {
  620. margin: 0 20px;
  621. }
  622. .mgb {
  623. margin-bottom: 20px;
  624. }
  625. .pdt {
  626. padding-bottom: 20px;
  627. }
  628. .text_rihgt {
  629. text-align: right;
  630. }
  631. .header {
  632. margin-bottom: 40px;
  633. }
  634. .el-main {
  635. overflow: hidden;
  636. }
  637. .btn {
  638. margin: 20px 0;
  639. text-align: center;
  640. }
  641. .query_btn {
  642. margin-left: 0;
  643. }
  644. .mg {
  645. margin: 20px;
  646. }
  647. .pdt {
  648. margin: 20px 0;
  649. }
  650. .el-main {
  651. overflow: hidden;
  652. }
  653. .middle {
  654. height: 430px;
  655. display: flex;
  656. align-content: center;
  657. justify-content: center;
  658. align-items: center;
  659. }
  660. .title {
  661. padding: 10px 0;
  662. text-align: center;
  663. border-left: 1px solid #ebeef5;
  664. border-right: 1px solid #ebeef5;
  665. border-top: 1px solid #ebeef5;
  666. }
  667. </style>