11
WXL
2024-08-14 0ac2d43fce4d74f6eea5a51a2e16af4e6a536c7c
src/views/project/components/orgselect/index.vue
@@ -1,5 +1,5 @@
<template>
  <div>
  <div class="selectclass">
    <el-select
      v-model="myValue"
      :loading="isLoading"
@@ -17,7 +17,7 @@
      value-key="organizationid"
      allow-create
      reserve-keyword
      :placeholder="placeholder ? placeholder : '请输入机构名称'"
      :placeholder="placeholder ? placeholder : '请选择'"
      class="full-block"
      ref="selecter"
    >
@@ -33,7 +33,7 @@
</template>
<script>
import { listOrganization,listReportname } from "@/api/project/organization";
import { listOrganization, listReportname } from "@/api/project/organization";
export default {
  name: "OrgSelecter",
@@ -41,66 +41,73 @@
  props: {
    //Select基础属性
    value: {
      type: [String, Array],
      type: [String, Array]
    },
    //获取列表
    dataList: {
      type: Array,
      default: function() {
        return [];
      }
    },
    disabled: {
      type: Boolean,
      default: false,
      default: false
    },
    clearable: {
      type: Boolean,
      default: false,
      default: false
    },
    filterable: {
      type: Boolean,
      default: true,
      default: true
    },
    multiple: {
      type: Boolean,
      default: false,
      default: false
    },
    multipleLimit: {
      type: Number,
      default: 0,
      default: 0
    },
    defaultFirstOption: {
      type: Boolean,
      default: true,
      default: true
    },
    size: {
      type: String,
      default: "small",
      default: "small"
    },
    placeholder: {
      type: String,
      default: "",
      default: ""
    },
    //业务属性
    lazyLoad: {
      type: Boolean,
      default: false,
      default: false
    },
    isAll: {
      type: Boolean,
      default: false,
      default: false
    },
    //机构类型
    orgType: {
      type: String,
      default: "",
    },
      default: ""
    }
  },
  data() {
    return {
      pageData: { pageNum:1,pageSize:100 },
      pageData: { pageNum: 1, pageSize: 100 },
      isLoading: false,
      dataList: [],
      // dataList: [],
      tempList: [],
      myValue: this.multiple ? [] : "",
      focusEvents: {
        func: () => {},
        loaded: false,
      },
        loaded: false
      }
    };
  },
  mounted() {
@@ -120,40 +127,52 @@
    }
  },
  methods: {
    renderSelecter() {
      this.pageData.PageSize = 100;
      this.dataList = [];
      this.myValue = this.value;
      this.getdataList();
    },
    //获取数据
    getdataList() {
      this.isLoading = true;
      let searchData={
          organizationtype:this.orgType,//传入的类型
          pageNum:1,
          pageSize:100000
      };//搜索条件
      let searchData = {
        organizationtype: this.orgType, //传入的类型
        pageNum: 1,
        pageSize: 100000
      }; //搜索条件
      let userType={"userType":"1"};
      let userType = { userType: "1" };
      if (this.orgType == 4) {
        let arr = this.$store.state.user.organization;
        this.dataList.push(...arr);
        if (this.isAll) {
          let all = {
            organizationid: "",
            organizationname: "全部"
          };
          this.dataList.unshift(all);
        }
        this.tempList = this.dataList.map(item => item);
        this.focusEvents.loaded = true;
        this.isLoading = false;
        return;
      }
      listOrganization(searchData)
        .then((response) => {
        .then(response => {
          this.dataList.push(...response.rows);
          if (this.isAll) {
            let all = {
              organizationid: "",
              organizationname: "全部",
              organizationname: "全部"
            };
            this.dataList.unshift(all);
          }
          this.tempList = this.dataList.map(item=>item);
          this.tempList = this.dataList.map(item => item);
          this.focusEvents.loaded = true;
        })
        .catch((error) => {
        .catch(error => {
          // 暂无处理
        })
        .finally(() => {
@@ -163,10 +182,10 @@
    getOptionByValue(key) {
      let outValue = null;
      this.dataList.forEach((e) => {
          if (e.organizationid == key) {
            outValue = e;
          }
      this.dataList.forEach(e => {
        if (e.organizationid == key) {
          outValue = e;
        }
      });
      return outValue;
@@ -175,7 +194,7 @@
    filterMethod(val) {
      this.myValue = val;
      if (val) {
        this.dataList = this.tempList.filter((item) => {
        this.dataList = this.tempList.filter(item => {
          if (
            (item.PYM &&
              !!~item.PYM.toUpperCase().indexOf(val.toUpperCase())) ||
@@ -190,7 +209,7 @@
          }
        });
      } else {
        this.dataList = this.tempList.map(item=>item);
        this.dataList = this.tempList.map(item => item);
      }
    },
    focus() {
@@ -211,20 +230,20 @@
    defaultInit(defaultItem, defaultItemName) {
      if (defaultItem && defaultItemName) {
        let list = this.dataList.filter(
          (r) =>
          r =>
            r.organizationid == defaultItem &&
            r.organizationname == defaultItemName
        );
        if (list.length == 0) {
          let data = {
            organizationname: defaultItemName,
            organizationid: defaultItem,
            organizationid: defaultItem
          };
          this.dataList.push(data);
        }
      }
      this.tempList = this.dataList.map(item=>item);
    },
      this.tempList = this.dataList.map(item => item);
    }
  },
  computed: {},
  watch: {
@@ -235,9 +254,15 @@
    myValue(newVal) {
      this.$emit("input", newVal);
      this.$emit("change", newVal);
    },
  },
    }
  }
};
</script>
<style></style>
<style lang="scss" scoped>
::v-deep.selectclass .el-select {
  display: inline-block;
  position: relative;
  width: 90%;
}
</style>