戴艳蓉 3 years ago
parent
commit
d2a3083fe0

+ 4 - 2
src/apis/service/sheetOrder/project/index.js

@@ -3,7 +3,7 @@ import http from "@/apis/axios";
 const api = "admin/";
 export default {
   // 添加
-  add: (data, params) => http(api + "salezxcreate", data, "post", params),
+  add: (data, params) => http(api + "projectcreate", data, "post", params),
   // 删除
   delete: (data, params) => http(api + "Consultdel", data, "post", params),
   // 分页查询
@@ -14,5 +14,7 @@ export default {
   update: (data, params) => http(api + "update", data, "post", params),
   // 修改状态
   status: (data, params) => http(api + "accountstatus", data, "post", params),
+  // 分类详情
+  catinfo: (data, params) => http(api + "catinfo", data, "post", params),
+
 };
-   

+ 1 - 1
src/components/globalComponents/search-work-company/main.vue

@@ -15,7 +15,7 @@
       :key="item.companyNo + index + ''"
       :label="item.company"
       :value="item.companyNo"
-      :disabled="item.status === '1'"
+      :disabled="item.status === '0'"
     />
   </el-select>
 </template>

+ 2 - 2
src/views/goodStore/active/components/edit-minorder-form.vue

@@ -53,7 +53,7 @@
                 :values="ruleForm.moq_num"
                 :placeholder="'起订量'"
                 :min="0"
-                :max="10000000000"
+                :max="100000000000"
                 :position="'right'"
                 :precision="0"
                 :controls="false"
@@ -67,7 +67,7 @@
                 :values="ruleForm.cost_price"
                 :placeholder="'起订量'"
                 :min="0"
-                :max="10000000000"
+                :max="100000000000"
                 :position="'right'"
                 :precision="2"
                 :controls="false"

+ 1 - 1
src/views/goodStore/active/components/set-active-price-form.vue

@@ -82,7 +82,7 @@
                 :values="ruleForm.activity_price"
                 :placeholder="'活动价'"
                 :min="0"
-                :max="10000000000"
+                :max="100000000000"
                 :position="'right'"
                 :precision="2"
                 :controls="false"

+ 1 - 1
src/views/goodStore/goldPrice/addEdit.vue

@@ -38,7 +38,7 @@
                 :values="ruleForm.price"
                 :placeholder="'最新价格'"
                 :min="0"
-                :max="10000000000"
+                :max="100000000000"
                 :position="'right'"
                 :precision="2"
                 :controls="false"

+ 37 - 13
src/views/goodStore/goodsCost/index.vue

@@ -225,12 +225,7 @@
         >
           <i
             class="el-icon-c-scale-to-original tb-icon"
-            @click="
-              routeGoto('goodsCostDetail', {
-                id: scope.row.spuCode,
-                type: 'editBase',
-              })
-            "
+            @click="wantto(scope.row.spuCode, scope.row.status, '2')"
           ></i>
         </el-tooltip>
         <el-tooltip
@@ -241,12 +236,7 @@
         >
           <i
             class="el-icon-coin tb-icon"
-            @click="
-              routeGoto('goodsCostDetail', {
-                id: scope.row.spuCode,
-                type: 'editCoin',
-              })
-            "
+            @click="wantto(scope.row.spuCode, scope.row.status, '3')"
           ></i>
         </el-tooltip>
         <el-tooltip
@@ -380,6 +370,40 @@ export default {
       };
       this.searchList();
     },
