style:采集设备模型/采集设备-添加点位类型名称字段入参

main
黄伟杰 1 week ago
parent ccdc91aa76
commit 1038b701ee

@ -24,8 +24,9 @@
clearable
filterable
placeholder="请选择点位类型"
@change="handleAttributeTypeChange"
>
<el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.name" />
<el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="数据类型" prop="dataType">
@ -95,7 +96,8 @@ const formData = ref({
id: undefined as number | undefined,
attributeCode: undefined as string | undefined,
attributeName: undefined as string | undefined,
attributeType: undefined as string | undefined,
attributeType: undefined as number | undefined,
typeName: undefined as string | undefined,
dataType: undefined as string | undefined,
address: undefined as string | undefined,
dataUnit: undefined as string | undefined,
@ -140,6 +142,13 @@ const handleSortInput = (val: string) => {
formData.value.sort = val?.replace(/\D/g, '')
}
const handleAttributeTypeChange = (val: number | string) => {
const matched = typeList.value.find(
(item) => item.id === val || String(item.id) === String(val)
)
formData.value.typeName = matched?.name
}
const formRules = reactive({
attributeCode: [
{ required: true, message: '点位编码不能为空', trigger: 'blur' },
@ -196,6 +205,7 @@ const buildSubmitData = () => {
attributeCode,
attributeName,
attributeType,
typeName,
dataType,
address,
dataUnit,
@ -215,6 +225,7 @@ const buildSubmitData = () => {
attributeCode,
attributeName,
attributeType,
typeName,
dataType,
address,
dataUnit,
@ -255,13 +266,14 @@ const open = async (type: string, id?: number, deviceId: number) => {
if (currentType !== undefined && currentType !== null && currentType !== '') {
const matched = typeList.value.find(
(item) =>
item.name === currentType ||
item.id === currentType ||
item.code === currentType ||
String(item.id) === String(currentType)
String(item.id) === String(currentType) ||
item.name === currentType ||
item.code === currentType
)
if (matched?.name) {
;(formData.value as any).attributeType = matched.name
if (matched) {
;(formData.value as any).attributeType = matched.id
;(formData.value as any).typeName = matched.name
}
}
} finally {
@ -302,6 +314,7 @@ const resetForm = () => {
attributeCode: undefined,
attributeName: undefined,
attributeType: undefined,
typeName: undefined,
dataType: undefined,
address: undefined,
dataUnit: undefined,

@ -20,6 +20,7 @@
filterable
placeholder="请选择点位类型"
class="!w-180px"
@change="handleAttributeTypeChange"
>
<el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
@ -92,17 +93,18 @@ const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
attributeCode: undefined,
attributeName: undefined,
attributeType: undefined,
dataType: undefined,
address: undefined,
dataUnit: undefined,
ratio: undefined,
remark: undefined,
deviceModelId: undefined,
})
id: undefined,
attributeCode: undefined,
attributeName: undefined,
attributeType: undefined,
typeName: undefined,
dataType: undefined,
address: undefined,
dataUnit: undefined,
ratio: undefined,
remark: undefined,
deviceModelId: undefined,
})
const formRules = reactive({
attributeCode: [{ required: true, message: '点位编码不能为空', trigger: 'blur' }],
attributeName: [{ required: true, message: '点位名称不能为空', trigger: 'blur' }],
@ -122,6 +124,21 @@ const open = async (type: string, id: number, modelId: number) => {
formLoading.value = true
try {
formData.value = await DeviceModelAttributeApi.getDeviceModelAttribute(id)
const currentType = (formData.value as any)?.attributeType
if (currentType !== undefined && currentType !== null && currentType !== '') {
const matched = typeList.value.find(
(item) =>
item.id === currentType ||
String(item.id) === String(currentType) ||
item.name === currentType ||
item.code === currentType
)
if (matched) {
;(formData.value as any).attributeType = matched.id
;(formData.value as any).typeName = matched.name
}
}
} finally {
formLoading.value = false
}
@ -153,6 +170,13 @@ const submitForm = async () => {
}
}
const handleAttributeTypeChange = (val: number | string) => {
const matched = typeList.value.find(
(item) => item.id === val || String(item.id) === String(val)
)
;(formData.value as any).typeName = matched?.name
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
@ -160,6 +184,7 @@ const resetForm = () => {
attributeCode: undefined,
attributeName: undefined,
attributeType: undefined,
typeName: undefined,
dataType: undefined,
address: undefined,
dataUnit: undefined,

@ -93,10 +93,6 @@ const render = (data: any = []) => {
x = []
y = []
}
// 使
// APImockfallback
//
chart.setOption({
backgroundColor: 'transparent',

Loading…
Cancel
Save