戴艳蓉 há 3 anos atrás
pai
commit
ff42d5b6bb

+ 3 - 1
src/apis/service/sellOut/project/index.js

@@ -28,5 +28,7 @@ export default {
   // 删除已添加的线上商品
   project_online_good_del: (data, params) => http(api + "projectfeeddel", data, "post", params),
   // 制作方案
-  project_make_plan: (data, params) => http(api + "projectfeeddel", data, "post", params),
+  project_make_plan: (data, params) => http(api + "plancreate", data, "post", params),
+  // 查询方案列表
+  pget_project_plan: (data, params) => http(api + "projectplan", data, "post", params),
 };

+ 282 - 35
src/views/sellOut/project/components/setPlan.vue

@@ -50,7 +50,7 @@
           </el-table>
         </template>
       </div>
-      <div class="project-setPlan-title">客户反馈商品情况</div>
+      <div class="project-setPlan-title">客户意向商品</div>
       <div class="project-setPlan-backGood-table">
         <el-table
           :data="tableData"
@@ -60,6 +60,152 @@
           ref="multipleTable"
           style="width: 100%"
           @selection-change="handleSelectionChange"
+        >
+          <el-table-column
+            type="selection"
+            width="40"
+            v-if="table_type === 'add'"
+          >
+          </el-table-column>
+          <el-table-column
+            prop="pgNo"
+            label="要求编码"
+            width="180px"
+            show-overflow-tooltip
+          />
+          <el-table-column
+            prop="sale_price"
+            label="销售单价"
+            width="110"
+            show-overflow-tooltip
+          />
+          <el-table-column
+            prop="num"
+            label="购买数量"
+            width="110"
+            show-overflow-tooltip
+          />
+          <el-table-column
+            prop="good_img"
+            label="图片"
+            width="50"
+            show-overflow-tooltip
+          >
+            <template slot-scope="scope">
+              <div
+                v-if="scope.row.good_img"
+                style="width: 20px; height: 20px"
+                class="hover"
+                v-viewer
+              >
+                <img
+                  :src="scope.row.good_img"
+                  style="display: inline-block; width: 100%; height: 100%"
+                  alt=""
+                />
+              </div>
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="good_name"
+            label="商品名称"
+            show-overflow-tooltip
+          />
+          <el-table-column
+            prop="class_cat"
+            label="商品分类"
+            show-overflow-tooltip
+          />
+          <el-table-column prop="model" label="规格" show-overflow-tooltip />
+          <el-table-column
+            prop="expiry_day"
+            label="信息有效期"
+            width="85"
+            show-overflow-tooltip
+          />
+          <el-table-column
+            prop="work_day"
+            label="制作工期"
+            width="85"
+            show-overflow-tooltip
+          />
+          <el-table-column
+            prop="delivery_day"
+            label="物流时间"
+            width="85"
+            show-overflow-tooltip
+          />
+        </el-table>
+      </div>
+      <div class="project-setPlan-title">
+        方案制定
+        <el-button-group
+          :size="'mini'"
+          class="fr"
+          v-if="table_type === 'list'"
+          style="margin: 8px 0 0 0"
+        >
+          <el-button
+            class="fr"
+            type="primary"
+            :size="'mini'"
+            v-if="index !== 0 && total !== 0"
+            icon="el-icon-arrow-left"
+            @click="index--, change_plan()"
+          ></el-button>
+          <el-button
+            type="primary"
+            class="fr"
+            v-if="total !== 0"
+            :size="'mini'"
+            style="height: 29px"
+            >方案共{{ index + 1 }}/{{ total }}</el-button
+          >
+          <el-button
+            type="primary"
+            class="fr"
+            v-if="index + 1 !== total && total !== 0"
+            @click="index++, change_plan()"
+            :size="'mini'"
+            ><i class="el-icon-arrow-right el-icon--right" :size="'mini'"></i
+          ></el-button>
+          <el-button
+            type="primary"
+            class="fr"
+            @click="add_plan"
+            icon="el-icon-circle-plus-outline"
+            :size="'mini'"
+            >添加方案
+          </el-button>
+        </el-button-group>
+        <el-button-group
+          :size="'mini'"
+          class="fr"
+          v-else-if="table_type === 'add'"
+          style="margin: 8px 0 0 0"
+        >
+          <el-button
+            class="fr"
+            type="primary"
+            :size="'mini'"
+            icon="el-icon-arrow-left"
+            @click="back_list"
+            >返回列表</el-button
+          >
+          <el-button type="primary" class="fr" @click="save_plan" :size="'mini'"
+            >保存方案<i class="el-icon-upload el-icon--right"></i>
+          </el-button>
+        </el-button-group>
+      </div>
+      <div class="project-setPlan-backGood-table">
+        <el-table
+          :data="plan_tableData"
+          :size="'mini'"
+          border
+          stripe
+          ref="multipleTable"
+          style="width: 100%"
+          @selection-change="handleSelectionChange"
         >
           <el-table-column
             prop="pgNo"
@@ -73,6 +219,26 @@
             width="110"
             show-overflow-tooltip
           />
+          <el-table-column
+            prop="sale_price"
+            label="销售单价"
+            width="110"
+            show-overflow-tooltip
+          >
+            <template slot-scope="scope">
+              <digital-input
+                :values="scope.row.sale_price"
+                :placeholder="'起订量'"
+                :min="0"
+                :max="100000000000"
+                :position="'right'"
+                :precision="0"
+                :controls="false"
+                :append="''"
+                @reschange="moq_num_change($event, scope.$index)"
+              />
+            </template>
+          </el-table-column>
           <el-table-column
             prop="num"
             label="购买数量"
