init project
This commit is contained in:
commit
571ba2a8a1
34 files changed
+3618
No files matched your search
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
// ========================================常用 require start===========================================
|
||||
const Service = require('egg').Service;
|
||||
const validateUtil = require("egg-jianghu/app/common/validateUtil");
|
||||
const idGenerateUtil = require("egg-jianghu/app/common/idGenerateUtil");
|
||||
const dayjs = require("dayjs");
|
||||
const actionDataScheme = Object.freeze({
|
||||
beforHookForGenerateStudentId: {
|
||||
type: "object",
|
||||
additionalProperties: true,
|
||||
required: ["dateOfBirth"],
|
||||
properties: {
|
||||
dateOfBirth: { type: "string", format: "date" },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
class StudentService extends Service {
|
||||
async beforHookForGenerateStudentId() {
|
||||
const { actionData } = this.ctx.request.body.appData;
|
||||
validateUtil.validate(
|
||||
actionDataScheme.beforHookForGenerateStudentId,
|
||||
actionData
|
||||
);
|
||||
const { dateOfBirth } = actionData;
|
||||
const dateOfBirthObj = dayjs(dateOfBirth);
|
||||
const studentId = `S_${idGenerateUtil.uuid(
|
||||
8
|
||||
)}_${dateOfBirthObj.month()}_${dateOfBirthObj.day()}`;
|
||||
this.ctx.request.body.appData.actionData.studentId = studentId;
|
||||
}
|
||||
|
||||
async appendStudentInfoToUserInfo() {
|
||||
const studentInfo = await this.app
|
||||
.jianghuKnex("student")
|
||||
.where({ studentId: this.ctx.userInfo.user.userId })
|
||||
.first();
|
||||
this.ctx.userInfo.studentInfo = studentInfo || { classId: null };
|
||||
}
|
||||
|
||||
async selectStudentList() {
|
||||
const studentInfo = await this.app
|
||||
.jianghuKnex("student")
|
||||
.where({ studentId: this.ctx.userInfo.user.userId })
|
||||
.first();
|
||||
const studentList = await this.app
|
||||
.jianghuKnex("student")
|
||||
.where({ classId: studentInfo.classId })
|
||||
.select();
|
||||
|
||||
return {
|
||||
rows: studentList,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StudentService;
|
||||
@@ -0,0 +1,77 @@
|
||||
<script type="text/x-template" id="classSelectDialog">
|
||||
<span>
|
||||
<v-select class="mr-4" @mouseup="classSelectDialog_shown = true" v-model="classSelectDialog_selected"
|
||||
:items="classSelectDialog_dataList" readonly :label="classSelectDialog_title" hide-details dense
|
||||
outlined hide-no-data hide-selected />
|
||||
<v-dialog v-model="classSelectDialog_shown" scrollable max-width="500px">
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<span>{{ classSelectDialog_title }}</span>
|
||||
<v-text-field
|
||||
label="搜索"
|
||||
clearable
|
||||
dense
|
||||
v-model="classSelectDialog_filterText"
|
||||
hide-details
|
||||
prepend-inner-icon="mdi-text-search"
|
||||
class="ma-2 pa-0"
|
||||
outlined
|
||||
></v-text-field>
|
||||
</v-card-title>
|
||||
<v-divider />
|
||||
<div class="list">
|
||||
<v-list rounded>
|
||||
<v-list-item-group color="primary" active-class>
|
||||
<v-list-item v-for="(item, index) in classSelectDialog_dataList_filter" :key="item.value" @click="selectItem({ item })">
|
||||
<template #default="{ active }">
|
||||
<v-list-item-content>
|
||||
<v-list-item-title v-text="item.text" />
|
||||
</v-list-item-content>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list-item-group>
|
||||
</v-list>
|
||||
</div>
|
||||
<v-divider />
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<v-btn color="primary" text @click="classSelectDialog_shown = false">取消</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</span>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
Vue.component("classSelectDialog", {
|
||||
template: "#classSelectDialog",
|
||||
vueComponent: 'classSelectDialog',
|
||||
mixins: [ window.jianghuUiActionMixins ],
|
||||
data: () => (window.vueData),
|
||||
computed: {
|
||||
classSelectDialog_dataList_filter() {
|
||||
const classSelectDialog_filterText = (this.classSelectDialog_filterText || '').toLowerCase();
|
||||
let list = this.classSelectDialog_dataList.slice();
|
||||
list = list.filter((item) =>
|
||||
item.text &&
|
||||
( item.text.toLowerCase().includes(classSelectDialog_filterText) ||
|
||||
item.text.includes(classSelectDialog_filterText)
|
||||
)
|
||||
)
|
||||
return list;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
selectItem({ item }) {
|
||||
this.classSelectDialog_selected = item.value;
|
||||
this.classSelectDialog_shown = false;
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.list {
|
||||
max-height: 700px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,347 @@
|
||||
{% extends 'template/jhTemplate.html'%}
|
||||
|
||||
{% block vue_template %}
|
||||
|
||||
<jh-layout>
|
||||
|
||||
|
||||
<!-- 页面主要内容 -->
|
||||
<v-container class="fullScreen d-flex flex-column pa-xs-0 pa-0">
|
||||
<v-row class="ma-0 pa-xs-4 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
|
||||
<v-col cols="12" sm="12" md="3" xl="2" class="pa-xs-0 pb-3" :class="{'pb-xs-4': !isMobile}">
|
||||
<v-text-field v-model="serverSearchInput.studentId" label="学生ID" class="cus-v-input " :class="{'mr-2': !isMobile}" dense outlined></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="3" xl="2" class="pa-xs-0 pb-3" :class="{'pb-xs-4': !isMobile, 'mt-2': isMobile}">
|
||||
<v-text-field v-model="serverSearchInput.classId" label="班级ID" class="cus-v-input" :class="{'mr-2': !isMobile}" dense outlined></v-text-field>
|
||||
</v-col>
|
||||
<v-col :class="{'pb-xs-4': !isMobile, 'pt-2': isMobile, 'pl-0': isMobile}" cols="12" md="2" sm="12" xl="3">
|
||||
<v-btn
|
||||
class="elevation-0"
|
||||
color="success"
|
||||
dark
|
||||
@click="refreshTableData"
|
||||
>
|
||||
查询
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-divider></v-divider>
|
||||
<v-row class="ma-0 pa-xs-4 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
|
||||
|
||||
<v-col cols="12" xs="4" sm="4" md="4" xl="4" class="pl-0">
|
||||
<v-btn color="success" small dark class="elevation-0 mr-2" @click="doUiAction('startCreateItem', null)">新增</v-btn>
|
||||
<span class="body-2">共{{ tableData.length }}条记录</span>
|
||||
</v-col>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
|
||||
<v-col cols="12" xs="8" sm="3" md="2" xl="2" class="pa-xs-0 pa-xs-2 col-sm-8-flex pl-0">
|
||||
<v-select class="cus-v-input mr-2" v-model="currentTableGenderType" :items="[{value: 'all', text: '全部'}, ...constantCollection.gender]"
|
||||
prefix="性别:" dense item-text="text" item-value="value" dense outlined></v-select>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" xs="8" sm="4" md="3" xl="3" class="pa-xs-0 pa-xs-2 col-sm-8-flex">
|
||||
<v-text-field v-model="searchInput" label="表格过滤" class="cus-v-input" dense outlined></v-text-field>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
<v-data-table fixed-header
|
||||
:headers="headers"
|
||||
:items="tableData"
|
||||
:search="searchInput"
|
||||
:footer-props="{ itemsPerPageOptions: [20, 40, 60, 100, -1] }"
|
||||
:items-per-page="20"
|
||||
mobile-breakpoint="0"
|
||||
:loading="isTableLoading"
|
||||
checkbox-color="success"
|
||||
class="elevation-0 mt-0 mb-xs-4 flex-fill d-flex flex-column">
|
||||
<template v-slot:item.gender="{ item }">
|
||||
{{ getConstantCollectionItemText('gender', item.gender) }}
|
||||
</template>
|
||||
<template v-slot:item.level="{ item }">
|
||||
{{ getConstantCollectionItemText('level', item.level) }}
|
||||
</template>
|
||||
<template v-slot:item.action="{ item }">
|
||||
<v-btn small class="mr-2 success" @click="doUiAction('startUpdateItem', item)">
|
||||
修改
|
||||
</v-btn>
|
||||
<v-btn small class="mr-2 error" @click="doUiAction('deleteItem', item)">
|
||||
删除
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-container>
|
||||
|
||||
<!-- 编辑抽屉 -->
|
||||
<v-navigation-drawer v-model="isEditDrawerShow" absolute temporary right width="80%" hide-overlay
|
||||
class="elevation-24">
|
||||
<v-form v-model="isFormValid" v-if="isEditDrawerShow" ref="form" lazy-validation>
|
||||
<v-row>
|
||||
<span class="title pa-6">{{ editItem.id ? "修改" : "新增" }}信息</span>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn class="mt-7 mr-8 elevation-0" fab x-small @click="isEditDrawerShow = false">
|
||||
<v-icon dark>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-row>
|
||||
<v-row class="pa-0 ma-0 pa-xs-4 pb-xs-4 flex-none">
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生ID" v-model="editItem.studentId" :rules="requireRules"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="班级ID" v-model="editItem.classId" :items="constantCollection.classId"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生名字" v-model="editItem.name"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="年级" v-model="editItem.level" :items="constantCollection.level"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="性别" v-model="editItem.gender" :items="constantCollection.gender"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-menu class="cus-v-input mr-2" offset-y max-width="290">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined v-on="on" label="出生日期" v-model="editItem.dateOfBirth"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker color="success" elevation="20" v-model="editItem.dateOfBirth"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="身高" v-model="editItem.bodyHeight"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="学生状态" v-model="editItem.studentStatus" :items="constantCollection.studentStatus"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="备注" v-model="editItem.remarks"></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="justify-end pr-6">
|
||||
<v-btn color="success" small @click="doUiAction(dialogSaveInfoAction)" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mb-2': isMobile, 'mr-4': isMobile}">保存</v-btn>
|
||||
<v-btn class="ml-2" small @click="isEditDrawerShow = false" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mr-4': isMobile}">取消</v-btn>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-navigation-drawer>
|
||||
|
||||
</jh-layout>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block vue_body %}
|
||||
<script type="module">
|
||||
window.registerData({
|
||||
// 表格相关数据
|
||||
isFormValid: true,
|
||||
requireRules: [
|
||||
v => !!v || 'This is required',
|
||||
],
|
||||
constantCollection: {
|
||||
gender: [{"value": "male", "text": "男"}, {"value": "female", "text": "女"}],
|
||||
classId: [
|
||||
{"value": "2021-01级-01班", "text": "2021-01级-01班"}, {"value": "2021-01级-02班", "text": "2021-01级-02班"},
|
||||
{"value": "2021-02级-01班", "text": "2021-02级-01班"}, {"value": "2021-02级-02班", "text": "2021-02级-02班"},
|
||||
{"value": "2021-03级-01班", "text": "2021-03级-01班"}, {"value": "2021-03级-02班", "text": "2021-03级-02班"}
|
||||
],
|
||||
level: [{"value": "01", "text": "一年级"}, {"value": "02", "text": "二年级"}, {"value": "03", "text": "三年级"}],
|
||||
icType: [{"value": "身份证", "text": "身份证"}, {"value": "护照", "text": "护照"}],
|
||||
enrollmentType: [{"value": "正常升学", "text": "正常升学"}, {"value": "借读", "text": "借读"}],
|
||||
studentStatus: [{"value": "正常", "text": "正常"}, {"value": "退学", "text": "退学"}]
|
||||
},
|
||||
|
||||
serverSearchInput: {
|
||||
studentId: null,
|
||||
classId: null
|
||||
},
|
||||
currentTableGenderType: 'all',
|
||||
isEditDrawerShow: false,
|
||||
searchInput: null,
|
||||
isTableLoading: true,
|
||||
tableDataFromBackend: [],
|
||||
headers: [
|
||||
{text: "学生ID", value: "studentId", width: 120, class: 'fixed', cellClass: 'fixed'},
|
||||
{text: "班级ID", value: "classId", width: 140},
|
||||
{text: "学生名字", value: "name", width: 120},
|
||||
{text: "年级", value: "level", width: 120},
|
||||
{text: "性别", value: "gender", width: 120},
|
||||
{text: "出生日期", value: "dateOfBirth", width: 120},
|
||||
{text: "身高", value: "bodyHeight", width: 120},
|
||||
{text: "学生状态", value: "studentStatus", width: 120},
|
||||
{text: "备注", value: "remarks", width: 120},
|
||||
{text: "操作者", value: "operationByUser", width: 120},
|
||||
{text: "操作时间", value: "operationAt", width: 250},
|
||||
{text: '操作', value: 'action', align: 'center', sortable: false, width: 200, class: 'fixed', cellClass: 'fixed'},
|
||||
],
|
||||
|
||||
editItem: {},
|
||||
dialogSaveInfoAction: ''
|
||||
})
|
||||
</script>
|
||||
|
||||
{% include 'layout/jhLayout.html' %}
|
||||
{% include 'common/resetTableMaxHeight.html' %}
|
||||
|
||||
<script type="module">
|
||||
new Vue({
|
||||
el: '#app',
|
||||
template: '#app-template',
|
||||
vueComponent: 'page',
|
||||
vuetify: new Vuetify(),
|
||||
mixins: [window.jianghuUiActionMixins],
|
||||
data: () => window.vueData,
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
tableData() {
|
||||
if (!this.currentTableGenderType || this.currentTableGenderType === 'all') {
|
||||
return this.tableDataFromBackend;
|
||||
}
|
||||
return this.tableDataFromBackend.filter(({gender}) => gender === this.currentTableGenderType);
|
||||
},
|
||||
computedEditItem() {
|
||||
return this.editItem;
|
||||
},
|
||||
},
|
||||
watch: {},
|
||||
async created() {
|
||||
},
|
||||
mounted() {
|
||||
this.doUiAction('refreshTableData');
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 获取表格数据
|
||||
*/
|
||||
async refreshTableData() {
|
||||
this.isTableLoading = true;
|
||||
const serverSearchInput = _.pickBy(this.serverSearchInput, value=> !!value);
|
||||
const { data: { appData: { rows } } } = await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'backendSearchDemo',
|
||||
actionId: 'selectItemList',
|
||||
actionData: {},
|
||||
where: {},
|
||||
whereLike: serverSearchInput,
|
||||
orderBy: [{column: 'operationAt', order: 'desc'}]
|
||||
}
|
||||
}
|
||||
});
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'allPage',
|
||||
actionId: 'getConstantList',
|
||||
actionData: {},
|
||||
where: {},
|
||||
}
|
||||
}
|
||||
})
|
||||
this.tableDataFromBackend = rows;
|
||||
this.isTableLoading = false;
|
||||
},
|
||||
|
||||
async clearItemData() {
|
||||
this.editItem = {};
|
||||
},
|
||||
|
||||
// validate
|
||||
prepareValidate() {
|
||||
return this.$refs.form.validate();
|
||||
},
|
||||
|
||||
async openCreateDialog() {
|
||||
this.isEditDrawerShow = true;
|
||||
this.dialogSaveInfoAction = 'createItem';
|
||||
},
|
||||
|
||||
async confirmCreateItemDialog() {
|
||||
return window.confirmDialog({ title: '新增', content: '确定新增吗?'})
|
||||
},
|
||||
|
||||
async doCreateItem() {
|
||||
delete this.computedEditItem.id;
|
||||
await window.vtoast.loading("新增学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'backendSearchDemo',
|
||||
actionId: 'insertItem',
|
||||
actionData: this.computedEditItem
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("新增学生成功");
|
||||
},
|
||||
|
||||
async closeDrawerShow() {
|
||||
this.isEditDrawerShow = false;
|
||||
},
|
||||
|
||||
async prepareItemData(item) {
|
||||
this.editItem = {...item};
|
||||
},
|
||||
|
||||
async openUpdateDialog() {
|
||||
this.isEditDrawerShow = true;
|
||||
this.dialogSaveInfoAction = 'updateItem';
|
||||
},
|
||||
|
||||
async confirmUpdateItemDialog() {
|
||||
return window.confirmDialog({ title: '修改', content: '确定修改吗?'});
|
||||
},
|
||||
|
||||
async doUpdateItem() {
|
||||
const id = this.computedEditItem.id;
|
||||
delete this.computedEditItem.id;
|
||||
await window.vtoast.loading("修改学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'backendSearchDemo',
|
||||
actionId: 'updateItem',
|
||||
actionData: this.computedEditItem,
|
||||
where: {id: id}
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("修改学生成功");
|
||||
this.isEditDrawerShow = false;
|
||||
},
|
||||
|
||||
async confirmDeleteItemDialog() {
|
||||
return window.confirmDialog({ title: '删除', content: '确定删除吗?'});
|
||||
},
|
||||
|
||||
async doDeleteItem() {
|
||||
const { id } = this.computedEditItem;
|
||||
await window.vtoast.loading("删除学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'backendSearchDemo',
|
||||
actionId: 'deleteItem',
|
||||
actionData: {},
|
||||
where: { id: id }
|
||||
}
|
||||
}
|
||||
});
|
||||
await window.vtoast.success("删除学生成功");
|
||||
},
|
||||
|
||||
getConstantCollectionItemText(key, _value) {
|
||||
const constantCollectionItemFind = this.constantCollection[key].find(({value}) => value === _value);
|
||||
if(constantCollectionItemFind) {
|
||||
return constantCollectionItemFind.text;
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,360 @@
|
||||
{% extends 'template/jhTemplate.html'%}
|
||||
|
||||
{% block vue_template %}
|
||||
|
||||
<jh-layout>
|
||||
|
||||
<!-- 页面主要内容 -->
|
||||
<v-container class="fullScreen d-flex flex-column pa-xs-0 pa-0">
|
||||
<div>
|
||||
<span class="red">备注: 需要为当前用户创建一条学生数据, 用户只能看到自己所在班级的数据。</span>
|
||||
</div>
|
||||
<v-row class="ma-0 pa-xs-4 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
|
||||
<v-col cols="12" xs="4" sm="4" md="4" xl="4" class="pl-0">
|
||||
<v-btn color="success" small dark class="elevation-0 mr-2" @click="doUiAction('startCreateItem', null)">新增</v-btn>
|
||||
<span class="body-2">共{{ tableData.length }}条记录</span>
|
||||
</v-col>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
|
||||
<v-select style="max-width: 200px;" class="cus-v-input mr-2" v-model="currentTableGenderType" :items="[{value: 'all', text: '全部'}, ...constantCollection.gender]"
|
||||
prefix="性别:" dense item-text="text" item-value="value" dense outlined></v-select>
|
||||
|
||||
<v-text-field style="max-width: 200px;" v-model="searchInput" label="表格过滤" class="cus-v-input" dense outlined></v-text-field>
|
||||
|
||||
</v-row>
|
||||
<v-data-table fixed-header
|
||||
:headers="headers"
|
||||
:items="tableData"
|
||||
:search="searchInput"
|
||||
:footer-props="{ itemsPerPageOptions: [20, 40, 60, 100, -1] }"
|
||||
:items-per-page="20"
|
||||
mobile-breakpoint="0"
|
||||
:loading="isTableLoading"
|
||||
checkbox-color="success"
|
||||
class="elevation-0 mt-0 mb-xs-4 flex-fill d-flex flex-column">
|
||||
<template v-slot:item.gender="{ item }">
|
||||
{{ getConstantCollectionItemText('gender', item.gender) }}
|
||||
</template>
|
||||
<template v-slot:item.level="{ item }">
|
||||
{{ getConstantCollectionItemText('level', item.level) }}
|
||||
</template>
|
||||
<template v-slot:item.action="{ item }">
|
||||
<v-btn small class="mr-2 success" @click="doUiAction('startUpdateItem', item)">
|
||||
修改
|
||||
</v-btn>
|
||||
<v-btn small class="mr-2 error" @click="doUiAction('deleteItem', item)">
|
||||
删除
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-container>
|
||||
|
||||
<!-- 编辑抽屉 -->
|
||||
<v-navigation-drawer v-model="isEditDrawerShow" absolute temporary right width="80%" hide-overlay
|
||||
class="elevation-24">
|
||||
<v-form v-model="isFormValid" ref="form" lazy-validation>
|
||||
<v-row>
|
||||
<span class="title pa-6">{{ currentClickButton.title }}信息</span>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn class="mt-7 mr-8 elevation-0" fab x-small @click="isEditDrawerShow = false">
|
||||
<v-icon dark>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-row>
|
||||
<v-row class="pa-0 ma-0 pa-xs-4 pb-xs-4 flex-none">
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生ID" v-model="editItem.studentId" :rules="requireRules"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="班级ID" v-model="editItem.classId" :items="constantCollection.classId"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生名字" v-model="editItem.name"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="年级" v-model="editItem.level" :items="constantCollection.level"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="性别" v-model="editItem.gender" :items="constantCollection.gender"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-menu class="cus-v-input mr-2" offset-y max-width="290">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined v-on="on" label="出生日期" v-model="editItem.dateOfBirth"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker color="success" elevation="20" v-model="editItem.dateOfBirth"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="身高" v-model="editItem.bodyHeight"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="学生状态" v-model="editItem.studentStatus" :items="constantCollection.studentStatus"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="备注" v-model="editItem.remarks"></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="justify-end pr-6">
|
||||
<v-btn color="success" small @click="doUiAction(dialogSaveInfoAction)" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mb-2': isMobile, 'mr-4': isMobile}">保存</v-btn>
|
||||
<v-btn class="ml-2" small @click="isEditDrawerShow = false" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mr-4': isMobile}">取消</v-btn>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-navigation-drawer>
|
||||
|
||||
</jh-layout>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block vue_body %}
|
||||
<script type="module">
|
||||
window.registerData({
|
||||
// 表格相关数据
|
||||
isFormValid: true,
|
||||
requireRules: [
|
||||
v => !!v || 'This is required',
|
||||
],
|
||||
constantCollection: {
|
||||
gender: [{"value": "male", "text": "男"}, {"value": "female", "text": "女"}],
|
||||
classId: [
|
||||
{"value": "2021-01级-01班", "text": "2021-01级-01班"}, {"value": "2021-01级-02班", "text": "2021-01级-02班"},
|
||||
{"value": "2021-02级-01班", "text": "2021-02级-01班"}, {"value": "2021-02级-02班", "text": "2021-02级-02班"},
|
||||
{"value": "2021-03级-01班", "text": "2021-03级-01班"}, {"value": "2021-03级-02班", "text": "2021-03级-02班"}
|
||||
],
|
||||
level: [{"value": "01", "text": "一年级"}, {"value": "02", "text": "二年级"}, {"value": "03", "text": "三年级"}],
|
||||
icType: [{"value": "身份证", "text": "身份证"}, {"value": "护照", "text": "护照"}],
|
||||
enrollmentType: [{"value": "正常升学", "text": "正常升学"}, {"value": "借读", "text": "借读"}],
|
||||
studentStatus: [{"value": "正常", "text": "正常"}, {"value": "退学", "text": "退学"}]
|
||||
},
|
||||
currentTableGenderType: 'all',
|
||||
isEditDrawerShow: false,
|
||||
searchInput: null,
|
||||
isTableLoading: true,
|
||||
tableDataFromBackend: [],
|
||||
headers: [
|
||||
{text: "学生ID", value: "studentId", type: "input", width: 120, class: 'fixed', cellClass: 'fixed'},
|
||||
{text: "班级ID", value: "classId", type: "select", width: 140},
|
||||
{text: "学生名字", value: "name", type: "input", width: 120},
|
||||
{text: "年级", value: "level", type: "select", width: 120},
|
||||
{text: "性别", value: "gender", type: "select", width: 120},
|
||||
{text: "出生日期", value: "dateOfBirth", type: "date", width: 120},
|
||||
{text: "身高", value: "bodyHeight", type: "input", width: 120},
|
||||
{text: "学生状态", value: "studentStatus", type: "select", width: 120},
|
||||
{text: "备注", value: "remarks", type: "textarea", width: 120},
|
||||
{text: "操作者", value: "operationByUser", type: "input", width: 120},
|
||||
{text: "操作时间", value: "operationAt", type: "input", width: 250},
|
||||
{text: '操作', value: 'action', type: 'button', align: 'center', sortable: false, width: 200, class: 'fixed', cellClass: 'fixed'},
|
||||
],
|
||||
|
||||
currentClickButton: {title: '新增', action: 'add'},
|
||||
editItem: {},
|
||||
dialogSaveInfoAction: ''
|
||||
})
|
||||
</script>
|
||||
{% include 'layout/jhLayout.html' %}
|
||||
{% include 'common/resetTableMaxHeight.html' %}
|
||||
|
||||
<script type="module">
|
||||
new Vue({
|
||||
el: '#app',
|
||||
template: '#app-template',
|
||||
vueComponent: 'page',
|
||||
vuetify: new Vuetify(),
|
||||
mixins: [window.jianghuUiActionMixins],
|
||||
data: () => ({
|
||||
// 表格相关数据
|
||||
isFormValid: true,
|
||||
requireRules: [
|
||||
v => !!v || 'This is required',
|
||||
],
|
||||
constantCollection: {
|
||||
gender: [{"value": "male", "text": "男"}, {"value": "female", "text": "女"}],
|
||||
classId: [
|
||||
{"value": "2021-01级-01班", "text": "2021-01级-01班"}, {"value": "2021-01级-02班", "text": "2021-01级-02班"},
|
||||
{"value": "2021-02级-01班", "text": "2021-02级-01班"}, {"value": "2021-02级-02班", "text": "2021-02级-02班"},
|
||||
{"value": "2021-03级-01班", "text": "2021-03级-01班"}, {"value": "2021-03级-02班", "text": "2021-03级-02班"}
|
||||
],
|
||||
level: [{"value": "01", "text": "一年级"}, {"value": "02", "text": "二年级"}, {"value": "03", "text": "三年级"}],
|
||||
icType: [{"value": "身份证", "text": "身份证"}, {"value": "护照", "text": "护照"}],
|
||||
enrollmentType: [{"value": "正常升学", "text": "正常升学"}, {"value": "借读", "text": "借读"}],
|
||||
studentStatus: [{"value": "正常", "text": "正常"}, {"value": "退学", "text": "退学"}]
|
||||
},
|
||||
currentTableGenderType: 'all',
|
||||
isEditDrawerShow: false,
|
||||
searchInput: null,
|
||||
isTableLoading: true,
|
||||
tableDataFromBackend: [],
|
||||
headers: [
|
||||
{text: "学生ID", value: "studentId", type: "input", width: 120, class: 'fixed', cellClass: 'fixed'},
|
||||
{text: "班级ID", value: "classId", type: "select", width: 140},
|
||||
{text: "学生名字", value: "name", type: "input", width: 120},
|
||||
{text: "年级", value: "level", type: "select", width: 120},
|
||||
{text: "性别", value: "gender", type: "select", width: 120},
|
||||
{text: "出生日期", value: "dateOfBirth", type: "date", width: 120},
|
||||
{text: "身高", value: "bodyHeight", type: "input", width: 120},
|
||||
{text: "学生状态", value: "studentStatus", type: "select", width: 120},
|
||||
{text: "备注", value: "remarks", type: "textarea", width: 120},
|
||||
{text: "操作者", value: "operationByUser", type: "input", width: 120},
|
||||
{text: "操作时间", value: "operationAt", type: "input", width: 250},
|
||||
{text: '操作', value: 'action', type: 'button', align: 'center', sortable: false, width: 200, class: 'fixed', cellClass: 'fixed'},
|
||||
],
|
||||
|
||||
currentClickButton: {title: '新增', action: 'add'},
|
||||
editItem: {},
|
||||
tableButtonList: [
|
||||
{text: '修改', buttonType: 'edit', color: 'success',},
|
||||
{text: '删除', buttonType: 'delete', color: 'error',},
|
||||
],
|
||||
}),
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
tableData() {
|
||||
if (!this.currentTableGenderType || this.currentTableGenderType === 'all') {
|
||||
return this.tableDataFromBackend;
|
||||
}
|
||||
return this.tableDataFromBackend.filter(({gender}) => gender === this.currentTableGenderType);
|
||||
},
|
||||
computedEditItem() {
|
||||
return this.editItem;
|
||||
},
|
||||
},
|
||||
watch: {},
|
||||
async created() {
|
||||
},
|
||||
mounted() {
|
||||
this.doUiAction('refreshTableData');
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 获取表格数据
|
||||
*/
|
||||
async refreshTableData() {
|
||||
this.isTableLoading = true;
|
||||
const result = await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'dataAccessRight',
|
||||
actionId: 'selectItemListByDynamicData',// 'selectItemListByService', 'selectItemListBySql'
|
||||
actionData: {},
|
||||
where: {},
|
||||
orderBy: [{column: 'operationAt', order: 'desc'}]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.tableDataFromBackend = result.data.appData.rows;
|
||||
this.isTableLoading = false;
|
||||
},
|
||||
|
||||
async clearItemData() {
|
||||
this.editItem = {};
|
||||
},
|
||||
|
||||
async openCreateDialog() {
|
||||
this.currentClickButton = {action: 'add', title: '新增'};
|
||||
this.isEditDrawerShow = true;
|
||||
this.dialogSaveInfoAction = 'createItem';
|
||||
},
|
||||
|
||||
// validate
|
||||
prepareValidate() {
|
||||
return this.$refs.form.validate();
|
||||
},
|
||||
|
||||
async confirmCreateItemDialog() {
|
||||
return window.confirmDialog({ title: '新增', content: '确定新增吗?'});
|
||||
},
|
||||
|
||||
/**
|
||||
* 新增学生
|
||||
*/
|
||||
async doCreateItem() {
|
||||
delete this.computedEditItem.id;
|
||||
await window.vtoast.loading("新增学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'dataAccessRight',
|
||||
actionId: 'insertItem',
|
||||
actionData: this.computedEditItem
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("新增学生成功");
|
||||
this.isEditDrawerShow = false;
|
||||
},
|
||||
|
||||
async closeDrawerShow() {
|
||||
this.isEditDrawerShow = false;
|
||||
},
|
||||
|
||||
async prepareItemData(item) {
|
||||
this.editItem = {...item};
|
||||
},
|
||||
|
||||
async openUpdateDialog() {
|
||||
this.currentClickButton = {action: 'edit', title: '修改'};
|
||||
this.isEditDrawerShow = true;
|
||||
this.dialogSaveInfoAction = 'updateItem';
|
||||
},
|
||||
|
||||
async confirmUpdateItemDialog() {
|
||||
return window.confirmDialog({ title: '修改', content: '确定修改吗?'});
|
||||
},
|
||||
|
||||
/**
|
||||
* 保存学生
|
||||
*/
|
||||
async doUpdateItem() {
|
||||
const id = this.computedEditItem.id;
|
||||
delete this.computedEditItem.id;
|
||||
await window.vtoast.loading("修改学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'dataAccessRight',
|
||||
actionId: 'updateItem',
|
||||
actionData: this.computedEditItem,
|
||||
where: {id: id}
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("修改学生成功");
|
||||
this.isEditDrawerShow = false;
|
||||
},
|
||||
|
||||
async confirmDeleteItemDialog() {
|
||||
return window.confirmDialog({ title: '删除', content: '确定删除吗?'});
|
||||
},
|
||||
|
||||
async doDeleteItem() {
|
||||
const { id } = this.computedEditItem;
|
||||
await window.vtoast.loading("删除学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'backendSearchDemo',
|
||||
actionId: 'deleteItem',
|
||||
actionData: {},
|
||||
where: { id: id }
|
||||
}
|
||||
}
|
||||
});
|
||||
await window.vtoast.success("删除学生成功");
|
||||
},
|
||||
getConstantCollectionItemText(key, _value) {
|
||||
const constantCollectionItemFind = this.constantCollection[key].find(({value}) => value === _value);
|
||||
if(constantCollectionItemFind) {
|
||||
return constantCollectionItemFind.text;
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,358 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>江湖演示-初级</title>
|
||||
<meta charset="utf-8" name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
|
||||
<link href="/xianfeng-v1/public/css/global.css" rel="stylesheet">
|
||||
<link href="/xianfeng-v1/public/css/materialdesignicons.min.css" rel="stylesheet">
|
||||
<link href="/xianfeng-v1/public/css/vuetify.min.css" rel="stylesheet">
|
||||
<link href="/xianfeng-v1/public/css/vuetify.custom.css" rel="stylesheet">
|
||||
<script src="/xianfeng-v1/public/js/lib/axios.min.js"></script>
|
||||
<script src="/xianfeng-v1/public/js/lib/vue.js"></script>
|
||||
<script src="/xianfeng-v1/public/js/lib/vuetify.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
<v-app>
|
||||
<!-- 菜单栏 -->
|
||||
<v-app-bar
|
||||
app
|
||||
color="secondary"
|
||||
clipped-left
|
||||
dark
|
||||
height="55"
|
||||
flat
|
||||
>
|
||||
<v-toolbar-title class="mr-4 align-center" style="font-size: 14px">
|
||||
<span class="title" style="font-size: 1rem!important;">江湖演示-初级</span>
|
||||
</v-toolbar-title>
|
||||
|
||||
<v-tabs
|
||||
v-model="menuSelectedIndex"
|
||||
show-arrows
|
||||
slider-size="5"
|
||||
style="max-width: calc(100vw - 280px)"
|
||||
>
|
||||
<v-tabs-slider color="success"></v-tabs-slider>
|
||||
<template v-for="item in inMenuList">
|
||||
<v-tab
|
||||
class="pl-3 pr-3"
|
||||
:key="item.path"
|
||||
@click="jump({ path: item.path })"
|
||||
>
|
||||
{{ item.title }}
|
||||
</v-tab>
|
||||
</template>
|
||||
</v-tabs>
|
||||
<v-spacer/>
|
||||
|
||||
<!--
|
||||
<div style="white-space: nowrap">
|
||||
<v-btn disabled text class="ml-1 text-none" style="color: #ffffff!important;">
|
||||
admin
|
||||
</v-btn>
|
||||
<v-btn icon small class="ml-1">
|
||||
<v-icon>mdi-account-circle</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
-->
|
||||
</v-app-bar>
|
||||
|
||||
<v-main>
|
||||
|
||||
<!-- 页面主要内容 -->
|
||||
<v-container class="fullScreen d-flex flex-column pa-xs-0 pa-0">
|
||||
<v-row class="ma-0 pa-xs-4 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
|
||||
<v-col cols="12" xs="4" sm="4" md="4" xl="4" class="pl-0">
|
||||
<v-btn color="success" small dark class="elevation-0 mr-2" @click="openEditDialog({ item: {} })">新增</v-btn>
|
||||
<span class="body-2">共{{ tableData.length }}条记录</span>
|
||||
</v-col>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
|
||||
<v-col cols="12" xs="8" sm="3" md="2" xl="2" class="pa-xs-0 pa-xs-2 col-sm-8-flex pl-0">
|
||||
<v-select class="cus-v-input mr-2" v-model="currentTableGenderType" :items="[{value: 'all', text: '全部'}, ...constantCollection.gender]"
|
||||
prefix="性别:" dense item-text="text" item-value="value" dense outlined></v-select>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" xs="8" sm="4" md="3" xl="3" class="pa-xs-0 pa-xs-2 col-sm-8-flex">
|
||||
<v-text-field v-model="searchInput" label="表格过滤" class="cus-v-input" dense outlined></v-text-field>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
<v-data-table fixed-header
|
||||
:headers="headers"
|
||||
:items="tableData"
|
||||
:search="searchInput"
|
||||
:footer-props="{ itemsPerPageOptions: [20, 40, 60, 100, -1] }"
|
||||
:items-per-page="20"
|
||||
mobile-breakpoint="0"
|
||||
:loading="isTableLoading"
|
||||
checkbox-color="success"
|
||||
class="elevation-0 mt-0 mb-xs-4 flex-fill d-flex flex-column">
|
||||
<template v-slot:item.action="{ item }">
|
||||
<v-btn small class="mr-2 success" @click="openEditDialog({ item })">
|
||||
修改
|
||||
</v-btn>
|
||||
<v-btn small class="mr-2 error" @click="deleteStudent({ item })">
|
||||
删除
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-container>
|
||||
|
||||
<!-- 编辑抽屉 -->
|
||||
<v-navigation-drawer v-model="isEditDrawerShow" absolute temporary right width="80%" hide-overlay
|
||||
class="elevation-24">
|
||||
<v-form v-model="isFormValid" v-if="isEditDrawerShow" ref="form" lazy-validation>
|
||||
<v-row>
|
||||
<span class="title pa-6">{{ currentClickButton.title }}信息</span>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn class="mt-7 mr-8 elevation-0" fab x-small @click="isEditDrawerShow = false">
|
||||
<v-icon dark>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-row>
|
||||
<v-row class="pa-0 ma-0 pa-xs-4 pb-xs-4 flex-none">
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生ID" v-model="editItem.studentId" :rules="requireRules"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="班级ID" v-model="editItem.classId" :items="constantCollection.classId"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生名字" v-model="editItem.name"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="年级" v-model="editItem.level" :items="constantCollection.level"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="性别" v-model="editItem.gender" :items="constantCollection.gender"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-menu class="cus-v-input mr-2" offset-y max-width="290">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined v-on="on" label="出生日期" v-model="editItem.dateOfBirth"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker color="success" elevation="20" v-model="editItem.dateOfBirth"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="身高" v-model="editItem.bodyHeight"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="学生状态" v-model="editItem.studentStatus" :items="constantCollection.studentStatus"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="备注" v-model="editItem.remarks"></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="justify-end pr-6">
|
||||
<v-btn v-if="editItem.id" color="success" small @click="updateStudent" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mb-2': isMobile, 'mr-4': isMobile}">修改</v-btn>
|
||||
<v-btn v-if="!editItem.id" color="success" small @click="insertStudent" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mb-2': isMobile, 'mr-4': isMobile}">创建</v-btn>
|
||||
<v-btn class="ml-2" small @click="isEditDrawerShow = false" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mr-4': isMobile}">取消</v-btn>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-navigation-drawer>
|
||||
|
||||
</v-main>
|
||||
</v-app>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
vuetify: new Vuetify(),
|
||||
data: {
|
||||
// 菜单相关数据
|
||||
menuSelectedIndex: 1,
|
||||
inMenuList: [
|
||||
{
|
||||
"path": `/xianfeng-v1/page/manual`,
|
||||
"title": "操作手册",
|
||||
},
|
||||
{
|
||||
"path": `/xianfeng-v1/page/frontendDemo01`,
|
||||
"title": "前端对接-学习",
|
||||
}
|
||||
],
|
||||
|
||||
// 表格相关数据
|
||||
isFormValid: true,
|
||||
requireRules: [
|
||||
v => !!v || 'This is required',
|
||||
],
|
||||
constantCollection: {
|
||||
gender: [{"value": "male", "text": "男"}, {"value": "female", "text": "女"}],
|
||||
classId: [
|
||||
{"value": "2021-01级-01班", "text": "2021-01级-01班"}, {"value": "2021-01级-02班", "text": "2021-01级-02班"},
|
||||
{"value": "2021-02级-01班", "text": "2021-02级-01班"}, {"value": "2021-02级-02班", "text": "2021-02级-02班"},
|
||||
{"value": "2021-03级-01班", "text": "2021-03级-01班"}, {"value": "2021-03级-02班", "text": "2021-03级-02班"}
|
||||
],
|
||||
level: [{"value": "01", "text": "一年级"}, {"value": "02", "text": "二年级"}, {"value": "03", "text": "三年级"}],
|
||||
icType: [{"value": "身份证", "text": "身份证"}, {"value": "护照", "text": "护照"}],
|
||||
enrollmentType: [{"value": "正常升学", "text": "正常升学"}, {"value": "借读", "text": "借读"}],
|
||||
studentStatus: [{"value": "正常", "text": "正常"}, {"value": "退学", "text": "退学"}]
|
||||
},
|
||||
currentTableGenderType: 'all',
|
||||
isEditDrawerShow: false,
|
||||
searchInput: null,
|
||||
isTableLoading: true,
|
||||
tableDataFromBackend: [],
|
||||
headers: [
|
||||
{text: "学生ID", value: "studentId", width: 120, class: 'fixed', cellClass: 'fixed'},
|
||||
{text: "班级ID", value: "classId", width: 140},
|
||||
{text: "学生名字", value: "name", width: 120},
|
||||
{text: "年级", value: "level", width: 120},
|
||||
{text: "性别", value: "gender", width: 120},
|
||||
{text: "出生日期", value: "dateOfBirth", width: 120},
|
||||
{text: "身高", value: "bodyHeight", width: 120},
|
||||
{text: "学生状态", value: "studentStatus", width: 120},
|
||||
{text: "备注", value: "remarks", width: 120},
|
||||
{text: "操作者", value: "operationByUser", width: 120},
|
||||
{text: "操作时间", value: "operationAt", width: 250},
|
||||
{text: '操作', value: 'action', align: 'center', sortable: false, width: 200, class: 'fixed', cellClass: 'fixed'},
|
||||
],
|
||||
|
||||
currentClickButton: {title: '新增', action: 'add'},
|
||||
editItem: {},
|
||||
tableButtonList: [
|
||||
{text: '修改', buttonType: 'edit', color: 'success',},
|
||||
{text: '删除', buttonType: 'delete', color: 'error',},
|
||||
],
|
||||
},
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
tableData() {
|
||||
if (!this.currentTableGenderType || this.currentTableGenderType === 'all') {
|
||||
return this.tableDataFromBackend;
|
||||
}
|
||||
return this.tableDataFromBackend.filter(({gender}) => gender === this.currentTableGenderType);
|
||||
},
|
||||
},
|
||||
watch: {},
|
||||
async created() {
|
||||
await this.getTableData();
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 获取表格数据
|
||||
*/
|
||||
async getTableData() {
|
||||
this.isTableLoading = true;
|
||||
const result = await axios({
|
||||
method: 'post',
|
||||
url: `/xianfeng-v1/resource`,
|
||||
data: {
|
||||
packageId: '123456',
|
||||
packageType: 'httpRequest',
|
||||
appData: {
|
||||
appId: 'xianfeng-v1',
|
||||
pageId: 'frontendDemo01',
|
||||
actionId: 'selectItemList',
|
||||
userAgent: 'demo_userAgent',
|
||||
authToken: localStorage.getItem(`xianfeng-v1_authToken`),
|
||||
actionData: {},
|
||||
where: {},
|
||||
orderBy: [{column: 'operationAt', order: 'desc'}]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.tableDataFromBackend = result.data.appData.rows;
|
||||
this.isTableLoading = false;
|
||||
},
|
||||
openEditDialog({ item }) {
|
||||
this.editItem = item;
|
||||
this.isEditDrawerShow = true;
|
||||
},
|
||||
/**
|
||||
* 删除学生
|
||||
*/
|
||||
async deleteStudent({ item }) {
|
||||
const { id } = item;
|
||||
await axios({
|
||||
method: 'post',
|
||||
url: `/xianfeng-v1/resource`,
|
||||
data: {
|
||||
packageId: '123456',
|
||||
packageType: 'httpRequest',
|
||||
appData: {
|
||||
appId: 'xianfeng-v1',
|
||||
pageId: 'frontendDemo01',
|
||||
actionId: 'deleteItem',
|
||||
userAgent: 'demo_userAgent',
|
||||
authToken: localStorage.getItem(`xianfeng-v1_authToken`),
|
||||
actionData: {},
|
||||
where: { id: id }
|
||||
}
|
||||
}
|
||||
});
|
||||
await this.getTableData();
|
||||
},
|
||||
/**
|
||||
* 新增学生
|
||||
*/
|
||||
async insertStudent() {
|
||||
if (!this.$refs.form.validate()) return false;
|
||||
const { id, ...actionData } = this.editItem;
|
||||
await axios({
|
||||
method: 'post',
|
||||
url: `/xianfeng-v1/resource`,
|
||||
data: {
|
||||
packageId: '123456',
|
||||
packageType: 'httpRequest',
|
||||
appData: {
|
||||
appId: 'xianfeng-v1',
|
||||
pageId: 'frontendDemo01',
|
||||
actionId: 'insertItem',
|
||||
userAgent: 'demo_userAgent',
|
||||
authToken: localStorage.getItem(`xianfeng-v1_authToken`),
|
||||
actionData: actionData
|
||||
}
|
||||
}
|
||||
})
|
||||
this.isEditDrawerShow = false;
|
||||
await this.getTableData();
|
||||
},
|
||||
/**
|
||||
* 保存学生
|
||||
*/
|
||||
async updateStudent() {
|
||||
if (!this.$refs.form.validate()) return false;
|
||||
const { id, ...actionData } = this.editItem;
|
||||
await axios({
|
||||
method: 'post',
|
||||
url: `/xianfeng-v1/resource`,
|
||||
data: {
|
||||
packageId: '123456',
|
||||
packageType: 'httpRequest',
|
||||
appData: {
|
||||
appId: 'xianfeng-v1',
|
||||
pageId: 'frontendDemo01',
|
||||
actionId: 'updateItem',
|
||||
userAgent: 'demo_userAgent',
|
||||
authToken: localStorage.getItem(`xianfeng-v1_authToken`),
|
||||
actionData: actionData,
|
||||
where: {id}
|
||||
}
|
||||
}
|
||||
})
|
||||
this.isEditDrawerShow = false;
|
||||
await this.getTableData();
|
||||
},
|
||||
jump({ path }) {
|
||||
window.location.href = path;
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
@@ -0,0 +1,323 @@
|
||||
{% extends 'template/jhTemplate.html'%}
|
||||
|
||||
{% block vue_template %}
|
||||
|
||||
<jh-layout>
|
||||
|
||||
<!-- 页面主要内容 -->
|
||||
<v-container class="fullScreen d-flex flex-column pa-xs-0 pa-0">
|
||||
<v-row class="ma-0 pa-xs-4 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
|
||||
|
||||
<v-col cols="12" xs="4" sm="4" md="4" xl="4" class="pl-0">
|
||||
<v-btn color="success" small dark class="elevation-0 mr-2" @click="handleTableButton({ text: '新增', buttonType: 'add' }, null)">新增</v-btn>
|
||||
<span class="body-2">共{{ tableData.length }}条记录</span>
|
||||
</v-col>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
|
||||
<v-col cols="12" xs="8" sm="3" md="2" xl="2" class="pa-xs-0 pa-xs-2 col-sm-8-flex pl-0">
|
||||
<v-select class="cus-v-input mr-2" v-model="currentTableGenderType" :items="[{value: 'all', text: '全部'}, ...constantCollection.gender]"
|
||||
prefix="性别:" dense item-text="text" item-value="value" dense outlined></v-select>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" xs="8" sm="4" md="3" xl="3" class="pa-xs-0 pa-xs-2 col-sm-8-flex">
|
||||
<v-text-field v-model="searchInput" label="表格过滤" class="cus-v-input" dense outlined></v-text-field>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
<v-data-table fixed-header
|
||||
:headers="headers"
|
||||
:items="tableData"
|
||||
:search="searchInput"
|
||||
:footer-props="{ itemsPerPageOptions: [20, 40, 60, 100, -1] }"
|
||||
:items-per-page="20"
|
||||
mobile-breakpoint="0"
|
||||
:loading="isTableLoading"
|
||||
checkbox-color="success"
|
||||
class="elevation-0 mt-0 mb-xs-4 flex-fill d-flex flex-column">
|
||||
<template v-slot:item.gender="{ item }">
|
||||
{{ getConstantCollectionItemText('gender', item.gender) }}
|
||||
</template>
|
||||
<template v-slot:item.level="{ item }">
|
||||
{{ getConstantCollectionItemText('level', item.level) }}
|
||||
</template>
|
||||
<template v-slot:item.action="{ item }">
|
||||
<v-btn small class="mr-2" :class="tableButton.color" v-for="tableButton of tableButtonList" @click="handleTableButton(tableButton, item)">
|
||||
{{ tableButton.text }}
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-container>
|
||||
|
||||
<!-- 编辑抽屉 -->
|
||||
<v-navigation-drawer v-model="isEditDrawerShow" absolute temporary right width="80%" hide-overlay
|
||||
class="elevation-24">
|
||||
<v-form v-model="isFormValid" v-if="isEditDrawerShow" ref="form" lazy-validation>
|
||||
<v-row>
|
||||
<span class="title pa-6">{{ currentClickButton.title }}信息</span>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn class="mt-7 mr-8 elevation-0" fab x-small @click="isEditDrawerShow = false">
|
||||
<v-icon dark>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-row>
|
||||
<v-row class="pa-0 ma-0 pa-xs-4 pb-xs-4 flex-none">
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生ID" v-model="editItem.studentId" :rules="requireRules"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="班级ID" v-model="editItem.classId" :items="constantCollection.classId"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生名字" v-model="editItem.name"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="年级" v-model="editItem.level" :items="constantCollection.level"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="性别" v-model="editItem.gender" :items="constantCollection.gender"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-menu class="cus-v-input mr-2" offset-y max-width="290">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined v-on="on" label="出生日期" v-model="editItem.dateOfBirth"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker color="success" elevation="20" v-model="editItem.dateOfBirth"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="身高" v-model="editItem.bodyHeight"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="学生状态" v-model="editItem.studentStatus" :items="constantCollection.studentStatus"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="备注" v-model="editItem.remarks"></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="justify-end pr-6">
|
||||
<v-btn color="success" small @click="saveInfo" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mb-2': isMobile, 'mr-4': isMobile}">保存</v-btn>
|
||||
<v-btn class="ml-2" small @click="isEditDrawerShow = false" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mr-4': isMobile}">取消</v-btn>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-navigation-drawer>
|
||||
|
||||
</jh-layout>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block vue_body %}
|
||||
|
||||
{% include 'layout/jhLayout.html' %}
|
||||
{% include 'common/resetTableMaxHeight.html' %}
|
||||
|
||||
<script type="module">
|
||||
new Vue({
|
||||
el: '#app',
|
||||
template: '#app-template',
|
||||
vuetify: new Vuetify(),
|
||||
data: () => ({
|
||||
// 表格相关数据
|
||||
isFormValid: true,
|
||||
requireRules: [
|
||||
v => !!v || 'This is required',
|
||||
],
|
||||
constantCollection: {
|
||||
gender: [{"value": "male", "text": "男"}, {"value": "female", "text": "女"}],
|
||||
classId: [
|
||||
{"value": "2021-01级-01班", "text": "2021-01级-01班"}, {"value": "2021-01级-02班", "text": "2021-01级-02班"},
|
||||
{"value": "2021-02级-01班", "text": "2021-02级-01班"}, {"value": "2021-02级-02班", "text": "2021-02级-02班"},
|
||||
{"value": "2021-03级-01班", "text": "2021-03级-01班"}, {"value": "2021-03级-02班", "text": "2021-03级-02班"}
|
||||
],
|
||||
level: [{"value": "01", "text": "一年级"}, {"value": "02", "text": "二年级"}, {"value": "03", "text": "三年级"}],
|
||||
icType: [{"value": "身份证", "text": "身份证"}, {"value": "护照", "text": "护照"}],
|
||||
enrollmentType: [{"value": "正常升学", "text": "正常升学"}, {"value": "借读", "text": "借读"}],
|
||||
studentStatus: [{"value": "正常", "text": "正常"}, {"value": "退学", "text": "退学"}]
|
||||
},
|
||||
currentTableGenderType: 'all',
|
||||
isEditDrawerShow: false,
|
||||
searchInput: null,
|
||||
isTableLoading: true,
|
||||
tableDataFromBackend: [],
|
||||
headers: [
|
||||
{text: "学生ID", value: "studentId", width: 120, class: 'fixed', cellClass: 'fixed'},
|
||||
{text: "班级ID", value: "classId", width: 140},
|
||||
{text: "学生名字", value: "name", width: 120},
|
||||
{text: "年级", value: "level", width: 120},
|
||||
{text: "性别", value: "gender", width: 120},
|
||||
{text: "出生日期", value: "dateOfBirth", width: 120},
|
||||
{text: "身高", value: "bodyHeight", width: 120},
|
||||
{text: "学生状态", value: "studentStatus", width: 120},
|
||||
{text: "备注", value: "remarks", width: 120},
|
||||
{text: "操作者", value: "operationByUser", width: 120},
|
||||
{text: "操作时间", value: "operationAt", width: 250},
|
||||
{text: '操作', value: 'action', align: 'center', sortable: false, width: 200, class: 'fixed', cellClass: 'fixed'},
|
||||
],
|
||||
|
||||
currentClickButton: {title: '新增', action: 'add'},
|
||||
editItem: {},
|
||||
tableButtonList: [
|
||||
{text: '修改', buttonType: 'edit', color: 'success',},
|
||||
{text: '删除', buttonType: 'delete', color: 'error',},
|
||||
],
|
||||
}),
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
tableData() {
|
||||
if (!this.currentTableGenderType || this.currentTableGenderType === 'all') {
|
||||
return this.tableDataFromBackend;
|
||||
}
|
||||
return this.tableDataFromBackend.filter(({gender}) => gender === this.currentTableGenderType);
|
||||
},
|
||||
computedEditItem() {
|
||||
return this.editItem;
|
||||
},
|
||||
},
|
||||
watch: {},
|
||||
async created() {
|
||||
await this.getTableData();
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
/**
|
||||
* 获取表格数据
|
||||
*/
|
||||
async getTableData() {
|
||||
this.isTableLoading = true;
|
||||
const result = await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'frontendDemo02',
|
||||
actionId: 'selectItemList',
|
||||
actionData: {},
|
||||
where: {},
|
||||
orderBy: [{column: 'operationAt', order: 'desc'}]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.tableDataFromBackend = result.data.appData.rows;
|
||||
this.isTableLoading = false;
|
||||
},
|
||||
|
||||
// validate
|
||||
prepareValidate() {
|
||||
return this.$refs.form.validate();
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击表格数据按钮
|
||||
*/
|
||||
async handleTableButton(button, item) {
|
||||
const buttonType = button.buttonType;
|
||||
switch (buttonType) {
|
||||
case 'edit':
|
||||
this.currentClickButton = {action: 'edit', title: '修改'};
|
||||
this.editItem = {...item};
|
||||
this.isEditDrawerShow = true;
|
||||
break;
|
||||
case 'add':
|
||||
this.currentClickButton = {action: 'add', title: '新增'};
|
||||
this.editItem = {};
|
||||
this.isEditDrawerShow = true;
|
||||
break;
|
||||
case 'delete':
|
||||
this.editItem = {...item};
|
||||
await this.deleteStudent();
|
||||
break;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 删除学生
|
||||
*/
|
||||
async deleteStudent() {
|
||||
const dialogDone = await window.confirmDialog({ title: '删除', content: '确定删除吗?'});
|
||||
if (!dialogDone) {
|
||||
return false;
|
||||
}
|
||||
const { id } = this.computedEditItem;
|
||||
await window.vtoast.loading("删除学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'frontendDemo02',
|
||||
actionId: 'deleteItem',
|
||||
actionData: {},
|
||||
where: { id: id }
|
||||
}
|
||||
}
|
||||
});
|
||||
await window.vtoast.success("删除学生成功");
|
||||
await this.getTableData();
|
||||
},
|
||||
/**
|
||||
* 保存数据
|
||||
*/
|
||||
async saveInfo() {
|
||||
if (!this.prepareValidate()) return false
|
||||
if (this.currentClickButton.action === 'add') {
|
||||
await this.insertStudent();
|
||||
}
|
||||
if (this.currentClickButton.action === 'edit') {
|
||||
await this.updateStudent();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 新增学生
|
||||
*/
|
||||
async insertStudent() {
|
||||
if (await window.confirmDialog({ title: '新增', content: '确定新增吗?'})) {
|
||||
delete this.computedEditItem.id;
|
||||
await window.vtoast.loading("新增学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'frontendDemo02',
|
||||
actionId: 'insertItem',
|
||||
actionData: this.computedEditItem
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("新增学生成功");
|
||||
this.isEditDrawerShow = false;
|
||||
await this.getTableData();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 保存学生
|
||||
*/
|
||||
async updateStudent() {
|
||||
if (await window.confirmDialog({ title: '修改', content: '确定修改吗?'})) {
|
||||
const id = this.computedEditItem.id;
|
||||
delete this.computedEditItem.id;
|
||||
await window.vtoast.loading("修改学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'frontendDemo02',
|
||||
actionId: 'updateItem',
|
||||
actionData: this.computedEditItem,
|
||||
where: {id: id}
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("修改学生成功");
|
||||
this.isEditDrawerShow = false;
|
||||
await this.getTableData();
|
||||
}
|
||||
},
|
||||
getConstantCollectionItemText(key, _value) {
|
||||
const constantCollectionItemFind = this.constantCollection[key].find(({value}) => value === _value);
|
||||
if(constantCollectionItemFind) {
|
||||
return constantCollectionItemFind.text;
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,135 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>
|
||||
江湖演示-初级-数据传输演示
|
||||
</title>
|
||||
<meta charset="utf-8" name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
|
||||
<script src="/xianfeng-v1/public/js/lib/axios.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
async function insertStudent() {
|
||||
// Tip: studentId不能重复
|
||||
const studentInfo = {
|
||||
studentId: "G00003",
|
||||
bodyHeight: "180",
|
||||
classId: "2021-01级-02班",
|
||||
dateOfBirth: "2022-01-25",
|
||||
gender: "male",
|
||||
level: "02",
|
||||
name: "小虾米",
|
||||
remarks: "小虾米",
|
||||
studentStatus: "正常",
|
||||
}
|
||||
const result = await axios({
|
||||
method: 'post',
|
||||
url: `/xianfeng-v1/resource`,
|
||||
data: {
|
||||
packageId: '123456',
|
||||
packageType: 'httpRequest',
|
||||
appData: {
|
||||
appId: 'xianfeng-v1',
|
||||
pageId: 'protocolDemo',
|
||||
actionId: 'insertItem',
|
||||
userAgent: 'demo_userAgent',
|
||||
authToken: localStorage.getItem(`xianfeng-v1_authToken`),
|
||||
actionData: studentInfo,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('insertStudent', result.data);
|
||||
|
||||
}
|
||||
|
||||
async function selectStudentList() {
|
||||
const result = await axios({
|
||||
method: 'post',
|
||||
url: `/xianfeng-v1/resource`,
|
||||
data: {
|
||||
packageId: '123456',
|
||||
packageType: 'httpRequest',
|
||||
appData: {
|
||||
appId: 'xianfeng-v1',
|
||||
pageId: 'protocolDemo',
|
||||
actionId: 'selectItemList',
|
||||
userAgent: 'demo_userAgent',
|
||||
authToken: localStorage.getItem(`xianfeng-v1_authToken`),
|
||||
actionData: {},
|
||||
where: {},
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('selectStudentList', result.data);
|
||||
}
|
||||
|
||||
async function updateStudent() {
|
||||
const studentInfo = {
|
||||
level: "03",
|
||||
}
|
||||
const result = await axios({
|
||||
method: 'post',
|
||||
url: `/xianfeng-v1/resource`,
|
||||
data: {
|
||||
packageId: '123456',
|
||||
packageType: 'httpRequest',
|
||||
appData: {
|
||||
appId: 'xianfeng-v1',
|
||||
pageId: 'protocolDemo',
|
||||
actionId: 'updateItem',
|
||||
userAgent: 'demo_userAgent',
|
||||
authToken: localStorage.getItem(`xianfeng-v1_authToken`),
|
||||
actionData: studentInfo,
|
||||
where: {
|
||||
studentId: "G00003",
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('updateStudent', result.data);
|
||||
}
|
||||
|
||||
async function deleteStudent() {
|
||||
const result = await axios({
|
||||
method: 'post',
|
||||
url: `/xianfeng-v1/resource`,
|
||||
data: {
|
||||
packageId: '123456',
|
||||
packageType: 'httpRequest',
|
||||
appData: {
|
||||
appId: 'xianfeng-v1',
|
||||
pageId: 'protocolDemo',
|
||||
actionId: 'deleteItem',
|
||||
userAgent: 'demo_userAgent',
|
||||
authToken: localStorage.getItem(`xianfeng-v1_authToken`),
|
||||
actionData: {},
|
||||
where: {
|
||||
studentId: "G00003",
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('deleteStudent', result.data);
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<a href="/">回到首页</a><p/>
|
||||
|
||||
<button onclick="insertStudent()">1. 创建一个学号 "G00003", 姓名 "小虾米" 的二年级学生</button><p/>
|
||||
<button onclick="selectStudentList()">2. 点击获取学生列表,显示在console里</button><p/>
|
||||
<button onclick="updateStudent()">3. 将学生 "G00003" 改为三年级(level = 3)</button><p/>
|
||||
<button onclick="deleteStudent()">4. 删除刚才创建的学生 "G00003"</button><p/>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
@@ -0,0 +1,318 @@
|
||||
{% extends 'template/jhTemplate.html'%}
|
||||
|
||||
{% block vue_template %}
|
||||
|
||||
<jh-layout>
|
||||
|
||||
<!-- 页面主要内容 -->
|
||||
<v-container class="fullScreen d-flex flex-column pa-xs-0 pa-0">
|
||||
<v-row class="ma-0 pa-xs-4 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
|
||||
|
||||
<v-col cols="12" xs="4" sm="4" md="4" xl="4" class="pl-0">
|
||||
<v-btn color="success" small dark class="elevation-0 mr-2" @click="doUiAction('startCreateItem', null)">新增</v-btn>
|
||||
<span class="body-2">共{{ tableData.length }}条记录</span>
|
||||
</v-col>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
|
||||
<v-col cols="12" xs="8" sm="3" md="2" xl="2" class="pa-xs-0 pa-xs-2 col-sm-8-flex pl-0">
|
||||
<v-select class="cus-v-input mr-2" v-model="currentTableGenderType" :items="[{value: 'all', text: '全部'}, ...constantCollection.gender]"
|
||||
prefix="性别:" dense item-text="text" item-value="value" dense outlined></v-select>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" xs="8" sm="4" md="3" xl="3" class="pa-xs-0 pa-xs-2 col-sm-8-flex">
|
||||
<v-text-field v-model="searchInput" label="表格过滤" class="cus-v-input" dense outlined></v-text-field>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
<v-data-table fixed-header
|
||||
:headers="headers"
|
||||
:items="tableData"
|
||||
:search="searchInput"
|
||||
:footer-props="{ itemsPerPageOptions: [20, 40, 60, 100, -1] }"
|
||||
:items-per-page="20"
|
||||
mobile-breakpoint="0"
|
||||
:loading="isTableLoading"
|
||||
checkbox-color="success"
|
||||
class="elevation-0 mt-0 mb-xs-4 flex-fill d-flex flex-column">
|
||||
<template v-slot:item.gender="{ item }">
|
||||
{{ getConstantCollectionItemText('gender', item.gender) }}
|
||||
</template>
|
||||
<template v-slot:item.level="{ item }">
|
||||
{{ getConstantCollectionItemText('level', item.level) }}
|
||||
</template>
|
||||
<template v-slot:item.action="{ item }">
|
||||
<v-btn small class="mr-2 success" @click="doUiAction('startUpdateItem', item)">
|
||||
修改
|
||||
</v-btn>
|
||||
<v-btn small class="mr-2 error" @click="doUiAction('deleteItem', item)">
|
||||
删除
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-container>
|
||||
|
||||
<!-- 编辑抽屉 -->
|
||||
<v-navigation-drawer v-model="isEditDrawerShow" absolute temporary right width="80%" hide-overlay
|
||||
v-click-outside="{ closeConditional: () => !dialogIsOpen(), }"
|
||||
class="elevation-24">
|
||||
<v-form v-model="isFormValid" v-if="isEditDrawerShow" ref="form" lazy-validation>
|
||||
<v-row>
|
||||
<span class="title pa-6">{{ editItem.id ? "修改" : "新增" }}信息</span>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn class="mt-7 mr-8 elevation-0" fab x-small @click="isEditDrawerShow = false">
|
||||
<v-icon dark>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-row>
|
||||
<v-row class="pa-0 ma-0 pa-xs-4 pb-xs-4 flex-none">
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生ID 后端生成" v-model="editItem.studentId"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="班级ID" v-model="editItem.classId" :items="constantCollection.classId" :rules="requireRules"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生名字" v-model="editItem.name" :rules="requireRules"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="年级" v-model="editItem.level" :items="constantCollection.level" :rules="requireRules"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="性别" v-model="editItem.gender" :items="constantCollection.gender" :rules="requireRules"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-menu class="cus-v-input mr-2" offset-y max-width="290">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined v-on="on" label="出生日期" v-model="editItem.dateOfBirth" :rules="requireRules"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker color="success" elevation="20" v-model="editItem.dateOfBirth"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="身高" v-model="editItem.bodyHeight"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="学生状态" v-model="editItem.studentStatus" :items="constantCollection.studentStatus"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="备注" v-model="editItem.remarks"></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="justify-end pr-6">
|
||||
<v-btn color="success" small @click="doUiAction(dialogSaveInfoAction)" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mb-2': isMobile, 'mr-4': isMobile}">保存</v-btn>
|
||||
<v-btn class="ml-2" small @click="isEditDrawerShow = false" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mr-4': isMobile}">取消</v-btn>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-navigation-drawer>
|
||||
|
||||
</jh-layout>
|
||||
|
||||
{% endblock %}
|
||||
{% block vue_body %}
|
||||
|
||||
<script type="module">
|
||||
window.registerData({
|
||||
// 表格相关数据
|
||||
isFormValid: true,
|
||||
requireRules: [
|
||||
v => !!v || 'This is required',
|
||||
],
|
||||
constantCollection: {
|
||||
gender: [{"value": "male", "text": "男"}, {"value": "female", "text": "女"}],
|
||||
classId: [
|
||||
{"value": "2021-01级-01班", "text": "2021-01级-01班"}, {"value": "2021-01级-02班", "text": "2021-01级-02班"},
|
||||
{"value": "2021-02级-01班", "text": "2021-02级-01班"}, {"value": "2021-02级-02班", "text": "2021-02级-02班"},
|
||||
{"value": "2021-03级-01班", "text": "2021-03级-01班"}, {"value": "2021-03级-02班", "text": "2021-03级-02班"}
|
||||
],
|
||||
level: [{"value": "01", "text": "一年级"}, {"value": "02", "text": "二年级"}, {"value": "03", "text": "三年级"}],
|
||||
icType: [{"value": "身份证", "text": "身份证"}, {"value": "护照", "text": "护照"}],
|
||||
enrollmentType: [{"value": "正常升学", "text": "正常升学"}, {"value": "借读", "text": "借读"}],
|
||||
studentStatus: [{"value": "正常", "text": "正常"}, {"value": "退学", "text": "退学"}]
|
||||
},
|
||||
currentTableGenderType: 'all',
|
||||
isEditDrawerShow: false,
|
||||
searchInput: null,
|
||||
isTableLoading: true,
|
||||
tableDataFromBackend: [],
|
||||
headers: [
|
||||
{text: "学生ID", value: "studentId", width: 120, class: 'fixed', cellClass: 'fixed'},
|
||||
{text: "班级ID", value: "classId", width: 140},
|
||||
{text: "学生名字", value: "name", width: 120},
|
||||
{text: "年级", value: "level", width: 120},
|
||||
{text: "性别", value: "gender", width: 120},
|
||||
{text: "出生日期", value: "dateOfBirth", width: 120},
|
||||
{text: "身高", value: "bodyHeight", width: 120},
|
||||
{text: "学生状态", value: "studentStatus", width: 120},
|
||||
{text: "备注", value: "remarks", width: 120},
|
||||
{text: "操作者", value: "operationByUser", width: 120},
|
||||
{text: "操作时间", value: "operationAt", width: 250},
|
||||
{text: '操作', value: 'action', align: 'center', sortable: false, width: 200, class: 'fixed', cellClass: 'fixed'},
|
||||
],
|
||||
editItem: {},
|
||||
})
|
||||
</script>
|
||||
{% include 'layout/jhLayout.html' %}
|
||||
{% include 'common/resetTableMaxHeight.html' %}
|
||||
|
||||
<script type="module">
|
||||
new Vue({
|
||||
el: '#app',
|
||||
template: '#app-template',
|
||||
vueComponent: 'page',
|
||||
vuetify: new Vuetify(),
|
||||
mixins: [window.jianghuUiActionMixins],
|
||||
data: () => window.vueData,
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
tableData() {
|
||||
if (!this.currentTableGenderType || this.currentTableGenderType === 'all') {
|
||||
return this.tableDataFromBackend;
|
||||
}
|
||||
return this.tableDataFromBackend.filter(({gender}) => gender === this.currentTableGenderType);
|
||||
},
|
||||
computedEditItem() {
|
||||
return this.editItem;
|
||||
},
|
||||
},
|
||||
watch: {},
|
||||
mounted() {
|
||||
this.doUiAction('refreshTableData')
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 获取表格数据
|
||||
*/
|
||||
async refreshTableData() {
|
||||
this.isTableLoading = true;
|
||||
const result = await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'resourceHook',
|
||||
actionId: 'selectItemList',
|
||||
actionData: {},
|
||||
where: {},
|
||||
orderBy: [{column: 'operationAt', order: 'desc'}]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.tableDataFromBackend = result.data.appData.rows;
|
||||
this.isTableLoading = false;
|
||||
},
|
||||
|
||||
async clearItemData() {
|
||||
this.editItem = {};
|
||||
},
|
||||
|
||||
async openCreateDialog() {
|
||||
this.isEditDrawerShow = true;
|
||||
this.dialogSaveInfoAction = "createItem";
|
||||
},
|
||||
|
||||
// createItem
|
||||
async confirmCreateItemDialog() {
|
||||
return await window.confirmDialog({ title: "新增", content: "确定新增吗?" });
|
||||
},
|
||||
|
||||
/**
|
||||
* 新增学生
|
||||
*/
|
||||
async doCreateItem() {
|
||||
delete this.computedEditItem.id;
|
||||
await window.vtoast.loading("新增学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'resourceHook',
|
||||
actionId: 'insertItem',
|
||||
actionData: this.computedEditItem
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("新增学生成功");
|
||||
},
|
||||
|
||||
// createItem/updateItem
|
||||
async closeDrawerShow() {
|
||||
this.isEditDrawerShow = false;
|
||||
},
|
||||
|
||||
async prepareItemData(item) {
|
||||
this.editItem = {...item};
|
||||
},
|
||||
|
||||
async openUpdateDialog() {
|
||||
this.isEditDrawerShow = true;
|
||||
this.dialogSaveInfoAction = "updateItem";
|
||||
},
|
||||
|
||||
// validate
|
||||
prepareValidate() {
|
||||
return this.$refs.form.validate();
|
||||
},
|
||||
|
||||
// createItem
|
||||
async confirmUpdateItemDialog() {
|
||||
return await window.confirmDialog({ title: "修改", content: "确定修改吗?" });
|
||||
},
|
||||
|
||||
/**
|
||||
* 新增学生
|
||||
*/
|
||||
async doUpdateItem() {
|
||||
const id = this.computedEditItem.id;
|
||||
delete this.computedEditItem.id;
|
||||
await window.vtoast.loading("修改学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'resourceHook',
|
||||
actionId: 'updateItem',
|
||||
actionData: this.computedEditItem,
|
||||
where: {id: id}
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("修改学生成功");
|
||||
},
|
||||
|
||||
async confirmDeleteItemDialog() {
|
||||
await window.confirmDialog({ title: '删除', content: '确定删除吗?'});
|
||||
},
|
||||
/**
|
||||
* 删除学生
|
||||
*/
|
||||
async doDeleteItem() {
|
||||
const { id } = this.computedEditItem;
|
||||
await window.vtoast.loading("删除学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'resourceHook',
|
||||
actionId: 'deleteItem',
|
||||
actionData: {},
|
||||
where: { id: id }
|
||||
}
|
||||
}
|
||||
});
|
||||
await window.vtoast.success("删除学生成功");
|
||||
},
|
||||
getConstantCollectionItemText(key, _value) {
|
||||
const constantCollectionItemFind = this.constantCollection[key].find(({value}) => value === _value);
|
||||
if(constantCollectionItemFind) {
|
||||
return constantCollectionItemFind.text;
|
||||
}
|
||||
return _value;
|
||||
},
|
||||
dialogIsOpen() {
|
||||
return window.dialogIsOpen;
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,332 @@
|
||||
{% extends 'template/jhTemplate.html'%}
|
||||
|
||||
{% block vue_template %}
|
||||
|
||||
<jh-layout>
|
||||
|
||||
<!-- 页面主要内容 -->
|
||||
<v-container class="fullScreen d-flex flex-column pa-xs-0 pa-0">
|
||||
<v-row class="ma-0 pa-xs-4 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
|
||||
|
||||
<v-col cols="12" xs="4" sm="4" md="4" xl="4" class="pl-0">
|
||||
<v-btn color="success" small dark class="elevation-0 mr-2" @click="doUiAction('startInsertItem')">新增</v-btn>
|
||||
<span class="body-2">共{{ tableDataFromBackend.length }}条记录</span>
|
||||
</v-col>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
|
||||
<v-col cols="12" xs="8" sm="4" md="3" xl="3" class="pa-xs-0 pa-xs-2 col-sm-8-flex">
|
||||
<v-text-field v-model="searchInput" label="表格过滤" class="cus-v-input" dense outlined></v-text-field>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
<v-data-table
|
||||
fixed-header
|
||||
:headers="headers"
|
||||
:items="tableDataFromBackend"
|
||||
:search="searchInput"
|
||||
:footer-props="{ itemsPerPageOptions: [20, 40, 60, 100, -1] }"
|
||||
:items-per-page="20"
|
||||
mobile-breakpoint="0"
|
||||
:loading="isTableLoading"
|
||||
checkbox-color="success"
|
||||
class="elevation-0 mt-0 mb-xs-4 flex-fill d-flex flex-column">
|
||||
|
||||
<template v-slot:item.action="{ item }">
|
||||
<v-btn small class="mr-2 success" @click="doUiAction('startUpdateItem', {item})">
|
||||
修改
|
||||
</v-btn>
|
||||
<v-btn small class="mr-2 error" @click="doUiAction('deleteItem', {item})">
|
||||
删除
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-container>
|
||||
|
||||
<v-navigation-drawer v-model="isCreateDrawerShow" absolute temporary right width="80%" hide-overlay
|
||||
v-click-outside="{ closeConditional: () => !dialogIsOpen(), }"
|
||||
class="elevation-24">
|
||||
<v-form v-model="isFormValid" v-if="isCreateDrawerShow" ref="form" lazy-validation>
|
||||
<v-row>
|
||||
<span class="title pa-6">新增</span>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn class="mt-7 mr-8 elevation-0" fab x-small @click="isCreateDrawerShow = false">
|
||||
<v-icon dark>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-row>
|
||||
<v-row class="pa-0 ma-0 pa-xs-4 pb-xs-4 flex-none">
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生ID" v-model="createItem.studentId" :rules="requireRules"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="班级ID" v-model="createItem.classId"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生名字" v-model="createItem.name"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="年级" v-model="createItem.level"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="性别" v-model="createItem.gender"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-menu class="cus-v-input mr-2" offset-y max-width="290">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined v-on="on" label="出生日期" v-model="createItem.dateOfBirth"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker color="success" elevation="20" v-model="createItem.dateOfBirth"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="身高" v-model="createItem.bodyHeight"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生状态" v-model="createItem.studentStatus"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="备注" v-model="createItem.remarks"></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="justify-end pr-6">
|
||||
<v-btn class="ml-2 success" small @click="doUiAction('createItem')" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mb-2': isMobile, 'mr-4': isMobile}">新增</v-btn>
|
||||
<v-btn class="ml-2" small @click="isCreateDrawerShow = false" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mr-4': isMobile}">取消</v-btn>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-navigation-drawer>
|
||||
|
||||
<v-navigation-drawer v-model="isUpdateDrawerShow" absolute temporary right width="80%" hide-overlay
|
||||
v-click-outside="{ closeConditional: () => !dialogIsOpen(), }"
|
||||
class="elevation-24">
|
||||
<v-form v-model="isFormValid" v-if="isUpdateDrawerShow" ref="form" lazy-validation>
|
||||
<v-row>
|
||||
<span class="title pa-6">修改</span>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn class="mt-7 mr-8 elevation-0" fab x-small @click="isUpdateDrawerShow = false">
|
||||
<v-icon dark>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-row>
|
||||
<v-row class="pa-0 ma-0 pa-xs-4 pb-xs-4 flex-none">
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生ID" disabled v-model="updateItem.studentId" :rules="requireRules"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="班级ID" v-model="updateItem.classId"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生名字" v-model="updateItem.name"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="年级" v-model="updateItem.level"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="性别" v-model="updateItem.gender"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-menu class="cus-v-input mr-2" offset-y max-width="290">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined v-on="on" label="出生日期" v-model="updateItem.dateOfBirth"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker color="success" elevation="20" v-model="updateItem.dateOfBirth"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="身高" v-model="updateItem.bodyHeight"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生状态" v-model="updateItem.studentStatus"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="备注" v-model="updateItem.remarks"></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="justify-end pr-6">
|
||||
<v-btn class="ml-2 success" color="success" small @click="doUiAction('updateItem')" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mb-2': isMobile, 'mr-4': isMobile}">修改</v-btn>
|
||||
<v-btn class="ml-2" small @click="isUpdateDrawerShow = false" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mr-4': isMobile}">取消</v-btn>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-navigation-drawer>
|
||||
|
||||
</jh-layout>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block vue_body %}
|
||||
{% include 'layout/jhLayout.html' %}
|
||||
{% include 'common/resetTableMaxHeight.html' %}
|
||||
|
||||
<script type="module">
|
||||
new Vue({
|
||||
el: '#app',
|
||||
template: '#app-template',
|
||||
vueComponent: 'page',
|
||||
vuetify: new Vuetify(),
|
||||
mixins: [window.jianghuUiActionMixins],
|
||||
data: {
|
||||
// 表格相关数据
|
||||
isFormValid: true,
|
||||
requireRules: [
|
||||
v => !!v || 'This is required',
|
||||
],
|
||||
searchInput: null,
|
||||
isTableLoading: true,
|
||||
tableDataFromBackend: [],
|
||||
headers: [
|
||||
{text: "学生ID", value: "studentId", width: 120, class: 'fixed', cellClass: 'fixed'},
|
||||
{text: "班级ID", value: "classId", width: 140},
|
||||
{text: "学生名字", value: "name", width: 120},
|
||||
{text: "年级", value: "level", width: 120},
|
||||
{text: "性别", value: "gender", width: 120},
|
||||
{text: "出生日期", value: "dateOfBirth", width: 120},
|
||||
{text: "身高", value: "bodyHeight", width: 120},
|
||||
{text: "学生状态", value: "studentStatus", width: 120},
|
||||
{text: "备注", value: "remarks", width: 120},
|
||||
{text: "操作者", value: "operationByUser", width: 120},
|
||||
{text: "操作时间", value: "operationAt", width: 250},
|
||||
{text: '操作', value: 'action', align: 'center', sortable: false, width: 200, class: 'fixed', cellClass: 'fixed'},
|
||||
],
|
||||
|
||||
isCreateDrawerShow: false,
|
||||
createItem: {},
|
||||
isUpdateDrawerShow: false,
|
||||
updateItem: {},
|
||||
},
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
},
|
||||
watch: {},
|
||||
mounted() {
|
||||
this.doUiAction('refreshTableData');
|
||||
},
|
||||
methods: {
|
||||
|
||||
async refreshTableData() {
|
||||
this.isTableLoading = true;
|
||||
const result = await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'uiAction',
|
||||
actionId: 'selectItemList',
|
||||
actionData: {},
|
||||
where: {},
|
||||
orderBy: [{column: 'operationAt', order: 'desc'}]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.tableDataFromBackend = result.data.appData.rows;
|
||||
this.isTableLoading = false;
|
||||
},
|
||||
|
||||
|
||||
// ====================================Create Start===========================================
|
||||
async clearCreateForm() {
|
||||
this.createItem = {};
|
||||
},
|
||||
// validate
|
||||
prepareValidate() {
|
||||
return this.$refs.form.validate();
|
||||
},
|
||||
async openCreateDrawer() {
|
||||
this.isCreateDrawerShow = true;
|
||||
},
|
||||
async prepareCreateItem() {
|
||||
delete this.createItem.id;
|
||||
},
|
||||
async confirmCreateFormDialog() {
|
||||
// retrun false 会中断后面的 uiAction function
|
||||
return await window.confirmDialog({ title: "新增", content: "确定新增吗?" });
|
||||
},
|
||||
async doCreateItem() {
|
||||
await window.vtoast.loading("新增学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'uiAction',
|
||||
actionId: 'createItem',
|
||||
actionData: this.createItem
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("新增学生成功");
|
||||
},
|
||||
async closeCreateDrawer() {
|
||||
this.isCreateDrawerShow = false;
|
||||
},
|
||||
// ====================================Create End===========================================
|
||||
|
||||
|
||||
// ====================================Update Start===========================================
|
||||
async fillUpdateForm({ item }) {
|
||||
this.updateItem = _.clone(item);
|
||||
},
|
||||
async openUpdateDrawer() {
|
||||
this.isUpdateDrawerShow = true;
|
||||
},
|
||||
async prepareUpdateItem() {
|
||||
// TODO: 对this.updateItem做一些数据处理
|
||||
},
|
||||
async confirmUpdateItemDialog() {
|
||||
// retrun false 会中断后面的 uiAction function
|
||||
return await window.confirmDialog({ title: "修改", content: "确定修改吗?" });
|
||||
},
|
||||
async doUpdateItem() {
|
||||
const {id, ...actionData} = this.updateItem;
|
||||
await window.vtoast.loading("修改学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'uiAction',
|
||||
actionId: 'updateItem',
|
||||
actionData: actionData,
|
||||
where: {id}
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("修改学生成功");
|
||||
},
|
||||
async closeUpdateDrawer() {
|
||||
this.isUpdateDrawerShow = false;
|
||||
},
|
||||
// ====================================Update End===========================================
|
||||
|
||||
|
||||
|
||||
// ====================================Create Start===========================================
|
||||
async confirmDeleteItemDialog({ item }) {
|
||||
if (!item || !item.id) {
|
||||
window.vtoast.fail("数据异常");
|
||||
return
|
||||
}
|
||||
return await window.confirmDialog({ title: "删除", content: "确定删除吗?" });
|
||||
},
|
||||
async doDeleteItem({ item }) {
|
||||
const { id } = item;
|
||||
await window.vtoast.loading("删除学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'uiAction',
|
||||
actionId: 'deleteItem',
|
||||
actionData: {},
|
||||
where: { id }
|
||||
}
|
||||
}
|
||||
});
|
||||
await window.vtoast.success("删除学生成功");
|
||||
},
|
||||
// ====================================Update End===========================================
|
||||
|
||||
|
||||
dialogIsOpen() {
|
||||
return window.dialogIsOpen;
|
||||
},
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,327 @@
|
||||
{% extends 'template/jhTemplate.html'%}
|
||||
|
||||
{% block vue_template %}
|
||||
|
||||
<jh-layout>
|
||||
|
||||
<!-- 页面主要内容 -->
|
||||
<v-container class="fullScreen d-flex flex-column pa-xs-0 pa-0">
|
||||
<v-row class="ma-0 pa-xs-4 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
|
||||
|
||||
<v-col cols="12" xs="4" sm="4" md="4" xl="4" class="pl-0">
|
||||
<v-btn color="success" small dark class="elevation-0 mr-2" @click="doUiAction('startCreateItem')">新增</v-btn>
|
||||
<span class="body-2">共{{ tableData.length }}条记录</span>
|
||||
</v-col>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
|
||||
|
||||
|
||||
<v-col cols="12" xs="8" sm="3" md="2" xl="2" class="pa-xs-0 pa-xs-2 col-sm-8-flex pl-0">
|
||||
<classSelectDialog />
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" xs="8" sm="3" md="2" xl="2" class="pa-xs-0 pa-xs-2 col-sm-8-flex pl-0">
|
||||
<v-select class="cus-v-input mr-2" v-model="currentTableGenderType" :items="[{value: 'all', text: '全部'}, ...constantCollection.gender]"
|
||||
prefix="性别:" dense item-text="text" item-value="value" dense outlined></v-select>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" xs="8" sm="4" md="3" xl="3" class="pa-xs-0 pa-xs-2 col-sm-8-flex">
|
||||
<v-text-field v-model="searchInput" label="表格过滤" class="cus-v-input" dense outlined></v-text-field>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
<v-data-table
|
||||
fixed-header
|
||||
:headers="headers"
|
||||
:items="tableData"
|
||||
:search="searchInput"
|
||||
:footer-props="{ itemsPerPageOptions: [20, 40, 60, 100, -1] }"
|
||||
:items-per-page="20"
|
||||
mobile-breakpoint="0"
|
||||
:loading="isTableLoading"
|
||||
checkbox-color="success"
|
||||
class="elevation-0 mt-0 mb-xs-4 flex-fill d-flex flex-column">
|
||||
|
||||
<template v-slot:item.gender="{ item }">
|
||||
{{ getConstantCollectionItemText('gender', item.gender) }}
|
||||
</template>
|
||||
<template v-slot:item.level="{ item }">
|
||||
{{ getConstantCollectionItemText('level', item.level) }}
|
||||
</template>
|
||||
<template v-slot:item.action="{ item }">
|
||||
<v-btn small class="mr-2 success" @click="doUiAction('startUpdateItem', {item})">
|
||||
修改
|
||||
</v-btn>
|
||||
<v-btn small class="mr-2 error" @click="doUiAction('deleteItem', {item})">
|
||||
删除
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-container>
|
||||
|
||||
<!-- 编辑抽屉 -->
|
||||
<v-navigation-drawer v-model="isEditDrawerShow" absolute temporary right width="80%" hide-overlay
|
||||
v-click-outside="{ closeConditional: () => !dialogIsOpen(), }"
|
||||
class="elevation-24">
|
||||
<v-form v-model="isFormValid" v-if="isEditDrawerShow" ref="form" lazy-validation>
|
||||
<v-row>
|
||||
<span class="title pa-6">{{ editItem.id ? "修改" : "新增" }}信息</span>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn class="mt-7 mr-8 elevation-0" fab x-small @click="isEditDrawerShow = false">
|
||||
<v-icon dark>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-row>
|
||||
<v-row class="pa-0 ma-0 pa-xs-4 pb-xs-4 flex-none">
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生ID" v-model="editItem.studentId" :rules="requireRules"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="班级ID" v-model="editItem.classId" :items="constantCollection.classId"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="学生名字" v-model="editItem.name"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="年级" v-model="editItem.level" :items="constantCollection.level"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="性别" v-model="editItem.gender" :items="constantCollection.gender"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-menu class="cus-v-input mr-2" offset-y max-width="290">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined v-on="on" label="出生日期" v-model="editItem.dateOfBirth"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker color="success" elevation="20" v-model="editItem.dateOfBirth"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="身高" v-model="editItem.bodyHeight"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-select class="cus-v-input mr-2" dense outlined clearable label="学生状态" v-model="editItem.studentStatus" :items="constantCollection.studentStatus"></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4" xl="3" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="备注" v-model="editItem.remarks"></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="justify-end pr-6">
|
||||
<v-btn v-if="editItem.id" color="success" small @click="doUiAction('updateItem')" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mb-2': isMobile, 'mr-4': isMobile}">修改</v-btn>
|
||||
<v-btn v-if="!editItem.id" small @click="doUiAction('insertItem')" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mb-2': isMobile, 'mr-4': isMobile}">创建</v-btn>
|
||||
<v-btn class="ml-2" small @click="isEditDrawerShow = false" :style="{width: isMobile ? 'calc(100% - 45px)' : '200px'}" :class="{'mr-4': isMobile}">取消</v-btn>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-navigation-drawer>
|
||||
|
||||
</jh-layout>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block vue_body %}
|
||||
|
||||
<script>
|
||||
window.registerData({
|
||||
// 组件的 数据
|
||||
classSelectDialog_shown: false,
|
||||
classSelectDialog_title: "班级",
|
||||
classSelectDialog_selected: null,
|
||||
classSelectDialog_filterText: null,
|
||||
classSelectDialog_dataList: [
|
||||
{ value: "2021-01级-01班", text: "2021-01级-01班" },
|
||||
{ value: "2021-01级-02班", text: "2021-01级-02班" },
|
||||
{ value: "2021-02级-01班", text: "2021-02级-01班" },
|
||||
{ value: "2021-02级-02班", text: "2021-02级-02班" },
|
||||
{ value: "2021-03级-01班", text: "2021-03级-01班" },
|
||||
{ value: "2021-03级-02班", text: "2021-03级-02班" },
|
||||
],
|
||||
|
||||
// page的 数据
|
||||
isFormValid: true,
|
||||
requireRules: [
|
||||
v => !!v || 'This is required',
|
||||
],
|
||||
constantCollection: {
|
||||
gender: [{"value": "male", "text": "男"}, {"value": "female", "text": "女"}],
|
||||
classId: [
|
||||
{"value": "2021-01级-01班", "text": "2021-01级-01班"}, {"value": "2021-01级-02班", "text": "2021-01级-02班"},
|
||||
{"value": "2021-02级-01班", "text": "2021-02级-01班"}, {"value": "2021-02级-02班", "text": "2021-02级-02班"},
|
||||
{"value": "2021-03级-01班", "text": "2021-03级-01班"}, {"value": "2021-03级-02班", "text": "2021-03级-02班"}
|
||||
],
|
||||
level: [{"value": "01", "text": "一年级"}, {"value": "02", "text": "二年级"}, {"value": "03", "text": "三年级"}],
|
||||
icType: [{"value": "身份证", "text": "身份证"}, {"value": "护照", "text": "护照"}],
|
||||
enrollmentType: [{"value": "正常升学", "text": "正常升学"}, {"value": "借读", "text": "借读"}],
|
||||
studentStatus: [{"value": "正常", "text": "正常"}, {"value": "退学", "text": "退学"}]
|
||||
},
|
||||
currentTableGenderType: 'all',
|
||||
isEditDrawerShow: false,
|
||||
searchInput: null,
|
||||
isTableLoading: true,
|
||||
tableDataFromBackend: [],
|
||||
headers: [
|
||||
{text: "学生ID", value: "studentId", width: 120, class: 'fixed', cellClass: 'fixed'},
|
||||
{text: "班级ID", value: "classId", width: 140},
|
||||
{text: "学生名字", value: "name", width: 120},
|
||||
{text: "年级", value: "level", width: 120},
|
||||
{text: "性别", value: "gender", width: 120},
|
||||
{text: "出生日期", value: "dateOfBirth", width: 120},
|
||||
{text: "身高", value: "bodyHeight", width: 120},
|
||||
{text: "学生状态", value: "studentStatus", width: 120},
|
||||
{text: "备注", value: "remarks", width: 120},
|
||||
{text: "操作者", value: "operationByUser", width: 120},
|
||||
{text: "操作时间", value: "operationAt", width: 250},
|
||||
{text: '操作', value: 'action', align: 'center', sortable: false, width: 200, class: 'fixed', cellClass: 'fixed'},
|
||||
],
|
||||
|
||||
editItem: {},
|
||||
})
|
||||
</script>
|
||||
{% include 'layout/jhLayout.html' %}
|
||||
{% include 'common/resetTableMaxHeight.html' %}
|
||||
{% include 'component/classSelectDialog.html' %}
|
||||
|
||||
<script type="module">
|
||||
new Vue({
|
||||
el: '#app',
|
||||
template: '#app-template',
|
||||
vueComponent: 'page',
|
||||
vuetify: new Vuetify(),
|
||||
mixins: [window.jianghuUiActionMixins],
|
||||
data: window.vueData,
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
tableData() {
|
||||
let dataList = this.tableDataFromBackend;
|
||||
if (this.currentTableGenderType && this.currentTableGenderType !== 'all') {
|
||||
dataList = dataList.filter(({gender}) => gender === this.currentTableGenderType);
|
||||
}
|
||||
if (this.classSelectDialog_selected) {
|
||||
dataList = dataList.filter(({classId}) => classId === this.classSelectDialog_selected);
|
||||
}
|
||||
return dataList;
|
||||
},
|
||||
},
|
||||
watch: {},
|
||||
mounted() {
|
||||
this.doUiAction('refreshTableData');
|
||||
},
|
||||
methods: {
|
||||
|
||||
async refreshTableData() {
|
||||
this.isTableLoading = true;
|
||||
const result = await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'uiActionComponent',
|
||||
actionId: 'selectItemList',
|
||||
actionData: {},
|
||||
where: {},
|
||||
orderBy: [{column: 'operationAt', order: 'desc'}]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.tableDataFromBackend = result.data.appData.rows;
|
||||
this.isTableLoading = false;
|
||||
},
|
||||
|
||||
async clearItemData() {
|
||||
this.editItem = {};
|
||||
},
|
||||
|
||||
// validate
|
||||
prepareValidate() {
|
||||
return this.$refs.form.validate();
|
||||
},
|
||||
|
||||
async openCreateDialog() {
|
||||
this.isEditDrawerShow = true;
|
||||
},
|
||||
|
||||
async prepareCreateItem() {
|
||||
delete this.editItem.id;
|
||||
},
|
||||
|
||||
async doCreateItem() {
|
||||
await window.vtoast.loading("新增学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'uiActionComponent',
|
||||
actionId: 'insertItem',
|
||||
actionData: this.editItem
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("新增学生成功");
|
||||
},
|
||||
|
||||
async closeDrawerShow() {
|
||||
this.isEditDrawerShow = false;
|
||||
},
|
||||
|
||||
async prepareItemData({item}) {
|
||||
this.editItem = { ...item };
|
||||
},
|
||||
|
||||
async openUpdateDialog() {
|
||||
this.isEditDrawerShow = true;
|
||||
},
|
||||
|
||||
async doUpdateItem() {
|
||||
const {id, ...actionData} = this.editItem;
|
||||
await window.vtoast.loading("修改学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'uiActionComponent',
|
||||
actionId: 'updateItem',
|
||||
actionData: actionData,
|
||||
where: {id}
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.vtoast.success("修改学生成功");
|
||||
},
|
||||
|
||||
async confirmDeleteItemDialog() {
|
||||
return await window.confirmDialog({ title: "删除", content: "确定删除吗?" });
|
||||
},
|
||||
|
||||
async doDeleteItem() {
|
||||
const {id} = this.editItem;
|
||||
await window.vtoast.loading("删除学生");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'uiActionComponent',
|
||||
actionId: 'deleteItem',
|
||||
actionData: {},
|
||||
where: {id: id}
|
||||
}
|
||||
}
|
||||
});
|
||||
await window.vtoast.success("删除学生成功");
|
||||
},
|
||||
|
||||
getConstantCollectionItemText(key, _value) {
|
||||
const constantCollectionItemFind = this.constantCollection[key].find(
|
||||
({ value }) => value === _value
|
||||
);
|
||||
if (constantCollectionItemFind) {
|
||||
return constantCollectionItemFind.text;
|
||||
}
|
||||
return _value;
|
||||
},
|
||||
dialogIsOpen() {
|
||||
return window.dialogIsOpen;
|
||||
},
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,3 @@
|
||||
## 服务端搜索(studentManagement04)
|
||||
|
||||
服务端搜索
|
||||
@@ -0,0 +1 @@
|
||||
# 选择部分数据的权限设置
|
||||
@@ -0,0 +1,3 @@
|
||||
## 前端对接(studentManagement02)
|
||||
|
||||
前端对接
|
||||
@@ -0,0 +1,3 @@
|
||||
## 前端优化(studentManagement03)
|
||||
|
||||
前端优化
|
||||
@@ -0,0 +1,16 @@
|
||||
<!-- 首页文档 -->
|
||||
# jianghujs_demo_basic
|
||||
|
||||
本项目展示江湖 js 的基本功能。
|
||||
|
||||
## 标题1
|
||||
|
||||
|
||||
## 标题2
|
||||
|
||||
|
||||
## 标题3
|
||||
|
||||
|
||||
## 标题4
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
## 应用协议(studentManagement01)
|
||||
|
||||
应用协议
|
||||
Reference in new issue
Block a user