戴艳蓉 3 лет назад
Родитель
Сommit
dd4324596e

+ 9 - 0
src/apis/components/search-unit.js

@@ -0,0 +1,9 @@
+import http from "@/apis/axios";
+const api = "admin/";
+export default {
+  // 列表
+  list: (data, params) => http(api + "brandlist", data, "post", params),
+  //  // 获取仓库  供应商仓/自建仓
+  //  warequery: (data, params) => http(api + "warequery", data, "post", params),
+};
+   

+ 1 - 1
src/components/globalComponents/search-brand/main.vue

@@ -26,7 +26,7 @@
 </template>
 
 <script>
-import asyncRequest from "@/apis/components/search-stock";
+import asyncRequest from "@/apis/components/search-brand";
 import resToken from "@/mixins/resToken";
 export default {
   name: "SearchBrand",

+ 2 - 0
src/components/globalComponents/search-unit/index.js

@@ -0,0 +1,2 @@
+import Main from './main.vue'
+export default Main

+ 134 - 0
src/components/globalComponents/search-unit/main.vue

@@ -0,0 +1,134 @@
+<template>
+  <el-select
+    v-model="value"
+    multiple
+    filterable
+    remote
+    :multiple-limit="1"
+    reserve-keyword
+    :size="size || 'medium'"
+    style="width: 100%"
+    :placeholder="placeholder || ''"
+    :disabled="disabled"
+    :remote-method="remoteMethod"
+    :loading="selectLoading"
+    @change="selectChange"
+  >
+    <el-option
+      v-for="(item, index) in options"
+      :key="item.id + index"
+      :label="item.name"
+      :value="item.wsm_code"
+      :disabled="item.status === '0'"
+    >
+    </el-option>
+  </el-select>
+</template>
+
+<script>
+import asyncRequest from "@/apis/components/search-unit";
+import resToken from "@/mixins/resToken";
+export default {
+  name: "SearchBrand",
+  mixins: [resToken],
+  props: [
+    "size",
+    "value",
+    "placeholder",
+    "isDetail",
+    "disabled",
+    "type",
+    "names",
+  ],
+  /**
+   * 属性集合
+   * @param {String}        size             : 组件大小            非必填
+   * @param {Array}         value            : 选中值              必填
+   * @param {String}        placeholder      : 提示信息            非必填
+   * @param {Boolean}       isDetail         : 是否是详情逻辑       必填
+   * @param {Boolean}       disabled         : 是否禁用            必填
+   * @param {String}        names            : 选中值label         展示详情必填
+   */
+  /**
+   * 事件集合
+   * @searchChange             : 选中值变化调用   抛出选中数据
+   */
+  data() {
+    return {
+      options: [],
+      selectLoading: false,
+      searchName: "",
+      formValue: {
+        page: 1,
+        size: 100,
+        supplierNo: "",
+        wsm_code: "",
+        start: "",
+        end: "",
+        mobile: "",
+        contactor: "",
+      },
+    };
+  },
+  watch: {
+   
+    //  names: function (val, old) {
+    //   // console.log(val, old);
+    //   this.searchName = val;
+    //   if (this.isDetail && this.searchName) {
+    //     this.remoteMethod(this.searchName);
+    //   }
+    // },
+  },
+  mounted() {
+    this.options = [];
+    this.selectLoading = false;
+  },
+  methods: {
+    async selectChange(e) {
+      if (e && e.length > 0) {
+        let index = this.options.findIndex((v) => v.wsm_code === e[0]);
+        if (index !== -1) {
+          let model = {
+            id: this.options[index].id,
+            code: this.options[index].wsm_code,
+            label: this.options[index].name,
+            contactor: this.options[index].wsm_name,
+            mobile: this.options[index].mobile,
+            addr: this.options[index].addr_cn + this.options[index].wsm_addr,
+          };
+          this.$emit("searchChange", model);
+        } else {
+          this.$emit("searchChange", {});
+        }
+      } else {
+        this.$emit("searchChange", {});
+      }
+    },
+    async remoteMethod(query) {
+      this.selectLoading = true;
+      if (query !== "") {
+        this.options = [];
+        let res = {};
+      this.formValue.supplierNo = query;
+          res = await asyncRequest.list(this.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;
+    },
+  },
+};
+</script>
+
+<style>
+</style>

+ 0 - 0
src/components/globalComponents/search-unit/单位选择框