tasks-user.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <hc-sys class="hc-report-page" :isNavBar="false">
  3. <uni-collapse class="mt-1">
  4. <uni-collapse-item :title="item.roleName" title-border="show" :open="item.open" v-for="item in dataList">
  5. <template v-if="item.signPfxFileList.length > 0">
  6. <uni-list-item title-border="show" v-for="items in item.signPfxFileList">
  7. <template v-slot:header>
  8. <checkbox @click.stop="items.select = !items.select" :checked="items.select"/>
  9. <text>{{items.certificateUserName}}</text>
  10. </template>
  11. </uni-list-item>
  12. </template>
  13. <view class="h-50 text-gray text-center p-5" v-else>无数据</view>
  14. </uni-collapse-item>
  15. </uni-collapse>
  16. <!--底部操作栏-->
  17. <HcTabbarBlock :height="77"/>
  18. <hc-tabbars>
  19. <button type="primary" class="action-bar-btn" @click="submitClick">确认选择</button>
  20. </hc-tabbars>
  21. </hc-sys>
  22. </template>
  23. <script setup>
  24. import {ref, onMounted, nextTick, getCurrentInstance} from "vue";
  25. import { checkFlowUser, checkFlowUserQuery } from '~api/other/index'
  26. import {getArrValue, getObjValue} from "js-fast-way";
  27. import {errorToast} from "@/utils/tools";
  28. import flowApi from '~api/tasks/flow'
  29. //初始变量
  30. const instance = getCurrentInstance().proxy
  31. const props = ref({})
  32. //渲染完成
  33. onMounted(async () => {
  34. await getEventChannel();
  35. queryAllRoleList().then()
  36. })
  37. //页面传参数据
  38. let eventChannel = null;
  39. const getEventChannel = async () => {
  40. await nextTick();
  41. eventChannel = instance.getOpenerEventChannel();
  42. eventChannel.on('flowUserData', (data) => {
  43. props.value = getObjValue(data);
  44. })
  45. }
  46. //获取数据
  47. const dataList = ref([])
  48. const queryAllRoleList = async () => {
  49. uni.showLoading({title: '获取数据中...', mask: true});
  50. const { projectId, contractId, selectedData } = props.value
  51. const { data } = await flowApi.queryAllRoleList({
  52. projectId: projectId,
  53. contractId: contractId,
  54. })
  55. const res = getArrValue(data)
  56. const selected_data = getArrValue(selectedData)
  57. res.forEach((item)=>{
  58. item.signPfxFileList.forEach((item2)=>{
  59. selected_data.forEach((selected)=>{
  60. if(item2.certificateUserId === selected.userId){
  61. item2.select = true; //勾选
  62. item.open = true; //展开
  63. }
  64. })
  65. })
  66. })
  67. dataList.value = res
  68. uni.hideLoading();
  69. }
  70. //确认提交
  71. const submitClick = async () => {
  72. const checks = await getChecks();
  73. if (checks.length <= 0) {
  74. errorToast('请先选择人员')
  75. return;
  76. }
  77. uni.showLoading({title: '效验数据中...', mask: true});
  78. let {type, typeData} = props.value, flowJson = {}
  79. //判断类型
  80. if (type === 'first') {
  81. flowJson['firstId'] = typeData
  82. } else if (type === 'log') {
  83. flowJson['theLogPrimaryKeyId'] = typeData
  84. } else if (type === 'wbs') {
  85. flowJson['privatePKeyId'] = typeData
  86. } else if (type === 'query') {
  87. flowJson['privatePKeyId'] = typeData
  88. }
  89. //封装数据
  90. let customFlowUserList = [], newUserId= [];
  91. checks.forEach(item => {
  92. customFlowUserList.push({
  93. userId: item.certificateUserId,
  94. userName: item.certificateUserName,
  95. })
  96. newUserId.push(item.certificateUserId)
  97. })
  98. //效验人员
  99. if (type === 'first' || type === 'log' || type === 'wbs') {
  100. getCheckCustomFlowUserIsEVisaPermissions(flowJson, customFlowUserList, newUserId).then()
  101. } else if (type === 'query') {
  102. getCheckCustomFlowUserIsEVisaPermissionsQuery(flowJson, customFlowUserList, newUserId).then()
  103. } else {
  104. uni.hideLoading();
  105. eventChannel.emit('flowUserList', customFlowUserList);
  106. uni.navigateBack()
  107. }
  108. }
  109. //检查所选的流程环节处理人是否具有审批权限(三大填报页、日志列表的批量上报、首件列表的批量上报)
  110. const getCheckCustomFlowUserIsEVisaPermissions = async (flowJson, newUser, newUserId) => {
  111. const { projectId, contractId } = props.value
  112. const { error, code, data, msg } = await checkFlowUser({
  113. projectId: projectId,
  114. contractId: contractId,
  115. customFlowUserList: newUserId,
  116. ...flowJson,
  117. })
  118. //处理数据
  119. uni.hideLoading();
  120. if (!error && code === 200 && data === true) {
  121. eventChannel.emit('flowUserList', newUser);
  122. uni.navigateBack()
  123. } else {
  124. errorToast(msg)
  125. }
  126. }
  127. //资料查询页面
  128. const getCheckCustomFlowUserIsEVisaPermissionsQuery = async (flowJson, newUser, newUserId) => {
  129. const { projectId, contractId } = props.value
  130. const { error, code, data, msg } = await checkFlowUserQuery({
  131. projectId: projectId,
  132. contractId: contractId,
  133. customFlowUserList: newUserId,
  134. ...flowJson,
  135. })
  136. //处理数据
  137. uni.hideLoading();
  138. if (!error && code === 200 && data === true) {
  139. eventChannel.emit('flowUserList', newUser);
  140. uni.navigateBack()
  141. } else {
  142. errorToast(msg)
  143. }
  144. }
  145. //获取选中的用户
  146. const getChecks = async () => {
  147. let res = [], arr = dataList.value;
  148. for (let i = 0; i < arr.length; i++) {
  149. const signList = arr[i].signPfxFileList;
  150. for (let j = 0; j < signList.length; j++) {
  151. if(signList[j].select){
  152. res.push(signList[j])
  153. }
  154. }
  155. }
  156. return res;
  157. }
  158. </script>
  159. <style lang="scss">
  160. @import "@/style/report/tasks-user.scss";
  161. </style>