index.vue 11 KB

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