bpm:流程列表 100%

This commit is contained in:
YunaiV 2023-01-19 16:49:57 +08:00
parent b90b297e6f
commit 2d85f11f82
2 changed files with 148 additions and 191 deletions

View File

@ -1,4 +1,5 @@
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
const { t } = useI18n() // 国际化
// 表单校验
@ -7,52 +8,33 @@ export const rules = reactive({
})
// CrudSchema
const crudSchemas = reactive<CrudSchema[]>([
{
label: t('common.index'),
field: 'id',
type: 'index',
form: {
show: false
const crudSchemas = reactive<VxeCrudSchema>({
primaryKey: 'id',
primaryType: 'seq',
primaryTitle: '表单编号',
action: true,
columns: [
{
title: '表单名',
field: 'name',
isSearch: true
},
detail: {
show: false
}
},
{
label: '表单名',
field: 'name',
search: {
show: true
}
},
{
label: t('common.status'),
field: 'status',
dictType: DICT_TYPE.COMMON_STATUS,
dictClass: 'number'
},
{
label: '备注',
field: 'remark'
},
{
label: t('common.createTime'),
field: 'createTime',
form: {
show: false
}
},
{
label: t('table.action'),
field: 'action',
width: '240px',
form: {
show: false
{
title: t('common.status'),
field: 'status',
dictType: DICT_TYPE.COMMON_STATUS,
dictClass: 'number'
},
detail: {
show: false
{
title: '备注',
field: 'remark'
},
{
title: t('common.createTime'),
field: 'createTime',
formatter: 'formatDate',
isForm: false
}
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)

View File

@ -1,165 +1,140 @@
<script setup lang="ts" name="Form">
import dayjs from 'dayjs'
import { DICT_TYPE } from '@/utils/dict'
import type { FormExpose } from '@/components/Form'
import type { FormVO } from '@/api/bpm/form/types'
import { rules, allSchemas } from './form.data'
<template>
<ContentWrap>
<!-- 列表 -->
<div>
<XTable @register="registerTable">
<!-- 操作新增 -->
<template #toolbar_buttons>
<XButton
type="primary"
preIcon="ep:zoom-in"
:title="t('action.add')"
v-hasPermi="['system:post:create']"
@click="handleCreate()"
/>
</template>
<template #actionbtns_default="{ row }">
<!-- 操作修改 -->
<XTextButton
preIcon="ep:edit"
:title="t('action.edit')"
v-hasPermi="['bpm:form:update']"
@click="handleUpdate(row.id)"
/>
<!-- 操作详情 -->
<XTextButton
preIcon="ep:view"
:title="t('action.detail')"
v-hasPermi="['bpm:form:query']"
@click="handleDetail(row.id)"
/>
<!-- 操作删除 -->
<XTextButton
preIcon="ep:delete"
:title="t('action.del')"
v-hasPermi="['bpm:form:delete']"
@click="deleteData(row.id)"
/>
</template>
</XTable>
<!-- TODO 芋艿待完善 -->
<XModal v-model="detailOpen" width="400" title="表单详情">
<!-- <div class="test-form">
<parser :key="new Date().getTime()" :form-conf="detailForm" />
</div> -->
表单详情
</XModal>
</div>
</ContentWrap>
</template>
<script setup lang="ts" name="BpmForm">
// import
// import { ref } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { useXTable } from '@/hooks/web/useXTable'
// import { FormExpose } from '@/components/Form'
// import
import * as FormApi from '@/api/bpm/form'
import { useTable } from '@/hooks/web/useTable'
import { allSchemas } from './form.data'
import { useRouter } from 'vue-router'
// import { decodeFields } from '@/utils/formGenerator' // TODO
const { t } = useI18n() //
const message = useMessage()
const message = useMessage() //
const router = useRouter() //
// ========== ==========
const { register, tableObject, methods } = useTable<FormVO>({
//
const [registerTable, { deleteData }] = useXTable({
allSchemas: allSchemas,
getListApi: FormApi.getFormPageApi,
delListApi: FormApi.deleteFormApi
deleteApi: FormApi.deleteFormApi
})
const { getList, setSearchParams, delList } = methods
// ========== CRUD ==========
const actionLoading = ref(false) //
const actionType = ref('') //
const dialogVisible = ref(false) //
const dialogTitle = ref('edit') //
const formRef = ref<FormExpose>() // Ref
//
// const modelVisible = ref(false) //
// const modelTitle = ref('edit') //
// const modelLoading = ref(false) // loading
// const actionType = ref('') //
// const actionLoading = ref(false) // Loading
// const formRef = ref<FormExpose>() // Ref
// const detailData = ref() // Ref
//
const setDialogTile = (type: string) => {
dialogTitle.value = t('action.' + type)
actionType.value = type
dialogVisible.value = true
}
// const setDialogTile = (type: string) => {
// modelLoading.value = true
// modelTitle.value = t('action.' + type)
// actionType.value = type
// modelVisible.value = true
// }
//
const handleCreate = () => {
setDialogTile('create')
console.log('新增')
if (true) {
message.success('动态表单开发中,预计 2 月底完成')
return
}
router.push({
path: '/manager/form/edit'
})
}
//
const handleUpdate = async (row: FormVO) => {
setDialogTile('update')
//
const res = await FormApi.getFormApi(row.id)
unref(formRef)?.setValues(res)
}
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as FormVO
if (actionType.value === 'create') {
await FormApi.createFormApi(data)
message.success(t('common.createSuccess'))
} else {
await FormApi.updateFormApi(data)
message.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
const handleUpdate = async (rowId: number) => {
console.log(rowId, '修改')
if (true) {
message.success('动态表单开发中,预计 2 月底完成')
return
}
await router.push({
path: '/bpm/manager/form/edit',
query: {
formId: rowId
}
})
}
// ========== ==========
const detailData = ref() // Ref
// // TODO
// const detailForm = ref({
// fields: []
// })
//
// const detailOpen = ref(false)
//
const handleDetail = async (row: FormVO) => {
//
detailData.value = row
setDialogTile('detail')
const handleDetail = async (rowId: number) => {
console.log(rowId, '详情')
message.success('动态表单开发中,预计 2 月底完成')
// FormApi.getFormApi(row.id).then((response) => {
// //
// const data = response.data
// detailForm.value = {
// ...JSON.parse(data.conf),
// fields: decodeFields([], data.fields)
// }
// //
// detailOpen.value = true
// })
}
// ========== ==========
getList()
</script>
<template>
<!-- 搜索工作区 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<ContentWrap>
<!-- 操作工具栏 -->
<div class="mb-10px">
<el-button type="primary" v-hasPermi="['bpm:form:create']" @click="handleCreate()">
<Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.add') }}
</el-button>
</div>
<!-- 列表 -->
<Table
:columns="allSchemas.tableColumns"
:selection="false"
:data="tableObject.tableList"
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
@register="register"
>
<template #status="{ row }">
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
</template>
<template #createTime="{ row }">
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
<template #action="{ row }">
<el-button link type="primary" v-hasPermi="['bpm:form:update']" @click="handleUpdate(row)">
<Icon icon="ep:edit" class="mr-1px" /> {{ t('action.edit') }}
</el-button>
<el-button link type="primary" v-hasPermi="['bpm:form:update']" @click="handleDetail(row)">
<Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
</el-button>
<el-button
link
type="primary"
v-hasPermi="['bpm:form:delete']"
@click="delList(row.id, false)"
>
<Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }}
</el-button>
</template>
</Table>
</ContentWrap>
<XModal v-model="dialogVisible" :title="dialogTitle">
<!-- 对话框(添加 / 修改) -->
<Form
v-if="['create', 'update'].includes(actionType)"
:schema="allSchemas.formSchema"
:rules="rules"
ref="formRef"
/>
<!-- 对话框(详情) -->
<Descriptions
v-if="actionType === 'detail'"
:schema="allSchemas.detailSchema"
:data="detailData"
/>
<!-- 操作按钮 -->
<template #footer>
<!-- 按钮保存 -->
<XButton
v-if="['create', 'update'].includes(actionType)"
type="primary"
:title="t('action.save')"
:loading="actionLoading"
@click="submitForm()"
/>
<!-- 按钮关闭 -->
<XButton :loading="actionLoading" :title="t('dialog.close')" @click="dialogVisible = false" />
</template>
</XModal>
</template>