internal.vue 13 KB

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