<template>
|
<div>
|
<el-card style="margin: 10px;" class="affix-container">
|
<div>
|
<div style="display: flex;justify-content: space-between">
|
<div>
|
<el-button link type="primary" @click="GoBack" :icon="icon.Back" size="default"
|
style="margin-right: 15px">
|
{{ $t('button.Back') }}
|
</el-button>
|
<b style="margin-right: 20px">
|
{{ $t('menu.QuestionPaper') }}
|
</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-row :style="{ 'margin': '10px 0px 10px 0px' }">
|
<el-col :span="24">
|
<el-space wrap>
|
<el-alert type="info" :closable="false">
|
<template #title>
|
{{ `${$t('label.Subject')}:` }}
|
<el-popover placement="bottom" trigger="click" width="auto">
|
<template #reference>
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
style="width: 230px" @change="subjectChange"
|
v-model="subjectname"
|
:placeholder="$t('message.PleaseInput')">
|
</el-input>
|
</template>
|
<el-tree :data="subjects" :props="defaultProps"
|
accordion
|
@node-click="handleSubjectSelectClick"></el-tree>
|
</el-popover>
|
</template>
|
</el-alert>
|
</el-space>
|
</el-col>
|
</el-row>
|
<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">
|
<!-- <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 prop="coverimage" align="center" :label="$t('label.CoverImage')" width="130">
|
<template #default="scope">
|
<div>
|
<svg-icon v-if="!scope.row.coverimage" name="question-paper" width="80" height="80"
|
style="margin: 5px"
|
color=""/>
|
<el-image v-else style="width: 100px; height: 100px; margin: 5px"
|
:src="scope.row.coverimage"
|
fit="cover"
|
/>
|
</div>
|
</template>
|
</el-table-column>
|
<el-table-column align="center" :label="$t('label.QuestionList')" width="160">
|
<template #default="scope">
|
<el-button @click="showQuestionView(scope.row)" :icon="icon.Pointer" size="small"
|
type="primary">
|
{{ $t('label.QuestionList') }}
|
</el-button>
|
</template>
|
</el-table-column>
|
<el-table-column prop="subjectname" sortable align="left" :label="$t('label.Subject')" width="200"/>
|
<el-table-column prop="categoryname" sortable align="left" :label="$t('label.Category')" width="200"/>
|
<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="type" sortable align="left" :label="$t('label.Type')" width="150">
|
<template #default="scope">
|
<el-tag v-if="scope.row.type === 0" type="success">
|
{{ $t('label.FREE') }}
|
</el-tag>
|
<el-tag v-else-if="scope.row.type === 1" type="warning">
|
{{ $t('label.VIP_FREE') }}
|
</el-tag>
|
<el-tag v-else type="danger">
|
{{ $t('label.CHARGE') }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="price" sortable align="left" :label="$t('label.Price')" width="150">
|
<template #default="scope">
|
{{ `ï¿¥${scope.row.price}` }}
|
</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="6" :style="{textAlign: 'center'}">
|
<svg-icon v-if="!entity.coverimage" name="question-paper" width="100" height="100"
|
style="margin: 5px"
|
color=""/>
|
<el-image v-else
|
style="width: 100px; height: 100px; margin: 5px"
|
:src="entity.coverimage"
|
:preview-src-list="[entity.coverimage]"
|
:z-index="1000"
|
fit="cover"
|
/>
|
<el-upload class="avatar-uploader"
|
:action="uploadurl"
|
:show-file-list="false"
|
:on-success="handleAvatarSuccess"
|
:on-error="handleAvatarError"
|
:before-upload="beforeAvatarUpload">
|
<el-button size="small" :icon="icon.Upload">
|
{{ $t('button.Upload') }}
|
</el-button>
|
</el-upload>
|
</el-col>
|
<el-col :span="15">
|
<el-row>
|
<el-col :span="24">
|
<el-form-item :label="$t('label.Name')" prop="name">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
style="width:100%"
|
v-model="entity.name"
|
:placeholder="$t('label.Name')">
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item :label="$t('label.Code')" prop="code">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
style="width:100%"
|
v-model="entity.code" disabled="disabled"
|
:placeholder="$t('label.Code')">
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item :label="$t('label.Subject')" prop="subjectname">
|
<el-popover placement="bottom" trigger="click" width="auto">
|
<template #reference>
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
style="width: 230px" @change="subjectChangeForAdd"
|
v-model="entity.subjectname"
|
:placeholder="$t('message.PleaseInput')">
|
</el-input>
|
</template>
|
<el-tree :data="subjects" :props="defaultProps"
|
accordion
|
@node-click="handleSubjectSelectClickForAdd"></el-tree>
|
</el-popover>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item :label="$t('label.Price')" prop="price">
|
<el-input-number size="default" :prefix-icon="icon.Edit"
|
style="width:100%"
|
maxlength="64"
|
:precision="2" :step="0.1"
|
v-model="entity.price"
|
:placeholder="$t('message.PleaseInput')"></el-input-number>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item :label="$t('label.Type')" prop="type">
|
<el-select size="default" style="width: 100%" v-model="entity.type"
|
filterable>
|
<el-option v-for="item in entitytypes" :key="item.id" :label="item.name"
|
:value="item.id" :disabled="item.disabled">
|
{{ item.name }}
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.Category')" prop="categoryname">
|
<el-popover placement="right" trigger="click" width="auto"
|
style="width:100%">
|
<template #reference>
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
style="width: 100%" @change="categoryChange"
|
v-model="entity.categoryname"
|
:placeholder="$t('label.Category')">
|
</el-input>
|
</template>
|
<el-tree :data="categories" :props="defaultProps"
|
accordion
|
@node-click="handleCategorySelectClick"></el-tree>
|
</el-popover>
|
</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" placeholder=""
|
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, onActivated} from "vue";
|
import {formatDate, DownloadBlobFileStream} from '../../../utils/common'
|
import {
|
GetQuestionSubjects,
|
GetQuestionPapers,
|
CreateQuestionPaper,
|
UpdateQuestionPaper,
|
DeleteQuestionPaper,
|
GetQuestionPaperCategoryTree
|
} from "../../../api/admin/question"
|
import {useBasicInfoStore} from "../../../store/basicInfo";
|
import * as elementplus from "element-plus";
|
import {getFileUploadUrl} from "@/api/common";
|
|
export default {
|
name: "QuestionPaper",
|
components: {},
|
setup() {
|
let {proxy} = getCurrentInstance();
|
const store = useBasicInfoStore();
|
const state = reactive({
|
subject: store.$state.subject,
|
subjectcode: "",
|
subjectname: "",
|
//common properties
|
title: '',
|
total: 0,
|
pageIndex: 1,
|
pageSize: store.config.ListSize,
|
loading: false,
|
windowWidth: document.documentElement.clientWidth,
|
windowHeight: document.documentElement.clientHeight,
|
uploadurl: '',
|
dialogVisible: false,
|
dialogMode: 'new',
|
showAdvanceSearchView: false,
|
searchValue: {
|
filter: "",
|
code: "",
|
name: "",
|
status: null,
|
},
|
defaultProps: {
|
children: 'children',
|
label: 'name'
|
},
|
categories: [],
|
entityList: [],
|
entity: {
|
id: "",
|
code: "",
|
name: "",
|
status: 0,
|
price: 0,
|
subjectid: "",
|
subjectname: "",
|
subjectcode: "",
|
categoryid: "",
|
categoryname: "",
|
type: 0,
|
remark: "",
|
coverimage: "",
|
},
|
entitytypes: [
|
{
|
id: 0,
|
name: `${proxy.$t('label.FREE')}`,
|
},
|
{
|
id: 1,
|
name: `${proxy.$t('label.VIP_FREE')}`,
|
},
|
{
|
id: 2,
|
name: `${proxy.$t('label.CHARGE')}`,
|
}
|
],
|
category: {
|
id: "",
|
code: "",
|
name: "",
|
status: 0,
|
remark: "",
|
icon: "",
|
},
|
rules: {
|
name: [{
|
required: true,
|
message: `${proxy.$t('message.IsRequired', {name: proxy.$t('label.Name')})}`,
|
trigger: 'blur'
|
}],
|
subjectname: [{
|
required: true,
|
message: `${proxy.$t('message.IsRequired', {name: proxy.$t('label.Subject')})}`,
|
trigger: 'blur'
|
}],
|
categoryname: [{
|
required: true,
|
message: `${proxy.$t('message.IsRequired', {name: proxy.$t('label.Category')})}`,
|
trigger: 'blur'
|
}],
|
},
|
subjects: [],
|
masterrules: {
|
subjectname: [{
|
required: true,
|
message: `${proxy.$t('message.IsRequired', {name: proxy.$t('label.Subject')})}`,
|
trigger: 'blur'
|
}],
|
},
|
});
|
|
onMounted(() => {
|
Init();
|
});
|
onBeforeUnmount(() => {
|
|
});
|
onActivated(() => {
|
state.subject = store.$state.subject;
|
|
Init();
|
});
|
|
const Init = () => {
|
if (store.$state.subject) {
|
state.subjectname = store.$state.subject.name;
|
state.subjectcode = store.$state.subject.code;
|
}
|
|
state.uploadurl = getFileUploadUrl();
|
|
LoadData();
|
LoadSubject();
|
LoadCategory();
|
};
|
const getSearchCondition = () => {
|
let condition;
|
if (!state.showAdvanceSearchView) {
|
condition = {
|
pageIndex: state.pageIndex,
|
pageSize: state.pageSize,
|
filter: state.searchValue.filter,
|
permissionLevel: store.permissionLevel,
|
subjectid: state.subject.id
|
}
|
} else {
|
condition = {
|
pageIndex: state.pageIndex,
|
pageSize: state.pageSize,
|
code: state.searchValue.code,
|
name: state.searchValue.name,
|
status: state.searchValue.status,
|
subjectid: state.subject.id
|
}
|
}
|
|
return condition;
|
};
|
const LoadData = () => {
|
state.entityList = [];
|
state.total = 0;
|
|
if (!state.subject) {
|
return;
|
}
|
|
state.loading = true;
|
let condition = getSearchCondition();
|
|
GetQuestionPapers(condition).then(resp => {
|
state.loading = false;
|
if (resp.data) {
|
state.entityList = resp.data.data;
|
state.total = resp.data.total;
|
}
|
}).catch(err => {
|
console.error(err);
|
});
|
};
|
|
const LoadSubject = () => {
|
GetQuestionSubjects({}).then(resp => {
|
state.loading = false
|
if (resp.data) {
|
state.subjects = resp.data.data
|
}
|
}).catch(err => {
|
console.error(err)
|
})
|
};
|
const handleSubjectSelectClick = (data) => {
|
state.subject = data;
|
store.$state.subject = state.subject;
|
state.subjectcode = store.$state.subject.code;
|
state.subjectname = store.$state.subject.name;
|
|
SearchData();
|
};
|
const subjectChange = (data) => {
|
if (!data) {
|
state.subject = null;
|
state.subjectcode = "";
|
state.subjectname = "";
|
}
|
};
|
const handleSubjectSelectClickForAdd = (data) => {
|
state.entity.subjectid = data.id;
|
state.entity.subjectcode = data.code;
|
state.entity.subjectname = data.name;
|
};
|
const subjectChangeForAdd = (data) => {
|
if (!data) {
|
state.entity.subjectid = "";
|
state.entity.subjectcode = "";
|
state.entity.subjectname = "";
|
}
|
};
|
|
const LoadCategory = () => {
|
GetQuestionPaperCategoryTree().then(resp => {
|
state.loading = false
|
if (resp.data) {
|
state.categories = resp.data
|
}
|
}).catch(err => {
|
console.error(err)
|
})
|
};
|
const handleCategorySelectClick = (data) => {
|
state.entity.categoryid = data.id;
|
state.entity.categoryname = data.name;
|
|
SearchData();
|
};
|
const categoryChange = (data) => {
|
if (!data) {
|
state.category = {
|
id: "",
|
code: "",
|
name: "",
|
status: 0
|
};
|
state.entity.categoryid = "";
|
state.entity.categoryname = "";
|
}
|
};
|
|
const sizeChange = (currentSize) => {
|
state.pageSize = currentSize;
|
store.config.ListSize = state.pageSize;
|
LoadData();
|
};
|
const currentChange = (currentPage) => {
|
state.pageIndex = currentPage;
|
LoadData();
|
};
|
const clearAddOrEditModel = () => {
|
let subjectid = state.subject.id;
|
let subjectname = state.subject.name;
|
let subjectcode = state.subject.code;
|
|
state.entity = {
|
id: "",
|
code: "",
|
name: "",
|
status: 0,
|
price: 0,
|
subjectid: subjectid,
|
subjectname: subjectname,
|
subjectcode: subjectcode,
|
categoryid: "",
|
categoryname: "",
|
type: 0,
|
remark: "",
|
coverimage: "",
|
}
|
state.subjects = [];
|
};
|
const SearchData = () => {
|
if (state.subject) {
|
state.page = 1;
|
|
LoadData();
|
}
|
};
|
const ClearSearchData = () => {
|
state.searchValue = {
|
filter: "",
|
code: "",
|
name: "",
|
status: null,
|
};
|
};
|
|
const showAddView = () => {
|
clearAddOrEditModel();
|
LoadSubject();
|
LoadCategory();
|
|
state.title = proxy.$t('button.New');
|
state.dialogMode = 'new';
|
state.dialogVisible = true;
|
};
|
const showEditView = (data) => {
|
LoadSubject();
|
LoadCategory();
|
|
state.title = `${proxy.$t('button.Edit')} [${data.name}]`;
|
state.dialogMode = 'edit';
|
state.entity = data;
|
state.dialogVisible = true;
|
};
|
|
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");
|
UpdateQuestionPaper(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");
|
CreateQuestionPaper(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;
|
DeleteQuestionPaper(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 showQuestionView = (data) => {
|
store.$state.paper = data;
|
proxy.$router.push(
|
{
|
path: '../../admin/question/QuestionPaperQuestionList',
|
query: {
|
paperid: data.id,
|
}
|
});
|
};
|
|
const handleAvatarSuccess = (res, file) => {
|
state.entity.coverimage = res;
|
};
|
const beforeAvatarUpload = (file) => {
|
const isJPG = file.type === 'image/jpeg';
|
const isPNG = file.type === 'image/png';
|
const isLt2M = file.size / 1024 / 1024 < 2;
|
|
if (!isJPG && !isPNG) {
|
proxy.$message.error('Avatar picture must be JPG or PNG format!')
|
}
|
if (!isLt2M) {
|
proxy.$message.error('Avatar picture size can not exceed 2MB!')
|
}
|
|
return true;
|
};
|
const handleAvatarError = (res, file) => {
|
proxy.$message.error(res);
|
};
|
|
//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)
|
};
|
const GoBack = () => {
|
proxy.$router.back();
|
};
|
|
return {
|
...toRefs(state),
|
icon,
|
LoadData,
|
sizeChange,
|
currentChange,
|
clearAddOrEditModel,
|
SearchData,
|
ClearSearchData,
|
showAddView,
|
showEditView,
|
deleteItem,
|
onSubmit,
|
handleAvatarSuccess,
|
beforeAvatarUpload,
|
handleAvatarError,
|
formatterDatetime,
|
formatterStatusBoolean,
|
capitalize,
|
handleCategorySelectClick,
|
categoryChange,
|
handleSubjectSelectClick,
|
subjectChange,
|
handleSubjectSelectClickForAdd,
|
subjectChangeForAdd,
|
GoBack,
|
showQuestionView
|
}
|
},
|
}
|
</script>
|
|
<style></style>
|