|
|
@@ -17,6 +17,7 @@
|
|
|
:model="form"
|
|
|
:rules="rules"
|
|
|
class="paper-form"
|
|
|
+ :class="readonly ? 'readonly-form' : ''"
|
|
|
@submit.native.prevent
|
|
|
>
|
|
|
<el-form-item label="题库名称:" prop="ti_ku_ming_cheng_">
|
|
|
@@ -148,6 +149,19 @@
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<div class="question-table">
|
|
|
+ <div v-if="!readonly" class="question-select">
|
|
|
+ <div class="label">选择试题:</div>
|
|
|
+ <ibps-custom-dialog
|
|
|
+ v-model="quesIdList"
|
|
|
+ size="small"
|
|
|
+ template-key="tmlb"
|
|
|
+ :dynamic-params="{parent_id_: ''}"
|
|
|
+ multiple
|
|
|
+ type="dialog"
|
|
|
+ class="custom-dialog"
|
|
|
+ placeholder="请选择需要关联的题目信息"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
<el-table
|
|
|
ref="elTable"
|
|
|
:data="questionData"
|
|
|
@@ -182,7 +196,7 @@
|
|
|
</div>
|
|
|
<div class="question-info-item">
|
|
|
<div class="label">评分人</div>
|
|
|
- <div class="value">{{ scope.row.rater || '—' }}</div>
|
|
|
+ <div class="value">{{ transformUser(scope.row.rater) }}</div>
|
|
|
</div>
|
|
|
<div class="question-info-item">
|
|
|
<div class="label">标签</div>
|
|
|
@@ -239,16 +253,35 @@
|
|
|
<el-table-column
|
|
|
prop="createTime"
|
|
|
label="出题时间"
|
|
|
- width="150"
|
|
|
+ width="160"
|
|
|
sortable
|
|
|
/>
|
|
|
<el-table-column
|
|
|
fixed="right"
|
|
|
label="操作"
|
|
|
- width="60"
|
|
|
+ width="100"
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button type="text" size="small" @click="handleRowDblclick(scope.row)">修改</el-button>
|
|
|
+ <el-button
|
|
|
+ v-if="!readonly"
|
|
|
+ type="text"
|
|
|
+ size="medium"
|
|
|
+ @click="handleRowDblclick(scope.row, false)"
|
|
|
+ >修改</el-button>
|
|
|
+ <el-button
|
|
|
+ v-if="!readonly"
|
|
|
+ type="text"
|
|
|
+ style="color: #f56c6c;"
|
|
|
+ size="medium"
|
|
|
+ @click="handleRemove(scope.row)"
|
|
|
+ >删除</el-button>
|
|
|
+ <el-button
|
|
|
+ v-if="readonly"
|
|
|
+ type="text"
|
|
|
+ style="color: #909399;"
|
|
|
+ size="medium"
|
|
|
+ @click="handleRowDblclick(scope.row)"
|
|
|
+ >详情</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -263,6 +296,9 @@
|
|
|
v-if="questionDialogVisible"
|
|
|
:id="quesId"
|
|
|
:visible.sync="questionDialogVisible"
|
|
|
+ :is-copy="isCopy"
|
|
|
+ :ques-id-list="quesIdList"
|
|
|
+ :readonly="quesReadonly"
|
|
|
@close="questionDialogVisible = false"
|
|
|
/>
|
|
|
</el-dialog>
|
|
|
@@ -273,7 +309,8 @@ import ActionUtils from '@/utils/action'
|
|
|
import { paperTypeOptions } from '../constants'
|
|
|
export default {
|
|
|
components: {
|
|
|
- QuesEdit: () => import('../question/edit')
|
|
|
+ QuesEdit: () => import('../question/edit'),
|
|
|
+ IbpsCustomDialog: () => import('@/business/platform/data/templaterender/custom-dialog')
|
|
|
},
|
|
|
props: {
|
|
|
visible: {
|
|
|
@@ -283,6 +320,10 @@ export default {
|
|
|
id: {
|
|
|
type: String,
|
|
|
default: ''
|
|
|
+ },
|
|
|
+ readonly: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
|
@@ -291,13 +332,17 @@ export default {
|
|
|
userList,
|
|
|
paperTypeOptions,
|
|
|
deptList: deptList.filter(i => i.depth === 4),
|
|
|
- title: this.id ? '编辑题库' : '创建题库',
|
|
|
+ title: this.readonly ? '题库明细' : this.id ? '编辑题库' : '创建题库',
|
|
|
formLabelWidth: '120px',
|
|
|
dialogVisible: this.visible,
|
|
|
dialogLoading: false,
|
|
|
questionData: [],
|
|
|
+ initialData: [],
|
|
|
questionDialogVisible: false,
|
|
|
quesId: '',
|
|
|
+ quesIdList: '',
|
|
|
+ isCopy: false,
|
|
|
+ quesReadonly: false,
|
|
|
form: {
|
|
|
bian_zhi_bu_men_: '',
|
|
|
bian_zhi_ren_: userId,
|
|
|
@@ -349,13 +394,18 @@ export default {
|
|
|
},
|
|
|
watch: {
|
|
|
visible: {
|
|
|
- handler: function (val, oldVal) {
|
|
|
+ handler (val, oldVal) {
|
|
|
this.dialogVisible = this.visible
|
|
|
}
|
|
|
// immediate: true
|
|
|
+ },
|
|
|
+ quesIdList: {
|
|
|
+ handler (val, oldVal) {
|
|
|
+ this.addSelectQuestion(val)
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
- created () {
|
|
|
+ mounted () {
|
|
|
this.getQuestionData()
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -400,10 +450,21 @@ export default {
|
|
|
const user = userList.find(u => u.userId === userId) || {}
|
|
|
return user.userName || '-'
|
|
|
},
|
|
|
- handleRowDblclick (row) {
|
|
|
+ handleRowDblclick (row, readonly = true) {
|
|
|
this.quesId = row.quesId
|
|
|
+ this.quesReadonly = readonly
|
|
|
+ this.isCopy = this.quesIdList.includes(this.quesId)
|
|
|
this.questionDialogVisible = true
|
|
|
},
|
|
|
+ handleRemove (row) {
|
|
|
+ this.$confirm('确定要删除该题目吗?删除操作将在题库信息保存后生效', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ this.questionData = this.questionData.filter(item => item.quesId !== row.quesId)
|
|
|
+ })
|
|
|
+ },
|
|
|
handleActionEvent ({ key }) {
|
|
|
switch (key) {
|
|
|
case 'submit':
|
|
|
@@ -422,7 +483,7 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
const sql1 = `select id_, bian_zhi_ren_, bian_zhi_bu_men_, bian_zhi_shi_jian, ti_ku_ming_cheng_, ti_ku_fen_lei_, ti_ku_zhuang_tai_, shi_fou_gong_kai_, xian_kao_ci_shu_, ping_fen_ren_, miao_shu_, suo_shu_fan_wei_, kao_shi_shi_chang, da_biao_zhan_bi_ from t_question_bank where id_ = '${this.formId}'`
|
|
|
- const sql2 = `select id_ as quesId, chu_ti_ren_ as creator, bu_men_ as createDept, chu_ti_shi_jian_ as createTime, xu_hao_ as sn, ti_gan_ as content, ti_xing_ as quesType, xuan_xiang_lei_xi as optionType, zheng_que_da_an_ as answer, ping_fen_fang_shi as rateType, ping_fen_ren_ as rater, fen_zhi_ as score, biao_qian_ as quesTag, zhuang_tai_ as quesState from t_questions where parent_id_ = '${this.formId}'`
|
|
|
+ const sql2 = `select id_ as quesId, chu_ti_ren_ as creator, bu_men_ as createDept, chu_ti_shi_jian_ as createTime, xu_hao_ as sn, ti_gan_ as content, ti_xing_ as quesType, fu_tu_ as img, xuan_xiang_lei_xi as optionType, da_an_ as answer, zheng_que_da_an_ as rightKey, ping_fen_fang_shi as rateType, ping_fen_ren_ as rater, fen_zhi_ as score, bei_zhu_ as note, xuan_xiang_shu_ as optionCount, zhuang_tai_ as status, biao_qian_ as quesTag, zhuang_tai_ as quesState from t_questions where parent_id_ = '${this.formId}'`
|
|
|
Promise.all([this.$common.request('sql', sql1), this.$common.request('sql', sql2)]).then(([res1, res2]) => {
|
|
|
const { data: bankData = [] } = res1.variables || {}
|
|
|
const { data: questionData = [] } = res2.variables || {}
|
|
|
@@ -441,11 +502,20 @@ export default {
|
|
|
bank.hours = Math.floor(bank.kao_shi_shi_chang / (1000 * 60 * 60))
|
|
|
bank.minutes = (bank.kao_shi_shi_chang % (1000 * 60 * 60)) / (60 * 1000)
|
|
|
}
|
|
|
- console.log(questionData)
|
|
|
+ // console.log(questionData)
|
|
|
this.questionData = questionData
|
|
|
+ this.initialData = JSON.parse(JSON.stringify(questionData))
|
|
|
+ // this.quesIdList = this.questionData.map(item => item.quesId).join(',')
|
|
|
this.form = bank
|
|
|
})
|
|
|
},
|
|
|
+ addSelectQuestion () {
|
|
|
+ const sql = `select id_ as quesId, chu_ti_ren_ as creator, bu_men_ as createDept, chu_ti_shi_jian_ as createTime, xu_hao_ as sn, ti_gan_ as content, ti_xing_ as quesType, fu_tu_ as img, xuan_xiang_lei_xi as optionType, da_an_ as answer, zheng_que_da_an_ as rightKey, ping_fen_fang_shi as rateType, ping_fen_ren_ as rater, fen_zhi_ as score, bei_zhu_ as note, xuan_xiang_shu_ as optionCount, zhuang_tai_ as status, biao_qian_ as quesTag, zhuang_tai_ as quesState from t_questions where find_in_set(id_, '${this.quesIdList}')`
|
|
|
+ this.$common.request('sql', sql).then(res => {
|
|
|
+ const { data = [] } = res.variables || {}
|
|
|
+ this.questionData = this.questionData.concat(data)
|
|
|
+ })
|
|
|
+ },
|
|
|
handleSubmit () {
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
if (valid) {
|
|
|
@@ -456,12 +526,82 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ async updatePaper (bankId) {
|
|
|
+ const sql = `select fen_zhi_ from t_questions where parent_id_ = '${bankId}'`
|
|
|
+ this.$common.request('sql', sql).then(res => {
|
|
|
+ const { data = [] } = res.variables || {}
|
|
|
+ const params = {
|
|
|
+ tableName: 't_question_bank',
|
|
|
+ updList: [
|
|
|
+ {
|
|
|
+ where: {
|
|
|
+ id_: bankId
|
|
|
+ },
|
|
|
+ param: {
|
|
|
+ ti_shu_: data.length,
|
|
|
+ zong_fen_: data.reduce((sum, item) => sum + parseInt(item.fen_zhi_), 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ this.$common.request('update', params).then(() => {
|
|
|
+ console.log('更新题库信息成功')
|
|
|
+ this.closeDialog()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async createQuestion (list, bankId) {
|
|
|
+ const paramWhere = list.map(item => ({
|
|
|
+ parent_id_: bankId,
|
|
|
+ bu_men_: item.createDept || '',
|
|
|
+ chu_ti_ren_: item.creator,
|
|
|
+ chu_ti_shi_jian_: item.createTime,
|
|
|
+ xu_hao_: item.sn || '',
|
|
|
+ ti_gan_: item.content,
|
|
|
+ ti_xing_: item.quesType,
|
|
|
+ fu_tu_: item.img,
|
|
|
+ xuan_xiang_lei_xi: item.optionType || '',
|
|
|
+ da_an_: item.answer || '',
|
|
|
+ fen_zhi_: item.score,
|
|
|
+ xuan_xiang_shu_: item.optionCount || '',
|
|
|
+ zheng_que_da_an_: item.rightKey,
|
|
|
+ ping_fen_fang_shi: item.rateType || '',
|
|
|
+ ping_fen_ren_: item.rater || '',
|
|
|
+ bei_zhu_: item.note || '',
|
|
|
+ zhuang_tai_: item.status,
|
|
|
+ biao_qian_: item.quesTag || ''
|
|
|
+ }))
|
|
|
+ await this.$common.request('add', {
|
|
|
+ tableName: 't_questions',
|
|
|
+ paramWhere
|
|
|
+ }).then(() => {
|
|
|
+ console.log(2)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 软删除,删除关联关系
|
|
|
+ async deleteQuestion (list) {
|
|
|
+ const updList = list.map(item => ({
|
|
|
+ where: {
|
|
|
+ id_: item.quesId
|
|
|
+ },
|
|
|
+ param: {
|
|
|
+ parent_id_: ''
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ await this.$common.request('update', {
|
|
|
+ tableName: 't_questions',
|
|
|
+ updList
|
|
|
+ }).then(() => {
|
|
|
+ console.log(1)
|
|
|
+ })
|
|
|
+ },
|
|
|
submitForm () {
|
|
|
if (this.form.limitTime === '0') {
|
|
|
this.form.kao_shi_shi_chang = '不限'
|
|
|
} else {
|
|
|
this.form.kao_shi_shi_chang = (this.form.hours * 60 + this.form.minutes) * 60 * 1000
|
|
|
}
|
|
|
+ this.form.bian_zhi_bu_men_ = this.form.suo_shu_fan_wei_ === '科级' ? '' : this.form.bian_zhi_bu_men_
|
|
|
delete this.form.isLimit
|
|
|
delete this.form.limitTime
|
|
|
delete this.form.hours
|
|
|
@@ -487,9 +627,26 @@ export default {
|
|
|
}
|
|
|
const type = this.formId ? 'update' : 'add'
|
|
|
const params = type === 'add' ? addParams : updateParams
|
|
|
- this.$common.request(type, params).then(() => {
|
|
|
- this.$message.success(this.formId ? '保存题库成功' : '新增题库成功')
|
|
|
- this.closeDialog()
|
|
|
+ const temp = this.questionData.filter(i => !this.quesIdList.includes(i.quesId)).map(i => i.quesId)
|
|
|
+ const deleteList = this.initialData.filter(item => !temp.includes(item.quesId))
|
|
|
+ const createList = this.questionData.filter(i => this.quesIdList.includes(i.quesId))
|
|
|
+ this.$common.request(type, params).then(async res => {
|
|
|
+ const { cont = [] } = res.variables || {}
|
|
|
+ let dataId = this.id
|
|
|
+ if (cont.length) {
|
|
|
+ dataId = cont[0].id_
|
|
|
+ }
|
|
|
+ const PromiseList = []
|
|
|
+ if (createList.length) {
|
|
|
+ PromiseList.push(this.createQuestion(createList, dataId))
|
|
|
+ }
|
|
|
+ if (deleteList.length) {
|
|
|
+ PromiseList.push(this.deleteQuestion(deleteList))
|
|
|
+ }
|
|
|
+ Promise.all(PromiseList).then(() => {
|
|
|
+ this.updatePaper(dataId)
|
|
|
+ })
|
|
|
+ this.$message.success(this.formId ? '保存题库信息成功' : '新增题库成功')
|
|
|
})
|
|
|
},
|
|
|
// 关闭当前窗口
|
|
|
@@ -521,6 +678,13 @@ export default {
|
|
|
padding-top: 6px;
|
|
|
}
|
|
|
}
|
|
|
+ .readonly-form {
|
|
|
+ ::v-deep {
|
|
|
+ .el-radio, .el-checkbox, .el-radio-button, .el-input, .el-select, .el-textarea, .el-input-number {
|
|
|
+ pointer-events: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
.paper-form {
|
|
|
padding: 20px;
|
|
|
}
|
|
|
@@ -555,6 +719,19 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ .question-select {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ .label {
|
|
|
+ width: 108px;
|
|
|
+ padding-right: 12px;
|
|
|
+ text-align: right;
|
|
|
+ }
|
|
|
+ .custom-dialog {
|
|
|
+ flex: 1;
|
|
|
+ }
|
|
|
+ margin-bottom: 10px;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
.question-info {
|
|
|
@@ -562,12 +739,12 @@ export default {
|
|
|
display: flex;
|
|
|
margin-bottom: 10px;
|
|
|
max-width: 200px;
|
|
|
+ font-size: 14px;
|
|
|
.label {
|
|
|
width: 100px;
|
|
|
font-size: 14px;
|
|
|
color: #606266;
|
|
|
- text-align: right;
|
|
|
- margin-right: 10px;
|
|
|
+ text-align: left;
|
|
|
}
|
|
|
.value {
|
|
|
font-weight: 600;
|