index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <a-card>
  3. <a-tabs v-model:activeKey="activeKey">
  4. <a-tab-pane key="pending" tab="待审核"></a-tab-pane>
  5. <a-tab-pane key="approved" tab="已审核"></a-tab-pane>
  6. </a-tabs>
  7. <a-row :gutter="16" style="margin-bottom: 16px">
  8. <a-col :span="2">
  9. <a-select v-model:value="formState.examineStatus" style="width: 100px" placeholder="请选择状态">
  10. <a-select-option value="pending">待审核</a-select-option>
  11. <a-select-option value="approved">已审核</a-select-option>
  12. </a-select>
  13. </a-col>
  14. <a-col :span="4">
  15. <a-select v-model:value="formState.orgName" style="width: 200px" placeholder="请选择组织结构">
  16. <a-select-option value="0">待审核</a-select-option>
  17. <a-select-option value="1">已审核</a-select-option>
  18. </a-select>
  19. </a-col>
  20. <a-col :span="6">
  21. <a-input v-model:value="formState.fileName" placeholder="请输入关键词搜索" />
  22. </a-col>
  23. <a-col :span="6">
  24. <a-button type="primary" @click="handleSearch">搜索</a-button>
  25. <a-button style="margin-left: 8px" @click="handleBatchApprove">批量审核</a-button>
  26. <a-button style="margin-left: 8px" @click="handleExportDetails">导出详情</a-button>
  27. </a-col>
  28. </a-row>
  29. <a-table
  30. :row-selection="rowSelection"
  31. :columns="columns"
  32. :data-source="dataSource"
  33. :pagination="false"
  34. :loading="loading"
  35. >
  36. <template #bodyCell="{ column, record }">
  37. <template v-if="column.key === 'resourceName'">
  38. <div class="resource-item">
  39. <img :src="record.thumbnail" alt="Thumbnail" class="thumbnail" />
  40. <span>{{ record.resourceName }}</span>
  41. </div>
  42. </template>
  43. <template v-else-if="column.key === 'size'">
  44. {{ formatSize(record.size) }}
  45. </template>
  46. <template v-else-if="column.key === 'applicant'">
  47. {{ record.applicant }} ({{ record.applicantAccount }})
  48. </template>
  49. <template v-else-if="column.key === 'applyTime'">
  50. {{ formatDate(record.applyTime) }}
  51. </template>
  52. <template v-else-if="column.key === 'aiAudit'">
  53. <span :style="{ color: record.aiAudit === '审核失败' ? 'red' : 'green' }">{{ record.aiAudit }}</span>
  54. </template>
  55. <template v-else-if="column.key === 'operation'">
  56. <a-button type="link" @click="handleAudit(record, 1)">同意</a-button>
  57. <a-button type="link" style="color: red" @click="handleAudit(record, 0)">驳回</a-button>
  58. </template>
  59. </template>
  60. </a-table>
  61. <a-modal v-model:visible="judgeVisible" title="审核" @ok="handleOk" @cancel="handleCancel">
  62. <p style="text-align: center">
  63. 审核结果:
  64. <a-select
  65. v-model:value="finalResult"
  66. style="width: 100px"
  67. :options="classify_results"
  68. placeholder="请选择审核结果"
  69. >
  70. </a-select>
  71. </p>
  72. </a-modal>
  73. <div class="dis-flex-end margin-top">
  74. <CustomPagination
  75. :total="pagination.total"
  76. :current="pagination.pageNum"
  77. :pageSize="pagination.pageSize"
  78. :showQuickJumper="true"
  79. :showSizeChanger="true"
  80. :showTotal="(total) => `共 ${total} 条数据`"
  81. @change="handlePageChange"
  82. @showSizeChange="handlePageSizeChange"
  83. />
  84. </div>
  85. </a-card>
  86. </template>
  87. <script setup>
  88. import { ref, onMounted } from 'vue'
  89. import InventoryReviewApi from '@/api/InventoryReview.js'
  90. import CustomPagination from '@/components/customPagination.vue'
  91. // 状态管理
  92. const activeKey = ref('pending')
  93. const loading = ref(false)
  94. const judgeVisible = ref(false)
  95. const finalResult = ref(null)
  96. const formState = reactive({
  97. fileName: null,
  98. examineStatus: null,
  99. orgName: null
  100. })
  101. // 表格数据
  102. const columns = [
  103. {
  104. title: '资源名称',
  105. key: 'fileName',
  106. dataIndex: 'fileName',
  107. width: 200,
  108. align: 'center'
  109. },
  110. {
  111. title: '大小',
  112. key: 'fileSizeNum',
  113. dataIndex: 'fileSizeNum',
  114. width: 100,
  115. align: 'center'
  116. },
  117. {
  118. title: '申请人',
  119. key: 'createUser',
  120. dataIndex: 'createUser',
  121. width: 200,
  122. align: 'center'
  123. },
  124. {
  125. title: '组织结构',
  126. key: 'orgName',
  127. dataIndex: 'orgName',
  128. width: 150,
  129. align: 'center'
  130. },
  131. {
  132. title: '申请时间',
  133. key: 'createTime',
  134. dataIndex: 'createTime',
  135. width: 150,
  136. align: 'center'
  137. },
  138. {
  139. title: '智能审核',
  140. key: 'examineReason',
  141. dataIndex: 'examineReason',
  142. width: 100,
  143. align: 'center'
  144. },
  145. {
  146. title: '待审核人',
  147. key: 'auditor',
  148. dataIndex: 'auditor',
  149. width: 150,
  150. align: 'center'
  151. },
  152. {
  153. title: '操作',
  154. key: 'operation',
  155. width: 100,
  156. align: 'center'
  157. }
  158. ]
  159. const dataSource = ref([])
  160. const classify_results = ref([
  161. { value: '1', label: '通过' },
  162. { value: '0', label: '驳回' }
  163. ])
  164. const pagination = reactive({
  165. pageSize: 10,
  166. pageNum: 1,
  167. total: 0
  168. })
  169. //勾选的ID列表
  170. const selectedRowKeys = ref([])
  171. //列表勾选
  172. const rowSelection = computed(() => {
  173. return {
  174. selectedRowKeys: unref(selectedRowKeys),
  175. onChange: onSelectChange,
  176. hideDefaultSelections: true
  177. }
  178. })
  179. //勾选方法
  180. const onSelectChange = (changaRowKeys) => {
  181. selectedRowKeys.value = changaRowKeys
  182. }
  183. // 翻页
  184. const handlePageChange = (page) => {
  185. pagination.pageNum = page
  186. getListData()
  187. }
  188. // 每页条数
  189. const handlePageSizeChange = (pageNum, size) => {
  190. pagination.pageNum = 1
  191. pagination.pageSize = size
  192. getListData()
  193. }
  194. const getListData = () => {
  195. let params = {
  196. pageNum: pagination.pageNum,
  197. pageSize: pagination.pageSize,
  198. orgName: formState.orgName,
  199. examineStatus: formState.examineStatus,
  200. fileName: formState.fileName
  201. }
  202. InventoryReviewApi.queryList(params)
  203. .then((res) => {
  204. console.log(res, '审核列表')
  205. dataSource.value = res.data
  206. pagination.total = res.total
  207. })
  208. .catch((err) => {
  209. console.log(err)
  210. })
  211. }
  212. // 方法
  213. const handleSearch = () => {
  214. // 处理搜索逻辑
  215. getListData()
  216. }
  217. //批量审批
  218. const handleBatchApprove = () => {
  219. judgeVisible.value = true
  220. }
  221. const handleOk = () => {
  222. if (!finalResult.value) {
  223. message.error('请选择审核类型')
  224. }
  225. const idList = selectedRowKeys.value
  226. const params = []
  227. idList.forEach((res) => {
  228. params.push({
  229. id: res,
  230. result: finalResult.value
  231. })
  232. })
  233. loading.value = true
  234. return
  235. }
  236. const handleExportDetails = () => {
  237. // 处理导出详情逻辑
  238. }
  239. const handleAudit = (record, state) => {
  240. // 处理单个审核逻辑
  241. console.log('审核记录:', record)
  242. if (state == 0) {
  243. let params = {
  244. targetId: record.id,
  245. examineReason: 'asdasd'
  246. }
  247. InventoryReviewApi.reject(params)
  248. .then((res) => {
  249. console.log(res, '驳回')
  250. })
  251. .catch((err) => {
  252. console.log(err)
  253. })
  254. } else {
  255. let params = {
  256. targetId: record.id,
  257. examineReason: 'asdasd'
  258. }
  259. InventoryReviewApi.reject(params)
  260. .then((res) => {
  261. console.log(res, '通过')
  262. })
  263. .catch((err) => {
  264. console.log(err)
  265. })
  266. }
  267. }
  268. const formatSize = (size) => {
  269. if (size < 1024) return `${size}B`
  270. else if (size < 1024 * 1024) return `${(size / 1024).toFixed(2)}KB`
  271. else if (size < 1024 * 1024 * 1024) return `${(size / (1024 * 1024)).toFixed(2)}MB`
  272. else return `${(size / (1024 * 1024 * 1024)).toFixed(2)}GB`
  273. }
  274. const formatDate = (dateStr) => {
  275. return new Date(dateStr).toLocaleString()
  276. }
  277. onMounted(() => {
  278. getListData()
  279. })
  280. </script>
  281. <style scoped>
  282. .resource-item {
  283. display: flex;
  284. align-items: center;
  285. }
  286. .thumbnail {
  287. width: 40px;
  288. height: 40px;
  289. margin-right: 8px;
  290. }
  291. @media (max-width: 768px) {
  292. .resource-item {
  293. flex-direction: column;
  294. align-items: flex-start;
  295. }
  296. .thumbnail {
  297. margin-right: 0;
  298. margin-bottom: 8px;
  299. }
  300. }
  301. </style>