|
|
@@ -0,0 +1,281 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+
|
|
|
+
|
|
|
+ <el-descriptions :title="manageData.name">
|
|
|
+ <template slot="extra">
|
|
|
+ <el-button type="danger" size="small" @click="deleteDialogVisible=true" plain>删除题目</el-button>
|
|
|
+ </template>
|
|
|
+ <el-descriptions-item label="题目序号">{{ manageData.id }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="题目名称">{{ manageData.name }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="时间限制(ms)">{{ manageData.timeLimit }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="空间限制(KB)">{{ manageData.memoryLimit }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="上传时间" :formatter="dateTimeFormat">{{ manageData.createTime }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="修改时间">{{ manageData.modifiedTime }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="题目描述">
|
|
|
+ <el-button type="primary" size="mini" @click="handleDescriptionDialog">查看</el-button>
|
|
|
+ </el-descriptions-item>
|
|
|
+ </el-descriptions>
|
|
|
+
|
|
|
+ <el-divider></el-divider>
|
|
|
+ <div style="text-align: left;display: flex;align-items: center">
|
|
|
+ <h4>测试用例</h4>
|
|
|
+
|
|
|
+ <span><el-button type="primary" size="mini" @click="tcDialogVisible = true;">新增测试用例</el-button></span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-table
|
|
|
+ :data="testcases">
|
|
|
+ <el-table-column prop="id" label="序号"></el-table-column>
|
|
|
+ <el-table-column prop="input" label="输入">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <div style="white-space: pre-wrap">{{ scope.row.input }}</div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="output" label="输出">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <div style="white-space: pre-wrap">{{ scope.row.output }}</div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column width="100px">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-popconfirm title="确定删除该测试用例吗?" @confirm="deleteTestCase(scope.row)">
|
|
|
+
|
|
|
+ <el-button type="danger" size="mini" slot="reference">删除</el-button>
|
|
|
+ </el-popconfirm>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <!-- <el-dialog-->
|
|
|
+ <!-- title="新增测试用例"-->
|
|
|
+ <!-- :visible.sync="tcDialogVisible"-->
|
|
|
+ <!-- >-->
|
|
|
+ <!-- <el-form ref="form" :model="form">-->
|
|
|
+ <!-- <el-form-item label="输入">-->
|
|
|
+ <!-- <el-input v-model="form.input" type="textarea" :row="3"></el-input>-->
|
|
|
+ <!-- </el-form-item>-->
|
|
|
+ <!-- <el-form-item label="输出">-->
|
|
|
+ <!-- <el-input v-model="form.output" type="textarea" :row="3"></el-input>-->
|
|
|
+ <!-- </el-form-item>-->
|
|
|
+ <!-- <el-form-item>-->
|
|
|
+ <!-- <el-button type="primary" @click="uploadTestCase">提交</el-button>-->
|
|
|
+ <!-- </el-form-item>-->
|
|
|
+
|
|
|
+ <!-- </el-form>-->
|
|
|
+
|
|
|
+ <!-- </el-dialog>-->
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ title="新增测试用例"
|
|
|
+ :visible.sync="tcDialogVisible"
|
|
|
+ >
|
|
|
+
|
|
|
+ <el-form ref="form" :model="batchForm">
|
|
|
+ <el-row
|
|
|
+ v-for="(tc,index) in batchForm.testCaseList"
|
|
|
+ :key="tc.key"
|
|
|
+ style="display: flex;align-items: center;justify-content: space-between"
|
|
|
+ >
|
|
|
+ <el-form-item :label="'输入'+index" label-width="60px" style="width: 40%">
|
|
|
+ <el-input v-model="tc.input" type="textarea" :row="1"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label="'输出'+index" label-width="60px" style="width: 40%">
|
|
|
+ <el-input v-model="tc.output" type="textarea" :row="1"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <div style="width: 120px">
|
|
|
+ <div style="display: flex;justify-content: left">
|
|
|
+ <el-form-item label-width="10px">
|
|
|
+ <el-button type="danger" @click.prevent="removeFormTestcase(tc)" icon="el-icon-delete" size="mini"
|
|
|
+ ></el-button>
|
|
|
+ <el-button type="primary" v-if="index===batchForm.testCaseList.length-1" @click="addFormTestcase"
|
|
|
+ icon="el-icon-plus" size="mini"></el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="uploadBatchTestCases">提交</el-button>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ title="题目描述"
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
+ >
|
|
|
+ <div style="text-align: left" class="markdown-body">
|
|
|
+ <VueMarkdown :source="manageData.description"></VueMarkdown>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ title="确认删除题目"
|
|
|
+ :visible.sync="deleteDialogVisible"
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ <h2>确认删除题目吗?</h2>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ 题目序号:{{ manageId }}
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ 题目名称:{{ manageData.name }}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogVisible = false">取 消</el-button>
|
|
|
+ <el-button type="danger" @click="deleteProblem">删除</el-button>
|
|
|
+ </span>
|
|
|
+
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ addTestCaseAPI, batchAddTestCaseAPI,
|
|
|
+ deleteProblemAPI,
|
|
|
+ delTestCaseAPI,
|
|
|
+ getProblemManageAPI,
|
|
|
+ getTestCasesByProblemIdAPI
|
|
|
+} from "@/api/problemAPI";
|
|
|
+import VueMarkdown from 'vue-markdown'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "ManagePage",
|
|
|
+ components: {
|
|
|
+ VueMarkdown
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ manageId: undefined,
|
|
|
+ manageData: {
|
|
|
+ name: ''
|
|
|
+ },
|
|
|
+ form: {},
|
|
|
+ batchForm: {
|
|
|
+ testCaseList: [
|
|
|
+ {
|
|
|
+ input: undefined,
|
|
|
+ output: undefined
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ testcases: undefined,
|
|
|
+ dialogVisible: false,
|
|
|
+ tcDialogVisible: false,
|
|
|
+ deleteDialogVisible: false,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getProblemManageById(problemId) {
|
|
|
+ getProblemManageAPI(problemId).then((res) => {
|
|
|
+ this.manageData = res.result;
|
|
|
+ this.manageData.createTime = this.dateTimeFormat(this.manageData.createTime);
|
|
|
+ this.manageData.modifiedTime = this.dateTimeFormat(this.manageData.modifiedTime);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getTestCasesByProblemId(problemId) {
|
|
|
+ getTestCasesByProblemIdAPI(problemId).then((res) => {
|
|
|
+ this.testcases = res.result;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleDescriptionDialog() {
|
|
|
+ this.dialogVisible = true;
|
|
|
+ },
|
|
|
+ deleteProblem() {
|
|
|
+ deleteProblemAPI(this.manageId).then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ this.$message.success("删除题目" + "[" + this.manageId + "]" + "成功");
|
|
|
+ this.deleteDialogVisible = false;
|
|
|
+ this.$router.push({
|
|
|
+ path: '/manage',
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ uploadTestCase() {
|
|
|
+ this.form.problemId = this.manageId;
|
|
|
+ console.log(this.form);
|
|
|
+ addTestCaseAPI(this.form).then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ this.getTestCasesByProblemId(this.manageId);
|
|
|
+ this.$message.success("新增测试用例成功");
|
|
|
+ this.tcDialogVisible = false;
|
|
|
+ this.form = {};
|
|
|
+ })
|
|
|
+ },
|
|
|
+ deleteTestCase(row) {
|
|
|
+ delTestCaseAPI(row.id).then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ this.getTestCasesByProblemId(this.manageId);
|
|
|
+ this.$message.success("删除测试用例成功!");
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ removeFormTestcase(item) {
|
|
|
+ let index = this.batchForm.testCaseList.indexOf(item);
|
|
|
+ if (this.batchForm.testCaseList.length === 1) {
|
|
|
+ this.$message.error("请至少填写一个子条件!")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (index !== -1) {
|
|
|
+ this.batchForm.testCaseList.splice(index, 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ addFormTestcase() {
|
|
|
+ this.batchForm.testCaseList.push({
|
|
|
+ input: undefined,
|
|
|
+ output: undefined
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ uploadBatchTestCases() {
|
|
|
+ for (let i = 0; i < this.batchForm.testCaseList.length; i++) {
|
|
|
+ this.batchForm.testCaseList[i].problemId = this.manageId;
|
|
|
+ }
|
|
|
+ console.log(this.batchForm.testCaseList);
|
|
|
+ batchAddTestCaseAPI(this.batchForm.testCaseList).then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ this.getTestCasesByProblemId(this.manageId);
|
|
|
+ this.$message.success("新增测试用例成功");
|
|
|
+ this.tcDialogVisible = false;
|
|
|
+ this.batchForm = {
|
|
|
+ testCaseList: [
|
|
|
+ {
|
|
|
+ input: undefined,
|
|
|
+ output: undefined
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ dateTimeFormat(time) {
|
|
|
+ if (time == null) {
|
|
|
+ return '--';
|
|
|
+ }
|
|
|
+ return new Date(time).toLocaleString();
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.manageId = this.$route.params.id;
|
|
|
+ this.getProblemManageById(this.manageId);
|
|
|
+ this.getTestCasesByProblemId(this.manageId);
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|