zhangjie 1 year ago
parent
commit
d328174d8a

+ 10 - 5
src/views/resource-guard/person-guard/person-files/add-person-file-dialog.vue

@@ -12,7 +12,8 @@
       <t-row :gutter="[0, 20]">
         <t-col :span="4">
           <t-form-item label="人员档案编号">
-            <span>{{ formData.code }}</span>
+            <span v-if="isEdit">{{ formData.code }}</span>
+            <span>系统生成</span>
           </t-form-item>
         </t-col>
         <t-col :span="4">
@@ -72,7 +73,7 @@
           </t-form-item>
         </t-col>
         <t-col :span="12">
-          <t-form-item label="上传照片">
+          <t-form-item label="上传照片" name="basePhotoPath">
             <t-upload
               ref="uploadRef"
               v-model="photos"
@@ -86,6 +87,7 @@
               }"
               :size-limit="{ size: 2, unit: 'MB' }"
               :request-method="requestMethod"
+              @change="fileChange"
             >
             </t-upload>
           </t-form-item>
@@ -167,7 +169,7 @@ import { ref, computed } from 'vue';
 import { MessagePlugin } from 'tdesign-vue-next';
 import useClearDialog from '@/hooks/useClearDialog';
 import useAuthenRole from '@/hooks/useAuthenRole';
-import { personFilesEditApi, personFilesCodeApi } from '@/api/resource-guard';
+import { personFilesEditApi } from '@/api/resource-guard';
 import { fileUploadApi } from '@/api/user';
 import { GENDER_TYPE, EDUCATION_TYPE } from '@/config/constants';
 import { getFileMD5 } from '@/utils/crypto';
@@ -357,6 +359,10 @@ const areaChange = (data) => {
   formData.area = data[2];
 };
 
+const fileChange = (data) => {
+  if (!data.length) formData.basePhotoPath = '';
+};
+
 const save = async () => {
   const valid = await formRef.value.validate();
   if (valid !== true) return;
@@ -371,10 +377,9 @@ const save = async () => {
 
 const dialogOpened = async () => {
   if (!props.curRow) {
-    const res = await personFilesCodeApi();
-    formData.code = res || '';
     areaInfo.value = ['', '', ''];
     photos.value = [];
+    formData.code = undefined;
   } else {
     areaInfo.value = [formData.province, formData.city, formData.area];
     photos.value = [{ url: props.curRow.basePhotoPreviewPath }];

+ 5 - 0
src/views/sop/components/dynamic-form-item/SELECT.vue

@@ -31,6 +31,11 @@ const getOptionsApi = () => {
   });
 };
 const getOptions = async () => {
+  if (props.config.options) {
+    options.value = props.config.options;
+    return;
+  }
+
   if (!props.config.dataGrid) return;
   const { data } = useRequest(getOptionsApi);
   // TODO: 将接口数据转换成options

+ 41 - 4
src/views/sop/sop-manage/sop-step/index.vue

@@ -218,9 +218,12 @@ const allSteps = ref([]);
 const tabs = ref([]);
 const curStep = ref('');
 const flowId = props.sop.flowId;
+const crmInfo = ref({});
 
 const initNew = async () => {
   loading.value = true;
+  const flowRes = await sopFlowViewApi({ flowId });
+  crmInfo.value = flowRes.crmInfo;
   const res = await flowFormPropertiesApi({
     flowDeploymentId: props.sop.flowDeploymentId,
   });
@@ -239,6 +242,7 @@ const initNew = async () => {
 const initFill = async () => {
   loading.value = true;
   const res = await sopFlowViewApi({ flowId });
+  crmInfo.value = res.crmInfo;
   loading.value = false;
   curStep.value = res.currFlowTaskResult.taskName;
   res.flowTaskHistoryList = res.flowTaskHistoryList || [];
@@ -306,18 +310,51 @@ const init = () => {
 init();
 
 const curFormConfig = computed(() => {
-  const formProperty =
-    allSteps.value.find((item) => item.taskName === curStep.value)
-      ?.formProperty || [];
+  const stepData = allSteps.value.find(
+    (item) => item.taskName === curStep.value
+  );
+  if (!stepData) return [];
+
+  const formProperty = stepData.formProperty || [];
   formProperty.forEach((item) => {
     if (IS_EDIT_MODE.value) {
-      item.writable = true;
       item.value = allFormData.value[item.formName];
     } else if (IS_FILL_MODE.value) {
       item.value = item.value ? JSON.parse(item.value).value : null;
       // item.value = null;
     }
   });
+
+  // 填报时第一步的特殊处理
+  if ((IS_FILL_MODE.value || IS_NEW_MODE.value) && stepData.setup === 1) {
+    // region_user_id_1 区域协调人
+    // engineer_user_id_1 实施工程师
+    // assistant_engineer_user_id_1 助理工程师
+    formProperty.forEach((field) => {
+      // 区域协调人
+      if (field.formId.startsWith('region_user') && !field.value) {
+        field.value = crmInfo.value.regionCoordinatorName;
+      }
+      // 实施工程师
+      if (field.formId.startsWith('engineer_user')) {
+        field.options = crmInfo.value.effectEngineerList.map((user) => {
+          return {
+            label: user.name,
+            value: user.userId,
+          };
+        });
+      }
+      // 助理工程师
+      if (field.formId.startsWith('assistant_engineer_user')) {
+        field.options = crmInfo.value.assistantEngineerList.map((user) => {
+          return {
+            label: user.name,
+            value: user.userId,
+          };
+        });
+      }
+    });
+  }
   return formProperty;
 });
 watch(curFormConfig, (val) => {