123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <template>
- <div style="display: flex;">
- <el-select
- v-model="value"
- placeholder="请选择"
- filterable
- clearable
- allow-create
- default-first-option
- @change="getKeyId(value)" :disabled="disabled"
- @clear="clear()">
- <template>
- <el-option v-for="item in corpList" :key="item.id" :label="corpType == 'DD'?item.name:corpType == 'DD-ID'?item.name:item.cname" :value="item.id">
- </el-option>
- </template>
- </el-select>
- <el-tooltip class="item" effect="dark" content="获取最新客户资料" placement="top-start">
- <el-button icon="el-icon-refresh" size="mini" v-if="label != 'shortName'" :disabled="disabled"
- @click="refreshData"></el-button>
- </el-tooltip>
- </div>
- </template>
- <script>
- import {allCropList} from "@/api/basicData/customerInformation";
- import {kMaxLength} from "buffer";
- import {getAllList} from "@/api/basicData/portinformation";
- export default {
- name: "main",
- data() {
- return {
- form: {},
- corpList: []
- };
- },
- props: {
- value: String,
- name: String,
- label: String,
- corpType: String,
- disabled: Boolean
- },
- model: {
- prop: "value",
- event: "balabala",
- },
- created() {
- this.getCorpList()
- },
- methods: {
- getCorpList(type) {
- let userObj = JSON.parse(localStorage.getItem("saber-userInfo")).content;
- if (this.corpType == 'DD'){
- getAllList().then(res => {
- this.corpList = res.data.data;
- if (type) {
- for (let item of this.corpList) {
- if (item.name == this.value) {
- return this.getKeyId(item.id)
- }
- }
- for (let item of this.corpList) {
- if (item.id == this.value) {
- return this.getKeyId(item.id)
- }
- }
- }
- });
- }else if(this.corpType == 'DD-ID'){
- getAllList().then(res => {
- this.corpList = res.data.data;
- if (type) {
- for (let item of this.corpList) {
- if (item.name == this.value) {
- return this.getKeyId(item.id)
- }
- }
- for (let item of this.corpList) {
- if (item.id == this.value) {
- return this.getKeyId(item.id)
- }
- }
- }
- });
- }else {
- allCropList({
- corpType: this.corpType ? this.corpType : 'KH',
- adminProfiles: userObj.role_name != "admin" ? userObj.user_id : null
- }).then(res => {
- this.corpList = res.data.data;
- if (type) {
- for (let item of this.corpList) {
- if (item.cname == this.value) {
- return this.getKeyId(item.id)
- }
- }
- for (let item of this.corpList) {
- if (item.id == this.value) {
- return this.getKeyId(item.id)
- }
- }
- }
- });
- }
- },
- refreshData() {
- this.getCorpList(true)
- },
- getKeyId(row) {
- if (row) {
- let res = this.corpList.find(e => {
- return e.id == row
- })
- if (res) {
- if (this.corpType == 'DD'){
- this.$emit('balabala',res.name)
- this.$emit('getCropId', res)
- }else if (this.corpType == 'DD-ID'){
- this.$emit('balabala',res.id)
- this.$emit('getCropId', res)
- }else {
- this.$emit('balabala',res.id)
- this.$emit('getCropId', res)
- }
- } else {
- if (this.corpType == 'DD'){
- this.$emit('update:name', row);
- }else if (this.corpType == 'DD-ID'){
- this.$emit('update:name', row);
- }else {
- this.$emit('update:name', row);
- }
- this.$emit('balabala',row)
- this.$emit('getCropId', null)
- }
- } else {
- this.$emit('balabala', null)
- this.$emit('getCropId', null)
- }
- },
- // 清空
- clear() {
- this.$emit('clear', null)
- }
- },
- watch: {}
- };
- </script>
- <style lang="scss" scoped>
- </style>
|