+    wantto(code, ntype, wtype) {
+      if (ntype === "0") {
+        this.$message.warning("新建商品成正在审核中,请审核结束后再修改!");
+        return;
+      }
+      if (ntype === "2") {
+        if (wtype === "2") {
+          this.$message.warning("商品基础信息已修改,请等待审核结果!");
+          return;
+        }
+        if (wtype === "3") {
+          this.$message.warning(
+            "商品基础信息修改流程正在审核中,请审核结束后再修改!"
+          );
+          return;
+        }
+      }
+      if (ntype === "3") {
+        if (wtype === "3") {
+          this.$message.warning("商品成本信息已修改,请等待审核结果!");
+          return;
+        }
+        if (wtype === "2") {
+          this.$message.warning(
+            "商品成信息修改流程正在审核中,请审核结束后再修改!"
+          );
+          return;
+        }
+      }
+      this.routeGoto("goodsCostDetail", {
+        id: code,
+        type: wtype === 2 ? "editBase" : wtype === 3 ? "editCoin" : "",
+      });
+    },
     //商品品牌选择
     async brandidsearchChange(e) {
       const { id, code, label } = e;
@@ -500,7 +524,7 @@ export default {
     },
     //商品分类选择
     async goods_class_change(e) {
-      this.parmValue.cat_id =e
+      this.parmValue.cat_id = e;
       this.pageInfo.curr = 1;
       this.parmValue.page = 1;
       await this.searchList();

+ 3 - 3
src/views/goodStore/goodsOnline/components/costFormAddEdit.vue

@@ -30,7 +30,7 @@
                 :values="ruleForm.min_num"
                 :placeholder="'起订量'"
                 :min="0"
-                :max="10000000000"
+                :max="100000000000"
                 :position="'right'"
                 :precision="0"
                 :controls="false"
@@ -44,7 +44,7 @@
                 :values="ruleForm.sale_price"
                 :placeholder="'售价'"
                 :min="0"
-                :max="10000000000"
+                :max="100000000000"
                 :position="'right'"
                 :precision="2"
                 :controls="false"
@@ -58,7 +58,7 @@
                 :values="ruleForm.market_price"
                 :placeholder="'市场价'"
                 :min="0"
-                :max="10000000000"
+                :max="100000000000"
                 :position="'right'"
                 :precision="2"
                 :controls="false"

+ 4 - 3
src/views/serviceParam/workCompany/index.vue

@@ -286,7 +286,7 @@ export default {
         {
           prop: "companyNo",
           label: "编号",
-          "max-width": "170px",
+          "width": "170px",
         },
 
         {
@@ -296,18 +296,19 @@ export default {
         {
           prop: "status",
           label: "状态",
-          "max-width": "60px",
+          "width": "100px",
           _slot_: "status",
         },
         {
           prop: "creater",
           label: "负责人",
+          width:'100px'
         },
 
         {
           prop: "addtime",
           label: "创建时间",
-          "max-width": "145px",
+          "width": "145px",
         },
         {
           prop: "",

+ 119 - 143
src/views/sheetOrder/project/components/addForm.vue

@@ -60,9 +60,9 @@
             <el-form-item label="项目总预算" prop="budget_total">
               <digital-input
                 :values="ruleForm.budget_total"
-                :placeholder="'起订量'"
+                :placeholder="'项目总预算'"
                 :min="0"
-                :max="10000000000"
+                :max="100000000000"
                 :position="'right'"
                 :precision="2"
                 :size="'mini'"
@@ -99,16 +99,22 @@
           <el-col :span="24">
             <el-form-item label="商品要求" prop="ladder">
               <el-table
-                :data="tableData"
+                :data="ruleForm.ladder"
                 :size="'mini'"
                 border
                 stripe
-                style="width: 100%; margin: 0 0 20px 0"
+                style="width: 100%"
               >
-                <el-table-column label="商品阶梯">
-                  <template slot-scope="scope"> {{ scope.$index }}</template>
+                <el-table-column label="商品阶梯" width="70px">
+                  <template slot-scope="scope">
+                    {{ scope.$index + 1 }}</template
+                  >
+                </el-table-column>
+                <el-table-column prop="good_type" label="商品类型" width="80px">
+                     <template slot-scope="scope">
+                    {{ scope.$index + 1 }}</template
+                  >
                 </el-table-column>
-                <el-table-column prop="good_type" label="商品类型" />
                 <el-table-column prop="good_name" label="商品名称" />
                 <el-table-column prop="good_img" label="商品图片" />
                 <el-table-column prop="cat_id" label="商品分类" />
@@ -193,12 +199,30 @@ export default {
     // },
   },
   data() {
+    const validate_sale_price = (rule, value, callback) => {
+      if (value === "") {
+        callback(new Error("项目总预算不能为空!"));
+      } else if (
+        value === "0" ||
+        value === "0." ||
+        value === "0.0" ||
+        value === "0.00"
+      ) {
+        callback(new Error("项目总预算不能为零!"));
+      } else {
+        callback();
+      }
+    };
     return {
       loading: false,
       tableData: [],
       costshowModel: false,
       costmodelIndex: "",
       costsitem: {},
+         options: [
+        { value: "1", label: "竞品" },
+        { value: "2", label: "竞聘" },
+      ],
       pickerOptions: {
         disabledDate(time) {
           return time.getTime() <= Date.now();
@@ -210,7 +234,7 @@ export default {
         companyNo: "",
         khNo: [],
         customer_name: "",
-        budget_total: "",
+        budget_total: "0",
         arrtime: "",
         use_desc: "",
         ladder: [],
@@ -251,7 +275,7 @@ export default {
         budget_total: [
           {
             required: true,
-            message: "项目总预算",
+            validator: validate_sale_price,
             trigger: "blur",
           },
         ],
@@ -286,11 +310,48 @@ export default {
     this.initForm();
   },
   methods: {
+    //商品要求阶梯修改
+    costrefreshEdit(e) {
+      let item = JSON.parse(JSON.stringify(e));
+      const {
+        index,
+        id,
+        budget_price,
+        num,
+        cat_name,
+        good_img,
+        good_name,
+        good_type,
+        cat_id,
+      } = item;
+      if (index + "" === "-1") {
+        this.ruleForm.ladder.push(item);
+      } else {
+        this.ruleForm.ladder.forEach((i, findex) => {
+          if (i.id === id && findex === parseInt(i.index)) {
+            this.ruleForm.ladder[findex].id = id;
+            this.ruleForm.ladder[findex].budget_price = budget_price;
+            this.ruleForm.ladder[findex].num = num;
+            this.ruleForm.ladder[findex].good_type = good_type;
+            this.ruleForm.ladder[findex].cat_id = JSON.parse(
+              JSON.stringify(cat_id)
+            );
+            this.ruleForm.ladder[findex].cat_name = JSON.parse(
+              JSON.stringify(cat_name)
+            );
+            this.ruleForm.ladder[findex].good_name = good_name;
+            this.ruleForm.ladder[findex].good_img = good_img;
+          }
+        });
+      }
+      this.showModel = false;
+      this.$refs.ruleForm.validateField("ladder");
+    },
     //平台选择
     platform_codesearchChange(e) {
       if (e) {
         const { id, code, label } = e;
-        this.parmValue.platform = id ? [id] : [];
+        this.ruleForm.platform = id ? [id] : [];
         this.$refs.ruleForm.validateField("platform");
       }
     },
@@ -316,53 +377,31 @@ export default {
 
       this.$refs.ruleForm.validateField("khNo");
     },
+    //项目总预算编辑
     budget_total_change(e) {
       this.ruleForm.budget_total = e + "";
       this.$refs.ruleForm.validateField("budget_total");
     },
+    //商品要求阶梯弹窗打开
     openCostEdit(index, sitem) {
       this.costmodelIndex = index;
       this.costsitem = sitem;
       this.costshowModel = true;
     },
-
+    //删除某一商品要求
     openCostEditDelete(index) {
-      this.tableData.splice(index, 1);
-    },
-    showAddrAddEditModalRefresh(e) {
-      const { index, item } = e;
-
-      if (index === -1) {
-        this.addrForm.addrlist.push(JSON.parse(JSON.stringify(item)));
-      } else {
-        const {
-          arrive_time,
-          receipt_quantity,
-          contactor,
-          mobile,
-          addr_code,
-          addr_code_name,
-          addr,
-          id,
-        } = JSON.parse(JSON.stringify(item));
-        this.addrForm.addrlist[index].receipt_quantity = receipt_quantity;
-        this.addrForm.addrlist[index].arrive_time = arrive_time;
-        this.addrForm.addrlist[index].contactor = contactor;
-        this.addrForm.addrlist[index].mobile = mobile;
-        this.addrForm.addrlist[index].addr_code = addr_code;
-        this.addrForm.addrlist[index].addr_code_name = addr_code_name;
-        this.addrForm.addrlist[index].addr = addr;
-        this.addrForm.addrlist[index].id = id;
-      }
-      this.$refs.addrForm.validateField("addrlist");
+      this.ruleForm.ladder.splice(index, 1);
+      this.$refs.ruleForm.validateField("ladder");
     },
+    //初始化整个组件
     async initForm() {
       this.loading = true;
+      this.ruleForm.ladder = [];
       this.rulesThis = this.rules;
       await this.resetForm();
       this.loading = false;
     },
-
+    //初始化整个表单
     async resetForm() {
       // 重置
       await this.$nextTick(() => {
@@ -372,124 +411,61 @@ export default {
           // const { zxNo, class_cat, khname, khNo, cpName, budget_total } =
           //   this.sitem;
           this.ruleForm = {
-            name: "",
+            name: "新项目",
             platform: [],
             companyNo: "",
             khNo: [],
-            budget_total: "",
-            arrtime: "",
-            use_desc: "",
+            budget_total: "100",
+            arrtime: "2022-03-01",
+            use_desc: "111",
             ladder: [],
           };
         }
       });
     },
-    addrRefresh(e) {
-      const { list } = e;
-      this.addrForm.addrlist.push(...list);
-    },
-    openHouseModal(index) {
-      this.AddrAddEditModalIndex = index;
 
-      if (index === -1) {
-        this.AddrAddEditModalSitem = {};
-      } else {
-        this.AddrAddEditModalSitem = JSON.parse(
-          JSON.stringify(this.addrForm.addrlist[index])
-        );
-      }
-      this.showAddrAddEditModal = true;
-
-      // let findex = this.addrForm.addrlist.findIndex((v) => v.edit === true);
-      // if (findex !== -1) {
-      //   this.$message.warning("当前已有地址在编辑,请保存后再试!");
-      //   return;
-      // } else {
-      //   if (index === -1) {
-      //     this.addrForm.addrlist.push({
-      //       edit: true,
-      //       arrive_time: "",
-      //       receipt_quantity: "",
-      //       contactor: "",
-      //       mobile: "",
-      //       addr_code: [],
-      //       addr: "",
-      //     });
-      //   } else {
-      //     this.addrForm.addrlist[index].edit = true;
-      //   }
-      // }
-    },
-    //省市区选择
-    select_area_change(e, index) {
-      this.addrForm.addrlist[index].addr_code = e;
-    },
-    //省市区保存某一行
-    checkRow(rowIndex) {
-      this.$refs.addrForm.validate((valid) => {
-        if (valid) {
-          this.addrForm.addrlist[rowIndex].edit = false;
-        } else {
-          console.log("error submit!!");
-          return false;
-        }
-      });
-    },
-    // 省市区删除行操作
-    deleteRow(index, rows) {
-      rows.splice(index, 1);
-    },
     async submitForm() {
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
           this.loading = true;
-          const { zxNo, khNo, good_num, sendtype, companyNo, goodtype } =
-            JSON.parse(JSON.stringify(this.ruleForm));
-          const { addrlist } = JSON.parse(JSON.stringify(this.addrForm));
-          if (sendtype === "1") {
-            let isok = true,
-              addrT = 0;
-            addrlist.forEach((v) => {
-              addrT += parseInt(v.receipt_quantity);
-              if (v.edit) {
-                isok = false;
-              }
-            });
-            if (!isok) {
-              this.$message.warning("请保存地址信息!");
-              this.loading = false;
-              return;
-            }
-            if (parseInt(good_num) !== addrT) {
-              this.$message.warning(
-                "下单数量,与收货地址信息中的总数量不一致!"
-              );
-              this.loading = false;
-              return;
-            }
+          let model = JSON.parse(JSON.stringify(this.ruleForm));
+          console.log(model);
+          const { budget_total, ladder } = model;
+          let ztotal = Math.floor(budget_total * 100) / 100;
+          model.platform = model.platform.toString();
+          model.khNo = model.khNo.toString();
+          delete model["customer_name"];
+          if (ladder && ladder.length < 2) {
+            this.$message.warning("至少添加两个商品要求!");
+            this.loading = false;
+            return;
           }
-          const model = {
-            zxNo: zxNo || "",
-            khNo: khNo.length === 1 ? khNo[0] : "",
-            good_num: good_num || "",
-            companyNo: companyNo.length > 0 ? companyNo[0] : "",
-            sendtype: sendtype | "",
-            goodtype: goodtype || "",
-            addrlist: [],
-          };
+          let total = 0;
           let list = [];
-          addrlist.forEach((v) => {
-            let xitem = {
-              contactor: v.contactor,
-              mobile: v.mobile,
-              addr: v.addr,
-              addr_code: v.addr_code,
-              receipt_quantity: v.receipt_quantity,
-              arrive_time: v.arrive_time,
-            };
-            list.push(xitem);
+          ladder.forEach((e) => {
+            let item = JSON.parse(JSON.stringify(e));
+            delete item["id"];
+            delete item["index"];
+            delete item["is_del"];
+            delete item["cat_name"];
+            item.cat_id =
+              item.cat_id && item.cat_id.length > 0
+                ? item.cat_id[item.cat_id.length - 1]
+                : "";
+            list.push(item);
+            let a1 = Math.floor(e.budget_price * 100);
+            let a2 = parseInt(e.num);
+            let a3 = (a1 * a2) / 100;
+            total = Math.floor((a3 + total) * 100) / 100;
           });
-          model.addrlist = sendtype === "1" ? list : [];
+          console.log(`项目总预算为${ztotal}---商品要求预算总和为${total}`);
+          if (ztotal < total) {
+            this.$message.warning("项目总预算不能低于所以商品要求预算总和!");
+            this.loading = false;
+            return;
+          }
+          model.ladder = JSON.parse(JSON.stringify(list));
+
           let res = await asyncRequest.add(model);
           this.loading = false;
           if (res && res.code === 0) {
@@ -499,7 +475,7 @@ export default {
             });
             this.showModelThis = false;
             // 刷新
-            this.$emit("refresh");
+            this.$emit("refresh",res.data);
           } else if (res && res.code >= 100 && res.code <= 104) {
             await this.logout();
           } else {

+ 139 - 69
src/views/sheetOrder/project/components/costFormAddEdit.vue

@@ -4,7 +4,7 @@
     :title="title"
     :center="true"
     align="left"
-    top="18vh"
+    top="12vh"
     width="500px"
     :close-on-click-modal="false"
     :visible.sync="showModelThis"
@@ -23,13 +23,41 @@
             :size="'mini'"
             :rules="rulesThis"
             label-width="80px"
-            class="demo-ruleForm"
           >
+            <el-form-item label="预算单价" prop="budget_price">
+              <digital-input
+                :values="ruleForm.budget_price"
+                :placeholder="'预算单价'"
+                :min="0"
+                :max="100000000000"
+                :position="'right'"
+                :precision="2"
+                :size="'mini'"
+                :controls="false"
+                :append="'元'"
+                @reschange="budget_price_change"
+              />
+            </el-form-item>
+            <el-form-item label="购买数量" prop="num">
+              <digital-input
+                :values="ruleForm.num"
+                :placeholder="'购买数量'"
+                :min="0"
+                :max="100000000000"
+                :position="'right'"
+                :precision="0"
+                :size="'mini'"
+                :controls="false"
+                :append="'元'"
+                @reschange="num_change"
+              />
+            </el-form-item>
             <el-form-item label="商品类型" prop="good_type">
               <el-select
                 style="width: 100%"
                 v-model="ruleForm.good_type"
                 placeholder="商品类型"
+                @change="good_type_change"
               >
                 <el-option
                   v-for="item in options"
@@ -40,6 +68,16 @@
                 </el-option>
               </el-select>
             </el-form-item>
+            <el-form-item label="商品分类" prop="cat_id">
+              <good-class
+                :value="ruleForm.cat_id"
+                @handleChange="goods_class_change"
+                :disabled="false"
+                :size="'mini'"
+                :isDetail="false"
+                :placeholder="'商品分类'"
+              />
+            </el-form-item>
             <el-form-item label="商品名称" prop="good_name">
               <el-input
                 placeholder="商品名称"
@@ -57,7 +95,7 @@
                 />
                 <el-link
                   :underline="false"
-                  @click="deleteUrl('2')"
+                  @click="deleteUrl()"
                   type="warning"
                   style="margin: 0 0 0 16px"
                   >删除</el-link
@@ -83,45 +121,6 @@
                 </div>
               </div>
             </el-form-item>
-
-            <el-form-item label="商品分类" prop="cat_id">
-              <good-class
-                :value="ruleform.cat_id"
-                @handleChange="goods_class_change"
-                :disabled="false"
-                :size="'mini'"
-                :isDetail="false"
-                :placeholder="'分类'"
-              />
-            </el-form-item>
-            <el-form-item label="预算单价" prop="budget_price">
-              <digital-input
-                :values="ruleForm.budget_price"
-                :placeholder="'预算单价'"
-                :min="0"
-                :max="10000000000"
-                :position="'right'"
-                :precision="2"
-                :size="'mini'"
-                :controls="false"
-                :append="'元'"
-                @reschange="budget_price_change"
-              />
-            </el-form-item>
-            <el-form-item label="购买数量" prop="num">
-              <digital-input
-                :values="ruleForm.num"
-                :placeholder="'购买数量'"
-                :min="0"
-                :max="10000000000"
-                :position="'right'"
-                :precision="2"
-                :size="'mini'"
-                :controls="false"
-                :append="'元'"
-                @reschange="num_change"
-              />
-            </el-form-item>
           </el-form>
         </el-col>
         <el-col :span="24" style="text-align: right">
@@ -138,34 +137,76 @@
 </template>
 <script>
 import resToken from "@/mixins/resToken";
+import asyncRequest from "@/apis/service/sheetOrder/project";
 export default {
   name: "brand",
   props: ["showModel", "index", "sitem"],
   mixins: [resToken],
   data() {
+    const validate_min_num = (rule, value, callback) => {
+      if (value === "") {
+        callback(new Error("购买数量不能为空!"));
+      } else if (value === "0") {
+        callback(new Error("购买数量不能为零!"));
+      } else {
+        callback();
+      }
+    };
+    const validate_sale_price = (rule, value, callback) => {
+      if (value === "") {
+        callback(new Error("预算单价不能为空!"));
+      } else if (
+        value === "0" ||
+        value === "0." ||
+        value === "0.0" ||
+        value === "0.00"
+      ) {
+        callback(new Error("预算单价不能为零!"));
+      } else {
+        callback();
+      }
+    };
     return {
       loading: false,
       title: "",
       options: [
-        { value: "1", name: "竞品" },
-        { value: "2", name: "竞聘" },
+        { value: "1", label: "竞品" },
+        { value: "2", label: "竞聘" },
       ],
       showModelThis: this.showModel,
-      ruleForm: {},
+      ruleForm: {
+        id: "",
+        index: -1,
+        good_type: "1",
+        good_name: "",
+        good_img: "",
+        cat_id: [],
+        budget_price: "",
+        num: "",
+      },
       rulesThis: this.rules,
       rules: {
-        min_num: [
-          { required: true, message: "起订量应为合法数字", trigger: "blur" },
+        good_type: [
+          { required: true, message: "请选择商品类型", trigger: "change" },
         ],
-        cost_fee: [
-          { required: true, message: "工艺费应为合法数字", trigger: "blur" },
+        good_name: [
+          { required: false, message: "商品名称不能为空", trigger: "blur" },
         ],
-        nake_fee: [
-          { required: true, message: "商品合计应为合法数字", trigger: "blur" },
+        good_img: [
+          { required: false, message: "商品图片不能为空", trigger: "change" },
         ],
-        delivery_fee: [
-          { required: true, message: "其中运费应为合法数字", trigger: "blur" },
+        cat_id: [
+          {
+            type: "array",
+            required: true,
+            message: "请选择商品分类",
+            trigger: "change",
+          },
         ],
+        budget_price: [
+          { required: true, validator: validate_sale_price, trigger: "blur" },
+        ],
+        num: [{ required: true, validator: validate_min_num, trigger: "blur" }],
       },
     };
   },
@@ -185,7 +226,7 @@ export default {
   methods: {
     async initForm() {
       this.loading = true;
-      await this.resetFormData();
+
       this.rulesThis = this.rules;
       console.log(this.index);
       if (this.index + "" === "-1") {
@@ -193,14 +234,25 @@ export default {
       } else {
         this.title = "修改商品阶梯";
       }
-
       await this.resetForm();
       this.loading = false;
     },
     //商品分类选择
-    async goods_class_change(e) {
-      this.ruleform.cat_id = e;
-      this.$refs.ruleform.validatefield("cat_id");
+    goods_class_change(e) {
+      this.ruleForm.cat_id = e;
+      this.$refs.ruleForm.validateField("cat_id");
+    },
+    deleteUrl() {
+      this.ruleForm.good_img = "";
+      this.$refs.ruleForm.validateField("good_img");
+    },
+    good_type_change() {
+      const { good_type } = this.ruleForm;
+      if (good_type === "1") {
+        this.rulesThis.cat_id[0].required = true;
+      } else {
+        this.rulesThis.cat_id[0].required = false;
+      }
     },
     //图片上传成功
     async UploadSuccessEventproof_url(data) {
@@ -208,8 +260,8 @@ export default {
       if (url === "noToken") {
         await this.logout();
       } else {
-        this.ruleform.good_img = url;
-        this.$refs.ruleform.validatefield("good_img");
+        this.ruleForm.good_img = url;
+        this.$refs.ruleForm.validateField("good_img");
         this.$message.success("图片上传成功!");
       }
     },
@@ -217,7 +269,7 @@ export default {
     //图片上传失败
     UploadErrorEventproof_url(res) {
       if (res !== "break") {
-        this.$refs.ruleform.validatefield("good_img");
+        this.$refs.ruleForm.validatefield("good_img");
         this.$message.error("图片上传失败!");
       }
     },
@@ -261,25 +313,43 @@ export default {
       });
     },
     async resetFormData() {
-      const { id, min_num, cost_fee, nake_fee, delivery_fee, cat_id } =
+      const { id, cat_id, good_type, good_name, good_img, budget_price, num } =
         this.sitem;
       this.ruleForm = {
         id: id || "",
         index: this.index,
-        good_type: good_type || "",
-        cat_id: cat_id || [],
-        cost_fee: cost_fee || "",
-        nake_fee: nake_fee || "",
-        delivery_fee: delivery_fee || "",
+        good_type: good_type || "1",
+        good_name: good_name || "",
+        good_img: good_img || "",
+        cat_id: cat_id ? [cat_id] : [],
+        budget_price: budget_price || "0.00",
+        num: num || "0",
       };
+      this.good_type_change();
     },
 
     async submitForm() {
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
+          this.loading = true;
+          let model = JSON.parse(JSON.stringify(this.ruleForm));
+          const { cat_id } = model;
+          let cat_id_name = "";
+          let length = cat_id.length;
+          for (let i = 0; i < length; i++) {
+            const { code, data, message } = await asyncRequest.catinfo({id:cat_id[i]});
+            if (code === 0) {
+              const { cat_name } = data;
+              cat_id_name += i === 0 ? cat_name : `/${cat_name}`;
+            } else if (code >= 100 && code <= 104) {
+              await this.logout();
+            } else {
+              this.$message.warning(message);
+            }
+          }
+          model.cat_name = cat_id_name;
           this.showModelThis = false;
-          // 刷新
-          this.$emit("refresh", this.ruleForm);
+          this.$emit("refresh", model);
         } else {
           console.log("error submit!!");
           return false;

+ 6 - 5
src/views/sheetOrder/project/detail.vue

@@ -7,7 +7,7 @@
     >
       <el-tabs v-model="projectTabs">
         <el-tab-pane label="新建项目" name="0" v-if="queryType === 'add'">
-          <add-form/>
+          <add-form @refresh="refresh" />
         </el-tab-pane>
         <el-tab-pane label="项目详情" name="1" v-if="queryType !== 'add'">
           <el-collapse v-model="projectNames" style="margin: -18px 0 0 0">
@@ -159,18 +159,19 @@ export default {
     handleClick(row) {
       console.log(row);
     },
-    refresh(e) {
-      const { spuCode } = e;
+    async refresh(e) {
+      const { projectNo } = e;
       let model = {
-        id: this.queryType === "add" ? spuCode : this.queryId,
+        id: this.queryType === "add" ? projectNo : this.queryId,
         type: "view",
       };
       this.routeReGoto("projectDetail", model);
+      await this.initForm();
     },
     async initData() {
       this.loading = true;
       const { code, message, data } = await asyncRequest.detail({
-        activity_code: this.queryId,
+        projectNo: this.queryId,
       });
       this.loading = false;
       if (code === 0) {