bpm:流程列表 100%

pull/2/head
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() // 国际化 const { t } = useI18n() // 国际化
// 表单校验 // 表单校验
@ -7,52 +8,33 @@ export const rules = reactive({
}) })
// CrudSchema // CrudSchema
const crudSchemas = reactive<CrudSchema[]>([ const crudSchemas = reactive<VxeCrudSchema>({
{ primaryKey: 'id',
label: t('common.index'), primaryType: 'seq',
field: 'id', primaryTitle: '表单编号',
type: 'index', action: true,
form: { columns: [
show: false {
title: '表单名',
field: 'name',
isSearch: true
}, },
detail: { {
show: false title: t('common.status'),
} field: 'status',
}, dictType: DICT_TYPE.COMMON_STATUS,
{ dictClass: 'number'
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
}, },
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"> <template>
import dayjs from 'dayjs' <ContentWrap>
import { DICT_TYPE } from '@/utils/dict' <!-- 列表 -->
import type { FormExpose } from '@/components/Form' <div>
import type { FormVO } from '@/api/bpm/form/types' <XTable @register="registerTable">
import { rules, allSchemas } from './form.data' <!-- 操作新增 -->
<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 * 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 { 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, getListApi: FormApi.getFormPageApi,
delListApi: FormApi.deleteFormApi deleteApi: FormApi.deleteFormApi
}) })
const { getList, setSearchParams, delList } = methods
// ========== CRUD ========== //
const actionLoading = ref(false) // // const modelVisible = ref(false) //
const actionType = ref('') // // const modelTitle = ref('edit') //
const dialogVisible = ref(false) // // const modelLoading = ref(false) // loading
const dialogTitle = ref('edit') // // const actionType = ref('') //
const formRef = ref<FormExpose>() // Ref // const actionLoading = ref(false) // Loading
// const formRef = ref<FormExpose>() // Ref
// const detailData = ref() // Ref
// //
const setDialogTile = (type: string) => { // const setDialogTile = (type: string) => {
dialogTitle.value = t('action.' + type) // modelLoading.value = true
actionType.value = type // modelTitle.value = t('action.' + type)
dialogVisible.value = true // actionType.value = type
} // modelVisible.value = true
// }
// //
const handleCreate = () => { const handleCreate = () => {
setDialogTile('create') console.log('新增')
if (true) {
message.success('动态表单开发中,预计 2 月底完成')
return
}
router.push({
path: '/manager/form/edit'
})
} }
// //
const handleUpdate = async (row: FormVO) => { const handleUpdate = async (rowId: number) => {
setDialogTile('update') console.log(rowId, '修改')
// if (true) {
const res = await FormApi.getFormApi(row.id) message.success('动态表单开发中,预计 2 月底完成')
unref(formRef)?.setValues(res) return
} }
await router.push({
// path: '/bpm/manager/form/edit',
const submitForm = async () => { query: {
const elForm = unref(formRef)?.getElFormRef() formId: rowId
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
}
} }
}) })
} }
// ========== ========== // // TODO
const detailData = ref() // Ref // const detailForm = ref({
// fields: []
// })
//
// const detailOpen = ref(false)
// const handleDetail = async (rowId: number) => {
const handleDetail = async (row: FormVO) => { console.log(rowId, '详情')
// message.success('动态表单开发中,预计 2 月底完成')
detailData.value = row // FormApi.getFormApi(row.id).then((response) => {
setDialogTile('detail') // //
// const data = response.data
// detailForm.value = {
// ...JSON.parse(data.conf),
// fields: decodeFields([], data.fields)
// }
// //
// detailOpen.value = true
// })
} }
// ========== ==========
getList()
</script> </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>