<template>
|
<el-dialog v-model="dialogVisible" :fullscreen="full" @close="resetForm(ruleFormRef)" :title="titles" width="50%" draggable>
|
<el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button>
|
<el-form :model="form" :disabled="disabled" ref="ruleFormRef" :rules="rules" label-width="120px">
|
<el-row>
|
<el-col :span="11">
|
<el-form-item label="是否为设备内容" size="default" prop="isContent">
|
<el-select v-model="form.isContent" placeholder="请选择" style="width: 100%">
|
<el-option label="是" value="1" />
|
<el-option label="否" value="2" />
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="11" :offset="2">
|
<el-form-item label="父级编号" size="default" prop="parentId">
|
<el-tree-select clearable check-strictly="true" v-model="form.parentId" :data="data" :props="propst" class="w100" placeholder="请选择" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="11">
|
<el-form-item label="类别名称" size="default" prop="typeName">
|
<el-input v-model="form.typeName" />
|
</el-form-item>
|
</el-col>
|
<el-col :span="11" :offset="2">
|
<el-form-item label="排列序列" size="default" prop="sortNum">
|
<el-input v-model.number="form.sortNum" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="resetForm(ruleFormRef)">关闭</el-button>
|
<el-button type="primary" @click="submitForm(ruleFormRef)">确定</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</template>
|
<script lang="ts">
|
import { defineComponent, ref, reactive } from 'vue';
|
import type { FormInstance, FormRules } from 'element-plus';
|
import { FullScreen } from '@element-plus/icons-vue';
|
import { facilityManagementApi } from '/@/api/facilityManagement';
|
import { ElMessage } from 'element-plus';
|
import { type } from 'os';
|
export default defineComponent({
|
setup(prpos, { emit }) {
|
const dialogVisible = ref(false);
|
const form = ref({
|
isContent: '', ////是否为设备内容 1:是 2:否
|
typeName: '', ////类别名称
|
parentId: "", ////父级ID,如果没有父级,为0
|
isCheck: 0, ////是否检测 1:是 2:否
|
isVisit: 0, ////是否巡检 1:是 2:否
|
sortNum: '', //排列序列
|
id: '', //设备类型ID ,更新时必填
|
});
|
const titles = ref();
|
const disabled = ref(false);
|
const openDailog = (title: string, id: number) => {
|
listApi();
|
dialogVisible.value = true;
|
titles.value = `${title}设备设施类型管理`;
|
if (title == '查看') {
|
disabled.value = true;
|
detail(id);
|
} else if (title == '修改') {
|
detail(id);
|
} else if (title == '添加') {
|
form.value.parentId=id
|
}
|
};
|
const detail = (id: number) => {
|
facilityManagementApi()
|
.getequipmentTypeMngDetail(id)
|
.then((res) => {
|
if (res.data.code == 200) {
|
form.value = res.data.data;
|
} else {
|
ElMessage({
|
showClose: true,
|
message: res.data.msg,
|
type: 'error',
|
});
|
}
|
});
|
};
|
// 列表
|
const listApi = () => {
|
facilityManagementApi()
|
.getequipmentTypeMngTreeData()
|
.then((res) => {
|
if (res.data.code == 200) {
|
data.value = res.data.data;
|
} else {
|
ElMessage({
|
showClose: true,
|
message: res.data.msg,
|
type: 'error',
|
});
|
}
|
});
|
};
|
const data = ref([]);
|
const propst = {
|
label: 'typeName',
|
children: 'childList',
|
value: 'id',
|
};
|
const ruleFormRef = ref<FormInstance>();
|
const rules = reactive<FormRules>({
|
isContent: [{ required: true, message: '是否为设备内容不能为空', trigger: 'change' }],
|
parentId: [],
|
typeName: [{ required: true, message: '类别名称不能为空', trigger: 'change' }],
|
sortNum: [
|
{ required: true, message: '排列序列不能为空', trigger: 'change' },
|
{ type: 'number', message: '请输入数字!', trigger: 'change' },
|
],
|
});
|
const submitForm = async (formEl: FormInstance | undefined) => {
|
if (!formEl) return;
|
await formEl.validate((valid, fields) => {
|
if (valid) {
|
facilityManagementApi()
|
.getequipmentTypeMngAddOrUpdate(form.value)
|
.then((res) => {
|
if (res.data.code == 200) {
|
dialogVisible.value = false;
|
ElMessage({
|
showClose: true,
|
message: res.data.msg,
|
type: 'success',
|
});
|
emit('onAdd');
|
formEl.resetFields();
|
} else {
|
ElMessage({
|
showClose: true,
|
message: res.data.msg,
|
type: 'error',
|
});
|
}
|
});
|
} else {
|
console.log('error submit!', fields);
|
}
|
});
|
};
|
const resetForm = (formEl: FormInstance | undefined) => {
|
if (!formEl) return;
|
formEl.resetFields();
|
dialogVisible.value = false;
|
};
|
//全屏
|
const full = ref(false);
|
const toggleFullscreen = () => {
|
if (full.value == false) {
|
full.value = true;
|
} else {
|
full.value = false;
|
}
|
};
|
return {
|
detail,
|
rules,
|
ruleFormRef,
|
listApi,
|
propst,
|
submitForm,
|
resetForm,
|
data,
|
disabled,
|
dialogVisible,
|
form,
|
titles,
|
openDailog,
|
full,
|
toggleFullscreen,
|
FullScreen,
|
};
|
},
|
});
|
</script>
|
<style scoped>
|
.el-row {
|
padding: 0 0 20px 0;
|
}
|
</style>
|