WorkflowUserDefine.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <div>
  3. <div class="page-header">
  4. <h4 style="display: inline-block">
  5. {{ $t("lang.workflowUserDefine.approve") }}
  6. </h4>
  7. </div>
  8. <div>
  9. <div>
  10. <div
  11. v-for="userSelectDefine in userSelectDefineList"
  12. :key="userSelectDefine.nodeId"
  13. >
  14. <UserSelectDefine
  15. ref="userSelectDefine"
  16. :user-select-define="userSelectDefine"
  17. />
  18. </div>
  19. <div>
  20. <div>{{ $t("lang.workflowUserDefine.copyUser") }}</div>
  21. <a-select
  22. v-model:value="copyUserIds"
  23. mode="multiple"
  24. style="width: 100%"
  25. :options="copyUserList"
  26. :filter-option="false"
  27. :not-found-content="fetching ? undefined : null"
  28. :field-names="{ label: 'text', value: 'id' }"
  29. @search="handleChange"
  30. >
  31. <template v-if="fetching" #notFoundContent>
  32. <a-spin size="small" />
  33. </template>
  34. </a-select>
  35. </div>
  36. <div style="margin-top: 10px">
  37. <a-button type="primary" @click="apply">
  38. {{ $t("lang.workflowUserDefine.submit") }}
  39. </a-button>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import Common from '../common/Common.js';
  47. import WorkflowResource from '../api/workflow/WorkflowResource.js';
  48. import UserSelectDefine from './UserSelectDefine.vue';
  49. import vSelect from 'vue-select';
  50. import 'vue-select/dist/vue-select.css';
  51. import UserResource from '../api/base/UserResource.js';
  52. export default {
  53. components: {
  54. UserSelectDefine,
  55. vSelect,
  56. },
  57. // 工作流定义Id
  58. props: {
  59. workFlow: {
  60. type: Object,
  61. default: function(){
  62. return null;
  63. },
  64. },
  65. modelData: {
  66. type: Object,
  67. default: function(){
  68. return null;
  69. },
  70. },
  71. },
  72. emits: ['apply'],
  73. data: function () {
  74. this.Common = Common;
  75. return {
  76. userSelectDefineList: [],
  77. copyUsers: [],
  78. whereClause: 'organization.id IN (:EnvOrganizationIdList)',
  79. // 抄送人Id
  80. copyUserIds: [],
  81. copyUserList: [],
  82. fetching: false,
  83. };
  84. },
  85. mounted: function () {
  86. var _self = this;
  87. _self.calculateUserSelect();
  88. _self.listInGroupCompanyByCondition(null);
  89. },
  90. methods: {
  91. /**
  92. * 审批
  93. * @return {void}
  94. */
  95. apply: function () {
  96. this.$emit('apply');
  97. },
  98. handleChange: Common.debounce(function (value) {
  99. this.copyUserList = [];
  100. this.fetching = true;
  101. this.listInGroupCompanyByCondition(value);
  102. },500),
  103. /**
  104. * 计算哪些用户选择项可以执行
  105. */
  106. calculateUserSelect: function () {
  107. let _self = this;
  108. const userSelectCalculateRequest = {
  109. workflowId: this.workFlow.id,
  110. modelData: this.modelData,
  111. };
  112. WorkflowResource.calculateUserSelect(userSelectCalculateRequest).then(
  113. successData => {
  114. if (successData.errorCode == 0 && successData.datas == null) {
  115. _self.userSelectDefineList.splice(
  116. 0,
  117. _self.userSelectDefineList.length,
  118. );
  119. } else if (successData.errorCode == 0 && successData.datas != null){
  120. successData.datas.forEach(function (item) {
  121. item.editable = true;
  122. });
  123. _self.userSelectDefineList = successData.datas;
  124. }
  125. },
  126. errorData => {
  127. Common.processException(errorData);
  128. },
  129. );
  130. },
  131. /**
  132. * 获取审批人的数据
  133. */
  134. getData: function () {
  135. let param = {
  136. userSelectDtos: null,
  137. copyUsers: null,
  138. };
  139. let userSelectDtos = [];
  140. let userSelectDefineList = this.$refs.userSelectDefine;
  141. if (userSelectDefineList != null && userSelectDefineList.length > 0) {
  142. for (let i = 0; i < userSelectDefineList.length; i++) {
  143. let userTaskDto = userSelectDefineList[i].getData();
  144. userSelectDtos.push(userTaskDto);
  145. }
  146. param.userSelectDtos = userSelectDtos;
  147. }
  148. if (Array.isArray(this.copyUserIds)) {
  149. param.copyUsers = this.copyUserIds;
  150. } else {
  151. param.copyUsers = [this.copyUserIds];
  152. }
  153. return param;
  154. },
  155. /**
  156. * 根据姓名获取抄送人用户集合
  157. */
  158. listInGroupCompanyByCondition: function (search) {
  159. let _self = this;
  160. const searchQueryParam = {
  161. range: {
  162. start: 0,
  163. length: 1000,
  164. },
  165. conditional: search,
  166. };
  167. //修复审批节点选择人员显示文件编码bug
  168. var selectList = [];
  169. if (
  170. this.copyUserIds != undefined &&
  171. this.copyUserList != undefined &&
  172. this.copyUserList.length > 0 &&
  173. this.copyUserIds.length > 0
  174. ) {
  175. this.copyUserList.forEach(function (value, index) {
  176. var id = value.id;
  177. _self.copyUserIds.forEach(function (item) {
  178. if (item == id) {
  179. selectList.push(value);
  180. }
  181. });
  182. });
  183. }
  184. UserResource.listInGroupCompanyByCondition(searchQueryParam).then(
  185. successData => {
  186. if (successData != null && successData.resultList != null) {
  187. successData.resultList.forEach(function (user) {
  188. user.text = user.name + '(' + user.no + ')' + '(';
  189. if(user.organizations != null && user.organizations.length > 0){
  190. let isFirst = true;
  191. user.organizations.forEach(item => {
  192. if(isFirst === true){
  193. user.text += item.organizationName;
  194. isFirst = false;
  195. }else{
  196. user.text += (',' + item.organizationName);
  197. }
  198. });
  199. }
  200. user.text += ')';
  201. });
  202. _self.copyUserList = successData.resultList;
  203. } else {
  204. _self.copyUserList = [];
  205. }
  206. this.fetching = false;
  207. },
  208. errorData => {
  209. this.fetching = false;
  210. Common.processException(errorData);
  211. },
  212. );
  213. },
  214. },
  215. };
  216. </script>
  217. <style scoped>
  218. </style>