parent
321d0841e2
commit
2f2e5c5622
3 changed files with 138 additions and 809 deletions
@ -1,715 +0,0 @@ |
||||
<template> |
||||
<div> |
||||
<el-drawer title="自动选题" :visible.sync="quesVisible" size="1200px" :close-on-click-modal="false" |
||||
custom-class="ques-dia" @closed="closeDia"> |
||||
<div class="overflow"> |
||||
<h6 class="page-name">难度设置</h6> |
||||
<div class="tool"> |
||||
<ul class="filter"> |
||||
<li style="margin-right: 10px"> |
||||
<label>试卷难度</label> |
||||
<el-select v-model="difficult" placeholder="请选择试卷难度" @change="difficultChange"> |
||||
<el-option v-for="(item, i) in difficults" :key="i" :label="item.name" :value="item.id"></el-option> |
||||
</el-select> |
||||
</li> |
||||
<el-tooltip placement="top"> |
||||
<div class="diff-text" slot="content"> |
||||
<p>基础题:难度系数0.2</p> |
||||
<p>普通题:难度系数0.4</p> |
||||
<p>较难题:难度系数0.6</p> |
||||
<p>困难题:难度系数0.8</p> |
||||
<p>(1)<span class="em">题型难度系数</span>=对应题型所有试题的难度系数之和/总试题数</p> |
||||
<p>(2)<span class="em">试卷总难度系数</span>=所有试题的难度系数之和/总试题数</p> |
||||
<p>(3)<span class="em">难度系数评价</span>:</p> |
||||
<div class="coe"> |
||||
<p>简单:系数 <=0.3</p> |
||||
<p>普通:0.3<系数<=0.4</p> |
||||
<p>较难:0.4<系数<0.5</p> |
||||
<p>困难:系数>=0.5</p> |
||||
</div> |
||||
</div> |
||||
<i class="el-icon-question" style="font-size: 16px;color: #8f8f8f;cursor: pointer;"></i> |
||||
</el-tooltip> |
||||
</ul> |
||||
</div> |
||||
|
||||
<el-table :data="list" stripe header-align="center" row-key="libraryId"> |
||||
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column> |
||||
<el-table-column label="大题" align="center" min-width="100"> |
||||
<template slot-scope="scope">第{{ arabicToChinese(scope.$index + 1) }}大题</template> |
||||
</el-table-column> |
||||
<el-table-column prop="name" label="题型" align="center" min-width="90"> |
||||
<template slot-scope="scope"> |
||||
<p v-if="scope.row.questionType">{{ questionTypes.find(e => e.id === scope.row.questionType).name }}</p> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column prop="questionNum" label="目标题数" align="center" min-width="80"></el-table-column> |
||||
<el-table-column label="基础(道题)" align="center" width="90"> |
||||
<template slot-scope="scope"> |
||||
<el-input v-model.number="scope.row.basicDifficulty" type="number" /> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="普通(道题)" align="center" width="90"> |
||||
<template slot-scope="scope"> |
||||
<el-input v-model.number="scope.row.normalDifficulty" type="number" /> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="较难(道题)" align="center" width="90"> |
||||
<template slot-scope="scope"> |
||||
<el-input v-model.number="scope.row.hardDifficulty" type="number" /> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="难(道题)" align="center" width="90"> |
||||
<template slot-scope="scope"> |
||||
<el-input v-model.number="scope.row.veryHardDifficulty" type="number" /> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="难度随机(道题)" align="center" width="100"> |
||||
<template slot-scope="scope"> |
||||
<el-input v-model.number="scope.row.randomDifficulty" type="number" /> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
|
||||
<h6 class="page-name m-t-20">知识点设置</h6> |
||||
<div class="wrap"> |
||||
<!-- 题库 --> |
||||
<div class="item"> |
||||
<p class="total m-b-10">题库</p> |
||||
<ul class="filter"> |
||||
<li class="m-b-10"> |
||||
<label>题库分类</label> |
||||
<el-cascader style="width: 240px;" placeholder="请选择题库分类" v-model="quesBankTypeVal" |
||||
:options="quesBankTypes" :props="{ value: 'id', label: 'name', checkStrictly: true }" clearable |
||||
@change="initQuesBank"></el-cascader> |
||||
</li> |
||||
<li> |
||||
<el-input placeholder="请输入题库名称" prefix-icon="el-icon-search" v-model="quesBankKeyword" clearable /> |
||||
</li> |
||||
</ul> |
||||
|
||||
<template v-if="quesBanks.length"> |
||||
<div class="line"> |
||||
<span class="serial first">序号</span> |
||||
<span>题库名称</span> |
||||
</div> |
||||
|
||||
<div class="able-check lines"> |
||||
<div v-for="(item, i) in quesBanks" :key="i" :class="['line', { active: curQuesBank.id === item.id }]" |
||||
@click="questionBankClick(item)"> |
||||
<span class="serial first">{{ i + 1 }}</span> |
||||
<p class="stem" :title="item.questionBankName">{{ item.questionBankName }}</p> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
<div v-else class="empty"> |
||||
<img class="icon" src="@/assets/images/empty.svg" alt=""> |
||||
<p>暂无数据</p> |
||||
</div> |
||||
</div> |
||||
<!-- 知识点 --> |
||||
<div class="item"> |
||||
<p class="total m-b-10">知识点</p> |
||||
<ul class="filter"> |
||||
<li class="m-b-10"> |
||||
<label>知识点框架</label> |
||||
<el-cascader style="width: 240px;" placeholder="请选择知识点分类" v-model="knowledgeTypeVal" |
||||
:options="knowledgeTypes" :props="{ value: 'id', label: 'name', checkStrictly: true }" clearable |
||||
@change="getKnowledge"></el-cascader> |
||||
</li> |
||||
<li> |
||||
<el-input placeholder="请输入知识点名称" prefix-icon="el-icon-search" v-model="knowledgeKeyword" clearable /> |
||||
</li> |
||||
</ul> |
||||
|
||||
<template v-if="knowledges.length"> |
||||
<div class="line"> |
||||
<el-checkbox v-model="knowledgeCheck" @change="knowledgeAllCheckChange"></el-checkbox> |
||||
<span class="serial">序号</span> |
||||
<span>知识点名称</span> |
||||
</div> |
||||
|
||||
<div class="lines"> |
||||
<div v-for="(item, i) in knowledges" :key="i" class="line"> |
||||
<el-checkbox v-model="item.check" :disabled="item.disabled" |
||||
@change="val => knowledgeChange(val, item)"></el-checkbox> |
||||
<span class="serial">{{ i + 1 }}</span> |
||||
<p class="stem" :title="item.name">{{ item.name }}</p> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
<div v-else class="empty"> |
||||
<img class="icon" src="@/assets/images/empty.svg" alt=""> |
||||
<p>暂无数据</p> |
||||
</div> |
||||
</div> |
||||
<!-- 已选知识点 --> |
||||
<div class="item"> |
||||
<div class="flex j-between a-center m-b-20"> |
||||
<p class="total m-b-10">已选知识点({{ allKnowledges.length }}个)</p> |
||||
<p class="clear" @click="clearChecked"> |
||||
<i class="el-icon-delete m-r-5"></i> |
||||
清空 |
||||
</p> |
||||
</div> |
||||
|
||||
<template v-for="(item, i) in checked"> |
||||
<div :key="i" class="j-between m-b-10"> |
||||
<div class="flex a-center"> |
||||
题库:{{ item.quesBank.questionBankName }} |
||||
<i class="el-icon-delete action-icon m-l-10" @click="delQuesBank(i)"></i> |
||||
</div> |
||||
<div class="knowledges"> |
||||
<el-tag v-for="(tag, j) in item.knowledges" :key="tag.name" class="m-r-8 m-b-8" closable |
||||
@close="delKnowledge(i, j, item, tag)">{{ tag.name }}</el-tag> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
</div> |
||||
</div> |
||||
|
||||
<h6 class="page-name m-t-20">年份设置</h6> |
||||
<div class="years flex"> |
||||
<el-checkbox style="margin-right: 20px" v-model="yearAll" @change="yearAllChange">全选</el-checkbox> |
||||
<el-checkbox-group v-model="yearCheck" @change="yearChange"> |
||||
<el-checkbox v-for="(item, i) in years" :key="i" :label="item"></el-checkbox> |
||||
</el-checkbox-group> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="btns"> |
||||
<el-button @click="quesVisible = false">取消</el-button> |
||||
<el-button type="primary" :loading="submiting" @click="submit">自动选题</el-button> |
||||
</div> |
||||
</el-drawer> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
import Setting from '@/setting' |
||||
import Util from '@/libs/util' |
||||
import QuesConst from '@/const/ques' |
||||
import TestPaperConst from '@/const/testPaper' |
||||
import _ from 'lodash' |
||||
import Decimal from 'decimal.js' |
||||
export default { |
||||
props: ['visible'], |
||||
data () { |
||||
return { |
||||
arabicToChinese: Util.arabicToChinese, |
||||
difficults: TestPaperConst.difficults, |
||||
questionTypes: QuesConst.questionTypes, |
||||
quesVisible: false, |
||||
difficult: '', |
||||
searchTimer: null, |
||||
|
||||
curQuesBank: {}, |
||||
quesBankTypeVal: [], |
||||
quesBankTypes: [], |
||||
quesBankKeyword: '', |
||||
|
||||
quesBanks: [], |
||||
pageQuesBank: 1, |
||||
pageSizeQuesBank: 10, |
||||
totalQuesBank: 0, |
||||
|
||||
knowledgeKeyword: '', |
||||
knowledgeTypeVal: [], |
||||
knowledgeTypes: [], |
||||
knowledgeCheck: false, |
||||
knowledges: [], |
||||
pageKn: 1, |
||||
pageSizeKn: 10, |
||||
totalKn: 0, |
||||
|
||||
checkedKeyword: '', |
||||
checked: [], |
||||
list: [], |
||||
years: ['暂无年份', '2024', '2023', '2022', '2021', '2020', '2019', '2018', '2017', '2016', '更早'], |
||||
yearAll: true, |
||||
yearCheck: [], |
||||
submiting: false, |
||||
loaded: 0, |
||||
}; |
||||
}, |
||||
computed: { |
||||
allKnowledges () { |
||||
const result = [] |
||||
this.checked.map(e => { |
||||
result.push(...e.knowledges) |
||||
}) |
||||
return result |
||||
}, |
||||
}, |
||||
watch: { |
||||
'quesBankKeyword': function (val) { |
||||
clearTimeout(this.searchTimer) |
||||
this.searchTimer = setTimeout(this.initQuesBank, 500) |
||||
}, |
||||
'knowledgeKeyword': function (val) { |
||||
clearTimeout(this.searchTimer) |
||||
this.searchTimer = setTimeout(this.getKnowledge, 500) |
||||
}, |
||||
visible () { |
||||
this.quesVisible = this.visible |
||||
this.visible && this.init() |
||||
} |
||||
}, |
||||
mounted () { |
||||
|
||||
}, |
||||
methods: { |
||||
// 初始化 |
||||
init () { |
||||
this.handleQuesList() |
||||
if (!this.loaded) { |
||||
this.loaded = 1 |
||||
this.yearCheck = this.years |
||||
this.getQuesBankType() |
||||
this.initQuesBank() |
||||
this.difficult = this.$parent.form.difficult |
||||
this.difficult && this.difficultChange(this.difficult) |
||||
} |
||||
}, |
||||
// 获取题库分类 |
||||
async getQuesBankType () { |
||||
try { |
||||
const { data } = await this.$post(this.api.getAllQuestionBankCategories, { |
||||
createSource: 1, |
||||
status: 1, |
||||
}) |
||||
this.handleList(data) |
||||
this.quesBankTypes = data |
||||
} catch (e) { } |
||||
}, |
||||
// 获取题库 |
||||
async getQuesBank () { |
||||
try { |
||||
const type = this.quesBankTypeVal |
||||
const res = await this.$post(this.api.questionBankList, { |
||||
status: 1, |
||||
pageNum: 1, |
||||
pageSize: 1000, |
||||
questionCategoryId: type.length ? type[type.length - 1] : '', |
||||
name: this.quesBankKeyword |
||||
}) |
||||
this.quesBanks = res.message.records |
||||
this.totalQuesBank = res.message.total |
||||
} catch (e) { } |
||||
}, |
||||
initQuesBank () { |
||||
this.curQuesBank = {} |
||||
this.pageQuesBank = 1 |
||||
this.getQuesBank() |
||||
}, |
||||
// 切换页码 |
||||
currentChangeQuesBank (val) { |
||||
this.pageQuesBank = val |
||||
this.getQuesBank() |
||||
}, |
||||
// 题目多选回调 |
||||
questionBankClick (item) { |
||||
this.curQuesBank = item |
||||
this.knowledgeCheck = false |
||||
this.getKnowledgeType() |
||||
this.getKnowledge() |
||||
}, |
||||
|
||||
// 处理树形 |
||||
handleList (list) { |
||||
list.map(e => { |
||||
if (e.children && e.children.length) { |
||||
this.handleList(e.children) |
||||
} else { |
||||
delete e.children |
||||
} |
||||
}) |
||||
}, |
||||
// 获取知识点分类 |
||||
async getKnowledgeType () { |
||||
try { |
||||
const { data } = await this.$post(this.api.classificationTreeStructure, { |
||||
createSource: 1, |
||||
questionBankId: this.curQuesBank.id, |
||||
}) |
||||
this.handleList(data) |
||||
this.knowledgeTypes = data |
||||
} catch (e) { } |
||||
}, |
||||
// 获取知识点 |
||||
async getKnowledge () { |
||||
try { |
||||
const { id } = this.curQuesBank |
||||
if (id) { |
||||
const type = this.knowledgeTypeVal |
||||
const res = await this.$post(this.api.knowledgeHierarchyList, { |
||||
pageNum: 1, |
||||
pageSize: 1000, |
||||
questionBankId: id, |
||||
knowledgePointCategoryId: type.length ? type[type.length - 1] : '', |
||||
name: this.knowledgeKeyword, |
||||
}) |
||||
const list = res.message.records |
||||
const { allKnowledges } = this |
||||
list.map(e => { |
||||
e.check = !!allKnowledges.find(n => n.id === e.id) |
||||
}) |
||||
this.knowledges = list |
||||
} |
||||
} catch (e) { } |
||||
}, |
||||
// 切换页码 |
||||
currentChangeKn (val) { |
||||
this.pageKn = val |
||||
this.getKnowledge() |
||||
}, |
||||
// 知识点全选回调 |
||||
knowledgeAllCheckChange (val) { |
||||
this.knowledges.map(e => { |
||||
e.check = val |
||||
this.knowledgeChange(val, e) |
||||
}) |
||||
}, |
||||
// 知识点勾选回调 |
||||
knowledgeChange (checked, data) { |
||||
const checkQues = this.curQuesBank |
||||
const index = this.checked.findIndex(e => e.quesBank.id === checkQues.id) |
||||
// 已选中的题库数组里有该题库,则往该题库的知识点数组里 |
||||
if (index !== -1) { |
||||
const ques = this.checked[index] |
||||
const i = ques.knowledges.findIndex(e => e.id === data.id) |
||||
if (checked && i === -1) { |
||||
ques.knowledges.push(data) |
||||
} else if (!checked && i >= 0) { |
||||
ques.knowledges.splice(i, 1) |
||||
} |
||||
ques.knowledges.length || this.checked.splice(index, 1) |
||||
} else { |
||||
this.checked.push({ |
||||
quesBank: checkQues, |
||||
knowledges: [data] |
||||
}) |
||||
} |
||||
}, |
||||
// 处理大纲列表 |
||||
handleQuesList () { |
||||
this.list = _.cloneDeep(this.$parent.form.paperOutline) |
||||
}, |
||||
// 清空已选 |
||||
async clearChecked () { |
||||
try { |
||||
await this.$confirm(`确认要清空吗?`, '提示', { |
||||
confirmButtonText: '确定', |
||||
cancelButtonText: '取消', |
||||
type: 'warning', |
||||
closeOnClickModal: false, |
||||
}) |
||||
this.knowledges.map(e => e.check = false) |
||||
this.checked = [] |
||||
this.knowledgeCheck = false |
||||
} catch (e) { } |
||||
}, |
||||
// 删除题库 |
||||
async delQuesBank (i) { |
||||
try { |
||||
await this.$confirm(`确认要移除吗?`, '提示', { |
||||
confirmButtonText: '确定', |
||||
cancelButtonText: '取消', |
||||
type: 'warning', |
||||
closeOnClickModal: false, |
||||
}) |
||||
const k = this.knowledges |
||||
this.checked[i].knowledges.map(e => { |
||||
const cur = k.findIndex(n => n.id === e.id) |
||||
if (cur !== -1) k[cur].check = false |
||||
}) |
||||
this.checked.splice(i, 1) |
||||
this.knowledgeCheck = false |
||||
} catch (e) { } |
||||
}, |
||||
// 删除知识点 |
||||
delKnowledge (i, j, item, k) { |
||||
const cur = this.knowledges.findIndex(e => e.id === k.id) |
||||
if (cur !== -1) this.knowledges[cur].check = false |
||||
item.knowledges.splice(j, 1) |
||||
item.knowledges.length || this.checked.splice(i, 1) // 知识点清空了则把该题库删除 |
||||
this.knowledgeCheck = false |
||||
}, |
||||
|
||||
|
||||
// 试卷难度选择回调 |
||||
difficultChange (val) { |
||||
const difficultyWeights = [0.2, 0.4, 0.6, 0.8] |
||||
const names = ['basicDifficulty', 'normalDifficulty', 'hardDifficulty', 'veryHardDifficulty'] |
||||
// 遍历题型数组 |
||||
this.list.forEach(e => { |
||||
const total = e.questionNum |
||||
|
||||
let already = 0 // 已经分配的数量 |
||||
if (val === 1) { |
||||
this.$set(e, 'basicDifficulty', Math.floor(total * 0.7)) |
||||
this.$set(e, 'normalDifficulty', Math.floor(total * 0.3)) |
||||
this.$set(e, 'hardDifficulty', 0) |
||||
this.$set(e, 'veryHardDifficulty', 0) |
||||
} else if (val === 2) { |
||||
this.$set(e, 'basicDifficulty', Math.floor(total * 0.45)) |
||||
this.$set(e, 'normalDifficulty', Math.floor(total * 0.55)) |
||||
this.$set(e, 'hardDifficulty', 0) |
||||
this.$set(e, 'veryHardDifficulty', 0) |
||||
} else if (val === 3) { |
||||
this.$set(e, 'basicDifficulty', Math.floor(total * 0.3)) |
||||
this.$set(e, 'normalDifficulty', Math.floor(total * 0.3)) |
||||
this.$set(e, 'hardDifficulty', Math.floor(total * 0.4)) |
||||
this.$set(e, 'veryHardDifficulty', 0) |
||||
} else if (val === 4) { |
||||
this.$set(e, 'basicDifficulty', Math.floor(total * 0.1)) |
||||
this.$set(e, 'normalDifficulty', Math.floor(total * 0.1)) |
||||
this.$set(e, 'hardDifficulty', Math.floor(total * 0.3)) |
||||
this.$set(e, 'veryHardDifficulty', Math.floor(total * 0.5)) |
||||
} |
||||
|
||||
|
||||
already = Decimal(already).add(e.basicDifficulty).add(e.normalDifficulty).add(e.hardDifficulty).add(e.veryHardDifficulty).toNumber() |
||||
// 如果按比例分配还没分配完 |
||||
while (total > already) { |
||||
e[names[val - 1]]++ |
||||
already++ |
||||
} |
||||
this.$set(e, 'randomDifficulty', 0) |
||||
}) |
||||
}, |
||||
// 年份全选回调 |
||||
yearAllChange (val) { |
||||
this.yearCheck = val ? this.years : [] |
||||
}, |
||||
// 年份选择回调 |
||||
yearChange (val) { |
||||
this.yearAll = val.length === 11 |
||||
}, |
||||
// 提交 |
||||
async submit () { |
||||
if (this.submiting) return false |
||||
const { list } = this |
||||
let invalid = 0 |
||||
let totalCount = 0 |
||||
for (const i in list) { |
||||
const e = list[i] |
||||
const name = `第${Util.arabicToChinese(+i + 1)}大题` |
||||
if (!e.questionType) { |
||||
Util.warningMsg(`${name}请先选择题型`) |
||||
invalid = 1 |
||||
break |
||||
} |
||||
if (!e.questionNum || isNaN(e.questionNum) || e.questionNum <= 0) { |
||||
Util.warningMsg(`${name}的目标题数请输入正整数`) |
||||
invalid = 1 |
||||
break |
||||
} |
||||
let total = Decimal(e.basicDifficulty || 0).add(e.normalDifficulty || 0).add(e.hardDifficulty || 0).add(e.veryHardDifficulty || 0).toNumber() // 先算前4个难度的题数 |
||||
if (total) { // 前面4个空有填1个,则清空随机 |
||||
this.$set(e, 'randomDifficulty', 0) |
||||
} else { |
||||
total = +e.randomDifficulty || 0 |
||||
} |
||||
|
||||
if (total > e.questionNum) { |
||||
Util.warningMsg(`${name}的小题总数大于目标题数,请重新输入`) |
||||
invalid = 1 |
||||
break |
||||
} |
||||
e.count = total |
||||
totalCount = Decimal(totalCount).add(total).toNumber() |
||||
} |
||||
if (invalid) return false |
||||
if (!totalCount) return Util.warningMsg(`请填写难度题数`) |
||||
this.submiting = true |
||||
const k = this.allKnowledges.map(e => e.id) |
||||
|
||||
const years = [] |
||||
this.yearCheck.map(e => { |
||||
if (e === '暂无年份') { |
||||
years.push('') |
||||
} else if (e === '更早') { |
||||
// 选的是更早则直接传1990~2005所有年份 |
||||
for (let i = 1990; i < 2006; i++) { |
||||
years.push(i) |
||||
} |
||||
} else { |
||||
years.push(+e) |
||||
} |
||||
}) |
||||
list.map(e => { |
||||
e.givenYears = years |
||||
e.knowledgePointsIds = k |
||||
}) |
||||
try { |
||||
const res = await this.$post(this.api.selectQuestionsByTypeAndDifficulty, list) |
||||
|
||||
let invalid = 0 |
||||
let hasQues = 0 |
||||
list.map((e, i) => { |
||||
if (+e.count !== res.list[i].questions.length) invalid = 1 |
||||
if (e.examQuestions.length) hasQues = 1 |
||||
e.score = 0 |
||||
}) |
||||
|
||||
// 3种情况提示不一样 |
||||
const tips = invalid && hasQues ? |
||||
'此操作会清空当前试卷已添加的试题,并且满足自动选题设置的试题数量不足,确定要继续自动选题吗?' : |
||||
invalid && !hasQues ? |
||||
'满足自动选题设置的试题数量不足,确认要继续自动选题吗?' : |
||||
!invalid && hasQues ? '此操作会清空当前试卷已添加的试题,是否确定要继续自动选题吗?' : |
||||
'' |
||||
|
||||
if (tips) { |
||||
await this.$confirm(tips, '提示', { |
||||
confirmButtonText: '确定', |
||||
cancelButtonText: '取消', |
||||
type: 'warning', |
||||
closeOnClickModal: false, |
||||
}) |
||||
} |
||||
list.map((e, i) => { |
||||
res.list[i].questions.map((e, i) => { |
||||
e.questionId = e.id |
||||
e.serialNumber = i + 1 |
||||
e.originSort = i + 1 |
||||
this.$parent.handleQuesInfo(e) |
||||
}) |
||||
this.$parent.form.paperOutline[i].examQuestions = res.list[i].questions |
||||
}) |
||||
this.quesVisible = false |
||||
this.$parent.calcDifficult() |
||||
this.submiting = false |
||||
} catch (e) { |
||||
this.submiting = false |
||||
} |
||||
}, |
||||
// 弹框关闭回调 |
||||
closeDia () { |
||||
this.$emit('update:visible', false) |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
/deep/.ques-dia { |
||||
.el-drawer__header { |
||||
margin-bottom: 20px; |
||||
} |
||||
|
||||
.overflow { |
||||
height: calc(100vh - 147px); |
||||
padding: 0 20px; |
||||
overflow: auto; |
||||
} |
||||
|
||||
|
||||
.wrap { |
||||
display: flex; |
||||
margin-top: 20px; |
||||
border: 1px solid #eee; |
||||
|
||||
.filter { |
||||
margin-bottom: 15px; |
||||
|
||||
li { |
||||
display: flex; |
||||
align-items: center; |
||||
} |
||||
|
||||
label { |
||||
margin-right: 10px; |
||||
font-size: 14px; |
||||
color: #333; |
||||
white-space: nowrap; |
||||
} |
||||
} |
||||
|
||||
.item { |
||||
width: 30%; |
||||
padding: 15px; |
||||
border-right: 1px solid #eee; |
||||
|
||||
&:last-child { |
||||
width: 40%; |
||||
border-right: 0; |
||||
} |
||||
} |
||||
|
||||
.total { |
||||
font-size: 16px; |
||||
color: #333; |
||||
} |
||||
|
||||
.clear { |
||||
display: inline-flex; |
||||
align-items: center; |
||||
font-size: 14px; |
||||
color: #8b8b8b; |
||||
cursor: pointer; |
||||
} |
||||
|
||||
.knowledges { |
||||
padding-left: 44px; |
||||
margin-top: 10px; |
||||
} |
||||
|
||||
.lines { |
||||
height: calc(100vh - 392px); |
||||
overflow: auto; |
||||
} |
||||
|
||||
.line { |
||||
display: flex; |
||||
padding: 5px 0; |
||||
color: #333; |
||||
|
||||
} |
||||
|
||||
.able-check { |
||||
.line { |
||||
cursor: pointer; |
||||
|
||||
&:hover { |
||||
background-color: #f5f5f5; |
||||
} |
||||
|
||||
&.active { |
||||
background-color: #e5e5e5; |
||||
} |
||||
} |
||||
} |
||||
|
||||
.serial { |
||||
width: 32px; |
||||
margin: 0 12px; |
||||
text-align: center; |
||||
white-space: nowrap; |
||||
|
||||
&.first { |
||||
margin-left: 0; |
||||
} |
||||
} |
||||
|
||||
.stem { |
||||
max-width: calc(100% - 71px); |
||||
@include ellipsis; |
||||
} |
||||
|
||||
.checked-stem { |
||||
max-width: 165px; |
||||
@include ellipsis; |
||||
} |
||||
|
||||
.check-left { |
||||
display: inline-flex; |
||||
align-items: center; |
||||
} |
||||
|
||||
.action-icon { |
||||
font-size: 14px; |
||||
} |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,133 @@ |
||||
<template> |
||||
<div> |
||||
<el-dialog title="课题类型设置" :visible.sync="classVisible" width="500px" :close-on-click-modal="false" |
||||
class="manage-dia" :before-close="closeClass"> |
||||
<div class="m-b-10 text-right"> |
||||
<i class="el-icon-circle-plus-outline action-icon" @click="addClass"></i> |
||||
</div> |
||||
<el-table :data="classifications" ref="table" header-align="center" row-key="id"> |
||||
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column> |
||||
<el-table-column prop="classificationName" label="课题类型名称" align="center" min-width="130"> |
||||
<template slot-scope="scope"> |
||||
<el-input v-if="scope.row.edit" placeholder="请输入课题类型名称" v-model="scope.row.classificationName" clearable |
||||
maxlength="30"></el-input> |
||||
<span v-else>{{ scope.row.classificationName }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column prop="updateTime1" label="是否引用" align="center" min-width="60">否</el-table-column> |
||||
<el-table-column label="操作" align="center" min-width="60"> |
||||
<template slot-scope="scope"> |
||||
<i v-if="scope.row.edit" class="el-icon-check edit" @click="submitClass(scope.row)"></i> |
||||
<i v-else class="el-icon-edit action-icon" @click="editClass(scope.row)"></i> |
||||
<i class="el-icon-delete action-icon" @click="delClass(scope.row, scope.$index)"></i> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<span slot="footer"> |
||||
<el-button @click="closeClass">返回</el-button> |
||||
</span> |
||||
</el-dialog> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
import Setting from '@/setting' |
||||
import Util from '@/libs/util' |
||||
import _ from 'lodash' |
||||
import Decimal from 'decimal.js' |
||||
export default { |
||||
props: ['visible', 'list'], |
||||
data () { |
||||
return { |
||||
classVisible: false, |
||||
classifications: [], |
||||
submiting: false, |
||||
}; |
||||
}, |
||||
watch: { |
||||
visible () { |
||||
this.classVisible = this.visible |
||||
this.visible && this.init() |
||||
} |
||||
}, |
||||
mounted () { |
||||
|
||||
}, |
||||
methods: { |
||||
init () { |
||||
this.classifications = _.cloneDeep(this.list) |
||||
}, |
||||
// 新增所属分类 |
||||
addClass () { |
||||
this.classifications.push({ |
||||
edit: true, |
||||
id: '', |
||||
classificationName: '' |
||||
}) |
||||
}, |
||||
// 编辑所属分类 |
||||
editClass (row) { |
||||
this.$set(row, 'edit', 1) |
||||
}, |
||||
// 删除所属分类 |
||||
delClass (row, i) { |
||||
if (row.id) { |
||||
this.$confirm('确定要删除吗?', '提示', { |
||||
type: 'warning' |
||||
}).then(() => { |
||||
this.$post(this.api.delClassif, Util.rsa(row.id)).then(res => { |
||||
Util.successMsg('删除成功') |
||||
this.getClassification() |
||||
}).catch(res => { }) |
||||
}).catch(() => { }) |
||||
} else { |
||||
this.classifications.splice(i, 1) |
||||
} |
||||
}, |
||||
// 提交所属分类 |
||||
submitClass (row, showMsg = 1) { |
||||
if (!row.classificationName) return Util.errorMsg('请输入分类名称') |
||||
this.$post(this.api.checkClassif, Util.rsa({ |
||||
classificationName: encodeURI(row.classificationName), |
||||
siteId: this.site.id, |
||||
classificationId: row.id |
||||
})).then(res => { |
||||
this.$post(this.api[row.id ? 'updateClassif' : 'saveClassif'], Util.rsa({ |
||||
classificationName: encodeURI(row.classificationName), |
||||
templateId: this.columnInfo.templateId, |
||||
id: row.id, |
||||
siteId: this.site.id, |
||||
editorId: this.userId, |
||||
founderId: this.userId |
||||
})).then(res => { |
||||
showMsg && Util.successMsg((row.id ? '修改' : '新增') + '成功') |
||||
this.getClassification() |
||||
}).catch(res => { }) |
||||
}).catch(res => { }) |
||||
}, |
||||
// 关闭所属分类 |
||||
closeClass () { |
||||
const list = this.classifications |
||||
if (list.find(e => e.edit && e.classificationName)) { |
||||
this.$confirm('所填写内容暂未保存,是否保存?', '提示', { |
||||
type: 'warning' |
||||
}).then(() => { |
||||
list.map(e => { |
||||
e.edit && e.classificationName && this.submitClass(e, 0) |
||||
}) |
||||
this.classVisible = false |
||||
}).catch(() => { |
||||
this.classVisible = false |
||||
}) |
||||
} else { |
||||
this.classVisible = false |
||||
} |
||||
}, |
||||
// 弹框关闭回调 |
||||
closeDia () { |
||||
this.$emit('update:visible', false) |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
|
||||
<style lang="scss" scoped></style> |
Loading…
Reference in new issue