houzhongjian
2024-08-08 820397e43a0b64d35c6d31d2a55475061438593b
提交 | 用户 | 时间
820397 1 <template>
H 2
3   <ContentWrap>
4     <!-- 搜索工作栏 -->
5     <el-form
6       class="-mb-15px"
7       :model="queryParams"
8       ref="queryFormRef"
9       :inline="true"
10       label-width="68px"
11     >
12       <el-form-item label="分类名" prop="name">
13         <el-input
14           v-model="queryParams.name"
15           placeholder="请输入分类名"
16           clearable
17           @keyup.enter="handleQuery"
18           class="!w-240px"
19         />
20       </el-form-item>
21       <el-form-item label="分类标志" prop="code">
22         <el-input
23           v-model="queryParams.code"
24           placeholder="请输入分类标志"
25           clearable
26           @keyup.enter="handleQuery"
27           class="!w-240px"
28         />
29       </el-form-item>
30       <el-form-item label="分类状态" prop="status">
31         <el-select
32           v-model="queryParams.status"
33           placeholder="请选择分类状态"
34           clearable
35           class="!w-240px"
36         >
37           <el-option
38             v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
39             :key="dict.value"
40             :label="dict.label"
41             :value="dict.value"
42           />
43         </el-select>
44       </el-form-item>
45       <el-form-item label="创建时间" prop="createTime">
46         <el-date-picker
47           v-model="queryParams.createTime"
48           value-format="YYYY-MM-DD HH:mm:ss"
49           type="daterange"
50           start-placeholder="开始日期"
51           end-placeholder="结束日期"
52           :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
53           class="!w-240px"
54         />
55       </el-form-item>
56       <el-form-item>
57         <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
58         <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
59         <el-button
60           type="primary"
61           plain
62           @click="openForm('create')"
63           v-hasPermi="['bpm:category:create']"
64         >
65           <Icon icon="ep:plus" class="mr-5px" /> 新增
66         </el-button>
67       </el-form-item>
68     </el-form>
69   </ContentWrap>
70
71   <!-- 列表 -->
72   <ContentWrap>
73     <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
74       <el-table-column label="分类编号" align="center" prop="id" />
75       <el-table-column label="分类名" align="center" prop="name" />
76       <el-table-column label="分类标志" align="center" prop="code" />
77       <el-table-column label="分类描述" align="center" prop="description" />
78       <el-table-column label="分类状态" align="center" prop="status">
79         <template #default="scope">
80           <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
81         </template>
82       </el-table-column>
83       <el-table-column label="分类排序" align="center" prop="sort" />
84       <el-table-column
85         label="创建时间"
86         align="center"
87         prop="createTime"
88         :formatter="dateFormatter"
89         width="180px"
90       />
91       <el-table-column label="操作" align="center">
92         <template #default="scope">
93           <el-button
94             link
95             type="primary"
96             @click="openForm('update', scope.row.id)"
97             v-hasPermi="['bpm:category:update']"
98           >
99             编辑
100           </el-button>
101           <el-button
102             link
103             type="danger"
104             @click="handleDelete(scope.row.id)"
105             v-hasPermi="['bpm:category:delete']"
106           >
107             删除
108           </el-button>
109         </template>
110       </el-table-column>
111     </el-table>
112     <!-- 分页 -->
113     <Pagination
114       :total="total"
115       v-model:page="queryParams.pageNo"
116       v-model:limit="queryParams.pageSize"
117       @pagination="getList"
118     />
119   </ContentWrap>
120
121   <!-- 表单弹窗:添加/修改 -->
122   <CategoryForm ref="formRef" @success="getList" />
123 </template>
124
125 <script setup lang="ts">
126 import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
127 import { dateFormatter } from '@/utils/formatTime'
128 import { CategoryApi, CategoryVO } from '@/api/bpm/category'
129 import CategoryForm from './CategoryForm.vue'
130
131 /** BPM 流程分类 列表 */
132 defineOptions({ name: 'BpmCategory' })
133
134 const message = useMessage() // 消息弹窗
135 const { t } = useI18n() // 国际化
136
137 const loading = ref(true) // 列表的加载中
138 const list = ref<CategoryVO[]>([]) // 列表的数据
139 const total = ref(0) // 列表的总页数
140 const queryParams = reactive({
141   pageNo: 1,
142   pageSize: 10,
143   name: undefined,
144   code: undefined,
145   status: undefined,
146   createTime: []
147 })
148 const queryFormRef = ref() // 搜索的表单
149 const exportLoading = ref(false) // 导出的加载中
150
151 /** 查询列表 */
152 const getList = async () => {
153   loading.value = true
154   try {
155     const data = await CategoryApi.getCategoryPage(queryParams)
156     list.value = data.list
157     total.value = data.total
158   } finally {
159     loading.value = false
160   }
161 }
162
163 /** 搜索按钮操作 */
164 const handleQuery = () => {
165   queryParams.pageNo = 1
166   getList()
167 }
168
169 /** 重置按钮操作 */
170 const resetQuery = () => {
171   queryFormRef.value.resetFields()
172   handleQuery()
173 }
174
175 /** 添加/修改操作 */
176 const formRef = ref()
177 const openForm = (type: string, id?: number) => {
178   formRef.value.open(type, id)
179 }
180
181 /** 删除按钮操作 */
182 const handleDelete = async (id: number) => {
183   try {
184     // 删除的二次确认
185     await message.delConfirm()
186     // 发起删除
187     await CategoryApi.deleteCategory(id)
188     message.success(t('common.delSuccess'))
189     // 刷新列表
190     await getList()
191   } catch {}
192 }
193
194 /** 初始化 **/
195 onMounted(() => {
196   getList()
197 })
198 </script>