index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div :class="ui" class="hc-report-tasks-user-box">
  3. <div class="tag-user-list" @click="userShowModal">
  4. <template v-for="(item, index) in userData" :key="index">
  5. <el-tag>{{ item.userName }}</el-tag>
  6. <hc-icon v-if="(userData.length - 1) > index" name="arrow-right" ui="arrow-icon-tag" />
  7. </template>
  8. <div v-if="userData.length <= 0" class="tasks-placeholder">
  9. <span v-if="!isChangePopele"> 点击这里选择任务人</span>
  10. <span v-else> 点击这里选择整改人</span>
  11. </div>
  12. </div>
  13. <!-- 选择任务人 -->
  14. <HcUserModal v-model="isUserModalShow" :data="userData" :datas="dataInfo" :fixed-flow-link-type-val="fixedFlowLinkTypeVal" @finish="fixedUserFinish" />
  15. </div>
  16. </template>
  17. <script setup>
  18. import { ref, watch } from 'vue'
  19. import { arrToKey, deepClone, getObjValue } from 'js-fast-way'
  20. import HcUserModal from './user-modal.vue'
  21. import { checkCustomFlowUserIsEVisaPermissions, checkCustomFlowUserIsEVisaPermissions3, checkCustomFlowUserIsEVisaPermissionsquery } from '~api/other'
  22. //参数
  23. const props = defineProps({
  24. ui: {
  25. type: String,
  26. default: '',
  27. },
  28. data: {
  29. type: Object,
  30. default: () => ({}),
  31. },
  32. //选中的用户数组
  33. users: {
  34. type: Array,
  35. default: () => ([]),
  36. },
  37. projectId: {
  38. type: [String, Number],
  39. default: '',
  40. },
  41. contractId: {
  42. type: [String, Number],
  43. default: '',
  44. },
  45. type: { //first,log,wbs
  46. type: [String, Number],
  47. default: '',
  48. },
  49. typeData: {
  50. type: [String, Number, Array, Object],
  51. default: '',
  52. },
  53. classifyType: {
  54. type: [String, Number],
  55. default: '',
  56. },
  57. tableOwner: {
  58. type: [String, Number],
  59. default: '',
  60. },
  61. nodeId: {
  62. type: [String, Number],
  63. default: '', //选中节点nodeid
  64. },
  65. infoIds:{
  66. type: [String, Number],
  67. default: '', //上报任务ID
  68. },
  69. disabled:{
  70. type:Boolean,
  71. default:false,
  72. },
  73. isChangePopele:{
  74. type:Boolean,
  75. default:false, //显示整改人还是任务人
  76. },
  77. fixedFlowLinkTypeVal: {
  78. type: [String, Number],
  79. default: '', //流程审批1,平行审批2
  80. },
  81. })
  82. //事件
  83. const emit = defineEmits(['change'])
  84. const projectId = ref(props.projectId)
  85. const contractId = ref(props.contractId)
  86. const isTypes = ref(props.type)
  87. const typeDatas = ref(props.typeData)
  88. const classifyType = ref(props.classifyType)
  89. const tableOwner = ref(props.tableOwner)
  90. const nodeId = ref(props.nodeId)
  91. const infoIds = ref(props.infoIds)
  92. const disabled = ref(props.disabled)
  93. const isChangePopele = ref(props.isChangePopele)
  94. const fixedFlowLinkTypeVal = ref(props.fixedFlowLinkTypeVal)
  95. //监听
  96. watch(() => [
  97. props.users,
  98. props.projectId,
  99. props.contractId,
  100. props.type,
  101. props.typeData,
  102. props.classifyType,
  103. props.tableOwner,
  104. props.nodeId,
  105. props.infoIds,
  106. props.disabled,
  107. props.isChangePopele,
  108. props.fixedFlowLinkTypeVal,
  109. ], ([users, pid, cid, type, data, cla, tab, noid, infoid, disa, isChan, typeVal]) => {
  110. userData.value = users
  111. projectId.value = pid
  112. contractId.value = cid
  113. isTypes.value = type
  114. typeDatas.value = data
  115. classifyType.value = cla
  116. tableOwner.value = tab
  117. nodeId.value = noid
  118. infoIds.value = infoid
  119. disabled.value = disa
  120. isChangePopele.value = isChan
  121. fixedFlowLinkTypeVal.value = typeVal
  122. })
  123. //监听基础数据
  124. const dataInfo = ref(props.data)
  125. watch(() => props.data, (data) => {
  126. dataInfo.value = getObjValue(data)
  127. }, { deep: true, immediate: true })
  128. //展开弹窗
  129. const isUserModalShow = ref(false)
  130. const userShowModal = () => {
  131. isUserModalShow.value = true
  132. }
  133. //选择完成
  134. const userData = ref(props.users)
  135. const fixedUserFinish = (data) => {
  136. const res = deepClone(data)
  137. userData.value = res
  138. const userIds = arrToKey(res, 'userId', ',')
  139. let userIdsArr = userIds.split(',')
  140. sureSignUserClick(userIdsArr, userData.value )
  141. }
  142. //确认选择
  143. const sureSignUserLoading = ref(false)
  144. const sureSignUserClick = (userIds, userData) => {
  145. let type = isTypes.value, flowJson = {}
  146. if (userIds.length > 0) {
  147. sureSignUserLoading.value = true
  148. //判断类型
  149. if (type === 'first') {
  150. flowJson['firstId'] = typeDatas.value
  151. } else if (type === 'log') {
  152. // flowJson['theLogPrimaryKeyId'] = typeDatas.value
  153. flowJson['theLogPrimaryKeyId'] = nodeId.value
  154. } else if (type === 'wbs') {
  155. flowJson['privatePKeyId'] = typeDatas.value
  156. } else if (type === 'query') {
  157. flowJson['privatePKeyId'] = typeDatas.value
  158. }
  159. //效验人员
  160. if (type === 'wbs') {
  161. getCheckCustomFlowUserIsEVisaPermissions(flowJson, userIds)
  162. } else if (type === 'first' || type === 'log' ) {
  163. getCheckCustomFlowUserIsEVisaPermissions3(flowJson, userIds)
  164. } else if (type === 'query') {
  165. getCheckCustomFlowUserIsEVisaPermissionsquery(flowJson, userIds)
  166. } else {
  167. sureSignUserLoading.value = false
  168. emit('change', userData)
  169. }
  170. } else {
  171. window.$message?.warning('请先选择任务人员,或点击取消')
  172. }
  173. }
  174. //检查所选的流程环节处理人是否具有审批权限(三大填报页、日志列表的批量上报、首件列表的批量上报)
  175. const getCheckCustomFlowUserIsEVisaPermissions = async (flowJson, newUserId) => {
  176. console.log( dataInfo.value, ' dataInfo.value')
  177. const { error, code, data, msg, success } = await checkCustomFlowUserIsEVisaPermissions({
  178. projectId: dataInfo.value.projectId,
  179. contractId: dataInfo.value.contractId,
  180. customFlowUserList: newUserId,
  181. ...flowJson,
  182. classifyType:classifyType.value,
  183. tableOwner:tableOwner.value,
  184. nodeId:nodeId.value,
  185. })
  186. //处理数据
  187. sureSignUserLoading.value = false
  188. if (!error && code === 200 && data === true) {
  189. emit('change', userData.value)
  190. isUserModalShow.value = false
  191. } else {
  192. // window.$message.error(msg)
  193. userData.value = []
  194. emit('change', [])
  195. }
  196. }
  197. //资料查询页面
  198. const getCheckCustomFlowUserIsEVisaPermissionsquery = async (flowJson, newUserId) => {
  199. const { error, code, data, msg } = await checkCustomFlowUserIsEVisaPermissionsquery({
  200. projectId: projectId.value,
  201. contractId: contractId.value,
  202. customFlowUserList: newUserId,
  203. ...flowJson,
  204. nodeId:nodeId.value,
  205. classifyType:classifyType.value,
  206. tableOwner:tableOwner.value,
  207. infoIds:infoIds.value,
  208. })
  209. //处理数据
  210. sureSignUserLoading.value = false
  211. if (!error && code === 200 && data === true) {
  212. isUserModalShow.value = false
  213. emit('change', userData.value)
  214. } else {
  215. // window.$message.error(msg)
  216. userData.value = []
  217. emit('change', [])
  218. }
  219. }
  220. //日志和首件页面
  221. const getCheckCustomFlowUserIsEVisaPermissions3 = async (flowJson, newUserId) => {
  222. const { error, code, data, msg } = await checkCustomFlowUserIsEVisaPermissions3({
  223. projectId: projectId.value,
  224. contractId: contractId.value,
  225. customFlowUserList: newUserId,
  226. ...flowJson,
  227. // nodeId:nodeId.value,
  228. classifyType:classifyType.value,
  229. tableOwner:tableOwner.value,
  230. infoIds:infoIds.value,
  231. })
  232. //处理数据
  233. sureSignUserLoading.value = false
  234. if (!error && code === 200 && data === true) {
  235. isUserModalShow.value = false
  236. emit('change', userData.value)
  237. } else {
  238. // window.$message.error(msg)
  239. userData.value = []
  240. emit('change', [])
  241. }
  242. }
  243. </script>
  244. <style lang="scss">
  245. @import './index.scss';
  246. </style>