提交 96fa4350 authored 作者: pengxiaohui's avatar pengxiaohui

bug fixes

上级 db90ccd3
......@@ -26,8 +26,11 @@ export default {
type: Boolean,
default: false
},
id: {
type: String
info: {
type: Object,
default () {
return {}
}
}
},
data() {
......@@ -35,6 +38,9 @@ export default {
multipleSelection: []
}
},
created() {
console.log(this.info)
},
computed: {
permissions() {
return this.$store.state.user.permissions || []
......@@ -44,11 +50,12 @@ export default {
},
tableOptions() {
const params = { key: '' }
if (this.isEdit) params.project_id = this.id
if (this.isEdit) params.project_id = this.info.id
return {
remote: {
httpRequest: getCourseList,
params: params
params: params,
callback: this.tableCallback
},
filters: [
{ type: 'input', placeholder: '请输入课程ID/课程名称', prop: 'key' }
......@@ -64,6 +71,13 @@ export default {
}
},
methods: {
tableCallback(list) {
if (!this.isEdit && Array.isArray(list) && this.info && this.info.courseIds.length > 0) {
// 默认删除已有项
list = list.filter(item => !this.info.courseIds.includes(item.id))
}
return list;
},
handleSelectionChange(val) {
this.multipleSelection = val.map(item => item.id)
},
......@@ -82,7 +96,7 @@ export default {
const msg = this.isEdit ? '删除课程' : '添加课程'
const params = {
type: this.isEdit ? 2 : 1,
project_id: this.id,
project_id: this.info.id,
courses_id: this.multipleSelection.join()
}
updateProjectCourseRelation(params).then(res => {
......
......@@ -30,7 +30,6 @@ export default {
}
},
created() {
console.log(this.info)
},
methods: {
fetchUpdateProject(val) {
......
......@@ -27,8 +27,11 @@ export default {
type: Boolean,
default: false
},
id: {
type: String
info: {
type: Object,
default () {
return {}
}
}
},
data() {
......@@ -45,11 +48,12 @@ export default {
},
tableOptions() {
const params = { key: '', mobile: '', email: '' }
if (this.isEdit) params.project_id = this.id
if (this.isEdit) params.project_id = this.info.id
return {
remote: {
httpRequest: getStudentList,
params: params
params: params,
callback: this.tableCallback
},
filters: [
{ type: 'input', placeholder: '请输入学员ID/学员名称', prop: 'key' },
......@@ -77,6 +81,14 @@ export default {
}
},
methods: {
tableCallback(list) {
console.log(this.info)
if (!this.isEdit && Array.isArray(list) && this.info && this.info.studentIds.length > 0) {
// 默认删除已有项
list = list.filter(item => !this.info.studentIds.includes(item.id))
}
return list;
},
handleSelectionChange(val) {
this.multipleSelection = val.map(item => item.id)
},
......@@ -93,7 +105,7 @@ export default {
const msg = this.isEdit ? '删除学员' : '添加学员'
const params = {
type: this.isEdit ? 2 : 1,
project_id: this.id,
project_id: this.info.id,
students_id: this.multipleSelection.join()
}
updateProjectStudentRelation(params).then(res => {
......
......@@ -44,10 +44,10 @@
<tab-info :info="details" @tableRefetch="tableRefetch"/>
</el-tab-pane>
<el-tab-pane label="关联学员" name="student">
<tab-student :id="details.id" v-model="drawerVisible" @tableRefetch="tableRefetch" isEdit/>
<tab-student :info="details" v-model="drawerVisible" @tableRefetch="tableRefetch" isEdit/>
</el-tab-pane>
<el-tab-pane label="关联课程" name="course">
<tab-course :id="details.id" v-model="drawerVisible" @tableRefetch="tableRefetch" isEdit/>
<tab-course :info="details" v-model="drawerVisible" @tableRefetch="tableRefetch" isEdit/>
</el-tab-pane>
</el-tabs>
</el-drawer>
......@@ -59,8 +59,8 @@
size="960px"
@close="handleClose">
<info-form v-if="createType === 'project'" v-model="createDrawerVisible" @formSubmit="fetchCreateProject" />
<tab-student v-if="createType === 'student'" v-model="createDrawerVisible" :id="details.id" type="create" @tableRefetch="tableRefetch"/>
<tab-course v-if="createType === 'course'" v-model="createDrawerVisible" :id="details.id" @tableRefetch="tableRefetch"/>
<tab-student v-if="createType === 'student'" v-model="createDrawerVisible" :info="details" @tableRefetch="tableRefetch"/>
<tab-course v-if="createType === 'course'" v-model="createDrawerVisible" :info="details" @tableRefetch="tableRefetch"/>
</el-drawer>
</div>
</template>
......@@ -187,7 +187,9 @@ export default {
english_name: val.english_name,
type: val.type,
pubdate: val.pubdate,
id: val.id
id: val.id,
courseIds: val.courses.map(item => item.id),
studentIds: val.students
}
this.details = details
},
......@@ -200,7 +202,9 @@ export default {
english_name: val.english_name,
type: val.type,
pubdate: val.pubdate,
id: val.id
id: val.id,
courseIds: val.courses.map(item => item.id),
studentIds: val.students
}
this.details = details
},
......
......@@ -18,13 +18,13 @@
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="520px" append-to-body @close="handleClose">
<el-form :model="form" :rules="rules" ref="ruleForm" label-width="120px">
<el-form-item label="Major" prop="major">
<el-input v-model="form.major" size="small" placeholder="请输入课程"/>
<el-input v-model="form.major" size="small" placeholder="请输入专业"/>
</el-form-item>
<el-form-item label="Degree Level" prop="level">
<el-input v-model="form.level" size="small" placeholder="请输入学位"/>
<el-input v-model="form.level" size="small" placeholder="请输入学位等级"/>
</el-form-item>
<el-form-item label="Degree Type" prop="type">
<el-input v-model="form.type" size="small" placeholder="请输入专业"/>
<el-input v-model="form.type" size="small" placeholder="请输入学位类型"/>
</el-form-item>
<el-form-item label="Program" prop="project_id">
<el-select v-model="form.project_id" placeholder="请选择项目" size="small" style="width:100%;">
......@@ -59,8 +59,8 @@ export default {
form: Object.assign({ student_id: this.id }, defaultForm),
rules: {
major: { required: true, message: '请输入专业', trigger: 'blur' },
level: { required: true, message: '请学位', trigger: 'blur' },
type: { required: true, message: '请学位类型', trigger: 'blur' },
level: { required: true, message: '请输入学位等级', trigger: 'blur' },
type: { required: true, message: '请输入学位类型', trigger: 'blur' },
project_id: { required: true, message: '请选择项目', trigger: 'blur' }
},
projectOptions: [],
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论