Files
ba_web/src/views/Training/SecurityTrainingVideo/components/detailForm.vue
2025-09-26 12:56:52 +08:00

92 lines
2.5 KiB
Vue

<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" />
</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"]);
const { proxy } = getCurrentInstance();
const dialogForm = ref(false);
const title = ref('');
const FormRef = ref();
const loading = ref(false);
const listQuery = ref({});
const openType = ref("")
const rules = reactive({
spbt: [{ required: true, message: "请输入视频标题", trigger: "blur" }],
fjid: [{ required: true, message: "请上传视频附件", trigger: "blur" }],
});
const formList = reactive([
[
{ label: "视频标题", prop: "spbt", type: "input" },
],
[
{ label: "附件", prop: "fjid", type: "upload",isImg:false,showBtn:true,limit:2 ,isAll:true},
],
])
// 初始化数据
const init = (type, row = {}) => {
dialogForm.value = true;
openType.value = type;
title.value = type == "add" ? "新增" : "编辑";
if(row) getDateById(row.id)
};
const getDateById = (id) =>{
qcckPost({},'/bagl/mosty-base/baxx/sok/getInfo/'+id).then(res=>{
res.fjid = res.fjid ? JSON.parse(res.fjid):[];
listQuery.value = res || {}
})
}
const save = () => {
FormRef.value.submit((val)=>{
loading.value = true;
let url = title.value == '新增' ? `/bagl/mosty-base/baxx/sok/add` : `/bagl/mosty-base/baxx/sok/edit`;
let params = {...val }
params.fjid = params.fjid ? JSON.stringify(params.fjid):''
qcckPost(params, url).then(() => {
loading.value = false;
proxy.$message.success("保存成功");
emit("refresh");
close();
}).catch(() => {
loading.value = false;
})
});
}
const close = () => {
dialogForm.value = false;
listQuery.value.fjid = []
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>