table-collect.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <hc-new-card scrollbar>
  3. <template #header>
  4. <HcTooltip keys="file_collection_btn_upload_scanned_files"> <el-checkbox v-model="checkedval" label="全选" size="large" @change="clickAll" /> </HcTooltip>
  5. </template>
  6. <template #extra>
  7. <!-- <HcNewSwitch :datas="tabData" :keys="tabKey" :round="false" @change="tabChange" /> -->
  8. <el-button hc-btn color="#626aef">
  9. <HcIcon name="eye" />
  10. <span>历史验收报告</span>
  11. </el-button>
  12. <el-button hc-btn class=" m-1" type="warning">
  13. <HcIcon name="eye" />
  14. <span>历史整改报告</span>
  15. </el-button>
  16. <HcTooltip keys="file_collection_btn_upload_scanned_files">
  17. <el-button v-if="!showBtn" type="primary" hc-btn @click="reportModalClick">
  18. <HcIcon name="git-pull-request" />
  19. <span>申请验收</span>
  20. </el-button>
  21. <el-button v-else type="primary" hc-btn @click="cancelClick">
  22. <HcIcon name="git-pull-request" />
  23. <span>撤回验收申请</span>
  24. </el-button>
  25. </HcTooltip>
  26. </template>
  27. <div v-loading="totalLoaing" class="h-screen">
  28. <div v-for="(item, index) in totalData" :key="item.unitInfo">
  29. <div class="hc-card-table-title">{{ item.unitInfo }}</div>
  30. <template v-for="(item1, index1) in item.nodeLists" :key="item1.nodeInfo">
  31. <HcCardItem v-if="item1.list && item1.list.length > 0" ui="h-half">
  32. <template #header>
  33. <!-- <el-checkbox v-model="item1.checkedval" label="全选" size="large" @change="clickAll($event, index)" /> -->
  34. <span>{{ item1.nodeInfo }}</span>
  35. <!-- <span class="text-gray">(238卷)</span> -->
  36. </template>
  37. <div :style="`height: ${item1.list !== null && item1.list.length > 9 ? '300px' : 'auto'};`">
  38. <visualTable ref="visuatable" :table-data="item1.list " :index-num="index" @getTableKeys="getTableKeys($event, index1)" />
  39. </div>
  40. </HcCardItem>
  41. </template>
  42. </div>
  43. </div>
  44. </hc-new-card>
  45. <!-- 批量上报审批 -->
  46. <HcReportModal
  47. title="申请验收"
  48. widths="1080px"
  49. url="archivesauto/saveApply"
  50. :show="showReportModal"
  51. :project-id="projectId"
  52. :contract-id="contractId"
  53. :task-name="reportTaskName"
  54. :ids="reportIds"
  55. is-datas
  56. :datas="reportDatas"
  57. @hide="hidereport"
  58. @finish="showReportFinish"
  59. @tagClose="reportTaskTagClose"
  60. />
  61. </template>
  62. <script setup>
  63. import { nextTick, onMounted, ref, watch } from 'vue'
  64. import { getArrValue, getObjValue } from 'js-fast-way'
  65. import { rowsToId } from '~uti/tools'
  66. import initialgApi from '~api/initial/initial'
  67. import visualTable from './visual-table.vue'
  68. //参数
  69. const props = defineProps({
  70. projectId: {
  71. type: [String, Number],
  72. default: '',
  73. },
  74. contractId: {
  75. type: [String, Number],
  76. default: '',
  77. },
  78. treeData: {
  79. type: Object,
  80. default: () => ({}),
  81. },
  82. })
  83. //变量
  84. const projectId = ref(props.projectId)
  85. const contractId = ref(props.contractId)
  86. const nodeData = ref(props.treeData)
  87. //监听
  88. watch(() => [
  89. props.treeData,
  90. ], ([treeData]) => {
  91. nodeData.value = treeData
  92. })
  93. //渲染完成
  94. onMounted(() => {
  95. getBtnstatus()
  96. getTotalData()
  97. })
  98. //查看验收申请状态
  99. const showBtn = ref(true)
  100. const getBtnstatus = async ()=>{
  101. const { error, code, data } = await initialgApi.getApplyStatus({
  102. projectId: projectId.value,
  103. })
  104. if (!error && code === 200) {
  105. console.log(data, 'data')
  106. showBtn.value = data
  107. } else {
  108. showBtn.value = true
  109. }
  110. }
  111. const totalData = ref([])
  112. const totalTabledata = ref([])
  113. const totalLoaing = ref(false)
  114. const getTotalData = async ()=>{
  115. totalLoaing.value = true
  116. const { error, code, data } = await initialgApi.getAllUnitArchivesView({
  117. projectId: projectId.value,
  118. })
  119. totalLoaing.value = false
  120. if (!error && code === 200) {
  121. console.log(data, 'data')
  122. totalData.value = getArrValue(data)
  123. getTotalTabledata(totalData.value)
  124. } else {
  125. totalData.value = []
  126. }
  127. }
  128. const getTotalTabledata = (data)=>{
  129. totalTabledata.value = []
  130. data.forEach((ele)=>{
  131. ele.nodeLists.forEach((ele1)=>{
  132. if (ele1.list !== null) {
  133. ele1?.list.forEach((ele2)=>{
  134. totalTabledata.value.push(ele2)
  135. })
  136. }
  137. })
  138. })
  139. }
  140. //------立项审批
  141. //上报
  142. const tableKeys = ref([])
  143. const reprotTitle = ref(new Map())
  144. const getTableKeys = (val, index)=>{
  145. let arr = []
  146. reprotTitle.value.set(index, val)
  147. for (const value of reprotTitle.value.values()) {
  148. console.log(value)
  149. value.forEach((ele)=>{
  150. arr.push(ele)
  151. })
  152. }
  153. tableKeys.value = arr
  154. }
  155. const checkedval = ref(false)
  156. const clickAll = (val)=>{
  157. if (val) {
  158. tableKeys.value = totalTabledata.value
  159. } else {
  160. tableKeys.value = []
  161. }
  162. // visuatable.value[index].tableSelectAll(val)
  163. }
  164. const reportIds = ref('')
  165. const reportTaskName = ref('')
  166. const reportDatas = ref([])
  167. const showReportModal = ref(false)
  168. const reportLoading = ref(false)
  169. const reportModalClick = async () => {
  170. const rows = tableKeys.value
  171. console.log(rows, 'rows验收申请行')
  172. if (rows.length > 0) {
  173. //初始ID
  174. const row = getObjValue(rows[0])
  175. reportIds.value = rowsToId(rows)
  176. //设置任务数据
  177. let reportDataArr = []
  178. rows.forEach(item => {
  179. reportDataArr.push({
  180. id: item?.id,
  181. name: item?.name,
  182. })
  183. })
  184. reportDatas.value = reportDataArr
  185. //设置任务名称
  186. reportTaskName.value = rows.length > 1 ? `${row.name}等${rows.length}个文件` : row.name
  187. reportLoading.value = false
  188. showReportModal.value = true
  189. } else {
  190. window.$message?.warning('请先勾选需要申请验收的数据')
  191. }
  192. }
  193. const hidereport = ()=>{
  194. showReportModal.value = false
  195. checkedval.value = false
  196. visuatable.value.forEach((ele, index)=>{
  197. visuatable.value[index]?.clearSelection()
  198. })
  199. }
  200. const visuatable = ref(null)
  201. //上报的审批内容移除
  202. const reportTaskTagClose = (index) => {
  203. // const row = tableKeys.value[index]
  204. console.log(visuatable.value[0])
  205. tableKeys.value.splice(index, 1)
  206. // // tableRef.value?.toggleRowSelection(row, false)
  207. // console.log(visuatable.value[index], '1111')
  208. }
  209. //上报完成
  210. const showReportFinish = async () => {
  211. showReportModal.value = false
  212. tableKeys.value = []
  213. await getBtnstatus()
  214. getTotalData()
  215. }
  216. //撤回验收申请
  217. const cancelClick = ()=>{
  218. window?.$messageBox?.alert('确认撤销? 撤销之后专家账号也一并清空删除', '提示', {
  219. showCancelButton: true,
  220. confirmButtonText: '确认撤销',
  221. cancelButtonText: '取消',
  222. callback: async (action, ctx ) => {
  223. if (action === 'confirm') {
  224. ctx.confirmButtonLoading = true
  225. const { code, msg, error } = await initialgApi.annulApply({
  226. projectId:projectId.value,
  227. })
  228. ctx.confirmButtonLoading = true
  229. if (!error && code === 200) {
  230. window.$message?.success(msg)
  231. getBtnstatus()
  232. getTotalData()
  233. }
  234. }
  235. },
  236. })
  237. }
  238. </script>
  239. <style lang="scss" scoped>
  240. @import '~style/transfer/scoped/initial.scss';
  241. </style>