ledger.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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.searchValue" 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.projectStage" 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.projectType" 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" :datas="tableData1" />
  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. import mainProApi from '~api/project/project'
  59. //子组件
  60. import HcTableList1 from './modules/project-list.vue'
  61. import HcTableList2 from './modules/gist-list.vue'
  62. //选项卡切换
  63. const tabsKey = ref('1')
  64. const tabsData = ref([
  65. { key: '1', name: '项目资料' },
  66. { key: '2', name: '工作要点' },
  67. ])
  68. const tabsChange = ({ key }) => {
  69. tabsKey.value = key
  70. if (key === '1') {
  71. searchClick1()
  72. } else if (key === '2') {
  73. searchClick2()
  74. }
  75. }
  76. //渲染完成
  77. onMounted(() => {
  78. getDataApi()
  79. })
  80. //获取接口数据
  81. const projectStage = ref([])//项目阶段
  82. const getDataApi = async () => {
  83. projectStage.value = await getDictionaryData('projectStage', true)
  84. getTableData1()
  85. }
  86. //项目类型
  87. const typeData = ref([])
  88. //搜索条件
  89. const searchForm1 = ref({
  90. startYear: '', endYear: '', searchValue: '', projectStage:null, projectType:null,
  91. current: 1, size: 20, total: 0,
  92. })
  93. const searchForm2 = ref({
  94. targetPlan: '', workFocusStage: null,
  95. current: 1, size: 20, total: 0,
  96. })
  97. //搜索
  98. const searchClick1 = () => {
  99. searchForm1.value.current = 1
  100. getTableData1()
  101. }
  102. const searchClick2 = () => {
  103. searchForm2.value.current = 1
  104. getTableData2()
  105. }
  106. //分页
  107. const pageChange1 = ({ current, size }) => {
  108. searchForm1.value.current = current
  109. searchForm1.value.size = size
  110. getTableData1()
  111. }
  112. //分页
  113. const pageChange2 = ({ current, size }) => {
  114. searchForm2.value.current = current
  115. searchForm2.value.size = size
  116. getTableData2()
  117. }
  118. const table1Ref = ref(null)
  119. //表格数据
  120. const tableData2 = ref([])
  121. const tableLoading2 = ref(false)
  122. const tableData1 = ref([])
  123. const tableLoading1 = ref(false)
  124. //表格被选择
  125. const tableCheckKeys1 = ref([])
  126. const tableCheckKeys2 = ref([])
  127. const tableCheck2 = (row) => {
  128. tableCheckKeys2.value = row
  129. }
  130. //获取表格数据
  131. const getTableData2 = async () => {
  132. tableData2.value = []
  133. tableLoading2.value = true
  134. const { error, code, data } = await mainApi.page(searchForm2.value)
  135. //处理数据
  136. tableLoading2.value = false
  137. if (!error && code === 200) {
  138. tableData2.value = getArrValue(data['records'])
  139. searchForm2.value.total = data.total || 0
  140. } else {
  141. tableData2.value = []
  142. searchForm2.value.total = 0
  143. }
  144. }
  145. //获取表格数据
  146. const getTableData1 = async () => {
  147. tableData1.value = []
  148. tableLoading1.value = true
  149. const { error, code, data } = await mainProApi.page(searchForm1.value)
  150. //处理数据
  151. tableLoading2.value = false
  152. if (!error && code === 200) {
  153. tableData1.value = getArrValue(data['records'])
  154. searchForm1.value.total = data.total || 0
  155. } else {
  156. tableData1.value = []
  157. searchForm1.value.total = 0
  158. }
  159. }
  160. //名称被点击
  161. const rowNameClick2 = (row) => {
  162. console.log(row)
  163. }
  164. //批量导出
  165. const deriveTableItem1 = async (_, resolve) => {
  166. resolve()
  167. }
  168. //批量导出
  169. const deriveTableItem2 = async (_, resolve) => {
  170. const ids = arrToId(tableCheckKeys2.value)
  171. const { error, val } = await mainApi.exportWorkfocus(ids)
  172. if (error) {
  173. window.$message?.error('数据异常')
  174. resolve()
  175. return
  176. }
  177. await newDownBlob(val)
  178. resolve()
  179. }
  180. </script>
  181. <style lang="scss">
  182. @import '~src/styles/project/ledger';
  183. </style>