初始提交

This commit is contained in:
2026-01-04 11:09:06 +08:00
commit 8fa31df250
1326 changed files with 213907 additions and 0 deletions

View File

@@ -0,0 +1,114 @@
<template>
<view class="jnpf-user-select w-full">
<selectBox v-model="innerValue" :placeholder="placeholder" @openSelect="openSelect"
:select-open="selectShow" :disabled="disabled" v-if="isInput" />
<SelectPopup v-model="selectShow" :multiple="multiple" :selectedData="selectedData" @close="handleClose"
@confirm="handleConfirm" :selectType="selectType" :ableIds="realAbleIds" />
</view>
</template>
<script>
import SelectPopup from './SelectPopup';
import selectBox from '@/components/selectBox'
import {
getUserInfoList
} from '@/api/common'
export default {
name: 'jnpf-user-select',
components: {
SelectPopup,
selectBox
},
props: {
modelValue: {
default: ''
},
isInput: {
type: Boolean,
default: true
},
placeholder: {
type: String,
default: '请选择'
},
disabled: {
type: Boolean,
default: false
},
multiple: {
type: Boolean,
default: false
},
selectType: {
type: String,
default: 'all'
},
ableIds: {
type: Array,
default: () => []
},
ableRelationIds: {
type: [Array, String],
default: () => []
},
},
data() {
return {
selectShow: false,
innerValue: '',
selectedData: [],
realAbleIds: []
}
},
watch: {
modelValue: {
handler() {
this.setDefault()
},
immediate: true
},
},
methods: {
setDefault() {
if (!this.modelValue || !this.modelValue.length) return this.setNullValue();
const ids = this.multiple ? this.modelValue : [this.modelValue];
getUserInfoList(ids).then((res) => {
if (!this.modelValue || !this.modelValue.length) return this.setNullValue();
const selectedData = res.data.list || []
this.selectedData = selectedData
this.innerValue = this.selectedData.map(o => o.fullName).join();
});
},
setNullValue() {
this.innerValue = '';
this.selectedData = [];
},
openSelect() {
if (this.disabled) return
if (this.selectType === 'custom') {
this.realAbleIds = this.ableIds
} else if (this.selectType != 'all') {
const suffix = '--' + this.selectType;
let ableIds = !this.ableRelationIds ? [] : Array.isArray(this.ableRelationIds) ? this
.ableRelationIds : [this.ableRelationIds];
this.realAbleIds = ableIds.map(o => o + suffix)
} else {
this.realAbleIds = []
}
this.selectShow = true
},
handleConfirm(selectedData, selectedIds) {
if (!this.multiple) {
this.$emit('update:modelValue', selectedIds[0])
this.$emit('change', selectedIds[0], selectedData[0])
} else {
this.$emit('update:modelValue', selectedIds)
this.$emit('change', selectedIds, selectedData)
}
},
handleClose() {
this.selectShow = false
}
}
}
</script>