戴艳蓉 hace 3 años
padre
commit
3318114dc4

+ 2 - 2
src/apis/components/search-metal-kind.js

@@ -3,7 +3,7 @@ const api = "admin/";
 export default {
   // 列表
   list: (data, params) => http(api + "goldlinst", data, "post", params),
-  //  // 获取仓库  供应商仓/自建仓
-  //  warequery: (data, params) => http(api + "warequery", data, "post", params),
+   // 获取当前金价
+   get_price: (data, params) => http(api + "golpricelast", data, "post", params),
 };
    

+ 19 - 5
src/components/globalComponents/search-metal-kind/main.vue

@@ -68,8 +68,8 @@ export default {
     };
   },
   watch: {
-    value:  function (val, old) {
-      console.log('111'+val);
+    value: function (val, old) {
+      console.log("111" + val);
       this.valuess = val;
     },
   },
@@ -86,7 +86,21 @@ export default {
           id: this.options[index].type,
           code: this.options[index].type,
           label: this.options[index].type_cn,
+          price: "0",
         };
+        const { code, data, message } = await asyncRequest.get_price({
+          type: this.options[index].type,
+        });
+        if (code === 0 && data && data[0]) {
+          let sitem = data[0];
+          const { price } = sitem;
+          model.price = price;
+        } else if (code >= 100 && code <= 104) {
+          await this.logout();
+        } else {
+          this.$message.warning(message);
+          return;
+        }
         this.$emit("searchChange", model);
       } else {
         this.$emit("searchChange", {});
@@ -98,9 +112,9 @@ export default {
       const { code, data, message } = await asyncRequest.list(this.formValue);
       if (code === 0) {
         this.options = data;
-        this.options.forEach(e=>{
-          e.type+=""
-        })
+        this.options.forEach((e) => {
+          e.type += "";
+        });
       } else if (code >= 100 && code <= 104) {
         await this.logout();
       } else {

+ 1 - 0
src/components/globalComponents/search-sort/main.vue

@@ -93,6 +93,7 @@ export default {
             code: this.options[index].id,
             label: this.options[index].search,
             cat_desc: this.options[index].cat_desc,
+            item:this.options[index].item,
           };
           this.$emit("searchChange", model);
         } else {

+ 2 - 3
src/views/goodStore/goodsCost/components/baseFormAddEdit.vue

@@ -135,7 +135,7 @@ export default {
       this.loading = true;
       this.resetFormData();
       this.rulesThis = this.rules;
-      if (this.index === "0") {
+      if (this.index + "" === "-1") {
         this.title = "添加商品规格值";
       } else {
         this.title = "修改商品规格值";
@@ -228,9 +228,8 @@ export default {
     async submitForm() {
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
-          this.loading = true;
+          this.showModelThis = false;
           this.$emit("refresh", this.ruleForm);
-          this.loading = false;
         } else {
           console.log("error submit!!");
           return false;

+ 21 - 12
src/views/goodStore/sort/addEditRate.vue

@@ -25,21 +25,16 @@
             label-width="110px"
             class="demo-ruleForm"
           >
-            <el-form-item label="上级分类" prop="pid">
-              <el-input
-                v-model="ruleForm.pid"
-                placeholder="上级分类"
-                minlength="20"
-                disabled
-              />
-            </el-form-item>
             <el-form-item label="分类名称" prop="cat_name">
               <el-input
                 v-model="ruleForm.cat_name"
                 disabled
                 placeholder="分类名称"
                 minlength="20"
-              />
+                ><template slot="prepend" v-if="pid_name">{{
+                  pid_name
+                }}</template></el-input
+              >
             </el-form-item>
             <el-form-item label="科目代码" prop="fund_code">
               <el-input
@@ -128,7 +123,7 @@ import asyncRequest from "@/apis/service/goodStore/sort";
 import resToken from "@/mixins/resToken";
 export default {
   name: "sort",
-  props: ["showModel", "id", "sitem"],
+  props: ["showModel", "id", "sitem", "titleList"],
   mixins: [resToken],
   data() {
     const validate_order_rate = (rule, value, callback) => {
@@ -162,6 +157,7 @@ export default {
     return {
       loading: false,
       showModelThis: this.showModel,
+      pid_name: "",
       ruleForm: {
         id: "",
         cat_name: "",
@@ -201,6 +197,10 @@ export default {
   methods: {
     async initForm() {
       this.loading = true;
+      this.pid_name = "";
+      this.titleList.forEach((e, i) => {
+        this.pid_name += i !== 0 ? `${e.titleName}/` : "";
+      });
       this.rulesThis = this.rules;
       await this.resetForm();
       await this.initData();
@@ -257,12 +257,21 @@ export default {
       const res = await asyncRequest.detail({ id: this.sitem.id });
       if (res && res.code === 0 && res.data) {
         console.log(res.data);
-        const { pid, id, cat_name, order_rate, sale_rate, lower_rate, rate } =
-          res.data;
+        const {
+          pid,
+          id,
+          cat_name,
+          order_rate,
+          sale_rate,
+          lower_rate,
+          rate,
+          fund_code,
+        } = res.data;
         this.ruleForm = {
           pid: pid || "",
           id: id || "",
           cat_name: cat_name || "",
+          fund_code: fund_code || "",
           order_rate: order_rate || "0",
           sale_rate: sale_rate || "0",
           lower_rate: lower_rate || "0",

+ 1 - 0
src/views/goodStore/sort/index.vue

@@ -220,6 +220,7 @@
       :id="modelRateId"
       :show-model="showRateModel"
       :sitem="sitemRate"
+      :titleList="titleList"
       @refresh="searchList"
       @cancel="showRateModel = false"
     />

+ 135 - 22
src/views/sellOut/zixunOrder/components/addEditForm.vue

@@ -119,7 +119,7 @@
         </el-form-item>
       </el-col>
 
-      <el-col :span="16" v-if="ruleForm.is_project === '1'">
+      <el-col :span="8" v-if="ruleForm.is_project === '1'">
         <el-form-item label="项目用途" class="clear" required>
           <el-input
             placeholder="项目用途"
@@ -129,6 +129,22 @@
           />
         </el-form-item>
       </el-col>
+      <el-col :span="8" v-if="ruleForm.is_project === '1'">
+        <el-form-item
+          label="项目咨询截止时间"
+          class="clear"
+          required
+          label-width="140px"
+        >
+          <el-input
+            placeholder="项目咨询截止时间"
+            v-model="ruleForm.pendtime"
+            disabled
+            maxlength="500"
+          />
+        </el-form-item>
+      </el-col>
+
       <el-col :span="8" v-if="ruleForm.is_project === '1'">
         <el-form-item label="要求到货时间" class="clear" required>
           <el-input
@@ -412,6 +428,7 @@ export default {
         customer_name: "", //客户名称
         companyNo: "",
         endtime: "", //咨询截止时间
+        pendtime: "", //咨询截止时间
         platform_code: [], //平台id
         use_desc: "",
         budget_total: "",
@@ -595,13 +612,13 @@ export default {
           } = this.sitem;
 
           this.ruleForm = {
-            is_project: is_project || "1", //咨询类型 1销售2咨询,
-            projectNo: projectNo ? [projectNo] : ["PROeh2e220301162721"], //项目编号
-            khNo: khNo ? [khNo] : ["KH202104272344"], //客户编号
-            customer_name: customer_name || "泰康人寿湖北分公司F1部", //客户名称
-            companyNo: companyNo || "GSjdi0220222190516",
-            endtime: endtime || "2022-03-10 00:00:00", //咨询截止时间
-            platform_code: platform_code ? [platform_code] : ["8"], //平台id
+            is_project: is_project || "0", //咨询类型 1项目 0 非项目
+            projectNo: projectNo ? [projectNo] : [], //项目编号
+            khNo: khNo ? [khNo] : [], //客户编号
+            customer_name: customer_name || "", //客户名称
+            companyNo: companyNo || "",
+            endtime: endtime || "", //咨询截止时间
+            platform_code: platform_code ? [platform_code] : [], //平台id
             use_desc: "",
             budget_total: "",
             arrtime: "",
@@ -620,24 +637,64 @@ export default {
       console.log(this.ruleForm);
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
-          this.loading = true;
+          // this.loading = true;
           if (this.tableData.length === 0) {
             this.$message.warning("至少提供一条商品要求!");
             this.loading = false;
             return;
           }
           let model = JSON.parse(JSON.stringify(this.ruleForm));
+          const { pendtime, is_project, endtime } = model;
+          if (
+            is_project === "1" &&
+            new Date(endtime).getTime() > new Date(pendtime).getTime()
+          ) {
+            this.$message.warning("咨询截止时间不能晚于项目咨询截止时间!");
+            this.loading = false;
+            return;
+          }
           model.khNo = model.khNo.toString();
           model.platform_code = model.platform_code.toString();
           model.projectNo = model.projectNo.toString();
-          model.ladder = JSON.parse(JSON.stringify(this.tableData));
-          model.ladder.forEach((e) => {
-            e.brand_id = e.brand_id.toString();
-            e.unit = e.unit.toString();
-            e.cat_id = e.cat_id[e.cat_id.length - 1];
-            e.config = e.config.toString();
+          model.ladder = [];
+          let list = JSON.parse(JSON.stringify(this.tableData));
+          list.forEach((e) => {
+            let im = {
+              good_name: e.good_name,
+              good_img: e.good_img,
+              cat_id: e.cat_id[e.cat_id.length - 1],
+              unit: e.unit.toString(),
+              brand_id: e.brand_id.toString(),
+              arrival_time: e.arrival_time,
+              cost_desc: e.cost_desc,
+              is_addrs: e.is_addrs,
+              is_custom: e.is_custom,
+              metal_id: e.metal_id,
+              config: e.config.toString(),
+              other_config: e.other_config,
+              specs_weight: e.specs_weight,
+              gold_price: e.gold_price,
+              budget_price: e.budget_price,
+              num: e.num,
+              use_desc: e.use_desc,
+              remark: e.remark,
+              pgNo: e.pgNo,
+              total_weight: e.total_weight,
+              is_gold_price: e.is_gold_price,
+              speclist: [],
+            };
+            e.speclist.forEach((a) => {
+              let am = {
+                id: a.id,
+                spec_id: a.spec_id,
+                spec_value_id: a.spec_value_id,
+              };
+              im.speclist.push(am);
+            });
           });
+          model.ladder.push(im);
           console.log(model);
+          return;
           const res = await asyncRequest.add(model);
           this.loading = false;
           if (res && res.code === 0) {
@@ -657,6 +714,47 @@ export default {
         }
       });
     },
+    // //获取规格值
+    // setResData() {
+    //   let list = JSON.parse(JSON.stringify(this.spec_tableData));
+    //   let oldlist = JSON.parse(JSON.stringify(this.old_spec_tableData));
+    //   let hasIDlist = [];
+    //   list.forEach((a) => {
+    //     if (a.id !== "") {
+    //       hasIDlist.push(a);
+    //     }
+    //   });
+    //   let newList = [];
+    //   let resList = [];
+    //   oldlist.forEach((a, ai) => {
+    //     let item = null;
+    //     let index = hasIDlist.findIndex((b) => a.id === b.id);
+    //     if (index === -1) {
+    //       item = JSON.parse(JSON.stringify(a));
+    //       item.is_del = "1";
+    //     } else {
+    //       item = JSON.parse(JSON.stringify(hasIDlist[index]));
+    //     }
+    //     newList.push(item);
+    //   });
+    //   list.forEach((b) => {
+    //     if (b.id === "") {
+    //       b.is_del = "0";
+    //       newList.push(b);
+    //     }
+    //   });
+    //   newList.forEach((a) => {
+    //     let m = {
+    //       id: a.id,
+    //       spec_id: a.spec_id,
+    //       spec_value_id: a.spec_value_id,
+    //       is_del: a.is_del || "0",
+    //     };
+    //     resList.push(m);
+    //   });
+
+    //   return resList;
+    // },
     //项目选择
     async selectChange(e) {
       const key = e && e.length > 0 ? e[0] : "";
@@ -665,10 +763,11 @@ export default {
           projectNo: key,
         });
         if (code === 0) {
-          const { use_desc, budget_total, ladder, arrtime } = data;
+          const { use_desc, budget_total, ladder, arrtime, endtime } = data;
           this.ruleForm.use_desc = use_desc || "";
           this.ruleForm.budget_total = budget_total || "";
           this.ruleForm.arrtime = arrtime || "";
+          this.ruleForm.pendtime = endtime || "";
           this.ptableData = ladder;
           this.ptableData.forEach((e) => {
             e.cat_name = "";
@@ -679,6 +778,7 @@ export default {
               });
             }
           });
+          this.tableData == [];
         } else if (code >= 100 && code <= 104) {
           await this.logout();
         } else {
@@ -687,12 +787,14 @@ export default {
           this.ruleForm.use_desc = "";
           this.ruleForm.budget_total = "";
           this.ruleForm.arrtime = "";
+          this.tableData == [];
         }
       } else {
         this.ptableData = [];
         this.ruleForm.use_desc = "";
         this.ruleForm.budget_total = "";
         this.ruleForm.arrtime = "";
+        this.tableData = [];
       }
     },
     async remoteMethod(query) {
@@ -746,11 +848,16 @@ export default {
     },
     //平台选择
     platform_code_codesearchChange(e) {
-      if (e) {
-        const { id, code, label } = e;
-        this.ruleForm.platform_code = id ? [id] : [];
-        this.$refs.ruleForm.validateField("platform_code");
-      }
+      const { id, code, label } = e;
+      this.ruleForm.platform_code = id ? [id] : [];
+      this.$refs.ruleForm.validateField("platform_code");
+      this.ruleForm.projectNo = [];
+      this.ruleForm.budget_total = "0";
+      this.ruleForm.use_desc = "";
+      this.ruleForm.pendtime = "";
+      this.ruleForm.arrtime = "";
+      this.ptableData = [];
+      this.tableData = [];
     },
     //销售方公司选择
     company_idsearchChange(e) {
@@ -769,8 +876,14 @@ export default {
         this.ruleForm.khNo = [];
         this.ruleForm.customer_name = "";
       }
-
       this.$refs.ruleForm.validateField("khNo");
+      this.ruleForm.projectNo = [];
+      this.ruleForm.budget_total = "0";
+      this.ruleForm.use_desc = "";
+      this.ruleForm.pendtime = "";
+      this.ruleForm.arrtime = "";
+      this.ptableData = [];
+      this.tableData = [];
     },
   },
 };

+ 230 - 191
src/views/sellOut/zixunOrder/components/addEditGoodModal.vue

@@ -12,6 +12,7 @@
     element-loading-spinner="el-icon-loading"
     element-loading-background="rgba(0, 0, 0, 0.8)"
     @close="showModelThis = false"
+    append-to-body
   >
     <el-card style="margin: -20px 0 0 0">
       <el-row :gutter="10">
@@ -70,7 +71,7 @@
                     :disabled="ruleForm.p_budget_price"
                     :controls="false"
                     :append="'元'"
-                    @reschange="budget_price_change"
+                    @reschange="num_change($event, 'budget_price')"
                   />
                 </el-form-item>
               </el-col>
@@ -87,7 +88,7 @@
                     :disabled="ruleForm.p_num"
                     :controls="false"
                     :append="''"
-                    @reschange="num_change"
+                    @reschange="num_change($event, 'num')"
                   />
                 </el-form-item>
               </el-col>
@@ -134,7 +135,7 @@
                     :controls="false"
                     :size="'mini'"
                     :append="'g'"
-                    @reschange="total_weight_change"
+                    @reschange="num_change($event, 'total_weight')"
                   />
                 </el-form-item>
               </el-col>
@@ -142,7 +143,6 @@
                 <el-form-item label="单位" prop="unit" label-width="60px">
                   <search-unit
                     :value="ruleForm.unit"
-                    :disabled="id == '007'"
                     :size="'mini'"
                     :isDetail="unit_name !== ''"
                     :names="unit_name"
@@ -168,7 +168,7 @@
                 <el-form-item label="商品名称" prop="good_name">
                   <el-input
                     v-model="ruleForm.good_name"
-                    :disabled="ruleForm.p_good_name"
+                    :disabled="false"
                     placeholder="商品名称"
                     maxlength="100"
                   />
@@ -178,7 +178,6 @@
                 <el-form-item label="工艺说明" prop="cost_desc">
                   <el-input
                     v-model="ruleForm.cost_desc"
-                    :disabled="id == '007'"
                     placeholder="工艺说明"
                     maxlength="500"
                   />
@@ -186,7 +185,6 @@
                 <el-form-item label="产品用途" prop="use_desc">
                   <el-input
                     v-model="ruleForm.use_desc"
-                    :disabled="id == '007'"
                     placeholder="产品用途"
                     maxlength="500"
                   />
@@ -194,25 +192,22 @@
                 <el-form-item label="商品备注" prop="remark">
                   <el-input
                     v-model="ruleForm.remark"
-                    :disabled="id == '007'"
                     placeholder="商品备注"
                     maxlength="500"
                   />
                 </el-form-item>
               </el-col>
-              <el-col :span="12" style="padding 0 0 0 12px">
+              <el-col :span="12" style="padding: 0 0 0 15px">
                 <el-table
                   :data="spec_tableData"
                   :size="'mini'"
                   border
                   style="width: 100%"
+                  height="120px"
                 >
                   <el-table-column prop="spec_value" label="规格类型" />
                   <el-table-column prop="spec_value_value" label="规格值" />
-                  <el-table-column
-                    fixed="right"
-                    v-if="type === 'add' || type === 'editBase'"
-                  >
+                  <el-table-column fixed="right" width="88px">
                     <template slot="header" slot-scope="scope">
                       <span>操作</span>
                       <el-tooltip
@@ -229,159 +224,168 @@
                       </el-tooltip>
                     </template>
                     <template slot-scope="scope">
-                      <el-button
-                        @click="openEdit(scope.$index, scope.row)"
-                        type="text"
-                        size="small"
-                        >修改</el-button
-                      >
-                      <el-button
-                        type="text"
-                        size="small"
-                        @click="openDelete(scope.$index)"
-                        >移除</el-button
-                      >
+                      <el-tooltip effect="dark" content="修改" placement="top">
+                        <i
+                          class="el-icon-edit tb-icon"
+                          @click="openEdit(scope.$index, scope.row)"
+                        ></i>
+                      </el-tooltip>
+                      <el-tooltip effect="dark" content="删除" placement="top">
+                        <i
+                          class="el-icon-delete tb-icon"
+                          @click="openDelete(scope.$index)"
+                        ></i>
+                      </el-tooltip>
                     </template>
                   </el-table-column>
                 </el-table>
                 <!-- 弹窗 新增/修改 -->
                 <base-form-add-edit
                   :index="modelIndex"
-                  :show-model="showModel"
-                  :sitem="sitem"
+                  :show-model="showOtherModel"
+                  :sitem="modelSitem"
                   @refresh="refreshEdit"
-                  @cancel="showModel = false"
+                  @cancel="showOtherModel = false"
                 />
               </el-col>
-              <el-col :span="8" v-if="is_noble">
-                <el-form-item label="启用金价" prop="is_gold_price">
-                  <el-select
-                    v-model="ruleForm.is_gold_price"
-                    placeholder="启用金价"
-                    style="width: 100%"
-                  >
-                    <el-option
-                      v-for="item in is_gold_price_options"
-                      :key="item.value"
-                      :label="item.label"
-                      :value="item.value"
-                    >
-                    </el-option>
-                  </el-select>
-                </el-form-item>
-              </el-col>
-
-              <el-col :span="16" v-if="is_noble">
-                <el-form-item label="配置要求" prop="config">
-                  <el-select
-                    v-model="ruleForm.config"
-                    multiple
-                    style="width: 100%"
-                    placeholder="配置要求"
-                  >
-                    <el-option
-                      v-for="(item, index) in config_options"
-                      :key="item + index"
-                      :label="item"
-                      :value="item"
-                    >
-                    </el-option>
-                  </el-select>
-                </el-form-item>
-              </el-col>
-
-              <el-col :span="8" v-if="is_noble">
-                <el-form-item label="金属克重" prop="specs_weight">
-                  <digital-input
-                    :values="ruleForm.specs_weight"
-                    :placeholder="'金属克重'"
-                    :min="0"
-                    :max="100000000000"
-                    :position="'right'"
-                    :precision="3"
-                    :controls="false"
-                    :size="'mini'"
-                    :append="'g'"
-                    @reschange="specs_weight_change"
-                  />
-                </el-form-item>
-              </el-col>
-
-              <el-col :span="16" v-if="is_noble">
-                <el-form-item label="其他要求" prop="other_config">
-                  <el-input
-                    v-model="ruleForm.other_config"
-                    :disabled="id == '007'"
-                    placeholder="其他要求"
-                    maxlength="20"
-                  />
-                </el-form-item>
+              <el-col :span="24" v-if="is_noble">
+                <el-row>
+                  <el-col :span="12" v-if="is_noble">
+                    <el-form-item label="配置要求" prop="config">
+                      <el-select
+                        v-model="ruleForm.config"
+                        multiple
+                        style="width: 100%"
+                        placeholder="配置要求"
+                      >
+                        <el-option
+                          v-for="(item, index) in config_options"
+                          :key="item + index"
+                          :label="item"
+                          :value="item"
+                        >
+                        </el-option>
+                      </el-select>
+                    </el-form-item>
+                  </el-col>
+                  <el-col :span="6" v-if="is_noble">
+                    <el-form-item label="金属克重" prop="specs_weight">
+                      <digital-input
+                        :values="ruleForm.specs_weight"
+                        :placeholder="'金属克重'"
+                        :min="0"
+                        :max="100000000000"
+                        :position="'right'"
+                        :precision="3"
+                        :controls="false"
+                        :size="'mini'"
+                        :append="'g'"
+                        @reschange="num_change($event, 'specs_weight')"
+                      />
+                    </el-form-item>
+                  </el-col>
+                  <el-col :span="6">
+                    <el-form-item label="启用金价" prop="is_gold_price">
+                      <el-select
+                        v-model="ruleForm.is_gold_price"
+                        placeholder="启用金价"
+                        style="width: 100%"
+                      >
+                        <el-option
+                          v-for="item in is_gold_price_options"
+                          :key="item.value"
+                          :label="item.label"
+                          :value="item.value"
+                        >
+                        </el-option>
+                      </el-select>
+                    </el-form-item>
+                  </el-col>
+                </el-row>
               </el-col>
 
               <el-col :span="24" style="text-align: right">
-                <el-col :span="8">
-                  <el-form-item
-                    label="商品图片"
-                    prop="good_img"
-                    :disabled="id == '007'"
-                    class="activity-upload"
-                  >
-                    <div class="btnupload" style="position: relative">
-                      <img
-                        v-if="ruleForm.good_img"
-                        :src="ruleForm.good_img"
-                        class="avatar"
+                <el-row>
+                  <el-col :span="8" class="clear">
+                    <el-form-item
+                      label="商品图片"
+                      prop="good_img"
+                      class="activity-upload"
+                    >
+                      <div class="btnupload" style="position: relative">
+                        <img
+                          v-if="ruleForm.good_img"
+                          :src="ruleForm.good_img"
+                          class="avatar"
+                        />
+                        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+                        <file-upload
+                          class="Upload"
+                          :disabled="false"
+                          :accept="'.jpg,.png,.jpeg'"
+                          :multiple="true"
+                          :uploadcondition="beforeAvatarUpload"
+                          @UploadErrorEvent="UploadErrorEvent"
+                          @UploadSuccessEvent="UploadSuccessEvent"
+                        ></file-upload>
+                      </div>
+                      <div class="txt-tips fl">
+                        <p>小于1Mb</p>
+                      </div>
+                    </el-form-item>
+                  </el-col>
+                  <el-col :span="8" v-if="is_noble">
+                    <el-form-item label="金属种类" prop="metal_id">
+                      <search-metal-kind
+                        :value="ruleForm.metal_id"
+                        :size="'mini'"
+                        :isDetail="type !== 'add'"
+                        :placeholder="'贵金属种类'"
+                        @searchChange="noble_metalsearchChange"
                       />
-                      <i v-else class="el-icon-plus avatar-uploader-icon"></i>
-                      <file-upload
-                        class="Upload"
-                        :disabled="ruleForm.p_good_img"
-                        :accept="'.jpg,.png,.jpeg'"
-                        :multiple="true"
-                        :uploadcondition="beforeAvatarUpload"
-                        @UploadErrorEvent="UploadErrorEvent"
-                        @UploadSuccessEvent="UploadSuccessEvent"
-                      ></file-upload>
-                    </div>
-                    <div class="txt-tips fl">
-                      <p>小于1Mb</p>
-                    </div>
-                  </el-form-item>
-                </el-col>
-                <el-col :span="8" v-if="is_noble">
-                  <el-form-item label="金属种类" prop="metal_id">
-                    <el-input
-                      v-model="ruleForm.metal_id"
-                      :disabled="id == '007'"
-                      placeholder="金属种类"
-                      maxlength="20"
-                    />
-                  </el-form-item>
-                  <el-form-item
-                    label="当前金价"
-                    prop="gold_price"
-                    style="margin: 0 0 0 0"
-                  >
-                    <el-input
-                      v-model="ruleForm.gold_price"
-                      disabled
-                      placeholder="当前金价"
-                      maxlength="500"
-                    />
-                  </el-form-item>
-                </el-col>
-                <el-col>
-                  <el-button
-                    v-if="id !== '007'"
-                    type="primary"
-                    :size="'mini'"
-                    @click="submitForm"
-                    >保 存
-                  </el-button>
-                  <el-button :size="'mini'" @click="showModelThis = false">{{
-                    id == "007" ? "关 闭" : "取 消"
-                  }}</el-button>
-                </el-col>
+                    </el-form-item>
+                    <el-form-item
+                      v-if="ruleForm.is_gold_price === '1'"
+                      label="当前金价"
+                      prop="gold_price"
+                      style="margin: 0 0 0 0"
+                    >
+                      <el-input
+                        v-model="ruleForm.gold_price"
+                        disabled
+                        placeholder="当前金价"
+                        maxlength="500"
+                      />
+                    </el-form-item>
+                  </el-col>
+                  <el-col :span="8" class="fr tr">
+                    <el-form-item
+                      label="其他配置要求"
+                      prop="other_config"
+                      label-width="120px"
+                      v-if="is_noble"
+                    >
+                      <el-input
+                        v-model="ruleForm.other_config"
+                        type="textarea"
+                        :rows="2"
+                        placeholder="其他要求"
+                        maxlength="200"
+                      />
+                    </el-form-item>
+
+                    <el-button
+                      v-if="id !== '007'"
+                      type="primary"
+                      :size="'mini'"
+                      @click="submitForm"
+                      >保 存
+                    </el-button>
+                    <el-button :size="'mini'" @click="showModelThis = false">{{
+                      id == "007" ? "关 闭" : "取 消"
+                    }}</el-button>
+                  </el-col>
+                </el-row>
               </el-col>
             </el-row>
           </el-form>
@@ -393,12 +397,19 @@
 <script>
 import resToken from "@/mixins/resToken";
 import { rules } from "../columns";
+import baseFormAddEdit from "./baseFormAddEdit";
 export default {
   name: "brand",
   props: ["showModel", "id", "sitem"],
   mixins: [resToken],
+  components: {
+    baseFormAddEdit,
+  },
   data() {
     return {
+      modelIndex: "",
+      modelSitem: {},
+      showOtherModel: false,
       spec_tableData: [],
       old_spec_tableData: [],
       loading: false,
@@ -445,7 +456,7 @@ export default {
         unit: [],
         good_img: "",
         good_name: "",
-        total_weight: "0",
+        total_weight: "0.000",
         is_addrs: "",
         is_custom: "",
         is_gold_price: "",
@@ -456,7 +467,7 @@ export default {
         use_desc: "",
         remark: "",
         metal_id: "",
-        gold_price: "",
+        gold_price: "0",
       },
       unit_name: "",
       rulesThis: this.rules,
@@ -493,12 +504,38 @@ export default {
     },
     openEdit(index, sitem) {
       this.modelIndex = index;
-      this.sitem = sitem;
-      this.showModel = true;
+      this.modelSitem = sitem;
+      this.showOtherModel = true;
     },
     openDelete(index) {
       this.spec_tableData.splice(index, 1);
     },
+    //规格编辑修改结果
+    refreshEdit(e) {
+      let item = JSON.parse(JSON.stringify(e));
+      const {
+        index,
+        id,
+        spec_id,
+        spec_value,
+        spec_value_id,
+        spec_value_value,
+      } = item;
+      if (index + "" === "-1") {
+        this.spec_tableData.push(item);
+      } else {
+        this.spec_tableData.forEach((i, findex) => {
+          if (i.spec_id === spec_id) {
+            this.spec_tableData[findex].id = id;
+            this.spec_tableData[findex].spec_id = spec_id;
+            this.spec_tableData[findex].spec_value = spec_value;
+            this.spec_tableData[findex].spec_value_id = spec_value_id;
+            this.spec_tableData[findex].spec_value_value = spec_value_value;
+          }
+        });
+      }
+      this.showOtherModel = false;
+    },
     async resetForm() {
       this.spec_tableData = [];
       this.old_spec_tableData = [];
@@ -544,10 +581,17 @@ export default {
             p_arrtime,
           } = this.sitem;
           this.unit_name = unit_name || "";
-          console.log(fi, p_pgNo);
+          console.log(p_cat_info);
+          let asd = [];
+          if (p_cat_info && p_cat_info.length > 0) {
+            p_cat_info.forEach((sd) => {
+              asd.push(sd.id);
+            });
+          }
           this.ruleForm = {
             p_cat_info: p_cat_info,
             p_cat_id: p_cat_id,
+            p_cat_arr_id: asd,
             p_budget_price: p_budget_price,
             p_pgNo: p_pgNo,
             p_num: p_num,
@@ -562,7 +606,8 @@ export default {
               fi === "-1" && p_pgNo ? p_budget_price : budget_price || "0.00",
             num: fi === "-1" && p_pgNo ? p_num : num || "0",
             brand_id: brand_id ? [brand_id] : [],
-            cat_id: fi === "-1" && p_pgNo ? p_cat_id : cat_id ? cat_id : [],
+            cat_id: [],
+            cat_arr_id: [],
             good_img: fi === "-1" && p_pgNo ? p_good_img : good_img || "",
             good_name: fi === "-1" && p_pgNo ? p_good_name : good_name || "",
             total_weight: total_weight || "0",
@@ -576,7 +621,7 @@ export default {
             use_desc: use_desc || "",
             remark: remark || "",
             metal_id: metal_id || "",
-            gold_price: gold_price || "",
+            gold_price: gold_price || "0",
             unit: unit ? [unit] : [],
           };
         }
@@ -584,59 +629,53 @@ export default {
     },
     //商品分类选择
     async goods_class_change(e) {
-      const { code, pid, id, label } = e;
+      console.log(e);
+      const { code, pid, id, label, item } = e;
       this.ruleForm.cat_id = id ? [id] : [];
+      this.ruleForm.cat_arr_id = item;
       this.$refs.ruleForm.validateField("cat_id");
       this.is_noble = pid === "6";
     },
 
     //单位选择
     unitsearchChange(e) {
-      const { id, code, label } = e;
-      if (id) {
-        this.ruleForm.unit = [code];
-      } else {
-        this.ruleForm.unit = [];
-      }
+      const { code } = e;
+      this.ruleForm.unit = code ? [code] : [];
       this.$refs.ruleForm.validateField("unit");
     },
-    //预算单价
-    budget_price_change(e) {
-      this.ruleForm.budget_price = e + "";
-      this.$refs.ruleForm.validateField("budget_price");
-    },
     //购买数量
-    num_change(e) {
-      this.ruleForm.num = e + "";
-      this.$refs.ruleForm.validateField("num");
+    num_change(e, key) {
+      this.ruleForm[key] = e + "";
+      this.$refs.ruleForm.validateField(key);
     },
     //品牌选择
     brand_id_searchChange(e) {
-      const { id, code, label } = e;
-      if (id) {
-        this.ruleForm.brand_id = [id];
-      } else {
-        this.ruleForm.brand_id = [];
-      }
+      const { id } = e;
+      this.ruleForm.brand_id = id ? [id] : [];
       this.$refs.ruleForm.validateField("brand_id");
     },
-    //商品总重量
-    total_weight_change(e) {
-      this.ruleForm.total_weight = e + "";
-      this.$refs.ruleForm.validateField("total_weight");
-    },
-    //金属克重
-    specs_weight_change(e) {
-      this.ruleForm.specs_weight = e + "";
-      this.$refs.ruleForm.validateField("specs_weight");
+    //贵金属种类选择
+    noble_metalsearchChange(e) {
+      const { id, price } = e;
+      this.ruleForm.metal_id = id ? id : "";
+      this.$refs.ruleForm.validateField("noble_metal");
+      this.ruleForm.gold_price = price ? price : "0";
+      this.$refs.ruleForm.validateField("gold_price");
     },
     async submitForm() {
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
           this.loading = true;
           let model = JSON.parse(JSON.stringify(this.ruleForm));
+          const { total_weight, specs_weight, p_cat_info } = model;
+          if (total_weight * 1000 < specs_weight * 1000) {
+            this.$message.warning("商品总重量不能小于贵金属重量!");
+            this.loading = false;
+            return;
+          }
           model.index = this.findex;
-
+          model.speclist = JSON.parse(JSON.stringify(this.spec_tableData));
+          this.loading = false;
           this.showModelThis = false;
           // 刷新
           this.$emit("refresh", model);

+ 253 - 0
src/views/sellOut/zixunOrder/components/baseFormAddEdit.vue

@@ -0,0 +1,253 @@
+<template>
+  <el-dialog
+    v-loading="loading"
+    :title="title"
+    :center="true"
+    align="left"
+    top="18vh"
+    width="570px"
+    :close-on-click-modal="false"
+    :visible.sync="showModelThis"
+    element-loading-text="拼命加载中"
+    element-loading-spinner="el-icon-loading"
+    element-loading-background="rgba(0, 0, 0, 0.8)"
+    @close="showModelThis = false"
+    append-to-body
+  >
+    <el-card style="margin: -20px 0 0 0">
+      <el-row :gutter="10">
+        <el-col :span="24">
+          <el-form
+            ref="ruleForm"
+            :model="ruleForm"
+            status-icon
+            :size="'small'"
+            :rules="rulesThis"
+            label-width="80px"
+            class="demo-ruleForm"
+          >
+            <el-form-item label="规格类型" prop="spec_id">
+              <search-spec
+                :value="ruleForm.spec_id"
+                :disabled="false"
+                :size="'mini'"
+                :isDetail="false"
+                :placeholder="'规格类型'"
+                @searchChange="spec_idsearchChange"
+              />
+            </el-form-item>
+            <el-form-item label="规格值" prop="spec_value_id">
+              <div v-if="specVlist.length > 0">
+                <el-radio-group
+                  v-model="ruleForm.spec_value_id"
+                  @change="spec_value_id_change"
+                >
+                  <el-radio
+                    v-for="item in specVlist"
+                    :key="item.id + item.spec_value"
+                    :label="item.id"
+                    >{{ item.spec_value }}</el-radio
+                  >
+                </el-radio-group>
+              </div>
+              <div class="no-data" v-else>暂无规格值,请添加!</div>
+            </el-form-item>
+          </el-form>
+        </el-col>
+        <el-col :span="24" style="text-align: right">
+          <el-input
+            style="width: 209px"
+            v-model="sinput"
+            class="fl"
+            :disabled="id == 'edit'"
+            :size="'small'"
+            placeholder="规格值名称,如红色"
+            maxlength="20"
+          />
+          <el-button
+            style="margin: 0 0 0 10px"
+            icon="el-icon-plus"
+            :size="'small'"
+            @click="add_spec"
+            class="fl"
+            >新增规格值</el-button
+          >
+          <el-button
+            v-if="id !== 'edit'"
+            :size="'small'"
+            type="primary"
+            @click="submitForm"
+            >保 存
+          </el-button>
+          <el-button @click="showModelThis = false" :size="'small'">{{
+            id == "edit" ? "关 闭" : "取 消"
+          }}</el-button>
+        </el-col>
+      </el-row>
+    </el-card>
+  </el-dialog>
+</template>
+<script>
+import asyncRequest from "@/apis/service/goodStore/goodsCost";
+import resToken from "@/mixins/resToken";
+export default {
+  name: "brand",
+  props: ["showModel", "index", "sitem"],
+  mixins: [resToken],
+  data() {
+    return {
+      loading: false,
+      title: "商品规格",
+      sinput: "",
+      showModelThis: this.showModel,
+      specVlist: [],
+      ruleForm: {},
+      rulesThis: this.rules,
+
+      rules: {
+        spec_id: [
+          {
+            required: true,
+            message: "规格类型不能为空",
+            trigger: "change",
+          },
+        ],
+        spec_value_id: [
+          { required: true, message: "请选择规格值", trigger: "change" },
+        ],
+      },
+    };
+  },
+  watch: {
+    showModel: function (val) {
+      this.showModelThis = val;
+      if (val) {
+        this.initForm();
+      }
+    },
+    showModelThis(val) {
+      if (!val) {
+        this.$emit("cancel");
+      }
+    },
+  },
+  methods: {
+    async initForm() {
+      this.loading = true;
+      this.resetFormData();
+      this.rulesThis = this.rules;
+      if (this.index + "" === "-1") {
+        this.title = "添加商品规格值";
+      } else {
+        this.title = "修改商品规格值";
+      }
+      await this.resetForm();
+      this.loading = false;
+    },
+    async resetForm() {
+      // 重置
+      await this.$nextTick(() => {
+        if (this.$refs.ruleForm) {
+          this.$refs.ruleForm.resetFields();
+          this.$refs.ruleForm.clearValidate();
+          this.resetFormData();
+        }
+      });
+    },
+    resetFormData() {
+      this.specVlist = [];
+      const { id, spec_id, spec_value, spec_value_id, spec_value_value } =
+        this.sitem;
+      this.ruleForm = {
+        index: this.index,
+        id: id || "",
+        spec_id: spec_id || "",
+        spec_value: spec_value || "",
+        spec_value_id: spec_value_id || "",
+        spec_value_value: spec_value_value || "",
+      };
+    },
+    async add_spec() {
+      const { spec_id } = this.ruleForm;
+      if (spec_id) {
+        if (this.sinput) {
+          const { code, data, message } = await asyncRequest.valueadd({
+            spec_id: spec_id,
+            spec_value: this.sinput,
+          });
+          if (code === 0) {
+            await this.getlist();
+          } else if (code >= 100 && code <= 104) {
+            await this.logout();
+          } else {
+            this.$message.warning(message);
+          }
+        } else {
+          this.$message.warning("请输入规格值!");
+        }
+      } else {
+        this.$message.warning("请选择规格类型!");
+      }
+    },
+    async spec_idsearchChange(e) {
+      const { id, spec_name } = e;
+      this.ruleForm.spec_id = id || "";
+      this.ruleForm.spec_value = spec_name || "";
+      this.$refs.ruleForm.validateField("spec_id");
+      await this.getlist();
+    },
+    spec_value_id_change(e) {
+      if (e) {
+        const { id, spec_value } = this.specVlist.find((i) => i.id === e);
+        this.ruleForm.spec_value_id = id || "";
+        this.ruleForm.spec_value_value = spec_value || "";
+      } else {
+        this.ruleForm.spec_value_id = "";
+        this.ruleForm.spec_value_value = "";
+      }
+      this.$refs.ruleForm.validateField("spec_value_id");
+    },
+    async getlist() {
+      const { spec_id } = this.ruleForm;
+      if (spec_id) {
+        const { code, data, message } = await asyncRequest.valueall({
+          spec_id: spec_id,
+        });
+        if (code === 0) {
+          this.specVlist = data;
+        } else if (code >= 100 && code <= 104) {
+          await this.logout();
+        } else {
+          this.$message.warning(message);
+        }
+      } else {
+        this.specVlist = [];
+      }
+    },
+
+    async submitForm() {
+      await this.$refs.ruleForm.validate(async (valid) => {
+        if (valid) {
+          this.showModelThis = false;
+          this.$emit("refresh", this.ruleForm);
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+    },
+  },
+};
+</script>
+
+   <style lang="scss" scoped>
+.goodsCostAdd {
+  .no-data {
+    text-align: center;
+    line-height: 32px;
+    color: #8492a6;
+    // border: 1px solid #ccc;
+    border-radius: 6px;
+  }
+}
+</style>