table-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <div class="hc-table-list-content">
  3. <HcCard>
  4. <template #header>
  5. <div class="w-64">
  6. <HcDatePicker :dates="betweenTime" clearable size="large" @change="betweenTimeUpdate" />
  7. </div>
  8. <div class="w-40 ml-3">
  9. <el-select v-model="searchForm.createUser" block clearable placeholder="请选择记录人" size="large">
  10. <el-option v-for="item in recordData" :label="item.userName" :value="item.userId" />
  11. </el-select>
  12. </div>
  13. <div class="ml-2">
  14. <el-button size="large" type="primary" @click="searchClick">
  15. <HcIcon name="search-2" />
  16. <span>搜索</span>
  17. </el-button>
  18. </div>
  19. </template>
  20. <template #extra>
  21. <HcTooltip keys="ledger_query_report">
  22. <el-button
  23. :disabled="tableCheckedKeys.length <= 0" :loading="reportLoading" hc-btn
  24. color="#FF976A" style="color: white;" @click="reportModalClick"
  25. >
  26. <HcIcon name="send-plane-2" />
  27. <span>批量上报</span>
  28. </el-button>
  29. </HcTooltip>
  30. <HcTooltip keys="ledger_query_abolish">
  31. <el-button
  32. :disabled="tableCheckedKeys.length <= 0" :loading="abolishLoading" hc-btn
  33. color="#A16222" @click="batchAbolishClick"
  34. >
  35. <HcIcon name="delete-bin-3" />
  36. <span>批量废除</span>
  37. </el-button>
  38. </HcTooltip>
  39. <HcTooltip keys="ledger_query_delete">
  40. <el-button
  41. :disabled="tableCheckedKeys.length <= 0" :loading="deleteLoading" hc-btn
  42. color="#e03997" @click="batchDeleteClick"
  43. >
  44. <HcIcon name="delete-bin" />
  45. <span>批量删除</span>
  46. </el-button>
  47. </HcTooltip>
  48. <HcTooltip keys="ledger_query_print">
  49. <el-button
  50. :disabled="tableCheckedKeys.length <= 0" :loading="previewPrintLoading" hc-btn
  51. color="#567722" @click="previewAndPrintClick"
  52. >
  53. <HcIcon name="printer" />
  54. <span>批量预览/打印</span>
  55. </el-button>
  56. </HcTooltip>
  57. </template>
  58. <HcTable
  59. ref="tableListRef" :column="tableListColumn" :datas="tableListData" :loading="tableLoading" is-check
  60. @selection-change="tableSelectionChange"
  61. >
  62. <template #action="{ row }">
  63. <HcTooltip keys="ledger_query_table_query">
  64. <el-button plain size="small" type="primary" @click="handleTableQuery(row)">查询</el-button>
  65. </HcTooltip>
  66. <HcTooltip keys="ledger_query_table_del">
  67. <el-button
  68. :disabled="!row.operation || row.status !== 0" plain size="small" type="danger"
  69. @click="handleTableDel(row)"
  70. >
  71. 删除
  72. </el-button>
  73. </HcTooltip>
  74. </template>
  75. </HcTable>
  76. <template #action>
  77. <HcPages :pages="searchForm" @change="pageChange" />
  78. </template>
  79. </HcCard>
  80. <!-- 批量上报审批 -->
  81. <HcReportModal
  82. :contract-id="contractId"
  83. :datas="reportDatas"
  84. :ids="reportIds"
  85. :project-id="projectId"
  86. :show="showReportModal"
  87. :task-name="reportTaskName"
  88. :type-data="menuItem.primaryKeyId"
  89. is-datas
  90. title="批量上报审批"
  91. type="log"
  92. url="contractLog/batchTask"
  93. @finish="showReportFinish"
  94. @hide="showReportModal = false"
  95. @tagClose="reportTaskTagClose"
  96. />
  97. </div>
  98. </template>
  99. <script setup>
  100. import { nextTick, ref, watch } from 'vue'
  101. import queryApi from '~api/ledger/query'
  102. import { eVisaTaskCheckApi } from '~api/other'
  103. import { arrToId, getArrValue, getObjValue, isString } from 'js-fast-way'
  104. //参数
  105. const props = defineProps({
  106. projectId: {
  107. type: [String, Number],
  108. default: '',
  109. },
  110. contractId: {
  111. type: [String, Number],
  112. default: '',
  113. },
  114. items: {
  115. type: Object,
  116. default: () => ({}),
  117. },
  118. })
  119. //变量
  120. const projectId = ref(props.projectId)
  121. const contractId = ref(props.contractId)
  122. const menuItem = ref(props.items)
  123. //监听
  124. watch(() => [
  125. props.projectId,
  126. props.contractId,
  127. props.items,
  128. ], ([pid, cid, item]) => {
  129. projectId.value = pid
  130. contractId.value = cid
  131. menuItem.value = item
  132. getQueryData()
  133. })
  134. //渲染完成
  135. nextTick(() => {
  136. getQueryData()
  137. })
  138. //获取相关数据
  139. const getQueryData = () => {
  140. searchClick()
  141. queryFillUser()
  142. }
  143. //获取记录人数据
  144. const recordData = ref([])
  145. const queryFillUser = async () => {
  146. const { primaryKeyId } = menuItem.value
  147. const { data } = await queryApi.queryFillUser({
  148. contractId: contractId.value,
  149. primaryKeyId: primaryKeyId,
  150. })
  151. recordData.value = getArrValue(data)
  152. }
  153. //搜索表单
  154. const searchForm = ref({ queryTime: '', createUser: null, current: 1, size: 20, total: 0 })
  155. //日期时间被选择
  156. const betweenTime = ref(null)
  157. const betweenTimeUpdate = ({ arr, query }) => {
  158. betweenTime.value = arr
  159. searchForm.value.queryTime = query
  160. }
  161. //搜索
  162. const searchClick = () => {
  163. searchForm.value.current = 1
  164. getTableData()
  165. }
  166. //分页被点击
  167. const pageChange = ({ current, size }) => {
  168. searchForm.value.current = current
  169. searchForm.value.size = size
  170. getTableData()
  171. }
  172. //获取数据
  173. const tableLoading = ref(false)
  174. const tableListColumn = ref([
  175. { key: 'recordTime', name: '记录日期' },
  176. { key: 'statusValue', name: '流程状态' },
  177. { key: 'createUserName', name: '记录人员' },
  178. { key: 'action', name: '操作', width: 200 },
  179. ])
  180. const tableListData = ref([])
  181. const getTableData = async () => {
  182. //初始数据处理
  183. tableLoading.value = true
  184. const { primaryKeyId } = menuItem.value
  185. tableListRef.value?.clearSelection()
  186. tableCheckedKeys.value = []
  187. //请求数据
  188. const { error, code, data } = await queryApi.constructionLogPage({
  189. ...searchForm.value,
  190. wbsNodeId: primaryKeyId,
  191. projectId: projectId.value,
  192. contractId: contractId.value,
  193. })
  194. console.log(data)
  195. //处理数据
  196. tableLoading.value = false
  197. if (!error && code === 200) {
  198. tableListData.value = getArrValue(data['records'])
  199. searchForm.value.total = data.total || 0
  200. } else {
  201. tableListData.value = []
  202. searchForm.value.total = 0
  203. }
  204. }
  205. //多选
  206. const tableListRef = ref(null)
  207. const tableCheckedKeys = ref([])
  208. const tableSelectionChange = (rows) => {
  209. tableCheckedKeys.value = rows.filter((item) => {
  210. return (item ?? '') !== ''
  211. })
  212. }
  213. //批量上报
  214. const reportIds = ref('')
  215. const reportTaskName = ref('')
  216. const reportDatas = ref([])
  217. const reportLoading = ref(false)
  218. const showReportModal = ref(false)
  219. const reportModalClick = async () => {
  220. const rows = tableCheckedKeys.value
  221. //判断是否满足条件
  222. const result = rows.every(({ status }) => {
  223. return status !== 1 && status !== 2
  224. })
  225. //判断状态
  226. if (result) {
  227. reportLoading.value = true
  228. const taskCheck = await eVisaTaskCheckApi({
  229. projectId: projectId.value,
  230. contractId: contractId.value,
  231. })
  232. if (taskCheck) {
  233. //初始ID
  234. const row = getObjValue(rows[0])
  235. reportIds.value = arrToId(rows)
  236. //设置任务数据
  237. let reportDataArr = []
  238. rows.forEach(item => {
  239. reportDataArr.push({
  240. id: item?.id,
  241. name: item?.fileName,
  242. })
  243. })
  244. reportDatas.value = reportDataArr
  245. //设置任务名称
  246. reportTaskName.value = rows.length > 1 ? `${row.fileName}等${rows.length}个文件` : row.fileName
  247. reportLoading.value = false
  248. showReportModal.value = true
  249. } else {
  250. reportLoading.value = false
  251. }
  252. } else {
  253. window.$message?.warning('已上报的文件不能进行再次上报,若要重新上报,要先撤回之前的上报,再重新上报')
  254. }
  255. }
  256. //上报的审批内容移除
  257. const reportTaskTagClose = (index) => {
  258. const row = tableCheckedKeys.value[index]
  259. tableListRef.value?.toggleRowSelection(row, false)
  260. }
  261. //上报完成
  262. const showReportFinish = () => {
  263. showReportModal.value = false
  264. getTableData()
  265. }
  266. //批量废除
  267. const abolishLoading = ref(false)
  268. const batchAbolishClick = () => {
  269. const rows = tableCheckedKeys.value
  270. //判断是否满足条件
  271. const result = rows.every(({ status, operation }) => {
  272. return status !== 0 && status !== 3 && operation
  273. })
  274. //判断状态
  275. if (result) {
  276. //拼接ID
  277. const ids = arrToId(rows)
  278. window?.$messageBox?.alert('是否废除勾选的已上报文件?', '废除文件', {
  279. showCancelButton: true,
  280. confirmButtonText: '确定废除',
  281. cancelButtonText: '取消',
  282. callback: (action) => {
  283. if (action === 'confirm') {
  284. batchAbolishSave(ids)
  285. }
  286. },
  287. })
  288. } else {
  289. window.$message?.warning('未上报的文件,和不是自己的文件,不能废除')
  290. }
  291. }
  292. //废除勾选的已上报文件
  293. const batchAbolishSave = async (ids) => {
  294. abolishLoading.value = true
  295. const { error, code } = await queryApi.batchAbolish({ ids: ids })
  296. //处理数据
  297. abolishLoading.value = false
  298. if (!error && code === 200) {
  299. window.$message?.success('批量废除成功')
  300. tableCheckedKeys.value = []
  301. getTableData()
  302. }
  303. }
  304. //批量删除
  305. const batchDeleteClick = () => {
  306. const rows = tableCheckedKeys.value
  307. //判断是否满足条件
  308. const result = rows.every(({ status, operation }) => {
  309. return status === 0 && operation
  310. })
  311. //判断状态
  312. if (result) {
  313. const ids = arrToId(rows)
  314. window?.$messageBox?.alert('是否删除勾选的日志文件?', '删除文件', {
  315. showCancelButton: true,
  316. confirmButtonText: '确定删除',
  317. cancelButtonText: '取消',
  318. callback: (action) => {
  319. if (action === 'confirm') {
  320. theLogRemoveByIds(ids)
  321. }
  322. },
  323. })
  324. } else {
  325. window.$message?.warning('只能删除自己的未上报日志文件')
  326. }
  327. }
  328. //预览、打印
  329. const previewPrintLoading = ref(false)
  330. const previewAndPrintClick = async () => {
  331. previewPrintLoading.value = true
  332. const rows = tableCheckedKeys.value
  333. const rowsIds = arrToId(rows)
  334. const ids = rowsIds.split(',')
  335. const { error, code, data } = await queryApi.theLogPreviewAndPrint({
  336. ids: ids,
  337. })
  338. //处理数据
  339. previewPrintLoading.value = false
  340. const res = isString(data) ? data || '' : ''
  341. if (!error && code === 200 && res) {
  342. window.open(res, '_blank')
  343. }
  344. }
  345. //查询
  346. const handleTableQuery = ({ evisaPdfUrl, pdfUrl }) => {
  347. if (evisaPdfUrl) {
  348. window.open(evisaPdfUrl, '_blank')
  349. } else if (pdfUrl) {
  350. window.open(pdfUrl, '_blank')
  351. } else {
  352. window.$message?.warning('该数据暂无PDF')
  353. }
  354. }
  355. //删除
  356. const handleTableDel = ({ id, status, operation }) => {
  357. //判断是否满足条件
  358. if (status === 0 && operation) {
  359. window?.$messageBox?.alert('是否删除勾选的日志文件?', '删除文件', {
  360. showCancelButton: true,
  361. confirmButtonText: '确定删除',
  362. cancelButtonText: '取消',
  363. callback: (action) => {
  364. if (action === 'confirm') {
  365. theLogRemoveByIds([id])
  366. }
  367. },
  368. })
  369. } else {
  370. window.$message?.warning('只能删除自己的未上报日志文件')
  371. }
  372. }
  373. //删除
  374. const deleteLoading = ref(false)
  375. const theLogRemoveByIds = async (ids) => {
  376. deleteLoading.value = true
  377. const { error, code } = await queryApi.theLogRemoveByIds({
  378. ids: ids,
  379. })
  380. deleteLoading.value = false
  381. if (!error && code === 200) {
  382. window.$message?.success('删除成功')
  383. tableCheckedKeys.value = []
  384. getTableData()
  385. }
  386. }
  387. </script>
  388. <style lang="scss" scoped>
  389. .hc-table-list-content {
  390. flex: 1;
  391. position: relative;
  392. margin-left: 24px;
  393. height: 100%;
  394. }
  395. </style>