dbsd_kczx/src/views/kc/zyJxdgBanben/ZyJxdgTeacherList.vue

768 lines
25 KiB
Vue

<template>
<div style="background: #fafafa; height: calc(100vh - 225px); overflow-y: auto; margin: 10px 0; padding: 8px 0 0 0">
<div v-if="showType == 0">
<a-row>
<a-col :span="24"><span class="title">教学大纲设置</span><a-divider /></a-col>
<div class="tishi">温馨提示:设置完成后,您也可以在课程教学过程中,随时根据实际情况进行调整。</div>
<div class="work-img">
<img class="work-img-img" src="../../../assets/images/homework.png" />
</div>
<a-col :span="24" style="text-align: center; color: #494b56">
<div>老师您好,</div>
<div>您还未填写教学大纲内容,请您及时填写教学大纲内容</div>
<div style="margin-top: 30px" class="ant-btn buttonClass"><a @click="handleShowType(1)">填写教学大纲内容</a></div>
</a-col>
</a-row>
</div>
<div v-if="showType == 1">
<a-row>
<a-col :span="24">
<span class="title">填写教学大纲内容</span>
<a-button type="primary" @click="init" style="float: right; margin-right: 8px"> <Icon icon="ant-design:export-outlined" />返回 </a-button>
<a-divider />
</a-col>
<a-col :span="24">
<a-row>
<a-col :span="24">
<span style="margin:10px;">请选择填写的教学大纲版本</span>
</a-col>
<a-col :span="24">
<a-table :columns="jxdgbbColumns" :dataSource="jxdgbbDataSource" :pagination="false">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-button type="primary" @click="handleCheckBanben(record)">选择</a-button>
</template>
</template>
</a-table>
</a-col>
</a-row>
</a-col>
<a-col>
<a-row>
<a-col :span="24" v-for="(item, index) in zyJxdgMainTable.dataSource" :key="index">
<a-row>
<a-col :span="24" style="margin-bottom: 15px; height: 40px; margin-top: 15px; background-color: rgba(1, 156, 136, 0.1)">
<span class="title">{{ item.title }}</span>
</a-col>
<!-- 单行文本 1 -->
<a-col v-if="item.type === '1'" :span="24">
<a-input placeholder="请输入内容" v-model:value="item.content" style="width: 100%" @blur="handleGlxm(item)"></a-input>
</a-col>
<!-- 多行文本 2 -->
<a-col v-else-if="item.type === '2'" :span="24">
<a-textarea placeholder="请输入内容" v-model:value="item.content" style="width: 100%"></a-textarea>
</a-col>
<!-- 富文本 3 -->
<a-col v-else-if="item.type === '3'" :span="24">
<j-editor placeholder="请输入内容" v-model:value="item.content" :disabled="disabled" />
</a-col>
<!-- 固定表单(基础信息) 4 -->
<a-col v-else-if="item.type === '4'" v-model:value="item.content" :span="24">
<a-form v-bind="formItemLayout">
<a-row>
<a-col v-for="(item2, index2) in item.zyJxdgPzxxList" :key="index2" :span="12">
<a-form-item :label="item2.title"
><a-input :placeholder="`请输入` + item2.title" v-model:value="item2.content"
/></a-form-item>
</a-col>
</a-row>
</a-form>
</a-col>
<!-- 自增表格 5 -->
<a-col v-else-if="item.type === '5'" :span="24">
<a-table :columns="getTableColumns(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
<template #bodyCell="{ column, record }">
<a-input placeholder="请输入内容" v-model:value="record[column.key]" style="width: 80%"></a-input>
</template>
</a-table>
</a-col>
<!-- 自增单行文本 6 -->
<a-col v-else-if="item.type === '6'" :span="24">
<a-row>
<a-col>
<a-button type="primary" @click="handleDhwb(item)" class="increase" preIcon="ant-design:plus-outlined">添加</a-button>
</a-col>
<a-col v-for="(item2, index2) in item.list" :key="index2">
<a-input
placeholder="请输入内容"
v-model:value="item2.title"
style="width: 80%; margin: 0 10px 10px 0px"
@blur="handleGlxm(item)"
></a-input>
<a-button type="danger" @click="handleDhwbDel(item, index2)">删除</a-button>
</a-col>
</a-row>
</a-col>
<!-- 自增富文本 7 -->
<a-col v-else-if="item.type === '7'" :span="24">
<a-row>
<a-col>
<a-button type="primary" @click="handleDhfwb(item)" class="increase" preIcon="ant-design:plus-outlined">添加</a-button>
</a-col>
<a-col v-for="(item2, index2) in item.list" :key="index2">
<j-editor placeholder="请输入内容" v-model:value="item2.title" :disabled="disabled" />
<a-button type="danger" @click="handleDhfwbDel(item, index2)" style="margin-top: 10px"></a-button>
</a-col>
</a-row>
</a-col>
<!-- 自增多行文本 8 -->
<a-col v-else-if="item.type === '8'" :span="24">
<a-row>
<a-col>
<a-button type="primary" @click="handleDhwbArea(item)" class="increase" preIcon="ant-design:plus-outlined">添加</a-button>
</a-col>
<a-col v-for="(item2, index2) in item.list" :key="index2" style="text-align: right">
<a-textarea placeholder="请输入内容" v-model:value="item2.title" :disabled="disabled" />
<a-button type="danger" @click="handleDhwbAreaDel(item, index2)" class="place-dele">删除</a-button>
</a-col>
</a-row>
</a-col>
<!-- 自增表格 9 -->
<a-col v-else-if="item.type === '9'" :span="24">
<div><a-button type="primary" @click="handleZzbg(item)" class="increase" preIcon="ant-design:plus-outlined">新增</a-button> </div>
<a-table :columns="getTableZzColumns(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-button type="danger" @click="handleZzbgDel(item.list, record.sort)">删除</a-button>
</template>
<template v-else>
<a-input placeholder="请输入内容" v-model:value="record[column.key]" style="width: 100%"></a-input>
</template>
</template>
</a-table>
</a-col>
<!-- 自增表格(两列关联) 10 -->
<a-col v-else-if="item.type === '10'" :span="24">
<div><a-button type="primary" @click="handleZzbg(item)" class="increase" preIcon="ant-design:plus-outlined">新增</a-button> </div>
<a-table :columns="getTableZzColumns(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-button type="danger" @click="handleZzbgDel(item.list, record.sort)">删除</a-button>
</template>
<template v-else>
<a-input
placeholder="请输入内容"
v-model:value="record[column.key]"
@blur="handleTwoGlxm(item)"
style="width: 100%"
></a-input>
</template>
</template>
</a-table>
</a-col>
<a-col v-else> </a-col>
<a-col :span="24" v-if="item.tsy">
<span class="tishi">
<span>{{ item.tsy }}</span>
</span>
</a-col>
</a-row>
</a-col>
</a-row>
</a-col>
<a-col :span="24" style="text-align: center" v-if="jxdgInfo.banbenId">
<a-button type="primary" @click="submitForm">保存</a-button>
</a-col>
</a-row>
</div>
<div v-if="showType == 999">
<a-row>
<a-col :span="24">
<span class="title">教学大纲内容</span>
<a-button type="primary" @click="handleShowType(2)" style="float: right; margin-right: 8px"> <Icon icon="ant-design:form-outlined" />编辑 </a-button>
<a-button type="primary" @click="handleFabu(1)" style="float: right; margin-right: 8px" v-if="jxdgInfo.sffb == '0'"> <Icon icon="ant-design:check-outlined"/>发布 </a-button>
<a-button type="primary" @click="handleFabu(0)" style="float: right; margin-right: 8px" v-if="jxdgInfo.sffb == '1'"> <Icon icon="ant-design:export-outlined"/>撤销</a-button>
<a-divider />
</a-col>
<a-col :span="24" v-for="(item, index) in zyJxdgMainTable.dataSource" :key="index">
<a-row>
<a-col :span="24" style="margin-bottom: 15px; height: 40px; margin-top: 15px; background-color: rgba(1, 156, 136, 0.1)">
<span class="title">{{ item.title }}</span>
</a-col>
<!-- 单行文本 1 -->
<a-col v-if="item.type === '1'" :span="24" style="margin: 10px; ">
<span v-text="item.content"></span>
</a-col>
<!-- 多行文本 2 -->
<a-col v-else-if="item.type === '2'" :span="24" style="margin: 10px; ">
<span v-text="item.content"></span>
</a-col>
<!-- 富文本 3 -->
<a-col v-else-if="item.type === '3'" :span="24">
<div v-html="item.content"></div>
</a-col>
<!-- 固定表单(基础信息) 4 -->
<a-col v-else-if="item.type === '4'" v-model:value="item.content" :span="24">
<a-form v-bind="formItemLayout">
<a-row>
<a-col v-for="(item2, index2) in item.zyJxdgPzxxList" :key="index2" :span="12">
<a-form-item :label="item2.title" >
<span v-text="item2.content"></span>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-col>
<!-- 自增表格 5 -->
<a-col v-else-if="item.type === '5'" :span="24">
<a-table :columns="getTableColumns(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
<!-- <template #bodyCell="{ column, record }">
<a-input placeholder="请输入内容" v-model:value="record[column.key]" style="width: 80%"></a-input>
</template> -->
</a-table>
</a-col>
<!-- 自增单行文本 6 -->
<a-col v-else-if="item.type === '6'" :span="24">
<a-row>
<a-col v-for="(item2, index2) in item.list" :key="index2" style="margin: 10px; ">
<span v-text="item2.title"></span>
</a-col>
</a-row>
</a-col>
<!-- 自增富文本 7 -->
<a-col v-else-if="item.type === '7'" :span="24">
<a-row>
<a-col v-for="(item2, index2) in item.list" :key="index2">
<div v-html="item2.title"></div>
</a-col>
</a-row>
</a-col>
<!-- 自增多行文本 8 -->
<a-col v-else-if="item.type === '8'" :span="24">
<a-row>
<a-col v-for="(item2, index2) in item.list" :key="index2" style="margin: 10px; ">
<span v-text="item2.title"></span>
</a-col>
</a-row>
</a-col>
<!-- 自增表格 9 -->
<a-col v-else-if="item.type === '9'" :span="24">
<a-table :columns="getTableZzColumns2(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
</a-table>
</a-col>
<!-- 自增表格(两列关联) 10 -->
<a-col v-else-if="item.type === '10'" :span="24">
<a-table :columns="getTableZzColumns(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
</a-table>
</a-col>
<a-col v-else> </a-col>
<a-col :span="24" v-if="item.tsy">
<span class="tishi">
<span>{{ item.tsy }}</span>
</span>
</a-col>
</a-row>
</a-col>
</a-row>
</div>
</div>
</template>
<script lang="ts" name="zyJxdgBanben-zyJxdgBanben" setup>
import { ref, reactive, computed, unref, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { defHttp } from '/@/utils/http/axios';
import { queryZyJxdgMainListByMainId, queryDataById, saveOrUpdate2, queryZyJxdgMainListByMainId2 } from '/@/views/kc/zyJxdgBanben/ZyJxdgBanben.api';
import JEditor from '/@/components/Form/src/jeecg/components/JEditor.vue';
//当前路由信息
const { currentRoute } = useRouter();
const { query } = unref(currentRoute);
const { rwbh, xqxn, type, teano } = query; //获取传递参数
const showType = ref<number>(0);
const jxdgInfo = ref<any>({});
const jxdgbbDataSource = ref<any>([]);
const disabled = ref<boolean>(false);
const zyJxdgMainTable = reactive<Record<string, any>>({
loading: false,
dataSource: [],
});
const formItemLayout = {
labelCol: { xs: { span: 24 }, sm: { span: 8 } },
wrapperCol: { xs: { span: 24 }, sm: { span: 13 } },
};
//关联项目计算方法
function handleGlxm(item) {
var sfsglxm = item.sfsglxm;
if (sfsglxm == '1') {
//判断是否是关联项目
var list1 = item.list; //课程目标集合
if (list1 != null) {
//关联项目是否有值
var sort = item.sort; //第几个关联项目
var alllist = zyJxdgMainTable.dataSource; //获取全部的数据
for (var j = 0; j < alllist.length; j++) {
for (var i = 0; i < list1.length; i++) {
var item1 = list1[i];
var title = item1.title; //具体信息
var item2 = alllist[j]; //具体数据
item2.list = item2.list || [];
if (item2.guanlian == sort) {
//关联项目等于当前数据
if (i == 0) {
//判断第一回将原来的清空重新赋值
item2.list = [];
}
//判断当前项是否等于关联项
var item3 = item2.zyJxdgPzxxList;
if (item3 != null && item3.length > 0) {
item2.list.push({ [item3[0].id]: title });
}
}
}
}
}
}
}
function handleFabu(sffb){
defHttp.post({ url: '/zyJxdgTeacherMain/zyJxdgTeacherMain/edit', params: { sffb,id:jxdgInfo.value.id} }).then((res) => {
init()
});
}
//两列关联项目计算方法
function handleTwoGlxm(item) {
var sfsglxm = item.sfsglxm;
if (sfsglxm == '1') {
//判断是否是关联项目
var list1 = item.list; //课程目标集合
if (list1 != null) {
//关联项目是否有值
var sort = item.sort; //第几个关联项目
var alllist = zyJxdgMainTable.dataSource; //获取全部的数据
for (var j = 0; j < alllist.length; j++) {
for (var i = 0; i < list1.length; i++) {
var item1 = list1[i];
var item2 = alllist[j]; //具体数据
item2.list = item2.list || [];
if (item2.guanlian == sort) {
//判断当前项是否等于关联项
var item3 = item.zyJxdgPzxxList;
var item4 = item2.zyJxdgPzxxList;
var title1 = item1[item3[0].id];
var title2 = item1[item3[1].id];
//关联项目等于当前数据
if (i == 0) {
//判断第一回将原来的清空重新赋值
item2.list = [];
}
if (item3 != null && item3.length > 0) {
item2.list.push({ [item4[0].id]: title1, [item4[1].id]: title2 });
}
}
}
}
}
}
}
//新增单行文本
function handleDhwb(item) {
item.list = item.list || [];
item.list.push({
title: '',
sort: item.list.length + 1,
});
}
//删除单行文本
function handleDhwbDel(item, index) {
item.list.splice(index, 1);
for (var i = 0; i < item.list.length; i++) {
item.list[i].sort = i;
}
}
//新增多行富文本
function handleDhfwb(item) {
item.list = item.list || [];
item.list.push({
title: '',
sort: item.list.length + 1,
});
}
//删除多行富文本
function handleDhfwbDel(item, index) {
item.list.splice(index, 1);
for (var i = 0; i < item.list.length; i++) {
item.list[i].sort = i;
}
}
//新增多行富文本
function handleDhwbArea(item) {
item.list = item.list || [];
item.list.push({
title: '',
sort: item.list.length + 1,
});
}
//删除多行富文本
function handleDhwbAreaDel(item, index) {
item.list.splice(index, 1);
for (var i = 0; i < item.list.length; i++) {
item.list[i].sort = i;
}
}
//新增自增表格
function handleZzbg(item) {
item.list = item.list || [];
item.list.push({
title: '',
sort: item.list.length,
});
}
//删除自增表格
function handleZzbgDel(list, record) {
list.splice(record, 1);
for (var i = 0; i < list.length; i++) {
list[i].sort = i;
}
}
//获取列表列表头
function getTableColumns(list) {
let columns = reactive<any>([]);
for (var i = 0; i < list.length; i++) {
var par = list[i];
var inePar = {
title: par.title,
dataIndex: par.id,
key: par.id,
};
columns.push(inePar);
}
return columns;
}
//获取自增列表列表头
function getTableZzColumns(list) {
let columns = reactive<any>([]);
for (var i = 0; i < list.length; i++) {
var par = list[i];
var inePar = {
title: par.title,
dataIndex: par.id,
key: par.id,
};
columns.push(inePar);
}
var inePar2 = {
title: '操作',
dataIndex: 'action',
key: 'action',
};
columns.push(inePar2);
return columns;
}
//获取自增列表列表头
function getTableZzColumns2(list) {
let columns = reactive<any>([]);
for (var i = 0; i < list.length; i++) {
var par = list[i];
var inePar = {
title: par.title,
dataIndex: par.id,
key: par.id,
};
columns.push(inePar);
}
return columns;
}
//选择教学大纲版本
async function handleCheckBanben(record) {
jxdgInfo.value.banbenId = record.id;
jxdgInfo.value.rwbh = rwbh;
jxdgInfo.value.teacherNo = teano;
//子表数据
var id = record.id;
const zyJxdgMainDataList = await queryZyJxdgMainListByMainId(id);
zyJxdgMainTable.dataSource = [...zyJxdgMainDataList];
}
async function submitForm() {
const alllist = zyJxdgMainTable.dataSource;
var values = {
id: jxdgInfo.value.id,
rwbh: rwbh,
banbenId: jxdgInfo.value.banbenId,
teacherNo: teano,
sffb: '0',
list: alllist,
};
console.log('表单提交数据', values);
const isUpdate = values.id ? true : false;
await saveOrUpdate2(values, isUpdate);
setTimeout(() => {
init();
}, 1000);
}
//切换显示模块
function handleShowType(type) {
if (type == 1) {
jxdgInfo.value = {};
zyJxdgMainTable.dataSource = [];
defHttp.get({ url: '/zyJxdgBanben/zyJxdgBanben/list', params: { sfsy: '1', pageNo: -1 } }).then((res) => {
jxdgbbDataSource.value = res.records;
});
}else if(type == 2){
type = 1;
defHttp.get({ url: '/zyJxdgBanben/zyJxdgBanben/list', params: { sfsy: '1', pageNo: -1 } }).then((res) => {
jxdgbbDataSource.value = res.records;
});
var teacherNo = teano;
zyJxdgMainTable.dataSource = [];
defHttp.get({ url: '/zyJxdgTeacherMain/zyJxdgTeacherMain/queryByRwbhList', params: { rwbh, teacherNo } }).then((res) => {
zyJxdgMainTable.dataSource = [...res];
});
}
showType.value = type;
}
//初始化查询
async function init() {
console.log('rwbh--->', rwbh);
defHttp.get({ url: '/zyJxdgTeacherMain/zyJxdgTeacherMain/queryByRwbh', params: { rwbh, xqxn, teacherNo: teano } }).then((res) => {
if (res) {
jxdgInfo.value = res;
showType.value = 999;
var teacherNo = teano;
defHttp.get({ url: '/zyJxdgTeacherMain/zyJxdgTeacherMain/queryByRwbhList', params: { rwbh, teacherNo } }).then((res) => {
zyJxdgMainTable.dataSource = [...res];
});
} else {
showType.value = 0;
}
});
if (jxdgInfo.value.id) {
}
}
const jxdgbbColumns = [
{
title: '版本',
align: 'center',
dataIndex: 'title',
},
{
title: '课程类型',
align: 'center',
dataIndex: 'twoTitle_dictText',
},
{
title: '操作',
align: 'action',
key: 'action',
},
];
onMounted(() => {
init();
});
</script>
<style lang="less" scoped>
.title {
margin-left: 20px;
font-size: 16px;
font-weight: bold;
}
.title2 {
font-size: 16px;
font-weight: bold;
}
.ant-divider-horizontal {
display: flex;
clear: both;
width: 100%;
min-width: 100%;
margin: 3px 0 5px;
}
.tishi {
width: 100%;
font-size: 12px;
color: #fd8f02;
margin-top: -4px;
background: #fffbf2;
text-align: center;
padding: 6px 0;
}
.cardClass {
min-height: 200px;
}
.sznrClass {
line-height: 40px;
text-align: center;
}
.ant-card {
box-sizing: border-box;
margin: 0;
padding: 0;
color: rgb(0 0 0);
font-size: 14px;
font-variant: tabular-nums;
line-height: 1.5715;
list-style: none;
font-feature-settings: tnum;
position: relative;
border-radius: 5px;
border: 1px solid #dadada;
background: #f7f7f7;
}
.ant-card-head {
min-height: 48px;
margin-bottom: -1px;
padding: 0 24px;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
font-size: 16px;
background: transparent;
border-bottom: 1px solid #dadada;
border-radius: 2px 2px 0 0;
}
.ellipsis {
overflow: hidden; /* 确保超出容器的内容被裁剪 */
white-space: nowrap; /* 确保文本在一行内显示 */
text-overflow: ellipsis; /* 超出部分显示省略号 */
}
.ellip-title {
display: flex;
justify-content: space-between;
align-items: flex-end;
margin-top: -10px;
}
.elli-title {
font-size: 16px;
font-weight: bold;
}
.ellip-word {
font-size: 12px;
color: #666666;
margin-right: 10px;
}
.ellip-word2 {
font-size: 12px;
color: #333;
font-weight: bold;
}
.zuanqu:hover {
cursor: pointer;
color: #18a689;
}
.data-suggest {
display: flex;
flex-direction: column;
text-align: center;
width: 25%;
margin-right: 3px;
padding: 8px 3px;
border-radius: 5px;
background: #f7f7f7;
margin-top: 10px;
}
.data-suggest span:nth-child(1) {
font-size: 16px;
font-weight: bold;
}
.data-suggest span:nth-child(2) {
font-size: 12px;
}
.work-img {
width: 100%;
display: flex;
justify-content: center;
margin-top: 80px;
margin-bottom: 30px;
}
.work-img-img {
width: 180px;
height: 139px;
}
.buttonClass {
background: #1ab394;
font-weight: 600;
color: #fff;
border-radius: 3px;
border: none;
}
.mar-right20 {
margin-right: 14px;
}
.button-zhta {
color: #666666;
cursor: pointer;
}
.button-zhta:hover {
cursor: pointer;
color: #18a689;
}
.sear-distance {
padding: 0 10px;
}
.ant-form-item {
box-sizing: border-box;
margin: 10px 0;
padding: 0;
color: rgba(0, 0, 0, 0.85);
font-size: 14px;
font-variant: tabular-nums;
line-height: 1.5715;
list-style: none;
font-feature-settings: tnum;
/* margin-bottom: 24px; */
vertical-align: top;
}
.bled-countenance {
color: #333333;
}
.bled-countenance2 {
color: #999999;
font-size: 12px;
}
.region {
margin: 5px 10px;
padding-bottom: 20px;
background: #fff;
border-radius: 5px;
}
.region-title {
font-size: 16px;
color: #029c88;
padding: 8px 20px;
border-left: 5px solid #029c88;
margin-bottom: 20px;
}
.tishi {
width: 100%;
display: flex;
flex-direction: column;
text-align: left;
margin: 5px;
}
.tishi span{
font-size: 12px;
color: #fd8f02;
}
.increase{
position: absolute;
right:6px;
top:-51px;
}
.place-dele{
margin:10px 0;
}
</style>