戴艳蓉 3 년 전
부모
커밋
997cc489df

+ 6 - 0
src/apis/components/search-work-company.js

@@ -0,0 +1,6 @@
+import http from "@/apis/axios";
+const api = "admin/";
+export default {
+  // 列表
+  list: (data, params) => http(api + "businesslist", data, "post", params),
+};

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

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

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

@@ -0,0 +1,95 @@
+<template>
+  <el-select
+    v-model="value"
+    :size="size || 'medium'"
+    style="width: 100%"
+    filterable
+    :placeholder="placeholder || ''"
+    :disabled="disabled"
+    :loading="selectLoading"
+    @change="selectChange"
+  >
+    <el-option
+      v-for="(item, index) in options"
+      :key="item.rate + index + ''"
+      :label="item.company"
+      :value="item.rate + '%'"
+      :disabled="item.status === '0'"
+    />
+  </el-select>
+</template>
+
+<script>
+import asyncRequest from "@/apis/components/search-work-company";
+import resToken from "@/mixins/resToken";
+export default {
+  name: "SearchWorkCompany",
+  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: "",
+    };
+  },
+  mounted() {
+    this.options = [];
+    this.selectLoading = false;
+    this.remoteMethod();
+  },
+  methods: {
+    async selectChange(e) {
+      // console.log(e);
+      let index = this.options.findIndex((v) => v.rate + "%" === e);
+      if (index !== -1) {
+        let model = {
+          id: this.options[index].rate,
+          code: this.options[index].rate,
+          label: this.options[index].rate+"%",
+        };
+        this.$emit("searchChange", model);
+      } else {
+        this.$emit("searchChange", {});
+      }
+    },
+    async remoteMethod() {
+      this.selectLoading = true;
+      const { code, data, message } = await asyncRequest.list({});
+      if (code === 0) {
+        this.options = data;
+      } else if (code >= 100 && code <= 104) {
+        await this.logout();
+      } else {
+        this.$message.warning(message);
+      }
+
+      this.selectLoading = false;
+    },
+  },
+};
+</script>
+
+<style>
+</style>

+ 0 - 0
src/components/globalComponents/search-work-company/业务企业选择框