internal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <HcNewCard>
  3. <template #header>
  4. <div class="absolute inset-0" style="height: 32px; top: -14px">
  5. <div class="relative w-full ">
  6. <el-scrollbar>
  7. <div class="relative whitespace-nowrap">
  8. <div class="w-32 inline-block">
  9. <el-select v-model="searchInternalForm.taskStatus" clearable placeholder="审批状态">
  10. <el-option v-for="item in InternalApproval" :key="item.value" :label="item.label" :value="item.value" />
  11. </el-select>
  12. </div>
  13. <div class="w-32 ml-2 inline-block">
  14. <el-select v-model="searchInternalForm.isEvaluate" clearable placeholder="是否评定">
  15. <el-option v-for="item in InternalAssess" :key="item.value" :label="item.label" :value="item.value" />
  16. </el-select>
  17. </div>
  18. <div class="w-32 ml-2 inline-block">
  19. <el-select v-model="searchInternalForm.reportNumber" clearable placeholder="上报批次">
  20. <el-option v-for="item in InternalReportBatch" :key="item" :label="item" :value="item" />
  21. </el-select>
  22. </div>
  23. <div class="w-32 ml-2 inline-block">
  24. <el-select v-model="searchInternalForm.isExperiment" clearable placeholder="关联试验">
  25. <el-option v-for="item in InternalAssociation" :key="item.value" :label="item.label" :value="item.value" />
  26. </el-select>
  27. </div>
  28. <div class="w-60 ml-2 inline-block">
  29. <el-input v-model="searchInternalForm.queryStr" clearable placeholder="请输入名称关键词检索" @keyup="searchInternalKeyUp" />
  30. </div>
  31. <div class="ml-2 inline-block">
  32. <el-button type="primary" @click="searchInternalClick">
  33. <HcIcon name="search-2" />
  34. <span>搜索</span>
  35. </el-button>
  36. </div>
  37. </div>
  38. </el-scrollbar>
  39. </div>
  40. </div>
  41. </template>
  42. <template #extra>
  43. <HcTooltip keys="write_industry_download">
  44. <el-button :disabled="tableInternalKeys.length <= 0" :loading="downloadLoading" hc-btn type="primary" @click="batchDownload">
  45. <HcIcon name="download" />
  46. <span>下载</span>
  47. </el-button>
  48. </HcTooltip>
  49. <HcTooltip keys="write_industry_print">
  50. <el-button :disabled="tableInternalKeys.length <= 0" :loading="printLoading" hc-btn @click="batchPrint">
  51. <HcIcon name="printer" />
  52. <span>打印</span>
  53. </el-button>
  54. </HcTooltip>
  55. </template>
  56. <HcTable
  57. ref="tableInternalRef" :column="tableInternalColumn" :datas="tableInternalData" :loading="tableInternalLoading"
  58. is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
  59. @selection-change="tableInternalSelection"
  60. >
  61. <template #taskStatus="{ row }">
  62. <el-tag v-if="row.taskStatus === '已审批'" class="mx-1" effect="dark" type="success">已审批</el-tag>
  63. <el-tag v-if="row.taskStatus === '待审批'" class="mx-1" effect="dark" type="danger">待审批</el-tag>
  64. <el-tag v-if="row.taskStatus === '未上报'" class="mx-1" effect="dark" type="warning">未上报</el-tag>
  65. </template>
  66. <template #isEvaluate="{ row }">
  67. <el-tag v-if="row.isEvaluate" class="mx-1" effect="dark" type="success">是</el-tag>
  68. <el-tag v-else class="mx-1" effect="dark" type="info">否</el-tag>
  69. </template>
  70. <template #reportNumber="{ row }">
  71. {{ row.reportNumber === '-1' || row.reportNumber === '0' ? '' : row.reportNumber }}
  72. </template>
  73. <template #isExperiment="{ row }">
  74. <el-tag v-if="row.isExperiment" class="mx-1" effect="dark" type="success">是</el-tag>
  75. <el-tag v-else class="mx-1" effect="dark" type="info">否</el-tag>
  76. </template>
  77. </HcTable>
  78. <template #action>
  79. <HcPages :pages="searchInternalForm" @change="pageInternalChange" />
  80. </template>
  81. </HcNewCard>
  82. </template>
  83. <script setup>
  84. import { nextTick, ref, watch } from 'vue'
  85. import internalApi from '~api/ledger/internal'
  86. import queryApi from '~api/data-fill/query'
  87. import { arrToId, downloadBlob, getArrValue, isString } from 'js-fast-way'
  88. import { toPdfPage } from '~uti/btn-auth'
  89. //参数
  90. const props = defineProps({
  91. projectId: {
  92. type: [String, Number],
  93. default: '',
  94. },
  95. contractId: {
  96. type: [String, Number],
  97. default: '',
  98. },
  99. treeData: {
  100. type: Object,
  101. default: () => ({}),
  102. },
  103. })
  104. //变量
  105. const projectId = ref(props.projectId)
  106. const contractId = ref(props.contractId)
  107. const nodeData = ref(props.treeData)
  108. //监听
  109. watch(() => [
  110. props.treeData,
  111. ], ([treeData]) => {
  112. nodeData.value = treeData
  113. setQueryData(treeData)
  114. })
  115. //渲染完成
  116. nextTick(() => {
  117. setQueryData(props.treeData)
  118. queryBatchList()
  119. })
  120. //获取相关数据
  121. const setQueryData = (data) => {
  122. const cid = data?.contractIdRelation || ''
  123. const wbsId = data['contractIdRelation'] ? data['id'] : data['primaryKeyId']
  124. if (wbsId) {
  125. searchInternalForm.value.contractId = cid ? cid : contractId.value
  126. searchInternalForm.value.contractIdRelation = data['contractIdRelation']
  127. searchInternalForm.value.wbsIds = [wbsId]
  128. searchInternalClick()
  129. }
  130. }
  131. //审批状态
  132. const InternalApproval = ref([
  133. { label: '未上报', value: '0' },
  134. { label: '待审批', value: '1' },
  135. { label: '已审批', value: '2' },
  136. ])
  137. //是否评定
  138. const InternalAssess = ref([
  139. { label: '是', value: true },
  140. { label: '否', value: false },
  141. ])
  142. //上报批次
  143. const InternalReportBatch = ref([
  144. // {label: "1", value: 1},
  145. // {label: "2", value: 2},
  146. // {label: "3", value: 3},
  147. ])
  148. //获取上报批次
  149. const queryBatchList = async () => {
  150. if (contractId.value) {
  151. // const { error, code, data } = await internalApi.queryBatchList({
  152. // projectId: projectId.value,
  153. // contractId: contractId.value || ''
  154. // })
  155. const { error, code, data } = await queryApi.getReportNumber({
  156. projectId: projectId.value,
  157. contractId: contractId.value || '',
  158. type: 1,
  159. })
  160. if (!error && code === 200) {
  161. InternalReportBatch.value = getArrValue(data)
  162. } else {
  163. InternalReportBatch.value = []
  164. }
  165. } else {
  166. InternalReportBatch.value = []
  167. }
  168. }
  169. //是否关联试验
  170. const InternalAssociation = ref([
  171. { label: '是', value: true },
  172. { label: '否', value: false },
  173. ])
  174. //搜索表单
  175. const searchInternalForm = ref({
  176. taskStatus: null, isEvaluate: null, reportNumber: null, isExperiment: null,
  177. current: 1, size: 20, total: 0,
  178. })
  179. //回车
  180. const searchInternalKeyUp = (e) => {
  181. if (e.key === 'Enter') {
  182. searchInternalClick()
  183. }
  184. }
  185. //搜索
  186. const searchInternalClick = () => {
  187. if (searchInternalForm.value?.wbsIds) {
  188. searchInternalForm.value.current = 1
  189. getTableInternalData()
  190. } else {
  191. window?.$message?.warning('请先选择一个树节点')
  192. }
  193. }
  194. //分页被点击
  195. const pageInternalChange = ({ current, size }) => {
  196. searchInternalForm.value.current = current
  197. searchInternalForm.value.size = size
  198. getTableInternalData()
  199. }
  200. //内业台账表头
  201. const tableInternalRef = ref(null)
  202. const tableInternalColumn = ref([
  203. { key: 'unitProject', name: '单位工程' },
  204. { key: 'partProject', name: '分部工程' },
  205. { key: 'partChildProject', name: '子分部工程' },
  206. { key: 'subentryProject', name: '分项工程' },
  207. { key: 'subentryChildProject', name: '子分项工程' },
  208. { key: 'process', name: '工序' },
  209. { key: 'taskStatus', name: '审批状态', width: 120, align: 'center' },
  210. { key: 'reportNumber', name: '上报批次', width: 100, align: 'center' },
  211. { key: 'isEvaluate', name: '是否评定', width: 100, align: 'center' },
  212. { key: 'isExperiment', name: '关联试验', width: 100, align: 'center' },
  213. ])
  214. const tableInternalData = ref([])
  215. //获取数据
  216. const tableInternalLoading = ref(false)
  217. const getTableInternalData = async () => {
  218. tableInternalLoading.value = true
  219. const { error, code, data } = await internalApi.queryInternalPage({
  220. ...searchInternalForm.value,
  221. projectId: projectId.value,
  222. })
  223. //判断状态
  224. tableInternalLoading.value = false
  225. if (!error && code === 200) {
  226. tableInternalData.value = getArrValue(data['records'])
  227. searchInternalForm.value.total = data['total'] || 0
  228. } else {
  229. tableInternalData.value = []
  230. searchInternalForm.value.total = 0
  231. }
  232. }
  233. //多选
  234. const tableInternalKeys = ref([])
  235. const tableInternalSelection = (rows) => {
  236. tableInternalKeys.value = rows.filter((item) => {
  237. return (item ?? '') !== ''
  238. })
  239. }
  240. //下载
  241. const downloadLoading = ref(false)
  242. const batchDownload = async () => {
  243. const rows = tableInternalKeys.value
  244. console.log(rows, 'rows')
  245. const ids = arrToId(rows)
  246. //批量下载
  247. downloadLoading.value = true
  248. const { error, disposition, res } = await queryApi.batchDownloadFileToZip({ ids: ids })
  249. //处理数据
  250. downloadLoading.value = false
  251. if (!error) {
  252. if (disposition) {
  253. downloadBlob(res, disposition)
  254. } else {
  255. window.$message?.error('选择的资料未生成文件')
  256. }
  257. }
  258. }
  259. //打印
  260. const printLoading = ref(false)
  261. const batchPrint = async () => {
  262. const rows = tableInternalKeys.value
  263. const ids = arrToId(rows)
  264. //批量下载
  265. printLoading.value = true
  266. const { error, code, data } = await queryApi.batchPrint({ ids: ids })
  267. //处理数据
  268. printLoading.value = false
  269. const res = isString(data) ? data ?? '' : ''
  270. if (!error && code === 200 && res) {
  271. toPdfPage(res)
  272. //window.open(res, '_blank')
  273. }
  274. }
  275. </script>