有个问题解决了一天,赶紧记录下来
问题:弹框弹出的时候 选中下拉的值要回显 ,但是现在只能显示编号,不能显示名称
解决:放在不同的数据源里
表格上的下拉:
<a-form class="form_item_right" layout="inline" :model="queries">
<a-form-item label="业务类型:" name="business_type">
<a-select optionLabelProp='busi_type_name' :options="businessTypeList"
:field-names="{ label: 'busi_type_name', value: 'busi_type_code' }" style="width: 230px"
v-model:value="queries.busi_type" placeholder="请选择" @select="nodeSelect">
</a-select>
</a-form-item>
</a-form>
弹出框的下拉
<a-form-item label="业务类型:" name="business_type">
<a-select optionLabelProp='busi_type_name' :options="businessTypeList" style="width: 230px"
v-model:value="formState.business_type" @select="billSelect"
:field-names="{ label: 'busi_type_name', value: 'busi_type_code' }"
</a-select>
</a-form-item>
放在不同的数据源
const businessData = reactive({
queries: {
busi_type: ''
},
formState: {
business_type: '',
},
}
点击弹框:
之前放在同一个数据源formState里,先清空formState里的所有值,把表格上下拉选中的值也清空了,就没法回显了
/** 编辑 */
const editBusiness = (row: any) => {
businessData.modalvisible = true;
businessData.modalTitle = '修改单据规则设置';
resetFormState();
const _row = _.cloneDeep(row);
businessData.formState = _row;
businessData.formState.business_type = businessData.queries.busi_type
getBillTypeList();
};