|
|
@@ -2,7 +2,7 @@
|
|
|
<div class="flex items-center">
|
|
|
<a-input-group compact>
|
|
|
<template v-if="props.params?.dictSort">
|
|
|
- <a-form-item class="select" :style="{ width: '24%' }">
|
|
|
+ <a-form-item class="select" :style="{ width: props.dictWidth + '%' }">
|
|
|
<a-select
|
|
|
v-model:value="dictValue"
|
|
|
:options="dictData"
|
|
|
@@ -10,15 +10,43 @@
|
|
|
style="width: 100%"
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
- <a-form-item class="input" :style="{ width: '76%' }">
|
|
|
- <a-input v-model:value="inputValue" @change="handleInputChange" style="width: 100%" />
|
|
|
+ <a-form-item class="input" :style="{ width: 100 - props.dictWidth + '%' }">
|
|
|
+ <a-input
|
|
|
+ v-if="!props.isInputNum"
|
|
|
+ v-model:value="inputValue"
|
|
|
+ @change="handleInputChange"
|
|
|
+ style="width: 100%"
|
|
|
+ :maxLength="props.inputLength"
|
|
|
+ />
|
|
|
+ <a-input-number
|
|
|
+ v-else
|
|
|
+ v-model:value="inputValue"
|
|
|
+ @change="handleInputChange"
|
|
|
+ style="width: 100%"
|
|
|
+ :min="props.numMin"
|
|
|
+ :max="props.numMax"
|
|
|
+ />
|
|
|
</a-form-item>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
- <a-form-item class="input" :style="{ width: '76%' }">
|
|
|
- <a-input v-model:value="inputValue" @change="handleInputChange" style="width: 100%" />
|
|
|
+ <a-form-item class="input" :style="{ width: 100 - props.dictWidth + '%' }">
|
|
|
+ <a-input
|
|
|
+ v-if="!props.isInputNum"
|
|
|
+ v-model:value="inputValue"
|
|
|
+ @change="handleInputChange"
|
|
|
+ style="width: 100%"
|
|
|
+ :maxLength="props.inputLength"
|
|
|
+ />
|
|
|
+ <a-input-number
|
|
|
+ v-else
|
|
|
+ v-model:value="inputValue"
|
|
|
+ @change="handleInputChange"
|
|
|
+ style="width: 100%"
|
|
|
+ :min="props.numMin"
|
|
|
+ :max="props.numMax"
|
|
|
+ />
|
|
|
</a-form-item>
|
|
|
- <a-form-item class="select" :style="{ width: '24%' }">
|
|
|
+ <a-form-item class="select" :style="{ width: props.dictWidth + '%' }">
|
|
|
<a-select
|
|
|
v-model:value="dictValue"
|
|
|
:options="dictData"
|
|
|
@@ -46,6 +74,11 @@
|
|
|
immediate: { type: Boolean, default: true },
|
|
|
resultField: propTypes.string.def(''),
|
|
|
placeholder: { type: String },
|
|
|
+ dictWidth: { type: Number, default: 24 },
|
|
|
+ isInputNum: { type: Boolean, default: false },
|
|
|
+ numMax: { type: Number, default: 999 },
|
|
|
+ numMin: { type: Number, default: 0 },
|
|
|
+ inputLength: { type: Number, default: 100 },
|
|
|
},
|
|
|
emits: ['change'],
|
|
|
setup(props, { attrs, emit }) {
|
|
|
@@ -104,12 +137,12 @@
|
|
|
const res = await api(props.params);
|
|
|
if (Array.isArray(res)) {
|
|
|
dictData.value = res;
|
|
|
- dictValue.value = dictData.value[0]['value'];
|
|
|
+ dictValue.value = dictValue.value || dictData.value[0]['value'];
|
|
|
return;
|
|
|
}
|
|
|
if (props.resultField) {
|
|
|
dictData.value = get(res, props.resultField) || [];
|
|
|
- dictValue.value = dictData.value[0]['value'];
|
|
|
+ dictValue.value = dictValue.value || dictData.value[0]['value'];
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.warn(error);
|
|
|
@@ -141,7 +174,12 @@
|
|
|
|
|
|
// 输入改变
|
|
|
function handleInputChange(e) {
|
|
|
- inputValue.value = e.target.value || '';
|
|
|
+ console.log('🚀 ~ file: ApiInputDict.vue:161 ~ handleInputChange ~ e:', e);
|
|
|
+ if (props.isInputNum) {
|
|
|
+ inputValue.value = e;
|
|
|
+ } else {
|
|
|
+ inputValue.value = e.target.value || '';
|
|
|
+ }
|
|
|
emitChange();
|
|
|
}
|
|
|
|