init project

This commit is contained in:
illuz committed 2022-07-05 14:40:21 +08:00
commit 571ba2a8a1
34 files changed
+3618

No files matched your search

+360
View File
@@ -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 %}