Files
workflow/app/view/page/workflowManagement.html
T
2022-08-05 09:25:31 +08:00

185 lines
5.6 KiB
HTML

{% extends 'template/jhTemplateV3.html'%}
{% block vue_template %}
<jh-layout-v3>
<!-- 页面主要内容 -->
<v-card :class="{'px-2': isMobile}">
<v-row class="ma-0 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
<v-col cols="12" xs="12" sm="4" md="4" xl="4" class="pl-0">
<v-btn color="success" 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="12" sm="4" md="3" xl="3" class="px-0">
<v-text-field v-model="searchInput" prefix="表格过滤:" color="success" class="cus-v-input" dense filled
single-line></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="{'mx-2': isMobile}"
color="success"
class="elevation-0 mt-0 flex-fill d-flex flex-column">
<template v-slot:item.action="{ item }">
<v-btn small class="mr-2" :class="tableButton.color" v-for="tableButton of tableButtonList"
@click="doUiAction(tableButton.action, {item})">
{{ tableButton.text }}
</v-btn>
</template>
</v-data-table>
</v-card>
</jh-layout-v3>
{% endblock %}
{% block vue_body %}
<script type="module">
new Vue({
el: '#app',
template: '#app-template',
vuetify: new Vuetify(),
mixins: [window.jianghuUiActionMixins],
data: () => ({
// 表格相关数据
requireRules: [
v => !!v || 'This is required',
],
serverSearchInput: {
studentId: null,
classId: null
},
currentTableGenderType: 'all',
isEditDrawerShow: false,
searchInput: null,
isTableLoading: true,
tableDataFromBackend: [],
headers: [
{text: "ID", value: "id", width: 120, class: 'fixed', cellClass: 'fixed'},
{text: "流程ID", value: "workflowId", width: 120},
{text: "流程名", value: "workflowName", width: 120},
{text: "分类ID", value: "workflowCategory", width: 120},
{text: "备注", value: "workFlowRemark", width: 120},
{text: "操作者", value: "operationByUser", width: 120},
{text: "操作时间", value: "operationAt", width: 250},
{text: '操作', value: 'action', align: 'center', sortable: false, width: 160, class: 'fixed', cellClass: 'fixed'},
],
currentClickButton: {title: '新增', action: 'add'},
editItem: {},
tableButtonList: [
{text: '修改', buttonType: 'edit', color: 'success', action: 'startUpdateItem'},
{text: '删除', buttonType: 'delete', color: 'error', action: 'deleteItem'},
],
dialogSaveInfoAction: '',
dialog: false,
}),
computed: {
isMobile() {
return window.innerWidth < 600;
},
tableData() {
if (!this.currentTableGenderType || this.currentTableGenderType === 'all') {
return this.tableDataFromBackend;
}
return this.tableDataFromBackend.filter(({gender}) => gender === this.currentTableGenderType);
},
},
async created() {
await this.doUiAction('refreshTableData');
},
mounted() {
},
methods: {
/**
* 获取表格数据
*/
async refreshTableData() {
this.isTableLoading = true;
const serverSearchInput = _.pickBy(this.serverSearchInput, value => !!value);
const {data: {appData: {rows}}} = await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectItemList',
actionData: {},
where: {},
whereLike: serverSearchInput,
orderBy: [{column: 'operationAt', order: 'desc'}]
}
}
});
for (const item of rows) {
item.workflowConfig = item.workflowConfig ? JSON.parse(item.workflowConfig) : null;
item.workflowForm = item.workflowForm ? JSON.parse(item.workflowForm) : [];
}
this.tableDataFromBackend = rows;
this.isTableLoading = false;
},
// startCreateItem
async clearItemData() {
if(this.isMobile) {
window.vtoast.fail({message: '该功能只能在电脑使用'})
return false;
}
window.location.href = `/${window.appInfo.appId}/page/workflowEditor?type=add`;
},
// startUpdateItem
async prepareItemData({item}) {
if(this.isMobile) {
window.vtoast.fail({message: '该功能只能在电脑使用'})
return false;
}
sessionStorage.setItem('workflowEditItem', JSON.stringify(item))
window.location.href = `/${window.appInfo.appId}/page/workflowEditor?type=edit`;
},
async confirmDeleteItemDialog() {
return window.confirmDialog({title: '删除', content: '确定删除吗?'});
},
/**
* 删除数据
*/
async doDeleteItem({item}) {
const {id} = item;
await window.vtoast.loading("删除数据");
await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'deleteItem',
actionData: {},
where: {id: id}
}
}
});
await window.vtoast.success("删除数据成功");
},
}
})
</script>
<style scoped>
.v-dialog--fullscreen .v-sheet {
height: unset;
top: unset;
position: unset;
background: white;
}
</style>
{% endblock %}