forked from dyf/dyf-vue-ui
增加类型字典code
This commit is contained in:
@ -40,6 +40,11 @@
|
||||
<el-table v-loading="loading" border :data="deviceTypeList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="50" align="center" />
|
||||
<el-table-column label="型号名称" align="center" prop="typeName" />
|
||||
<el-table-column label="类型code" align="center" prop="modelDictionary">
|
||||
<template #default="scope">
|
||||
{{ modelDictionaryOptions.find(item => item.dictValue == scope.row.modelDictionary)?.dictLabel }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否支持蓝牙" align="center" prop="isSupportBle">
|
||||
<template #default="scope">
|
||||
{{ scope.row.isSupportBle ? '是' : '否' }}
|
||||
@ -90,6 +95,16 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="类型code" prop="modelDictionary">
|
||||
<el-select v-model="form.modelDictionary" placeholder="请选择">
|
||||
<el-option v-for="item in modelDictionaryOptions" :key="item.dictValue" :label="item.dictLabel"
|
||||
:value="item.dictValue" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="是否支持蓝牙" prop="isSupportBle">
|
||||
@ -137,24 +152,22 @@
|
||||
<script setup name="User" lang="ts">
|
||||
import api from '@/api/equipmentManagement/deviceType/index';
|
||||
import { deviceTypeQuery } from '@/api/equipmentManagement/deviceType/types';
|
||||
import { getDicts } from '@/api/system/dict/data';
|
||||
import { to } from 'await-to-js';
|
||||
import { ComponentInternalInstance, getCurrentInstance, onMounted, reactive, ref, toRefs } from 'vue';
|
||||
import { ElDialog, ElForm, ElFormItem, ElInput, ElRow, ElCol, ElButton, ElCard, ElSelect, ElOption, ElDatePicker, ElTable, ElTableColumn, ElTooltip, ElSwitch } from 'element-plus';
|
||||
|
||||
interface deviceTypeVO {
|
||||
id: string | number;
|
||||
typeName: string;
|
||||
isSupportBle: boolean;
|
||||
locateMode: string;
|
||||
modelDictionary: string;
|
||||
communicationMode: string;
|
||||
createTime: string;
|
||||
createByName: string;
|
||||
}
|
||||
|
||||
interface DeviceTypeForm extends deviceTypeVO {
|
||||
// 可能有其他字段
|
||||
}
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const deviceTypeList = ref<deviceTypeVO[]>();
|
||||
const loading = ref(true);
|
||||
@ -167,15 +180,16 @@ const queryFormRef = ref<InstanceType<typeof ElForm>>();
|
||||
const userFormRef = ref<InstanceType<typeof ElForm>>();
|
||||
const formDialogRef = ref<InstanceType<typeof ElDialog>>();
|
||||
const loadingIng = ref(false)
|
||||
const modelDictionaryOptions = ref<any[]>([]);
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: DeviceTypeForm = {
|
||||
typeName: '',
|
||||
isSupportBle: false,
|
||||
locateMode: '',
|
||||
modelDictionary: '',
|
||||
communicationMode: '',
|
||||
id: '',
|
||||
createTime: '',
|
||||
@ -193,6 +207,9 @@ const initData = {
|
||||
typeName: [
|
||||
{ required: true, message: '请输入设备类型名称', trigger: 'blur' },
|
||||
],
|
||||
modelDictionary: [
|
||||
{ required: true, message: '请选择类型code', trigger: 'blur' },
|
||||
],
|
||||
locateMode: [
|
||||
{ required: true, message: '请选择定位方式', trigger: 'blur' },
|
||||
],
|
||||
@ -218,7 +235,10 @@ const getList = async () => {
|
||||
deviceTypeList.value = res.rows;
|
||||
total.value = res.total;
|
||||
};
|
||||
|
||||
const getDict = async () => {
|
||||
const res = await getDicts('model_dictionary');
|
||||
modelDictionaryOptions.value = res.data;
|
||||
}
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
@ -278,11 +298,10 @@ const handleUpdate = async (row?: DeviceTypeForm) => {
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改设备类型';
|
||||
try {
|
||||
if (row) {
|
||||
Object.assign(form.value, row);
|
||||
} else {
|
||||
const selectedId = ids.value[0];
|
||||
Object.assign(form.value, selectedId);
|
||||
const deviceData = row || ids.value[0];
|
||||
Object.assign(form.value, deviceData);
|
||||
if (form.value.modelDictionary) {
|
||||
form.value.modelDictionary = String(form.value.modelDictionary);
|
||||
}
|
||||
} catch (error) {
|
||||
dialog.visible = false;
|
||||
@ -295,7 +314,11 @@ const submitForm = () => {
|
||||
if (valid) {
|
||||
loadingIng.value = true;
|
||||
try {
|
||||
form.value.id ? await api.updateDeviceType(form.value) : await api.addDeviceType(form.value);
|
||||
const payload = {
|
||||
...form.value,
|
||||
modelDictionary: Number(form.value.modelDictionary)
|
||||
};
|
||||
form.value.id ? await api.updateDeviceType(payload) : await api.addDeviceType(payload);
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
@ -325,6 +348,7 @@ const resetForm = () => {
|
||||
|
||||
onMounted(() => {
|
||||
getList(); // 初始化列表数据
|
||||
getDict();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user