Selaa lähdekoodia

解决子组件刷新问题

yin_yu820 2 vuotta sitten
vanhempi
commit
b1b911e3b2

+ 16 - 17
src/views/activityMan/nonReligiousInformation/nonReligiousInformationView.vue

@@ -51,7 +51,7 @@
           show-cancel-button
           @confirm="reselected2"
         >
-          <organizations-list @selected="selected2" :type="1" :id="inputForm.nonReligiousCategoriesname"></organizations-list>
+          <organizations-list @selected="selected2" :type="1" :id="inputForm.nonReligiousCategories" ref="organ"></organizations-list>
         </van-dialog>
       </van-cell-group>
 
@@ -124,18 +124,6 @@
           </template>
         </van-field>
       </van-cell-group>
-
-      <!-- <van-cell-group>
-        <van-field
-          v-model="inputForm.eventOverview"
-          center
-          label="事件概述:"
-          placeholder="请填写事件概述"
-          input-align="right"
-          right-icon="location"
-        />
-      </van-cell-group> -->
-
       <van-cell-group>
         <div class="rowTextArea">
           <van-field
@@ -202,6 +190,8 @@ export default {
       eventOverview: "",
     });
     const contentEditor = ref(null);
+    // 获取组件
+    const organ = ref(null);
     let route = useRoute();
     onMounted(() => {
       // 根据路由初始化
@@ -218,6 +208,7 @@ export default {
               });
             });
             contentEditor.value.init(inputForm.value.eventContent);
+            
             isLoading.value = false;
           });
       } else {
@@ -238,12 +229,18 @@ export default {
       value: "id",
     };
     const getCategories = ({ selectedOptions }) => {
-      var that=this;
       if(selectedOptions[0]!=undefined&&selectedOptions[0]!=null){ 
         showCategories.value = false;
         inputForm.value.nonReligiousCategories = selectedOptions[0].id;
-        inputForm.value.nonReligiousCategoriesname = selectedOptions[0].name;
-        //organizationsList.flushByid(selectedOptions[0].id);
+        inputForm.value.nonReligiousCategoriesname = selectedOptions[0].name;        
+        //组件显示出来的时候就可以调用了
+        if(organ.value!=null){
+          organ.value.flushByid(selectedOptions[0].id)
+          inputForm.value.siteName.id = "";
+          inputForm.value.siteName.name = "";
+          list2.value = [];
+          list2.type = "";
+        }
       }
     };
 
@@ -306,7 +303,6 @@ export default {
         inputForm.value.placeSelectName = selectedOptions
           .map((option) => option.name)
           .join("/");
-          console.log("选择地区:"+selectedOptions);
 
           inputForm.value.place = selectedOptions
           .map((option) => option.id)
@@ -318,6 +314,8 @@ export default {
       }
 
     };
+    
+
     const submit = () => {
       isLoading.value = true;
       new nonReligiousInformationService().save(inputForm.value).then((res) => {
@@ -360,6 +358,7 @@ export default {
       contentEditor,
       // change,
       submit,
+      organ
     };
   },
 };

+ 5 - 7
src/views/activityMan/organizationsList.vue

@@ -19,7 +19,7 @@
           ref="checkboxGroup"
         >
           <van-button type="primary" size="mini" @click="checkAll"
-            >全选{{id}}</van-button
+            >全选</van-button
           >
           <van-cell-group inset>
             <van-cell
@@ -59,15 +59,13 @@
   </template>
   
   <script>
-  import { ref } from "vue";
+  import { ref,onMounted } from "vue";
   import tools from "@/api/sys/tools";
   export default {
     name: "organizationsList",
     emits: ["selected"],
     props: ["type","id"],
     setup(props, { emit }) {
-
-      console.log("选择组织id:"+props.id);
       let oType=props.id;
       const list = ref([]);
       const loading = ref(false);
@@ -112,15 +110,15 @@
       };
       const selectes = (val) => {
         checked.value = val;
-        //console.log(props.type);
-        //console.log(111);
         emit("selected", checked.value, 0);
       };
   
       const flushByid= (val) =>{
         index=0;
         oType=val;
-        console.log("子组件更新:"+val);
+        list.value=[];
+        checkboxRefs.value=[];
+        checked.value=[];
         onLoad();
       };