ledger.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <hc-tab-card w-to="1450" :tabs="tabsData" :tab-key="tabsKey" class="hc-project-ledger-page" @change="tabsChange">
  3. <template #extraToSearch>
  4. <div v-if="tabsKey === '1'" class="hc-flex">
  5. <hc-date-year v-model="searchForm1.startYear" v-model:end="searchForm1.endYear" />
  6. <div class="relative ml-3 w-[300px]">
  7. <hc-search-input v-model="searchForm1.queryValue" text="搜索" color="#151921" @search="searchClick1">
  8. <template #prepend>
  9. <el-select v-model="searchForm1.year" placeholder="年份" clearable style="width: 80px">
  10. <el-option label="2023" value="2023" />
  11. <el-option label="2024" value="2024" />
  12. </el-select>
  13. </template>
  14. </hc-search-input>
  15. </div>
  16. </div>
  17. </template>
  18. <template #extra>
  19. <div v-if="tabsKey === '1'" class="hc-flex">
  20. <div class="ml-6 w-[120px]">
  21. <el-select v-model="searchForm1.key1" filterable clearable block placeholder="项目阶段" @change="searchClick1">
  22. <el-option v-for="item in projectStage" :key="item.value" :label="item.label" :value="item.value" />
  23. </el-select>
  24. </div>
  25. <div class="ml-2 w-[100px]">
  26. <el-select v-model="searchForm1.key2" filterable clearable block placeholder="项目类型" @change="searchClick1">
  27. <el-option v-for="item in typeData" :key="item.value" :label="item.label" :value="item.value" />
  28. </el-select>
  29. </div>
  30. <el-button v-yes-com:[deriveTableItem1] :disabled="tableCheckKeys1.length <= 0" type="primary" class="ml-2">批量导出</el-button>
  31. </div>
  32. <div v-if="tabsKey === '2'" class="hc-flex">
  33. <hc-date-year v-model="searchForm2.startYear" v-model:end="searchForm2.endYear" />
  34. <div class="relative ml-3 w-[260px]">
  35. <hc-search-input v-model="searchForm2.targetPlan" color="#151921" text="搜索" @search="searchClick2" />
  36. </div>
  37. <div class="ml-6 w-[120px]">
  38. <el-select v-model="searchForm2.workFocusStage" filterable clearable block placeholder="项目阶段" @change="searchClick2">
  39. <el-option v-for="item in projectStage" :key="item.value" :label="item.label" :value="item.value" />
  40. </el-select>
  41. </div>
  42. <el-button v-yes-com:[deriveTableItem2] :disabled="tableCheckKeys2.length <= 0" type="primary" class="ml-2">批量导出</el-button>
  43. </div>
  44. </template>
  45. <HcTableList1 v-if="tabsKey === '1'" ref="table1Ref" />
  46. <HcTableList2 v-if="tabsKey === '2'" :datas="tableData2" :loading="tableLoading2" @tap="rowNameClick2" @check="tableCheck2" @change="searchClick2" />
  47. <template #action>
  48. <hc-pages v-if="tabsKey === '1'" :pages="searchForm1" @change="pageChange1" />
  49. <hc-pages v-if="tabsKey === '2'" :pages="searchForm2" @change="pageChange2" />
  50. </template>
  51. </hc-tab-card>
  52. </template>
  53. <script setup>
  54. import { onMounted, ref } from 'vue'
  55. import { getDictionaryData } from '~src/utils/tools'
  56. import { arrToId, getArrValue, newDownBlob } from 'js-fast-way'
  57. import mainApi from '~api/project/gist'
  58. //子组件
  59. import HcTableList1 from './modules/project-list.vue'
  60. import HcTableList2 from './modules/gist-list.vue'
  61. //选项卡切换
  62. const tabsKey = ref('1')
  63. const tabsData = ref([
  64. { key: '1', name: '项目资料' },
  65. { key: '2', name: '工作要点' },
  66. ])
  67. const tabsChange = ({ key }) => {
  68. tabsKey.value = key
  69. if (key === '1') {
  70. searchClick1()
  71. } else if (key === '2') {
  72. searchClick2()
  73. }
  74. }
  75. //渲染完成
  76. onMounted(() => {
  77. getDataApi()
  78. })
  79. //获取接口数据
  80. const projectStage = ref([])//项目阶段
  81. const getDataApi = async () => {
  82. projectStage.value = await getDictionaryData('projectStage', true)
  83. }
  84. //项目类型
  85. const typeData = ref([{ value: '1', label: '铁路' }, { value: '2', label: '高速公路' }])
  86. //搜索条件
  87. const searchForm1 = ref({
  88. startYear: '', endYear: '', queryValue: '', year: '',
  89. current: 1, size: 20, total: 0,
  90. })
  91. const searchForm2 = ref({
  92. targetPlan: '', workFocusStage: null,
  93. current: 1, size: 20, total: 0,
  94. })
  95. //搜索
  96. const searchClick1 = () => {
  97. }
  98. const searchClick2 = () => {
  99. searchForm2.value.current = 1
  100. getTableData2()
  101. }
  102. //分页
  103. const pageChange1 = ({ current, size }) => {
  104. searchForm1.value.current = current
  105. searchForm1.value.size = size
  106. }
  107. //分页
  108. const pageChange2 = ({ current, size }) => {
  109. searchForm2.value.current = current
  110. searchForm2.value.size = size
  111. getTableData2()
  112. }
  113. const table1Ref = ref(null)
  114. //表格数据
  115. const tableData2 = ref([])
  116. const tableLoading2 = ref(false)
  117. //表格被选择
  118. const tableCheckKeys1 = ref([])
  119. const tableCheckKeys2 = ref([])
  120. const tableCheck2 = (row) => {
  121. tableCheckKeys2.value = row
  122. }
  123. //获取表格数据
  124. const getTableData2 = async () => {
  125. tableData2.value = []
  126. tableLoading2.value = true
  127. const { error, code, data } = await mainApi.page(searchForm2.value)
  128. //处理数据
  129. tableLoading2.value = false
  130. if (!error && code === 200) {
  131. tableData2.value = getArrValue(data['records'])
  132. searchForm2.value.total = data.total || 0
  133. } else {
  134. tableData2.value = []
  135. searchForm2.value.total = 0
  136. }
  137. }
  138. //名称被点击
  139. const rowNameClick2 = (row) => {
  140. console.log(row)
  141. }
  142. //批量导出
  143. const deriveTableItem1 = async (_, resolve) => {
  144. resolve()
  145. }
  146. //批量导出
  147. const deriveTableItem2 = async (_, resolve) => {
  148. const ids = arrToId(tableCheckKeys2.value)
  149. const { error, val } = await mainApi.exportWorkfocus(ids)
  150. if (error) {
  151. window.$message?.error('数据异常')
  152. resolve()
  153. return
  154. }
  155. await newDownBlob(val)
  156. resolve()
  157. }
  158. </script>
  159. <style lang="scss">
  160. @import '~src/styles/project/ledger';
  161. </style>