tasks-user.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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(async () => {
  35. await getEventChannel();
  36. queryAllRoleList().then()
  37. })
  38. //页面传参数据
  39. let eventChannel = null;
  40. const getEventChannel = async () => {
  41. await nextTick();
  42. eventChannel = instance.getOpenerEventChannel();
  43. eventChannel.on('flowUserData', (data) => {
  44. props.value = getObjValue(data);
  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. const res = getArrValue(data)
  57. const selected_data = getArrValue(selectedData)
  58. res.forEach((item)=>{
  59. item.signPfxFileList.forEach((item2)=>{
  60. selected_data.forEach((selected)=>{
  61. if(item2.certificateUserId === selected.userId){
  62. item2.select = true; //勾选
  63. item.open = true; //展开
  64. }
  65. })
  66. })
  67. })
  68. dataList.value = res
  69. uni.hideLoading();
  70. }
  71. //确认提交
  72. const submitClick = async () => {
  73. const checks = await getChecks();
  74. if (checks.length <= 0) {
  75. errorToast('请先选择人员')
  76. return;
  77. }
  78. uni.showLoading({title: '效验数据中...', mask: true});
  79. let {type, typeData} = props.value, flowJson = {}
  80. //判断类型
  81. if (type === 'first') {
  82. flowJson['firstId'] = typeData
  83. } else if (type === 'log') {
  84. flowJson['theLogPrimaryKeyId'] = typeData
  85. } else if (type === 'wbs') {
  86. flowJson['privatePKeyId'] = typeData
  87. } else if (type === 'query') {
  88. flowJson['privatePKeyId'] = typeData
  89. }
  90. //封装数据
  91. let customFlowUserList = [], newUserId= [];
  92. checks.forEach(item => {
  93. customFlowUserList.push({
  94. userId: item.certificateUserId,
  95. userName: item.certificateUserName,
  96. })
  97. newUserId.push(item.certificateUserId)
  98. })
  99. //效验人员
  100. if (type === 'first' || type === 'log' || type === 'wbs') {
  101. getCheckCustomFlowUserIsEVisaPermissions(flowJson, customFlowUserList, newUserId).then()
  102. } else if (type === 'query') {
  103. getCheckCustomFlowUserIsEVisaPermissionsQuery(flowJson, customFlowUserList, newUserId).then()
  104. } else {
  105. uni.hideLoading();
  106. eventChannel.emit('flowUserList', customFlowUserList);
  107. uni.navigateBack()
  108. }
  109. }
  110. //检查所选的流程环节处理人是否具有审批权限(三大填报页、日志列表的批量上报、首件列表的批量上报)
  111. const getCheckCustomFlowUserIsEVisaPermissions = async (flowJson, newUser, newUserId) => {
  112. const { projectId, contractId } = props.value
  113. const { error, code, data, msg } = await checkFlowUser({
  114. projectId: projectId,
  115. contractId: contractId,
  116. customFlowUserList: newUserId,
  117. ...flowJson,
  118. })
  119. //处理数据
  120. uni.hideLoading();
  121. if (!error && code === 200 && data === true) {
  122. eventChannel.emit('flowUserList', newUser);
  123. uni.navigateBack()
  124. } else {
  125. errorToast(msg)
  126. }
  127. }
  128. //资料查询页面
  129. const getCheckCustomFlowUserIsEVisaPermissionsQuery = async (flowJson, newUser, newUserId) => {
  130. const { projectId, contractId } = props.value
  131. const { error, code, data, msg } = await checkFlowUserQuery({
  132. projectId: projectId,
  133. contractId: contractId,
  134. customFlowUserList: newUserId,
  135. ...flowJson,
  136. })
  137. //处理数据
  138. uni.hideLoading();
  139. if (!error && code === 200 && data === true) {
  140. eventChannel.emit('flowUserList', newUser);
  141. uni.navigateBack()
  142. } else {
  143. errorToast(msg)
  144. }
  145. }
  146. //获取选中的用户
  147. const getChecks = async () => {
  148. let res = [], arr = dataList.value;
  149. for (let i = 0; i < arr.length; i++) {
  150. const signList = arr[i].signPfxFileList;
  151. for (let j = 0; j < signList.length; j++) {
  152. if(signList[j].select){
  153. res.push(signList[j])
  154. }
  155. }
  156. }
  157. return res;
  158. }
  159. </script>
  160. <style lang="scss">
  161. @import "@/style/report/tasks-user.scss";
  162. </style>