WorkflowSearch.vue 6.5 KB

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