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

bug fixes

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