Просмотр исходного кода

家庭及监护的删除 提交成功后的清除数据

“hanlingqiang 2 лет назад
Родитель
Сommit
3297b6c29e

+ 20 - 2
src/views/weibao/views/collect/family.vue

@@ -35,7 +35,7 @@
                         </template>
                     </van-cell>
                     <template #right>
-                        <van-button square type="danger" text="删除" />
+                        <van-button square type="danger" text="删除" @click="onDeleteClick(1,index)" />
                     </template>
                 </van-swipe-cell>
             </div>
@@ -58,7 +58,7 @@
                         </template>
                     </van-cell>
                     <template #right>
-                        <van-button square type="danger" text="删除" />
+                        <van-button square type="danger" text="删除" @click="onDeleteClick(2,index)" />
                     </template>
                 </van-swipe-cell>
             </div>
@@ -137,6 +137,8 @@ export default {
                         if(this.type == '1') {
                             // 家庭状况
                             localStorage.getItem('infoForm') && this.familyMembers.push(JSON.parse(localStorage.getItem('infoForm')))
+                            console.log('增加+家庭状况:')
+                            console.log(this.familyMembers)
                             
                         }else if(this.type == '2') {
                             localStorage.getItem('infoForm') && this.guardians.push(JSON.parse(localStorage.getItem('infoForm')))
@@ -211,6 +213,18 @@ export default {
             })
 
         },
