<template>
|
<div class="system-add-user-container">
|
<el-dialog :title="title" v-model="isShowVideoDialog" width="50%">
|
<el-form :model="riskForm" size="default" ref="userRef" :rules="riskFormRules" label-width="120px">
|
<el-form-item label="风险辨识内容:" prop="content">
|
<el-input v-model.trim="riskForm.content" placeholder="请输入风险辨识内容" ></el-input>
|
</el-form-item>
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="isShowVideoDialog = !isShowVideoDialog" size="default">取 消</el-button>
|
<el-button v-if="!isDisabled" type="primary" v-throttle @click="onSubmit" size="default">确 定</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { reactive, toRefs, onMounted, defineComponent, ref } from 'vue';
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
import { saftyApi } from '/@/api/systemManage/saftyManage';
|
import {riskApi} from "/@/api/systemManage/riskManage";
|
|
// 定义接口来定义对象的类型
|
interface DeptData {}
|
interface sexData {}
|
interface UserState {
|
title: string;
|
isDisabled: boolean;
|
isShowVideoDialog: boolean;
|
riskForm: {
|
content: string | null;
|
|
};
|
riskFormRules:{
|
|
},
|
}
|
interface TypeList {
|
label: string,
|
value: number
|
}
|
export default defineComponent({
|
name: 'videoDialog',
|
setup(props, context) {
|
const userRef = ref()
|
const state = reactive<UserState>({
|
title: '',
|
isDisabled: false,
|
isShowVideoDialog: false,
|
riskForm: {
|
content: ''
|
},
|
riskFormRules:{
|
content: [{ required: true, message: '请填写风险辨识内容', trigger: 'blur' }],
|
},
|
});
|
// 打开弹窗
|
const openDialog = (type: string, value: any, departmentList: [], roleList: [], dutyList:[]) => {
|
state.isShowVideoDialog = true;
|
if (type === '新增') {
|
state.title = '新增风险辨识内容'
|
state.isDisabled = false
|
state.riskForm = {
|
content: ''
|
};
|
} else if(type === '编辑'){
|
state.title = '编辑风险辨识内容';
|
state.isDisabled = false
|
state.riskForm = JSON.parse(JSON.stringify(value));
|
}
|
};
|
|
// 新增修改
|
const onSubmit = async () => {
|
userRef.value.validate(async (valid:Boolean) => {
|
if(valid){
|
if (state.title === '新增风险辨识内容') {
|
let res = await riskApi().addRisk(state.riskForm);
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
message: '风险辨识内容新增成功',
|
duration: 2000
|
});
|
state.isShowVideoDialog = false;
|
context.emit('getRiskList');
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
} else {
|
let res = await riskApi().modRisk(state.riskForm);
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
message: '风险辨识内容修改成功',
|
duration: 2000
|
});
|
state.isShowVideoDialog = false;
|
context.emit('getRiskList');
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
}
|
}else{
|
ElMessage({
|
type:'warning',
|
message:'请完善基本信息'
|
})
|
}
|
})
|
|
};
|
|
// 页面加载时
|
onMounted(() => {});
|
return {
|
userRef,
|
openDialog,
|
onSubmit,
|
...toRefs(state)
|
};
|
}
|
});
|
</script>
|