internal.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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 v-if="!isWaterProject" class="relative whitespace-nowrap">
  8. <!-- <div class="inline-block w-32">
  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="inline-block w-40">
  14. <el-select v-model="searchInternalForm.dateIsComplete" clearable placeholder="日期是否完整">
  15. <el-option label="是" value="1" />
  16. <el-option label="否" value="2" />
  17. </el-select>
  18. </div>
  19. <div class="ml-2 inline-block w-38">
  20. <el-select v-model="searchInternalForm.isFile" clearable placeholder="是否缺失附件">
  21. <el-option label="是" :value="false" />
  22. <el-option label="否" :value="true" />
  23. </el-select>
  24. </div>
  25. <div class="ml-2 inline-block w-38">
  26. <el-select v-model="searchInternalForm.selectType" clearable placeholder="节点显示">
  27. <el-option label="按工序展示" :value="1" />
  28. <el-option label="按本节点显示" :value="2" />
  29. </el-select>
  30. </div>
  31. <div class="ml-2 inline-block w-60">
  32. <el-input v-model="searchInternalForm.queryStr" clearable placeholder="请输入名称关键词检索" @keyup="searchInternalKeyUp" />
  33. </div>
  34. <div class="ml-2 inline-block">
  35. <el-button type="primary" @click="searchInternalClick">
  36. <HcIcon name="search-2" />
  37. <span>搜索</span>
  38. </el-button>
  39. </div>
  40. </div>
  41. <div v-else class="relative whitespace-nowrap">
  42. <div class="inline-block w-64">
  43. <el-select v-model="searchWaterForm.type" clearable placeholder="审批状态">
  44. <el-option label="汇总统计" :value="1" />
  45. <el-option label="详细统计" :value="2" />
  46. </el-select>
  47. <el-button type="primary" @click="getTableWaterData">
  48. <HcIcon name="search-2" />
  49. <span>搜索</span>
  50. </el-button>
  51. </div>
  52. </div>
  53. </el-scrollbar>
  54. </div>
  55. </div>
  56. </template>
  57. <template #extra>
  58. <HcTooltip v-if="!isWaterProject" keys="write_industry_download">
  59. <el-button :disabled="tableInternalKeys.length <= 0" :loading="downloadLoading" hc-btn type="primary" @click="batchDownload">
  60. <HcIcon name="download" />
  61. <span>导出EXCEL表格</span>
  62. </el-button>
  63. </HcTooltip>
  64. <HcTooltip v-if="isWaterProject" keys="write_industry_download">
  65. <el-button :disabled="tableWaterKeys.length <= 0" :loading="waterDownloadLoading" hc-btn type="primary" @click="waterBatchDownload">
  66. <HcIcon name="download" />
  67. <span>导出EXCEL表格</span>
  68. </el-button>
  69. </HcTooltip>
  70. </template>
  71. <HcTable
  72. v-if="!isWaterProject" ref="tableInternalRef" :column="tableInternalColumn" :datas="tableInternalData"
  73. :loading="tableInternalLoading" is-new :index-style="{ width: 60 }" is-check
  74. :check-style="{ width: 29 }"
  75. @selection-change="tableInternalSelection"
  76. >
  77. <template #taskStatus="{ row }">
  78. <el-tag v-if="row.taskStatus === '已审批'" class="mx-1" effect="dark" type="success">已审批</el-tag>
  79. <el-tag v-if="row.taskStatus === '待审批'" class="mx-1" effect="dark" type="danger">待审批</el-tag>
  80. <el-tag v-if="row.taskStatus === '未上报'" class="mx-1" effect="dark" type="warning">未上报</el-tag>
  81. </template>
  82. <template #isEvaluate="{ row }">
  83. <el-tag v-if="row.isEvaluate" class="mx-1" effect="dark" type="success">是</el-tag>
  84. <el-tag v-else class="mx-1" effect="dark" type="info">否</el-tag>
  85. </template>
  86. <template #reportNumber="{ row }">
  87. {{ row.reportNumber === '-1' || row.reportNumber === '0' ? '' : row.reportNumber }}
  88. </template>
  89. <template #isExperiment="{ row }">
  90. <el-tag v-if="row.isExperiment" class="mx-1" effect="dark" type="success">是</el-tag>
  91. <el-tag v-else class="mx-1" effect="dark" type="info">否</el-tag>
  92. </template>
  93. <template #infoQueryName="{ row }">
  94. <span class="text-link" @click="tableRowName(row)">{{ row?.infoQueryName }}</span>
  95. </template>
  96. </HcTable>
  97. <template #action>
  98. <HcPages v-if="!isWaterProject" :pages="searchInternalForm" @change="pageInternalChange" />
  99. <!-- <HcPages v-if="isWaterProject" :pages="searchWaterForm" @change="pageWaterChange" /> -->
  100. </template>
  101. <HcTable
  102. v-if="isWaterProject" :column="tableWaterColumn" :datas="tableWaterData"
  103. :loading="tableWaterLoading" is-new :index-style="{ width: 60 }" is-check @selection-change="tableWaterSelection"
  104. />
  105. </HcNewCard>
  106. </template>
  107. <script setup>
  108. import { nextTick, ref, watch } from 'vue'
  109. import internalApi from '~api/ledger/internal'
  110. import queryApi from '~api/data-fill/query'
  111. import { arrToId, downloadBlob, getArrValue, isString } from 'js-fast-way'
  112. import { toPdfPage } from '~uti/btn-auth'
  113. //参数
  114. const props = defineProps({
  115. projectId: {
  116. type: [String, Number],
  117. default: '',
  118. },
  119. contractId: {
  120. type: [String, Number],
  121. default: '',
  122. },
  123. treeData: {
  124. type: Object,
  125. default: () => ({}),
  126. },
  127. isWaterProject: {
  128. type: Boolean,
  129. default: false,
  130. },
  131. })
  132. //变量
  133. const projectId = ref(props.projectId)
  134. const contractId = ref(props.contractId)
  135. const nodeData = ref(props.treeData)
  136. const isWaterProject = ref(props.isWaterProject)
  137. const searchWaterForm = ref({
  138. type:1,
  139. })
  140. const tableWaterColumn = ref([
  141. { key: 'className', name: '单位工程' },
  142. { key: 'partName', name: '分部工程' },
  143. { key: 'subPartName', name: '子分部工程' },
  144. { key: 'unitName', name: '单元工程' },
  145. { key: 'unitCount', name: '单元工程个数' },
  146. { key: 'passCount', name: '合格个数' },
  147. { key: 'goodCount', name: '其中优良个数' },
  148. { key: 'goodRate', name: '优良率(%)' },
  149. ])
  150. //监听
  151. watch(() => [
  152. props.treeData,
  153. props.isWaterProject,
  154. ], ([treeData, water]) => {
  155. nodeData.value = treeData
  156. isWaterProject.value = water
  157. setQueryData(treeData)
  158. })
  159. //渲染完成
  160. nextTick(() => {
  161. setQueryData(props.treeData)
  162. })
  163. //获取相关数据
  164. const setQueryData = (data) => {
  165. const cid = data?.contractIdRelation || ''
  166. const wbsId = data['contractIdRelation'] ? data['id'] : data['primaryKeyId']
  167. if (wbsId) {
  168. searchInternalForm.value.contractId = cid ? cid : contractId.value
  169. searchInternalForm.value.contractIdRelation = data['contractIdRelation']
  170. searchInternalForm.value.wbsIds = [wbsId]
  171. searchInternalClick()
  172. }
  173. }
  174. //审批状态
  175. const InternalApproval = ref([
  176. { label: '未上报', value: '0' },
  177. { label: '待审批', value: '1' },
  178. { label: '已审批', value: '2' },
  179. ])
  180. //是否评定
  181. const InternalAssess = ref([
  182. { label: '是', value: true },
  183. { label: '否', value: false },
  184. ])
  185. //是否关联试验
  186. const InternalAssociation = ref([
  187. { label: '是', value: true },
  188. { label: '否', value: false },
  189. ])
  190. //搜索表单
  191. const searchInternalForm = ref({
  192. taskStatus: null, isFile: null, reportNumber: null, isExperiment: null, selectType: null,
  193. current: 1, size: 20, total: 0,
  194. })
  195. //回车
  196. const searchInternalKeyUp = (e) => {
  197. if (e.key === 'Enter') {
  198. searchInternalClick()
  199. }
  200. }
  201. //搜索
  202. const searchInternalClick = () => {
  203. if (searchInternalForm.value?.wbsIds) {
  204. searchInternalForm.value.current = 1
  205. if (isWaterProject.value) {
  206. getTableWaterData()
  207. } else {
  208. getTableInternalData()
  209. }
  210. } else {
  211. window?.$message?.warning('请先选择一个树节点')
  212. }
  213. }
  214. //分页被点击
  215. const pageInternalChange = ({ current, size }) => {
  216. searchInternalForm.value.current = current
  217. searchInternalForm.value.size = size
  218. getTableInternalData()
  219. }
  220. // const pageWaterChange = ({ current, size }) => {
  221. // searchWaterForm.value.current = current
  222. // searchWaterForm.value.size = size
  223. // getTableWaterData()
  224. // }
  225. //获取水利水电工程台账
  226. //内业台账表头
  227. const tableInternalRef = ref(null)
  228. const tableInternalColumn = ref([
  229. { key: 'unitProject', name: '单位工程' },
  230. { key: 'partProject', name: '分部工程' },
  231. { key: 'partChildProject', name: '子分部工程' },
  232. { key: 'subentryProject', name: '分项工程' },
  233. { key: 'subentryChildProject', name: '子分项工程' },
  234. { key: 'infoQueryName', name: '文件题名' },
  235. { key: 'taskStatus', name: '审批状态', width: 80, align: 'center' },
  236. { key: 'dateIsComplete', name: '日期是否完整', width: 100, align: 'center' },
  237. { key: 'fileTypeMsg', name: '附件报告', width: 100, align: 'center' },
  238. ])
  239. const tableInternalData = ref([])
  240. //获取数据
  241. const tableInternalLoading = ref(false)
  242. const getTableInternalData = async () => {
  243. tableInternalData.value = []
  244. tableInternalLoading.value = true
  245. const { error, code, data } = await internalApi.queryInternalPage({
  246. ...searchInternalForm.value,
  247. projectId: projectId.value,
  248. })
  249. //判断状态
  250. tableInternalLoading.value = false
  251. if (!error && code === 200) {
  252. tableInternalData.value = getArrValue(data['records'])
  253. searchInternalForm.value.total = data['total'] || 0
  254. } else {
  255. tableInternalData.value = []
  256. searchInternalForm.value.total = 0
  257. }
  258. }
  259. //获取数据
  260. const tableWaterData = ref([])
  261. const tableWaterLoading = ref(false)
  262. const getTableWaterData = async () => {
  263. tableWaterLoading.value = true
  264. const { error, code, data } = await internalApi.queryCurrentNodeNeiYeLedger1({
  265. ...searchWaterForm.value,
  266. projectId: projectId.value,
  267. pkeyId: nodeData.value['primaryKeyId'],
  268. })
  269. //判断状态
  270. tableWaterLoading.value = false
  271. if (!error && code === 200) {
  272. tableWaterData.value = getArrValue(data)
  273. } else {
  274. tableWaterData.value = []
  275. }
  276. }
  277. //多选
  278. const tableInternalKeys = ref([])
  279. const tableInternalSelection = (rows) => {
  280. tableInternalKeys.value = rows.filter((item) => {
  281. return (item ?? '') !== ''
  282. })
  283. }
  284. //下载
  285. const downloadLoading = ref(false)
  286. const batchDownload = async () => {
  287. //批量下载
  288. downloadLoading.value = true
  289. const { error, disposition, res } = await queryApi.exportNeiye({
  290. ...searchInternalForm.value,
  291. projectId: projectId.value,
  292. })
  293. //处理数据
  294. downloadLoading.value = false
  295. if (!error) {
  296. if (disposition) {
  297. downloadBlob(res, disposition)
  298. } else {
  299. window.$message?.error('选择的资料未生成文件')
  300. }
  301. }
  302. }
  303. const waterDownloadLoading = ref(false)
  304. const tableWaterKeys = ref([])
  305. const tableWaterSelection = (rows) => {
  306. tableWaterKeys.value = rows.filter((item) => {
  307. return (item ?? '') !== ''
  308. })
  309. }
  310. const waterBatchDownload = async () => {
  311. const rows = tableWaterKeys.value
  312. // const ids = arrToId(rows)
  313. //批量下载
  314. waterDownloadLoading.value = true
  315. const { error, disposition, res } = await queryApi.downloadNeiYe(rows)
  316. //处理数据
  317. waterDownloadLoading.value = false
  318. if (!error) {
  319. if (disposition) {
  320. downloadBlob(res, disposition)
  321. } else {
  322. window.$message?.error('选择的资料未生成文件')
  323. }
  324. }
  325. }
  326. //打印
  327. const printLoading = ref(false)
  328. const batchPrint = async () => {
  329. const rows = tableInternalKeys.value
  330. const ids = arrToId(rows)
  331. //批量下载
  332. printLoading.value = true
  333. const { error, code, data } = await queryApi.batchPrint({ ids: ids })
  334. //处理数据
  335. printLoading.value = false
  336. const res = isString(data) ? data ?? '' : ''
  337. if (!error && code === 200 && res) {
  338. toPdfPage(res)
  339. //window.open(res, '_blank')
  340. }
  341. }
  342. const tableRowName = (row)=>{
  343. const res = row.pdfUrl
  344. toPdfPage(res)
  345. }
  346. </script>
  347. <style lang="scss" scoped>
  348. </style>