<template>
|
<div>
|
<el-card style="margin: 10px;" class="affix-container">
|
<div>
|
<div style="display: flex;justify-content: space-between">
|
<div>
|
<b style="margin-right: 20px">{{ $t('menu.QuestionSubject') }}</b>
|
<el-button link size="default" type="primary" :icon="icon.CirclePlus" @click="showAddView">
|
{{ $t('button.New') }}
|
</el-button>
|
</div>
|
<div>
|
<el-input :placeholder="$t('message.PleaseInputKeyWords')" :prefix-icon="icon.Search"
|
maxlength="64"
|
clearable size="default" @clear="SearchData" style="width: 200px;margin-right: 10px"
|
v-model="searchValue.filter" @keydown.enter.native="SearchData"
|
:disabled="showAdvanceSearchView"></el-input>
|
<el-button :icon="icon.Search" type="primary" size="default" @click="SearchData"
|
:disabled="showAdvanceSearchView">
|
{{ $t('button.Search') }}
|
</el-button>
|
<el-button type="warning" size="default"
|
:icon="showAdvanceSearchView ? icon.CaretTop : icon.CaretBottom"
|
@click="showAdvanceSearchView = !showAdvanceSearchView">
|
{{ $t('button.AdvancedSearch') }}
|
</el-button>
|
</div>
|
</div>
|
<transition name="slide-fade">
|
<div v-show="showAdvanceSearchView" class="advanced-search-box">
|
<el-form label-width="120px">
|
<el-row :style="{ margin: '10px 0px 0px 0px' }">
|
<el-col :span="7">
|
<el-form-item :label="$t('label.Name')" :style="{ marginBottom: '0px' }">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
v-model="searchValue.name" placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.Code')" :style="{ marginBottom: '0px' }">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
v-model="searchValue.code" placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :style="{ margin: '10px 0px 0px 0px' }">
|
<el-col :span="14">
|
<el-form-item :label="$t('label.Status')" :style="{ marginBottom: '0px' }">
|
<el-radio-group size="default" v-model="searchValue.status">
|
<el-radio :label="null">{{ $t('label.All') }}</el-radio>
|
<el-radio :label="0">{{ $t('label.Enabled') }}</el-radio>
|
<el-radio :label="1">{{ $t('label.Disabled') }}</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :style="{ margin: '10px 0px 0px 0px' }">
|
<el-col :span="21" :style="{ textAlign: 'right' }" :offset="0">
|
<el-button size="default" :icon="icon.Search" type="primary" @click="SearchData">
|
{{ $t('button.Search') }}
|
</el-button>
|
<el-button size="default" :icon="icon.Delete" type="info" plain
|
@click="ClearSearchData">
|
{{ $t('button.Clear') }}
|
</el-button>
|
<el-button size="default" :icon="icon.CircleClose" type="danger" plain
|
@click="showAdvanceSearchView = !showAdvanceSearchView">
|
{{ $t('button.Close') }}
|
</el-button>
|
</el-col>
|
</el-row>
|
</el-form>
|
</div>
|
</transition>
|
</div>
|
<el-divider :style="{ 'margin': '10px 0px' }"></el-divider>
|
<el-table :data="entityList" stripe border size="default" v-loading="loading"
|
element-loading-text="Loading..." element-loading-spinner="el-icon-loading"
|
element-loading-background="rgba(0, 0, 0, 0.8)"
|
:header-row-style="{ height: '40px', color: 'var(--el-color-primary)', background: '#f5f4f4', }"
|
:header-cell-style="{ height: '40px', margin: '0px', padding: '0px', background: 'transparent' }"
|
:row-style="{ height: '30px', margin: '0px', padding: '0px', }"
|
:cell-style="{ height: '30px', margin: '0px', padding: '0px', }"
|
@row-dblclick="showEditView"
|
@selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="40"/>
|
<el-table-column type="index" fixed :label="$t('label.Index')" width="65"/>
|
<el-table-column prop="code" sortable align="left" :label="$t('label.Code')" width="100"/>
|
<el-table-column prop="name" align="left" :label="$t('label.Name')" width="150"/>
|
<el-table-column align="center" :label="$t('label.QuestionPaperList')" width="160">
|
<template #default="scope">
|
<el-button @click="showQuestionPaperView(scope.row)" :icon="icon.Pointer" size="small"
|
type="primary">
|
{{ $t('label.QuestionPaperList') }}
|
</el-button>
|
</template>
|
</el-table-column>
|
<el-table-column prop="point" align="center" :label="$t('label.KnowledgePoint')" width="160">
|
<template #default="scope">
|
<el-button @click="showKnowledgePointView(scope.row)" :icon="icon.Pointer" size="small"
|
type="primary">
|
{{ $t('menu.QuestionSubjectKnowledgePoint') }}
|
</el-button>
|
</template>
|
</el-table-column>
|
<el-table-column prop="status" sortable align="left" :label="$t('label.Status')" width="150">
|
<template #default="scope">
|
<el-tag v-if="scope.row.status === 0" type="success">
|
{{ $t('label.Enabled') }}
|
</el-tag>
|
<el-tag v-else-if="scope.row.status === 1" type="danger">
|
{{ $t('label.Disabled') }}
|
</el-tag>
|
<el-tag v-else type="info">
|
{{ $t('label.Undefined') }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="remark" sortable align="left" :label="$t('label.Remark')" min-width="300"
|
width="*"/>
|
<el-table-column fixed="right" :label="$t('label.Operation')" width="110">
|
<template #default="scope">
|
<el-button @click="showEditView(scope.row)" :icon="icon.Edit" size="small" type="primary"
|
circle>
|
</el-button>
|
<el-button @click="deleteItem(scope.row)" :icon="icon.Delete" size="small" type="danger" circle>
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-affix position="bottom" :offset="10" target=".affix-container">
|
<div style="background: white;padding-bottom:10px;">
|
<el-divider :style="{ 'margin': '10px 0px' }"></el-divider>
|
<el-row>
|
<el-col :span="12" align="left">
|
|
</el-col>
|
<el-col :span="12" align="right">
|
<div style="display: flex;justify-content: flex-end">
|
<el-pagination :currentPage="pageIndex" :page-size="pageSize" background
|
@current-change="currentChange" @size-change="sizeChange"
|
:page-sizes="[10, 20, 50, 100]"
|
layout="sizes, prev, pager, next, jumper, ->, total, slot"
|
:total="total">
|
</el-pagination>
|
</div>
|
</el-col>
|
</el-row>
|
</div>
|
</el-affix>
|
</el-card>
|
<div v-dialogdrag>
|
<el-dialog :title="title" id="detailDialog" v-model="dialogVisible" :close-on-click-modal="false"
|
class="el-dialog-customer" width="1000px">
|
<template #header>
|
<el-row>
|
<el-col :span="12">
|
<el-icon style="font:normal bold 20px arial,sans-serif;vertical-align: -10%"
|
v-if="dialogMode === 'new'">
|
<plus/>
|
</el-icon>
|
<el-icon v-else style="font:normal bold 20px arial,serif;vertical-align: -10%">
|
<edit/>
|
</el-icon>
|
<span style="margin-left: 10px; font:normal bold 20px arial,serif;">{{ title }}</span>
|
</el-col>
|
</el-row>
|
</template>
|
<el-card style="margin-top: 0px;">
|
<el-form :model="entity" :rules="rules" ref="dialogForm" label-width="120px" size="default">
|
<el-tabs style="min-height: 300px" v-if="dialogVisible">
|
<el-tab-pane :label="$t('label.BasicInformation')">
|
<el-row>
|
<el-col :span="14">
|
<el-form-item :label="$t('label.Name')" prop="name">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
v-model="entity.name">
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.Code')" prop="code">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
disabled="disabled"
|
v-model="entity.code">
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="14">
|
<el-form-item :label="$t('label.Status')" prop="status">
|
<el-radio-group v-model="entity.status">
|
<el-radio :label="0">{{ $t('label.Enabled') }}</el-radio>
|
<el-radio :label="1">{{ $t('label.Disabled') }}</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</el-col>
|
<el-col :span="21">
|
<el-form-item :label="$t('label.Remark')" prop="remark">
|
<el-input type="textarea" :rows="5" maxlength="500"
|
v-model="entity.remark"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-tab-pane>
|
</el-tabs>
|
</el-form>
|
</el-card>
|
<template #footer>
|
<el-button type="primary" @click="onSubmit" :icon="icon.CircleCheck" size="default">
|
{{ $t('button.Submit') }}
|
</el-button>
|
<el-button type="danger" @click="dialogVisible = false" :icon="icon.CircleClose" size="default"
|
plain>
|
{{ $t('button.Close') }}
|
</el-button>
|
</template>
|
</el-dialog>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
|
import * as icon from '@element-plus/icons-vue'
|
import {getCurrentInstance, onBeforeUnmount, onMounted, reactive, toRefs, shallowRef, ref} from "vue";
|
import {formatDate, DownloadBlobFileStream} from '../../../utils/common'
|
import {
|
GetQuestionSubjects,
|
CreateQuestionSubject,
|
UpdateQuestionSubject,
|
DeleteQuestionSubject
|
} from "../../../api/admin/question"
|
import {useBasicInfoStore} from "../../../store/basicInfo";
|
import wangEditorExt from '../../../components/common/wangEditorExt.vue'
|
import * as elementplus from "element-plus";
|
|
export default {
|
name: "QuestionSubject",
|
components: {wangEditorExt},
|
setup() {
|
let {proxy} = getCurrentInstance();
|
const store = useBasicInfoStore();
|
const state = reactive({
|
//common properties
|
title: '',
|
total: 0,
|
pageIndex: 1,
|
pageSize: store.config.ListSize,
|
loading: false,
|
windowWidth: document.documentElement.clientWidth,
|
windowHeight: document.documentElement.clientHeight,
|
dialogVisible: false,
|
dialogMode: 'new',
|
showAdvanceSearchView: false,
|
searchValue: {
|
filter: "",
|
code: "",
|
name: "",
|
status: null,
|
},
|
entityList: [],
|
multipleSelection: [],
|
entity: {
|
id: "",
|
code: "",
|
name: "",
|
status: 0,
|
remark: "",
|
},
|
rules: {
|
name: [{
|
required: true,
|
message: `${proxy.$t('message.IsRequired', {name: proxy.$t('label.Name')})}`,
|
trigger: 'blur'
|
}],
|
},
|
});
|
|
onMounted(() => {
|
Init();
|
LoadData();
|
});
|
onBeforeUnmount(() => {
|
|
});
|
|
const Init = () => {
|
|
};
|
const getSearchCondition = () => {
|
let condition;
|
if (!state.showAdvanceSearchView) {
|
condition = {
|
pageIndex: state.pageIndex,
|
pageSize: state.pageSize,
|
filter: state.searchValue.filter,
|
permissionLevel: store.permissionLevel,
|
}
|
} else {
|
condition = {
|
pageIndex: state.pageIndex,
|
pageSize: state.pageSize,
|
code: state.searchValue.code,
|
name: state.searchValue.name,
|
status: state.searchValue.status,
|
}
|
}
|
|
return condition;
|
};
|
const LoadData = () => {
|
state.loading = true;
|
let condition = getSearchCondition();
|
|
GetQuestionSubjects(condition).then(resp => {
|
state.loading = false;
|
console.info(resp.data);
|
if (resp.data) {
|
state.entityList = resp.data.data;
|
state.total = resp.data.total;
|
}
|
}).catch(err => {
|
console.error(err);
|
});
|
};
|
const sizeChange = (currentSize) => {
|
state.pageSize = currentSize;
|
store.config.ListSize = state.pageSize;
|
LoadData();
|
};
|
const currentChange = (currentPage) => {
|
state.pageIndex = currentPage;
|
LoadData();
|
};
|
const clearAddOrEditModel = () => {
|
state.entity = {
|
id: "",
|
code: "",
|
name: "",
|
status: 0,
|
remark: "",
|
}
|
};
|
const SearchData = () => {
|
state.page = 1;
|
LoadData();
|
};
|
const ClearSearchData = () => {
|
state.searchValue = {
|
filter: "",
|
code: "",
|
name: "",
|
status: null,
|
};
|
};
|
|
const showAddView = () => {
|
clearAddOrEditModel();
|
state.title = proxy.$t('button.New');
|
state.dialogMode = 'new';
|
state.dialogVisible = true;
|
};
|
const showEditView = (data) => {
|
state.title = `${proxy.$t('button.Edit')} [${data.name}]`;
|
state.dialogMode = 'edit';
|
state.entity = data;
|
state.dialogVisible = true;
|
};
|
|
const handleSelectionChange = (val) => {
|
state.multipleSelection = val
|
};
|
const exportSelectionvalue = () => {
|
return state.multipleSelection;
|
}
|
|
const onSubmit = () => {
|
if (state.entity.id) {
|
proxy.$refs['dialogForm'].validate(valid => {
|
if (valid) {
|
proxy.$confirm(`${proxy.$t('message.AreYouSureToSubmit')}`, `${proxy.$t('label.SystemConfirm')}`, {
|
confirmButtonText: `${proxy.$t('button.Yes')}`,
|
cancelButtonText: `${proxy.$t('button.No')}`,
|
type: 'warning',
|
center: true
|
}).then(() => {
|
const rLoading = proxy.openLoading("#detailDialog");
|
UpdateQuestionSubject(state.entity).then(resp => {
|
if (resp.data && resp.data.code !== 200) {
|
elementplus.ElMessageBox.alert(
|
`${proxy.$t('message.' + resp.data.message)}`,
|
'',
|
{
|
confirmButtonText: 'OK',
|
type: 'error',
|
}
|
);
|
} else {
|
state.dialogVisible = false;
|
LoadData();
|
}
|
rLoading.close();
|
});
|
}).catch((error) => {
|
console.error(error)
|
})
|
}
|
});
|
} else {
|
proxy.$refs['dialogForm'].validate(valid => {
|
if (valid) {
|
proxy.$confirm(`${proxy.$t('message.AreYouSureToSubmit')}`, `${proxy.$t('label.SystemConfirm')}`, {
|
confirmButtonText: `${proxy.$t('button.Yes')}`,
|
cancelButtonText: `${proxy.$t('button.No')}`,
|
type: 'warning',
|
center: true
|
}).then(() => {
|
const rLoading = proxy.openLoading("#detailDialog");
|
CreateQuestionSubject(state.entity).then(resp => {
|
if (resp.data && resp.data.code !== 200) {
|
elementplus.ElMessageBox.alert(
|
`${proxy.$t('message.' + resp.data.message)}`,
|
'',
|
{
|
confirmButtonText: 'OK',
|
type: 'error',
|
}
|
);
|
} else {
|
state.dialogVisible = false;
|
LoadData();
|
}
|
rLoading.close();
|
});
|
}).catch((error) => {
|
console.error(error)
|
})
|
}
|
});
|
}
|
};
|
const deleteItem = (data) => {
|
proxy.$confirm(`${proxy.$t('message.AreYouSureToRemove')}`, `${proxy.$t('label.SystemConfirm')}`, {
|
confirmButtonText: `${proxy.$t('button.Yes')}`,
|
cancelButtonText: `${proxy.$t('button.No')}`,
|
confirmButtonClass: 'confirmButtonClass',
|
cancelButtonClass: 'cancelButtonClass',
|
type: 'warning',
|
center: true,
|
}).then(() => {
|
state.loading = true;
|
DeleteQuestionSubject(data.id).then(resp => {
|
if (resp) {
|
if (resp.data && resp.data.code !== 200) {
|
elementplus.ElMessageBox.alert(
|
`${proxy.$t('message.' + resp.data.message)}`,
|
'',
|
{
|
confirmButtonText: 'OK',
|
type: 'error',
|
}
|
);
|
} else {
|
LoadData();
|
}
|
}
|
state.loading = false;
|
});
|
}).catch((error) => {
|
console.error(error);
|
state.loading = false;
|
});
|
};
|
|
const showKnowledgePointView = (data) => {
|
store.$state.subject = data;
|
proxy.$router.push(
|
{
|
path: '../../admin/question/QuestionSubjectKnowledgePoint',
|
query: {
|
subjectid: data.id,
|
}
|
});
|
};
|
const showQuestionPaperView = (data) => {
|
store.$state.subject = data;
|
proxy.$router.push(
|
{
|
path: '../../admin/question/QuestionPaper',
|
query: {
|
subjectid: data.id,
|
}
|
});
|
};
|
|
//formatter
|
const formatterDatetime = (row, column) => {
|
let date = null;
|
switch (column.property) {
|
case "createtime":
|
if (!row.createtime)
|
return null;
|
date = new Date(row.createtime);
|
break;
|
case "birthday":
|
if (!row.birthday)
|
return null;
|
date = new Date(row.birthday);
|
break;
|
case "actiontime":
|
if (!row.actiontime)
|
return null;
|
date = new Date(row.actiontime);
|
break;
|
case "validdateto":
|
if (!row.validdateto)
|
return null;
|
date = new Date(row.validdateto);
|
break;
|
case "validdatefrom":
|
if (!row.validdatefrom)
|
return null;
|
date = new Date(row.validdatefrom);
|
break;
|
}
|
|
return formatDate(date, 'yyyy-MM-dd hh:mm');
|
};
|
const formatterStatusBoolean = (row, column) => {
|
var ret = ''
|
if (row.status) {
|
ret = "Valid";
|
} else {
|
ret = "Invalid";
|
}
|
return ret;
|
};
|
const capitalize = (value) => {
|
if (!value) return ''
|
value = value.toString()
|
return value.charAt(0).toUpperCase() + value.slice(1)
|
};
|
|
return {
|
...toRefs(state),
|
icon,
|
LoadData,
|
sizeChange,
|
currentChange,
|
clearAddOrEditModel,
|
SearchData,
|
ClearSearchData,
|
showAddView,
|
showEditView,
|
deleteItem,
|
onSubmit,
|
handleSelectionChange,
|
exportSelectionvalue,
|
formatterDatetime,
|
formatterStatusBoolean,
|
capitalize,
|
showKnowledgePointView,
|
showQuestionPaperView
|
}
|
},
|
}
|
</script>
|
|
<style></style>
|