zhangjie 1 gadu atpakaļ
vecāks
revīzija
5a209c5ea2

+ 12 - 2
src/api/resource-guard.js

@@ -64,12 +64,22 @@ export const personAllocateDeployApi = (data) =>
 export const personAllocateSubmitSopApi = (crmNo) =>
   request({
     url: '/api/admin/user/archives/allocation/publish',
-    param: { crmNo },
+    params: { crmNo },
   });
 export const personAllocateCancelSubmitSopApi = (crmNo) =>
   request({
     url: '/api/admin/user/archives/allocation/un_publish',
-    param: { crmNo },
+    params: { crmNo },
+  });
+export const personAllocateFreeEngineerApi = (roleType) =>
+  request({
+    url: '/api/admin/user/archives/allocation/free_engineer',
+    params: { roleType },
+  });
+export const personAllocateFreeCoordinatorApi = (serviceUnitId) =>
+  request({
+    url: '/api/admin/user/archives/allocation/free_coordinator',
+    params: { serviceUnitId },
   });
 
 // registration-query

+ 3 - 3
src/components/common/select-customer/index.vue

@@ -47,13 +47,13 @@ const search = async () => {
 };
 
 const onChange = () => {
-  const selectedData = isMultiple
+  const selectedData = isMultiple.value
     ? optionList.value.filter(
         (item) => selected.value && selected.value.includes(item.id)
       )
     : optionList.value.filter((item) => selected.value === item.id);
   emit('update:modelValue', selected.value);
-  emit('change', isMultiple ? selectedData : selectedData[0]);
+  emit('change', isMultiple.value ? selectedData : selectedData[0]);
 };
 
 onMounted(() => {
@@ -72,7 +72,7 @@ watch(
     if (val !== oldval) {
       search();
       emit('update:modelValue', null);
-      emit('change', isMultiple ? [] : null);
+      emit('change', isMultiple.value ? [] : null);
     }
   }
 );

+ 87 - 0
src/components/common/select-free-engineer/index.vue

@@ -0,0 +1,87 @@
+<template>
+  <t-select
+    v-model="selected"
+    filterable
+    clearable
+    v-bind="attrs"
+    @change="onChange"
+  >
+    <t-option
+      v-for="item in optionList"
+      :key="item.userId"
+      :value="item.userId"
+      :label="item.name"
+    />
+  </t-select>
+</template>
+
+<script setup name="SelectFreeEngineer">
+import { onMounted, ref, useAttrs, watch, computed } from 'vue';
+import {
+  personAllocateFreeCoordinatorApi,
+  personAllocateFreeEngineerApi,
+} from '@/api/resource-guard';
+
+let optionList = ref([]);
+let selected = ref('');
+
+const attrs = useAttrs();
+
+const emit = defineEmits(['update:modelValue', 'change']);
+const props = defineProps({
+  modelValue: { type: [Number, String, Array], default: '' },
+  type: { type: String, default: '' },
+  unitId: { type: String, default: '' },
+});
+const isMultiple = computed(() => {
+  const multiple = attrs.multiple;
+  return multiple === '' || multiple;
+});
+
+const search = async () => {
+  if (!props.type) return;
+  optionList.value = [];
+
+  let res = null;
+  if (props.type === 'REGION_COORDINATOR') {
+    res = await personAllocateFreeCoordinatorApi(props.unitId).catch(() => {});
+    if (!res) return;
+  } else {
+    res = await personAllocateFreeEngineerApi(props.type).catch(() => {});
+    if (!res) return;
+  }
+
+  optionList.value = res;
+};
+
+const onChange = () => {
+  const selectedData = isMultiple.value
+    ? optionList.value.filter(
+        (item) => selected.value && selected.value.includes(item.userId)
+      )
+    : optionList.value.filter((item) => selected.value === item.userId);
+  emit('update:modelValue', selected.value);
+  emit('change', isMultiple.value ? selectedData : selectedData[0]);
+};
+
+onMounted(() => {
+  search();
+});
+
+watch(
+  () => props.modelValue,
+  (val) => {
+    selected.value = val;
+  }
+);
+watch(
+  () => props.type,
+  (val, oldval) => {
+    if (val !== oldval) {
+      search();
+      emit('update:modelValue', null);
+      emit('change', isMultiple.value ? [] : null);
+    }
+  }
+);
+</script>

+ 2 - 2
src/components/common/select-product/index.vue

@@ -43,13 +43,13 @@ const search = async () => {
 };
 
 const onChange = () => {
-  const selectedData = isMultiple
+  const selectedData = isMultiple.value
     ? optionList.value.filter(
         (item) => selected.value && selected.value.includes(item.id)
       )
     : optionList.value.filter((item) => selected.value === item.id);
   emit('update:modelValue', selected.value);
-  emit('change', isMultiple ? selectedData : selectedData[0]);
+  emit('change', isMultiple.value ? selectedData : selectedData[0]);
 };
 
 onMounted(() => {

+ 2 - 2
src/components/common/select-role/index.vue

@@ -42,13 +42,13 @@ const search = async () => {
 };
 
 const onChange = () => {
-  const selectedData = isMultiple
+  const selectedData = isMultiple.value
     ? optionList.value.filter(
         (item) => selected.value && selected.value.includes(item.id)
       )
     : optionList.value.filter((item) => selected.value === item.id);
   emit('update:modelValue', selected.value);
-  emit('change', isMultiple ? selectedData : selectedData[0]);
+  emit('change', isMultiple.value ? selectedData : selectedData[0]);
 };
 
 onMounted(() => {

+ 3 - 3
src/components/common/select-service-level/index.vue

@@ -48,13 +48,13 @@ const search = async () => {
 };
 
 const onChange = () => {
-  const selectedData = isMultiple
+  const selectedData = isMultiple.value
     ? optionList.value.filter(
         (item) => selected.value && selected.value.includes(item.id)
       )
     : optionList.value.filter((item) => selected.value === item.id);
   emit('update:modelValue', selected.value);
-  emit('change', isMultiple ? selectedData : selectedData[0]);
+  emit('change', isMultiple.value ? selectedData : selectedData[0]);
 };
 
 onMounted(() => {
@@ -73,7 +73,7 @@ watch(
     if (val !== oldval) {
       search();
       emit('update:modelValue', null);
-      emit('change', isMultiple ? [] : null);
+      emit('change', isMultiple.value ? [] : null);
     }
   }
 );

+ 16 - 4
src/components/common/select-service-unit/index.vue

@@ -24,9 +24,10 @@ let selected = ref('');
 
 const attrs = useAttrs();
 
-const emit = defineEmits(['update:modelValue', 'change']);
+const emit = defineEmits(['update:modelValue', 'change', 'default-selected']);
 const props = defineProps({
   modelValue: { type: [Number, String, Array], default: '' },
+  defaultSelect: { type: Boolean, default: false },
   filterParams: {
     type: Object,
     default() {
@@ -49,16 +50,27 @@ const search = async () => {
   if (!res) return;
 
   optionList.value = res;
+
+  if (props.defaultSelect && !props.modelValue) selectDefault();
+};
+
+const selectDefault = () => {
+  const defaultOption = optionList.value[0];
+  if (defaultOption) {
+    selected.value = isMultiple.value ? [defaultOption.id] : defaultOption.id;
+    onChange();
+    emit('default-selected', defaultOption);
+  }
 };
 
 const onChange = () => {
-  const selectedData = isMultiple
+  const selectedData = isMultiple.value
     ? optionList.value.filter(
         (item) => selected.value && selected.value.includes(item.id)
       )
     : optionList.value.filter((item) => selected.value === item.id);
   emit('update:modelValue', selected.value);
-  emit('change', isMultiple ? selectedData : selectedData[0]);
+  emit('change', isMultiple.value ? selectedData : selectedData[0]);
 };
 
 onMounted(() => {
@@ -77,7 +89,7 @@ watch(
     if (JSON.stringify(val) !== JSON.stringify(oldval)) {
       search();
       emit('update:modelValue', null);
-      emit('change', isMultiple ? [] : null);
+      emit('change', isMultiple.value ? [] : null);
     }
   },
   {

+ 3 - 3
src/components/common/select-supplier/index.vue

@@ -48,13 +48,13 @@ const search = async () => {
 };
 
 const onChange = () => {
-  const selectedData = isMultiple
+  const selectedData = isMultiple.value
     ? optionList.value.filter(
         (item) => selected.value && selected.value.includes(item.id)
       )
     : optionList.value.filter((item) => selected.value === item.id);
   emit('update:modelValue', selected.value);
-  emit('change', isMultiple ? selectedData : selectedData[0]);
+  emit('change', isMultiple.value ? selectedData : selectedData[0]);
 };
 
 onMounted(() => {
@@ -73,7 +73,7 @@ watch(
     if (val !== oldval) {
       search();
       emit('update:modelValue', null);
-      emit('change', isMultiple ? [] : null);
+      emit('change', isMultiple.value ? [] : null);
     }
   }
 );

+ 3 - 3
src/components/common/select-type-user/index.vue

@@ -44,13 +44,13 @@ const search = async () => {
 };
 
 const onChange = () => {
-  const selectedData = isMultiple
+  const selectedData = isMultiple.value
     ? optionList.value.filter(
         (item) => selected.value && selected.value.includes(item.id)
       )
     : optionList.value.filter((item) => selected.value === item.id);
   emit('update:modelValue', selected.value);
-  emit('change', isMultiple ? selectedData : selectedData[0]);
+  emit('change', isMultiple.value ? selectedData : selectedData[0]);
 };
 
 onMounted(() => {
@@ -69,7 +69,7 @@ watch(
     if (val !== oldval) {
       search();
       emit('update:modelValue', null);
-      emit('change', isMultiple ? [] : null);
+      emit('change', isMultiple.value ? [] : null);
     }
   }
 );

+ 12 - 2
src/views/resource-guard/person-guard/person-allocate/index.vue

@@ -2,7 +2,11 @@
   <div class="person-allocate flex flex-col h-full">
     <SearchForm :fields="fields" :params="params">
       <template #service="{ item, params }">
-        <select-service-unit v-model="params[item.prop]"></select-service-unit>
+        <select-service-unit
+          v-model="params[item.prop]"
+          default-select
+          @default-selected="initData"
+        ></select-service-unit>
       </template>
       <template #area>
         <select-area
@@ -224,7 +228,8 @@ const { pagination, tableData, fetchData, search, onChange } = useFetchTable(
       selectedRowKeys.value = [];
     },
     params,
-  }
+  },
+  false
 );
 
 const rolesFilter = (row) => {
@@ -257,6 +262,11 @@ const personDeploySuccess = () => {
   getStatisticsInfo();
 };
 
+const initData = () => {
+  search();
+  getStatisticsInfo();
+};
+
 const areaChange = (data) => {
   params.provice = data[0];
   params.city = data[1];

+ 20 - 10
src/views/resource-guard/person-guard/person-allocate/person-deploy-dialog.vue

@@ -55,11 +55,15 @@
                   <span>{{ row.quota }}</span>
                 </template>
                 <template #users="{ row }">
-                  <select-type-user
+                  <select-free-engineer
                     v-model="row.userIdList"
                     :type="row.roleType"
-                    :multiple="row.roleType !== 'REGION_COORDINATOR'"
-                  ></select-type-user>
+                    :unit-id="curRow.serviceUnitId"
+                    multiple
+                    :min-collapsed-num="3"
+                    :filterable="false"
+                    :max="row.roleType === 'REGION_COORDINATOR' ? 1 : 0"
+                  ></select-free-engineer>
                 </template>
                 <template #operate="{ row }">
                   <div class="table-operations">
@@ -252,7 +256,7 @@ const checkRoleList = () => {
   if (!val || !val.length)
     return { result: false, message: '至少配置一个角色' };
 
-  if (val.some((item) => !item.users.length))
+  if (val.some((item) => !item.userIdList.length))
     return { result: false, message: '有角色未设置人员' };
 
   return { result: true, type: 'success' };
@@ -267,13 +271,19 @@ const save = async () => {
   let data = {
     serviceUnitId: formData.serviceUnitId,
     crmNo: formData.crmNo,
-    allocationParams: formData.roleConfigInfo.map((item) => {
-      return {
-        roleId: item.roleId,
-        userIdList: item.userIdList,
-      };
-    }),
+    allocationParams: formData.roleConfigInfo
+      .filter((item) => item.roleType !== 'REGION_COORDINATOR')
+      .map((item) => {
+        return {
+          roleId: item.roleId,
+          userIdList: item.userIdList,
+        };
+      }),
   };
+  const regionUserInfo = formData.roleConfigInfo.filter(
+    (item) => item.roleType === 'REGION_COORDINATOR'
+  );
+  if (regionUserInfo) data.regionUserId = regionUserInfo[0].userIdList[0];
 
   const res = await personAllocateDeployApi(data).catch(() => {});
   if (!res) return;

+ 1 - 1
src/views/system/task/task-manage/index.vue

@@ -126,7 +126,7 @@ const columns = [
   { colKey: 'type', title: '任务类型' },
   { colKey: 'status', title: '任务状态', width: 100 },
   { colKey: 'result', title: '任务结果', width: 80 },
-  { colKey: 'createName', title: '创建人', width: 120 },
+  { colKey: 'createName', title: '创建人' },
   { colKey: 'createTime', title: '创建时间', cell: 'create-time', width: 170 },
   {
     title: '操作',