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

92 lines
2.5 KiB
Vue
Raw Normal View History

2025-09-22 14:50:02 +08:00
<template>
<div class="dialog" v-if="dialogForm">
<div class="head_box">
2025-09-22 17:16:42 +08:00
<span class="title">保安视频库{{ title }}</span>
2025-09-22 14:50:02 +08:00
<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">
2025-09-24 20:32:05 +08:00
<FormMessage ref="FormRef" v-model="listQuery" :disabled="openType == 'detail'" :rules="rules" :formList="formList" />
2025-09-22 14:50:02 +08:00
</div>
</div>
</template>
<script setup>
import { qcckPost , qcckGet} from "@/api/qcckApi.js";
import FormMessage from "@/components/aboutTable/FormMessage.vue";
2025-09-22 17:16:42 +08:00
import { ref, reactive,defineEmits,getCurrentInstance } from 'vue';
2025-09-22 14:50:02 +08:00
const emit = defineEmits(["refresh"]);
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-22 14:50:02 +08:00
const rules = reactive({
2025-09-22 17:16:42 +08:00
spbt: [{ required: true, message: "请输入视频标题", trigger: "blur" }],
fjid: [{ required: true, message: "请上传视频附件", trigger: "blur" }],
2025-09-22 14:50:02 +08:00
});
2025-09-22 14:50:02 +08:00
const formList = reactive([
[
2025-09-22 17:16:42 +08:00
{ label: "视频标题", prop: "spbt", type: "input" },
2025-09-22 14:50:02 +08:00
],
[
2025-09-25 10:36:27 +08:00
{ label: "附件", prop: "fjid", type: "upload",isImg:false,showBtn:true,limit:2 ,isAll:true},
2025-09-22 14:50:02 +08:00
],
])
// 初始化数据
const init = (type, row = {}) => {
2025-09-22 14:50:02 +08:00
dialogForm.value = true;
openType.value = type;
2025-09-22 14:50:02 +08:00
title.value = type == "add" ? "新增" : "编辑";
2025-09-25 10:36:27 +08:00
if(row) getDateById(row.id)
2025-09-22 14:50:02 +08:00
};
2025-09-25 10:36:27 +08:00
const getDateById = (id) =>{
2025-09-26 12:56:52 +08:00
qcckPost({},'/bagl/mosty-base/baxx/sok/getInfo/'+id).then(res=>{
2025-09-25 10:36:27 +08:00
res.fjid = res.fjid ? JSON.parse(res.fjid):[];
listQuery.value = res || {}
})
}
2025-09-22 14:50:02 +08:00
const save = () => {
2025-09-25 10:36:27 +08:00
FormRef.value.submit((val)=>{
loading.value = true;
2025-09-26 12:56:52 +08:00
let url = title.value == '新增' ? `/bagl/mosty-base/baxx/sok/add` : `/bagl/mosty-base/baxx/sok/edit`;
2025-09-25 10:36:27 +08:00
let params = {...val }
params.fjid = params.fjid ? JSON.stringify(params.fjid):''
qcckPost(params, url).then(() => {
loading.value = false;
2025-09-22 14:50:02 +08:00
proxy.$message.success("保存成功");
emit("refresh");
2025-09-22 14:50:02 +08:00
close();
}).catch(() => {
loading.value = false;
})
2025-09-22 14:50:02 +08:00
});
}
const close = () => {
dialogForm.value = false;
2025-09-25 09:44:34 +08:00
listQuery.value.fjid = []
2025-09-22 14:50:02 +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>