<template>
|
<div class="system-add-menu-container">
|
<el-dialog :title="title" v-model="isShowApproveBasicDialog" width="600px" :close-on-click-modal="false">
|
<el-form :model="approveBasicForm" :rules="approveBasicFormRules" ref="approveBasicFormRef" size="default" label-width="120px">
|
<el-row :gutter="35">
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="标题" prop="title">
|
<el-input class="input-add" :disabled="!disabled" v-model.trim="approveBasicForm.title" placeholder="请输入标题名称" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="标准类型" prop="ruleStandType">
|
<el-select class="input-add" :disabled="!disabled" v-model="approveBasicForm.ruleStandType" placeholder="请选择标准类型" clearable filterable>
|
<el-option v-for="item in ruleStandTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="最大值" prop="maxVal">
|
<el-input :disabled="!disabled" v-model="approveBasicForm.maxVal" type="number" class="input-add" placeholder="请根据需求选择">
|
<template #prepend>
|
<el-select :disabled="!disabled" v-model="approveBasicForm.maxValMatchPattern" placeholder="请根据需求选择" style="width: 115px">
|
<el-option v-for="item in typeTwoList" :key="item.id" :value="item.id" :label="item.name"> </el-option>
|
</el-select>
|
</template>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="最小值" prop="minVal">
|
<el-input :disabled="!disabled" v-model="approveBasicForm.minVal" type="number" class="input-add" placeholder="请根据需求选择">
|
<template #prepend>
|
<el-select :disabled="!disabled" v-model="approveBasicForm.minValMatchPattern" placeholder="请根据需求选择" style="width: 115px">
|
<el-option v-for="item in typeList" :key="item.id" :value="item.id" :label="item.name"> </el-option>
|
</el-select>
|
</template>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="描述" prop="info">
|
<el-input class="input-add" :rows="3" :disabled="!disabled" v-model.trim="approveBasicForm.info" type="textarea" placeholder="请输入描述"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-show="personTime">
|
<el-form-item label="创建人" prop="createUname">
|
<el-input class="input-add" :disabled="!disabled" v-model.trim="approveBasicForm.createUname"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-show="personTime">
|
<el-form-item label="创建时间" prop="gmtCreate">
|
<el-input class="input-add" :disabled="!disabled" v-model.trim="approveBasicForm.gmtCreate"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-show="personTime">
|
<el-form-item label="最后修改人" prop="modifiedUname">
|
<el-input class="input-add" :disabled="!disabled" v-model.trim="approveBasicForm.modifiedUname"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-show="personTime">
|
<el-form-item label="最后修改时间" prop="gmtModified">
|
<el-input class="input-add" :disabled="!disabled" v-model.trim="approveBasicForm.gmtModified"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer" v-show="disabled">
|
<el-button @click="isShowApproveBasicDialog = !isShowApproveBasicDialog" size="default">取 消</el-button>
|
<el-button type="primary" @click="submitApproveBasic" v-throttle size="default">确 定</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script lang="ts">
|
interface stateType {
|
isShowApproveBasicDialog: Boolean;
|
disabled: Boolean;
|
personTime: Boolean;
|
approveBasicForm: {
|
ruleStandId: null | number;
|
ruleStandType: null | number;
|
minVal: null | number;
|
minValMatchPattern: null;
|
maxVal: null | number;
|
maxValMatchPattern: null | number;
|
title: null | string;
|
info: null | string;
|
};
|
title: string;
|
departmentList: [];
|
ruleStandTypeList: Array<levelListState>;
|
typeList: Array<levelListState>;
|
typeTwoList: Array<levelListState>;
|
approveBasicFormRules: {};
|
}
|
interface levelListState {
|
id: number;
|
name: string;
|
}
|
interface approveBasicForm {
|
ruleStandId: null | number;
|
ruleStandType: null | number;
|
minVal: null | number;
|
minValMatchPattern: null;
|
maxVal: null | number;
|
maxValMatchPattern: null | number;
|
title: null | string;
|
info: null | string;
|
}
|
|
import { reactive, toRefs, ref } from 'vue';
|
import { approveBasicApi } from '/@/api/specialWorkSystem/approveBasic';
|
import { ElMessage } from 'element-plus';
|
export default {
|
name: 'approveBasicDialog',
|
setup(props: any, context: any) {
|
const approveBasicFormRef = ref();
|
const state = reactive<stateType>({
|
title: '',
|
disabled: false,
|
personTime: false,
|
departmentList: [],
|
isShowApproveBasicDialog: false,
|
ruleStandTypeList: [
|
{ id: 1, name: '可燃气浓度' },
|
{ id: 2, name: '氧气浓度' },
|
{ id: 3, name: '一氧化碳浓度' },
|
{ id: 4, name: '硫化氢浓度' },
|
{ id: 5, name: '温度' },
|
{ id: 6, name: '压力' },
|
{ id: 7, name: '震动' }
|
],
|
typeList: [
|
{ id: 1, name: '大于' },
|
{ id: 2, name: '等于' },
|
{ id: 4, name: '大于等于' }
|
],
|
typeTwoList: [
|
{ id: 3, name: '小于' },
|
{ id: 2, name: '等于' },
|
{ id: 5, name: '小于等于' }
|
],
|
approveBasicForm: {
|
ruleStandId: null,
|
ruleStandType: null,
|
minVal: null,
|
minValMatchPattern: null,
|
maxVal: null,
|
maxValMatchPattern: null,
|
title: null,
|
info: null
|
},
|
approveBasicFormRules: {
|
ruleStandType: [{ required: true, message: '请选择标准类型', trigger: 'change' }],
|
minVal: [{ required: true, message: '请填写标最低值', trigger: 'blur' }],
|
maxVal: [{ required: true, message: '请填写标最高值', trigger: 'blur' }],
|
title: [{ required: true, message: '请选择风险等级', trigger: 'blur' }],
|
info: [{ required: true, message: '请填写描述信息', trigger: 'blur' }]
|
}
|
});
|
|
//打开模态框
|
const showApproveBasicDialog = (type: string, value: object, department: []) => {
|
state.isShowApproveBasicDialog = true;
|
state.departmentList = department;
|
setTimeout(() => {
|
approveBasicFormRef.value.clearValidate();
|
});
|
if (type === '新增') {
|
state.disabled = true;
|
state.personTime = false;
|
state.title = '新增审批标准';
|
state.approveBasicForm = {
|
ruleStandId: null,
|
ruleStandType: null,
|
minVal: null,
|
minValMatchPattern: null,
|
maxVal: null,
|
maxValMatchPattern: null,
|
title: null,
|
info: null
|
};
|
} else if (type === '查看') {
|
state.disabled = false;
|
state.personTime = true;
|
state.title = '查看审批标准';
|
state.approveBasicForm = JSON.parse(JSON.stringify(value));
|
} else {
|
state.disabled = true;
|
state.personTime = false;
|
state.title = '修改审批标准';
|
state.approveBasicForm = JSON.parse(JSON.stringify(value));
|
// for (let i in state.approveBasicForm) {
|
// state.approveBasicForm[i] = approveBasicForm[i];
|
// }
|
}
|
};
|
|
//新增修改提交
|
const submitApproveBasic = async () => {
|
approveBasicFormRef.value.validate(async (valid: Boolean) => {
|
if (valid) {
|
if (state.title === '新增审批标准') {
|
let res = await approveBasicApi().addApproveBasic(state.approveBasicForm);
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
message: '审批标准新增成功',
|
duration: 2000
|
});
|
state.isShowApproveBasicDialog = false;
|
context.emit('refreshApproveBasic');
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
} else {
|
let res = await approveBasicApi().modApproveBasic(state.approveBasicForm);
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
message: '审批标准修改成功',
|
duration: 2000
|
});
|
state.isShowApproveBasicDialog = false;
|
context.emit('refreshApproveBasic');
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
}
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: '请完善基本信息'
|
});
|
}
|
});
|
};
|
|
return {
|
...toRefs(state),
|
approveBasicFormRef,
|
submitApproveBasic,
|
showApproveBasicDialog
|
};
|
}
|
};
|
</script>
|
|
<style scoped></style>
|