archiveList.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <div class="archive-list">
  3. <div v-if="activeTab == 'list'">
  4. <!-- 搜索表单 -->
  5. <div class="search-panel">
  6. <el-form :inline="true" :model="searchForm" class="search-form">
  7. <el-form-item label="年度:" prop="projectYear">
  8. <el-date-picker
  9. v-model="searchForm.projectYear"
  10. type="year"
  11. placeholder="选择年"
  12. format="yyyy"
  13. value-format="yyyy"
  14. ></el-date-picker>
  15. </el-form-item>
  16. <el-form-item label="监审项目名称:">
  17. <el-input
  18. v-model="searchForm.projectName"
  19. placeholder="请输入监审项目名称"
  20. clearable
  21. style="width: 200px"
  22. ></el-input>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button type="primary" @click="handleSearch">搜索</el-button>
  26. <el-button plain type="primary" @click="handleReset">
  27. 重置
  28. </el-button>
  29. </el-form-item>
  30. </el-form>
  31. </div>
  32. <!-- 数据表格 -->
  33. <el-table
  34. v-loading="loading"
  35. :data="tableData"
  36. style="width: 100%"
  37. border
  38. default-expand-all
  39. row-key="id"
  40. :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
  41. >
  42. <el-table-column
  43. type="index"
  44. label="序号"
  45. width="80"
  46. header-align="center"
  47. align="center"
  48. >
  49. <template slot-scope="scope">
  50. <!-- 只显示父节点的序号 -->
  51. <span v-if="scope.row.children || !scope.row.isSubTask">
  52. {{ getParentNodeIndex(scope.row) }}
  53. </span>
  54. <span v-else></span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column
  58. prop="year"
  59. label="立项年度"
  60. width="100"
  61. header-align="center"
  62. align="center"
  63. />
  64. <el-table-column
  65. prop="projectName"
  66. label="成本监审项目名称"
  67. show-overflow-tooltip
  68. header-align="center"
  69. align="left"
  70. >
  71. <template slot-scope="scope">
  72. <div class="cell-content cell-content--left">
  73. <span class="project-link" @click="handleDetail(scope.row)">
  74. {{ scope.row.projectName }}
  75. </span>
  76. </div>
  77. </template>
  78. </el-table-column>
  79. <el-table-column
  80. prop="auditObject"
  81. label="监审对象"
  82. header-align="center"
  83. align="left"
  84. />
  85. <el-table-column
  86. prop="auditPeriod"
  87. label="监审期间"
  88. header-align="center"
  89. align="center"
  90. width="200"
  91. />
  92. <el-table-column
  93. prop="source"
  94. label="立项来源"
  95. header-align="center"
  96. align="center"
  97. width="120"
  98. />
  99. <el-table-column
  100. prop="form"
  101. label="监审形式"
  102. header-align="center"
  103. align="center"
  104. width="120"
  105. />
  106. <el-table-column label="操作" align="center" width="200" fixed="right">
  107. <template slot-scope="scope">
  108. <span class="action-buttons">
  109. <el-button
  110. type="text"
  111. size="small"
  112. @click="handleTaskDetail(scope.row)"
  113. >
  114. 任务详情
  115. </el-button>
  116. <el-button
  117. type="text"
  118. size="small"
  119. @click="handleView(scope.row)"
  120. >
  121. 查看
  122. </el-button>
  123. </span>
  124. </template>
  125. </el-table-column>
  126. </el-table>
  127. <el-pagination
  128. style="margin-top: 10px"
  129. background
  130. layout="total, sizes, prev, pager, next"
  131. :current-page="pagination.currentPage"
  132. :page-sizes="[10, 20, 30, 40]"
  133. :page-size="pagination.pageSize"
  134. :total="pagination.total"
  135. @current-change="handleCurrentChange"
  136. @size-change="handleSizeChange"
  137. />
  138. </div>
  139. <!-- 任务详情弹窗 -->
  140. <taskDetail ref="taskDetail" />
  141. </div>
  142. </template>
  143. <script>
  144. import taskDetail from '@/components/task/taskDetail.vue'
  145. import { getArchiveList } from '@/api/audit/archive'
  146. export default {
  147. name: 'ArchiveList',
  148. components: {
  149. taskDetail,
  150. },
  151. data() {
  152. return {
  153. searchForm: {
  154. projectYear: '2025',
  155. projectName: '',
  156. },
  157. loading: false,
  158. tableData: [],
  159. // 分页配置
  160. pagination: {
  161. currentPage: 1,
  162. pageSize: 10,
  163. total: 0,
  164. },
  165. activeTab: 'list',
  166. }
  167. },
  168. created() {
  169. this.fetchData()
  170. },
  171. methods: {
  172. // 获取父节点的连续序号
  173. getParentNodeIndex(row) {
  174. // 过滤出所有父节点
  175. const parentNodes = this.tableData.filter(
  176. (item) =>
  177. (item.children && item.children.length > 0) || !item.isSubTask
  178. )
  179. // 找到当前行在父节点数组中的索引
  180. const index = parentNodes.findIndex((item) => item.id === row.id)
  181. // 返回序号(索引+1)
  182. return index + 1
  183. },
  184. // 获取数据
  185. async fetchData() {
  186. try {
  187. this.loading = true
  188. const params = {
  189. currentPage: this.pagination.currentPage,
  190. pageSize: this.pagination.pageSize,
  191. projectYear: this.searchForm.projectYear,
  192. projectName: this.searchForm.projectName,
  193. isGd: 1, // 已归档
  194. }
  195. const response = await getArchiveList(params)
  196. // 根据API返回格式处理数据
  197. if (response && response.value) {
  198. // 获取记录列表
  199. const records = response.value.records || []
  200. // 转换数据格式,将childTasks转换为children以适应表格组件
  201. this.tableData = records.map((record) => {
  202. return {
  203. id: record.id,
  204. year: record.projectYear || record.year || '',
  205. projectName: record.projectName,
  206. auditObject: record.auditedUnitName || record.auditObject || '',
  207. auditPeriod: record.auditPeriod || '',
  208. source: this.getSourceTypeText(record.sourceType),
  209. form: this.getAuditTypeText(record.auditType),
  210. isSubTask: record.pid && record.pid !== '0',
  211. projectId: record.projectId,
  212. auditedUnitId: record.auditedUnitId,
  213. taskId: record.id,
  214. children: record.childTasks
  215. ? record.childTasks.map((child) => ({
  216. id: child.id,
  217. year: '',
  218. projectName: child.projectName,
  219. auditObject: child.auditedUnitName || '',
  220. auditPeriod: record.auditPeriod || '', // 子任务可能使用父任务的审核期间
  221. source: '',
  222. form: '',
  223. isSubTask: true,
  224. projectId: child.projectId,
  225. auditedUnitId: child.auditedUnitId,
  226. taskId: child.id,
  227. }))
  228. : [],
  229. }
  230. })
  231. // 设置总数
  232. this.pagination.total = response.value.total || 0
  233. } else {
  234. this.tableData = []
  235. this.pagination.total = 0
  236. }
  237. } catch (error) {
  238. // this.$message.error('加载列表失败')
  239. console.error('加载列表失败:', error)
  240. this.tableData = []
  241. this.pagination.total = 0
  242. } finally {
  243. this.loading = false
  244. }
  245. },
  246. // 获取来源类型文本
  247. getSourceTypeText(type) {
  248. const typeMap = {
  249. 1: '年度计划内',
  250. 2: '年度计划外',
  251. }
  252. return typeMap[type] || type || ''
  253. },
  254. // 获取审核类型文本
  255. getAuditTypeText(type) {
  256. const typeMap = {
  257. 1: '定期监审',
  258. 2: '定调价监审',
  259. }
  260. return typeMap[type] || type || ''
  261. },
  262. handleSearch() {
  263. this.pagination.currentPage = 1
  264. this.fetchData()
  265. },
  266. handleReset() {
  267. this.searchForm = {
  268. projectYear: '2025',
  269. projectName: '',
  270. }
  271. this.pagination.currentPage = 1
  272. this.fetchData()
  273. },
  274. // 处理分页变化
  275. handleCurrentChange(current) {
  276. this.pagination.currentPage = current
  277. this.fetchData()
  278. },
  279. handleSizeChange(size) {
  280. this.pagination.pageSize = size
  281. this.pagination.currentPage = 1
  282. this.fetchData()
  283. },
  284. handleDetail(row) {
  285. // 可以在这里处理详情点击
  286. console.log('详情:', row)
  287. },
  288. handleTaskDetail(row) {
  289. // 打开任务详情弹窗
  290. this.$refs.taskDetail.open(row, 'chengben')
  291. },
  292. handleView(row) {
  293. // 查看操作,可以打开查看弹窗或跳转
  294. console.log('查看:', row)
  295. this.$message.info('查看功能待实现')
  296. },
  297. backToList() {
  298. this.activeTab = 'list'
  299. },
  300. },
  301. }
  302. </script>
  303. <style scoped lang="scss">
  304. .archive-list {
  305. padding: 20px;
  306. }
  307. .search-panel {
  308. margin-bottom: 20px;
  309. padding: 20px;
  310. background-color: #f5f7fa;
  311. border-radius: 4px;
  312. }
  313. .action-buttons {
  314. display: inline-flex;
  315. gap: 8px;
  316. }
  317. .action-link {
  318. color: #409eff;
  319. cursor: pointer;
  320. text-decoration: none;
  321. transition: color 0.3s;
  322. &:hover {
  323. color: #66b1ff;
  324. text-decoration: underline;
  325. }
  326. }
  327. .project-link {
  328. color: #409eff;
  329. cursor: pointer;
  330. text-decoration: none;
  331. transition: color 0.3s;
  332. &:hover {
  333. color: #66b1ff;
  334. text-decoration: underline;
  335. }
  336. }
  337. </style>