@@ -160,7 +326,11 @@ export default {
       showModel: false,
       searchItem: {},
       loading: false,
+      allPlanList: [],
       ladder: [],
+      index: 0,
+      total: 0,
+      table_type: "list",
       //   allList: [],
       projectNo: "",
       statusOptions: [
@@ -176,6 +346,7 @@ export default {
       columns: columnsForm,
       tableData: [],
       multipleSelection: [],
+      plan_tableData: [],
     };
   },
   mounted() {
@@ -198,6 +369,16 @@ export default {
       this.tableData = [];
       await this.searchList();
     },
+    back_list() {
+      this.table_type = "list";
+    },
+    add_plan() {
+      this.table_type = "add";
+    },
+    moq_num_change(e, index) {
+      this.plan_tableData[index].sale_pricee = e + "";
+      this.$set(this.plan_tableData, index, this.plan_tableData[index]);
+    },
     //初始化整个组件
     async initListData() {
       console.log(this.sitem);
@@ -205,7 +386,7 @@ export default {
       this.projectNo = projectNo;
       this.ladder = JSON.parse(JSON.stringify(ladder));
       this.pageInfo = {
-        size: 15,
+        size: 100,
         curr: 1,
         total: 0,
       };
@@ -214,42 +395,18 @@ export default {
     },
     handleSelectionChange(val) {
       this.multipleSelection = val;
-      let list = JSON.parse(JSON.stringify(val));
-      let isok = true;
-      list.forEach((a) => {
-        let findex = list.findIndex((b) => b.pgNo === a.pgNo && a.id !== b.id);
-        if (findex !== -1) {
-          isok = false;
+      let list = JSON.parse(JSON.stringify(this.plan_tableData));
+      this.plan_tableData = [];
+      this.multipleSelection.forEach((a, i) => {
+        let fi = list.findIndex((b) => a.id === b.id && b.pgNo === a.pgNo);
+        if (fi !== -1) {
+          this.plan_tableData.push(list[fi]);
+        } else {
+          this.plan_tableData.push(this.multipleSelection[i]);
         }
       });
-      if (!isok) {
-        this.$message.warning("一种商品要求只能选择一种商品!");
-        this.multipleSelection =[];
-        return;
-      }
-
-    //   this.ladder.forEach(a=>{
-    //       let to=0
-    //      list.forEach((b) => {
-    //          if(a.pgNo === a.pgNo){
-
-    //          }
-    //      }) 
-    //   })
-
-     
-    },
-    //页数选择
-    async handlePageChange(e) {
-      this.pageInfo.curr = e;
-      await this.searchList();
-    },
-    //页面条数选择
-    async handleSizeChange(e) {
-      this.pageInfo.curr = 1;
-      this.pageInfo.size = e;
-      await this.searchList();
     },
+
     async searchList() {
       const { size, curr } = this.pageInfo;
       this.loading = true;
@@ -285,6 +442,96 @@ export default {
       }
       this.loading = false;
     },
+    //保存方案
+    async save_plan() {
+      if (!this.loading) {
+        let list = JSON.parse(JSON.stringify(this.plan_tableData));
+        let isok = true;
+        list.forEach((a) => {
+          let findex = list.findIndex(
+            (b) => b.pgNo === a.pgNo && a.id !== b.id
+          );
+          if (findex !== -1) {
+            isok = false;
+          }
+        });
+        if (!isok) {
+          this.$message.warning("一种商品要求只能选择一种商品!");
+          return;
+        }
+        let isall = true;
+        this.ladder.forEach((a) => {
+          let to = 0;
+          list.forEach((b) => {
+            if (a.pgNo === b.pgNo) {
+              to++;
+            }
+          });
+          if (to !== 1) {
+            isall = false;
+          }
+        });
+        if (!isall) {
+          this.$message.warning("方案必须涵盖全部商品要求!");
+          return;
+        }
+        this.loading = true;
+        let model = {
+          feedback: [],
+          projectNo: this.projectNo,
+        };
+
+        this.plan_tableData.forEach((e) => {
+          let si = {
+            id: e.id,
+            plan_Price: "0",
+          };
+          model.push(si);
+        });
+        const { code, data } = await asyncRequest.project_make_plan(model);
+        if (code === 0) {
+        } else if (code >= 100 && code <= 104) {
+          await this.logout();
+        } else {
+          this.$message.warning(res.message);
+        }
+        this.loading = false;
+      }
+    },
+    //获取全部方案
+    async get_plan(type) {
+      if (!this.loading) {
+        this.loading = true;
+        let model = {
+          projectNo: this.projectNo,
+        };
+        const { code, data } = await asyncRequest.pget_project_plan(model);
+        if (code === 0) {
+          const { plan } = data;
+          this.allPlanList = JSON.parse(JSON.stringify(plan));
+          this.total = this.allPlanList.length;
+          if (type) {
+            await this.change_plan("1");
+          }
+        } else if (code >= 100 && code <= 104) {
+          await this.logout();
+        } else {
+          this.$message.warning(res.message);
+        }
+        this.loading = false;
+      }
+    },
+    //切换当前展示的方案
+    async change_plan(type) {
+      this.table_type = "list";
+      if (type) {
+        this.index = 0;
+      }
+
+      this.plan_tableData = JSON.parse(
+        JSON.stringify(this.allPlanList[this.index])
+      );
+    },
   },
 };
 </script>