目录代码整合
This commit is contained in:
169
packages/party/AppQuestionBank/AppQuestionBank.vue
Normal file
169
packages/party/AppQuestionBank/AppQuestionBank.vue
Normal file
@@ -0,0 +1,169 @@
|
||||
<template>
|
||||
<section class="AppQuestionBank">
|
||||
<ai-list v-if="showList">
|
||||
<template #title>
|
||||
<ai-title title="党史题库" isShowBottomBorder></ai-title>
|
||||
</template>
|
||||
<template #content>
|
||||
<ai-search-bar>
|
||||
<template slot="left">
|
||||
<el-button type="primary" icon="iconfont iconAdd" @click="handleAdd">添加</el-button>
|
||||
</template>
|
||||
</ai-search-bar>
|
||||
<ai-table
|
||||
:tableData="tableData"
|
||||
:col-configs="colConfigs"
|
||||
stripe
|
||||
:total="total"
|
||||
:current.sync="page.current"
|
||||
:size.sync="page.size"
|
||||
style="margin-top: 10px;"
|
||||
@getList="getList">
|
||||
<el-table-column slot="options" label="操作" align="center" width="220px" fixed="right">
|
||||
<template slot-scope="{row}">
|
||||
<div class="table-options">
|
||||
<el-button type="text" title="详情" @click="handleDetail(row)">详情</el-button>
|
||||
<el-button type="text" title="编辑" @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button type="text" title="删除" @click="handleDelete(row)">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ai-table>
|
||||
</template>
|
||||
</ai-list>
|
||||
<component :is="comp" v-else :row="row" :instance="instance" :dict="dict" :permissions="permissions" @back="back"
|
||||
:isEdit="isEdit"></component>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import questionBankAdd from "./components/questionBankAdd";
|
||||
import {mapState} from "vuex";
|
||||
|
||||
export default {
|
||||
name: "AppQuestionBank",
|
||||
label: "党史题库",
|
||||
components: {questionBankAdd},
|
||||
props: {
|
||||
instance: Function,
|
||||
dict: Object,
|
||||
permissions: Function,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
comp: "",
|
||||
tableData: [],
|
||||
total: 0,
|
||||
row: {},
|
||||
showList: true,
|
||||
search: {},
|
||||
isEdit: false,
|
||||
partyList: [],
|
||||
treeData: [],
|
||||
page: {
|
||||
current: 1,
|
||||
size: 10
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(["user"]),
|
||||
colConfigs() {
|
||||
return [
|
||||
{label: "类型", render: (h, {row}) => [< span> {row.type == 1 ? '单选题' : '多选题'} < /span>]},
|
||||
{label: "题目", prop: "title"},
|
||||
{label: "创建时间", prop: "createDate"},
|
||||
{slot: "options"}
|
||||
];
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleDetail(row) {
|
||||
this.comp = "questionBankAdd";
|
||||
this.showList = false;
|
||||
this.isEdit = false;
|
||||
this.row = row;
|
||||
},
|
||||
changeParty(e) {
|
||||
if (!e.length) return
|
||||
this.organizationName = e[0]?.name;
|
||||
this.search.current = 1;
|
||||
this.getList();
|
||||
},
|
||||
// 查询所有单位 树形结构
|
||||
searchSysAll(id) {
|
||||
this.instance.post('/admin/partyOrganization/queryAllChildren', null, {
|
||||
params: {
|
||||
id: id
|
||||
}
|
||||
}).then((res) => {
|
||||
if (res?.data) {
|
||||
res.data = res.data.map(a => {
|
||||
return {...a, label: a.name}
|
||||
});
|
||||
this.treeData = res.data.filter(e => e.id == this.user.info.organizationId);
|
||||
this.treeData.map(t => this.addChild(t, res.data));
|
||||
}
|
||||
})
|
||||
},
|
||||
// 点击树节点
|
||||
handleNodeClick(data) {
|
||||
this.partyList = data;
|
||||
},
|
||||
handleDelete({id}) {
|
||||
this.$confirm("是否确定要删除?").then(_ => {
|
||||
this.instance.post("/app/apppartyquestion/delete", null, {
|
||||
params: {
|
||||
ids: id
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$message.success("删除成功");
|
||||
this.getList();
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
handleEdit(row) {
|
||||
this.comp = "questionBankAdd";
|
||||
this.showList = false;
|
||||
this.isEdit = true;
|
||||
this.row = row;
|
||||
},
|
||||
back() {
|
||||
this.comp = "";
|
||||
this.showList = true;
|
||||
this.isEdit = false;
|
||||
this.row = {};
|
||||
this.getList();
|
||||
},
|
||||
handleAdd() {
|
||||
this.comp = "questionBankAdd";
|
||||
this.showList = false;
|
||||
this.isEdit = true;
|
||||
this.row = {};
|
||||
},
|
||||
getList() {
|
||||
this.instance.post("/app/apppartyquestion/list", null, {
|
||||
params: {
|
||||
...this.page
|
||||
}
|
||||
}).then(res => {
|
||||
if (res?.data) {
|
||||
this.tableData = res.data.records;
|
||||
this.total = res.data.total;
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.AppQuestionBank {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
257
packages/party/AppQuestionBank/components/questionBankAdd.vue
Normal file
257
packages/party/AppQuestionBank/components/questionBankAdd.vue
Normal file
@@ -0,0 +1,257 @@
|
||||
<template>
|
||||
<ai-detail>
|
||||
<ai-title slot="title" :title="detailTitle" isShowBottomBorder isShowBack @onBackClick="$emit('back')">
|
||||
</ai-title>
|
||||
<template #content>
|
||||
<ai-card v-if="isEdit" title="基本信息">
|
||||
<el-form slot="content" :model="form" label-width="120px" ref="ruleForm" :rules="rules">
|
||||
<el-form-item label="题目描述" prop="title">
|
||||
<el-input size="small" v-model="form.title" type="textarea" :rows="6" clearable placeholder="请输入..."
|
||||
maxlength="1000"
|
||||
show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label="题目类型" prop="type">
|
||||
<el-radio-group v-model="form.type" @change="radioChange">
|
||||
<el-radio label="1">单选题</el-radio>
|
||||
<el-radio label="2">多选题</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="题目选项" prop="items">
|
||||
<el-row type="flex" v-for="(question,index) in form.items" :key="index" style="width: 100%; margin-bottom: 20px;">
|
||||
<div>
|
||||
<el-form-item :prop="'items.' + index + '.content'" :rules="[{ required: true, message: '选项不能为空', trigger: 'blur' }]">
|
||||
<div class="display: flex;">
|
||||
<label>{{map(index)}}</label>
|
||||
<el-input style="width: 500px; margin: 0 20px;" placeholder="请输入选项内容" size="small" v-model="question.content" clearable></el-input>
|
||||
<el-checkbox :value="question.checked" @change="handleChange(index)">设为答案</el-checkbox>
|
||||
<el-button type="text" icon="iconfont iconDelete" style="margin-top: 6px;"
|
||||
:disabled="form.items.length<=1" @click="handleDel(index)"></el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-button type="text" @click="handleAdd" v-if="form.items && form.items.length<7">添加选项</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="答案解析" prop="analysis">
|
||||
<ai-editor v-model="form.analysis" :instance="instance"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ai-card>
|
||||
<!--详情-->
|
||||
<ai-card class="village_detail" v-else :title="form.title">
|
||||
<template #content>
|
||||
<ai-wrapper :columnsNumber="2" label-width="80px">
|
||||
<ai-info-item label="题目类型:">{{form.type==1?'单选题':'多选题'}}</ai-info-item>
|
||||
<ai-info-item label="正确答案:">
|
||||
<span
|
||||
style="color: #2EA222;">{{form.items && form.items.filter(e=>e.checked).map(e=>e.sort).join(',')}}</span>
|
||||
</ai-info-item>
|
||||
<ai-info-item label="题目选项:" isLine>
|
||||
<div v-for="(item,index) in form.items" :key="index" style="margin-bottom: 8px">
|
||||
{{item.sort}}.{{item.content}}
|
||||
</div>
|
||||
</ai-info-item>
|
||||
<ai-info-item label="答案解析:" isLine>
|
||||
<span v-html="form.analysis"></span>
|
||||
</ai-info-item>
|
||||
</ai-wrapper>
|
||||
</template>
|
||||
</ai-card>
|
||||
</template>
|
||||
<template #footer>
|
||||
<template v-if="isEdit">
|
||||
<el-button size="small" @click="$emit('back')">取消</el-button>
|
||||
<el-button type="primary" size="small" @click="saveAdd(1)">保存
|
||||
</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</ai-detail>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "questionBankAdd",
|
||||
props: {
|
||||
instance: Function,
|
||||
dict: Object,
|
||||
permissions: Function,
|
||||
row: Object,
|
||||
isEdit: Boolean
|
||||
},
|
||||
computed: {
|
||||
detailTitle() {
|
||||
return this.isEdit ? '编辑党史题库' : '党史题库详情'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
title: '',
|
||||
type: '1',
|
||||
analysis: '',
|
||||
items: [{
|
||||
content: "",
|
||||
sort: "A",
|
||||
checked: false,
|
||||
}]
|
||||
},
|
||||
rules: {
|
||||
title: [{required: true, message: "请填写题目描述"}],
|
||||
type: [{required: true, message: "请选择类型"}],
|
||||
items: [{required: true, message: ""}],
|
||||
analysis: [{required: true, message: "请填写答案解析"}],
|
||||
},
|
||||
fileList: [],
|
||||
isDetail: true,
|
||||
count: 0,
|
||||
cropOps: {
|
||||
width: "336px",
|
||||
height: "210px"
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
radioChange(){
|
||||
this.form.items = [...this.form.items.map(e=>({...e,checked:false}))];
|
||||
},
|
||||
handleChange(index) {
|
||||
if (this.form.type == 1) {
|
||||
this.form.items = [...this.form.items.map(e=>({...e,checked:false}))];
|
||||
this.form.items[index].checked = !this.form.items[index].checked;
|
||||
}else {
|
||||
this.form.items[index].checked = !this.form.items[index].checked;
|
||||
}
|
||||
},
|
||||
handleDel(index) {
|
||||
this.form.items.splice(index, 1);
|
||||
},
|
||||
handleAdd() {
|
||||
this.form.items.push({
|
||||
content: "",
|
||||
sort: this.map(this.form.items.length),
|
||||
checked: false,
|
||||
})
|
||||
},
|
||||
map(index) {
|
||||
return {
|
||||
"0": "A",
|
||||
"1": "B",
|
||||
"2": "C",
|
||||
"3": "D",
|
||||
"4": "E",
|
||||
"5": "F",
|
||||
"6": "G",
|
||||
}[index]
|
||||
},
|
||||
downLoad(url) {
|
||||
window.open(url);
|
||||
},
|
||||
saveAdd() {
|
||||
this.$refs.ruleForm.validate(v => {
|
||||
if (v) {
|
||||
if (this.form.items.length < 2) {
|
||||
return this.$message.error("题目选项至少保留两项");
|
||||
}
|
||||
const flag = this.form.items.filter(e=>e.checked).length==0
|
||||
if(flag){
|
||||
return this.$message.error("请设置题目选项答案");
|
||||
}
|
||||
this.instance.post('/app/apppartyquestion/addOrUpdate', {
|
||||
...this.form,
|
||||
items: this.form.items?.map(e => ({...e, checked: e.checked ? 1 : 0})),
|
||||
id: this.row?.id
|
||||
}).then((res) => {
|
||||
if (res && res.code == 0) {
|
||||
this.row?.id ? this.$message.success('修改成功') : this.$message.success('添加成功');
|
||||
this.$emit("back");
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 详情
|
||||
checkDetaiList(id) {
|
||||
id && this.instance.post('/app/apppartyquestion/queryDetailById', null, {
|
||||
params: {id}
|
||||
}).then((res) => {
|
||||
if (res?.data) {
|
||||
const items = res.data.items?.map(e => ({...e, checked: e.checked != 0}));
|
||||
this.form = {...res.data, items};
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.dict.load('partyHistoryType0', 'partyPublicCommentStatus')
|
||||
this.checkDetaiList(this.row?.id);
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.cover {
|
||||
display: block;
|
||||
width: 300px;
|
||||
height: 140px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
.add_Party {
|
||||
height: 100%;
|
||||
position: relative;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.detail-content {
|
||||
padding-bottom: 80px;
|
||||
}
|
||||
|
||||
.el-form {
|
||||
width: 760px;
|
||||
margin: 18px auto 64px;
|
||||
padding-right: 3px !important;
|
||||
|
||||
.el-form-item {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
position: absolute;
|
||||
text-align: left;
|
||||
left: 100px;
|
||||
top: 5px;
|
||||
|
||||
li {
|
||||
color: #888;
|
||||
font-size: 12px;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
b {
|
||||
color: red;
|
||||
font-size: 14px
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.village_detail {
|
||||
margin-top: 16px;
|
||||
width: 760px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
&.isDetail {
|
||||
::v-deep .ai-detail__content {
|
||||
background: #f3f6f9;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user