123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679 |
- <template>
- <section class="content" style="margin-top: 20px;">
- <div class="box box-info">
- <!-- 正文信息 -->
- <div class="box-body">
- <el-form
- :model="formSearch"
- :inline="true"
- label-position="right"
- label-width="100px"
- >
- <el-form-item label="学校">
- <el-select
- v-model="formSearch.orgId"
- placeholder="请选择"
- clearable
- @change="loadExamList(formSearch.orgId)"
- >
- <el-option
- v-for="item in orgList"
- :label="item.orgName"
- :value="item.orgId"
- :key="item.orgId"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="考试">
- <el-select
- v-model="formSearch.examId"
- placeholder="请选择"
- @change="searchRecords(1)"
- clearable
- >
- <el-option
- v-for="item in examList"
- :label="item.examName"
- :value="item.examId"
- :key="item.examId"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button
- size="small"
- type="primary"
- icon="el-icon-search"
- @click="searchRecords(1)"
- >查询
- </el-button>
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- :disabled="!hasPermit"
- v-show="!checkEmptyNumber(formSearch.orgId)"
- @click="openAddStructureDialog"
- >新增
- </el-button>
- </el-form-item>
- </el-form>
- <!-- 数据列表 -->
- <el-table
- v-loading="loading"
- :data="tableData"
- element-loading-text="数据加载中"
- style="width:100%;"
- border
- >
- <el-table-column label="学校名称" prop="orgName" />
- <el-table-column label="考试名称" prop="examName" />
- <el-table-column width="220" label="题数">
- <template slot-scope="scope">
- 单选:{{ scope.row.questionStructure.singleChoiceTotal }}<br />
- 多选:{{ scope.row.questionStructure.multipleChoiceTotal }}<br />
- 判断:{{ scope.row.questionStructure.boolQuestionTotal }}
- </template>
- </el-table-column>
- <el-table-column width="200" label="操作" :context="_self">
- <template slot-scope="scope">
- <el-button
- size="mini"
- icon="el-icon-menu"
- @click="openCloneStructureDialog(scope.row)"
- :disabled="!hasPermit"
- >复用
- </el-button>
- <el-button
- size="mini"
- type="danger"
- icon="el-icon-delete"
- @click="removeStructure(scope.row)"
- :disabled="!hasPermit"
- >删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <!-- 分页 -->
- <div class="page pull-right">
- <el-pagination
- @current-change="handlePager"
- :current-page="formSearch.pageNo"
- :page-size="formSearch.pageSize"
- :total="totalElements"
- layout="total, prev, pager, next, jumper"
- ></el-pagination>
- </div>
- </div>
- <!-- 新增考试结构弹窗 -->
- <el-dialog
- title="新增考试结构"
- width="400px"
- :visible.sync="addStructureDialog"
- @close="closeAddStructureDialog"
- >
- <el-form
- :model="addStructureForm"
- ref="addStructureForm"
- :rules="rules"
- label-position="right"
- label-width="100px"
- >
- <el-form-item label="学校名称" prop="orgId">
- <el-select
- v-model="addStructureForm.orgId"
- placeholder="请选择"
- :disabled="true"
- class="w220"
- >
- <el-option
- v-for="item in orgList"
- :label="item.orgName"
- :value="item.orgId"
- :key="item.orgId"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="考试名称" prop="examId">
- <el-select
- v-model="addStructureForm.examId"
- placeholder="请选择"
- class="w220"
- >
- <el-option
- v-for="item in examList"
- :label="item.examName"
- :value="item.examId"
- :key="item.examId"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="单选题数量" prop="singleChoiceTotal">
- <el-input
- v-model="addStructureForm.questionStructure.singleChoiceTotal"
- class="w220"
- ></el-input>
- </el-form-item>
- <el-form-item label="多选题数量" prop="multipleChoiceTotal">
- <el-input
- v-model="addStructureForm.questionStructure.multipleChoiceTotal"
- class="w220"
- ></el-input>
- </el-form-item>
- <el-form-item label="判断题数量" prop="boolQuestionTotal">
- <el-input
- v-model="addStructureForm.questionStructure.boolQuestionTotal"
- class="w220"
- ></el-input>
- </el-form-item>
- <div style="text-align: center">
- <el-button type="primary" @click="addStructure">确 定</el-button>
- <el-button @click="closeAddStructureDialog">取 消</el-button>
- </div>
- </el-form>
- </el-dialog>
- <!-- 复用考试结构弹窗 -->
- <el-dialog
- title="复用考试结构"
- width="450px"
- :visible.sync="cloneStructureDialog"
- @close="closeCloneStructureDialog"
- >
- <el-form
- :model="cloneStructureForm"
- ref="cloneStructureForm"
- :rules="rules"
- label-position="right"
- label-width="80px"
- >
- <el-tabs v-model="sourceTab">
- <el-tab-pane label="原结构信息" name="first">
- <el-form-item label="学校名称" prop="orgId">
- <el-select
- v-model="cloneStructureForm.orgId"
- placeholder="请选择"
- :disabled="true"
- class="w220"
- >
- <el-option
- v-for="item in orgList"
- :label="item.orgName"
- :value="item.orgId"
- :key="item.orgId"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="考试名称" prop="examId">
- <el-select
- v-model="cloneStructureForm.examId"
- placeholder="请选择"
- :disabled="true"
- class="w220"
- >
- <el-option
- v-for="item in examList"
- :label="item.examName"
- :value="item.examId"
- :key="item.examId"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-tab-pane>
- </el-tabs>
- <el-tabs v-model="targetTab">
- <el-tab-pane label="新结构信息" name="first">
- <el-form-item label="学校名称" prop="newOrgId">
- <el-select
- v-model="cloneStructureForm.newOrgId"
- @change="loadCloneExamList(cloneStructureForm.newOrgId)"
- placeholder="请选择"
- class="w220"
- >
- <el-option
- v-for="item in orgList"
- :label="item.orgName"
- :value="item.orgId"
- :key="item.orgId"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="考试名称" prop="newExamId">
- <el-select
- v-model="cloneStructureForm.newExamId"
- placeholder="请选择"
- class="w220"
- >
- <el-option
- v-for="item in cloneExamList"
- :label="item.examName"
- :value="item.examId"
- :key="item.examId"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-tab-pane>
- </el-tabs>
- <div style="text-align: center">
- <el-button type="primary" @click="cloneStructure">确 定</el-button>
- <el-button @click="closeCloneStructureDialog">取 消</el-button>
- </div>
- </el-form>
- </el-dialog>
- </div>
- </section>
- </template>
- <script>
- import { PRINT_API } from "@/constants/constants";
- import {} from "../constants/constants.js";
- import { mapState } from "vuex";
- import { checkEmptyNumber } from "../utils/common.js";
- export default {
- data() {
- let validateSingleChoiceTotal = (rule, value, callback) => {
- if (
- checkEmptyNumber(
- this.addStructureForm.questionStructure.singleChoiceTotal
- )
- ) {
- callback(new Error("请输入正确的数值!"));
- return;
- }
- if (this.addStructureForm.questionStructure.singleChoiceTotal > 1000) {
- callback(new Error("请输入合理有效的数值!"));
- return;
- }
- callback();
- };
- let validateMultipleChoiceTotal = (rule, value, callback) => {
- if (
- checkEmptyNumber(
- this.addStructureForm.questionStructure.multipleChoiceTotal
- )
- ) {
- callback(new Error("请输入正确的数值!"));
- return;
- }
- if (this.addStructureForm.questionStructure.multipleChoiceTotal > 1000) {
- callback(new Error("请输入合理有效的数值!"));
- return;
- }
- callback();
- };
- let validateBoolChoiceTotal = (rule, value, callback) => {
- if (
- checkEmptyNumber(
- this.addStructureForm.questionStructure.boolQuestionTotal
- )
- ) {
- callback(new Error("请输入正确的数值!"));
- return;
- }
- if (this.addStructureForm.questionStructure.boolQuestionTotal > 1000) {
- callback(new Error("请输入合理有效的数值!"));
- return;
- }
- callback();
- };
- return {
- formSearch: {
- orgId: "",
- examId: "",
- pageNo: 1,
- pageSize: 10
- },
- curUserRole: {},
- hasPermit: false,
- totalElements: 0,
- loading: false,
- tableData: [],
- orgList: [],
- examList: [],
- addStructureDialog: false,
- addStructureForm: {
- examId: "",
- examName: "",
- orgId: "",
- orgName: "",
- questionStructure: {
- singleChoiceTotal: 0,
- multipleChoiceTotal: 0,
- boolQuestionTotal: 0
- }
- },
- cloneStructureDialog: false,
- cloneExamList: [],
- sourceTab: "first",
- targetTab: "first",
- cloneStructureForm: {
- examId: "",
- orgId: "",
- newExamId: "",
- newExamName: "",
- newOrgId: "",
- newOrgName: ""
- },
- rules: {
- orgId: [
- { required: true, message: "学校不能为空!", trigger: "change" }
- ],
- examId: [
- { required: true, message: "考试不能为空!", trigger: "change" }
- ],
- newOrgId: [
- { required: true, message: "学校不能为空!", trigger: "change" }
- ],
- newExamId: [
- { required: true, message: "考试不能为空!", trigger: "change" }
- ],
- singleChoiceTotal: [
- {
- required: true,
- validator: validateSingleChoiceTotal,
- trigger: "change"
- }
- ],
- multipleChoiceTotal: [
- {
- required: true,
- validator: validateMultipleChoiceTotal,
- trigger: "change"
- }
- ],
- boolQuestionTotal: [
- {
- required: true,
- validator: validateBoolChoiceTotal,
- trigger: "change"
- }
- ]
- }
- };
- },
- methods: {
- handlePager(current) {
- /* 处理分页 */
- this.searchRecords(current);
- },
- searchRecords(pageNo) {
- this.formSearch.pageNo = pageNo;
- /* 查询记录列表 */
- let orgId = this.formSearch.orgId;
- if (checkEmptyNumber(orgId)) {
- this.$notify({
- title: "提示",
- message: "请选择学校!",
- type: "warning"
- });
- return;
- }
- this.loading = true;
- let url = PRINT_API + "/examStructure/list";
- this.$http.post(url, this.formSearch).then(
- response => {
- this.tableData = response.data.content;
- this.totalElements = response.data.totalElements;
- this.loading = false;
- },
- error => {
- console.log(error);
- this.loading = false;
- }
- );
- },
- selectDefault() {
- if (this.orgList.length > 0) {
- let firstOrgId = this.orgList[0].orgId;
- this.formSearch.orgId = firstOrgId;
- this.loadExamList(firstOrgId);
- }
- },
- loadOrgList() {
- /* 查询学校列表 */
- let url = PRINT_API + "/printing/project/org/list";
- this.$http.post(url).then(
- response => {
- this.orgList = response.data;
- this.selectDefault();
- },
- error => {
- console.log(error.response);
- // ignore
- }
- );
- },
- loadExamList(orgId) {
- /* 查询考试列表 */
- this.formSearch.examId = "";
- this.examList = [];
- this.tableData = [];
- if (!checkEmptyNumber(orgId)) {
- let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
- this.$http.post(url).then(response => {
- this.examList = response.data;
- if (this.examList.length > 0) {
- this.formSearch.examId = this.examList[0].examId;
- this.searchRecords(1);
- }
- });
- }
- },
- loadCloneExamList(orgId) {
- /* 查询考试列表 */
- this.cloneStructureForm.newExamId = "";
- this.cloneExamList = [];
- if (!checkEmptyNumber(orgId)) {
- let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
- this.$http.post(url).then(response => {
- this.cloneExamList = response.data;
- });
- }
- },
- getOrgNameById(orgList, orgId) {
- for (let i = 0; i < orgList.length; i++) {
- if (orgList[i].orgId == orgId) {
- return orgList[i].orgName;
- }
- }
- return "";
- },
- getExamNameById(examList, examId) {
- for (let i = 0; i < examList.length; i++) {
- if (examList[i].examId == examId) {
- return examList[i].examName;
- }
- }
- return "";
- },
- openAddStructureDialog() {
- /* 打开考试结构弹窗 */
- this.addStructureDialog = true;
- this.addStructureForm.orgId = this.formSearch.orgId;
- this.addStructureForm.examId = this.formSearch.examId;
- this.addStructureForm.questionStructure.singleChoiceTotal = 0;
- this.addStructureForm.questionStructure.multipleChoiceTotal = 0;
- this.addStructureForm.questionStructure.boolQuestionTotal = 0;
- },
- closeAddStructureDialog() {
- /* 关闭考试结构弹窗 */
- this.addStructureDialog = false;
- },
- addStructure() {
- /* 新增考试结构 */
- this.$refs.addStructureForm.validate(valid => {
- if (!valid) {
- return false;
- }
- this.addStructureForm.orgName = this.getOrgNameById(
- this.orgList,
- this.addStructureForm.orgId
- );
- this.addStructureForm.examName = this.getExamNameById(
- this.examList,
- this.addStructureForm.examId
- );
- let url = PRINT_API + "/examStructure/save";
- this.$http.post(url, this.addStructureForm).then(
- () => {
- this.$notify({
- title: "提示",
- message: "考试结构新增成功!",
- type: "success"
- });
- this.addStructureDialog = false;
- this.searchRecords(1);
- },
- error => {
- console.log(error.response);
- this.$notify({
- title: "错误",
- type: "error",
- message: error.response.data.desc
- });
- }
- );
- });
- },
- openCloneStructureDialog(row) {
- /* 打开复用考试结构弹窗 */
- this.cloneStructureDialog = true;
- this.cloneStructureForm.orgId = row.orgId;
- this.cloneStructureForm.examId = row.examId;
- this.cloneStructureForm.newOrgId = "";
- this.cloneStructureForm.newExamId = "";
- },
- closeCloneStructureDialog() {
- /* 关闭复用考试结构弹窗 */
- this.cloneStructureDialog = false;
- },
- cloneStructure() {
- /* 复用考试结构 */
- this.$refs.cloneStructureForm.validate(valid => {
- if (!valid) {
- return false;
- }
- this.cloneStructureForm.newOrgName = this.getOrgNameById(
- this.orgList,
- this.cloneStructureForm.newOrgId
- );
- this.cloneStructureForm.newExamName = this.getExamNameById(
- this.cloneExamList,
- this.cloneStructureForm.newExamId
- );
- let url = PRINT_API + "/examStructure/clone";
- this.$http.post(url, this.cloneStructureForm).then(
- () => {
- this.$notify({
- title: "提示",
- message: "考试结构复用成功!",
- type: "success"
- });
- this.cloneStructureDialog = false;
- this.searchRecords(1);
- },
- error => {
- console.log(error.response);
- this.$notify({
- title: "错误",
- type: "error",
- message: error.response.data.desc
- });
- }
- );
- });
- },
- removeStructure(row) {
- /* 删除考试结构 */
- this.$confirm("确定删除当前结构吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- let url = PRINT_API + "/examStructure/delete/" + row.id;
- this.$http.post(url).then(
- () => {
- this.$notify({
- title: "提示",
- type: "success",
- message: "删除当前结构成功!"
- });
- this.searchRecords(1);
- },
- error => {
- console.log(error.response);
- this.$notify({
- title: "错误",
- type: "error",
- message: error.response.data.desc
- });
- }
- );
- })
- .catch(() => {
- /*ignore*/
- });
- },
- checkEmptyNumber: checkEmptyNumber
- },
- computed: {
- ...mapState({ user: state => state.user })
- },
- created() {
- this.loadOrgList();
- this.loadUserRole(this.user);
- if (this.curUserRole.isSuperLeader || this.curUserRole.isPM) {
- this.hasPermit = true;
- } else {
- this.hasPermit = false;
- }
- }
- };
- </script>
- <style scoped>
- .page {
- margin-top: 10px;
- }
- .pull-right {
- float: right;
- }
- .pull-left {
- float: left;
- }
- .w220 {
- width: 220px;
- }
- </style>
|