Sfoglia il codice sorgente

Merge branch 'feature/bug' into develop

张田田 10 mesi fa
parent
commit
36e53beab0

+ 43 - 41
src/service/EditSystemService.vue

@@ -29,6 +29,7 @@ const props = defineProps<{ data: FollowModel }>();
 const fileList = ref<UploadFile[]>([]);
 const uploadProps = reactive({ showRemoveIcon: true });
 const emit = defineEmits<{ submit: [data?: SystemCwModel] }>();
+const deptId = ref<string>('');
 // 获取所有的机构
 const branch = ref<any[]>([]);
 const { loading: branchLoading } = useRequest(branchMethod).onSuccess(({ data }) => {
@@ -68,35 +69,7 @@ const formData = reactive<FollowModel>({
     constitutionGroupNames: [],
     willillStateNames: [],
   },
-  // cwPatientMatchRules: [
-  //   {
-  //     diagnoseDiseaseNames: [],
-  //     diagnoseSyndromeNames: [],
-  //     constitutionGroupNames: [],
-  //     diagnoseDisease: {
-  //       id: '',
-  //       code: '',
-  //       name: '',
-  //       optionalWords: '',
-  //       attributes: [],
-  //       children: [],
-  //     },
-  //     diagnoseSyndrome: {
-  //       code: '',
-  //       name: '',
-  //       analysis: '',
-  //       remark: '',
-  //     },
-  //     constitutionGroup: {
-  //       id: '',
-  //       code: '',
-  //       name: '',
-  //       definition: '',
-  //       remark: '',
-  //     },
-  //   },
-  // ], // 适用情况
-  items: [], // Initialize as empty array
+  items: [],
 });
 const emptyRow = {
   id: '',
@@ -178,6 +151,7 @@ watch(totalPrice, (val) => {
 
 const projectSearchRef = useTemplateRef<HTMLInputElement>('projectSearchRef');
 const projectSearchFocus = (visible: boolean) => {
+  showProjectPopover.value = visible;
   if (visible) setTimeout(() => projectSearchRef.value?.focus?.(), 300);
 };
 
@@ -488,7 +462,9 @@ async function getDesiredConditions() {
 }
 // 获取性别
 const genders = ref<{ id: string; name: string }[]>([]);
+const gendersLoading = ref(false);
 async function getGender() {
+  gendersLoading.value = true;
   const res = await getDictionaryMethod('sys_user_sex');
   if (res && res.length > 0) {
     genders.value = res.map((item: any) => ({
@@ -496,6 +472,7 @@ async function getGender() {
       name: item.label,
     }));
   }
+  gendersLoading.value = false;
 }
 // 获取年龄
 const ages = ref<{ id: string; name: string }[]>([]);
@@ -518,17 +495,24 @@ async function getConstitutionGroup() {
   }
 }
 onMounted(async () => {
+  // 获取欲病状态
   getDesiredConditions();
+  // 获取性别
   getGender();
+  // 获取年龄
   getAge();
+  // 获取体质
   getConstitutionGroup();
+  // 获取机构项目列表  服务包内容点击 弹窗里的内容
+  await getProjectList();
+  // 有id说明是编辑
   if (props.data.id) {
-    props.data.types = 'institution'; // Modify the local copy instead
-    // 调编辑接口获取数据
+    props.data.types = 'institution';
+    // 调编辑接口获取调理包详情  机构服务包和系统服务包的详情接口是一样的
     const res: any = await getConditioningRecordDetailMethod(props.data);
     Object.assign(formData, res); // Use the response to update formData
     await nextTick(); // 确保视图更新
-
+    // 获取适用情况
     const matchRule = res?.conditioningWrapPatientMatchRule || {};
     Object.assign(formData.conditioningWrapPatientMatchRule!, {
       sex: matchRule.sex ?? '',
@@ -554,7 +538,6 @@ onMounted(async () => {
       row.frequencyTypeing = row.frequencyType ? [row.frequencyType] : [];
     });
   }
-  await getProjectList();
 });
 
 const tableData = computed(() => {
@@ -568,6 +551,9 @@ function removeTableRow(idx: number) {
 }
 // 引入服务包
 function addInstitution() {
+  deptId.value = localStorage.getItem('deptId') || '';
+  console.log(deptId.value, '当前机构');
+  console.log(formData.institutionId, '选择的机构');
   VxeUI.modal.open({
     title: '选择引入',
     width: 1000,
@@ -581,6 +567,7 @@ function addInstitution() {
       default() {
         return h(ServicePackageList, {
           data: formData,
+          institutionId: formData.institutionId ? formData.institutionId : deptId.value,
           onSubmit(data: SystemCwModel) {
             VxeUI.modal.close(`systemService-list-modal`);
           },
@@ -612,9 +599,9 @@ const handlePreview = async (file: UploadFile) => {
   previewImg.value = file.response?.url ?? file.thumbUrl;
   visible.value = true;
 };
-function set(){
+function set() {
   formData.items = [];
-  formData.name='';
+  formData.name = '';
   formData.conditioningWrapPatientMatchRule = {
     sex: '',
     age: '',
@@ -629,9 +616,9 @@ function handleSelect(value: string, node: any, extra: any) {
   set();
   formData.institutionId = value;
   formData.institutionName = node.label;
-
 }
 function openPopover() {
+  console.log('openPopover');
   showProjectPopover.value = true;
 }
 </script>
@@ -644,14 +631,14 @@ function openPopover() {
         <span style="white-space: nowrap; margin-right: 8px">机构名称:</span>
         <a-tree-select
           v-model:value="formData.institutionId"
-          show-search
           style="width: 220px"
           :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
           placeholder="请选择"
-          allow-clear
           tree-default-expand-all
           :tree-data="branch"
           @select="handleSelect"
+          :loading="branchLoading"
+          :getPopupContainer="(triggerNode: any) => triggerNode.parentNode"
         />
       </div>
       <!-- 服务包名称 -->
@@ -686,7 +673,14 @@ function openPopover() {
         <span class="w-20">使用限制</span>
         <div class="mr-10">
           <span>性别:</span>
-          <a-select placeholder="请选择" v-model:value="formData.conditioningWrapPatientMatchRule.sex" style="width: 150px; margin: 0 5px" allowClear>
+          <a-select
+            placeholder="请选择"
+            v-model:value="formData.conditioningWrapPatientMatchRule.sex"
+            style="width: 150px; margin: 0 5px"
+            allowClear
+            :loading="gendersLoading"
+            :getPopupContainer="(triggerNode: any) => triggerNode.parentNode"
+          >
             <a-select-option v-for="option in genders" :key="option.id" :value="option.id" placeholder="请选择">
               {{ option.name }}
             </a-select-option>
@@ -694,7 +688,13 @@ function openPopover() {
         </div>
         <div>
           <span>年龄:</span>
-          <a-select v-model:value="formData.conditioningWrapPatientMatchRule.age" style="width: 150px; margin: 0 8px" placeholder="请选择" allowClear>
+          <a-select
+            v-model:value="formData.conditioningWrapPatientMatchRule.age"
+            style="width: 150px; margin: 0 8px"
+            placeholder="请选择"
+            allowClear
+            :getPopupContainer="(triggerNode: any) => triggerNode.parentNode"
+          >
             <a-select-option v-for="option in ages" :key="option.id" :value="option.id" placeholder="请选择">{{ option.name }}</a-select-option>
           </a-select>
         </div>
@@ -730,6 +730,7 @@ function openPopover() {
             placeholder="请选择"
             allowClear
             mode="multiple"
+            :getPopupContainer="(triggerNode: any) => triggerNode.parentNode"
           >
             <a-select-option v-for="option in constitutionGroups" :key="option.id" :value="option.id" placeholder="请选择">{{ option.name }}</a-select-option>
           </a-select>
@@ -743,6 +744,7 @@ function openPopover() {
             placeholder="请选择"
             allowClear
             mode="multiple"
+            :getPopupContainer="(triggerNode: any) => triggerNode.parentNode"
             @change="(value) => (formData.conditioningWrapPatientMatchRule.willillStateNames = value)"
           >
             <a-select-option v-for="option in desiredConditions" :key="option.id" :value="option.id" placeholder="请选择">{{ option.name }}</a-select-option>
@@ -784,7 +786,7 @@ function openPopover() {
                     </vxe-column>
                   </vxe-table>
                 </template>
-                <a-input v-model:value="row.name" placeholder="请搜索" style="width: 120px" @click="openPopover" readonly />
+                <a-input v-model:value="row.name" placeholder="请搜索" style="width: 120px" @focus="openPopover" readonly />
               </a-popover>
             </template>
             <template v-else>

+ 23 - 13
src/service/IntroduceProjectList.vue

@@ -1,34 +1,44 @@
 <script lang="ts" setup>
-import { ref } from 'vue';
+import { ref, onMounted, reactive } from 'vue';
 import type { SystemItemModel, SystemCwModel } from '@/model/care.model';
 import { VxeUI } from 'vxe-pc-ui';
 import { getCopyCwMethod } from '@/request/api/care.api';
-const tableData = ref<SystemItemModel[]>([]);
 
+const emit = defineEmits<{
+  submit: [data: any]
+}>();
+const tableData = ref<SystemItemModel[]>([]);
 type FollowModel = Partial<SystemCwModel>;
-const props = defineProps<{ data: FollowModel; id: number | string,institutionId:number | string}>();
-
+const props = defineProps<{ data: FollowModel; id: number | string; institutionId: number | string;  }>();
 // 引入已有项目
-async function handleAdd(row: any) {
+async function handleAdd() {
   // 关闭引入服务包弹窗
   VxeUI.modal.close(`systemService-list-modal`);
   // 关闭引入已有项目弹窗
   VxeUI.modal.close(`introduceProjectList-modal`);
+  // 向父组件传入数据
+  emit('submit', props.data as SystemCwModel);
 }
-
 function handleCancel() {
   VxeUI.modal.close(`introduceProjectList-modal`);
 }
-const dataObj = reactive({
-  types: 'institution',
-  id: props.id,
-  institutionId: props.institutionId,
-});
-
+const detailData = ref<any>({});
 onMounted(async () => {
+  const dataObj = reactive({
+    types: 'institution',
+    id: props.id,
+    institutionId: props.institutionId,
+  });
   const res: any = await getCopyCwMethod(dataObj);
-  if(res && res.items && res.items.length > 0){
+  detailData.value = res;
+  if (res && res.items && res.items.length > 0) {
     tableData.value = res.items;
+
+    if (res && res.items && res.items.length > 0) {
+      res.items.forEach((item: any) => {
+        delete item.conditioningProgramDetail.id;
+      });
+    }
   }
 });
 const checked = ref(true);

+ 28 - 44
src/service/ServicePackageList.vue

@@ -2,11 +2,11 @@
 import { ref } from 'vue';
 import { VxeUI } from 'vxe-pc-ui';
 import IntroduceProjectList from '@/service/IntroduceProjectList.vue';
-import { getSystemCpListMethod,getCopyCwMethod } from '@/request/api/care.api';
+import { getSystemCpListMethod, getCopyCwMethod } from '@/request/api/care.api';
 import { usePagination } from 'alova/client';
 import type { SystemCwModel } from '@/model/care.model';
 type FollowModel = Partial<SystemCwModel>;
-const props = defineProps<{ data: FollowModel }>();
+const props = defineProps<{ data: FollowModel; institutionId: string }>();
 const emit = defineEmits(['update:data']);
 const tableData = ref<SystemCwModel[]>([]);
 const { loading, page, pageSize, total, onSuccess, replace, refresh, remove } = usePagination((page, size) => getSystemCpListMethod(page, size), {
@@ -20,53 +20,36 @@ onSuccess(({ data: { data } }) => {
   loading.value = false;
 });
 const id = ref<string>('');
-const institutionId = ref<string>('');
+async function handleSubmit() {
+  const res: any = await getCopyCwMethod(parms.value);
+  if (res && res.items && res.items.length > 0) {
+    res.items.forEach((item: any) => {
+      delete item.conditioningProgramDetail.id;
+      item.frequencyTypeing = item.frequencyType ? [item.frequencyType] : [];
+    });
+    props.data.items = [...res.items];
+    props.data.price = res.price;
+    props.data.name = res.name;
+    if (res.conditioningWrapPatientMatchRule) {
+      props.data.conditioningWrapPatientMatchRule.diagnoseDiseaseNames = res.conditioningWrapPatientMatchRule.diagnoseDiseaseNames || [];
+      props.data.conditioningWrapPatientMatchRule.diagnoseSyndromeNames = res.conditioningWrapPatientMatchRule.diagnoseSyndromeNames || [];
+      props.data.conditioningWrapPatientMatchRule.constitutionGroupNames = res.conditioningWrapPatientMatchRule.constitutionGroupNames || [];
+      props.data.conditioningWrapPatientMatchRule.sex = res.conditioningWrapPatientMatchRule.sex || '';
+      props.data.conditioningWrapPatientMatchRule.age = res.conditioningWrapPatientMatchRule.age || '';
+      props.data.conditioningWrapPatientMatchRule.willillStateNames = res.conditioningWrapPatientMatchRule.willillStateNames || [];
+    }
+  }
+}
+const parms = ref<any>({});
 async function handleSelect(model?: SystemCwModel) {
   if (model?.id) {
     id.value = model.id;
-    institutionId.value = model.institutionId;
     try {
-      const params = {
+      parms.value = {
         types: 'institution',
         id: model.id,
-        institutionId: model.institutionId,
+        institutionId: props.institutionId,
       };
-      const res: any = await getCopyCwMethod(params);
-      if (res && res.items && res.items.length > 0) {
-        res.items.forEach((item: any) => {
-          delete item.conditioningProgramDetail.id;
-        });
-        props.data.items = [...res.items];
-        props.data.items?.forEach((row: any) => {
-          row.frequencyTypeing = row.frequencyType ? [row.frequencyType] : [];
-        });
-      }
-     
-      // 确保 conditioningWrapPatientMatchRule 存在
-      if (!props.data.conditioningWrapPatientMatchRule) {
-        props.data.conditioningWrapPatientMatchRule = {
-          sex: '',
-          age: '',
-          diagnoseDiseaseNames: [],
-          diagnoseSyndromeNames: [],
-          constitutionGroupNames: [],
-          willillStateNames: [],
-        };
-      }
-
-      // props.data.cwPatientMatchRules = model.cwPatientMatchRules;
-      props.data.price = model.price;
-      props.data.name = model.name;
-      
-      // 安全地访问 conditioningWrapPatientMatchRule 属性
-      if (model.conditioningWrapPatientMatchRule) {
-        props.data.conditioningWrapPatientMatchRule.diagnoseDiseaseNames = model.conditioningWrapPatientMatchRule.diagnoseDiseaseNames || [];
-        props.data.conditioningWrapPatientMatchRule.diagnoseSyndromeNames = model.conditioningWrapPatientMatchRule.diagnoseSyndromeNames || [];
-        props.data.conditioningWrapPatientMatchRule.constitutionGroupNames = model.conditioningWrapPatientMatchRule.constitutionGroupNames || [];
-        props.data.conditioningWrapPatientMatchRule.sex = model.conditioningWrapPatientMatchRule.sex || '';
-        props.data.conditioningWrapPatientMatchRule.age = model.conditioningWrapPatientMatchRule.age || '';
-        props.data.conditioningWrapPatientMatchRule.willillStateNames = model.conditioningWrapPatientMatchRule.willillStateNames || [];
-      }
     } catch (err) {
       console.error('Error fetching data:', err);
     }
@@ -86,8 +69,9 @@ async function handleSelect(model?: SystemCwModel) {
         return h(IntroduceProjectList, {
           data: { ...props.data },
           id: id.value,
-          institutionId: institutionId.value,
+          institutionId: props.institutionId,
           onSubmit() {
+            handleSubmit();
             VxeUI.modal.close(`introduceProjectList-modal`);
           },
         });
@@ -98,7 +82,7 @@ async function handleSelect(model?: SystemCwModel) {
 </script>
 
 <template>
-  <div style=" background: #fff; padding: 32px; border-radius: 6px; box-shadow: 0 2px 8px #0001">
+  <div style="background: #fff; padding: 32px; border-radius: 6px; box-shadow: 0 2px 8px #0001">
     <vxe-table :data="tableData" border>
       <vxe-column field="name" title="服务包名称" />
       <vxe-column field="conditioningWrapPatientMatchRule.diagnoseDiseaseNames" title="专病" />