戴艳蓉 3 years ago
parent
commit
b36e5e8b18

+ 3 - 1
src/apis/components/serach-good-modal.js → src/apis/components/search-good-modal.js

@@ -3,5 +3,7 @@ const api = "admin/";
 export default {
   // 列表
   list: (data, params) => http(api + "goodlist", data, "post", params),
+  // 供应商列表
+  supplierList: (data, params) => http(api + "supplierlist", data, "post", params),
+
 };
-   

+ 2 - 2
src/apis/service/stock/check/index.js

@@ -3,11 +3,11 @@ import http from "@/apis/axios";
 const api = "admin/";
 export default {
   // 添加
-  add: (data, params) => http(api + "add", data, "post", params),
+  add: (data, params) => http(api + "checkcreate", data, "post", params),
   // 删除
   delete: (data, params) => http(api + "delete", data, "post", params),
   // 分页查询
-  list: (data, params) => http(api + "list", data, "post", params),
+  list: (data, params) => http(api + "checklist", data, "post", params),
   // 详情
   detail: (data, params) => http(api + "detail", data, "post", params),
   // 更新

+ 19 - 17
src/components/search-good-modal/columns.js

@@ -1,4 +1,5 @@
 export default [
+  { type: "selection", fixed: "left", _noset_: true },
   {
     prop: "good_code",
     label: "商品编码",
@@ -13,23 +14,23 @@ export default [
   {
     prop: "gys_code",
     label: "供应商编码",
-    width: "145",
+    width: "142",
   },
   {
     prop: "supplier_name",
     label: "供货商",
     "min-width": "160",
   },
-  {
-    prop: "cg_saler",
-    label: "采购员",
-    width: "60",
-  },
-  {
-    prop: "usable_stock",
-    label: "商品库存",
-    width: "70",
-  },
+  // {
+  //   prop: "cg_saler",
+  //   label: "采购员",
+  //   width: "60",
+  // },
+  // {
+  //   prop: "usable_stock",
+  //   label: "商品库存",
+  //   width: "70",
+  // },
   {
     prop: "unit",
     label: "单位",
@@ -41,11 +42,7 @@ export default [
   //   _slot_: "status",
   //   width: "80px",
   // },
-  {
-    prop: "brand",
-    label: "品牌",
-    "width": "70",
-  },
+
 
   // {
   //   prop: "classArr",
@@ -61,6 +58,11 @@ export default [
     label: "商品材质",
     width: "70",
   },
+  {
+    prop: "brand",
+    label: "品牌",
+    "width": "70",
+  },
   // {
   //   prop: "good_type",
   //   label: "商品类型",
@@ -78,5 +80,5 @@ export default [
   //   _noset_: true,
   //   _slot_: "operation",
   // },
- 
+
 ]

+ 95 - 42
src/components/search-good-modal/main.vue

@@ -35,48 +35,55 @@
           searchList();
         "
       >
-        <template #table-header="{}">
+        <template #table-header="{ selection }">
           <div style="width: 100%">
-            <el-row style="padding: 0 0 0 80px">
+            <el-row style="margin-top: -15px">
               <el-col :span="24">
-                <el-col :span="4" style="width: 120px">
+                <el-col :span="4" style="width: 280px; padding: 0">
                   <el-select
-                    :size="searchSize"
-                    v-model="parmValue.status"
+                    v-model="supplierCode"
+                    multiple
                     filterable
+                    remote
+                    :multiple-limit="1"
+                    reserve-keyword
+                    :size="searchSize"
                     clearable
-                    placeholder="账号状态"
                     style="width: 100%"
-                    @change="
-                      pageInfo.curr = 1;
-                      parmValue.page = 1;
-                      searchList();
-                    "
+                    :placeholder="'供应商名称'"
+                    :remote-method="remoteMethod"
+                    :loading="selectLoading"
+                    @change="supplierChange"
                   >
                     <el-option
-                      v-for="item in statusList"
-                      :key="'status' + item.code"
+                      v-for="(item, index) in options"
+                      :key="item.id + index"
                       :label="item.name"
-                      :value="item.code"
-                    />
+                      :value="item.code + ''"
+                      :disabled="item.status !== '1'"
+                    >
+                    </el-option>
                   </el-select>
                 </el-col>
-                <el-col :span="4" style="width: 150px; padding: 0 0 0 10px">
+                <el-col :span="4" style="width: 190px; padding: 0 0 0 10px">
                   <el-input
                     :size="searchSize"
-                    v-model="parmValue.name"
+                    v-model="parmValue.good_code"
                     :maxlength="40"
-                    placeholder="业务员姓名"
+                    clearable
+                    placeholder="商品编号"
                   />
                 </el-col>
-                <el-col :span="4" style="width: 160px; padding: 0 0 0 10px">
+                <el-col :span="4" style="width: 180px; padding: 0 0 0 10px">
                   <el-input
                     :size="searchSize"
-                    v-model="parmValue.username"
+                    v-model="parmValue.good_name"
                     :maxlength="40"
-                    placeholder="手机号"
+                    clearable
+                    placeholder="商品名称"
                   />
                 </el-col>
+
                 <el-col :span="4" style="width: 54px">
                   <el-button
                     :size="searchSize"
@@ -95,7 +102,7 @@
                     重置
                   </el-button>
                 </el-col>
-                <el-col :span="3" style="width: 66px; float: right">
+                <el-col :span="3" style="width: 66px">
                   <el-button
                     :size="searchSize"
                     type="primary"
@@ -105,6 +112,16 @@
                     刷新
                   </el-button>
                 </el-col>
+                <el-col :span="3" style="width: 66px; float: right">
+                  <el-button
+                    :size="searchSize"
+                    type="success"
+                    style="float: right; margin-left: 5px"
+                    @click="resultList(selection)"
+                  >
+                    保存
+                  </el-button>
+                </el-col>
               </el-col>
             </el-row>
           </div>
@@ -115,11 +132,10 @@
 </template>
 
 <script>
-import asyncRequest from "@/apis/components/serach-good-modal";
+import asyncRequest from "@/apis/components/search-good-modal";
 import resToken from "@/mixins/resToken";
 import mixinPage from "@/mixins/elPaginationHandle";
 import setNum from "@/mixins/setNum";
-import statusList from "@/assets/js/statusList";
 import { mapGetters } from "vuex";
 import columns from "./columns";
 export default {
@@ -128,18 +144,12 @@ export default {
   computed: {
     ...mapGetters(["tablebtnSize", "searchSize", "size"]),
   },
-  props: ["showModel", "supplierNo", "wsmcode"],
+  props: ["showModel"],
 
   /**
    * 属性集合
-   * @param {String}        size             : 组件大小            非必填
-   * @param {Array}         value            : 选中值              必填
-   * @param {String}        placeholder      : 提示信息            非必填
-   * @param {Boolean}       isDetail          : 是否是详情逻辑       必填
-   * @param {Boolean}       disabled         : 是否禁用            必填
-   * @param {Boolean}       multiple         : 是否多选            必填
-   * @param {Boolean}       checkStrictly    : 是否选择任意一项     必填
-   *
+   * @param {Boolean}       showModel             : 是否弹出弹窗        必填
+   * @param {Boolean}       once                  : 是否只选一条        非必填
    */
   /**
    * 事件集合
@@ -147,12 +157,12 @@ export default {
    */
   data() {
     return {
-      title: "",
-      statusList: statusList,
+      options: [],
+      selectLoading: false,
+      searchName: "",
+      supplierCode: [],
       loading: true,
-      showModel: false,
-      isDetail: false,
-      modelId: 0,
+      showModelThis: false,
       parmValue: {
         type_code: "", // 商品属性code
         supplierNo: "", // 供应商code
@@ -172,7 +182,7 @@ export default {
       table: {
         stripe: true,
         border: true,
-        _defaultHeader_: ["setcol"],
+        // _defaultHeader_: ["setcol"],
       },
       // 表格 - 分页
       pageInfo: {
@@ -186,9 +196,9 @@ export default {
   },
   watch: {
     showModel: function (val) {
-      console.log(val);
       this.showModelThis = val;
       if (val) {
+        this.supplierCode = [];
         this.searchList();
       }
     },
@@ -200,10 +210,20 @@ export default {
   },
 
   methods: {
-    async selectChange(e) {
-      this.$emit("searchChange", e);
+    closeModel() {
+      console.log("closeModel!!");
+    },
+    supplierChange(e) {
+      if (e && e.length === 1) {
+        this.parmValue.supplierNo = e[0];
+      } else {
+        this.parmValue.supplierNo = "";
+      }
+      this.parmValue.page = 1;
+      this.searchList();
     },
     restSearch() {
+      this.supplierCode = [];
       this.parmValue = {
         type_code: "", // 商品属性code
         supplierNo: "", // 供应商code
@@ -237,6 +257,39 @@ export default {
       }
       this.loading = false;
     },
+    async remoteMethod(query) {
+      this.selectLoading = true;
+      if (query !== "") {
+        this.options = [];
+        let formValue = {
+          page: 1,
+          size: 100,
+          name: query,
+          code: "",
+        };
+
+        let res = await asyncRequest.supplierList(formValue);
+        if (res && res.code === 0 && res.data) {
+          const { list } = res.data;
+          this.options = list;
+        } else if (res && res.code >= 100 && res.code <= 104) {
+          await this.logout();
+        } else {
+          this.$message.warning(res.message);
+        }
+      } else {
+        this.options = [];
+      }
+      this.selectLoading = false;
+    },
+    async resultList(selection) {
+      if (selection && selection.length > 1 && this.once) {
+        this.$message.warning("只能选择一条商品信息!");
+        return;
+      }
+      this.showModelThis = false;
+      this.$emit("resultList", selection);
+    },
   },
 };
 </script>

+ 2 - 2
src/components/search-supplier/main.vue → src/components/search-supplier/index.vue

@@ -18,7 +18,7 @@
       v-for="(item, index) in options"
       :key="item.id + index"
       :label="item.name"
-      :value="item.code"
+      :value="item.code+''"
       :disabled="item.status!=='1'"
     >
     </el-option>
@@ -54,7 +54,7 @@ export default {
   },
   watch: {
     names: function (val, old) {
-      console.log(val, old);
+      // console.log(val, old);
       this.searchName = val;
       if (this.isDetail && this.searchName) {
         this.remoteMethod(this.searchName);

+ 9 - 9
src/layout/components/Sidebar/index.vue

@@ -14,17 +14,17 @@
         :collapse-transition="false"
         mode="vertical"
       >
-        <el-menu-item
-          v-for="(route, index) in menuList"
-          :key="route.path + index"
-          :route="route.path"
-          :index="index + ''"
-        >
-          <template v-if="!route.hidden">
+        <template v-for="(route, index) in menuList">
+          <el-menu-item
+            v-if="!route.hidden"
+            :key="route.path + index"
+            :route="route.path"
+            :index="index + ''"
+          >
             <i :class="route.meta.icon"></i>
             <span slot="title">{{ route.meta.title }}</span>
-          </template>
-        </el-menu-item>
+          </el-menu-item>
+        </template>
       </el-menu>
     </el-scrollbar>
   </div>

+ 1 - 1
src/views/stock/check/addModel.vue

@@ -3,7 +3,7 @@
     title="新建盘点"
     :center="true"
     align="left"
-    top="15vh"
+    top="8vh"
     width="1040px"
     @close="closeModel"
     :close-on-click-modal="false"

+ 142 - 132
src/views/stock/check/components/addEdit.vue

@@ -1,118 +1,126 @@
 <template>
-  <el-form
-    :model="ruleForm"
-    status-icon
-    :rules="rulesThis"
-    ref="ruleForm"
-    label-width="80px"
-    class="demo-ruleForm"
-  >
-    <el-row>
-      <el-col :span="12">
-        <el-form-item label="盘点公司" prop="wsm_supplier">
-          <search-supplier
-            :value="ruleForm.wsm_supplier"
-            :placeholder="'请选择盘点公司'"
-            @searchChange="supplierChange"
-          />
-        </el-form-item>
-      </el-col>
-      <el-col :span="12">
-        <el-form-item label="盘点仓库" prop="wsm_code">
-          <search-stock
-            :value="ruleForm.wsm_code"
-            :isDetail="true"
-            :placeholder="'请选择盘点仓库'"
-            :isRelation="true"
-            :companyCode="companyCode"
-            :names="''"
-            @searchChange="stockChange"
-          />
-        </el-form-item>
-      </el-col>
-      <el-col :span="12">
-        <el-form-item label="盘点类型" prop="type">
-          <el-select
-            v-model="ruleForm.type"
-            placeholder="请选择盘点类型"
-            style="width: 100%"
-          >
-            <el-option
-              v-for="item in typeList"
-              :key="item.value"
-              :label="item.label"
-              :value="item.value"
+  <div>
+    <el-form
+      :model="ruleForm"
+      :rules="rulesThis"
+      status-icon
+      ref="ruleForm"
+      label-width="80px"
+      class="demo-ruleForm"
+    >
+      <el-row>
+        <el-col :span="12">
+          <el-form-item label="盘点公司" prop="wsm_supplier">
+            <search-supplier
+              :value="ruleForm.wsm_supplier"
+              :placeholder="'请选择盘点公司'"
+              @searchChange="supplierChange"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="盘点仓库" prop="wsm_code">
+            <search-stock
+              :value="ruleForm.wsm_code"
+              :isDetail="true"
+              :placeholder="'请选择盘点仓库'"
+              :isRelation="true"
+              :companyCode="companyCode"
+              :names="''"
+              @searchChange="stockChange"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="盘点类型" prop="type">
+            <el-select
+              v-model="ruleForm.type"
+              placeholder="请选择盘点类型"
+              style="width: 100%"
             >
-            </el-option>
-          </el-select>
-        </el-form-item>
-      </el-col>
-      <el-col :span="24" v-if="ruleForm.type !== '1'">
-        <el-form-item label="盘点商品" size="'mini'" prop="good_type_code">
-          <el-table
-            :data="ruleForm.good_type_code"
-            border
-            :size="'mini'"
-            max-height="400"
-            style="width: 100%"
-          >
-            <el-table-column
-              v-for="item in columns"
-              :key="item.prop"
-              :prop="item.prop"
-              :label="item.label"
+              <el-option
+                v-for="item in typeList"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="24" v-if="ruleForm.type !== '1'">
+          <el-form-item label="盘点商品" :size="'mini'" prop="good_type_code">
+            <el-table
+              :data="ruleForm.good_type_code"
+              border
+              :size="'mini'"
+              max-height="400"
+              style="width: 100%"
             >
-            </el-table-column>
-            <el-table-column align="right">
-              <template slot="header" slot-scope="scope">
-                <el-button
-                  @click="cliacasss()"
+              <el-table-column
+                show-overflow-tooltip
+                v-for="item in columns"
+                :key="item.prop"
+                :prop="item.prop"
+                :label="item.label"
+                :width="item.width"
+                :min-width="item.minWidth + 'px'"
+              >
+              </el-table-column>
+              <el-table-column width="60px">
+                <template slot="header" slot-scope="scope">
+                  <el-tooltip effect="dark" content="添加商品" placement="top">
+                    <i
+                      class="el-icon-circle-plus-outline tb-icon"
+                      style="color: #63cbe7"
+                      @click="showGoodsModel = true"
+                    ></i>
+                  </el-tooltip>
+
+                  <!-- <el-link type="primary"  @click="showGoodsModel = true">添加商品</el-link> -->
+                  <!-- <el-button
+                  @click="showGoodsModel = true"
                   :size="'mini'"
                   type="primary"
-                  style="float: right; margin-left: 5px"
-                  >添加商品
-                </el-button>
-              </template>
-              <template slot-scope="scope">
-                <el-tooltip effect="dark" content="删除" placement="top">
-                  <i
-                    class="el-icon-delete tb-icon"
-                    @click="deleteById(scope.$index)"
-                  ></i>
-                </el-tooltip>
-              </template>
-            </el-table-column>
-          </el-table>
-
-          <search-good-modal :show-model="showGoodsModel" />
-        </el-form-item>
-      </el-col>
-      <el-col :span="24" style="text-align: right">
-        <el-button type="primary" @click="submitForm" v-if="!isDetail"
-          >保 存
-        </el-button>
-        <el-button @click="showModelThis = false">{{
-          isDetail ? "关 闭" : "取 消"
-        }}</el-button>
-      </el-col>
-    </el-row>
-  </el-form>
+                  icon="el-icon-circle-plus-outline"
+                  circle
+                >
+                </el-button> -->
+                </template>
+                <template slot-scope="scope">
+                  <el-tooltip effect="dark" content="删除" placement="top">
+                    <i
+                      class="el-icon-delete tb-icon"
+                      @click="deleteById(scope.$index)"
+                    ></i>
+                  </el-tooltip>
+                </template>
+              </el-table-column>
+            </el-table>
+          </el-form-item>
+        </el-col>
+        <el-col :span="24" style="text-align: right">
+          <el-button type="primary" @click="submitForm" v-if="!isDetail"
+            >保 存
+          </el-button>
+          <el-button @click="showModelThis = false">{{
+            isDetail ? "关 闭" : "取 消"
+          }}</el-button>
+        </el-col>
+      </el-row>
+    </el-form>
+    <search-good-modal
+      :show-model="showGoodsModel"
+      @cancel="showGoodsModel = false"
+      @resultList="addGoodsRes"
+    />
+  </div>
 </template>
    <script>
 import asyncRequest from "@/apis/service/stock/check";
 import resToken from "@/mixins/resToken";
-import {
-  isnumber,
-  isMobile,
-  validEmail,
-  isAlphanumeric,
-  isChinese,
-  isEmoticon,
-  validAlphabets,
-} from "@/utils/validate";
-import stockSearch from "../../allotFlow/components/stockSearch.vue";
+import columns from "./columns";
 export default {
-  components: { stockSearch },
   name: "addEdit",
   props: ["showModel", "id"],
   mixins: [resToken],
@@ -132,28 +140,11 @@ export default {
         },
       ],
       showModelThis: this.showModel,
-      columns: [
-        {
-          prop: "code",
-          label: "商品编码",
-        },
-        {
-          prop: "code1",
-          label: "商品编码1",
-        },
-        {
-          prop: "code2",
-          label: "商品编码2",
-        },
-        {
-          prop: "code3",
-          label: "商品编码3",
-        },
-      ],
+      columns: columns,
       ruleForm: {
         wsm_supplier: [], //供应商
         wsm_code: [], // 盘点仓库
-        type: "1", // 盘点类型
+        type: "2", // 盘点类型
         good_type_code: [], //商品列表
       },
       rulesThis: this.rules,
@@ -200,9 +191,18 @@ export default {
     closeModel() {
       console.log("closeModel!!");
     },
-    cliacasss() {
-      this.showGoodsModel = true;
-      console.log(this.showGoodsModel);
+    addGoodsRes(e) {
+      let oldList = JSON.parse(JSON.stringify(this.ruleForm.good_type_code)),
+        addList = JSON.parse(JSON.stringify(e)),
+        newList = [].concat(...oldList);
+      addList.forEach((v1, index) => {
+        let oldindex = oldList.findIndex((v2) => v1.good_code === v2.good_code);
+        if (oldindex === -1) {
+          newList.push(addList[index]);
+        }
+      });
+      this.ruleForm.good_type_code = [].concat(...newList);
+      this.$refs.ruleForm.validateField("good_type_code");
     },
     //供应商选择
     supplierChange(e) {
@@ -224,7 +224,10 @@ export default {
       }
       this.$refs.ruleForm.validateField("wsm_code");
     },
-    deleteById(index) {},
+    deleteById(index) {
+      this.ruleForm.good_type_code.splice(index, 1);
+      this.$refs.ruleForm.validateField("good_type_code");
+    },
     async initForm() {
       console.log(this.id);
       this.loading = true;
@@ -266,13 +269,16 @@ export default {
           this.ruleForm = {
             wsm_supplier: [], // 盘点公司
             wsm_code: [], // 盘点仓库
-            type: "1", // 真实姓名
+            type: "2", // 真实姓名
             good_type_code: [], //商品列表
           };
         }
       });
     },
-
+    getId(list) {
+      let arr = JSON.parse(JSON.stringify(list));
+      return arr.join(",");
+    },
     async submitForm() {
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
@@ -280,11 +286,15 @@ export default {
           const { wsm_code, type, good_type_code } = JSON.parse(
             JSON.stringify(this.ruleForm)
           );
+          let goodcode = "";
+          good_type_code.forEach((v, i) => {
+            goodcode += i !== 0 ? `,${v.good_code}` : v.good_code;
+          });
           const model = {
             id: this.id,
-            wsm_code: wsm_code || [], // 盘点仓库
+            wsm_code: this.getId(wsm_code) || "", // 盘点仓库
             type: type || "", // 盘点类型
-            good_type_code: good_type_code || "", //商品列表
+            good_type_code: goodcode || "", //商品列表
           };
           let res = {};
           if (this.id === "add") {

+ 83 - 0
src/views/stock/check/components/columns.js

@@ -0,0 +1,83 @@
+export default [
+  {
+    prop: "good_code",
+    label: "商品编码",
+    width: "150",
+  },
+  {
+    prop: "good_name",
+    label: "商品名称",
+    minWidth: "100",
+  },
+
+  {
+    prop: "gys_code",
+    label: "供应商编码",
+    width: "142",
+  },
+  {
+    prop: "supplier_name",
+    label: "供货商",
+    minWidth: "110",
+  },
+  // {
+  //   prop: "cg_saler",
+  //   label: "采购员",
+  //   width: "60",
+  // },
+  // {
+  //   prop: "usable_stock",
+  //   label: "商品库存",
+  //   width: "70",
+  // },
+  {
+    prop: "unit",
+    label: "单位",
+    width: "45",
+  },
+  // {
+  //   prop: "bstatus",
+  //   label: "当前状态",
+  //   _slot_: "status",
+  //   width: "80px",
+  // },
+
+
+  // {
+  //   prop: "classArr",
+  //   label: "商品类别",
+  // },
+  {
+    prop: "color",
+    label: "商品颜色",
+    width: "70",
+  },
+  {
+    prop: "material",
+    label: "商品材质",
+    width: "70",
+  },
+  // {
+  //   prop: "brand",
+  //   label: "品牌",
+  //   width: "70",
+  // },
+  // {
+  //   prop: "good_type",
+  //   label: "商品类型",
+  // },
+  // {后端有接口但是没有值。
+  //   prop: "specs",
+  //   label: "商品规格",
+  // },
+
+  // {
+  //   prop: "",
+  //   label: "操作",
+  //   width: "80px",
+  //   fixed: "right",
+  //   _noset_: true,
+  //   _slot_: "operation",
+  // },
+
+]

+ 15 - 15
src/views/stock/check/index.vue

@@ -267,8 +267,8 @@ export default {
       // 表格 - 列参数
       columns: [
         {
-          prop: "nickname",
-          label: "真实姓名",
+          prop: "check_code",
+          label: "盘点编号",
         },
         {
           prop: "role_name",
@@ -314,7 +314,7 @@ export default {
         username: "", // 账号
         status: "", //
         page: 1, // 页码
-        size: 10, // 每页显示条数
+        size: 15, // 每页显示条数
       };
       this.searchList();
     },
@@ -354,18 +354,18 @@ export default {
       //   });
     },
     async searchList() {
-      // this.loading = true;
-      // const res = await asyncRequest.list(this.parmValue);
-      // if (res && res.code === 0 && res.data) {
-      //   this.tableData = res.data.list;
-      //   this.pageInfo.total = Number(res.data.count);
-      // } else if (res && res.code >= 100 && res.code <= 104) {
-      //   await this.logout();
-      // } else {
-      //   this.tableData = [];
-      //   this.pageInfo.total = 0;
-      // }
-      // this.loading = false;
+      this.loading = true;
+      const res = await asyncRequest.list(this.parmValue);
+      if (res && res.code === 0 && res.data) {
+        this.tableData = res.data.list;
+        this.pageInfo.total = Number(res.data.count);
+      } else if (res && res.code >= 100 && res.code <= 104) {
+        await this.logout();
+      } else {
+        this.tableData = [];
+        this.pageInfo.total = 0;
+      }
+      this.loading = false;
     },
 
     async statusConfirm(id, status) {