AdminBatchesView.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div class="admin-batches-view">
  3. <PagePanel title="批次管理">
  4. <p class="tip">
  5. 全区批次运维查询。「已归档」多为重复/作废残留。删除会摘离明细并从列表隐藏。日常业务仍由各岗位办理。
  6. </p>
  7. <div class="query-panel">
  8. <el-form :inline="true" size="small">
  9. <el-form-item label="发放年月">
  10. <el-input v-model="q.payMonth" clearable placeholder="yyyyMM" style="width: 120px" />
  11. </el-form-item>
  12. <el-form-item label="街镇">
  13. <el-select v-model="q.townId" clearable style="width: 140px" @change="onTown">
  14. <el-option v-for="t in towns" :key="t.id" :label="t.name" :value="t.id" />
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="村居">
  18. <el-select v-model="q.villageId" clearable style="width: 140px">
  19. <el-option v-for="v in villages" :key="v.id" :label="v.name" :value="v.id" />
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="级别">
  23. <el-select v-model="q.batchLevel" clearable style="width: 110px">
  24. <el-option label="村级" value="VILLAGE" />
  25. <el-option label="镇级" value="TOWN" />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button type="primary" @click="search">查询</el-button>
  30. <el-button @click="reset">重置</el-button>
  31. </el-form-item>
  32. </el-form>
  33. </div>
  34. <el-table v-loading="loading" :data="pagedList" border stripe size="small">
  35. <el-table-column prop="id" label="批次ID" min-width="140" show-overflow-tooltip />
  36. <el-table-column prop="payMonth" label="发放年月" width="100" align="center" />
  37. <el-table-column label="级别" width="70" align="center">
  38. <template #default="{ row }">{{ row.batchLevel === 'TOWN' ? '镇' : '村' }}</template>
  39. </el-table-column>
  40. <el-table-column prop="town" label="街镇" width="100" />
  41. <el-table-column prop="village" label="村居" width="100" />
  42. <el-table-column prop="peopleCount" label="人数" width="70" align="center" />
  43. <el-table-column label="合计" width="110" align="right">
  44. <template #default="{ row }">{{ formatAmt(row.totalAmount) }}</template>
  45. </el-table-column>
  46. <el-table-column prop="status" label="状态" width="140" show-overflow-tooltip />
  47. <el-table-column prop="currentStage" label="阶段" width="150" show-overflow-tooltip />
  48. <el-table-column label="操作" width="200" align="center" fixed="right">
  49. <template #default="{ row }">
  50. <el-button link type="primary" size="small" @click="open(row, 'detail')">详情</el-button>
  51. <el-button link type="primary" size="small" @click="open(row, 'flow')">流程</el-button>
  52. <el-button link type="danger" size="small" @click="onDelete(row)">删除</el-button>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <TablePagination v-model:page="page" v-model:page-size="pageSize" :total="total" />
  57. </PagePanel>
  58. <BatchDetailDrawer
  59. v-model="drawer"
  60. :batch-id="drawerId"
  61. :initial-tab="drawerTab"
  62. />
  63. </div>
  64. </template>
  65. <script setup lang="ts">
  66. import { onMounted, reactive, ref } from 'vue'
  67. import { ElMessage, ElMessageBox } from 'element-plus'
  68. import PagePanel from '@/components/common/PagePanel.vue'
  69. import TablePagination from '@/components/common/TablePagination.vue'
  70. import BatchDetailDrawer from '@/components/biz/BatchDetailDrawer.vue'
  71. import { listRegionsAdmin, pageAdminBatches, purgeBatchAdmin } from '@/api/biz'
  72. import { useClientPagination } from '@/composables/useClientPagination'
  73. import type { RegionRow } from '@/api/sjnmtybt/regionStore'
  74. type AdminBatch = {
  75. id: string
  76. payMonth: string
  77. batchLevel: string
  78. town: string
  79. village: string
  80. peopleCount: number
  81. totalAmount: number
  82. status: string
  83. currentStage: string
  84. }
  85. const q = reactive({
  86. payMonth: '',
  87. townId: '',
  88. villageId: '',
  89. batchLevel: '',
  90. })
  91. const list = ref<AdminBatch[]>([])
  92. const towns = ref<RegionRow[]>([])
  93. const villages = ref<RegionRow[]>([])
  94. const loading = ref(false)
  95. const drawer = ref(false)
  96. const drawerId = ref('')
  97. const drawerTab = ref<'detail' | 'flow'>('detail')
  98. const { page, pageSize, total, pagedList, resetPage } = useClientPagination(list)
  99. function formatAmt(n: number) {
  100. return Number(n || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
  101. }
  102. async function onTown() {
  103. q.villageId = ''
  104. villages.value = q.townId
  105. ? await listRegionsAdmin({ level: 'VILLAGE', parentId: q.townId })
  106. : []
  107. }
  108. async function search() {
  109. loading.value = true
  110. try {
  111. list.value = (await pageAdminBatches({
  112. payMonth: q.payMonth || undefined,
  113. townId: q.townId || undefined,
  114. villageId: q.villageId || undefined,
  115. batchLevel: q.batchLevel || undefined,
  116. })) as AdminBatch[]
  117. resetPage()
  118. } finally {
  119. loading.value = false
  120. }
  121. }
  122. function reset() {
  123. q.payMonth = ''
  124. q.townId = ''
  125. q.villageId = ''
  126. q.batchLevel = ''
  127. villages.value = []
  128. search()
  129. }
  130. function open(row: AdminBatch, tab: 'detail' | 'flow') {
  131. drawerId.value = row.id
  132. drawerTab.value = tab
  133. drawer.value = true
  134. }
  135. async function onDelete(row: AdminBatch) {
  136. try {
  137. await ElMessageBox.confirm(
  138. `确认删除批次 ${row.id}?将软摘离明细并隐藏该批次。`,
  139. '删除批次',
  140. { type: 'warning', confirmButtonText: '确认删除' },
  141. )
  142. } catch {
  143. return
  144. }
  145. await purgeBatchAdmin(row.id)
  146. ElMessage.success('批次已删除')
  147. await search()
  148. }
  149. onMounted(async () => {
  150. towns.value = await listRegionsAdmin({ level: 'TOWN', parentId: 'D_SJ' })
  151. await search()
  152. })
  153. </script>
  154. <style scoped lang="less">
  155. .tip {
  156. margin: 0 0 10px;
  157. font-size: 12px;
  158. color: @text-secondary;
  159. line-height: 1.5;
  160. }
  161. .query-panel {
  162. margin-bottom: 10px;
  163. }
  164. </style>