parent
f91294e666
commit
17c3fd5afe
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
@ -0,0 +1,37 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function index(params,isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/area/index',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function show(params,isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/area/show',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function save(data, isLoading = true) {
|
||||
return request({
|
||||
method: 'post',
|
||||
url: '/api/admin/area/save',
|
||||
data,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function destroy(params, isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/area/destroy',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function index(params,isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/school/index',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function show(params,isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/school/show',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function save(data, isLoading = true) {
|
||||
return request({
|
||||
method: 'post',
|
||||
url: '/api/admin/school/save',
|
||||
data,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function destroy(params, isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/school/destroy',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function index(params,isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/score/index',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function show(params,isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/score/show',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function save(data, isLoading = true) {
|
||||
return request({
|
||||
method: 'post',
|
||||
url: '/api/admin/score/save',
|
||||
data,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function destroy(params, isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/score/destroy',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function index(params,isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/user/index',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function show(params,isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/user/show',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function save(data, isLoading = true) {
|
||||
return request({
|
||||
method: 'post',
|
||||
url: '/api/admin/user/save',
|
||||
data,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function destroy(params, isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/user/destroy',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 126 KiB |
@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<div>
|
||||
<vxe-modal
|
||||
:width="defaultModalSize.width"
|
||||
v-model="showModal"
|
||||
:height="defaultModalSize.height"
|
||||
show-zoom
|
||||
resize
|
||||
transfer
|
||||
esc-closable
|
||||
show-footer
|
||||
show-confirm-button
|
||||
show-cancel-button
|
||||
:fullscreen="$store.getters.device === 'mobile'"
|
||||
:z-index="zIndex"
|
||||
title="文本"
|
||||
@confirm="confirm"
|
||||
>
|
||||
<template>
|
||||
<my-tinymce v-model="myText" style="height: 100%;" :disabled="readonly" />
|
||||
</template>
|
||||
</vxe-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { PopupManager } from 'element-ui/lib/utils/popup'
|
||||
import { defaultModalSize } from '@/settings'
|
||||
|
||||
export default {
|
||||
name: 'RichTextModal',
|
||||
data() {
|
||||
return {
|
||||
defaultModalSize,
|
||||
zIndex: PopupManager.nextZIndex(),
|
||||
showModal: false,
|
||||
myText: '',
|
||||
readonly: false,
|
||||
fieldName: '',
|
||||
row: {}
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
created() {
|
||||
this.$bus.$on('rich-text', ({ text, readonly }) => this.open(text, readonly))
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$bus.$off('rich-text')
|
||||
},
|
||||
methods: {
|
||||
open({ text, readonly, row, fieldName }) {
|
||||
this.showModal = true
|
||||
this.$nextTick(() => {
|
||||
this.myText = text
|
||||
this.readonly = !!readonly
|
||||
this.row = row
|
||||
this.fieldName = fieldName
|
||||
})
|
||||
},
|
||||
confirm() {
|
||||
if (!this.readonly) {
|
||||
this.$emit('confirm', {
|
||||
row: this.row,
|
||||
fieldName: this.fieldName,
|
||||
text: this.myText
|
||||
})
|
||||
console.log(this.myText)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
</style>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,406 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card shadow="never" style="margin-top: 20px">
|
||||
<template #header>
|
||||
<slot name="header">
|
||||
<vxe-toolbar
|
||||
:export="isHasAuth('export')"
|
||||
:print="isHasAuth('print')"
|
||||
custom
|
||||
ref="toolbar"
|
||||
>
|
||||
<template #buttons>
|
||||
<el-button
|
||||
v-if="isHasAuth('create')"
|
||||
icon="el-icon-plus"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="isShowAdd = true"
|
||||
>新增</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="isHasAuth('search')"
|
||||
icon="el-icon-search"
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
@click="getList"
|
||||
>搜索</el-button
|
||||
>
|
||||
</template>
|
||||
</vxe-toolbar>
|
||||
</slot>
|
||||
</template>
|
||||
|
||||
<vxe-table
|
||||
ref="table"
|
||||
stripe
|
||||
style="margin-top: 10px"
|
||||
:loading="loading"
|
||||
:height="tableHeight"
|
||||
keep-source
|
||||
show-overflow
|
||||
:menu-config="{
|
||||
className: 'my-menus',
|
||||
body: {
|
||||
options: [
|
||||
[
|
||||
{
|
||||
code: 'copy',
|
||||
name: '复制',
|
||||
prefixConfig: { icon: 'vxe-icon-copy' },
|
||||
suffixConfig: { content: 'Ctrl+C' },
|
||||
},
|
||||
{
|
||||
code: 'remove',
|
||||
name: '删除',
|
||||
prefixConfig: {
|
||||
icon: 'vxe-icon-delete-fill',
|
||||
className: 'color-red',
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
}"
|
||||
@menu-click="contextMenuClickEvent"
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:column-config="{ resizable: true }"
|
||||
:export-config="{}"
|
||||
:edit-rules="validRules"
|
||||
:edit-config="{
|
||||
trigger: 'manual',
|
||||
mode: 'row',
|
||||
showStatus: true,
|
||||
isHover: true,
|
||||
autoClear: false,
|
||||
}"
|
||||
:align="allAlign"
|
||||
:data="tableData"
|
||||
>
|
||||
<vxe-column type="seq" width="58" align="center" />
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="name"
|
||||
width="160"
|
||||
title="名称"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
field="operate"
|
||||
header-align="center"
|
||||
title="操作"
|
||||
min-width="220"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<template v-if="isActiveStatus(row)">
|
||||
<el-button size="small" type="primary" @click="saveRowEvent(row)"
|
||||
>保存</el-button
|
||||
>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="cancelRowEvent(row)"
|
||||
>取消</el-button
|
||||
>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button
|
||||
v-if="isHasAuth('detail')"
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="detail(row)"
|
||||
>查看</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="isHasAuth('edit')"
|
||||
size="small"
|
||||
type="warning"
|
||||
@click="editRowEvent(row)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="isHasAuth('delete')"
|
||||
size="small"
|
||||
type="danger"
|
||||
@click="destroyRowEvent(row)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
|
||||
<el-pagination
|
||||
style="margin-top: 10px; display: flex; justify-content: flex-end"
|
||||
:current-page.sync="select.page"
|
||||
:page-sizes="[20, 30, 40, 50]"
|
||||
:page-size.sync="select.page_size"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
@size-change="
|
||||
(e) => {
|
||||
select.page_size = e;
|
||||
select.page = 1;
|
||||
getList();
|
||||
}
|
||||
"
|
||||
@current-change="
|
||||
(e) => {
|
||||
select.page = e;
|
||||
getList();
|
||||
}
|
||||
"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<AddArea ref="AddArea" :is-show.sync="isShowAdd" @refresh="getList" />
|
||||
<ShowArea ref="ShowArea" :is-show.sync="isShowDetail" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import VxeUI from "vxe-pc-ui";
|
||||
|
||||
import { authMixin } from "@/mixin/authMixin";
|
||||
import { uploadSize } from "@/settings";
|
||||
import { deepCopy } from "@/utils";
|
||||
import { destroy, index, save } from "@/api/area/area";
|
||||
import AddArea from "./components/AddArea.vue";
|
||||
import ShowArea from "./components/ShowArea.vue";
|
||||
import axios from "axios";
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
name: "Area",
|
||||
mixins: [authMixin],
|
||||
components: {
|
||||
AddArea,
|
||||
ShowArea,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadSize,
|
||||
examineKey: 0,
|
||||
isShowAdd: false,
|
||||
isShowDetail: false,
|
||||
|
||||
loading: false,
|
||||
tableHeight: 400,
|
||||
select: {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
keyword: "",
|
||||
show_relation: [],
|
||||
},
|
||||
total: 0,
|
||||
allAlign: null,
|
||||
tableData: [],
|
||||
form: {
|
||||
id: "",
|
||||
|
||||
name: "",
|
||||
},
|
||||
validRules: {},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isActiveStatus() {
|
||||
return function (row) {
|
||||
if (this.$refs["table"]) {
|
||||
return this.$refs["table"].isEditByRow(row);
|
||||
}
|
||||
};
|
||||
},
|
||||
isHasAuth() {
|
||||
return function (auth) {
|
||||
return this.auths_auth_mixin.indexOf(auth) !== -1;
|
||||
};
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
mounted() {
|
||||
this.bindToolbar();
|
||||
this.calcTableHeight();
|
||||
},
|
||||
methods: {
|
||||
calcTableHeight() {
|
||||
let clientHeight = document.documentElement.clientHeight;
|
||||
let cardTitle = document
|
||||
.querySelector(".el-card__header")
|
||||
?.getBoundingClientRect()?.height;
|
||||
let search = document
|
||||
.querySelector(".vxe-toolbar")
|
||||
?.getBoundingClientRect()?.height;
|
||||
let paginationHeight =
|
||||
(document.querySelector(".el-pagination")?.getBoundingClientRect()
|
||||
?.height ?? 0) + 10; //分页的高度
|
||||
let topHeight = 50; //页面 头部
|
||||
let padding = 80;
|
||||
let margin = 20;
|
||||
this.tableHeight =
|
||||
clientHeight -
|
||||
cardTitle -
|
||||
search -
|
||||
paginationHeight -
|
||||
topHeight -
|
||||
padding -
|
||||
margin;
|
||||
},
|
||||
contextMenuClickEvent({ menu, row, column }) {
|
||||
switch (menu.code) {
|
||||
case "copy":
|
||||
// 示例
|
||||
if (row && column) {
|
||||
if (VxeUI.clipboard.copy(row[column.field])) {
|
||||
this.$message.success("已复制到剪贴板!");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
if (row && column) {
|
||||
this.destroyRowEvent(row);
|
||||
}
|
||||
default:
|
||||
}
|
||||
},
|
||||
async detail(row) {
|
||||
await this.$refs["ShowArea"].getDetail(row.id);
|
||||
this.isShowDetail = true;
|
||||
},
|
||||
|
||||
uploadMethod(file) {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
window.$_uploading = true;
|
||||
return axios
|
||||
.post(process.env.VUE_APP_UPLOAD_API, formData, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${getToken()}`,
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
window.$_uploading = false;
|
||||
if (response.status === 200 && !response.data.code) {
|
||||
return {
|
||||
response: response.data,
|
||||
name: response.data.original_name,
|
||||
url: response.data.url,
|
||||
};
|
||||
} else {
|
||||
this.$message.error("上传失败");
|
||||
}
|
||||
})
|
||||
.catch((_) => {
|
||||
window.$_uploading = false;
|
||||
});
|
||||
},
|
||||
bindToolbar() {
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs["table"] && this.$refs["toolbar"]) {
|
||||
this.$refs["table"].connect(this.$refs["toolbar"]);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
editRowEvent(row) {
|
||||
if (this.$refs["table"]) {
|
||||
this.$refs["table"].setEditRow(row);
|
||||
}
|
||||
},
|
||||
cancelRowEvent(row) {
|
||||
if (this.$refs["table"]) {
|
||||
this.$refs["table"].clearEdit().then(() => {
|
||||
// 还原行数据
|
||||
this.$refs["table"].revertData(row);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async getList() {
|
||||
this.loading = true;
|
||||
try {
|
||||
const res = await index(this.select, false);
|
||||
this.tableData = res.data;
|
||||
this.total = res.total;
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
async saveRowEvent(row) {
|
||||
if (window.$_uploading) {
|
||||
this.$message.warning("文件正在上传中");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const errMap = await this.$refs["table"].validate();
|
||||
if (errMap) {
|
||||
throw new Error(errMap);
|
||||
}
|
||||
await this.$confirm("确认保存?", "提示", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
});
|
||||
await this.$refs["table"].clearEdit();
|
||||
let form = deepCopy(this.form);
|
||||
for (const key in form) {
|
||||
form[key] = row[key];
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
await save(form, false);
|
||||
await this.getList();
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
async destroyRowEvent(row) {
|
||||
try {
|
||||
await this.$confirm("确认删除?", "提示", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
});
|
||||
this.loading = true;
|
||||
if (row.id) {
|
||||
await destroy(
|
||||
{
|
||||
id: row.id,
|
||||
},
|
||||
false
|
||||
);
|
||||
await this.getList();
|
||||
} else {
|
||||
console.log(row);
|
||||
this.tableData.splice(
|
||||
this.tableData.findIndex((i) => i._X_ROW_KEY === row._X_ROW_KEY),
|
||||
1
|
||||
);
|
||||
}
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
::v-deep .el-card__header {
|
||||
padding: 6px 20px;
|
||||
}
|
||||
::v-deep .el-tag + .el-tag {
|
||||
margin-left: 4px;
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,95 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-drawer
|
||||
:title="$route.meta.title"
|
||||
direction="rtl"
|
||||
size="68%"
|
||||
:visible.sync="visible"
|
||||
append-to-body
|
||||
@close="$emit('update:isShow', false)"
|
||||
>
|
||||
<section class="drawer-container">
|
||||
<el-descriptions
|
||||
class="drawer-container__desc"
|
||||
size="small"
|
||||
border
|
||||
ref="elDesc"
|
||||
:column="2"
|
||||
direction="vertical"
|
||||
:labelStyle="{ 'font-weight': '500', 'font-size': '15px' }"
|
||||
>
|
||||
<el-descriptions-item label="名称">
|
||||
{{ form["name"] }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { show } from "@/api/area/area";
|
||||
|
||||
export default {
|
||||
name: "AreaShow",
|
||||
props: {
|
||||
isShow: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
visible: false,
|
||||
form: {
|
||||
name: "",
|
||||
},
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
isShow(newVal) {
|
||||
this.visible = newVal;
|
||||
},
|
||||
visible(newVal) {
|
||||
this.$emit("update:isShow", newVal);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async getDetail(id) {
|
||||
try {
|
||||
const detail = await show({
|
||||
id,
|
||||
});
|
||||
for (let key in this.form) {
|
||||
if (detail.hasOwnProperty(key)) {
|
||||
this.form[key] = detail[key];
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.span2 {
|
||||
grid-column: span 2;
|
||||
}
|
||||
::v-deep .el-form-item > * {
|
||||
max-width: 100%;
|
||||
}
|
||||
.drawer-container {
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
& > * {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,685 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card shadow="never" style="margin-top: 20px">
|
||||
<template #header>
|
||||
<slot name="header">
|
||||
<vxe-toolbar
|
||||
custom
|
||||
:print="isHasAuth('print')"
|
||||
ref="toolbar"
|
||||
>
|
||||
<template #toolSuffix>
|
||||
<vxe-button style="margin-right: 10px;" v-if="isHasAuth('export')" icon="vxe-icon-download" circle @click="exportMethod"></vxe-button>
|
||||
</template>
|
||||
<template #buttons>
|
||||
<el-button
|
||||
v-if="isHasAuth('create')"
|
||||
icon="el-icon-plus"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="isShowAdd = true"
|
||||
>新增</el-button
|
||||
>
|
||||
<template v-if="isHasAuth('search')">
|
||||
<el-input style="width: 120px;" v-model="select['filter[1][value]']" placeholder="学校名称.." size="small"></el-input>
|
||||
<el-select style="width: 100px;" v-model="select['filter[0][value]']" placeholder="区域.." size="small">
|
||||
<el-option v-for="item in area" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
<el-input style="width: 120px;" v-model="select['filter[2][value]']" placeholder="学校星级.." size="small"></el-input>
|
||||
|
||||
<el-button
|
||||
icon="el-icon-search"
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
@click="getList"
|
||||
>搜索</el-button
|
||||
>
|
||||
</template>
|
||||
</template>
|
||||
</vxe-toolbar>
|
||||
</slot>
|
||||
</template>
|
||||
|
||||
<vxe-table
|
||||
ref="table"
|
||||
stripe
|
||||
style="margin-top: 10px"
|
||||
:loading="loading"
|
||||
:height="tableHeight"
|
||||
keep-source
|
||||
show-overflow
|
||||
:menu-config="{
|
||||
className: 'my-menus',
|
||||
body: {
|
||||
options: [
|
||||
[
|
||||
{
|
||||
code: 'copy',
|
||||
name: '复制',
|
||||
prefixConfig: { icon: 'vxe-icon-copy' },
|
||||
suffixConfig: { content: 'Ctrl+C' },
|
||||
},
|
||||
{
|
||||
code: 'remove',
|
||||
name: '删除',
|
||||
prefixConfig: {
|
||||
icon: 'vxe-icon-delete-fill',
|
||||
className: 'color-red',
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
}"
|
||||
@menu-click="contextMenuClickEvent"
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:column-config="{ resizable: true }"
|
||||
:export-config="{}"
|
||||
:edit-rules="validRules"
|
||||
:edit-config="{
|
||||
trigger: 'manual',
|
||||
mode: 'row',
|
||||
showStatus: true,
|
||||
isHover: true,
|
||||
autoClear: false,
|
||||
}"
|
||||
:align="allAlign"
|
||||
:data="tableData"
|
||||
>
|
||||
<vxe-column type="checkbox" width="50" align="center" />
|
||||
<vxe-column type="seq" width="58" align="center" />
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="name"
|
||||
width="160"
|
||||
title="学校名称"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
align="center"
|
||||
field="area_id"
|
||||
width="180"
|
||||
title="区域"
|
||||
:edit-render="{
|
||||
name: 'VxeSelect',
|
||||
options: area,
|
||||
props: { multiple: false },
|
||||
optionProps: { value: 'id', label: 'name' },
|
||||
}"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="code"
|
||||
width="160"
|
||||
title="学校代码"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="star"
|
||||
width="160"
|
||||
title="星级"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="address"
|
||||
width="160"
|
||||
title="地址"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
align="center"
|
||||
field="nature"
|
||||
width="180"
|
||||
title="性质"
|
||||
:edit-render="{
|
||||
name: 'VxeSelect',
|
||||
options: [
|
||||
{ value: 1, label: '公办' },
|
||||
{ value: 2, label: '民办' },
|
||||
],
|
||||
props: { multiple: false },
|
||||
optionProps: { value: 'value', label: 'label' },
|
||||
}"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
align="center"
|
||||
field="type"
|
||||
width="180"
|
||||
title="学校类型"
|
||||
:edit-render="{
|
||||
name: 'VxeSelect',
|
||||
options: [
|
||||
{ label: '初中', value: '初中' },
|
||||
{ label: '中专', value: '中专' },
|
||||
{ label: '3+3', value: '3+3' },
|
||||
{ label: '五年制大专', value: '五年制大专' },
|
||||
{ label: '中本贯通5+2', value: '中本贯通5+2' },
|
||||
{ label: '中本贯通3+4', value: '中本贯通3+4' },
|
||||
{ label: '综合高中', value: '综合高中' },
|
||||
{ label: '高中', value: '高中' },
|
||||
],
|
||||
props: { multiple: true },
|
||||
optionProps: { value: 'value', label: 'label' },
|
||||
}"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="build_year"
|
||||
width="160"
|
||||
title="建校年份"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
align="center"
|
||||
header-align="center"
|
||||
field="introduce"
|
||||
width="120"
|
||||
title="学校介绍"
|
||||
:edit-render="{}"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
slot="reference"
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
@click="
|
||||
$refs['RichTextModal'].open({
|
||||
text: row['introduce'],
|
||||
readonly: true,
|
||||
fieldName: 'introduce',
|
||||
row,
|
||||
})
|
||||
"
|
||||
>查看</el-button
|
||||
>
|
||||
</template>
|
||||
<template #edit="{ row }">
|
||||
<el-button
|
||||
slot="reference"
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-edit"
|
||||
@click="
|
||||
$refs['RichTextModal'].open({
|
||||
text: row['introduce'],
|
||||
readonly: false,
|
||||
fieldName: 'introduce',
|
||||
row,
|
||||
})
|
||||
"
|
||||
>编辑</el-button
|
||||
>
|
||||
</template>
|
||||
</vxe-column>
|
||||
|
||||
<vxe-column
|
||||
align="center"
|
||||
header-align="center"
|
||||
field="teacher"
|
||||
width="120"
|
||||
title="教师信息"
|
||||
:edit-render="{}"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
slot="reference"
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
@click="
|
||||
$refs['RichTextModal'].open({
|
||||
text: row['teacher'],
|
||||
readonly: true,
|
||||
fieldName: 'teacher',
|
||||
row,
|
||||
})
|
||||
"
|
||||
>查看</el-button
|
||||
>
|
||||
</template>
|
||||
<template #edit="{ row }">
|
||||
<el-button
|
||||
slot="reference"
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-edit"
|
||||
@click="
|
||||
$refs['RichTextModal'].open({
|
||||
text: row['teacher'],
|
||||
readonly: false,
|
||||
fieldName: 'teacher',
|
||||
row,
|
||||
})
|
||||
"
|
||||
>编辑</el-button
|
||||
>
|
||||
</template>
|
||||
</vxe-column>
|
||||
|
||||
<vxe-column
|
||||
field="operate"
|
||||
header-align="center"
|
||||
title="操作"
|
||||
min-width="220"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<template v-if="isActiveStatus(row)">
|
||||
<el-button size="small" type="primary" @click="saveRowEvent(row)"
|
||||
>保存</el-button
|
||||
>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="cancelRowEvent(row)"
|
||||
>取消</el-button
|
||||
>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button
|
||||
v-if="isHasAuth('detail')"
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="detail(row)"
|
||||
>查看</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="isHasAuth('edit')"
|
||||
size="small"
|
||||
type="warning"
|
||||
@click="editRowEvent(row)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="isHasAuth('delete')"
|
||||
size="small"
|
||||
type="danger"
|
||||
@click="destroyRowEvent(row)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
|
||||
<el-pagination
|
||||
style="margin-top: 10px; display: flex; justify-content: flex-end"
|
||||
:current-page.sync="select.page"
|
||||
:page-sizes="[20, 30, 40, 50]"
|
||||
:page-size.sync="select.page_size"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
@size-change="
|
||||
(e) => {
|
||||
select.page_size = e;
|
||||
select.page = 1;
|
||||
getList();
|
||||
}
|
||||
"
|
||||
@current-change="
|
||||
(e) => {
|
||||
select.page = e;
|
||||
getList();
|
||||
}
|
||||
"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<AddSchool
|
||||
ref="AddSchool"
|
||||
:area="area"
|
||||
:is-show.sync="isShowAdd"
|
||||
@refresh="getList"
|
||||
/>
|
||||
<ShowSchool ref="ShowSchool" :area="area" :is-show.sync="isShowDetail" />
|
||||
|
||||
<rich-text-modal
|
||||
ref="RichTextModal"
|
||||
@confirm="({ row, fieldName, text }) => (row[fieldName] = text)"
|
||||
></rich-text-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import VxeUI from "vxe-pc-ui";
|
||||
|
||||
import RichTextModal from "@/components/RichTextModal/index.vue";
|
||||
|
||||
import { authMixin } from "@/mixin/authMixin";
|
||||
import { uploadSize } from "@/settings";
|
||||
import { deepCopy } from "@/utils";
|
||||
import { destroy, index, save } from "@/api/school/school";
|
||||
import AddSchool from "./components/AddSchool.vue";
|
||||
import ShowSchool from "./components/ShowSchool.vue";
|
||||
import axios from "axios";
|
||||
import { getToken } from "@/utils/auth";
|
||||
import { download } from "@/utils/downloadRequest"
|
||||
import { index as areaIndex } from "@/api/area/area";
|
||||
|
||||
export default {
|
||||
name: "School",
|
||||
mixins: [authMixin],
|
||||
components: {
|
||||
RichTextModal,
|
||||
|
||||
AddSchool,
|
||||
ShowSchool,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadSize,
|
||||
examineKey: 0,
|
||||
isShowAdd: false,
|
||||
isShowDetail: false,
|
||||
|
||||
loading: false,
|
||||
tableHeight: 400,
|
||||
select: {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
keyword: "",
|
||||
show_relation: [],
|
||||
'filter[0][key]': 'area_id',
|
||||
'filter[0][op]': 'eq',
|
||||
'filter[0][value]': '',
|
||||
'filter[1][key]': 'name',
|
||||
'filter[1][op]': 'like',
|
||||
'filter[1][value]': '',
|
||||
'filter[2][key]': 'star',
|
||||
'filter[2][op]': 'like',
|
||||
'filter[2][value]': '',
|
||||
},
|
||||
total: 0,
|
||||
allAlign: null,
|
||||
tableData: [],
|
||||
form: {
|
||||
id: "",
|
||||
|
||||
name: "",
|
||||
|
||||
area_id: "",
|
||||
|
||||
code: "",
|
||||
|
||||
star: "",
|
||||
|
||||
address: "",
|
||||
|
||||
nature: "",
|
||||
|
||||
type: "",
|
||||
|
||||
build_year: "",
|
||||
|
||||
introduce: "",
|
||||
|
||||
teacher: "",
|
||||
},
|
||||
validRules: {
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: "学校名称" + "必填",
|
||||
},
|
||||
],
|
||||
|
||||
area_id: [
|
||||
{
|
||||
required: true,
|
||||
message: "区域" + "必填",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
area: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isActiveStatus() {
|
||||
return function (row) {
|
||||
if (this.$refs["table"]) {
|
||||
return this.$refs["table"].isEditByRow(row);
|
||||
}
|
||||
};
|
||||
},
|
||||
isHasAuth() {
|
||||
return function (auth) {
|
||||
return this.auths_auth_mixin.indexOf(auth) !== -1;
|
||||
};
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getArea();
|
||||
|
||||
this.getList();
|
||||
},
|
||||
mounted() {
|
||||
this.bindToolbar();
|
||||
this.calcTableHeight();
|
||||
},
|
||||
methods: {
|
||||
exportMethod() {
|
||||
this.$confirm("请选择导出方式", "提示", {
|
||||
confirmButtonText: "全量导出",
|
||||
cancelButtonText: "部分导出",
|
||||
distinguishCancelAndClose: true
|
||||
}).then(_ => {
|
||||
download('/api/admin/school/index', 'get', {
|
||||
...this.select,
|
||||
page: 1,
|
||||
page_size: 9999,
|
||||
is_export: 1,
|
||||
export_fields: Object.keys(this.form)
|
||||
})
|
||||
}).catch(action => {
|
||||
if (action === 'cancel' && this.$refs['table']) {
|
||||
this.$refs['table'].openExport()
|
||||
}
|
||||
});
|
||||
},
|
||||
calcTableHeight() {
|
||||
let clientHeight = document.documentElement.clientHeight;
|
||||
let cardTitle = document
|
||||
.querySelector(".el-card__header")
|
||||
?.getBoundingClientRect()?.height;
|
||||
let search = document
|
||||
.querySelector(".vxe-toolbar")
|
||||
?.getBoundingClientRect()?.height;
|
||||
let paginationHeight =
|
||||
(document.querySelector(".el-pagination")?.getBoundingClientRect()
|
||||
?.height ?? 0) + 10; //分页的高度
|
||||
let topHeight = 50; //页面 头部
|
||||
let padding = 80;
|
||||
let margin = 20;
|
||||
this.tableHeight =
|
||||
clientHeight -
|
||||
cardTitle -
|
||||
search -
|
||||
paginationHeight -
|
||||
topHeight -
|
||||
padding -
|
||||
margin;
|
||||
},
|
||||
contextMenuClickEvent({ menu, row, column }) {
|
||||
switch (menu.code) {
|
||||
case "copy":
|
||||
// 示例
|
||||
if (row && column) {
|
||||
if (VxeUI.clipboard.copy(row[column.field])) {
|
||||
this.$message.success("已复制到剪贴板!");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
if (row && column) {
|
||||
this.destroyRowEvent(row);
|
||||
}
|
||||
default:
|
||||
}
|
||||
},
|
||||
async detail(row) {
|
||||
await this.$refs["ShowSchool"].getDetail(row.id);
|
||||
this.isShowDetail = true;
|
||||
},
|
||||
|
||||
async getArea() {
|
||||
try {
|
||||
const res = await areaIndex(
|
||||
{
|
||||
page: 1,
|
||||
page_size: 999,
|
||||
},
|
||||
false
|
||||
);
|
||||
this.area = res.data;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
},
|
||||
|
||||
uploadMethod(file) {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
window.$_uploading = true;
|
||||
return axios
|
||||
.post(process.env.VUE_APP_UPLOAD_API, formData, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${getToken()}`,
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
window.$_uploading = false;
|
||||
if (response.status === 200 && !response.data.code) {
|
||||
return {
|
||||
response: response.data,
|
||||
name: response.data.original_name,
|
||||
url: response.data.url,
|
||||
};
|
||||
} else {
|
||||
this.$message.error("上传失败");
|
||||
}
|
||||
})
|
||||
.catch((_) => {
|
||||
window.$_uploading = false;
|
||||
});
|
||||
},
|
||||
bindToolbar() {
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs["table"] && this.$refs["toolbar"]) {
|
||||
this.$refs["table"].connect(this.$refs["toolbar"]);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
editRowEvent(row) {
|
||||
if (this.$refs["table"]) {
|
||||
this.$refs["table"].setEditRow(row);
|
||||
}
|
||||
},
|
||||
cancelRowEvent(row) {
|
||||
if (this.$refs["table"]) {
|
||||
this.$refs["table"].clearEdit().then(() => {
|
||||
// 还原行数据
|
||||
this.$refs["table"].revertData(row);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async getList() {
|
||||
this.loading = true;
|
||||
try {
|
||||
const res = await index(this.select, false);
|
||||
this.tableData = res.data;
|
||||
this.total = res.total;
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
async saveRowEvent(row) {
|
||||
if (window.$_uploading) {
|
||||
this.$message.warning("文件正在上传中");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const errMap = await this.$refs["table"].validate();
|
||||
if (errMap) {
|
||||
throw new Error(errMap);
|
||||
}
|
||||
await this.$confirm("确认保存?", "提示", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
});
|
||||
await this.$refs["table"].clearEdit();
|
||||
let form = deepCopy(this.form);
|
||||
for (const key in form) {
|
||||
form[key] = row[key];
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
await save(form, false);
|
||||
await this.getList();
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
async destroyRowEvent(row) {
|
||||
try {
|
||||
await this.$confirm("确认删除?", "提示", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
});
|
||||
this.loading = true;
|
||||
if (row.id) {
|
||||
await destroy(
|
||||
{
|
||||
id: row.id,
|
||||
},
|
||||
false
|
||||
);
|
||||
await this.getList();
|
||||
} else {
|
||||
console.log(row);
|
||||
this.tableData.splice(
|
||||
this.tableData.findIndex((i) => i._X_ROW_KEY === row._X_ROW_KEY),
|
||||
1
|
||||
);
|
||||
}
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
::v-deep .vxe-buttons--wrapper > * + * {
|
||||
margin-left: 10px;
|
||||
}
|
||||
::v-deep .el-card__header {
|
||||
padding: 6px 20px;
|
||||
}
|
||||
::v-deep .el-tag + .el-tag {
|
||||
margin-left: 4px;
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,170 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-drawer
|
||||
:title="$route.meta.title"
|
||||
direction="rtl"
|
||||
size="68%"
|
||||
:visible.sync="visible"
|
||||
append-to-body
|
||||
@close="$emit('update:isShow', false)"
|
||||
>
|
||||
<section class="drawer-container">
|
||||
<el-descriptions
|
||||
class="drawer-container__desc"
|
||||
size="small"
|
||||
border
|
||||
ref="elDesc"
|
||||
:column="2"
|
||||
direction="vertical"
|
||||
:labelStyle="{ 'font-weight': '500', 'font-size': '15px' }"
|
||||
>
|
||||
<el-descriptions-item label="学校名称">
|
||||
{{ form["name"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="区域">
|
||||
{{
|
||||
area.find((i) => i["id"] === form["area_id"])
|
||||
? area.find((i) => i["id"] === form["area_id"])["name"]
|
||||
: ""
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="学校代码">
|
||||
{{ form["code"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="星级">
|
||||
{{ form["star"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="地址">
|
||||
{{ form["address"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="性质">
|
||||
{{
|
||||
[
|
||||
{ value: 1, label: "公办" },
|
||||
{ value: 2, label: "民办" },
|
||||
].find((i) => i["value"] === form["nature"])
|
||||
? [
|
||||
{ value: 1, label: "公办" },
|
||||
{ value: 2, label: "民办" },
|
||||
].find((i) => i["value"] === form["nature"])["label"]
|
||||
: ""
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="学校类型">
|
||||
{{
|
||||
form["type"].toString()
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="建校年份">
|
||||
{{ form["build_year"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="学校介绍" span="2">
|
||||
{{ form["introduce"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="教师信息" span="2">
|
||||
{{ form["teacher"] }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { show } from "@/api/school/school";
|
||||
|
||||
export default {
|
||||
name: "SchoolShow",
|
||||
props: {
|
||||
isShow: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
required: true,
|
||||
},
|
||||
|
||||
area: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
visible: false,
|
||||
form: {
|
||||
name: "",
|
||||
|
||||
area_id: "",
|
||||
|
||||
code: "",
|
||||
|
||||
star: "",
|
||||
|
||||
address: "",
|
||||
|
||||
nature: "",
|
||||
|
||||
type: "",
|
||||
|
||||
build_year: "",
|
||||
|
||||
introduce: "",
|
||||
|
||||
teacher: "",
|
||||
},
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
isShow(newVal) {
|
||||
this.visible = newVal;
|
||||
},
|
||||
visible(newVal) {
|
||||
this.$emit("update:isShow", newVal);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async getDetail(id) {
|
||||
try {
|
||||
const detail = await show({
|
||||
id,
|
||||
});
|
||||
for (let key in this.form) {
|
||||
if (detail.hasOwnProperty(key)) {
|
||||
this.form[key] = detail[key];
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.span2 {
|
||||
grid-column: span 2;
|
||||
}
|
||||
::v-deep .el-form-item > * {
|
||||
max-width: 100%;
|
||||
}
|
||||
.drawer-container {
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
& > * {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,539 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card shadow="never" style="margin-top: 20px">
|
||||
<template #header>
|
||||
<slot name="header">
|
||||
<vxe-toolbar
|
||||
:print="isHasAuth('print')"
|
||||
custom
|
||||
ref="toolbar"
|
||||
>
|
||||
<template #toolSuffix>
|
||||
<vxe-button style="margin-right: 10px;" v-if="isHasAuth('export')" icon="vxe-icon-download" circle @click="exportMethod"></vxe-button>
|
||||
</template>
|
||||
<template #buttons>
|
||||
<el-button
|
||||
v-if="isHasAuth('create')"
|
||||
icon="el-icon-plus"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="isShowAdd = true"
|
||||
>新增</el-button
|
||||
>
|
||||
<template v-if="isHasAuth('search')">
|
||||
<el-select style="width: 120px;" v-model="select['filter[0][value]']" placeholder="学校.." size="small">
|
||||
<el-option v-for="item in school" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
<el-date-picker style="width: 100px;" type="year" value-format="yyyy" v-model="select['filter[1][value]']" placeholder="年份.." size="small"></el-date-picker>
|
||||
|
||||
<el-button
|
||||
icon="el-icon-search"
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
@click="getList"
|
||||
>搜索</el-button
|
||||
>
|
||||
</template>
|
||||
</template>
|
||||
</vxe-toolbar>
|
||||
</slot>
|
||||
</template>
|
||||
|
||||
<vxe-table
|
||||
ref="table"
|
||||
stripe
|
||||
style="margin-top: 10px"
|
||||
:loading="loading"
|
||||
:height="tableHeight"
|
||||
keep-source
|
||||
show-overflow
|
||||
:menu-config="{
|
||||
className: 'my-menus',
|
||||
body: {
|
||||
options: [
|
||||
[
|
||||
{
|
||||
code: 'copy',
|
||||
name: '复制',
|
||||
prefixConfig: { icon: 'vxe-icon-copy' },
|
||||
suffixConfig: { content: 'Ctrl+C' },
|
||||
},
|
||||
{
|
||||
code: 'remove',
|
||||
name: '删除',
|
||||
prefixConfig: {
|
||||
icon: 'vxe-icon-delete-fill',
|
||||
className: 'color-red',
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
}"
|
||||
@menu-click="contextMenuClickEvent"
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:column-config="{ resizable: true }"
|
||||
:export-config="{}"
|
||||
:edit-rules="validRules"
|
||||
:edit-config="{
|
||||
trigger: 'manual',
|
||||
mode: 'row',
|
||||
showStatus: true,
|
||||
isHover: true,
|
||||
autoClear: false,
|
||||
}"
|
||||
:align="allAlign"
|
||||
:data="tableData"
|
||||
>
|
||||
<vxe-column type="checkbox" width="50" align="center" />
|
||||
<vxe-column type="seq" width="58" align="center" />
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="code"
|
||||
width="160"
|
||||
title="代码"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
align="center"
|
||||
field="school_id"
|
||||
width="180"
|
||||
title="所属学校"
|
||||
:edit-render="{
|
||||
name: 'VxeSelect',
|
||||
options: school,
|
||||
props: { multiple: false },
|
||||
optionProps: { value: 'id', label: 'name' },
|
||||
}"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
align="center"
|
||||
field="year"
|
||||
width="180"
|
||||
title="年份"
|
||||
:edit-render="{ name: 'VxeDatePicker', props: { type: 'year' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
align="right"
|
||||
field="total_score"
|
||||
width="160"
|
||||
title="统招总分"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'number' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
align="right"
|
||||
field="main_score"
|
||||
width="160"
|
||||
title="统招语数外"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'number' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
align="right"
|
||||
field="area_total_score"
|
||||
width="160"
|
||||
title="跨区总分"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'number' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
align="right"
|
||||
field="area_main_score"
|
||||
width="160"
|
||||
title="跨区语数外"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'number' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
field="operate"
|
||||
header-align="center"
|
||||
title="操作"
|
||||
min-width="220"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<template v-if="isActiveStatus(row)">
|
||||
<el-button size="small" type="primary" @click="saveRowEvent(row)"
|
||||
>保存</el-button
|
||||
>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="cancelRowEvent(row)"
|
||||
>取消</el-button
|
||||
>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button
|
||||
v-if="isHasAuth('detail')"
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="detail(row)"
|
||||
>查看</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="isHasAuth('edit')"
|
||||
size="small"
|
||||
type="warning"
|
||||
@click="editRowEvent(row)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="isHasAuth('delete')"
|
||||
size="small"
|
||||
type="danger"
|
||||
@click="destroyRowEvent(row)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
|
||||
<el-pagination
|
||||
style="margin-top: 10px; display: flex; justify-content: flex-end"
|
||||
:current-page.sync="select.page"
|
||||
:page-sizes="[20, 30, 40, 50]"
|
||||
:page-size.sync="select.page_size"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
@size-change="
|
||||
(e) => {
|
||||
select.page_size = e;
|
||||
select.page = 1;
|
||||
getList();
|
||||
}
|
||||
"
|
||||
@current-change="
|
||||
(e) => {
|
||||
select.page = e;
|
||||
getList();
|
||||
}
|
||||
"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<AddScore
|
||||
ref="AddScore"
|
||||
:school="school"
|
||||
:is-show.sync="isShowAdd"
|
||||
@refresh="getList"
|
||||
/>
|
||||
<ShowScore ref="ShowScore" :school="school" :is-show.sync="isShowDetail" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import VxeUI from "vxe-pc-ui";
|
||||
|
||||
import { authMixin } from "@/mixin/authMixin";
|
||||
import { uploadSize } from "@/settings";
|
||||
import { deepCopy } from "@/utils";
|
||||
import { destroy, index, save } from "@/api/score/score";
|
||||
import AddScore from "./components/AddScore.vue";
|
||||
import ShowScore from "./components/ShowScore.vue";
|
||||
import axios from "axios";
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
import { index as schoolIndex } from "@/api/school/school";
|
||||
import {download} from "@/utils/downloadRequest";
|
||||
|
||||
export default {
|
||||
name: "Score",
|
||||
mixins: [authMixin],
|
||||
components: {
|
||||
AddScore,
|
||||
ShowScore,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadSize,
|
||||
examineKey: 0,
|
||||
isShowAdd: false,
|
||||
isShowDetail: false,
|
||||
|
||||
loading: false,
|
||||
tableHeight: 400,
|
||||
select: {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
keyword: "",
|
||||
show_relation: [],
|
||||
"filter[0][key]": "school_id",
|
||||
"filter[0][op]": "eq",
|
||||
"filter[0][value]": "",
|
||||
"filter[1][key]": "year",
|
||||
"filter[1][op]": "eq",
|
||||
"filter[1][value]": "",
|
||||
},
|
||||
total: 0,
|
||||
allAlign: null,
|
||||
tableData: [],
|
||||
form: {
|
||||
id: "",
|
||||
|
||||
code: "",
|
||||
|
||||
school_id: "",
|
||||
|
||||
year: "",
|
||||
|
||||
total_score: "",
|
||||
|
||||
main_score: "",
|
||||
|
||||
area_total_score: "",
|
||||
|
||||
area_main_score: "",
|
||||
},
|
||||
validRules: {},
|
||||
|
||||
school: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isActiveStatus() {
|
||||
return function (row) {
|
||||
if (this.$refs["table"]) {
|
||||
return this.$refs["table"].isEditByRow(row);
|
||||
}
|
||||
};
|
||||
},
|
||||
isHasAuth() {
|
||||
return function (auth) {
|
||||
return this.auths_auth_mixin.indexOf(auth) !== -1;
|
||||
};
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getSchool();
|
||||
|
||||
this.getList();
|
||||
},
|
||||
mounted() {
|
||||
this.bindToolbar();
|
||||
this.calcTableHeight();
|
||||
},
|
||||
methods: {
|
||||
exportMethod() {
|
||||
this.$confirm("请选择导出方式", "提示", {
|
||||
confirmButtonText: "全量导出",
|
||||
cancelButtonText: "部分导出",
|
||||
distinguishCancelAndClose: true
|
||||
}).then(_ => {
|
||||
download('/api/admin/school/index', 'get', {
|
||||
...this.select,
|
||||
page: 1,
|
||||
page_size: 9999,
|
||||
is_export: 1,
|
||||
export_fields: Object.keys(this.form)
|
||||
})
|
||||
}).catch(action => {
|
||||
if (action === 'cancel' && this.$refs['table']) {
|
||||
this.$refs['table'].openExport()
|
||||
}
|
||||
});
|
||||
},
|
||||
calcTableHeight() {
|
||||
let clientHeight = document.documentElement.clientHeight;
|
||||
let cardTitle = document
|
||||
.querySelector(".el-card__header")
|
||||
?.getBoundingClientRect()?.height;
|
||||
let search = document
|
||||
.querySelector(".vxe-toolbar")
|
||||
?.getBoundingClientRect()?.height;
|
||||
let paginationHeight =
|
||||
(document.querySelector(".el-pagination")?.getBoundingClientRect()
|
||||
?.height ?? 0) + 10; //分页的高度
|
||||
let topHeight = 50; //页面 头部
|
||||
let padding = 80;
|
||||
let margin = 20;
|
||||
this.tableHeight =
|
||||
clientHeight -
|
||||
cardTitle -
|
||||
search -
|
||||
paginationHeight -
|
||||
topHeight -
|
||||
padding -
|
||||
margin;
|
||||
},
|
||||
contextMenuClickEvent({ menu, row, column }) {
|
||||
switch (menu.code) {
|
||||
case "copy":
|
||||
// 示例
|
||||
if (row && column) {
|
||||
if (VxeUI.clipboard.copy(row[column.field])) {
|
||||
this.$message.success("已复制到剪贴板!");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
if (row && column) {
|
||||
this.destroyRowEvent(row);
|
||||
}
|
||||
default:
|
||||
}
|
||||
},
|
||||
async detail(row) {
|
||||
await this.$refs["ShowScore"].getDetail(row.id);
|
||||
this.isShowDetail = true;
|
||||
},
|
||||
|
||||
async getSchool() {
|
||||
try {
|
||||
const res = await schoolIndex(
|
||||
{
|
||||
page: 1,
|
||||
page_size: 999,
|
||||
},
|
||||
false
|
||||
);
|
||||
this.school = res.data;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
},
|
||||
|
||||
uploadMethod(file) {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
window.$_uploading = true;
|
||||
return axios
|
||||
.post(process.env.VUE_APP_UPLOAD_API, formData, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${getToken()}`,
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
window.$_uploading = false;
|
||||
if (response.status === 200 && !response.data.code) {
|
||||
return {
|
||||
response: response.data,
|
||||
name: response.data.original_name,
|
||||
url: response.data.url,
|
||||
};
|
||||
} else {
|
||||
this.$message.error("上传失败");
|
||||
}
|
||||
})
|
||||
.catch((_) => {
|
||||
window.$_uploading = false;
|
||||
});
|
||||
},
|
||||
bindToolbar() {
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs["table"] && this.$refs["toolbar"]) {
|
||||
this.$refs["table"].connect(this.$refs["toolbar"]);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
editRowEvent(row) {
|
||||
if (this.$refs["table"]) {
|
||||
this.$refs["table"].setEditRow(row);
|
||||
}
|
||||
},
|
||||
cancelRowEvent(row) {
|
||||
if (this.$refs["table"]) {
|
||||
this.$refs["table"].clearEdit().then(() => {
|
||||
// 还原行数据
|
||||
this.$refs["table"].revertData(row);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async getList() {
|
||||
this.loading = true;
|
||||
try {
|
||||
const res = await index(this.select, false);
|
||||
this.tableData = res.data;
|
||||
this.total = res.total;
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
async saveRowEvent(row) {
|
||||
if (window.$_uploading) {
|
||||
this.$message.warning("文件正在上传中");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const errMap = await this.$refs["table"].validate();
|
||||
if (errMap) {
|
||||
throw new Error(errMap);
|
||||
}
|
||||
await this.$confirm("确认保存?", "提示", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
});
|
||||
await this.$refs["table"].clearEdit();
|
||||
let form = deepCopy(this.form);
|
||||
for (const key in form) {
|
||||
form[key] = row[key];
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
await save(form, false);
|
||||
await this.getList();
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
async destroyRowEvent(row) {
|
||||
try {
|
||||
await this.$confirm("确认删除?", "提示", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
});
|
||||
this.loading = true;
|
||||
if (row.id) {
|
||||
await destroy(
|
||||
{
|
||||
id: row.id,
|
||||
},
|
||||
false
|
||||
);
|
||||
await this.getList();
|
||||
} else {
|
||||
console.log(row);
|
||||
this.tableData.splice(
|
||||
this.tableData.findIndex((i) => i._X_ROW_KEY === row._X_ROW_KEY),
|
||||
1
|
||||
);
|
||||
}
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
::v-deep .vxe-buttons--wrapper > * + * {
|
||||
margin-left: 10px;
|
||||
}
|
||||
::v-deep .el-card__header {
|
||||
padding: 6px 20px;
|
||||
}
|
||||
::v-deep .el-tag + .el-tag {
|
||||
margin-left: 4px;
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,156 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-drawer
|
||||
:title="$route.meta.title"
|
||||
direction="rtl"
|
||||
size="68%"
|
||||
:visible.sync="visible"
|
||||
append-to-body
|
||||
@close="$emit('update:isShow', false)"
|
||||
>
|
||||
<section class="drawer-container">
|
||||
<el-descriptions
|
||||
class="drawer-container__desc"
|
||||
size="small"
|
||||
border
|
||||
ref="elDesc"
|
||||
:column="2"
|
||||
direction="vertical"
|
||||
:labelStyle="{ 'font-weight': '500', 'font-size': '15px' }"
|
||||
>
|
||||
<el-descriptions-item label="代码">
|
||||
{{ form["code"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="所属学校">
|
||||
{{
|
||||
school.find((i) => i["id"] === form["school_id"])
|
||||
? school.find((i) => i["id"] === form["school_id"])["name"]
|
||||
: ""
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="年份">
|
||||
{{ form["year"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="统招总分">
|
||||
{{
|
||||
typeof form["total_score"] === "number"
|
||||
? form["total_score"].toFixed(2)
|
||||
: form["total_score"]
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="统招语数外">
|
||||
{{
|
||||
typeof form["main_score"] === "number"
|
||||
? form["main_score"].toFixed(2)
|
||||
: form["main_score"]
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="跨区总分">
|
||||
{{
|
||||
typeof form["area_total_score"] === "number"
|
||||
? form["area_total_score"].toFixed(2)
|
||||
: form["area_total_score"]
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="跨区语数外">
|
||||
{{
|
||||
typeof form["area_main_score"] === "number"
|
||||
? form["area_main_score"].toFixed(2)
|
||||
: form["area_main_score"]
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { show } from "@/api/score/score";
|
||||
|
||||
export default {
|
||||
name: "ScoreShow",
|
||||
props: {
|
||||
isShow: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
required: true,
|
||||
},
|
||||
|
||||
school: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
visible: false,
|
||||
form: {
|
||||
code: "",
|
||||
|
||||
school_id: "",
|
||||
|
||||
year: "",
|
||||
|
||||
total_score: "",
|
||||
|
||||
main_score: "",
|
||||
|
||||
area_total_score: "",
|
||||
|
||||
area_main_score: "",
|
||||
},
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
isShow(newVal) {
|
||||
this.visible = newVal;
|
||||
},
|
||||
visible(newVal) {
|
||||
this.$emit("update:isShow", newVal);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async getDetail(id) {
|
||||
try {
|
||||
const detail = await show({
|
||||
id,
|
||||
});
|
||||
for (let key in this.form) {
|
||||
if (detail.hasOwnProperty(key)) {
|
||||
this.form[key] = detail[key];
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.span2 {
|
||||
grid-column: span 2;
|
||||
}
|
||||
::v-deep .el-form-item > * {
|
||||
max-width: 100%;
|
||||
}
|
||||
.drawer-container {
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
& > * {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,547 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card shadow="never" style="margin-top: 20px">
|
||||
<template #header>
|
||||
<slot name="header">
|
||||
<vxe-toolbar
|
||||
:export="isHasAuth('export')"
|
||||
:print="isHasAuth('print')"
|
||||
custom
|
||||
ref="toolbar"
|
||||
>
|
||||
<template #buttons>
|
||||
<el-button
|
||||
v-if="isHasAuth('create')"
|
||||
icon="el-icon-plus"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="isShowAdd = true"
|
||||
>新增</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="isHasAuth('search')"
|
||||
icon="el-icon-search"
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
@click="getList"
|
||||
>搜索</el-button
|
||||
>
|
||||
</template>
|
||||
</vxe-toolbar>
|
||||
</slot>
|
||||
</template>
|
||||
|
||||
<vxe-table
|
||||
ref="table"
|
||||
stripe
|
||||
style="margin-top: 10px"
|
||||
:loading="loading"
|
||||
:height="tableHeight"
|
||||
keep-source
|
||||
show-overflow
|
||||
:menu-config="{
|
||||
className: 'my-menus',
|
||||
body: {
|
||||
options: [
|
||||
[
|
||||
{
|
||||
code: 'copy',
|
||||
name: '复制',
|
||||
prefixConfig: { icon: 'vxe-icon-copy' },
|
||||
suffixConfig: { content: 'Ctrl+C' },
|
||||
},
|
||||
{
|
||||
code: 'remove',
|
||||
name: '删除',
|
||||
prefixConfig: {
|
||||
icon: 'vxe-icon-delete-fill',
|
||||
className: 'color-red',
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
}"
|
||||
@menu-click="contextMenuClickEvent"
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:column-config="{ resizable: true }"
|
||||
:export-config="{}"
|
||||
:edit-rules="validRules"
|
||||
:edit-config="{
|
||||
trigger: 'manual',
|
||||
mode: 'row',
|
||||
showStatus: true,
|
||||
isHover: true,
|
||||
autoClear: false,
|
||||
}"
|
||||
:align="allAlign"
|
||||
:data="tableData"
|
||||
>
|
||||
<vxe-column type="seq" width="58" align="center" />
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="nickname"
|
||||
width="160"
|
||||
title="昵称"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="openid"
|
||||
width="160"
|
||||
title="openid"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="headimgurl"
|
||||
width="160"
|
||||
title="头像地址"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="mobile"
|
||||
width="160"
|
||||
title="手机号"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
align="center"
|
||||
field="sex"
|
||||
width="180"
|
||||
title="性别"
|
||||
:edit-render="{
|
||||
name: 'VxeSelect',
|
||||
options: [
|
||||
{ value: '男', label: '男' },
|
||||
{ value: '女', label: '女' },
|
||||
{ value: '保密', label: '保密' },
|
||||
],
|
||||
props: { multiple: false },
|
||||
optionProps: { value: 'value', label: 'label' },
|
||||
}"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="area"
|
||||
width="160"
|
||||
title="区县"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="province"
|
||||
width="160"
|
||||
title="省份"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="city"
|
||||
width="160"
|
||||
title="城市"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="name"
|
||||
width="160"
|
||||
title="学生姓名"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="grade"
|
||||
width="160"
|
||||
title="年级"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
align="center"
|
||||
field="middle_exam_year"
|
||||
width="180"
|
||||
title="中考年份"
|
||||
:edit-render="{ name: 'VxeDatePicker', props: { type: 'year' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="nationality"
|
||||
width="160"
|
||||
title="民族"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
header-align="center"
|
||||
field="school"
|
||||
width="160"
|
||||
title="学校"
|
||||
:edit-render="{ name: 'input', attrs: { type: 'text' } }"
|
||||
/>
|
||||
|
||||
<vxe-column
|
||||
field="operate"
|
||||
header-align="center"
|
||||
title="操作"
|
||||
min-width="220"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<template v-if="isActiveStatus(row)">
|
||||
<el-button size="small" type="primary" @click="saveRowEvent(row)"
|
||||
>保存</el-button
|
||||
>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="cancelRowEvent(row)"
|
||||
>取消</el-button
|
||||
>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button
|
||||
v-if="isHasAuth('detail')"
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="detail(row)"
|
||||
>查看</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="isHasAuth('edit')"
|
||||
size="small"
|
||||
type="warning"
|
||||
@click="editRowEvent(row)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="isHasAuth('delete')"
|
||||
size="small"
|
||||
type="danger"
|
||||
@click="destroyRowEvent(row)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
|
||||
<el-pagination
|
||||
style="margin-top: 10px; display: flex; justify-content: flex-end"
|
||||
:current-page.sync="select.page"
|
||||
:page-sizes="[20, 30, 40, 50]"
|
||||
:page-size.sync="select.page_size"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
@size-change="
|
||||
(e) => {
|
||||
select.page_size = e;
|
||||
select.page = 1;
|
||||
getList();
|
||||
}
|
||||
"
|
||||
@current-change="
|
||||
(e) => {
|
||||
select.page = e;
|
||||
getList();
|
||||
}
|
||||
"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<AddUser ref="AddUser" :is-show.sync="isShowAdd" @refresh="getList" />
|
||||
<ShowUser ref="ShowUser" :is-show.sync="isShowDetail" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import VxeUI from "vxe-pc-ui";
|
||||
|
||||
import { authMixin } from "@/mixin/authMixin";
|
||||
import { uploadSize } from "@/settings";
|
||||
import { deepCopy } from "@/utils";
|
||||
import { destroy, index, save } from "@/api/user/user";
|
||||
import AddUser from "./components/AddUser.vue";
|
||||
import ShowUser from "./components/ShowUser.vue";
|
||||
import axios from "axios";
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
name: "User",
|
||||
mixins: [authMixin],
|
||||
components: {
|
||||
AddUser,
|
||||
ShowUser,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadSize,
|
||||
examineKey: 0,
|
||||
isShowAdd: false,
|
||||
isShowDetail: false,
|
||||
|
||||
loading: false,
|
||||
tableHeight: 400,
|
||||
select: {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
keyword: "",
|
||||
show_relation: [],
|
||||
},
|
||||
total: 0,
|
||||
allAlign: null,
|
||||
tableData: [],
|
||||
form: {
|
||||
id: "",
|
||||
|
||||
nickname: "",
|
||||
|
||||
openid: "",
|
||||
|
||||
headimgurl: "",
|
||||
|
||||
mobile: "",
|
||||
|
||||
sex: "",
|
||||
|
||||
area: "",
|
||||
|
||||
province: "",
|
||||
|
||||
city: "",
|
||||
|
||||
name: "",
|
||||
|
||||
grade: "",
|
||||
|
||||
middle_exam_year: "",
|
||||
|
||||
nationality: "",
|
||||
|
||||
school: "",
|
||||
},
|
||||
validRules: {
|
||||
mobile: [
|
||||
{
|
||||
required: true,
|
||||
message: "手机号" + "必填",
|
||||
},
|
||||
|
||||
{
|
||||
pattern: /(^$)|(^1[3456789]\d{9})|(^(0\d{2,3}(-)*)?\d{7})$/,
|
||||
message: "手机号" + "验证失败",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isActiveStatus() {
|
||||
return function (row) {
|
||||
if (this.$refs["table"]) {
|
||||
return this.$refs["table"].isEditByRow(row);
|
||||
}
|
||||
};
|
||||
},
|
||||
isHasAuth() {
|
||||
return function (auth) {
|
||||
return this.auths_auth_mixin.indexOf(auth) !== -1;
|
||||
};
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
mounted() {
|
||||
this.bindToolbar();
|
||||
this.calcTableHeight();
|
||||
},
|
||||
methods: {
|
||||
calcTableHeight() {
|
||||
let clientHeight = document.documentElement.clientHeight;
|
||||
let cardTitle = document
|
||||
.querySelector(".el-card__header")
|
||||
?.getBoundingClientRect()?.height;
|
||||
let search = document
|
||||
.querySelector(".vxe-toolbar")
|
||||
?.getBoundingClientRect()?.height;
|
||||
let paginationHeight =
|
||||
(document.querySelector(".el-pagination")?.getBoundingClientRect()
|
||||
?.height ?? 0) + 10; //分页的高度
|
||||
let topHeight = 50; //页面 头部
|
||||
let padding = 80;
|
||||
let margin = 20;
|
||||
this.tableHeight =
|
||||
clientHeight -
|
||||
cardTitle -
|
||||
search -
|
||||
paginationHeight -
|
||||
topHeight -
|
||||
padding -
|
||||
margin;
|
||||
},
|
||||
contextMenuClickEvent({ menu, row, column }) {
|
||||
switch (menu.code) {
|
||||
case "copy":
|
||||
// 示例
|
||||
if (row && column) {
|
||||
if (VxeUI.clipboard.copy(row[column.field])) {
|
||||
this.$message.success("已复制到剪贴板!");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
if (row && column) {
|
||||
this.destroyRowEvent(row);
|
||||
}
|
||||
default:
|
||||
}
|
||||
},
|
||||
async detail(row) {
|
||||
await this.$refs["ShowUser"].getDetail(row.id);
|
||||
this.isShowDetail = true;
|
||||
},
|
||||
|
||||
uploadMethod(file) {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
window.$_uploading = true;
|
||||
return axios
|
||||
.post(process.env.VUE_APP_UPLOAD_API, formData, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${getToken()}`,
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
window.$_uploading = false;
|
||||
if (response.status === 200 && !response.data.code) {
|
||||
return {
|
||||
response: response.data,
|
||||
name: response.data.original_name,
|
||||
url: response.data.url,
|
||||
};
|
||||
} else {
|
||||
this.$message.error("上传失败");
|
||||
}
|
||||
})
|
||||
.catch((_) => {
|
||||
window.$_uploading = false;
|
||||
});
|
||||
},
|
||||
bindToolbar() {
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs["table"] && this.$refs["toolbar"]) {
|
||||
this.$refs["table"].connect(this.$refs["toolbar"]);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
editRowEvent(row) {
|
||||
if (this.$refs["table"]) {
|
||||
this.$refs["table"].setEditRow(row);
|
||||
}
|
||||
},
|
||||
cancelRowEvent(row) {
|
||||
if (this.$refs["table"]) {
|
||||
this.$refs["table"].clearEdit().then(() => {
|
||||
// 还原行数据
|
||||
this.$refs["table"].revertData(row);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async getList() {
|
||||
this.loading = true;
|
||||
try {
|
||||
const res = await index(this.select, false);
|
||||
this.tableData = res.data;
|
||||
this.total = res.total;
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
async saveRowEvent(row) {
|
||||
if (window.$_uploading) {
|
||||
this.$message.warning("文件正在上传中");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const errMap = await this.$refs["table"].validate();
|
||||
if (errMap) {
|
||||
throw new Error(errMap);
|
||||
}
|
||||
await this.$confirm("确认保存?", "提示", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
});
|
||||
await this.$refs["table"].clearEdit();
|
||||
let form = deepCopy(this.form);
|
||||
for (const key in form) {
|
||||
form[key] = row[key];
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
await save(form, false);
|
||||
await this.getList();
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
async destroyRowEvent(row) {
|
||||
try {
|
||||
await this.$confirm("确认删除?", "提示", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
});
|
||||
this.loading = true;
|
||||
if (row.id) {
|
||||
await destroy(
|
||||
{
|
||||
id: row.id,
|
||||
},
|
||||
false
|
||||
);
|
||||
await this.getList();
|
||||
} else {
|
||||
console.log(row);
|
||||
this.tableData.splice(
|
||||
this.tableData.findIndex((i) => i._X_ROW_KEY === row._X_ROW_KEY),
|
||||
1
|
||||
);
|
||||
}
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
::v-deep .el-card__header {
|
||||
padding: 6px 20px;
|
||||
}
|
||||
::v-deep .el-tag + .el-tag {
|
||||
margin-left: 4px;
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,179 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-drawer
|
||||
:title="$route.meta.title"
|
||||
direction="rtl"
|
||||
size="68%"
|
||||
:visible.sync="visible"
|
||||
append-to-body
|
||||
@close="$emit('update:isShow', false)"
|
||||
>
|
||||
<section class="drawer-container">
|
||||
<el-descriptions
|
||||
class="drawer-container__desc"
|
||||
size="small"
|
||||
border
|
||||
ref="elDesc"
|
||||
:column="2"
|
||||
direction="vertical"
|
||||
:labelStyle="{ 'font-weight': '500', 'font-size': '15px' }"
|
||||
>
|
||||
<el-descriptions-item label="昵称">
|
||||
{{ form["nickname"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="openid">
|
||||
{{ form["openid"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="头像地址">
|
||||
{{ form["headimgurl"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="手机号">
|
||||
{{ form["mobile"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="性别">
|
||||
{{
|
||||
[
|
||||
{ value: "男", label: "男" },
|
||||
{ value: "女", label: "女" },
|
||||
{ value: "保密", label: "保密" },
|
||||
].find((i) => i["value"] === form["sex"])
|
||||
? [
|
||||
{ value: "男", label: "男" },
|
||||
{ value: "女", label: "女" },
|
||||
{ value: "保密", label: "保密" },
|
||||
].find((i) => i["value"] === form["sex"])["label"]
|
||||
: ""
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="区县">
|
||||
{{ form["area"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="省份">
|
||||
{{ form["province"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="城市">
|
||||
{{ form["city"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="学生姓名">
|
||||
{{ form["name"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="年级">
|
||||
{{ form["grade"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="中考年份">
|
||||
{{ form["middle_exam_year"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="民族">
|
||||
{{ form["nationality"] }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="学校">
|
||||
{{ form["school"] }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { show } from "@/api/user/user";
|
||||
|
||||
export default {
|
||||
name: "UserShow",
|
||||
props: {
|
||||
isShow: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
visible: false,
|
||||
form: {
|
||||
nickname: "",
|
||||
|
||||
openid: "",
|
||||
|
||||
headimgurl: "",
|
||||
|
||||
mobile: "",
|
||||
|
||||
sex: "",
|
||||
|
||||
area: "",
|
||||
|
||||
province: "",
|
||||
|
||||
city: "",
|
||||
|
||||
name: "",
|
||||
|
||||
grade: "",
|
||||
|
||||
middle_exam_year: "",
|
||||
|
||||
nationality: "",
|
||||
|
||||
school: "",
|
||||
},
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
isShow(newVal) {
|
||||
this.visible = newVal;
|
||||
},
|
||||
visible(newVal) {
|
||||
this.$emit("update:isShow", newVal);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async getDetail(id) {
|
||||
try {
|
||||
const detail = await show({
|
||||
id,
|
||||
});
|
||||
for (let key in this.form) {
|
||||
if (detail.hasOwnProperty(key)) {
|
||||
this.form[key] = detail[key];
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.span2 {
|
||||
grid-column: span 2;
|
||||
}
|
||||
::v-deep .el-form-item > * {
|
||||
max-width: 100%;
|
||||
}
|
||||
.drawer-container {
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
& > * {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in new issue