+        // 每一行的删除
+        onDeleteClick(type,cellIndex) {
+            console.log('删除')
+            if(type == '1') {
+                // 家庭状况的删除
+                this.familyMembers.splice(cellIndex,1)
+
+            }else if(type == '2') {
+                // 监护状况的删除
+                this.guardians.splice(cellIndex,1)
+            }
+        },
         // 提交
         async onSubmitClick() {
             console.log('111111')
@@ -228,6 +242,10 @@ export default {
             const res = await createChildBaseInfo(data)
             this.showoOverlay = false
             if (res.code == '0000') {
+                this.familyType =''
+                this.familyTypeStr =[]
+                this.familyMembers =[]
+                this.guardians =[]
                 this.$toast.success('成功')
                 this.$router.go(-2)
             }

+ 71 - 64
src/views/weibao/views/collect/index.vue

@@ -3,7 +3,7 @@
         <van-nav-bar title="信息采集" @click-left="$router.back()" left-arrow fixed placeholder safe-area-inset-top />
         <van-form @submit="saveFollowUp">
             <div class="main">
-                <vanUploader :text="'图片'" :maxCount="1" @getfileList="getfileList"></vanUploader>
+                <vanUploader :text="'图片'" ref="vanimg" :maxCount="1" @getfileList="getfileList"></vanUploader>
                 <van-row class="cell">
                     <van-col span="6">姓名<span>*</span>:</van-col>
                     <van-col span="18">
@@ -286,71 +286,72 @@ import {validateIDcard} from '@/utils/validate.js'
 import { listArea, childType, organization, listEmployeeByName} from '../../api/index.js'
 import vanUploader from '../../components/vanUploader.vue'
 import vanFieldCheckbox from '../../components/vanFieldCheckbox.vue'
+const setupForm = {
+    childId:'',
+    photoImgUrl:'',//头像图片URL
+    name:'',//姓名
+    gender:'',//性别
+    nation:'',//民族
+    nationType:'',//民族ID
+    idCard:'',//身份证号
+    birthday:'',//出生日期
+    provinceName:'',//省份名称
+    provinceId:'',//省份ID
+    cityName:'',//市名称
+    cityId:'',//市ID
+    countryName:'',//区名称
+    countryId:'',//区ID
+    streetName:'',//街道名称
+    streetId:'',//街道ID
+    communityName:'',//社区名称
+    communityId:'',//社区ID
+    address:'',//详细地址
+    typeDesc:'',//儿童类型
+    type:'',//儿童类型 id
+    stationDesc:'',//帮扶单位
+    stationId:'',//帮扶单位id
+    tutelageId:'',//儿童主任ID
+    mobile:'',//联系电话
+    healthStatus:'',//健康状况
+    prevalence:'',//患病情况
+    height:'',//身高
+    weight:'',//体重
+    school:'',//就读学校
+    grades:'',//年级
+    familyDesc:'',//家庭情况
+    disabilityLevel:'',//残疾等级
+    disabilityCertificate:'',//残疾证书号
+    higherEducationStatus:'0',//是否受过高等教育 0 否 1是
+    subsistence:'0',//低保状态 0 否 1 是
+    disabledSerious:'0',//重度残疾状态 0 否 1 是
+    disabled:'0',//残疾状态 0 否 1 是
+}
+const modelValue = {
+    nationShow:false,
+    genderShow:false,
+    genderValue:'',
+    regionShow:false,
+    regionValue:'',
+    sigleRegionValue:'',
+    childShow:false,
+    childValue:[],
+    assistShow:false,
+    assistValue:[],
+    directorShow:false,
+    directorTvalue:'',
+    healthShow:false,
+    healthValue:'',
+    disabilityShow:false,
+    disabilityValue:'',
+}
 export default {
     components: { vanUploader,vanFieldCheckbox },
     data() {
         return {
             userInfo:{},
             directorLink:'',
-            form:{
-                childId:'133',
-                photoImgUrl:'',//头像图片URL
-                name:'',//姓名
-                gender:'',//性别
-                nation:'',//民族
-                nationType:'',//民族ID
-                idCard:'',//身份证号
-                birthday:'',//出生日期
-                provinceName:'',//省份名称
-                provinceId:'',//省份ID
-                cityName:'',//市名称
-                cityId:'',//市ID
-                countryName:'',//区名称
-                countryId:'',//区ID
-                streetName:'',//街道名称
-                streetId:'',//街道ID
-                communityName:'',//社区名称
-                communityId:'',//社区ID
-                address:'',//详细地址
-                typeDesc:'',//儿童类型
-                type:'',//儿童类型 id
-                stationDesc:'',//帮扶单位
-                stationId:'',//帮扶单位id
-                tutelageId:'',//儿童主任ID
-                mobile:'',//联系电话
-                healthStatus:'',//健康状况
-                prevalence:'',//患病情况
-                height:'',//身高
-                weight:'',//体重
-                school:'',//就读学校
-                grades:'',//年级
-                familyDesc:'',//家庭情况
-                disabilityLevel:'',//残疾等级
-                disabilityCertificate:'',//残疾证书号
-                higherEducationStatus:'0',//是否受过高等教育 0 否 1是
-                subsistence:'0',//低保状态 0 否 1 是
-                disabledSerious:'0',//重度残疾状态 0 否 1 是
-                disabled:'0',//残疾状态 0 否 1 是
-
-            },
-            modelValue:{
-                nationShow:false,
-                genderShow:false,
-                genderValue:'',
-                regionShow:false,
-                regionValue:'',
-                sigleRegionValue:'',
-                childShow:false,
-                childValue:[],
-                assistShow:false,
-                assistValue:[],
-                directorShow:false,
-                directorTvalue:'',
-                healthShow:false,
-                healthValue:'',
-                disabilityShow:false,
-                disabilityValue:'',
-            },
+            form: JSON.parse(JSON.stringify(setupForm)),
+            modelValue:JSON.parse(JSON.stringify(modelValue)),
             genderList:[
                 {
                     text:'男',
@@ -418,10 +419,16 @@ export default {
         this.childTypeF()
         this.organizationF()
     },
-    beforeRouteUpdate(to,from,next){
-        this.form = to.query.form
-        console.log(to.query.form)
-        next();
+    beforeRouteEnter(to,from,next) {
+        next(
+            vm=>{
+                if(to.path == '/collect/index' && from.path == '/home') {
+                    vm.$refs.vanimg.childrenClear()
+                    vm.form = JSON.parse(JSON.stringify(setupForm))
+                    vm.modelValue = JSON.parse(JSON.stringify(modelValue))
+                }
+            }
+        )
     },
     methods: {
         async listAreaF() {

+ 3 - 2
src/views/weibao/views/collect/inforMation.vue

@@ -45,7 +45,7 @@ export default {
     components: {},
     data() {
         return {
-           isEdit:'',
+           isEdit:false,
            type:'',
            title:'',
            infoForm:{
@@ -59,6 +59,7 @@ export default {
     },
     created() {
         this.type = this.$route.query.type
+        this.isEdit = this.$route.query.isEdit
         if(this.$route.query.value) {
             this.infoForm = this.$route.query.value
         }
@@ -71,7 +72,7 @@ export default {
             this.$router.back()
         },
         onNavBarLeft() {
-            if(this.isEdit) {
+            if(this.isEdit == 'true') {
                 localStorage.setItem('infoForm', JSON.stringify(this.infoForm))
             }else {
                 localStorage.setItem('infoForm', '')