tasks-user.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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, nextTick, getCurrentInstance} from "vue";
  25. import {onLoad} from '@dcloudio/uni-app'
  26. import {checkFlowUser, checkFlowUserQuery} from '~api/other/index'
  27. import {getArrValue, getObjValue} from "js-fast-way";
  28. import {errorToast} from "@/utils/tools";
  29. import flowApi from '~api/tasks/flow'
  30. //初始变量
  31. const instance = getCurrentInstance().proxy
  32. const props = ref({})
  33. //渲染完成
  34. onLoad(() => {
  35. getEventChannel();
  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. queryAllRoleList().then()
  45. })
  46. }
  47. //获取数据
  48. const dataList = ref([])
  49. const queryAllRoleList = async () => {
  50. uni.showLoading({title: '获取数据中...', mask: true});
  51. const { projectId, contractId, selectedData } = props.value
  52. const { data } = await flowApi.queryAllRoleList({
  53. projectId: projectId,
  54. contractId: contractId,
  55. })
  56. console.log(data)
  57. const res = getArrValue(data)
  58. const selected_data = getArrValue(selectedData)
  59. res.forEach((item)=>{
  60. item.signPfxFileList.forEach((item2)=>{
  61. selected_data.forEach((selected)=>{
  62. if(item2.certificateUserId === selected.userId){
  63. item2.select = true; //勾选
  64. item.open = true; //展开
  65. }
  66. })
  67. })
  68. })
  69. dataList.value = res
  70. uni.hideLoading();
  71. }
  72. //确认提交
  73. const submitClick = async () => {
  74. const checks = await getChecks();
  75. if (checks.length <= 0) {
  76. errorToast('请先选择人员')
  77. return;
  78. }
  79. uni.showLoading({title: '效验数据中...', mask: true});
  80. let {type, typeData} = props.value, flowJson = {}
  81. //判断类型
  82. if (type === 'first') {
  83. flowJson['firstId'] = typeData
  84. } else if (type === 'log') {
  85. flowJson['theLogPrimaryKeyId'] = typeData
  86. } else if (type === 'wbs') {
  87. flowJson['privatePKeyId'] = typeData
  88. } else if (type === 'query') {
  89. flowJson['privatePKeyId'] = typeData
  90. }
  91. //封装数据
  92. let customFlowUserList = [], newUserId= [];
  93. checks.forEach(item => {
  94. customFlowUserList.push({
  95. userId: item.certificateUserId,
  96. userName: item.certificateUserName,
  97. })
  98. newUserId.push(item.certificateUserId)
  99. })
  100. //效验人员
  101. if (type === 'first' || type === 'log' || type === 'wbs') {
  102. getCheckCustomFlowUserIsEVisaPermissions(flowJson, customFlowUserList, newUserId).then()
  103. } else if (type === 'query') {
  104. getCheckCustomFlowUserIsEVisaPermissionsQuery(flowJson, customFlowUserList, newUserId).then()
  105. } else {
  106. uni.hideLoading();
  107. eventChannel.emit('flowUserList', customFlowUserList);
  108. uni.navigateBack()
  109. }
  110. }
  111. //检查所选的流程环节处理人是否具有审批权限(三大填报页、日志列表的批量上报、首件列表的批量上报)
  112. const getCheckCustomFlowUserIsEVisaPermissions = async (flowJson, newUser, newUserId) => {
  113. const { projectId, contractId, nodeId, tableOwner, classifyType } = props.value
  114. const { error, code, data, msg } = await checkFlowUser({
  115. projectId: projectId,
  116. contractId: contractId,
  117. customFlowUserList: newUserId,
  118. classifyType: classifyType,
  119. tableOwner: tableOwner,
  120. nodeId: nodeId,
  121. ...flowJson,
  122. })
  123. //处理数据
  124. uni.hideLoading();
  125. if (!error && code === 200 && data === true) {
  126. eventChannel.emit('flowUserList', newUser);
  127. uni.navigateBack()
  128. } else {
  129. errorToast(msg)
  130. }
  131. }
  132. //资料查询页面
  133. const getCheckCustomFlowUserIsEVisaPermissionsQuery = async (flowJson, newUser, newUserId) => {
  134. const { projectId, contractId, nodeId, tableOwner, classifyType } = props.value
  135. const { error, code, data, msg } = await checkFlowUserQuery({
  136. projectId: projectId,
  137. contractId: contractId,
  138. customFlowUserList: newUserId,
  139. classifyType: classifyType,
  140. tableOwner: tableOwner,
  141. nodeId: nodeId,
  142. ...flowJson,
  143. })
  144. //处理数据
  145. uni.hideLoading();
  146. if (!error && code === 200 && data === true) {
  147. eventChannel.emit('flowUserList', newUser);
  148. uni.navigateBack()
  149. } else {
  150. errorToast(msg)
  151. }
  152. }
  153. //获取选中的用户
  154. const getChecks = async () => {
  155. let res = [], arr = dataList.value;
  156. for (let i = 0; i < arr.length; i++) {
  157. const signList = arr[i].signPfxFileList;
  158. for (let j = 0; j < signList.length; j++) {
  159. if(signList[j].select){
  160. res.push(signList[j])
  161. }
  162. }
  163. }
  164. return res;
  165. }
  166. </script>
  167. <style lang="scss">
  168. @import "@/style/report/tasks-user.scss";
  169. </style>