Files
workflow/app/view/page/taskCreateManagement.html
T

255 lines
9.7 KiB
HTML

{% extends 'template/jhTemplateV3.html'%}
{% block vue_template %}
<jh-layout-v3>
<template slot="serverSearch">
<v-row class="ma-0 align-center" :class="{'pa-0': isMobile, 'pa-2': !isMobile}" style="justify-content: end">
<v-col cols="12" sm="12" xs="5" md="3" xl="2" class="pb-3" :class="{'pl-0': isMobile, 'pt-0': isMobile}">
<v-text-field v-model="serverSearchInput.workflowName" color="success" prefix="流程名称:" class="cus-v-input" :class="{'mr-2': !isMobile}" dense filled single-line></v-text-field>
</v-col>
<v-col class="pl-0 pr-0" :class="{'pt-0': isMobile}" style="max-width: 57px">
<v-btn
class="elevation-0"
color="success"
dark
@click="doUiAction('refreshTableData')"
>
查询
</v-btn>
</v-col>
</v-row>
</template>
<!-- 页面主要内容 -->
<v-card :class="{'px-2': isMobile}">
<v-data-table :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="{'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 color="success" class="mr-2" @click="doUiAction('startCreateItem', {item: item})">
申请
</v-btn>
</template>
</v-data-table>
</v-card>
<!-- 编辑抽屉 -->
<v-navigation-drawer v-model="isEditDrawerShow" :permanent="isEditDrawerShow" fixed temporary right width="40%"
class="elevation-24">
<v-form v-model="isFormValid" v-if="isEditDrawerShow" ref="form" lazy-validation>
<v-row class="pt-8">
<span class="title pa-6" :class="{'pl-12': !isMobile, 'pl-6': isMobile}">{{ currentClickButton.title }}信息</span>
<v-spacer></v-spacer>
<v-btn class="mt-6 elevation-0" :class="{'mr-16': !isMobile, 'mr-8': isMobile}" fab x-small @click="isEditDrawerShow = false">
<v-icon dark>mdi-close</v-icon>
</v-btn>
</v-row>
<v-row :class="{'px-10': !isMobile, 'px-3': isMobile, 'pb-7': isMobile}">
<v-col cols="12" sm="12" md="12" :class="{'pa-0': isMobile, 'px-3': isMobile, 'pt-6': isMobile}">
<span class="inputLabel">任务标题</span>
<v-text-field class="cus-v-input mr-2" dense filled single-line label="任务标题" v-model="editItem['taskTitle']">
</v-text-field>
</v-col>
<v-col cols="12" class=" pb-3" v-for="(formItem, index) in editItem.workflowForm" :key="index">
<span class="inputLabel">{{ index+1 }}、 {{ formItem.component.outline }}</span>
<v-list-item-content v-if="formItem.component.type === 'singleSelect'">
<v-radio-group row v-model="editItem.workflowFormData[formItem.id]" hide-details>
<v-radio v-for="(option, optionIndex) in formItem.component.property.selectOptionList"
:key="optionIndex" :label="option.value"></v-radio>
</v-radio-group>
</v-list-item-content>
<v-list-item-content v-if="formItem.component.type === 'multipleSelect'">
<div v-for="(option, optionIndex) in formItem.component.property.selectOptionList" :key="optionIndex">
<v-checkbox style="margin-top: 0px;" :label="option.value" :value="option.value" v-model="editItem.workflowFormData[formItem.id]" hide-details color="red"></v-checkbox>
</div>
</v-list-item-content>
<v-list-item-content v-if="formItem.component.type === 'textarea'">
<v-textarea hide-details dense filled single-line placeholder="请输入" :rules="requireRules" :label="(index+1) + '. ' + formItem.component.outline" v-model="editItem.workflowFormData[formItem.id]" :rows="4"/>
</v-list-item-content>
<v-list-item-content v-if="formItem.component.type === 'input'">
<v-text-field class="cus-v-input mr-2" dense filled single-line placeholder="请输入" :rules="requireRules" :label="(index+1) + '. ' + formItem.component.outline" v-model="editItem.workflowFormData[formItem.id]" ></v-text-field>
</v-list-item-content>
</v-col>
</v-row>
<v-row class="justify-end mx-0 mt-8" :class="{'px-10': !isMobile, 'px-4': isMobile, 'mb-8': isMobile}">
<v-btn color="success" @click="doUiAction(dialogSaveInfoAction)"
>保存
</v-btn>
<v-btn class="elevation-0 ml-2" @click="isEditDrawerShow = false">取消</v-btn>
</v-row>
</v-form>
</v-navigation-drawer>
</jh-layout-v3>
{% endblock %}
{% block vue_body %}
<script type="module">
new Vue({
el: '#app',
template: '#app-template',
vuetify: new Vuetify(),
data: () => ({
isMobile: window.innerWidth < 600,
// 表格相关数据
isFormValid: true,
requireRules: [
v => !!v || 'This is required',
],
constantCollection: {
categoryList: [],
},
serverSearchInput: {
workflowName: null
},
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: "workflowConfig", 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: 200, class: 'fixed', cellClass: 'fixed' },
],
currentClickButton: { title: '新增', action: 'add' },
editItem: {},
tplItem: {},
tableButtonList: [
{ text: '修改', buttonType: 'edit', color: 'success', action: 'startUpdateItem' },
{ text: '删除', buttonType: 'delete', color: 'error', action: 'deleteItem' },
],
dialogSaveInfoAction: ''
}),
async created() {
await this.doUiAction('refreshTableData');
},
mounted() { },
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'refreshTableData':
await this.refreshTableData(uiActionData);
break;
case 'startCreateItem':
await this.clearItemData(uiActionData);
await this.openCreateItemDialog(uiActionData);
break;
case 'createItem':
await this.confirmCreateItemDialog(uiActionData);
await this.doCreateItem(uiActionData);
await this.refreshTableData(uiActionData);
await this.closeDrawerShow(uiActionData);
break;
default:
console.error("[doAction] uiActionId not find", { uiActionId });
break;
}
},
/**
* 获取表格数据
*/
async refreshTableData() {
this.isTableLoading = true;
const serverSearchInput = _.pickBy(this.serverSearchInput, value => !!value);
const { data: { appData: { resultData: {rows} } } } = await window.jianghuAxios({
data: {
appData: {
pageId: 'taskCreateManagement',
actionId: 'selectWorkflowList',
actionData: {},
where: {},
whereLike: serverSearchInput,
orderBy: [{ column: 'operationAt', order: 'desc' }]
}
}
});
rows.forEach(row => {
if(row.workflowConfig) {
row.workflowConfig = JSON.parse(row.workflowConfig).nodeList.map(item => [item.label, item.lineTypeList]);
row.workflowForm = JSON.parse(row.workflowForm || '[]');
}
})
this.tableDataFromBackend = rows;
this.isTableLoading = false;
},
// startCreateItem
clearItemData({item: { workflowForm, workflowConfig, workflowId }}) {
const workflowFormData = {};
workflowForm.forEach(e => {
workflowFormData[e.id] = '';
if (e.component.type === 'multipleSelect') {
workflowFormData[e.id] = [];
}
})
this.editItem = {workflowForm, workflowFormData, workflowId};
},
async openCreateItemDialog() {
this.currentClickButton = { action: 'add', title: '新增' };
this.isEditDrawerShow = true;
this.dialogSaveInfoAction = 'createItem';
},
// createItem
async confirmCreateItemDialog() {
if (await window.confirmDialog({title: "新增", content: "确定新增吗?"}) === false) {
throw new Error("[confirmCreateFormDialog] 否");
}
},
/**
* 新增数据
*/
async doCreateItem() {
delete this.editItem.id;
await window.vtoast.loading("新增数据");
await window.jianghuAxios({
data: {
appData: {
pageId: 'taskCreateManagement',
actionId: 'insertItem',
actionData: this.editItem
}
}
})
await window.vtoast.success("新增数据成功");
},
async closeDrawerShow() {
this.isEditDrawerShow = false;
}
}
})
</script>
<style scoped>
</style>
{% endblock %}