PageEmergencyList.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div class="safety-platform-container">
  3. <div class="safety-platform-container__header">
  4. <div class="breadcrumb-title">物资清单</div>
  5. </div>
  6. <div class="safety-platform-container__main">
  7. <div class="search-table-container">
  8. <header class="disaster-precaution__header">
  9. <el-button
  10. type="primary"
  11. class="search-table-container--button"
  12. :icon="Plus"
  13. @click="handleAddSupply"
  14. v-if="emergencySupplyPermissions"
  15. >添加物资
  16. </el-button>
  17. <el-button
  18. type="primary"
  19. class="search-table-container--button"
  20. v-if="emergencySupplyPermissions"
  21. @click="handleInventory"
  22. >
  23. <template #icon>
  24. <SvgIcon iconName="inventory-check" />
  25. </template>
  26. 发起盘点
  27. </el-button>
  28. <BasicSearch
  29. :searchConfig="SUPPLY_LIST_SEARCH_CONFIG"
  30. :searchData="searchData"
  31. @update:searchData="handleSearch"
  32. >
  33. <template #emergencyType>
  34. <el-select v-model="searchData.emergencyType" placeholder="请选择应急事件类型" filterable>
  35. <el-option
  36. v-for="item in emergencyEventDice"
  37. :key="item.itemCode"
  38. :label="item.itemValue"
  39. :value="item.itemCode"
  40. />
  41. </el-select>
  42. </template>
  43. <template #supplyType>
  44. <el-select v-model="searchData.supplyType" placeholder="请选择物资类型" filterable>
  45. <el-option
  46. v-for="item in emergencySupplyDice"
  47. :key="item.itemCode"
  48. :label="item.itemValue"
  49. :value="item.itemCode"
  50. />
  51. </el-select>
  52. </template>
  53. <template #park>
  54. <el-select v-model="searchData.park" placeholder="请选择园区">
  55. <el-option
  56. v-for="item in parkDice"
  57. :key="item.itemCode"
  58. :label="item.itemValue"
  59. :value="item.itemCode"
  60. />
  61. </el-select>
  62. </template>
  63. </BasicSearch>
  64. </header>
  65. <BasicTable
  66. :tableData="tableData"
  67. :tableConfig="tableConfig"
  68. @update:pageSize="handleSizeChange"
  69. @update:pageNumber="handleCurrentChange"
  70. >
  71. <template #emergencyType="scope">
  72. <span>{{ getEmergencyEvent(scope.row.emergencyType) }}</span>
  73. </template>
  74. <template #supplyType="scope">
  75. <span>{{ getEmergencySupply(scope.row.supplyType) }}</span>
  76. </template>
  77. <template #park="scope">
  78. <span>{{ getPark(scope.row.park) }}</span>
  79. </template>
  80. <template #location="scope">
  81. <span>{{ getLocation(scope.row.location) }}</span>
  82. </template>
  83. <template #status="scope">
  84. <span :style="{ color: scope.row.status === EMERGENCY_SUPPLY_STATUS.DAMAGED ? 'red' : '' }">
  85. {{ getEmergencyStatus(scope.row.status) }}
  86. </span>
  87. </template>
  88. <template #remark="scope">
  89. <div class="remark--div">
  90. <el-tooltip
  91. :content="scope.row.remark"
  92. placement="top"
  93. effect="light"
  94. :popper-class="['custom-tooltip', scope.row.remark.length > 10 ? '' : 'custom-tooltip--opacity0']"
  95. >
  96. <span>{{ scope.row.remark }}</span>
  97. </el-tooltip>
  98. </div>
  99. </template>
  100. <template #action="scope">
  101. <div class="action-container--div">
  102. <ActionButton text="查看" @click="handleViewDetail(scope.row.id)" />
  103. <ActionButton text="编辑" v-if="emergencySupplyPermissions" @click="handleEditSupply(scope.row.id)" />
  104. <ActionButton
  105. text="删除"
  106. v-if="emergencySupplyPermissions"
  107. :popconfirm="{
  108. title: '确定删除?',
  109. }"
  110. @confirm="handleDeleteSupply(scope.row.id)"
  111. />
  112. </div>
  113. </template>
  114. </BasicTable>
  115. </div>
  116. </div>
  117. </div>
  118. <InventoryTask ref="inventoryTaskRef" />
  119. </template>
  120. <script setup lang="ts">
  121. import { useRouter } from 'vue-router';
  122. import { ref, reactive, onMounted } from 'vue';
  123. import { Plus } from '@element-plus/icons-vue';
  124. import { ElMessage } from 'element-plus';
  125. // @ts-ignore
  126. import SvgIcon from '@/components/SvgIcon/SvgIcon.vue';
  127. import BasicSearch from '@/components/BasicSearch.vue';
  128. import BasicTable from '@/components/BasicTable.vue';
  129. import ActionButton from '@/components/ActionButton.vue';
  130. import InventoryTask from './src/components/InventoryTask.vue';
  131. import {
  132. SUPPLY_LIST_SEARCH_CONFIG,
  133. SUPPLY_LIST_TABLE_COLUMNS,
  134. SUPPLY_LIST_TABLE_OPTIONS,
  135. SUPPLY_LIST_TABLE_MAX_HEIGHT_DEFAULT,
  136. SUPPLY_LIST_TABLE_MAX_HEIGHT_PERMISSION,
  137. } from './src/config';
  138. import useTableConfig from '@/hooks/useTableConfigHook';
  139. import { useUserInfoHook } from '@/hooks/useUserInfoHook';
  140. import { useEmergencySuppliesHook } from './src/hook';
  141. import type { EmergencySupplyListQuery, EmergencySupplyListResponse } from '@/types/emergency-supplier';
  142. import type { QueryPageRequest } from '@/types/basic-query';
  143. import { getEmergencySupplyList, deleteEmergencySupplyList } from '@/api/emergency-supplier';
  144. import { EMERGENCY_PERMISSIONS } from '@/views/emergency/src/constant';
  145. import { EMERGENCY_SUPPLY_STATUS } from './src/constant';
  146. const router = useRouter();
  147. const {
  148. emergencyEventDice,
  149. getEmergencyEventDict,
  150. getEmergencyEvent,
  151. emergencySupplyDice,
  152. getEmergencySupplyDict,
  153. getEmergencySupply,
  154. getEmergencyStatus,
  155. parkDice,
  156. getParkDict,
  157. getPark,
  158. getLocationDict,
  159. getLocation,
  160. } = useEmergencySuppliesHook();
  161. const { permissions } = useUserInfoHook();
  162. const { tableConfig, pagination } = useTableConfig(SUPPLY_LIST_TABLE_COLUMNS, SUPPLY_LIST_TABLE_OPTIONS);
  163. const emergencySupplyPermissions = ref<Boolean>(false);
  164. let emergencySupplyListQuery: QueryPageRequest<EmergencySupplyListQuery> = {
  165. pageNumber: pagination.pageNumber,
  166. pageSize: pagination.pageSize,
  167. queryParam: {},
  168. };
  169. const tableData = ref<EmergencySupplyListResponse[]>([]);
  170. const searchData = reactive({
  171. emergencyType: null,
  172. supplyType: null,
  173. supplyName: null,
  174. park: null,
  175. location: null,
  176. keeperName: null,
  177. status: null,
  178. });
  179. const handleSearch = () => {
  180. emergencySupplyListQuery.queryParam = {};
  181. if (searchData.emergencyType) {
  182. emergencySupplyListQuery.queryParam.emergencyType = searchData.emergencyType;
  183. }
  184. if (searchData.supplyType) {
  185. emergencySupplyListQuery.queryParam.supplyType = searchData.supplyType;
  186. }
  187. if (searchData.supplyName) {
  188. emergencySupplyListQuery.queryParam.supplyName = searchData.supplyName;
  189. }
  190. if (searchData.park) {
  191. emergencySupplyListQuery.queryParam.park = searchData.park;
  192. }
  193. if (searchData.location) {
  194. emergencySupplyListQuery.queryParam.location = searchData.location;
  195. }
  196. if (searchData.keeperName) {
  197. emergencySupplyListQuery.queryParam.keeperName = searchData.keeperName;
  198. }
  199. if (searchData.status !== null) {
  200. emergencySupplyListQuery.queryParam.status = searchData.status;
  201. }
  202. getTableData();
  203. };
  204. const getTableData = async () => {
  205. tableConfig.loading = true;
  206. const res = await getEmergencySupplyList(emergencySupplyListQuery);
  207. tableData.value = res.records;
  208. pagination.total = res.totalRow;
  209. tableConfig.loading = false;
  210. };
  211. const handleSizeChange = (value: number) => {
  212. pagination.pageSize = value;
  213. emergencySupplyListQuery.pageSize = value;
  214. getTableData();
  215. };
  216. const handleCurrentChange = (value: number) => {
  217. pagination.pageNumber = value;
  218. emergencySupplyListQuery.pageNumber = value;
  219. getTableData();
  220. };
  221. const handleDeleteSupply = async (id: number) => {
  222. await deleteEmergencySupplyList(id);
  223. await getTableData();
  224. ElMessage.success('删除成功');
  225. };
  226. const inventoryTaskRef = ref<InstanceType<typeof InventoryTask>>();
  227. const handleInventory = () => {
  228. inventoryTaskRef.value?.openDialog();
  229. };
  230. const defaultRouterName = 'emergency-list-info';
  231. const handleAddSupply = () => {
  232. router.push({
  233. name: defaultRouterName,
  234. query: {
  235. type: 'add',
  236. },
  237. });
  238. };
  239. const handleEditSupply = (id: number) => {
  240. router.push({
  241. name: defaultRouterName,
  242. query: {
  243. id,
  244. },
  245. });
  246. };
  247. const handleViewDetail = (id: number) => {
  248. router.push({
  249. name: 'emergency-list-detail',
  250. params: {
  251. id,
  252. },
  253. });
  254. };
  255. onMounted(() => {
  256. getEmergencyEventDict();
  257. getEmergencySupplyDict();
  258. getParkDict();
  259. getLocationDict('all');
  260. getTableData();
  261. emergencySupplyPermissions.value = Boolean(
  262. permissions.find((item: { code: string }) => item.code === EMERGENCY_PERMISSIONS.SUPPLY_LIST),
  263. );
  264. tableConfig.maxHeight = emergencySupplyPermissions.value
  265. ? SUPPLY_LIST_TABLE_MAX_HEIGHT_PERMISSION
  266. : SUPPLY_LIST_TABLE_MAX_HEIGHT_DEFAULT;
  267. });
  268. </script>
  269. <style scoped lang="scss">
  270. @use '@/styles/page-details-layout.scss' as *;
  271. @use '@/styles/page-main-layout.scss' as *;
  272. @use '@/styles/basic-table-action.scss' as *;
  273. @use './src/styles/page-common.scss' as *;
  274. </style>