internal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. //参数
  89. const props = defineProps({
  90. projectId: {
  91. type: [String, Number],
  92. default: '',
  93. },
  94. contractId: {
  95. type: [String, Number],
  96. default: '',
  97. },
  98. treeData: {
  99. type: Object,
  100. default: () => ({}),
  101. },
  102. })
  103. //变量
  104. const projectId = ref(props.projectId)
  105. const contractId = ref(props.contractId)
  106. const nodeData = ref(props.treeData)
  107. //监听
  108. watch(() => [
  109. props.treeData,
  110. ], ([treeData]) => {
  111. nodeData.value = treeData
  112. setQueryData(treeData)
  113. })
  114. //渲染完成
  115. nextTick(() => {
  116. setQueryData(props.treeData)
  117. queryBatchList()
  118. })
  119. //获取相关数据
  120. const setQueryData = (data) => {
  121. const cid = data?.contractIdRelation || ''
  122. const wbsId = data['contractIdRelation'] ? data['id'] : data['primaryKeyId']
  123. if (wbsId) {
  124. searchInternalForm.value.contractId = cid ? cid : contractId.value
  125. searchInternalForm.value.contractIdRelation = data['contractIdRelation']
  126. searchInternalForm.value.wbsIds = [wbsId]
  127. searchInternalClick()
  128. }
  129. }
  130. //审批状态
  131. const InternalApproval = ref([
  132. { label: '未上报', value: '0' },
  133. { label: '待审批', value: '1' },
  134. { label: '已审批', value: '2' },
  135. ])
  136. //是否评定
  137. const InternalAssess = ref([
  138. { label: '是', value: true },
  139. { label: '否', value: false },
  140. ])
  141. //上报批次
  142. const InternalReportBatch = ref([
  143. // {label: "1", value: 1},
  144. // {label: "2", value: 2},
  145. // {label: "3", value: 3},
  146. ])
  147. //获取上报批次
  148. const queryBatchList = async () => {
  149. if (contractId.value) {
  150. // const { error, code, data } = await internalApi.queryBatchList({
  151. // projectId: projectId.value,
  152. // contractId: contractId.value || ''
  153. // })
  154. const { error, code, data } = await queryApi.getReportNumber({
  155. projectId: projectId.value,
  156. contractId: contractId.value || '',
  157. type: 1,
  158. })
  159. if (!error && code === 200) {
  160. InternalReportBatch.value = getArrValue(data)
  161. } else {
  162. InternalReportBatch.value = []
  163. }
  164. } else {
  165. InternalReportBatch.value = []
  166. }
  167. }
  168. //是否关联试验
  169. const InternalAssociation = ref([
  170. { label: '是', value: true },
  171. { label: '否', value: false },
  172. ])
  173. //搜索表单
  174. const searchInternalForm = ref({
  175. taskStatus: null, isEvaluate: null, reportNumber: null, isExperiment: null,
  176. current: 1, size: 20, total: 0,
  177. })
  178. //回车
  179. const searchInternalKeyUp = (e) => {
  180. if (e.key === 'Enter') {
  181. searchInternalClick()
  182. }
  183. }
  184. //搜索
  185. const searchInternalClick = () => {
  186. if (searchInternalForm.value?.wbsIds) {
  187. searchInternalForm.value.current = 1
  188. getTableInternalData()
  189. } else {
  190. window?.$message?.warning('请先选择一个树节点')
  191. }
  192. }
  193. //分页被点击
  194. const pageInternalChange = ({ current, size }) => {
  195. searchInternalForm.value.current = current
  196. searchInternalForm.value.size = size
  197. getTableInternalData()
  198. }
  199. //内业台账表头
  200. const tableInternalRef = ref(null)
  201. const tableInternalColumn = ref([
  202. { key: 'unitProject', name: '单位工程' },
  203. { key: 'partProject', name: '分部工程' },
  204. { key: 'partChildProject', name: '子分部工程' },
  205. { key: 'subentryProject', name: '分项工程' },
  206. { key: 'subentryChildProject', name: '子分项工程' },
  207. { key: 'process', name: '工序' },
  208. { key: 'taskStatus', name: '审批状态', width: 120, align: 'center' },
  209. { key: 'reportNumber', name: '上报批次', width: 100, align: 'center' },
  210. { key: 'isEvaluate', name: '是否评定', width: 100, align: 'center' },
  211. { key: 'isExperiment', name: '关联试验', width: 100, align: 'center' },
  212. ])
  213. const tableInternalData = ref([])
  214. //获取数据
  215. const tableInternalLoading = ref(false)
  216. const getTableInternalData = async () => {
  217. tableInternalLoading.value = true
  218. const { error, code, data } = await internalApi.queryInternalPage({
  219. ...searchInternalForm.value,
  220. projectId: projectId.value,
  221. })
  222. //判断状态
  223. tableInternalLoading.value = false
  224. if (!error && code === 200) {
  225. tableInternalData.value = getArrValue(data['records'])
  226. searchInternalForm.value.total = data['total'] || 0
  227. } else {
  228. tableInternalData.value = []
  229. searchInternalForm.value.total = 0
  230. }
  231. }
  232. //多选
  233. const tableInternalKeys = ref([])
  234. const tableInternalSelection = (rows) => {
  235. tableInternalKeys.value = rows.filter((item) => {
  236. return (item ?? '') !== ''
  237. })
  238. }
  239. //下载
  240. const downloadLoading = ref(false)
  241. const batchDownload = async () => {
  242. const rows = tableInternalKeys.value
  243. console.log(rows, 'rows')
  244. const ids = arrToId(rows)
  245. //批量下载
  246. downloadLoading.value = true
  247. const { error, disposition, res } = await queryApi.batchDownloadFileToZip({ ids: ids })
  248. //处理数据
  249. downloadLoading.value = false
  250. if (!error) {
  251. if (disposition) {
  252. downloadBlob(res, disposition)
  253. } else {
  254. window.$message?.error('选择的资料未生成文件')
  255. }
  256. }
  257. }
  258. //打印
  259. const printLoading = ref(false)
  260. const batchPrint = async () => {
  261. const rows = tableInternalKeys.value
  262. const ids = arrToId(rows)
  263. //批量下载
  264. printLoading.value = true
  265. const { error, code, data } = await queryApi.batchPrint({ ids: ids })
  266. //处理数据
  267. printLoading.value = false
  268. const res = isString(data) ? data ?? '' : ''
  269. if (!error && code === 200 && res) {
  270. window.open(res, '_blank')
  271. }
  272. }
  273. </script>