保存修改验证调整

This commit is contained in:
wangxuemei
2024-08-27 17:34:20 +08:00
parent 66aac5dc34
commit ed8b4769de
5 changed files with 272 additions and 178 deletions

View File

@@ -71,14 +71,14 @@
<a-table style="border: 1px solid #f2f6fe" :columns="columns" :data-source="tableData" :loading="tableLoading"
@expand="expandTable" :pagination="false">
<template #bodyCell="{ record, column }">
<template v-if="column.key === 'organizationName'">
<a-space style="display:flex ;justify-content: space-around; ">
<a-popover>
<template #content>
<p>{{ record.organizationName }}</p>
</template>
<span>{{ record.neworganizationName }}</span>
<span>{{ record.neworganizationName }}</span>
</a-popover>
</a-space>
</template>
@@ -102,15 +102,15 @@
<div class="tableBox ">
<div style="float: right;">
<a-pagination v-if="tableDataTotal > 10" :showSizeChanger="true" :showQuickJumper="false " :hideOnSinglePage="true"
:pageSize="searchParam.pageSize" :current="searchParam.pageNo" :total="tableDataTotal" class="pagination"
@change="changePagination" />
<a-pagination v-if="tableDataTotal > 10" :showSizeChanger="true" :showQuickJumper="false"
:hideOnSinglePage="true" :pageSize="searchParam.pageSize" :current="searchParam.pageNo" :total="tableDataTotal"
class="pagination" @change="changePagination" />
</div>
</div>
<!-- 弹窗组件 -->
<a-drawer v-model:visible="teacherdialog" placement="right" @closa="cancelTeacherDialog" :maskClosable="true"
width="60%" :title="teacherdialogtitle">
<a-form :model="formParam" :rules="rules" layout="vertical">
<a-form :model="formParam" :rules="rules" layout="vertical" ref="formRef">
<a-row>
<a-col :span="24">
<span class="line"></span><span>基本信息</span>
@@ -120,18 +120,18 @@
<a-col :span="24">
<div class="item_inp" style="background-color: #fff;">
<a-tooltip>
<template #title>修改头像</template>
<a-upload name="avatar" list-type="picture-card" class="avatar-uploader" :show-upload-list="false"
:headers="headers" :before-upload="beforeUpload" >
<img class="i_upload_img" v-if="formParam.photo" :src="formParam.photo" alt="avatar" />
<div class="i_upload" v-else>
<div class="addimg">
<div class="heng"></div>
<div class="shu"></div>
<template #title>修改头像</template>
<a-upload name="avatar" list-type="picture-card" class="avatar-uploader" :show-upload-list="false"
:headers="headers" :before-upload="beforeUpload">
<img class="i_upload_img" v-if="formParam.photo" :src="formParam.photo" alt="avatar" />
<div class="i_upload" v-else>
<div class="addimg">
<div class="heng"></div>
<div class="shu"></div>
</div>
</div>
</div>
</a-upload>
</a-tooltip>
</a-upload>
</a-tooltip>
<div class="i_bottom">
<div class="tip" style="margin-bottom: 10px;">
<span style="color: #999999; margin-left: 8px">支持图片格式为jpg/jpeg/png 图片最大为500KB</span>
@@ -143,11 +143,12 @@
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="讲师名称" name="name">
<!-- <ProjectManager v-model:value="formParam.userNo"
<!-- <ProjectManager v-model:value="formParam.userNo"
v-model:name="formParam.name"
placeholder="请输入工号/讲师姓名进行检索"
@onChange="managerChange" mode="multiple"></ProjectManager> -->
<SearchTeacher v-model:value="formParam.name" v-model:lable="formParam.orgName" v-model:newlable="formParam.neworgName"></SearchTeacher>
<SearchTeacher v-model:value="formParam.name" v-model:lable="formParam.orgName"
v-model:newlable="formParam.neworgName"></SearchTeacher>
<!-- <a-tree-select v-model:value="formParam.name"
show-search allow-clear tree-data-simple-mode class="draitem"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" :tree-data="treeData" placeholder="请输入讲师名称" /> -->
@@ -155,10 +156,10 @@
</a-col>
<a-col :span="12">
<a-form-item label="讲师组织" name="orgName">
<a-popover >
<a-popover>
<template #content>
{{ formParam.orgName }}
{{formParam.neworgName }}
{{ formParam.neworgName }}
</template>
<a-input disabled v-model:value="formParam.neworgName" class="draitem"
@@ -177,19 +178,20 @@
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="讲师级别" name="tlevelId" ><div @click="handlesel">
<a-select class="draitem" v-model:value="formParam.tlevelId" placeholder="请选择讲师级别" allowClear
:disabled="getLevelList.length !== 0 ? false : true" :options="getLevelList" >
</a-select>
</div>
<a-form-item label="讲师级别" name="tlevelId">
<div @click="handlesel">
<a-select class="draitem" v-model:value="formParam.tlevelId" placeholder="请选择讲师级别" allowClear
:disabled="getLevelList.length !== 0 ? false : true" :options="getLevelList">
</a-select>
</div>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="初始授课时长" name="defaultteachingTime">
<a-input v-model:value="formParam.defaultteachingTime" style="width:80%; height: 40px; border-radius: 8px; " @blur="clearNonNumber"
placeholder="0" allowClear showSearch suffix="分钟">
<a-input v-model:value="formParam.defaultteachingTime" style="width:80%; height: 40px; border-radius: 8px; "
@blur="clearNonNumber" placeholder="0" allowClear showSearch suffix="分钟">
</a-input>
<span style="margin-left: 5px ;" v-if="formParam.defaultteachingTime != null">{{
(formParam.defaultteachingTime / 60).toFixed(2) }}小时</span>
@@ -216,7 +218,7 @@
<a-row :gutter="16">
<a-col :span="24">
<a-form-item label="讲师介绍">
<Editor v-model:value="formParam.description "/>
<Editor v-model:value="formParam.description" />
</a-form-item>
</a-col>
</a-row>
@@ -230,7 +232,7 @@
<a-row :gutter="16">
<a-col :span="24">
<a-form-item label="擅长课程">
<Editor v-model:value="formParam.courses "/>
<Editor v-model:value="formParam.courses" />
</a-form-item>
</a-col>
</a-row>
@@ -467,7 +469,7 @@
<!-- 删除功能弹窗 -->
<div>
<a-modal v-model:visible="deleteInTeacherdialog" :footer="null" :closable="closableQR" centered="true">
<a-modal v-model:visible="deleteInTeacherdialog" :footer="null" :closable="closableQR" centered="true">
<div class="delete">
<div class="del_header"></div>
<div class="del_main">
@@ -493,15 +495,9 @@
</a-modal>
</div>
<!-- 修改状态功能弹窗 -->
<div>
<a-modal
v-model:visible="editTeacher"
:footer="null"
:closable="closableQR"
wrapClassName="DelModal"
style="margin-top: 400px"
:zIndex="9999"
>
<div>
<a-modal v-model:visible="editTeacher" :footer="null" :closable="closableQR" wrapClassName="DelModal"
style="margin-top: 400px" :zIndex="9999">
<div class="delete">
<div class="del_header"></div>
<div class="del_main">
@@ -523,7 +519,7 @@
</div>
</div>
</div>
</a-modal>
</a-modal>
</div>
<AddContent v-model:showContent="showContent" @AddContentList="AddContentList" :Addtitle="Addtitle" />
<!-- <div> <Upload/> </div> -->
@@ -531,6 +527,7 @@
</template>
<script lang="jsx">
import { reactive, toRefs, ref, watch } from "vue";
import { useStore } from "vuex";
import {
RightOutlined,
UpOutlined,
@@ -561,12 +558,14 @@ export default {
FolderAddOutlined,//图标--新增
},
setup() {
const formRef = ref();
const store = useStore();
const router = useRouter();
const state = reactive({
Addtitle: '选择教师专长',
log:false,
log: false,
showContent: false,
closableQR:false,
closableQR: false,
updialog: false,
moreid: 1,
byPid: null,
@@ -590,15 +589,15 @@ export default {
tableDataTotal: -1,//table列表总条数
vf: false,
formParam: {
teachenType:'0',
teachenType: '0',
name: null,
certStatus: 0,//认证状态
defaultteachingTime: '0',
photo: 'https://p0.itc.cn/q_70/images01/20211013/f45d91616a364d6ea9c42a8db69734aa.png'
// photo: 'https://p0.itc.cn/q_70/images01/20211013/f45d91616a364d6ea9c42a8db69734aa.png'
},
searchParam: {
currentPage: 1,
pageSize1: 10,
currentPage: 1,
pageSize1: 10,
teacherNameOrUserNo: null,
systemId: null,
tlevelId: null,
@@ -638,7 +637,7 @@ export default {
watch(() => state.formParam.courses, (val) => {
console.log(val, 'courses')
})
watch(()=>state.formParam.orgName,(val)=>{
watch(() => state.formParam.orgName, (val) => {
console.log(val, 'orgName')
// if( val !==null ){
// state.formParam.neworgName=val.split('/')
@@ -958,10 +957,11 @@ export default {
])
//列表数据
const tableData = ref([
])
// 搜索
const searchSubmit = () => {
store.commit("setShouInclude", ['lecturerlist']);
getTableDate();
};
//重置
@@ -981,6 +981,7 @@ export default {
pageNo: 1,
pageSize: 10,
};
store.commit("setShouInclude", []);
getTableDate();
};
// List接口数据
@@ -990,13 +991,14 @@ export default {
getTeacherList(objA)
.then((res) => {
// tableData.value = res.data.data.records
let objA= res.data.data.records
objA.map((item)=>{
if( item.organizationName !==null ){
item.neworganizationName=item.organizationName.split('/')
item.neworganizationName= item.neworganizationName[item.neworganizationName.length-1]}
})
tableData.value = objA
let objA = res.data.data.records
objA.map((item) => {
if (item.organizationName !== null) {
item.neworganizationName = item.organizationName.split('/')
item.neworganizationName = item.neworganizationName[item.neworganizationName.length - 1]
}
})
tableData.value = objA
state.tableDataTotal = Number(res.data.data.total);
state.tableLoading = false
})
@@ -1014,7 +1016,7 @@ export default {
cancel()
state.teacherdialog = true;
state.teacherdialogtitle = '新增讲师'
state.formParam.photo = state.formParam.photo === null ? 'https://p0.itc.cn/q_70/images01/20211013/f45d91616a364d6ea9c42a8db69734aa.png' : state.formParam.photo
// state.formParam.photo = state.formParam.photo === null ? 'https://p0.itc.cn/q_70/images01/20211013/f45d91616a364d6ea9c42a8db69734aa.png' : state.formParam.photo
state.formParam.status = '1'
state.vf = true
}
@@ -1028,26 +1030,73 @@ export default {
}
//保存
const createTeacherDialog = () => {
rule()
if( state.log = true){
state.teacherdialog = true;
}
else
{ if (state.vf == false) {
updateInTeacher(state.formParam).then(response => {
message.success("修改成功");
formRef.value
.validate()
.then(() => {
if (state.vf == false) {
updateInTeacher(state.formParam).then(response => {
message.success("修改成功");
state.teacherdialog = false;
cancel()
getTableDate();
});
}
else {
insertTeacher(state.formParam)
.then((res) => {
message.success("保存成功");
state.teacherdialog = false;
cancel()
getTableDate();
}).catch((err) => {
console.log(err);
});
}
})
.catch(() => {
console.log('error', error);
});
}
else {
insertTeacher(state.formParam)
.then((res) => {
message.success("保存成功");
}).catch((err) => {
console.log(err);
});
}
state.teacherdialog = false;
getTableDate();}
// rule()
// if (state.log = true) {
// state.teacherdialog = true;
// }
// else {
// // formRef.value.validate(valid => {
// // if (valid) {
// // if (state.vf == false) {
// // updateInTeacher(state.formParam).then(response => {
// // message.success("修改成功");
// // });
// // }
// // else {
// // insertTeacher(state.formParam)
// // .then((res) => {
// // message.success("保存成功");
// // }).catch((err) => {
// // console.log(err);
// // });
// // }
// // state.teacherdialog = false;
// // getTableDate();
// // }
// // }
// // )
// if (state.vf == false) {
// updateInTeacher(state.formParam).then(response => {
// message.success("修改成功");
// });
// }
// else {
// insertTeacher(state.formParam)
// .then((res) => {
// message.success("保存成功");
// }).catch((err) => {
// console.log(err);
// });
// }
// state.teacherdialog = false;
// getTableDate();
// }
};
//删除弹窗
const deleteModal = (record) => {
@@ -1095,6 +1144,7 @@ export default {
//取消按钮 清空输入的数据
const cancelTeacherDialog = () => {
if (state.teacherdialog = true) {
formRef.value.resetFields();
state.teacherdialog = false
cancel()
}
@@ -1106,9 +1156,9 @@ export default {
//清空数据
const cancel = () => {
state.formParam = {
name:null,
status:null,
teacherType:'0',
name: null,
status: null,
teacherType: '0',
photo: null,
teacherNameOrUserNo: null,
newdepartId: null,
@@ -1129,39 +1179,46 @@ export default {
newdepartId: [{ required: true, message: '组织不能为空' }],
tlevelId: [{ required: true, message: '讲师级别不能为空' }],
tsystemId: [{ required: true, message: '讲师体系不能为空' }],
defaultteachingTime: [{ required: true, message: '授课时长不能为空' }],
defaultteachingTime: [{ required: true, message: '' }],
certStatus: [{ required: true, message: '认证状态不能为空' }],
}
const rule =()=>{
if (state.formParam.name==null){
const rule = () => {
if (state.formParam.name == null) {
state.log = true
message.warning( '讲师不能为空')
message.warning('讲师不能为空')
return
600000000000000000000000000000000
}
if (state.formParam.departId==null){
if (state.formParam.departId == null) {
state.log = true
message.warning( '组织不能为空')
message.warning('组织不能为空')
return
}
if (state.formParam.tlevelId==null){
if (state.formParam.tlevelId == null) {
state.log = true
message.warning( '讲师级别不能为空')
message.warning('讲师级别不能为空')
return
}
if (state.formParam.tsystemId==null){
if (state.formParam.tsystemId == null) {
state.log = true
message.warning( '讲师体系不能为空')
message.warning('讲师体系不能为空')
return
}
if (state.formParam.defaultteachingTime==null){
state.log = true
message.warning( '授课时长不能为空')
}
if (state.formParam.certStatus==null){
if (state.formParam.defaultteachingTime == null) {
state.log = true
message.warning( '认证状态不能为空')
message.warning('授课时长不能为空')
return
}
if (state.formParam.certStatus == null) {
state.log = true
message.warning('认证状态不能为空')
return
}
}
// //表格内查看数据操作
const handleLook = (record) => {
let id = record.id
router.push({ path: '/LookInsideLecturer', query: { id } })
}
@@ -1172,17 +1229,17 @@ export default {
// let objA= res.data.data[0]
// if( objA.orgName !==null ){
// objA.neworgName=objA.orgName.split('/')
// objA.neworgName= objA.neworgName[objA.neworgName.length-1]
// }
state.formParam = res.data.data[0]
state.formParam.description = state.formParam.description === null ? '' : state.formParam.description
state.formParam.workExperience = state.formParam.workExperience === null ? '' : state.formParam.workExperience
state.formParam.workExp0erience = state.formParam.workExperience === null ? '' : state.formParam.workExperience
state.formParam.courses = state.formParam.courses === null ? '' : state.formParam.courses
state.formParam.photo = state.formParam.photo === null ? 'https://p0.itc.cn/q_70/images01/20211013/f45d91616a364d6ea9c42a8db69734aa.png' : state.formParam.photo
}
console.log("内部讲师详情", state.formParam);
})
.catch((err) => {
@@ -1198,15 +1255,15 @@ export default {
// const customPreview =(e)=>{
// e.stopPropagation()
// }
const handlesel=()=>{
console.log( '请下选择讲师体系')
const handlesel = () => {
console.log('请下选择讲师体系')
if (state.formParam.tsystemId == undefimed) {
message.warning( '请下选择讲师体系')
message.warning('请下选择讲师体系')
}
}
//导出功能
const handleExport = () => {
window.open (
window.open(
`${process.env.VUE_APP_BASE_API}/teacher/export?pageNo=${state.searchParam.currentPage
}&pageSize=${state.searchParam.pageSize}
&teacherNameOrUserNo=${state.searchParam.teacherNameOrUserNo ? state.searchParam.teacherNameOrUserNo : ""}
@@ -1224,6 +1281,7 @@ export default {
...toRefs(state),
rules,
rule,
formRef,
handlesel,
// customPreview,
clearNonNumber,
@@ -1272,6 +1330,10 @@ export default {
};
</script>
<style lang="scss" scoped>
::v-deep .ant-upload.ant-upload-select-picture-card {
border-radius: 50% !important;
}
.add_content {
width: 40px;
height: 40px;
@@ -1590,7 +1652,8 @@ export default {
.item_inp .i_upload[data-v-6b882d01] {
border-radius: 50% !important;
}
::v-deep .ant-modal-close{
::v-deep .ant-modal-close {
display: none;
}
</style>