项目表单更新

This commit is contained in:
hbzgyjh 2021-12-16 21:26:45 +08:00
parent 0d242f5f8a
commit df4c00dac4
6 changed files with 58 additions and 42 deletions

View File

@ -58,11 +58,6 @@ export default {
// - 访this // - 访this
created() { created() {
console.log('分步表单创建完成', this.$route) console.log('分步表单创建完成', this.$route)
if (this.$route.query.projectId) {
getProjectDetail({ id: this.$route.query.projectId }).then(res => {
this.form = res.data
})
}
}, },
destroyed() { destroyed() {
console.log('分步表单销毁了。。。。。') console.log('分步表单销毁了。。。。。')
@ -88,7 +83,7 @@ export default {
form: { form: {
t: this.$route.query.t, t: this.$route.query.t,
projectType: this.$route.query.t === 'sys' ? 0 : 1, projectType: this.$route.query.t === 'sys' ? 0 : 1,
trainWay: '2', trainWay: '1',
totalScore: '100' totalScore: '100'
}, },
result: true, result: true,

View File

@ -8,7 +8,7 @@
</template> --> </template> -->
<a-space direction="vertical" style="width: 100%"> <a-space direction="vertical" style="width: 100%">
<a-space direction="horizontal"> <a-space direction="horizontal">
<span>总课时{{ totalHours }}H , 总学时要求{{ totalLearnHours }}H , 总题目数量{{ totalTopicNum }} </span> <span>总课时{{ form.totalCourseHours }}H , 总学时要求{{ form.totalLearnHours }}H , 总题目数量{{ form.totalTopicNumber }} </span>
课程名: 课程名:
<a-input v-model="queryParam.courseName" style="width: 100%" /> <a-input v-model="queryParam.courseName" style="width: 100%" />
<a-button type="primary" icon="search" @click="$refs.table.refresh(true)">查询</a-button> <a-button type="primary" icon="search" @click="$refs.table.refresh(true)">查询</a-button>
@ -92,9 +92,9 @@ export default {
labelCol: {}, labelCol: {},
wrapperCol: {}, wrapperCol: {},
vertical: 'vertical', vertical: 'vertical',
totalHours: 0, // totalCourseHours: 0, //
totalLearnHours: 0, // totalLearnHours: 0, //
totalTopicNum: 0, // totalTopicNumber: 0, //
selectCourseId: '', //id selectCourseId: '', //id
courseVisible: false, // courseVisible: false, //
@ -117,8 +117,9 @@ export default {
loadData: (parameter) => { loadData: (parameter) => {
if (this.$route.query.projectId) { if (this.$route.query.projectId) {
/** 编辑进来的有项目id */ /** 编辑进来的有项目id */
return getCourseList(this.$route.query.projectId).then((res) => { return getCourseList({id:this.$route.query.projectId}).then((res) => {
this.selData = res.data; this.selData = res.data;
this.calc(res.data) this.calc(res.data)
return res.data return res.data
}) })
@ -156,13 +157,13 @@ export default {
}, },
// //
calc(data) { calc(data) {
this.totalHours = 0 this.form.totalCourseHours = 0
this.totalLearnHours = 0 this.form.totalLearnHours = 0
this.totalTopicNum = 0 this.form.totalTopicNumber = 0
data.forEach((item) => { data.forEach((item) => {
this.totalHours = this.totalHours + parseInt(item.courseHours) this.form.totalCourseHours = this.form.totalCourseHours + parseInt(item.courseHours)
this.totalLearnHours = this.totalLearnHours + parseInt(item.learnHours) this.form.totalLearnHours = this.form.totalLearnHours + parseInt(item.learnHours)
this.totalTopicNum = this.totalTopicNum + parseInt(item.topicNumber) this.form.totalTopicNumber = this.form.totalTopicNumber + parseInt(item.topicNumber)
}) })
}, },
// //

View File

@ -7,14 +7,7 @@
<template slot="extra"> <template slot="extra">
<a-button type="primary" size="default" @click="close">退出</a-button> <a-button type="primary" size="default" @click="close">退出</a-button>
</template> --> </template> -->
<a-form-model <a-form-model ref="form" :rules="rules" :model="form" :label-col="labelCol" :wrapper-col="wrapperCol" layout="horizontal">
ref="form"
:rules="rules"
:model="form"
:label-col="labelCol"
:wrapper-col="wrapperCol"
layout="horizontal"
>
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :md="24" :sm="24"> <a-col :md="24" :sm="24">
<a-form-model-item label="项目名称" prop="projectName"> <a-form-model-item label="项目名称" prop="projectName">
@ -25,7 +18,7 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :md="24" :sm="24"> <a-col :md="24" :sm="24">
<a-form-model-item label="培训种类" prop="trainClass"> <a-form-model-item label="培训种类" prop="trainClass">
<a-select v-model="form.trainClass" placeholder="--请选择--"> <a-select v-model="form.trainClass" placeholder="--请选择--">
<a-select-option v-for="entity in trainClass" :key="entity.value"> {{ entity.name }} </a-select-option> <a-select-option v-for="entity in trainClass" :key="entity.value"> {{ entity.name }} </a-select-option>
</a-select> </a-select>
<!-- <a-button type="primary" @click="$refs.classList.list()"> 新增种类 </a-button> --> <!-- <a-button type="primary" @click="$refs.classList.list()"> 新增种类 </a-button> -->
@ -138,6 +131,7 @@
import { dictGet } from '@/api/project/project' import { dictGet } from '@/api/project/project'
import ClassList from '../classAdd/ClassList.vue' import ClassList from '../classAdd/ClassList.vue'
import { classList } from '@/api/project/class' import { classList } from '@/api/project/class'
import { projectAdd, getProjectDetail } from '@/api/project/project'
export default { export default {
props: { props: {
@ -179,6 +173,11 @@ export default {
}, },
created(ClassList) { created(ClassList) {
console.log('第一个表单创建了') console.log('第一个表单创建了')
if (this.$route.query.projectId) {
getProjectDetail({ id: this.$route.query.projectId }).then(res => {
this.form = res.data
})
}
this.fetchTemplateData() this.fetchTemplateData()
this.getTrainClass() this.getTrainClass()
}, },

View File

@ -88,7 +88,7 @@ export default {
expandedKeys: [], expandedKeys: [],
autoExpandParent: true, autoExpandParent: true,
defaultExpandedKeys: [], defaultExpandedKeys: [],
selectedRowKeys: this.projectForm.personIds || [], selectedRowKeys: [],
selectedRows: this.projectForm.projectPersonLists || [], selectedRows: this.projectForm.projectPersonLists || [],
orgTree: [], orgTree: [],
orgId: '', orgId: '',
@ -186,7 +186,12 @@ export default {
// //
initPersonList() { initPersonList() {
if (this.form.personIds) { if (this.form.projectPersonLists) {
this.selectedRowKeys = [],
this.form.projectPersonLists.forEach(element => {
this.selectedRowKeys.push(element.id)
});
console.log('初始化的值',this.selectedRowKeys)
} }
}, },
@ -213,6 +218,7 @@ export default {
// - 访this // - 访this
created() { created() {
this.getOrgTree() this.getOrgTree()
this.initPersonList()
}, },
// - 访DOM // - 访DOM
mounted() { }, mounted() { },

View File

@ -46,16 +46,16 @@
<a-card :bordered="false" title="组卷策略详情"> <a-card :bordered="false" title="组卷策略详情">
<a-table :columns="columns" :data-source="tableData" bordered :position="{ disabled: false }" :pagination="false"> <a-table :columns="columns" :data-source="tableData" bordered :position="{ disabled: false }" :pagination="false">
<template slot="topicNum" slot-scope="text, record"> <template slot="topicNum" slot-scope="text, record">
<a-input-number style="margin: -5px 0" v-model="record.topicNum" min="0" :max="record.totalNum" /> <a-input-number style="margin: -5px 0" v-model="record.topicNum" :min="0" :max="record.totalNum" />
</template> </template>
<template slot="topicScore" slot-scope="text, record"> <template slot="topicScore" slot-scope="text, record">
<a-input-number style="margin: -5px 0" v-model="record.topicScore" min="0" /> <a-input-number style="margin: -5px 0" v-model="record.topicScore" :min="0" />
</template> </template>
<template slot="totalScore" slot-scope="text, record"> <template slot="totalScore" slot-scope="text, record">
<p>{{record.topicScore}}</p> <p>{{record.topicScore}}</p>
</template> </template>
<template slot="footer" :style="{ float:left }"> <template slot="footer" :style="{ float:'left' }">
<p>总分数{{form.totalScore}} </p> <p class="right">总分数{{form.totalScore}} </p>
</template> </template>
</a-table> </a-table>
</a-card> </a-card>
@ -135,12 +135,21 @@ export default {
}, },
], ],
tableData: this.projectForm.testPaperTactics || [], tableData: this.projectForm.testPaperTactics || [],
totalScore: 0,
} }
}, },
// data // data
computed: {}, computed: {},
// data // data
watch: {}, watch: {
tableData: function () {
let sum = 0;
this.tableData.array.forEach(element => {
sum = element.totalScore + sum;
});
this.form.totalScore = sum;
}
},
// //
methods: { methods: {
validataScore() { validataScore() {
@ -148,23 +157,21 @@ export default {
}, },
// //
toSave() { toSave() {
this.form.testPaperTactics = this.tableData this.form.testPaperTactics = this.tableData;
this.form.projectStatus = 1
this.$emit('executeSave', this.form) this.$emit('executeSave', this.form)
}, },
// //
toIssue() { toIssue() {
this.form.testPaperTactics = this.tableData this.form.testPaperTactics = this.tableData;
this.form.projectStatus = 2
this.$emit('executeIssue', this.form) this.$emit('executeIssue', this.form)
}, },
// //
toPrev() { toPrev() {
this.form.testPaperTactics = this.tableData
this.$emit('prevStep', this.form) this.$emit('prevStep', this.form)
}, },
}, initTable() {
// - 访this
created() {
if (this.tableData.length == 0) {
let ids = this.form.lessonIds.map((t) => { let ids = this.form.lessonIds.map((t) => {
return parseInt(t.ids); return parseInt(t.ids);
}) })
@ -173,6 +180,10 @@ export default {
}) })
} }
}, },
// - 访this
created() {
this.initTable();
},
// - 访DOM // - 访DOM
mounted() { }, mounted() { },
// - // -
@ -192,4 +203,9 @@ export default {
} }
</script> </script>
<style scoped> <style scoped>
</style>ß .right {
/* 右对齐 */
text-align: right;
font-size: 16px;
}
</style>

View File

@ -44,11 +44,10 @@ export default {
}, },
toProjectList() { toProjectList() {
this.$router.push({ this.$router.push({
path: '/project/list'+this.$route.query.t, path: '/project/list/'+this.$route.query.t,
query: { query: {
t: this.$route.query.t, t: this.$route.query.t,
projectPageNum: 1 , projectPageNum: 1 ,
queryParam: this.$route.query.projectQueryParam,
}, },
}) })
}, },