audit-user-picker.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <div>
  3. <sd-value-picker
  4. :render="renderList"
  5. :modal-props="{ class: $style.userpicker }"
  6. v-bind="$props"
  7. option-value="code"
  8. :single-column="$props.single"
  9. v-on="$listeners"
  10. @change="change"
  11. >
  12. <template v-slot="scope">
  13. <AuditPickerUsersByGroup
  14. title="按机构"
  15. icon="apartment"
  16. v-bind="scope"
  17. :render="renderList"
  18. :root-node="rootNode"
  19. :hierarchical="hierarchical"
  20. :secret-level="secretLevel"
  21. />
  22. <sd-picker-source-list
  23. title="常用的"
  24. icon="user"
  25. :load-list-data="() => recentUser()"
  26. v-bind="scope"
  27. :show-search="false"
  28. />
  29. </template>
  30. <template v-slot:targetListHeader="{ targetKeys, targetValues }">
  31. <a-button type="link" icon="save" title="保存群组" @click="userGroupClick(targetValues)" />
  32. </template>
  33. <a-icon v-if="!readOnly" slot="suffixIcon" type="user" />
  34. </sd-value-picker>
  35. <a-modal
  36. ok-text="保存"
  37. cancel-text="退出"
  38. :mask="true"
  39. destroy-tooltip-on-hide
  40. :visible="confirm.confirmvisible"
  41. @ok="saveconfirm"
  42. @cancel="cancelconfirm"
  43. >
  44. <a-form-model ref="ruleForm" :model="confirm.form" :rules="confirm.rules">
  45. <a-form-model-item ref="groupName" label="群组名称" prop="groupName">
  46. <a-input v-model="confirm.form.groupName" />
  47. </a-form-model-item>
  48. </a-form-model>
  49. </a-modal>
  50. </div>
  51. </template>
  52. <script>
  53. import AddressBook from '@/addressbook/group-user-service'
  54. import PageService from '@/common/services/page-service'
  55. import axios from '@/common/services/axios-instance'
  56. import { Modal, Message } from 'ant-design-vue'
  57. import sdUserinfoCard from '@/common/components/sd-user-item/sd-userinfo-card'
  58. // import { sdLocalStorage } from '../../../../../../src/common/services/storage-service'
  59. import pickerMixin from './picker-mixin'
  60. import AuditPickerUsersByGroup from './audit-picker-users-by-group.vue'
  61. // import SdPickerUsersByUsergroup from './sd-picker/sd-picker-users-by-usergroup.vue'
  62. // import SdPickerUsersByDepgroup from './sd-picker/sd-picker-users-by-depgroup.vue'
  63. import components from './_import-components/audit-user-picker-import'
  64. let saveValues
  65. export default {
  66. name: 'AuditUserPicker',
  67. components: {
  68. ...components,
  69. AuditPickerUsersByGroup,
  70. // SdPickerUsersByUsergroup,
  71. // SdPickerUsersByDepgroup,
  72. },
  73. mixins: [pickerMixin],
  74. metaInfo: {
  75. title: 'AuditUsersPicker',
  76. },
  77. props: {
  78. rootNode: {
  79. type: [Object, Array],
  80. default: undefined,
  81. },
  82. /**
  83. * 当开启分级授权时,是否过滤掉启用分级授权的子公司,true时过滤,false时不过滤
  84. *
  85. */
  86. hierarchical: {
  87. type: Boolean,
  88. default: undefined,
  89. },
  90. /**
  91. * 密级,开启等分保功能后,可按密级过滤人员
  92. * @since 0.17
  93. */
  94. secretLevel: {
  95. type: String,
  96. default: '',
  97. },
  98. },
  99. data() {
  100. return {
  101. confirm: {
  102. confirmvisible: false,
  103. pageflowId: '',
  104. pagePath: '',
  105. groupData: [],
  106. form: {
  107. groupName: '',
  108. },
  109. rules: {
  110. groupName: [{ required: true, message: '请输入群组名称', trigger: ['change', 'blur'] }],
  111. },
  112. },
  113. }
  114. },
  115. inject: {
  116. webflow: { default: () => ({}) },
  117. },
  118. methods: {
  119. // 获取流程参与人
  120. participant() {
  121. const params = {}
  122. if (this.secretLevel) {
  123. params.securityLevel = this.secretLevel
  124. }
  125. return axios
  126. .get(
  127. `api/xcoa-mobile/v1/user-manager/instance/${this.webflow.FlowData?.instId ||
  128. 0}/processors`,
  129. {
  130. params,
  131. }
  132. )
  133. .then((res) => {
  134. return (res.data || []).map((item) => {
  135. return {
  136. id: item.id,
  137. code: item.props.account,
  138. name: item.text,
  139. props: item.props,
  140. }
  141. })
  142. })
  143. .catch(() => {
  144. Message.error('获取流程参与人失败')
  145. return []
  146. })
  147. },
  148. recentUser() {
  149. // const recents = JSON.parse(sdLocalStorage.getItem('recentUser') || '[]')
  150. // // 有密级且有常用人时,调用接口按密级过滤
  151. // if (this.secretLevel && recents.length > 0) {
  152. // return axios
  153. // .post(`api/xcoa-mobile/v1/user-manager/filter_user_by_securityl`, {
  154. // sourceSecurityL: this.secretLevel,
  155. // targetUser: recents.map((item) => item.code),
  156. // })
  157. // .then((res) => recents.filter((item) => (res.data || []).includes(item.code)))
  158. // .catch(() => [])
  159. // } else {
  160. // return Promise.resolve(recents)
  161. // }
  162. return []
  163. },
  164. renderList(item) {
  165. return [
  166. <span class={this.$style.label}>{item.name}</span>,
  167. <sdUserinfoCard account={item.code} />,
  168. ]
  169. },
  170. // 打开保存个人组
  171. userGroupClick(targetValues) {
  172. if (targetValues.length < 1) {
  173. Message.warning('请选择人员')
  174. return
  175. }
  176. saveValues = targetValues
  177. this.confirm.form.groupName = ''
  178. PageService.get({}, 'personal/usergroup/personalUserGroup').then((res) => {
  179. if (res.status === 200) {
  180. this.confirm.groupData = res.data
  181. this.confirm.confirmvisible = true
  182. }
  183. })
  184. },
  185. // 关闭组
  186. cancelconfirm() {
  187. this.confirm.confirmvisible = false
  188. },
  189. // 保存个人组
  190. saveconfirm() {
  191. this.$refs.ruleForm.validate((valid) => {
  192. if (valid) {
  193. const groupName = this.confirm.form.groupName
  194. // 检查群组名是否存在
  195. AddressBook.checkExistGroupByName(groupName).then((res) => {
  196. if (res.data === true) {
  197. Message.warn('已存在群组名[' + groupName + '],请重新输入!')
  198. return false
  199. } else {
  200. const resJson = this.confirm.groupData
  201. resJson.pageFormData.pageFieldInfos.forEach((item) => {
  202. if (item.name === 'groupName') {
  203. item.value = this.confirm.form.groupName
  204. }
  205. if (item.name === 'members') {
  206. item.value = JSON.stringify(saveValues)
  207. }
  208. })
  209. const params = {
  210. eventId: 'save',
  211. inputs: resJson.pageFormData.pageFieldInfos.map((v) => ({
  212. name: v.name,
  213. value: v.value,
  214. })),
  215. pageFlowId: resJson.attrs.pageflowId,
  216. pagePath: resJson.attrs.pagePath,
  217. }
  218. PageService.save(params)
  219. .then((res) => {
  220. Message.success('保存成功')
  221. this.confirm.confirmvisible = false
  222. this.$refs.SdPickerUsersByUsergroup?.updateTree()
  223. })
  224. .catch((err) => {
  225. Modal.error({
  226. title: '保存失败',
  227. content: err.response?.data?.message?.split(':')[1] || '保存失败',
  228. })
  229. })
  230. }
  231. })
  232. } else {
  233. return false
  234. }
  235. })
  236. },
  237. change(users) {
  238. // 常用选择人
  239. // let recentUser = JSON.parse(sdLocalStorage.getItem('recentUser') || '[]')
  240. // users.forEach((item) => {
  241. // if (!recentUser.find((user) => user.code === item.code)) {
  242. // recentUser.unshift(item)
  243. // }
  244. // })
  245. // recentUser = recentUser.slice(0, 100)
  246. // sdLocalStorage.setItem('recentUser', JSON.stringify(recentUser))
  247. },
  248. },
  249. }
  250. </script>
  251. <style module lang="scss">
  252. @use '@/common/design' as *;
  253. .userpicker {
  254. :global(.ant-tabs-tabpane):nth-child(1) {
  255. margin-left: 270px;
  256. }
  257. :global(.ant-tabs-tabpane):nth-child(2) {
  258. margin-left: 270px;
  259. }
  260. :global(.ant-tabs-tabpane):nth-child(3) {
  261. margin-left: 270px;
  262. :global(.ant-transfer-list):first-child {
  263. top: 250px;
  264. height: 250px;
  265. }
  266. :global(.source-list-header_sd-value-picker_common) button {
  267. top: 250px;
  268. }
  269. }
  270. :global(.ant-transfer-list-body-customize-wrapper) {
  271. > div {
  272. height: 100%;
  273. }
  274. }
  275. div[mask='true'] {
  276. display: inline-block;
  277. }
  278. a {
  279. display: none;
  280. }
  281. :global(.ant-transfer-list-content-item:not(.ant-transfer-list-content-item-disabled):hover) {
  282. a {
  283. display: inline;
  284. }
  285. }
  286. :global(.ant-tabs-left-content) {
  287. height: 500px;
  288. }
  289. }
  290. .label {
  291. display: inline-block;
  292. width: calc(100% - 42px);
  293. min-width: 120px;
  294. overflow: hidden;
  295. text-overflow: ellipsis;
  296. vertical-align: top;
  297. }
  298. </style>