提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
|
|
3 |
<ContentWrap> |
|
4 |
<!-- 搜索工作栏 --> |
|
5 |
<el-form |
|
6 |
ref="queryFormRef" |
|
7 |
:inline="true" |
|
8 |
:model="queryParams" |
|
9 |
class="-mb-15px" |
|
10 |
label-width="68px" |
|
11 |
> |
|
12 |
<el-form-item label="表单名" prop="name"> |
|
13 |
<el-input |
|
14 |
v-model="queryParams.name" |
|
15 |
class="!w-240px" |
|
16 |
clearable |
|
17 |
placeholder="请输入表单名" |
|
18 |
@keyup.enter="handleQuery" |
|
19 |
/> |
|
20 |
</el-form-item> |
|
21 |
<el-form-item> |
|
22 |
<el-button @click="handleQuery"> |
|
23 |
<Icon class="mr-5px" icon="ep:search" /> |
|
24 |
搜索 |
|
25 |
</el-button> |
|
26 |
<el-button @click="resetQuery"> |
|
27 |
<Icon class="mr-5px" icon="ep:refresh" /> |
|
28 |
重置 |
|
29 |
</el-button> |
|
30 |
<el-button v-hasPermi="['bpm:form:create']" plain type="primary" @click="openForm"> |
|
31 |
<Icon class="mr-5px" icon="ep:plus" /> |
|
32 |
新增 |
|
33 |
</el-button> |
|
34 |
</el-form-item> |
|
35 |
</el-form> |
|
36 |
</ContentWrap> |
|
37 |
|
|
38 |
<!-- 列表 --> |
|
39 |
<ContentWrap> |
|
40 |
<el-table v-loading="loading" :data="list"> |
|
41 |
<el-table-column align="center" label="编号" prop="id" /> |
|
42 |
<el-table-column align="center" label="表单名" prop="name" /> |
|
43 |
<el-table-column align="center" label="状态" prop="status"> |
|
44 |
<template #default="scope"> |
|
45 |
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> |
|
46 |
</template> |
|
47 |
</el-table-column> |
|
48 |
<el-table-column align="center" label="备注" prop="remark" /> |
|
49 |
<el-table-column |
|
50 |
:formatter="dateFormatter" |
|
51 |
align="center" |
|
52 |
label="创建时间" |
|
53 |
prop="createTime" |
|
54 |
/> |
|
55 |
<el-table-column align="center" label="操作"> |
|
56 |
<template #default="scope"> |
|
57 |
<el-button |
|
58 |
v-hasPermi="['bpm:form:update']" |
|
59 |
link |
|
60 |
type="primary" |
|
61 |
@click="openForm(scope.row.id)" |
|
62 |
> |
|
63 |
编辑 |
|
64 |
</el-button> |
|
65 |
<el-button v-hasPermi="['bpm:form:query']" link @click="openDetail(scope.row.id)"> |
|
66 |
详情 |
|
67 |
</el-button> |
|
68 |
<el-button |
|
69 |
v-hasPermi="['bpm:form:delete']" |
|
70 |
link |
|
71 |
type="danger" |
|
72 |
@click="handleDelete(scope.row.id)" |
|
73 |
> |
|
74 |
删除 |
|
75 |
</el-button> |
|
76 |
</template> |
|
77 |
</el-table-column> |
|
78 |
</el-table> |
|
79 |
<!-- 分页 --> |
|
80 |
<Pagination |
|
81 |
v-model:limit="queryParams.pageSize" |
|
82 |
v-model:page="queryParams.pageNo" |
|
83 |
:total="total" |
|
84 |
@pagination="getList" |
|
85 |
/> |
|
86 |
</ContentWrap> |
|
87 |
|
|
88 |
<!-- 表单详情的弹窗 --> |
|
89 |
<Dialog v-model="detailVisible" title="表单详情" width="800"> |
|
90 |
<form-create :option="detailData.option" :rule="detailData.rule" /> |
|
91 |
</Dialog> |
|
92 |
</template> |
|
93 |
|
|
94 |
<script lang="ts" setup> |
|
95 |
import { DICT_TYPE } from '@/utils/dict' |
|
96 |
import { dateFormatter } from '@/utils/formatTime' |
|
97 |
import * as FormApi from '@/api/bpm/form' |
|
98 |
import { setConfAndFields2 } from '@/utils/formCreate' |
|
99 |
|
|
100 |
defineOptions({ name: 'BpmForm' }) |
|
101 |
|
|
102 |
const message = useMessage() // 消息弹窗 |
|
103 |
const { t } = useI18n() // 国际化 |
|
104 |
const { currentRoute, push } = useRouter() // 路由 |
|
105 |
|
|
106 |
const loading = ref(true) // 列表的加载中 |
|
107 |
const total = ref(0) // 列表的总页数 |
|
108 |
const list = ref([]) // 列表的数据 |
|
109 |
const queryParams = reactive({ |
|
110 |
pageNo: 1, |
|
111 |
pageSize: 10, |
|
112 |
name: null |
|
113 |
}) |
|
114 |
const queryFormRef = ref() // 搜索的表单 |
|
115 |
|
|
116 |
/** 查询列表 */ |
|
117 |
const getList = async () => { |
|
118 |
loading.value = true |
|
119 |
try { |
|
120 |
const data = await FormApi.getFormPage(queryParams) |
|
121 |
list.value = data.list |
|
122 |
total.value = data.total |
|
123 |
} finally { |
|
124 |
loading.value = false |
|
125 |
} |
|
126 |
} |
|
127 |
|
|
128 |
/** 搜索按钮操作 */ |
|
129 |
const handleQuery = () => { |
|
130 |
queryParams.pageNo = 1 |
|
131 |
getList() |
|
132 |
} |
|
133 |
|
|
134 |
/** 重置按钮操作 */ |
|
135 |
const resetQuery = () => { |
|
136 |
queryFormRef.value.resetFields() |
|
137 |
handleQuery() |
|
138 |
} |
|
139 |
|
|
140 |
/** 添加/修改操作 */ |
|
141 |
const openForm = (id?: number) => { |
|
142 |
const toRouter: { name: string; query?: { id: number } } = { |
|
143 |
name: 'BpmFormEditor' |
|
144 |
} |
3e359e
|
145 |
console.log(typeof id) |
820397
|
146 |
// 表单新建的时候id传的是event需要排除 |
3e359e
|
147 |
if (typeof id === 'number' || typeof id === 'string') { |
820397
|
148 |
toRouter.query = { |
H |
149 |
id |
|
150 |
} |
|
151 |
} |
|
152 |
push(toRouter) |
|
153 |
} |
|
154 |
|
|
155 |
/** 删除按钮操作 */ |
|
156 |
const handleDelete = async (id: number) => { |
|
157 |
try { |
|
158 |
// 删除的二次确认 |
|
159 |
await message.delConfirm() |
|
160 |
// 发起删除 |
|
161 |
await FormApi.deleteForm(id) |
|
162 |
message.success(t('common.delSuccess')) |
|
163 |
// 刷新列表 |
|
164 |
await getList() |
|
165 |
} catch {} |
|
166 |
} |
|
167 |
|
|
168 |
/** 详情操作 */ |
|
169 |
const detailVisible = ref(false) |
|
170 |
const detailData = ref({ |
|
171 |
rule: [], |
|
172 |
option: {} |
|
173 |
}) |
|
174 |
const openDetail = async (rowId: number) => { |
|
175 |
// 设置表单 |
|
176 |
const data = await FormApi.getForm(rowId) |
|
177 |
setConfAndFields2(detailData, data.conf, data.fields) |
|
178 |
// 弹窗打开 |
|
179 |
detailVisible.value = true |
|
180 |
} |
|
181 |
/**表单保存返回后重新加载列表 */ |
|
182 |
watch( |
|
183 |
() => currentRoute.value, |
|
184 |
() => { |
|
185 |
getList() |
|
186 |
}, |
|
187 |
{ |
|
188 |
immediate: true |
|
189 |
} |
|
190 |
) |
|
191 |
/** 初始化 **/ |
|
192 |
onMounted(() => { |
|
193 |
getList() |
|
194 |
}) |
|
195 |
</script> |