list.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div class="safety-platform-container">
  3. <header class="safety-platform-container__header">
  4. <div class="breadcrumb-title">特种设备设施管理</div>
  5. </header>
  6. <main class="safety-platform-container__main">
  7. <div class="search-table-container">
  8. <header>
  9. <div style="position: relative">
  10. <el-button
  11. type="primary"
  12. class="search-table-container--button"
  13. @click="$router.push({ name: 'specialEquipmentManageAdd' })"
  14. >
  15. 添加
  16. </el-button>
  17. </div>
  18. <div class="act-search">
  19. <section class="select-box">
  20. <div class="select-box--item">
  21. <span>设备名称:</span>
  22. <el-input
  23. v-model="queryParams.queryParam.deviceName"
  24. placeholder="请输入设备名称"
  25. class="act-search-input"
  26. clearable
  27. />
  28. </div>
  29. <div class="select-box--item">
  30. <span>状态:</span>
  31. <el-select
  32. v-model="queryParams.queryParam.deviceStatus"
  33. placeholder="请选择状态"
  34. clearable
  35. class="act-search-input"
  36. >
  37. <el-option label="在用" :value="1" />
  38. <el-option label="停用" :value="2" />
  39. <el-option label="报废" :value="3" />
  40. </el-select>
  41. </div>
  42. <div class="select-box--item">
  43. <span>是否使用部门:</span>
  44. <el-select
  45. v-model="queryParams.queryParam.isUseDepartment"
  46. placeholder="是否使用部门"
  47. clearable
  48. class="act-search-input"
  49. >
  50. <el-option label="是" :value="1" />
  51. <el-option label="否" :value="0" />
  52. </el-select>
  53. </div>
  54. <div class="select-box--item">
  55. <span>责任部门:</span>
  56. <el-cascader
  57. v-model="responsibilityDeptPath"
  58. :options="deptOptions"
  59. :props="deptCascaderProps"
  60. :show-all-levels="false"
  61. placeholder="请选择责任部门"
  62. class="act-search-input"
  63. filterable
  64. clearable
  65. @change="handleDeptChange"
  66. />
  67. </div>
  68. <div class="select-box--item">
  69. <span>使用单位:</span>
  70. <el-input
  71. v-model="queryParams.queryParam.useUnit"
  72. placeholder="请输入使用单位"
  73. class="act-search-input"
  74. clearable
  75. />
  76. </div>
  77. </section>
  78. <section class="search-btn">
  79. <el-button type="primary" @click="queryTableList">查询</el-button>
  80. <el-button @click="handleRestParams">重置</el-button>
  81. </section>
  82. </div>
  83. </header>
  84. <div class="batch-table">
  85. <BasicTable
  86. ref="basicTableRef"
  87. :tableData="tableData"
  88. :tableConfig="tableConfig"
  89. @update:pageSize="handleSizeChange"
  90. @update:pageNumber="handleCurrentChange"
  91. >
  92. <template #deviceStatus="scope">
  93. <span>
  94. {{ getStatusText(scope.row.deviceStatus, scope.row.deviceStatusName) }}
  95. </span>
  96. </template>
  97. <template #action="scope">
  98. <div class="action-container--div" style="justify-content: left">
  99. <ActionButton
  100. text="查看"
  101. @click="$router.push({ name: 'specialEquipmentManageView', query: { id: scope.row.id } })"
  102. />
  103. <ActionButton
  104. text="编辑"
  105. @click="$router.push({ name: 'specialEquipmentManageEdit', query: { id: scope.row.id } })"
  106. />
  107. <ActionButton
  108. text="删除"
  109. :popconfirm="{ title: '确定要删除该特种设备设施吗?' }"
  110. @confirm="handleDelete(scope.row)"
  111. />
  112. </div>
  113. </template>
  114. </BasicTable>
  115. </div>
  116. </div>
  117. </main>
  118. </div>
  119. </template>
  120. <script lang="ts" setup>
  121. import { onMounted, reactive, ref } from 'vue';
  122. import { ElMessage } from 'element-plus';
  123. import type { QueryPageRequest } from '@/types/basic-query';
  124. import {
  125. querySpecialEquipmentPage,
  126. deleteSpecialEquipment,
  127. type SpecialEquipment,
  128. type SpecialEquipmentQueryParam,
  129. } from '@/api/production-safety/special-equipment';
  130. import { getAllDepartments } from '@/api/auth/dept';
  131. import { formatDeptTree } from '@/views/disaster/utils/formatDeptTree';
  132. import BasicTable from '@/components/BasicTable.vue';
  133. import useTableConfig from '@/hooks/useTableConfigHook';
  134. import ActionButton from '@/components/ActionButton.vue';
  135. import { TABLE_OPTIONS, SPECIAL_EQUIPMENT_TABLE_COLUMNS } from './configs/tables';
  136. const loading = ref(false);
  137. // BasicTable
  138. const basicTableRef = ref<InstanceType<typeof BasicTable>>();
  139. const { tableConfig, pagination } = useTableConfig(SPECIAL_EQUIPMENT_TABLE_COLUMNS, TABLE_OPTIONS);
  140. const queryParams = reactive<QueryPageRequest<SpecialEquipmentQueryParam>>({
  141. pageNumber: 1,
  142. pageSize: 10,
  143. queryParam: {
  144. deviceName: '',
  145. deviceStatus: undefined,
  146. categoryId: undefined,
  147. typeId: undefined,
  148. isUseDepartment: undefined,
  149. responsibilityDeptId: undefined,
  150. useUnit: '',
  151. },
  152. });
  153. // 类别/种类名称(目前接口只支持按 ID 查,这里仅作为显示搜索占位)
  154. const categoryName = ref('');
  155. const typeName = ref('');
  156. // 部门树(queryAllDeptTree 样式)
  157. const deptOptions = ref<any[]>([]);
  158. const responsibilityDeptPath = ref<number[]>([]);
  159. const deptCascaderProps = {
  160. expandTrigger: 'click',
  161. checkStrictly: true,
  162. value: 'id',
  163. label: 'deptName',
  164. };
  165. const tableData = ref<SpecialEquipment[]>([]);
  166. const handleSizeChange = (value: number) => {
  167. pagination.pageSize = value;
  168. queryParams.pageSize = value;
  169. queryParams.pageNumber = 1;
  170. queryTableList();
  171. };
  172. const handleCurrentChange = (value: number) => {
  173. pagination.pageNumber = value;
  174. queryParams.pageNumber = value;
  175. queryTableList();
  176. };
  177. const getStatusText = (status?: number, statusName?: string) => {
  178. if (statusName) return statusName;
  179. if (status === 1) return '在用';
  180. if (status === 2) return '停用';
  181. if (status === 3) return '报废';
  182. return '-';
  183. };
  184. const loadDeptTree = async () => {
  185. try {
  186. const res = await getAllDepartments();
  187. deptOptions.value = formatDeptTree(res);
  188. } catch (e) {
  189. console.error('获取部门树失败:', e);
  190. deptOptions.value = [];
  191. }
  192. };
  193. const handleDeptChange = (val: number[]) => {
  194. if (Array.isArray(val) && val.length) {
  195. queryParams.queryParam.responsibilityDeptId = val[val.length - 1];
  196. } else {
  197. queryParams.queryParam.responsibilityDeptId = undefined;
  198. }
  199. };
  200. const queryTableList = () => {
  201. loading.value = true;
  202. tableConfig.loading = true;
  203. querySpecialEquipmentPage(queryParams)
  204. .then((res: any) => {
  205. tableData.value = (res?.records ?? res?.list ?? []) as SpecialEquipment[];
  206. pagination.total = res?.totalRow ?? res?.total ?? 0;
  207. })
  208. .finally(() => {
  209. loading.value = false;
  210. tableConfig.loading = false;
  211. });
  212. };
  213. const handleDelete = (row: SpecialEquipment) => {
  214. if (!row.id) return;
  215. deleteSpecialEquipment(row.id!)
  216. .then(() => {
  217. ElMessage.success('删除成功');
  218. queryTableList();
  219. })
  220. .catch(() => {});
  221. };
  222. const handleRestParams = () => {
  223. pagination.pageNumber = 1;
  224. pagination.pageSize = 10;
  225. queryParams.pageNumber = 1;
  226. queryParams.pageSize = 10;
  227. queryParams.queryParam = {
  228. deviceName: '',
  229. deviceStatus: undefined,
  230. categoryId: undefined,
  231. typeId: undefined,
  232. isUseDepartment: undefined,
  233. responsibilityDeptId: undefined,
  234. useUnit: '',
  235. };
  236. categoryName.value = '';
  237. typeName.value = '';
  238. responsibilityDeptPath.value = [];
  239. queryTableList();
  240. };
  241. onMounted(() => {
  242. loadDeptTree();
  243. queryTableList();
  244. });
  245. </script>
  246. <style lang="scss" scoped>
  247. @use '@/styles/page-details-layout.scss' as *;
  248. @use '@/styles/page-main-layout.scss' as *;
  249. @use '@/styles/basic-table-action.scss' as *;
  250. @use '@/views/traffic/violation/style/act-search-table.scss' as *;
  251. </style>