mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	bpm:流程列表 100%
This commit is contained in:
		| @@ -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) | ||||||
|   | |||||||
| @@ -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> |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV