table-list.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div class="hc-table-list-content">
  3. <HcCard>
  4. <template #header>
  5. <div class="w-64">
  6. <HcDatePicker :dates="betweenTime" size="large" clearable @change="betweenTimeUpdate"/>
  7. </div>
  8. <div class="w-40 ml-3">
  9. <el-select v-model="searchForm.createUser" block clearable size="large" placeholder="请选择记录人">
  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 type="primary" size="large" @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 hc-btn type="primary" :disabled="tableCheckedKeys.length <= 0" @click="reportModalClick">
  23. <HcIcon name="send-plane-2"/>
  24. <span>批量上报</span>
  25. </el-button>
  26. </HcTooltip>
  27. <HcTooltip keys="ledger_query_abolish">
  28. <el-button hc-btn :disabled="tableCheckedKeys.length <= 0" @click="batchAbolishClick">
  29. <HcIcon name="delete-bin-3"/>
  30. <span>批量废除</span>
  31. </el-button>
  32. </HcTooltip>
  33. <HcTooltip keys="ledger_query_delete">
  34. <el-button hc-btn :disabled="tableCheckedKeys.length <= 0" @click="batchDeleteClick">
  35. <HcIcon name="delete-bin"/>
  36. <span>批量删除</span>
  37. </el-button>
  38. </HcTooltip>
  39. <HcTooltip keys="ledger_query_print">
  40. <el-button hc-btn :disabled="tableCheckedKeys.length <= 0" :loading="previewPrintLoading" @click="previewAndPrintClick">
  41. <HcIcon name="printer"/>
  42. <span>批量预览/打印</span>
  43. </el-button>
  44. </HcTooltip>
  45. </template>
  46. <HcTable ref="tableListRef" :column="tableListColumn" :datas="tableListData" :loading="tableLoading" isCheck @selection-change="tableSelectionChange">
  47. <template #action="{row}">
  48. <HcTooltip keys="ledger_query_table_query">
  49. <el-button type="primary" size="small" plain @click="handleTableQuery(row)">查询</el-button>
  50. </HcTooltip>
  51. <HcTooltip keys="ledger_query_table_del">
  52. <el-button type="danger" size="small" plain @click="handleTableDel(row)">删除</el-button>
  53. </HcTooltip>
  54. </template>
  55. </HcTable>
  56. <template #action>
  57. <HcPages :pages="searchForm" @change="pageChange"/>
  58. </template>
  59. </HcCard>
  60. <!--批量上报审批-->
  61. <HcReportModal title="批量上报审批" url="contractLog/batchTask" :show="showReportModal" :projectId="projectId" :contractId="contractId"
  62. :taskName="reportTaskName" :ids="reportIds" @hide="showReportModal = false" @finish="showReportFinish"/>
  63. </div>
  64. </template>
  65. <script setup>
  66. import {ref, watch, nextTick} from "vue";
  67. import queryApi from '~api/ledger/query';
  68. import {getArrValue, getObjValue, isString} from "vue-utils-plus"
  69. //参数
  70. const props = defineProps({
  71. projectId: {
  72. type: [String,Number],
  73. default: ''
  74. },
  75. contractId: {
  76. type: [String,Number],
  77. default: ''
  78. },
  79. items: {
  80. type: Object,
  81. default: () => ({})
  82. }
  83. })
  84. //变量
  85. const projectId = ref(props.projectId);
  86. const contractId = ref(props.contractId);
  87. const menuItem = ref(props.items);
  88. //监听
  89. watch(() => [
  90. props.projectId,
  91. props.contractId,
  92. props.items,
  93. ], ([pid, cid, item]) => {
  94. projectId.value = pid
  95. contractId.value = cid
  96. menuItem.value = item
  97. getQueryData()
  98. })
  99. //渲染完成
  100. nextTick(() => {
  101. getQueryData()
  102. })
  103. //获取相关数据
  104. const getQueryData = () => {
  105. searchClick()
  106. queryFillUser()
  107. }
  108. //获取记录人数据
  109. const recordData = ref([])
  110. const queryFillUser = async () => {
  111. const { primaryKeyId } = menuItem.value
  112. const { data } = await queryApi.queryFillUser({
  113. contractId: contractId.value,
  114. primaryKeyId: primaryKeyId
  115. })
  116. recordData.value = getArrValue(data)
  117. }
  118. //搜索表单
  119. const searchForm = ref({queryTime: '', createUser: null, current: 1, size: 20, total: 0})
  120. //日期时间被选择
  121. const betweenTime = ref(null)
  122. const betweenTimeUpdate = ({arr, query}) => {
  123. betweenTime.value = arr
  124. searchForm.value.queryTime = query
  125. }
  126. //搜索
  127. const searchClick = () => {
  128. searchForm.value.current = 1;
  129. getTableData()
  130. }
  131. //分页被点击
  132. const pageChange = ({current, size}) => {
  133. searchForm.value.current = current
  134. searchForm.value.size = size
  135. getTableData()
  136. }
  137. //获取数据
  138. const tableLoading = ref(false)
  139. const tableListColumn = ref([
  140. {key:'recordTime', name: '记录日期'},
  141. {key:'statusValue', name: '流程状态'},
  142. {key:'createUserName', name: '记录人员'},
  143. {key:'action', name: '操作', width: 200}
  144. ])
  145. const tableListData = ref([])
  146. const getTableData = async () => {
  147. //初始数据处理
  148. tableLoading.value = true
  149. const {primaryKeyId} = menuItem.value
  150. tableListRef.value?.clearSelection()
  151. tableCheckedKeys.value = []
  152. //请求数据
  153. const { error, code, data } = await queryApi.constructionLogPage({
  154. ...searchForm.value,
  155. wbsNodeId: primaryKeyId,
  156. projectId: projectId.value,
  157. contractId: contractId.value,
  158. })
  159. console.log(data)
  160. //处理数据
  161. tableLoading.value = false
  162. if (!error && code === 200) {
  163. tableListData.value = getArrValue(data['records'])
  164. searchForm.value.total = data.total || 0
  165. } else {
  166. tableListData.value = []
  167. searchForm.value.total = 0
  168. }
  169. }
  170. //多选
  171. const tableListRef = ref(null)
  172. const tableCheckedKeys = ref([])
  173. const tableSelectionChange = (rows) => {
  174. tableCheckedKeys.value = rows.filter((item) => {
  175. return (item??'') !== '';
  176. })
  177. }
  178. //批量上报
  179. const showReportModal = ref(false)
  180. const reportIds = ref('')
  181. const reportTaskName = ref('')
  182. const reportModalClick = () => {
  183. const rows = tableCheckedKeys.value;
  184. //判断是否满足条件
  185. const result = rows.every(({status})=> {
  186. return status !== 1 && status !== 2
  187. })
  188. //判断状态
  189. if (result) {
  190. const row = getObjValue(rows[0])
  191. reportIds.value = rowsToId(rows)
  192. reportTaskName.value = rows.length > 1 ? `${row.name}等${rows.length}个文件` : row.name
  193. showReportModal.value = true
  194. } else {
  195. window.$message?.warning('已上报的文件不能进行再次上报,若要重新上报,要先撤回之前的上报,再重新上报')
  196. }
  197. }
  198. //上报完成
  199. const showReportFinish = () => {
  200. showReportModal.value = false
  201. getTableData()
  202. }
  203. //批量废除
  204. const batchAbolishClick = () => {
  205. const rows = tableCheckedKeys.value;
  206. //判断是否满足条件
  207. const result = rows.every(({status})=> {
  208. return status !== 0 && status !== 3
  209. })
  210. //判断状态
  211. if (result) {
  212. //拼接ID
  213. const ids = rowsToId(rows)
  214. window?.$messageBox?.alert('是否废除勾选的已上报文件?', '废除文件', {
  215. showCancelButton: true,
  216. confirmButtonText: '确定废除',
  217. cancelButtonText: '取消',
  218. callback: (action) => {
  219. if (action === 'confirm') {
  220. batchAbolishSave(ids)
  221. }
  222. }
  223. })
  224. } else {
  225. window.$message?.warning('未上报的文件不能废除')
  226. }
  227. }
  228. //废除勾选的已上报文件
  229. const batchAbolishSave = async (ids) => {
  230. const { error, code } = await queryApi.batchAbolish({ids: ids})
  231. //处理数据
  232. if (!error && code === 200) {
  233. window.$message?.success('批量废除成功')
  234. tableCheckedKeys.value = []
  235. getTableData()
  236. }
  237. }
  238. //批量删除
  239. const batchDeleteClick = () => {
  240. window.$message?.warning('暂无接口')
  241. }
  242. //预览、打印
  243. const previewPrintLoading = ref(false)
  244. const previewAndPrintClick = async () => {
  245. previewPrintLoading.value = true
  246. const rows = tableCheckedKeys.value;
  247. const rowsIds = rowsToId(rows)
  248. const ids = rowsIds.split(',')
  249. const { error, code, data } = await queryApi.theLogPreviewAndPrint({
  250. ids: ids
  251. })
  252. //处理数据
  253. previewPrintLoading.value = false
  254. const res = isString(data) ? data || '' : ''
  255. if (!error && code === 200 && res) {
  256. window.open(res,'_blank')
  257. }
  258. }
  259. //查询
  260. const handleTableQuery = (row) => {
  261. window.$message?.warning('暂无接口')
  262. }
  263. //删除
  264. const handleTableDel = (row) => {
  265. window.$message?.warning('暂无接口')
  266. }
  267. //拼接ID
  268. const rowsToId = (rows) => {
  269. return rows.map((obj) => {
  270. return obj.id;
  271. }).join(",")
  272. }
  273. </script>
  274. <style lang="scss" scoped>
  275. .hc-table-list-content {
  276. flex: 1;
  277. position: relative;
  278. margin-left: 24px;
  279. height: 100%;
  280. }
  281. </style>