Skip to content

Commit afb4af8

Browse files
committed
add create problem
Signed-off-by: zhangtianli2006 <49156174+zhangtianli2006@users.noreply.github.com>
1 parent fd28171 commit afb4af8

File tree

6 files changed

+122
-3
lines changed

6 files changed

+122
-3
lines changed

src/assets/css/basic.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,23 @@ h3::before {
204204
position: fixed;
205205
}
206206

207+
.el-dialog,
208+
.el-dialog__wrapper {
209+
z-index: 200000 !important;
210+
}
211+
212+
.v-modal {
213+
z-index: 100000 !important;
214+
}
215+
207216
* {
208217
border-radius: 0 !important;
209218
}
219+
220+
.icon-error {
221+
color: #f56c6c !important;
222+
}
223+
224+
.icon-success {
225+
color: #67c23a !important;
226+
}

src/components/problem/create.vue

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<template>
2+
<el-dialog
3+
title="Create New Problem"
4+
:visible.sync="$store.state.createProblem.displayCreateProblem"
5+
width="500px"
6+
class="max-screen"
7+
>
8+
<el-form>
9+
<div class="icon-lable">
10+
<i class="el-icon-s-operation" />
11+
PID
12+
</div>
13+
<el-form-item prop="username">
14+
<el-input v-model="pid" placeholder="PID">
15+
<template slot="prepend">#.</template>
16+
<i v-if="errorPID" slot="suffix" class="icon-error el-input__icon el-icon-circle-close"></i>
17+
<i v-else slot="suffix" class="icon-success el-input__icon el-icon-circle-check"></i>
18+
</el-input>
19+
</el-form-item>
20+
<div class="icon-lable">
21+
<i class="el-icon-edit-outline" />
22+
Title
23+
</div>
24+
<el-form-item>
25+
<el-input v-model="title" placeholder="Title"></el-input>
26+
</el-form-item>
27+
<el-form-item>
28+
<el-button
29+
type="primary"
30+
v-on:click="Submit();"
31+
>
32+
Edit Detail
33+
</el-button>
34+
<el-button v-on:click="$store.state.createProblem.displayCreateProblem = false">Cancel</el-button>
35+
</el-form-item>
36+
</el-form>
37+
</el-dialog>
38+
</template>
39+
40+
<script>
41+
import apiurl from './../../apiurl';
42+
43+
export default {
44+
name: 'CreateProblem',
45+
data() {
46+
return {
47+
pid: null,
48+
title: null,
49+
errorPID: true
50+
};
51+
},
52+
watch: {
53+
pid(val) {
54+
this.$axios
55+
.get(apiurl('/problem/' + String(val)))
56+
.then(() => {
57+
this.errorPID = true;
58+
})
59+
.catch(() => {
60+
this.errorPID = false;
61+
});
62+
}
63+
},
64+
methods: {
65+
Submit() {
66+
this.$axios
67+
.post(apiurl('/problem'), {
68+
pid: this.pid,
69+
title: this.title,
70+
description: 'Input description'
71+
})
72+
.then(() => {
73+
this.$store.state.createProblem.displayCreateProblem = false;
74+
this.$router.push('/problem/' + this.pid + '/edit');
75+
})
76+
.catch(err => {
77+
if (err.request.status === 400) {
78+
this.$SegmentMessage.error(this, 'PID or title is empty');
79+
} else if(err.request.status === 403) {
80+
this.$SegmentMessage.error(this, 'Permission denied');
81+
} else {
82+
this.$SegmentMessage.error(this, 'Unkown error');
83+
}
84+
});
85+
}
86+
}
87+
};
88+
</script>

src/components/problem/list.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@
4444
/>
4545
<el-divider />
4646
<el-checkbox v-model="showTags"> Show Tags</el-checkbox>
47+
<el-divider />
48+
<el-button type="info" style="width: 100%" @click="$store.state.createProblem.displayCreateProblem = true" plain>Create New Problem</el-button>
4749
</el-card>
4850
</el-col>
4951
</el-row>
52+
53+
<CreateProblem />
5054
</div>
5155
</template>
5256

@@ -55,6 +59,7 @@ import apiurl from './../../apiurl';
5559
import AjaxTable from './../lib/AjaxTable.vue';
5660
import JumpToProblem from './../lib/jumpToProblem.vue';
5761
import listTag from './listTag.vue';
62+
import CreateProblem from './create.vue';
5863
5964
export default {
6065
name: 'ProblemList',
@@ -83,7 +88,7 @@ export default {
8388
sortable: false
8489
}, {
8590
name: 'tag',
86-
width: '400',
91+
width: '300',
8792
align: 'right',
8893
sortable: false
8994
}],
@@ -166,7 +171,8 @@ export default {
166171
},
167172
components: {
168173
AjaxTable,
169-
JumpToProblem
174+
JumpToProblem,
175+
CreateProblem
170176
},
171177
mounted() {
172178
this.get_list_lenth();

src/components/user/login.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
title="Login"
55
:visible.sync="$store.state.user.showlogin"
66
:destroy-on-close="true"
7-
:close-on-click-modal="false"
87
width="500px"
98
class="max-screen"
109
>

src/store/createProblem.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const createProblem = {
2+
state: {
3+
displayCreateProblem: false
4+
}
5+
};
6+
7+
export default createProblem;

src/store/store.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ Vue.use(Vuex);
66
import userstore from './user';
77
import captchastore from './captcha';
88
import tagsstore from './tags';
9+
import createProblem from './createProblem';
910

1011
export default new Vuex.Store({
1112
modules: {
1213
user: userstore,
1314
captcha: captchastore,
1415
tags: tagsstore,
16+
createProblem: createProblem,
1517
}
1618
});

0 commit comments

Comments
 (0)