backend/yudao-ui-admin-vue3/src/views/bpm/form/index.vue

100 lines
2.6 KiB
Vue
Raw Normal View History

2023-01-19 16:49:57 +08:00
<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>
2023-01-20 13:40:00 +08:00
<!-- 表单详情的弹窗 -->
<XModal v-model="detailOpen" width="800" title="表单详情">
<ViewForm :rule="detailPreview.rule" :option="detailPreview.option" v-if="detailOpen" />
2023-01-19 16:49:57 +08:00
</XModal>
</div>
</ContentWrap>
</template>
<script setup lang="ts" name="BpmForm">
// 全局相关的 import
// 业务相关的 import
2022-07-28 12:18:38 +08:00
import * as FormApi from '@/api/bpm/form'
2023-01-19 16:49:57 +08:00
import { allSchemas } from './form.data'
2022-07-28 12:18:38 +08:00
const { t } = useI18n() // 国际化
2023-01-19 16:49:57 +08:00
const router = useRouter() // 路由
2022-07-28 12:18:38 +08:00
2023-01-20 13:40:00 +08:00
// 表单详情相关的变量和 import
import viewForm from '@form-create/element-ui'
const ViewForm = viewForm.$form()
import { setConfAndFields2 } from '@/utils/formCreate'
2023-01-19 16:49:57 +08:00
// 列表相关的变量
const [registerTable, { deleteData }] = useXTable({
allSchemas: allSchemas,
2022-07-28 12:18:38 +08:00
getListApi: FormApi.getFormPageApi,
2023-01-19 16:49:57 +08:00
deleteApi: FormApi.deleteFormApi
2022-07-28 12:18:38 +08:00
})
// 新增操作
const handleCreate = () => {
2023-01-19 16:49:57 +08:00
router.push({
name: 'bpmFormEditor'
2023-01-19 16:49:57 +08:00
})
2022-07-28 12:18:38 +08:00
}
// 修改操作
2023-01-19 16:49:57 +08:00
const handleUpdate = async (rowId: number) => {
await router.push({
2023-01-20 13:40:00 +08:00
name: 'bpmFormEditor',
2023-01-19 16:49:57 +08:00
query: {
2023-01-20 13:40:00 +08:00
id: rowId
2022-07-28 12:18:38 +08:00
}
2022-10-17 11:24:22 +08:00
})
2022-07-28 12:18:38 +08:00
}
2023-01-20 13:40:00 +08:00
// 详情操作
const detailOpen = ref(false)
const detailPreview = ref({
rule: [],
option: {}
})
2023-01-19 16:49:57 +08:00
const handleDetail = async (rowId: number) => {
2023-01-20 13:40:00 +08:00
// 设置表单
const data = await FormApi.getFormApi(rowId)
setConfAndFields2(detailPreview, data.conf, data.fields)
// 弹窗打开
detailOpen.value = true
2022-07-28 12:18:38 +08:00
}
</script>