feat:bug修改
This commit is contained in:
1 parent
9005953114
commit
5e7dd66971
3 files changed
+39
-27
No files matched your search
@@ -1,13 +1,6 @@
|
||||
<template>
|
||||
<el-select
|
||||
:model-value="modelValue"
|
||||
:placeholder="placeholder"
|
||||
:multiple="multiple"
|
||||
:disabled="disabled"
|
||||
:clearable="clearable"
|
||||
class="w-full"
|
||||
@update:model-value="handleChange"
|
||||
>
|
||||
<el-select :model-value="modelValue" :placeholder="placeholder" :multiple="multiple" :disabled="disabled"
|
||||
:clearable="clearable" class="w-full" @update:model-value="handleChange">
|
||||
<el-option v-for="item in dictData" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</template>
|
||||
@@ -52,11 +45,11 @@ const dictList = ref<DictOption[]>([]);
|
||||
|
||||
async function loadDictData() {
|
||||
if (props.dictType) {
|
||||
const res = await getDicts(props.dictType);
|
||||
dictList.value = res.data.map((p: any) => ({
|
||||
label: p.label,
|
||||
value: p.value
|
||||
}));
|
||||
const res = await getDicts(props.dictType);
|
||||
dictList.value = res.data.map((p: any) => ({
|
||||
label: p.label,
|
||||
value: p.value
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
<template>
|
||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="120px" v-loading="loading">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="分组名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入分组名称" />
|
||||
<el-input :disabled="form.bizType == '1'" v-model="form.name" placeholder="请输入分组名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="大屏预览分组" prop="bizType">
|
||||
<dict-select v-model="form.panelViewCodes" :options="panel_type" multiple placeholder="请选择大屏预览分组" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
@@ -47,12 +53,13 @@ const dataFormRef = ref();
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
// 定义字典
|
||||
|
||||
const { panel_type } = useDict("panel_type")
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: '',
|
||||
name: '',
|
||||
bizType: '',
|
||||
panelViewCodes: [],
|
||||
sort: '',
|
||||
});
|
||||
|
||||
@@ -87,7 +94,11 @@ const onSubmit = async () => {
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
form.id ? await deviceGroupApi.putObj(form) : await deviceGroupApi.addObj(form);
|
||||
const _form: any = { ...form }
|
||||
if (_form.panelViewCodes && _form.panelViewCodes.length) {
|
||||
_form.panelViewCodes = _form.panelViewCodes.join(',')
|
||||
}
|
||||
form.id ? await deviceGroupApi.putObj(_form) : await deviceGroupApi.addObj(_form);
|
||||
useMessage().success(form.id ? '修改成功' : '添加成功');
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
@@ -100,14 +111,19 @@ const onSubmit = async () => {
|
||||
|
||||
|
||||
// 初始化表单数据
|
||||
const getdeviceGroupData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
deviceGroupApi.getObj(id).then((res: any) => {
|
||||
Object.assign(form, res.data)
|
||||
}).finally(() => {
|
||||
const getdeviceGroupData = async (id: string) => {
|
||||
try {
|
||||
loading.value = true
|
||||
const { code, data } = await deviceGroupApi.getObj(id)
|
||||
if (data.panelViewCodes) {
|
||||
data.panelViewCodes = data.panelViewCodes.split(',')
|
||||
}
|
||||
Object.assign(form, data)
|
||||
} catch (error) {
|
||||
console.error("|初始化表单数据|意外的错误:", error);
|
||||
} finally {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
<el-form-item style="width: 250px;" label="类型" prop="bizType">
|
||||
<dict-select v-model="state.queryForm.bizType" :options="device_group_type" placeholder="请选择类型" />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 300px;" label="大屏预览分组" prop="panelViewCodes">
|
||||
<dict-select v-model="state.queryForm.panelViewCodes" :options="panel_type" placeholder="请选择大屏预览分组" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" @click="getDataList">
|
||||
{{ $t('common.queryBtn') }}
|
||||
@@ -53,7 +56,7 @@
|
||||
<el-button icon="VideoPlay" text type="primary" @click="cameraTableDialogRef.openDialog(row.id)">
|
||||
摄像头
|
||||
</el-button>
|
||||
<el-button v-if="row.bizType != 1" icon="edit-pen" text type="primary" v-auth="'device_deviceGroup_edit'"
|
||||
<el-button icon="edit-pen" text type="primary" v-auth="'device_deviceGroup_edit'"
|
||||
@click="formDialogRef.openDialog(row.id)">
|
||||
编辑
|
||||
</el-button>
|
||||
@@ -86,7 +89,7 @@ const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
const CameraTableDialog = defineAsyncComponent(() => import('./camera-table-dialog.vue'));
|
||||
|
||||
// 定义查询字典
|
||||
const { device_group_type } = useDict("device_group_type")
|
||||
const { device_group_type, panel_type } = useDict("device_group_type", "panel_type")
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref()
|
||||
const cameraTableDialogRef = ref()
|
||||
|
||||
Reference in new issue
Block a user