WorkflowSearch.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <a-dropdown v-model:open="visible" :trigger="['click']">
  3. <a-button v-if="!isShowClear" style="margin-left: 12px">
  4. <align-center-outlined />
  5. 高级筛选
  6. </a-button>
  7. <a-button v-else style="margin-left: 12px; color: #40a9ff">
  8. <align-center-outlined />
  9. 高级筛选
  10. </a-button>
  11. <template #overlay>
  12. <a-form
  13. :model="formState"
  14. name="basic"
  15. autocomplete="off"
  16. style="width: 458px; padding: 20px"
  17. >
  18. <a-form-item
  19. v-if="functionType != 4 && functionType != 6"
  20. label="审批单发起人:"
  21. name="startUserId"
  22. style="margin-bottom: 12px"
  23. >
  24. <a-select
  25. v-model:value="formState.startUserId"
  26. placeholder="请选择审批人"
  27. style="width: 418px"
  28. :filter-option="false"
  29. :field-names="{ label: 'text', value: 'id' }"
  30. :not-found-content="fetching ? undefined : null"
  31. :options="copyUserIds"
  32. show-search
  33. @search="fetchUser"
  34. >
  35. <template v-if="fetching" #notFoundContent>
  36. <a-spin size="small" />
  37. </template>
  38. </a-select>
  39. </a-form-item>
  40. <a-form-item label="提交审批时间:">
  41. <a-date-picker
  42. v-model:value="formState.processInstanceStartAfter"
  43. @change="(_, str) => dateChange(str, 'processInstanceStartAfter')"
  44. />
  45. <a-date-picker
  46. v-model:value="formState.processInstanceStartBefore"
  47. @change="(_, str) => dateChange(str, 'processInstanceStartBefore')"
  48. />
  49. </a-form-item>
  50. <a-form-item v-if="functionType == 2" label="任务开始时间:">
  51. <a-date-picker
  52. v-model:value="formState.taskCreateTimeAfter"
  53. @change="(_, str) => dateChange(str, 'taskCreateTimeAfter')"
  54. />
  55. <a-date-picker
  56. v-model:value="formState.taskCreateTimeBefore"
  57. @change="(_, str) => dateChange(str, 'taskCreateTimeBefore')"
  58. />
  59. </a-form-item>
  60. <a-form-item v-if="functionType == 3" label="完成审批时间:">
  61. <a-date-picker
  62. v-model:value="formState.taskEndTimeAfter"
  63. @change="(_, str) => dateChange(str, 'taskEndTimeAfter')"
  64. />
  65. <a-date-picker
  66. v-model:value="formState.taskEndTimeBefore"
  67. @change="(_, str) => dateChange(str, 'taskEndTimeBefore')"
  68. />
  69. </a-form-item>
  70. <a-form-item
  71. v-if="functionType == 4 || functionType == 6"
  72. label="完成审批时间:"
  73. >
  74. <a-date-picker
  75. v-model:value="formState.processInstanceEndAfter"
  76. @change="(_, str) => dateChange(str, 'processInstanceEndAfter')"
  77. />
  78. <a-date-picker
  79. v-model:value="formState.processInstanceEndBefore"
  80. @change="(_, str) => dateChange(str, 'processInstanceEndBefore')"
  81. />
  82. </a-form-item>
  83. <a-divider />
  84. <a-row type="flex" align="middle" justify="space-between">
  85. <a-col>
  86. <span v-if="!isShowClear" style="color: #c8c8c9; cursor: pointer">清空搜索条件</span>
  87. <a v-else @click="clearFilter"> 清空搜索条件</a>
  88. </a-col>
  89. <a-col>
  90. <a-button @click="visible = false">取消</a-button>
  91. <a-button
  92. type="primary"
  93. style="margin-left: 12px"
  94. @click="searchWorkflow"
  95. >
  96. 确认
  97. </a-button>
  98. </a-col>
  99. </a-row>
  100. </a-form>
  101. </template>
  102. </a-dropdown>
  103. </template>
  104. <script setup>
  105. import Common from '../common/Common';
  106. import { ref, defineEmits, defineProps, watch, onMounted } from 'vue';
  107. import UserResource from '../api/base/UserResource.js';
  108. import { AlignCenterOutlined } from '@ant-design/icons-vue';
  109. const emit = defineEmits(['getSearchParams']);
  110. const props = defineProps({
  111. functionType: {
  112. type: Number,
  113. default: 2,
  114. },
  115. });
  116. const formState = ref({});
  117. const visible = ref(false);
  118. const fetching = ref(false);
  119. const searchParams = ref({});
  120. const isShowClear = ref(false);
  121. const copyUserIds = ref([]);
  122. // 获取日期string格式
  123. const dateChange = (value, key) => {
  124. if (value) {
  125. if (
  126. key === 'processInstanceStartAfter' ||
  127. key === 'taskCreateTimeAfter' ||
  128. key === 'taskEndTimeAfter' ||
  129. key === 'processInstanceEndAfter'
  130. ) {
  131. searchParams.value[key] = value + ' 00:00:00';
  132. } else {
  133. searchParams.value[key] = value + ' 23:59:59';
  134. }
  135. } else {
  136. searchParams.value[key] = value;
  137. }
  138. };
  139. // 将搜索参数传过去
  140. const searchWorkflow = () => {
  141. visible.value = false;
  142. const params = JSON.parse(
  143. JSON.stringify({ ...formState.value, ...searchParams.value }),
  144. );
  145. emit('getSearchParams', params);
  146. };
  147. onMounted(() => {
  148. getUsers();
  149. });
  150. const fetchUser = Common.debounce(value => {
  151. copyUserIds.value = [];
  152. fetching.value = true;
  153. getUsers(value);
  154. }, 500);
  155. // 筛选
  156. // const filterOption = (input, option) => {
  157. // return option.text.toLowerCase().indexOf(input.toLowerCase()) >= 0;
  158. // };
  159. // 清空搜索条件
  160. const clearFilter = () => {
  161. formState.value = {};
  162. searchParams.value = {};
  163. isShowClear.value = false;
  164. };
  165. watch(
  166. formState,
  167. newData => {
  168. const obj = JSON.parse(JSON.stringify(newData));
  169. isShowClear.value = validValue(obj);
  170. },
  171. { deep: true },
  172. );
  173. // 用来判断是否有高级搜索条件
  174. const validValue = obj => {
  175. for (const [key, value] of Object.entries(obj)) {
  176. if (value !== undefined && value !== null && value !== '') {
  177. return true;
  178. }
  179. }
  180. return false;
  181. };
  182. // 查询审批人
  183. const getUsers = value => {
  184. const params = {
  185. range: {
  186. start: 0,
  187. length: 1000,
  188. },
  189. conditional: value,
  190. };
  191. UserResource.listInGroupCompanyByCondition(params).then(
  192. successData => {
  193. if (successData != null && successData.resultList != null) {
  194. successData.resultList.forEach(function (user) {
  195. user.text = user.name + '(' + user.no + ')' + '(';
  196. if (user.organizations != null && user.organizations.length > 0) {
  197. let isFirst = true;
  198. user.organizations.forEach(item => {
  199. if (isFirst === true) {
  200. user.text += item.organizationName;
  201. isFirst = false;
  202. } else {
  203. user.text += ',' + item.organizationName;
  204. }
  205. });
  206. }
  207. user.text += ')';
  208. });
  209. copyUserIds.value = successData.resultList;
  210. } else {
  211. copyUserIds.value = [];
  212. }
  213. fetching.value = false;
  214. },
  215. errorData => {
  216. fetching.value = false;
  217. Common.processException(errorData);
  218. },
  219. );
  220. };
  221. </script>
  222. <style scoped>
  223. :deep(.ant-form-item-label) > label {
  224. font-weight: 500;
  225. font-size: 14px !important;
  226. }
  227. .ant-divider-horizontal {
  228. margin: 12px 0;
  229. }
  230. </style>