Files
ba_web/src/views/Training/SecurityTrainingSyllabus/components/detailForm.vue

103 lines
2.6 KiB
Vue
Raw Normal View History

2025-09-22 17:16:42 +08:00
<template>
<div class="dialog" v-if="dialogForm">
<div class="head_box">
<span class="title">保安培训教学大纲{{ title }}</span>
<div>
<el-button size="small" v-if="openType != 'detail'" @click="save" type="primary" :loading="loading">保存</el-button>
<el-button size="small" @click="close">关闭</el-button>
</div>
</div>
<div class="cntinfo">
<FormMessage ref="FormRef" v-model="listQuery" :disabled="openType == 'detail'" :rules="rules" :formList="formList">
</FormMessage>
</div>
</div>
</template>
<script setup>
import { qcckPost , qcckGet} from "@/api/qcckApi.js";
import FormMessage from "@/components/aboutTable/FormMessage.vue";
import { ref, reactive,defineEmits,getCurrentInstance } from 'vue';
const emit = defineEmits(["refresh"]);
2025-09-24 19:26:59 +08:00
const props = defineProps({
dic: {
type: Object,
default: () => {}
}
})
2025-09-22 17:16:42 +08:00
const { proxy } = getCurrentInstance();
const dialogForm = ref(false);
const title = ref('');
const FormRef = ref();
const loading = ref(false);
const listQuery = ref({});
const openType = ref("")
2025-09-24 17:35:24 +08:00
2025-09-22 17:16:42 +08:00
const rules = reactive({
pxlx: [{ required: true, message: "请输入视频标题", trigger: "blur" }],
});
const formList = reactive([
[
2025-09-24 19:26:59 +08:00
{ label: "培训类型", prop: "pxlx", type: "select", options: props.dic.D_PXDG_PXLX },
2025-09-22 17:16:42 +08:00
{ label: "教学项目", prop: "jxxm", type: "input" },
],
2025-09-22 19:04:13 +08:00
[
2025-09-24 19:26:59 +08:00
{ label: "教学内容", prop: "dgnr", type: "input" },
2025-09-22 19:04:13 +08:00
{ label: "教学目标", prop: "jxmb", type: "input" },
],
[
2025-09-24 20:30:47 +08:00
{ label: "学时安排", prop: "gksc", type: "input" },
2025-09-22 19:04:13 +08:00
],
[
2025-09-24 19:26:59 +08:00
{ label: "上传附件", prop: "fj", type: "upload" },
2025-09-22 19:04:13 +08:00
],
2025-09-22 17:16:42 +08:00
])
// 初始化数据
const init = (type, id,) => {
dialogForm.value = true;
openType.value = type;
title.value = type == "add" ? "新增" : "编辑";
if(id) getDateById(id)
};
2025-09-24 19:26:59 +08:00
function getDateById (id) {
qcckPost({},`/mosty-base/baxx/jxda/getInfo/${id}`).then((res) => {
listQuery.value = res || {};
})
}
2025-09-22 17:16:42 +08:00
const save = () => {
FormRef.value.submit(()=>{
2025-09-24 19:26:59 +08:00
loading.value = true;
let url = title.value == '新增' ? `/mosty-base/baxx/jxda/add` : `/mosty-base/baxx/jxda/edit`;
qcckPost(listQuery.value, url).then(() => {
loading.value = false;
2025-09-22 17:16:42 +08:00
proxy.$message.success("保存成功");
2025-09-24 19:26:59 +08:00
emit("refresh");
2025-09-22 17:16:42 +08:00
close();
2025-09-24 19:26:59 +08:00
}).catch(() => {
loading.value = false;
})
2025-09-22 17:16:42 +08:00
});
}
const close = () => {
dialogForm.value = false;
2025-09-24 19:26:59 +08:00
listQuery.value = {fj:''}
2025-09-22 17:16:42 +08:00
FormRef.value.reset()
};;
defineExpose({init})
</script>
<style lang="scss" scoped>
@import "@/assets/css/layout.scss";
.mapBox{
width: calc(100% - 24rem);
height:500px;
overflow: hidden;
margin: 0 12rem;
}
</style>