修改 金林湾bug(安全教育页面)分类回显、新增显示

This commit is contained in:
骆乐 2022-11-18 13:54:38 +08:00
parent 9c0d409744
commit ed3c060124
2 changed files with 305 additions and 189 deletions

View File

@ -30,15 +30,15 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 课程分类 --> <!-- 课程分类 -->
<el-form-item :label="$t('message.safetyEducation.courseClass')" prop="classifyName"> <el-form-item :label="$t('message.safetyEducation.courseClass')" prop="classifyId">
<el-select :disabled="classifyId!=''" <el-select :disabled="eduId!=''"
style="width: 100%" style="width: 100%"
v-model="ruleForm.classifyName" v-model="ruleForm.classifyId"
:placeholder="$t('message.safetyEducation.pleaseEnter')" :placeholder="$t('message.safetyEducation.pleaseEnter')"
> >
<el-option <el-option
v-for="item in classifyList" v-for="item in classifyList"
:key="item.id+'classify'" :key="item.id"
:label="item.classifyName" :label="item.classifyName"
:value="item.id" :value="item.id"
> >
@ -331,8 +331,8 @@ export default {
questionList: [], questionList: [],
totalScore: "", totalScore: "",
videoType: 1, videoType: 1,
classifyId:'', classifyId:"",
classifyName:"" classifyName:"",
}, },
indexList: [ indexList: [
"A", "A",
@ -397,7 +397,7 @@ export default {
// //
{ required: true, message: this.$t('message.safetyEducation.rulesA2'), trigger: "change" }, { required: true, message: this.$t('message.safetyEducation.rulesA2'), trigger: "change" },
], ],
classifyName:[ classifyId:[
// //
{ required: true, message: this.$t('message.safetyEducation.rulesA3'), trigger: "change" } { required: true, message: this.$t('message.safetyEducation.rulesA3'), trigger: "change" }
], ],
@ -429,21 +429,29 @@ export default {
}, },
mounted(){ mounted(){
// console.log(process.env.NODE_ENV) // console.log(process.env.NODE_ENV)
console.log("进入 mounted--1", this.classifyId);
if(this.classifyId != ''){ if(this.classifyId != ''){
this.ruleForm.classifyName= this.$route.query.name this.ruleForm.classifyName= this.$route.query.name
console.log('=====',this.ruleForm.classifyName) console.log('=====',this.ruleForm.classifyName)
this.ruleForm.classifyId=parseInt(this.classifyId) this.ruleForm.classifyId=this.classifyId
console.log("this.ruleForm.classifyId", this.ruleForm.classifyId);
} }
console.log("进入 mounted--2", this.classifyId);
this.styleType = this.$store.state.userInfo.styleType this.styleType = this.$store.state.userInfo.styleType
console.log(this.styleType) console.log(this.styleType)
if(this.eduId==''){ if(this.eduId==''){
console.log("进入 mounted--3", this.classifyId);
if(this.$route.path.indexOf('/project/')!=-1){ if(this.$route.path.indexOf('/project/')!=-1){
this.ruleForm.projectSn=this.$store.state.projectSn this.ruleForm.projectSn=this.$store.state.projectSn
}else{ }else{
this.ruleForm.projectSn=this.$store.state.userInfo.headquartersSn this.ruleForm.projectSn=this.$store.state.userInfo.headquartersSn
} }
console.log("进入 mounted--4", this.classifyId);
this.getClassifyList() this.getClassifyList()
}else{ }else{
console.log("进入 mounted--5", this.eduId);
this.createQRcode('') this.createQRcode('')
this.getDetailData() this.getDetailData()
} }
@ -514,6 +522,12 @@ export default {
safeEducationQuestionDetailApi({eduId:this.eduId}).then(res=>{ safeEducationQuestionDetailApi({eduId:this.eduId}).then(res=>{
this.ruleForm=res.result.safeEducation this.ruleForm=res.result.safeEducation
this.ruleForm.classifyName = this.$route.query.name this.ruleForm.classifyName = this.$route.query.name
console.log('分类详细数据',this.ruleForm.classifyName);
console.log('详细数据',this.ruleForm);
if(this.ruleForm.projectSn != null) {
console.log("getDetailData 调用 getClassifyList -- ",this.ruleForm.projectSn);
this.getClassifyList()
}
}) })
}, },
addOptions() { addOptions() {
@ -686,6 +700,7 @@ export default {
type=1 type=1
} }
this.ruleForm.type=type this.ruleForm.type=type
console.log("this.ruleForm",this.ruleForm);
safeEducationQuestionAddApi(this.ruleForm).then(res=>{ safeEducationQuestionAddApi(this.ruleForm).then(res=>{
// //
this.$message.success(this.$t('message.safetyEducation.savedSuccess')) this.$message.success(this.$t('message.safetyEducation.savedSuccess'))

View File

@ -1,11 +1,18 @@
<template> <template>
<div class="fullHeight"> <div class="fullHeight">
<div
<div class="fullHeight" v-if="pageType == 'list'" style="position:relative"> class="fullHeight"
v-if="pageType == 'list'"
style="position: relative"
>
<!--courseManagement 课程管理 --> <!--courseManagement 课程管理 -->
<el-page-header style="margin-bottom:15px" v-if="$route.path.indexOf('/project/')==-1" <el-page-header
style="margin-bottom: 15px"
v-if="$route.path.indexOf('/project/') == -1"
@back="goBack2" @back="goBack2"
:content="parentName+' /' + $t('message.safetyEducation.courseManagement') " :content="
parentName + ' /' + $t('message.safetyEducation.courseManagement')
"
class="backText" class="backText"
></el-page-header> ></el-page-header>
<!-- <el-tabs v-model="activeName" @tab-click="getList" v-if="$route.path.indexOf('/project/')!=-1"> <!-- <el-tabs v-model="activeName" @tab-click="getList" v-if="$route.path.indexOf('/project/')!=-1">
@ -14,25 +21,55 @@
</el-tabs> --> </el-tabs> -->
<!-- v-if="$route.path.indexOf('/project/')==-1" --> <!-- v-if="$route.path.indexOf('/project/')==-1" -->
<div class="classificationBox" v-else> <div class="classificationBox" v-else>
<span :class="{'active':parentId==''}" @click="parentId='';getList()"> <span
:class="{ active: parentId == '' }"
@click="
parentId = '';
getList();
"
>
<!-- 全部 --> <!-- 全部 -->
{{ $t('message.safetyEducation.whole') }} {{ $t("message.safetyEducation.whole") }}
</span> </span>
<span :class="{'active':parentId==item.id}" v-for="(item,index) in classifyList" :key="index" @click="parentId=item.id;getList()">{{item.classifyName}} <span
<i class="el-icon-error" v-if="activeName=='project'" @click.stop="deleteClassifyFn(item)"></i> :class="{ active: parentId == item.id }"
v-for="item in classifyList"
:key="item.id"
:label="item.classifyName"
:value="item.id"
@click="
parentId = item.id;
getList();
"
>{{ item.classifyName }}
<i
class="el-icon-error"
v-if="activeName == 'project'"
@click.stop="deleteClassifyFn(item)"
></i>
</span> </span>
<span class="addTypeBtn" @click="addClassifyFn" v-if="$route.path.indexOf('/project/')==-1||activeName=='project'"> <i class="el-icon-plus"></i> <span
class="addTypeBtn"
@click="addClassifyFn"
v-if="
$route.path.indexOf('/project/') == -1 || activeName == 'project'
"
>
<i class="el-icon-plus"></i>
<!-- 新增类型 --> <!-- 新增类型 -->
{{ $t('message.safetyEducation.newType') }} {{ $t("message.safetyEducation.newType") }}
</span> </span>
</div> </div>
<div v-show="activeName=='project'||$route.path.indexOf('/project/')==-1" style="margin: 10px 15px;position:absolute;right:20px;top:-10px"> <div
<el-button type="primary" size="medium" @click="addFn" v-show="
activeName == 'project' || $route.path.indexOf('/project/') == -1
"
style="margin: 10px 15px; position: absolute; right: 20px; top: -10px"
> >
<el-button type="primary" size="medium" @click="addFn">
<!-- 新增课程 --> <!-- 新增课程 -->
{{ $t('message.safetyEducation.newCourses') }} {{ $t("message.safetyEducation.newCourses") }}
</el-button </el-button>
>
<el-button type="warning" plain size="medium" @click="refresh">{{ <el-button type="warning" plain size="medium" @click="refresh">{{
$t("message.alarmValueSet.refresh") $t("message.alarmValueSet.refresh")
}}</el-button> }}</el-button>
@ -54,7 +91,8 @@
></video> ></video>
<div class="desc"> <div class="desc">
<!-- <span class="time">30分钟</span> --> <!-- <span class="time">30分钟</span> -->
<span v-if="item.eduWorkerNum">{{ item.eduWorkerNum }} <span v-if="item.eduWorkerNum"
>{{ item.eduWorkerNum }}
{{ $t("message.safetyEducation.humanLearning") }} {{ $t("message.safetyEducation.humanLearning") }}
<!-- 人学习 --> <!-- 人学习 -->
</span> </span>
@ -64,9 +102,19 @@
{{ $t("message.safetyEducation.enterQuestionBank") }} {{ $t("message.safetyEducation.enterQuestionBank") }}
</div> </div>
</div> </div>
<div class="title" @click="editBefore(item)">{{ item.eduCourseName }}</div> <div class="title" @click="editBefore(item)">
<div @click.stop="deleteBefore(item)" class="deleteBtn" v-show="activeName=='project'"> {{ item.eduCourseName }}
<img src="@/assets/images/icon-delete.png" width="15px" height="15px"/> </div>
<div
@click.stop="deleteBefore(item)"
class="deleteBtn"
v-show="activeName == 'project'"
>
<img
src="@/assets/images/icon-delete.png"
width="15px"
height="15px"
/>
<!-- <span>{{$t('message.workType.delete')}}</span> --> <!-- <span>{{$t('message.workType.delete')}}</span> -->
</div> </div>
</div> </div>
@ -97,25 +145,50 @@
<!-- '新增课程' : '课程详细' --> <!-- '新增课程' : '课程详细' -->
<el-page-header <el-page-header
@back="goBack" @back="goBack"
:content="(itemId == '' ? $t('message.safetyEducation.newType') : $t('message.safetyEducation.courseDetails'))" :content="
itemId == ''
? $t('message.safetyEducation.newType')
: $t('message.safetyEducation.courseDetails')
"
class="backText" class="backText"
></el-page-header> ></el-page-header>
<addCourse :eduId="itemId" :classifyId="parentId" @showList="goBack"></addCourse> <addCourse
:eduId="itemId"
:classifyId="parentId"
@showList="goBack"
></addCourse>
</div> </div>
<!-- 添加分类 --> <!-- 添加分类 -->
<el-dialog <el-dialog
:modal-append-to-body="false" :modal-append-to-body="false"
:title="$t('message.safetyEducation.addCategory')" :title="$t('message.safetyEducation.addCategory')"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
width="667px"> width="667px"
>
<div class="dialog_content"> <div class="dialog_content">
<el-form label-width="120px" size="medium" class="dialogFormBox" ref="addEditForm" :model="classifyForm"> <el-form
label-width="120px"
size="medium"
class="dialogFormBox"
ref="addEditForm"
:model="classifyForm"
>
<!-- 分类名称 --> <!-- 分类名称 -->
<el-form-item :label="$t('message.safetyEducation.classificationName')" prop="classifyName" :rules="[ <el-form-item
{ required: true, message: $t('message.safetyEducation.pleaseEnter'), trigger: 'blur' } :label="$t('message.safetyEducation.classificationName')"
]"> prop="classifyName"
<el-input v-model="classifyForm.classifyName" :rules="[
:placeholder="$t('message.workType.placeholder')"></el-input> {
required: true,
message: $t('message.safetyEducation.pleaseEnter'),
trigger: 'blur',
},
]"
>
<el-input
v-model="classifyForm.classifyName"
:placeholder="$t('message.workType.placeholder')"
></el-input>
</el-form-item> </el-form-item>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button <el-button
@ -123,28 +196,33 @@
@click="dialogVisible = false" @click="dialogVisible = false"
icon="el-icon-circle-close" icon="el-icon-circle-close"
size="medium" size="medium"
>{{$t('message.personnelPosition.cancel')}} >{{ $t("message.personnelPosition.cancel") }}
</el-button> </el-button>
<el-button <el-button
type="primary" type="primary"
icon="el-icon-circle-check" icon="el-icon-circle-check"
@click="saveClassifyFn" @click="saveClassifyFn"
size="medium" size="medium"
>{{$t('message.personnelPosition.determine')}} >{{ $t("message.personnelPosition.determine") }}
</el-button> </el-button>
</div> </div>
</el-form> </el-form>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { import {
safeEducationQuestionListApi, safeEducationQuestionListApi,
workerSafeEducationDeleteApi,selectCompanyEducationCoursePageApi workerSafeEducationDeleteApi,
selectCompanyEducationCoursePageApi,
} from "@/assets/js/api/laborPerson";
import {
educationClassifyAddApi,
educationClassifyEditApi,
educationClassifyDeleteApi,
educationClassifyListApi,
} from "@/assets/js/api/laborPerson"; } from "@/assets/js/api/laborPerson";
import {educationClassifyAddApi, educationClassifyEditApi, educationClassifyDeleteApi, educationClassifyListApi} from '@/assets/js/api/laborPerson'
import addCourse from "./addCourse"; import addCourse from "./addCourse";
export default { export default {
components: { addCourse }, components: { addCourse },
@ -158,76 +236,83 @@ export default {
total: 0, // total: 0, //
}, },
itemId: "", itemId: "",
parentId:'', parentId: "",
parentName:'', parentName: "",
activeName:'company', activeName: "company",
classifyList: [], classifyList: [],
dialogVisible: false, dialogVisible: false,
classifyForm: { classifyForm: {
classifyName:'' classifyName: "",
}, },
dataSn:'' dataSn: "",
}; };
}, },
mounted() { mounted() {
if (this.$route.params.type) { if (this.$route.params.type) {
this.activeName=this.$route.params.type this.activeName = this.$route.params.type;
} else { } else {
this.parentId=this.$route.query.id this.parentId = this.$route.query.id;
} }
if(this.activeName=='company'){ if (this.activeName == "company") {
this.dataSn=this.$store.state.userInfo.headquartersSn this.dataSn = this.$store.state.userInfo.headquartersSn;
} else { } else {
this.dataSn=this.$store.state.projectSn this.dataSn = this.$store.state.projectSn;
} }
this.parentName=this.$route.query.name this.parentName = this.$route.query.name;
this.getClassifyList() this.getClassifyList();
this.getList(); this.getList();
}, },
watch: { watch: {
$route(to, from) { $route(to, from) {
if (this.$route.params.type) { if (this.$route.params.type) {
this.activeName=this.$route.params.type this.activeName = this.$route.params.type;
if(this.activeName=='company'){ if (this.activeName == "company") {
this.dataSn=this.$store.state.userInfo.headquartersSn this.dataSn = this.$store.state.userInfo.headquartersSn;
} else { } else {
this.dataSn=this.$store.state.projectSn this.dataSn = this.$store.state.projectSn;
} }
this.parentId='' this.parentId = "";
this.pageType='list' this.pageType = "list";
} }
this.getClassifyList() this.getClassifyList();
this.getList(); this.getList();
}, },
}, },
methods: { methods: {
goBack2() { goBack2() {
this.$router.back() this.$router.back();
}, },
refresh() { refresh() {
this.getList(); this.getList();
}, },
getList() { getList() {
let sn = this.$store.state.projectSn let sn = this.$store.state.projectSn;
let type =1 // 21 let type = 1; // 21
if(this.activeName=='company'){ if (this.activeName == "company") {
sn=this.$store.state.userInfo.headquartersSn sn = this.$store.state.userInfo.headquartersSn;
type=2 type = 2;
selectCompanyEducationCoursePageApi({ selectCompanyEducationCoursePageApi({
sn: sn,type:type,classifyId:this.parentId,pageNo:this.pageInfo.pageNo,pageSize:this.pageInfo.pageSize sn: sn,
type: type,
classifyId: this.parentId,
pageNo: this.pageInfo.pageNo,
pageSize: this.pageInfo.pageSize,
}).then((res) => { }).then((res) => {
this.workerList = res.result.records; this.workerList = res.result.records;
this.pageInfo.total = res.result.total; this.pageInfo.total = res.result.total;
}); });
} else { } else {
safeEducationQuestionListApi({ safeEducationQuestionListApi({
projectSn: sn,type:type,classifyId:this.parentId,pageNo:this.pageInfo.pageNo,pageSize:this.pageInfo.pageSize projectSn: sn,
type: type,
classifyId: this.parentId,
pageNo: this.pageInfo.pageNo,
pageSize: this.pageInfo.pageSize,
}).then((res) => { }).then((res) => {
this.workerList = res.result.records; this.workerList = res.result.records;
this.pageInfo.total = res.result.total; this.pageInfo.total = res.result.total;
}); });
} }
}, },
goBack() { goBack() {
this.pageType = "list"; this.pageType = "list";
@ -239,16 +324,20 @@ export default {
}, },
editBefore(item) { editBefore(item) {
this.itemId = item.id; this.itemId = item.id;
console.log('展示') console.log("展示");
this.pageType = "detail"; this.pageType = "detail";
}, },
deleteBefore(item) { deleteBefore(item) {
// , ? // , ?
this.$confirm(this.$t("message.safetyEducation.permanentlyDelete"), this.$t("message.safetyEducation.tips"), { this.$confirm(
this.$t("message.safetyEducation.permanentlyDelete"),
this.$t("message.safetyEducation.tips"),
{
confirmButtonText: this.$t("message.safetyEducation.determine"), // determine confirmButtonText: this.$t("message.safetyEducation.determine"), // determine
cancelButtonText: this.$t("message.safetyEducation.cancel"), // cancelButtonText: this.$t("message.safetyEducation.cancel"), //
type: "warning", type: "warning",
}) }
)
.then(() => { .then(() => {
workerSafeEducationDeleteApi({ id: item.id }).then((res) => { workerSafeEducationDeleteApi({ id: item.id }).then((res) => {
this.$message({ this.$message({
@ -274,56 +363,67 @@ export default {
this.getList(); this.getList();
}, },
getClassifyList() { getClassifyList() {
educationClassifyListApi({sn: this.dataSn}).then(result => { educationClassifyListApi({ sn: this.dataSn }).then((result) => {
this.classifyList = result.result; this.classifyList = result.result;
}) console.log('课程分类', this.classifyList);
});
}, },
addClassifyFn() { addClassifyFn() {
this.dialogVisible = true; this.dialogVisible = true;
this.classifyForm.classifyName='' this.classifyForm.classifyName = "";
}, },
editClassifyFn() {}, editClassifyFn() {},
deleteClassifyFn(item) { deleteClassifyFn(item) {
this.$confirm(this.$t('message.personnelPosition.beaconManage.table.confirmText') + "【" + item.classifyName + "】?", this.$t('message.personnelPosition.beaconManage.table.Tips'), { this.$confirm(
confirmButtonText: this.$t('message.personnelPosition.confirmButtonText'), this.$t("message.personnelPosition.beaconManage.table.confirmText") +
cancelButtonText: this.$t('message.personnelPosition.cancelButtonText'), "【" +
item.classifyName +
"】?",
this.$t("message.personnelPosition.beaconManage.table.Tips"),
{
confirmButtonText: this.$t(
"message.personnelPosition.confirmButtonText"
),
cancelButtonText: this.$t(
"message.personnelPosition.cancelButtonText"
),
type: "warning", type: "warning",
}).then(() => { }
educationClassifyDeleteApi({id: item.id}).then(result => { ).then(() => {
educationClassifyDeleteApi({ id: item.id }).then((result) => {
if (result.success) { if (result.success) {
this.$message.success(result.message); this.$message.success(result.message);
if (item.id == this.parentId) { if (item.id == this.parentId) {
this.parentId='' this.parentId = "";
this.getList(); this.getList();
} }
this.getClassifyList(); this.getClassifyList();
} }
}) });
}) });
}, },
saveClassifyFn() { saveClassifyFn() {
this.$refs['addEditForm'].validate((valid) => { this.$refs["addEditForm"].validate((valid) => {
if (valid) { if (valid) {
educationClassifyAddApi({ educationClassifyAddApi({
sn: this.dataSn, sn: this.dataSn,
classifyName: this.classifyForm.classifyName, classifyName: this.classifyForm.classifyName,
type:this.activeName=='company'?1:2 type: this.activeName == "company" ? 1 : 2,
}).then(result => { }).then((result) => {
this.dialogVisible = false; this.dialogVisible = false;
this.$message.success(result.message); this.$message.success(result.message);
this.getClassifyList(); this.getClassifyList();
}) });
} else { } else {
console.log('error submit!!'); console.log("error submit!!");
return false; return false;
} }
}); });
} },
}, },
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.backText { .backText {
margin: -10px 0 0 0; margin: -10px 0 0 0;
} }
@ -430,7 +530,8 @@ export default {
border-radius: 3px; border-radius: 3px;
padding: 3px 10px; padding: 3px 10px;
position: relative; position: relative;
&.active,&:hover{ &.active,
&:hover {
background-color: @--color-primary-deep; background-color: @--color-primary-deep;
color: white; color: white;
} }