zhangjinxing 3 years ago
parent
commit
64aa8d7a0e

+ 55 - 67
src/views/stock/stockWarning/addEdit.vue

@@ -27,6 +27,7 @@
             <el-form-item label="供应商名称" prop="supplier_code">
               <search-supplier
                 :value="ruleForm.supplier_code"
+                :disabled="true"
                 :placeholder="'请选择供应商'"
                 @searchChange="selectSupplier"
               />
@@ -42,7 +43,7 @@
               />
             </el-form-item>
             <el-form-item label="商品名称" prop="good_name">
-              <el-input v-model="ruleForm.good_name"></el-input>
+              <el-input v-model="ruleForm.good_name" disabled></el-input>
             </el-form-item>
             <el-form-item label="预警数量" prop="warn_num">
               <el-input v-model="ruleForm.warn_num"></el-input>
@@ -58,6 +59,7 @@
           }}</el-button>
         </el-col>
       </el-row>
+      <!-- {{ sitem }}供应商公司编码+仓库编码 -->
     </el-card>
   </el-dialog>
 </template>
@@ -70,8 +72,9 @@ export default {
   mixins: [resToken],
   data() {
     return {
-      input: "",
-      select: "1",
+      title: "库存预警修改",
+      input: "", //二合一搜索框输入
+      select: "1", //二合一搜索框下拉
       companyCode: "", //选择公司
       loading: false,
       showModelThis: this.showModel,
@@ -79,7 +82,8 @@ export default {
         supplier_code: [], //供应商名称
         stock_code: [], //仓库名称
         good_name: "", //产品名称
-        warn_num: "", //预警数量
+        warn_num_low: "", //预警数量下限
+        warn_num_up: "", //预警数量上限
       },
       rulesThis: this.rules,
       rules: {
@@ -118,7 +122,6 @@ export default {
   },
   watch: {
     showModel: function (val) {
-      console.log(this.row);
       this.showModelThis = val;
       if (val) {
         this.initForm();
@@ -129,88 +132,73 @@ export default {
         this.$emit("cancel");
       }
     },
+    sitem(val) {
+      // 缺少供应商名称和仓库名称
+      let { good_name, warn_stock } = val;
+      console.log(val);
+      this.ruleForm.good_name = good_name;
+      this.ruleForm.warn_num = warn_stock;
+    },
   },
   methods: {
+    // 关闭弹窗
     closeModel() {
       console.log("closeModel!!");
     },
     async initForm() {
       this.loading = true;
       // await this.getRole();
-      if (this.id === "add") {
-        this.title = "库存预警修改";
-        this.rulesThis = this.rules;
-        await this.resetForm();
-      } else {
-        if (this.isDetail) {
-          this.title = "库存详情";
-          this.rulesThis = {};
-        } else {
-          this.rulesThis = this.rules;
-        }
-        // await this.initData()
-      }
+      // if (this.id === "add") {
+      //   this.title = "库存预警修改";
+      //   this.rulesThis = this.rules;
+      //   // await this.resetForm();
+      // } else {
+      //   if (this.isDetail) {
+      //     this.title = "库存详情";
+      //     this.rulesThis = {};
+      //   } else {
+      //     this.rulesThis = this.rules;
+      //   }
+      //   // await this.initData()
+      // }
       this.title = "库存预警修改";
       this.rulesThis = this.rules;
-      // await this.resetForm(this.sitem);
       this.loading = false;
     },
-    async initData() {
-      const res = await asyncRequest.detail({ id: this.id });
-      if (res && res.code === 0 && res.data) {
-        this.ruleForm = res.data;
-        this.ruleForm.role_id = this.ruleForm.role;
-      } else if (res && res.code >= 100 && res.code <= 104) {
-        await this.logout();
-      } else {
-        this.$message.warning(res.message);
-      }
-    },
+    // 重置
     async resetForm() {
-      // 重置
-      await this.$nextTick(() => {
-        if (this.$refs.ruleForm) {
-          this.$refs.ruleForm.resetFields();
-          this.$refs.ruleForm.clearValidate();
-          this.ruleForm = {
-            stock_code: [],
-            supplier_code: [],
-            good_name: "", //产品名称
-            warn_num: "", //预警数量
-          };
-          if (this.id === "add" || this.isDetail) {
-            // this.rules.username[0].required = false;
-            console.log("当前是add或者 this.isDetail是true");
-          }
-        }
-      });
+      // await this.$nextTick(() => {
+      //   if (this.$refs.ruleForm) {
+      //     this.$refs.ruleForm.resetFields();
+      //     this.$refs.ruleForm.clearValidate();
+      //     this.ruleForm = {
+      //       stock_code: [],
+      //       supplier_code: [],
+      //       good_name: "", //产品名称
+      //       warn_num: "", //预警数量
+      //     };
+      //   }
+      // });
     },
-    // if
+    // 提交库存预警量修改
     async submitForm() {
-      console.log(this.id);
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
           this.loading = true;
-          console.log(this.ruleForm);
-          // const { name, mobile, email, role_id, status } = JSON.parse(
-          //   JSON.stringify(this.ruleForm)
-          // );
+          // console.log(this.ruleForm);
           const model = {
-            id: this.id,
-            // username: username || "", // 账号
-            // nickname: name || "", // 真实姓名
-            // mobile: mobile || "",
-            // email: email || "",
-            // role: role_id || "",
-            // status: status || "",
+            // 使用供应商编码+公司编码
+            warn_stock: this.ruleForm.warn_num,
           };
-          let res = {};
-          if (this.id === "add") {
-            delete model["id"];
-            res = await asyncRequest.add(model);
-          } else {
-            res = await asyncRequest.update(model);
-          }
+          // console.log(model);
+          const res = await asyncRequest.update(model);
+          // let res = {};
+          // if (this.id === "add") {
+          //   delete model["id"];
+          //   res = await asyncRequest.add(model);
+          // } else {
+          //   res = await asyncRequest.update(model);
+          // }
           this.loading = false;
           if (res && res.code === 0) {
             const title = this.id === "add" ? "添加成功" : "修改成功";

+ 10 - 19
src/views/stock/stockWarning/colums.js

@@ -4,11 +4,6 @@ export default [
           label: "产品编码",
           width:"150"
         },
-        {
-          prop: "gys_code",
-          label: "供应商编码",
-          width:"150"
-        },
         {
           prop: "brand",
           label: "品牌",
@@ -17,16 +12,12 @@ export default [
         {
           prop: "good_name",
           label: "产品名称",
+          width:"100"
         },
         {
           prop: "attribute",
           label: "产品型号",
         },
-        {
-          prop: "bstatus",
-          label: "状态",
-          width:"60"
-        },
         {
           prop: "good_desc",
           label: "工艺说明",
@@ -39,6 +30,14 @@ export default [
           prop: "good_type",
           label: "产品类型",
         },
+        {
+          prop: "usable_stock",
+          label: "可用库存",
+        },
+        {
+          prop: "usable_stock", //暂时无这个字段
+          label: "预警库存",
+        },
         {
           prop: "unit",
           label: "单位",
@@ -56,19 +55,11 @@ export default [
           prop: "specs",
           label: "规格",
         },
-        {
-          prop: "is_main",
-          label: "是否主推",
-        },
-        
         {
           prop: "addtime",
           label: "添加时间",
         },
-        {
-          prop: "usable_stock",
-          label: "可用库存",
-        },
+        
         {
           prop: "",
           label: "操作",

+ 165 - 88
src/views/stock/stockWarning/index.vue

@@ -28,61 +28,37 @@
           <div style="width: 100%" class="min">
             <el-row style="padding: 0 0 0 80px">
               <el-col :span="24">
-                <!-- 库存量/仓库搜索二合一 -->
-                <el-col :span="18" style="width: 500px; padding: 0">
-                  <el-input
-                    placeholder="关键字"
-                    v-model="input"
+                <!-- 供应商选择 -->
+                <el-col :span="12" style="width: 300px; padding: 0">
+                  <search-supplier
                     :size="searchSize"
-                    class="input-with-select"
-                  >
-                    <el-select
-                      v-model="select"
-                      slot="prepend"
-                      style="width: 125px"
-                      placeholder="请选择类型"
-                    >
-                      <el-option label="仓库编码" value="1"></el-option>
-                      <el-option label="库存量" value="2"></el-option>
-                    </el-select>
-                    <el-button
-                      slot="append"
-                      icon="el-icon-search"
-                      @click="searchList"
-                    ></el-button>
-                  </el-input>
+                    :placeholder="'请选择供应商公司'"
+                    :value="parmValue.supplier_code"
+                    @searchChange="selectSupplier"
+                  />
                 </el-col>
-
-                <el-col :span="6" style="width: 273px; padding: 0 0 0 10px">
-                  <number-range
-                    :start="parmValue.total_low"
-                    :end="parmValue.total_up"
-                    :type="1"
-                    :width="'120px'"
-                    :title="'库存量'"
+                <el-col :span="12" style="width: 200px; padding-left: 10px">
+                  <search-stock
+                    :isDetail="true"
                     :size="searchSize"
-                    @numReturned="numReturned($event, 0)"
+                    :value="parmValue.stock_code"
+                    :disabled="isDisabled"
+                    :placeholder="'请选择出口仓库'"
+                    :isRelation="true"
+                    :companyCode="supplier_code"
+                    :names="''"
+                    @searchChange="selectStock"
                   />
                 </el-col>
-
-                <!-- 预警库存量 -->
-                <el-col :span="6" style="width: 303px" class="mr10">
-                  <number-range
-                    :start="parmValue.total_low"
-                    :end="parmValue.total_up"
-                    :type="1"
-                    :width="'135px'"
-                    :title="'预警量'"
+                <el-col style="width: 200px; padding-left: 10px">
+                  <el-input
+                    :disabled="is_disabled"
+                    placeholder="请输入商品编码"
                     :size="searchSize"
-                    @numReturned="numReturned($event, 0)"
+                    v-model="parmValue.goods_sn"
                   />
                 </el-col>
-
-                <el-col
-                  :span="4"
-                  style="width: 54px; margin-left: 10px"
-                  class="mr5"
-                >
+                <el-col :span="4" style="width: 54px; margin-left: 10px">
                   <el-button
                     :size="searchSize"
                     class="fr"
@@ -91,11 +67,55 @@
                     >重置</el-button
                   >
                 </el-col>
+                <el-col :span="3" style="width: 56px; float: right">
+                  <el-button
+                    type="primary"
+                    :size="searchSize"
+                    style="float: right; margin-left: 5px"
+                    @click="searchList"
+                  >
+                    刷新
+                  </el-button>
+                </el-col>
               </el-col>
             </el-row>
+            <el-row>
+              <el-col :span="6" style="width: 273px; padding: 10px 0 0 0px">
+                <num-ber-range
+                  :lower="parmValue.stock_num_low"
+                  :online="parmValue.stock_num_up"
+                  :title="'库存量'"
+                  :width="'120px'"
+                  :size="searchSize"
+                  @numReturned="numReturned($event, 0)"
+                />
+              </el-col>
+              <el-col :span="6" style="width: 303px; padding-top: 10px">
+                <num-ber-range
+                  :lower="parmValue.warn_num_low"
+                  :online="parmValue.warn_num_up"
+                  :width="'135px'"
+                  :title="'预警量'"
+                  :size="searchSize"
+                  @numReturned="numReturned1($event, 0)"
+                />
+              </el-col>
+              <!--搜索按钮 -->
+              <el-col :span="4" style="width: 44px; padding-top: 10px">
+                <el-button
+                  style="width: 100%"
+                  type="primary"
+                  icon="el-icon-search"
+                  :size="searchSize"
+                  @click="searchList"
+                >
+                </el-button>
+              </el-col>
+            </el-row>
+            {{ parmValue }}1{{ supplier_code }}
           </div>
         </template>
-        <!-- <template #status="{ scope }">
+        <template #status="{ scope }">
           <el-tag
             :size="tablebtnSize"
             :type="scope.row.status == '0' ? 'warning' : ''"
@@ -104,7 +124,7 @@
                 .label || '--'
             "
           ></el-tag>
-        </template> -->
+        </template>
         <template #operation="{ scope }">
           <el-tooltip
             v-if="powers.some((item) => item == '005')"
@@ -164,7 +184,6 @@ import mixinPage from "@/mixins/elPaginationHandle";
 import resToken from "@/mixins/resToken";
 import statusList from "@/assets/js/statusList";
 import asyncRequest from "@/apis/service/stock/stockWarning";
-// import asyncRequest from "@/mock/service/stock/stockWarning";
 import colums from "./colums";
 import addEdit from "./addEdit";
 import { mapGetters } from "vuex";
@@ -190,33 +209,25 @@ export default {
   },
   data() {
     return {
-      options: [],
-      // stock: [
-      //   { id: "1", name: "自建仓" },
-      //   { id: "2", name: "自建仓" },
-      //   { id: "1", name: "部门仓" },
-      //   { id: "2", name: "部门仓" },
-      // ],
-      // sitem: null,
-
+      input: "WSMdr4w211019095958", //三合一输入框的内容
+      stockCode: "", //仓库名称
+      supplier_code: "", //供应商名称
+      isDisabled: true, //默认不能选仓库
+      is_disabled: true, //默认不能选商品编码
       statusList: statusList,
       loading: true,
       showModel: false,
       isDetail: false,
       modelId: 0,
-      row: "",
       parmValue: {
-        stock_sn: "", // 商品编码
-        stock_start: 0, //库存量开始
-        stock_end: 0, //库存量结束
-        stockWarn_start: 0, //预警量开始
-        stockWarn_end: 0, //预警量结束
-        status: "", //
-        page: 1, // 页码
-        size: 15, // 每页显示条数
+        goods_sn: "", //商品编码
+        supplier_code: [], //供应商编码
+        stock_code: [], //仓库编码
+        warn_num_low: "", //预警库存下限
+        warn_num_up: "", //预警库存上限
+        stock_num_low: "", //库存量下限
+        stock_num_up: "", //库存上限
       },
-      tableData: [],
-
       // 表格 - 数据
       tableData: [],
       // 表格 - 参数
@@ -233,22 +244,65 @@ export default {
       },
       // 表格 - 列参数
       columns: colums,
-      // 状态
-      // statusOptions: [
-      //   { id: "0", label: "禁用" },
-      //   { id: "1", label: "启用" },
-      // ],
-      // passwordModel: false,
-      // passwordModelId: 0,
-      // isPasswordDetail: false,
     };
   },
   mounted() {
     this.searchList();
-    // this.stockName();
   },
 
   methods: {
+    // 选择供应商仓库
+    selectStock(e) {
+      if (e && e.id) {
+        this.parmValue.stock_code = [e.code];
+        this.stockCode = e.code;
+        this.is_disabled = false;
+      } else {
+        this.parmValue.stock_code = [];
+        this.stock_code = "";
+        this.is_disabled = true;
+        this.parmValue.goods_sn = "";
+      }
+    },
+    // 选择供应商
+    selectSupplier(e) {
+      if (e && e.id) {
+        this.parmValue.supplier_code = [e.code];
+        this.supplier_code = e.code;
+        this.isDisabled = false;
+      } else {
+        console.log("asa");
+        this.parmValue.stock_code = [];
+        this.parmValue.goods_sn = "";
+        this.parmValue.supplier_code = [];
+        this.stock_code = "";
+        this.supplier_code = "";
+        this.is_disabled = true;
+        this.isDisabled = true;
+      }
+    },
+    // 预警量范围框
+    numReturned1(e) {
+      if (e && e.lower != "" && e.online != "") {
+        this.parmValue.warn_num_low = e.lower;
+        this.parmValue.warn_num_up = e.online;
+      } else {
+        this.parmValue.warn_num_low = "0";
+        this.parmValue.warn_num_up = "0";
+      }
+    },
+    // 库存量范围框
+    numReturned(e) {
+      if (e && e.lower != "" && e.online != "") {
+        this.parmValue.stock_num_low = e.lower;
+        this.parmValue.stock_num_up = e.online;
+      } else {
+        this.parmValue.stock_num_low = "0";
+        this.parmValue.stock_num_up = "0";
+      }
+      console.log(this.parmValue);
+    },
+    // 重置搜索栏
     restSearch() {
       // 表格 - 分页
       this.pageInfo = {
@@ -256,13 +310,14 @@ export default {
         curr: 1,
         total: 0,
       };
-      this.input = "";
-      this.select = "1";
-      this.ruleForm = {
-        supplier_code: [], //供应商名称
-        stock_code: [], //仓库名称
-        good_name: "", //产品名称
-        warn_num: "", //预警数量
+      this.parmValue = {
+        goods_sn: "", //商品编码
+        supplier_code: [], //供应商编码
+        stock_code: [], //仓库编码
+        warn_num_low: "", //预警库存下限
+        warn_num_up: "", //预警库存上限
+        stock_num_low: "", //库存量下限
+        stock_num_up: "", //库存上限
       };
       this.searchList();
     },
@@ -278,10 +333,32 @@ export default {
 
     async searchList() {
       this.loading = true;
+      const {
+        supplier_code,
+        stock_code,
+        goods_sn,
+        stock_num_low,
+        stock_num_up,
+        warn_num_low,
+        warn_num_up,
+      } = JSON.parse(JSON.stringify(this.parmValue));
+      console.log(this.ruleForm);
       let model = {
-        wsm_code: "WSMdr4w211019095958",
+        wsm_code: "", //WSMdr4w211019095958
+        // 缺少库存量上下限两个字段
+        // 缺少预警量上下限两个字段
+        supplier_code: supplier_code.toString() || "",
+        stock_code: stock_code.toString() || "",
+        goods_sn,
+        stock_num_low,
+        stock_num_up,
+        warn_num_low,
+        warn_num_up,
+        page: 1,
+        size: 15,
       };
-      console.log(this.ruleForm);
+      console.log(model);
+
       const res = await asyncRequest.list(model);
       if (res && res.code === 0 && res.data) {
         // console.log(res.data.list);