物模型:表单添加加载状态
历史数据:原始数据限制单设备查询
This commit is contained in:
parent
c0993b0398
commit
8b4cbb1ede
@ -32,7 +32,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer v-if="modelDialogState !== ModelDialogTitleStateType['detail']">
|
<template #footer v-if="modelDialogState !== ModelDialogTitleStateType['detail']">
|
||||||
<el-button type="primary" @click="submitModelForm">保存</el-button>
|
<el-button type="primary" @click="submitModelForm" :loading="submitModelLoading">保存</el-button>
|
||||||
<el-button @click="cancelModelForm">取消</el-button>
|
<el-button @click="cancelModelForm">取消</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@ -285,7 +285,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button type="primary" @click="submitAttributeForm">保存</el-button>
|
<el-button type="primary" @click="submitAttributeForm" :loading="submitAttributeLoading">保存</el-button>
|
||||||
<el-button @click="closeAttributeForm">取消</el-button>
|
<el-button @click="closeAttributeForm">取消</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@ -308,7 +308,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button type="primary" @click="submitServiceForm">保存</el-button>
|
<el-button type="primary" @click="submitServiceForm" :loading="submitServiceLoading">保存</el-button>
|
||||||
<el-button @click="closeServiceForm">取消</el-button>
|
<el-button @click="closeServiceForm">取消</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@ -441,36 +441,48 @@ const modelFormRules = {
|
|||||||
iotModelCode: [{ required: true, message: '请输入物模型编码', trigger: 'blur' }],
|
iotModelCode: [{ required: true, message: '请输入物模型编码', trigger: 'blur' }],
|
||||||
objectType: [{ required: true, message: '请选择物模型类型', trigger: 'blur' }],
|
objectType: [{ required: true, message: '请选择物模型类型', trigger: 'blur' }],
|
||||||
}
|
}
|
||||||
|
const submitModelLoading = ref(false)
|
||||||
const submitModelForm = () => {
|
const submitModelForm = () => {
|
||||||
if (modelDialogState.value === ModelDialogTitleStateType['add']) {
|
modelFormRef.value?.validate((valid) => {
|
||||||
addModelReq(modelForm.value)
|
if (valid) {
|
||||||
.then((res) => {
|
submitModelLoading.value = true
|
||||||
if (res.success) {
|
if (modelDialogState.value === ModelDialogTitleStateType['add']) {
|
||||||
ElMessage.success('新增物模型成功')
|
addModelReq(modelForm.value)
|
||||||
modelDialogVisible.value = false
|
.then((res) => {
|
||||||
getModelList()
|
if (res.success) {
|
||||||
} else {
|
ElMessage.success('新增物模型成功')
|
||||||
ElMessage.error(res.msg)
|
modelDialogVisible.value = false
|
||||||
}
|
getModelList()
|
||||||
})
|
} else {
|
||||||
.catch((err) => {
|
ElMessage.error(res.msg)
|
||||||
ElMessage.error(err?.response?.data?.msg ?? '新增失败')
|
}
|
||||||
})
|
})
|
||||||
} else if (modelDialogState.value === ModelDialogTitleStateType['edit']) {
|
.catch((err) => {
|
||||||
updateModelReq(modelForm.value)
|
ElMessage.error(err?.response?.data?.msg ?? '新增失败')
|
||||||
.then((res) => {
|
})
|
||||||
if (res.success) {
|
.finally(() => {
|
||||||
ElMessage.success('修改物模型成功')
|
submitModelLoading.value = false
|
||||||
modelDialogVisible.value = false
|
})
|
||||||
getModelList()
|
} else if (modelDialogState.value === ModelDialogTitleStateType['edit']) {
|
||||||
} else {
|
updateModelReq(modelForm.value)
|
||||||
ElMessage.error(res.msg)
|
.then((res) => {
|
||||||
}
|
if (res.success) {
|
||||||
})
|
ElMessage.success('修改物模型成功')
|
||||||
.catch((err) => {
|
modelDialogVisible.value = false
|
||||||
ElMessage.error(err?.response?.data?.msg ?? '修改失败')
|
getModelList()
|
||||||
})
|
} else {
|
||||||
}
|
ElMessage.error(res.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
ElMessage.error(err?.response?.data?.msg ?? '修改失败')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
submitModelLoading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
const getModelList = (name?: string) => {
|
const getModelList = (name?: string) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
@ -837,9 +849,11 @@ const closeAttributeForm = () => {
|
|||||||
attributeForm.value = JSON.parse(JSON.stringify(originAttributeForm))
|
attributeForm.value = JSON.parse(JSON.stringify(originAttributeForm))
|
||||||
attributeFormRef.value?.resetFields()
|
attributeFormRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
const submitAttributeLoading = ref(false)
|
||||||
const submitAttributeForm = () => {
|
const submitAttributeForm = () => {
|
||||||
attributeFormRef.value?.validate((valid: boolean) => {
|
attributeFormRef.value?.validate((valid: boolean) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
submitAttributeLoading.value = true
|
||||||
const copyFormData = JSON.parse(JSON.stringify(attributeForm.value))
|
const copyFormData = JSON.parse(JSON.stringify(attributeForm.value))
|
||||||
copyFormData.highSpeed = copyFormData.highSpeed ? 1 : 0
|
copyFormData.highSpeed = copyFormData.highSpeed ? 1 : 0
|
||||||
copyFormData.visible = copyFormData.visible ? 1 : 0
|
copyFormData.visible = copyFormData.visible ? 1 : 0
|
||||||
@ -864,6 +878,9 @@ const submitAttributeForm = () => {
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
ElMessage.error(err?.response?.data?.msg ?? '新增失败')
|
ElMessage.error(err?.response?.data?.msg ?? '新增失败')
|
||||||
})
|
})
|
||||||
|
.finally(() => {
|
||||||
|
submitAttributeLoading.value = false
|
||||||
|
})
|
||||||
} else if (attributeFormTitle.value === AttributeDialogTitleStateType['edit']) {
|
} else if (attributeFormTitle.value === AttributeDialogTitleStateType['edit']) {
|
||||||
updateModelAttributeReq(copyFormData)
|
updateModelAttributeReq(copyFormData)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -878,6 +895,9 @@ const submitAttributeForm = () => {
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
ElMessage.error(err?.response?.data?.msg ?? '修改失败')
|
ElMessage.error(err?.response?.data?.msg ?? '修改失败')
|
||||||
})
|
})
|
||||||
|
.finally(() => {
|
||||||
|
submitAttributeLoading.value = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -905,9 +925,11 @@ const closeServiceForm = () => {
|
|||||||
serviceForm.value = JSON.parse(JSON.stringify(originServiceForm))
|
serviceForm.value = JSON.parse(JSON.stringify(originServiceForm))
|
||||||
serviceFormRef.value?.resetFields()
|
serviceFormRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
const submitServiceLoading = ref(false)
|
||||||
const submitServiceForm = () => {
|
const submitServiceForm = () => {
|
||||||
serviceFormRef.value?.validate((valid: boolean) => {
|
serviceFormRef.value?.validate((valid: boolean) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
submitServiceLoading.value = true
|
||||||
if (serviceFormTitle.value === serviceDialogTitleStateType['add']) {
|
if (serviceFormTitle.value === serviceDialogTitleStateType['add']) {
|
||||||
serviceForm.value.iotModelId = curContextMenuTreeData.value!.id!
|
serviceForm.value.iotModelId = curContextMenuTreeData.value!.id!
|
||||||
addModelServiceReq(serviceForm.value)
|
addModelServiceReq(serviceForm.value)
|
||||||
@ -923,6 +945,9 @@ const submitServiceForm = () => {
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
ElMessage.error(err?.response?.data?.msg ?? '新增失败')
|
ElMessage.error(err?.response?.data?.msg ?? '新增失败')
|
||||||
})
|
})
|
||||||
|
.finally(() => {
|
||||||
|
submitServiceLoading.value = false
|
||||||
|
})
|
||||||
} else if (serviceFormTitle.value === serviceDialogTitleStateType['edit']) {
|
} else if (serviceFormTitle.value === serviceDialogTitleStateType['edit']) {
|
||||||
updateModelServiceReq(serviceForm.value)
|
updateModelServiceReq(serviceForm.value)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -937,6 +962,9 @@ const submitServiceForm = () => {
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
ElMessage.error(err?.response?.data?.msg ?? '修改失败')
|
ElMessage.error(err?.response?.data?.msg ?? '修改失败')
|
||||||
})
|
})
|
||||||
|
.finally(() => {
|
||||||
|
submitServiceLoading.value = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
<div class="pointDialogColTitle">风机列表</div>
|
<div class="pointDialogColTitle">风机列表</div>
|
||||||
<div class="pointDialogColContent">
|
<div class="pointDialogColContent">
|
||||||
<el-scrollbar>
|
<el-scrollbar>
|
||||||
<el-checkbox-group v-model="selectWindBlower">
|
<el-checkbox-group v-model="selectWindBlower" :max="searchData.interval === 'NONE' ? 1 : 99">
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-for="v in windBlowerOptions"
|
v-for="v in windBlowerOptions"
|
||||||
:key="v.value"
|
:key="v.value"
|
||||||
|
Loading…
Reference in New Issue
Block a user