|
@@ -0,0 +1,85 @@
|
|
|
+<template>
|
|
|
+ <el-select
|
|
|
+ v-model="vModel"
|
|
|
+ placeholder="请选择"
|
|
|
+ filterable
|
|
|
+ remote
|
|
|
+ :remote-method="remoteMethod"
|
|
|
+ clearable
|
|
|
+ v-bind="$attrs"
|
|
|
+ @change="onChange"
|
|
|
+ >
|
|
|
+ <el-option v-for="item in options" :key="item.id" :value="item.id">
|
|
|
+ <span style="float: left">{{ item.nickname }}</span>
|
|
|
+ <span style="float: right; color: #8492a6; font-size: 13px">{{
|
|
|
+ item.mobileNumber
|
|
|
+ }}</span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getSelectList } from '@/api/system/account';
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'AccountSelect',
|
|
|
+
|
|
|
+ props: {
|
|
|
+ value: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ firstLoad: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ vModel: this.value,
|
|
|
+ options: []
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
+ watch: {
|
|
|
+ value: {
|
|
|
+ handler(val) {
|
|
|
+ this.vModel = val;
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ mounted() {
|
|
|
+ this.firstLoad && this.loadData();
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ onChange(value) {
|
|
|
+ this.$emit('input', value || null);
|
|
|
+ },
|
|
|
+
|
|
|
+ remoteMethod(query) {
|
|
|
+ if (query === '') {
|
|
|
+ this.loadData();
|
|
|
+ } else {
|
|
|
+ this.loadData(query);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ async loadData(keyword = '') {
|
|
|
+ const params = {};
|
|
|
+ if (keyword) {
|
|
|
+ params.keyword = keyword;
|
|
|
+ }
|
|
|
+ const { success, data, msg } = await getSelectList(params);
|
|
|
+ if (success) {
|
|
|
+ this.options = data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped></style>
|