This commit is contained in:
fengerli
2025-09-01 17:02:21 +08:00
parent 031f6135c1
commit 3782f73215
6 changed files with 59 additions and 41 deletions

View File

@ -98,15 +98,15 @@
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="pc路由跳转" prop="modelDictionary">
<el-select v-model="form.modelDictionary" placeholder="请选择">
<el-option v-for="item in pcmodelDictionaryOptions" :key="item.dictValue" :label="item.dictLabel"
<el-form-item label="路由跳转" prop="appModelDictionary">
<el-select v-model="form.appModelDictionary" placeholder="请选择" @change="handlePcRouteChange">
<el-option v-for="item in appmodelDictionaryOptions" :key="item.dictCode" :label="item.dictLabel"
:value="item.dictValue" />
</el-select>
</el-form-item>
<el-form-item label="app路由跳转" prop="modelDictionary">
<el-select v-model="form.modelDictionary" placeholder="请选择">
<el-option v-for="item in appmodelDictionaryOptions" :key="item.dictValue" :label="item.dictLabel"
<el-form-item label="pc路由跳转" prop="pcModelDictionary" style="display: none;">
<el-select v-model="form.pcModelDictionary" placeholder="请选择" >
<el-option v-for="item in pcmodelDictionaryOptions" :key="item.dictCode" :label="item.dictLabel"
:value="item.dictValue" />
</el-select>
</el-form-item>
@ -169,6 +169,8 @@ interface deviceTypeVO {
isSupportBle: boolean;
locateMode: number;
modelDictionary: string;
appModelDictionary: string;
pcModelDictionary: string;
communicationMode: number;
createTime: string;
createByName: string;
@ -197,7 +199,9 @@ const initFormData: DeviceTypeForm = {
typeName: '',
isSupportBle: false,
locateMode: 0,
modelDictionary: '',
// modelDictionary: '',
appModelDictionary: '',
pcModelDictionary: '',
communicationMode: 0,
id: '',
createTime: '',
@ -215,7 +219,7 @@ const initData = {
typeName: [
{ required: true, message: '请输入设备类型名称', trigger: 'blur' },
],
modelDictionary: [
appModelDictionary: [
{ required: true, message: '请选择类型code', trigger: 'blur' },
],
locateMode: [
@ -262,6 +266,22 @@ const resetQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
// PC路由变化时同步对应APP路由
const handlePcRouteChange = (pcDictValue: string) => {
const selectedPcItem = appmodelDictionaryOptions.value.find(
item => item.dictValue === pcDictValue
);
if (!selectedPcItem) return;
const matchedAppItem = pcmodelDictionaryOptions.value.find(
item => item.dictLabel === selectedPcItem.dictLabel
);
if (matchedAppItem) {
form.value.pcModelDictionary = matchedAppItem.dictValue;
} else {
form.value.pcModelDictionary = '';
console.warn(`没有找到dictLabel为${selectedPcItem.dictLabel}的APP路由`);
}
};
/** 删除按钮操作 */
const handleDelete = async (row?: deviceTypeVO) => {
@ -313,7 +333,8 @@ const handleUpdate = async (row?: DeviceTypeForm) => {
const deviceData = row || ids.value[0];
Object.assign(form.value, deviceData);
// 确保数据类型正确
form.value.modelDictionary = String(form.value.modelDictionary || '');
form.value.appModelDictionary = String(form.value.appModelDictionary || '');
form.value.pcModelDictionary = String(form.value.pcModelDictionary || '');
form.value.locateMode = Number(form.value.locateMode) || 0;
form.value.communicationMode = Number(form.value.communicationMode) || 0;
} catch (error) {
@ -329,9 +350,9 @@ const submitForm = () => {
try {
const payload = {
...form.value,
appModelDictionary: form.value.modelDictionary,
pcModelDictionary:form.value.modelDictionary,
appModelDictionary: form.value.appModelDictionary,
pcModelDictionary: form.value.pcModelDictionary,
locateMode: Number(form.value.locateMode),
communicationMode: Number(form.value.communicationMode)
};
@ -368,5 +389,4 @@ onMounted(() => {
getDict();
pcgetDict() //pc跳转
});
</script>