|
|
|
|
@ -1,194 +1,197 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<el-drawer
|
|
|
|
|
:title="$route.meta.title"
|
|
|
|
|
direction="rtl"
|
|
|
|
|
size="68%"
|
|
|
|
|
:visible.sync="visible"
|
|
|
|
|
append-to-body
|
|
|
|
|
:before-close="handleClose"
|
|
|
|
|
@close="$emit('update:isShow', false)"
|
|
|
|
|
>
|
|
|
|
|
<section class="drawer-container">
|
|
|
|
|
<el-form
|
|
|
|
|
class="drawer-container__form"
|
|
|
|
|
ref="elForm"
|
|
|
|
|
:model="form"
|
|
|
|
|
:rules="rules"
|
|
|
|
|
label-position="top"
|
|
|
|
|
label-width="120px"
|
|
|
|
|
size="small"
|
|
|
|
|
>
|
|
|
|
|
<div class="form-layout">
|
|
|
|
|
<el-form-item label="名称" prop="name">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form['name']"
|
|
|
|
|
clearable
|
|
|
|
|
placeholder="请填写名称"
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label="分组" prop="group">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form['group']"
|
|
|
|
|
clearable
|
|
|
|
|
placeholder="请填写分组"
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</div>
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
<div class="drawer-container__footer">
|
|
|
|
|
<el-button @click="reset">重 置</el-button>
|
|
|
|
|
<el-button type="primary" @click="submit" :loading="loading">{{
|
|
|
|
|
loading ? "提交中 ..." : "确 定"
|
|
|
|
|
}}</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</el-drawer>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { save, show } from "@/api/area/area";
|
|
|
|
|
import axios from "axios";
|
|
|
|
|
import { getToken } from "@/utils/auth";
|
|
|
|
|
import { uploadSize } from "@/settings";
|
|
|
|
|
import { formatFileSize } from "@/utils";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "AreaDrawer",
|
|
|
|
|
props: {
|
|
|
|
|
isShow: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
uploadSize,
|
|
|
|
|
action: process.env.VUE_APP_UPLOAD_API,
|
|
|
|
|
loading: false,
|
|
|
|
|
visible: false,
|
|
|
|
|
form: {
|
|
|
|
|
name: "",
|
|
|
|
|
|
|
|
|
|
group: "",
|
|
|
|
|
},
|
|
|
|
|
rules: {},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
isShow(newVal) {
|
|
|
|
|
this.visible = newVal;
|
|
|
|
|
},
|
|
|
|
|
visible(newVal) {
|
|
|
|
|
this.$emit("update:isShow", newVal);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
uploadBefore(file) {
|
|
|
|
|
if (file.size > uploadSize) {
|
|
|
|
|
this.$message({
|
|
|
|
|
type: "warning",
|
|
|
|
|
message: `上传图片大小超过${formatFileSize(uploadSize)}!`,
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
window.$_uploading = true;
|
|
|
|
|
},
|
|
|
|
|
uploadSuccess(response, file, fileList, fieldName) {
|
|
|
|
|
window.$_uploading = false;
|
|
|
|
|
fileList.forEach((file) => {
|
|
|
|
|
if (file.response?.data && !file.response?.code) {
|
|
|
|
|
file.response = file.response.data;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.form[fieldName] = fileList;
|
|
|
|
|
},
|
|
|
|
|
uploadRemove(file, fileList, fieldName) {
|
|
|
|
|
this.form[fieldName] = fileList;
|
|
|
|
|
},
|
|
|
|
|
uploadError(err, file, fileList, fieldName) {
|
|
|
|
|
window.$_uploading = false;
|
|
|
|
|
this.form[fieldName] = fileList;
|
|
|
|
|
this.$message({
|
|
|
|
|
type: "warning",
|
|
|
|
|
message: err,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
formatFileSize,
|
|
|
|
|
getToken,
|
|
|
|
|
handleClose(done) {
|
|
|
|
|
this.$confirm("确定关闭窗口?")
|
|
|
|
|
.then((_) => {
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
.catch((_) => {});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reset() {
|
|
|
|
|
this.form = {
|
|
|
|
|
name: "",
|
|
|
|
|
|
|
|
|
|
group: "",
|
|
|
|
|
};
|
|
|
|
|
this.$refs["elForm"].resetFields();
|
|
|
|
|
},
|
|
|
|
|
submit() {
|
|
|
|
|
if (window.$_uploading) {
|
|
|
|
|
this.$message.warning("文件正在上传中");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.$refs["elForm"].validate(async (valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
this.loading = true;
|
|
|
|
|
try {
|
|
|
|
|
await save(this.form);
|
|
|
|
|
this.$message.success("新增成功");
|
|
|
|
|
this.$emit("refresh");
|
|
|
|
|
this.$emit("update:isShow", false);
|
|
|
|
|
this.loading = false;
|
|
|
|
|
this.reset();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.span2 {
|
|
|
|
|
grid-column: span 2;
|
|
|
|
|
}
|
|
|
|
|
::v-deep .el-form-item > * {
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
}
|
|
|
|
|
.form-layout {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-gap: 2%;
|
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
}
|
|
|
|
|
.drawer-container {
|
|
|
|
|
height: 100%;
|
|
|
|
|
padding: 20px;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
|
|
&__form {
|
|
|
|
|
flex: 1;
|
|
|
|
|
overflow-y: scroll;
|
|
|
|
|
}
|
|
|
|
|
&__footer {
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
display: flex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<el-drawer :title="$route.meta.title" direction="rtl" size="68%" :visible.sync="visible" append-to-body
|
|
|
|
|
:before-close="handleClose" @close="$emit('update:isShow', false)">
|
|
|
|
|
<section class="drawer-container">
|
|
|
|
|
<el-form class="drawer-container__form" ref="elForm" :model="form" :rules="rules" label-position="top"
|
|
|
|
|
label-width="120px" size="small">
|
|
|
|
|
<div class="form-layout">
|
|
|
|
|
<el-form-item label="名称" prop="name">
|
|
|
|
|
<el-input v-model="form['name']" clearable placeholder="请填写名称" style="width: 100%"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label="分组" prop="group">
|
|
|
|
|
<el-input v-model="form['group']" clearable placeholder="请填写分组" style="width: 100%"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="自主招生显示" prop="is_show">
|
|
|
|
|
<el-select v-model="form['is_show']">
|
|
|
|
|
<el-option v-for="item in showList" :key="item.id" :label="item.value"
|
|
|
|
|
:value="item.id"></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</div>
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
<div class="drawer-container__footer">
|
|
|
|
|
<el-button @click="reset">重 置</el-button>
|
|
|
|
|
<el-button type="primary" @click="submit" :loading="loading">{{
|
|
|
|
|
loading ? "提交中 ..." : "确 定"
|
|
|
|
|
}}</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</el-drawer>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import {
|
|
|
|
|
save,
|
|
|
|
|
show
|
|
|
|
|
} from "@/api/area/area";
|
|
|
|
|
import axios from "axios";
|
|
|
|
|
import {
|
|
|
|
|
getToken
|
|
|
|
|
} from "@/utils/auth";
|
|
|
|
|
import {
|
|
|
|
|
uploadSize
|
|
|
|
|
} from "@/settings";
|
|
|
|
|
import {
|
|
|
|
|
formatFileSize
|
|
|
|
|
} from "@/utils";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "AreaDrawer",
|
|
|
|
|
props: {
|
|
|
|
|
isShow: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
uploadSize,
|
|
|
|
|
action: process.env.VUE_APP_UPLOAD_API,
|
|
|
|
|
loading: false,
|
|
|
|
|
visible: false,
|
|
|
|
|
showList: [{
|
|
|
|
|
id: 1,
|
|
|
|
|
value: '是'
|
|
|
|
|
}, {
|
|
|
|
|
id: 0,
|
|
|
|
|
value: '否'
|
|
|
|
|
}],
|
|
|
|
|
form: {
|
|
|
|
|
name: "",
|
|
|
|
|
|
|
|
|
|
group: "",
|
|
|
|
|
is_show: 1
|
|
|
|
|
},
|
|
|
|
|
rules: {},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
isShow(newVal) {
|
|
|
|
|
this.visible = newVal;
|
|
|
|
|
},
|
|
|
|
|
visible(newVal) {
|
|
|
|
|
this.$emit("update:isShow", newVal);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
uploadBefore(file) {
|
|
|
|
|
if (file.size > uploadSize) {
|
|
|
|
|
this.$message({
|
|
|
|
|
type: "warning",
|
|
|
|
|
message: `上传图片大小超过${formatFileSize(uploadSize)}!`,
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
window.$_uploading = true;
|
|
|
|
|
},
|
|
|
|
|
uploadSuccess(response, file, fileList, fieldName) {
|
|
|
|
|
window.$_uploading = false;
|
|
|
|
|
fileList.forEach((file) => {
|
|
|
|
|
if (file.response?.data && !file.response?.code) {
|
|
|
|
|
file.response = file.response.data;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.form[fieldName] = fileList;
|
|
|
|
|
},
|
|
|
|
|
uploadRemove(file, fileList, fieldName) {
|
|
|
|
|
this.form[fieldName] = fileList;
|
|
|
|
|
},
|
|
|
|
|
uploadError(err, file, fileList, fieldName) {
|
|
|
|
|
window.$_uploading = false;
|
|
|
|
|
this.form[fieldName] = fileList;
|
|
|
|
|
this.$message({
|
|
|
|
|
type: "warning",
|
|
|
|
|
message: err,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
formatFileSize,
|
|
|
|
|
getToken,
|
|
|
|
|
handleClose(done) {
|
|
|
|
|
this.$confirm("确定关闭窗口?")
|
|
|
|
|
.then((_) => {
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
.catch((_) => {});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reset() {
|
|
|
|
|
this.form = {
|
|
|
|
|
name: "",
|
|
|
|
|
|
|
|
|
|
group: "",
|
|
|
|
|
};
|
|
|
|
|
this.$refs["elForm"].resetFields();
|
|
|
|
|
},
|
|
|
|
|
submit() {
|
|
|
|
|
if (window.$_uploading) {
|
|
|
|
|
this.$message.warning("文件正在上传中");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.$refs["elForm"].validate(async (valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
this.loading = true;
|
|
|
|
|
try {
|
|
|
|
|
await save(this.form);
|
|
|
|
|
this.$message.success("新增成功");
|
|
|
|
|
this.$emit("refresh");
|
|
|
|
|
this.$emit("update:isShow", false);
|
|
|
|
|
this.loading = false;
|
|
|
|
|
this.reset();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.span2 {
|
|
|
|
|
grid-column: span 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::v-deep .el-form-item>* {
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-layout {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-gap: 2%;
|
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.drawer-container {
|
|
|
|
|
height: 100%;
|
|
|
|
|
padding: 20px;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
|
|
&__form {
|
|
|
|
|
flex: 1;
|
|
|
|
|
overflow-y: scroll;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&__footer {
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
display: flex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|