18.普通用户、网格长、网格员,操作数据(5)newapp/components/wgy.vue

2020-07-03 10:41:51 浏览数 (3)

1.在newapp/components/wgy.vue中:

代码语言:javascript复制
<template>
    <view>
        <scroll-view scroll-x class="bg-cyan nav text-center">
            <view class="cu-item text-lg" :class="0==TabCur1?'text-white cur':''" @tap="tabSelect1" data-id="0">
                <text class="cuIcon-addressbook"></text> 编辑数据
            </view>
            <view class="cu-item text-lg" :class="1==TabCur1?'text-white cur':''" @tap="tabSelect1" data-id="1">
                <text class="cuIcon-edit"></text> 展示数据
            </view>                
        </scroll-view>
        
        
        <!-- 数据编辑 -->
        <view class="zhanshi" v-show="flag_edit">
            <view class="edit" v-if="wgy_can_edit">
                <scroll-view scroll-x class="bg-cyan nav text-center margin-top">
                    <view class="cu-item text-lg" :class="0==TabCur6?'text-white cur':''" @tap="tabSelect6" data-id="0">
                        <text class="cuIcon-addressbook"></text> 编辑单元(组)
                    </view>
                    <view class="cu-item text-lg" :class="1==TabCur6?'text-white cur':''" @tap="tabSelect6" data-id="1">
                        <text class="cuIcon-edit"></text> 编辑住户
                    </view>
                    <view class="cu-item text-lg" :class="2==TabCur6?'text-white cur':''" @tap="tabSelect6" data-id="2">
                        <text class="cuIcon-edit"></text> 编辑人员
                    </view>            
                </scroll-view>
                
                <view class="edit_danyuan" v-show="flag_edit_danyuan">
                    <view class="cu-form-group margin-top">
                        <view class="title">楼(街):</view>
                        <picker @change="PickerChange1" :value="index" :range="data2.lou_list_re" :range-key="'name'">
                            <view class="picker">
                                {{lou_name}}
                            </view>
                        </picker>
                    </view>
                    
                    <view class="cu-form-group margin-top text-xl">
                        <view class="title">单元(组)名:</view>
                        <input placeholder="单元(组)名" name="input" v-model="danyuan_name"></input>
                    </view>
                    <view class="padding flex flex-direction">
                        <button class="cu-btn bg-cyan lg" @tap="addDanyuan">增加单元(组)名</button>
                    </view>
                    
                    <view class="danyuan_list" v-for="(item,index) in newest_danyuan_list" :key=index>
                        
                        <view class="padding-xl radius shadow-warp bg-gray margin-top">
                            <view class="cu-bar solid-bottom">
                                <view class="action">
                                    <text class="cuIcon-title text-orange"></text> 楼(街)名:{{item.lou}}
                                </view>
                            </view>
                            <view class="cu-bar solid-bottom">
                                <view class="action">
                                    <text class="cuIcon-friendfamous text-orange"></text> 单元(组)名:{{item.name}}
                                </view>
                            </view>
                            <view class="cu-bar solid-bottom">
                                <view class="action">
                                    <text class="cuIcon-favor text-orange"></text> 单元(组)长:{{item.dyz}}
                                </view>
                            </view>
                            <view class="padding flex flex-direction">
                                <button class="cu-btn bg-red lg" @tap="DelDanyuan(item.id)">删除单元(组)名</button>
                            </view>
                        </view>
                        
                    </view>
                    
                </view>
                <view class="edit_danyuan" v-show="flag_edit_zhuhu">
    
                    <view class="cu-form-group margin-top">
                        <view class="title">楼(街):</view>
                        <picker @change="PickerChange2" :value="index" :range="data2.lou_list_re" :range-key="'name'">
                            <view class="picker">
                                {{zhuhu_lou_name}}
                            </view>
                        </picker>
                    </view>
                    
                    <view class="cu-form-group margin-top">
                        <view class="title">单元(组):</view>
                        <picker @change="PickerChange3" :value="index" :range="zhuhu_danyuan_list" :range-key="'name'">
                            <view class="picker">
                                {{zhuhu_danyuan_name}}
                            </view>
                        </picker>
                    </view>
                    
                    <view class="cu-form-group margin-top text-xl">
                        <view class="title">住户名:</view>
                        <input placeholder="住户名" name="input" v-model="zhuhu_name"></input>
                    </view>
                    <view class="padding flex flex-direction">
                        <button class="cu-btn bg-cyan lg" @tap="addZhuhu">增加住户名</button>
                    </view>
                    
                    <view class="zhuhu_list" v-for="(item,index) in newest_zhuhu_list" :key=index>
                        <view class="padding-xl radius shadow-warp bg-gray margin-top">
                            <view class="cu-bar solid-bottom">
                                <view class="action">
                                    <text class="cuIcon-title text-orange"></text> 单元(组)名:{{item.dy}}
                                </view>
                            </view>
                            <view class="cu-bar solid-bottom">
                                <view class="action">
                                    <text class="cuIcon-friendfamous text-orange"></text> 住户名:{{item.name}}
                                </view>
                            </view>
                            
                            <view class="padding flex flex-direction">
                                <button class="cu-btn bg-red lg" @tap="DelZhuhu(item.id)">删除住户名</button>
                            </view>
                        </view>
                    </view>
                    
                </view>
                <view class="edit_danyuan" v-show="flag_edit_renyuan">
                    <view class="cu-form-group margin-top">
                        <view class="title">楼(街):</view>
                        <picker @change="PickerChange4" :value="index" :range="data2.lou_list_re" :range-key="'name'">
                            <view class="picker">
                                {{user_lou_name}}
                            </view>
                        </picker>
                    </view>
                    <view class="cu-form-group margin-top">
                        <view class="title">单元(组):</view>
                        <picker @change="PickerChange5" :value="index" :range="user_danyuan_list" :range-key="'name'">
                            <view class="picker">
                                {{user_danyuan_name}}
                            </view>
                        </picker>
                    </view>
                    <view class="cu-form-group margin-top">
                        <view class="title">住户:</view>
                        <picker @change="PickerChange6" :value="index" :range="user_zhuhu_list" :range-key="'name'">
                            <view class="picker">
                                {{user_zhuhu_name}}
                            </view>
                        </picker>
                    </view>
                    
                    <view class="cu-form-group margin-top text-xl">
                        <view class="title">居民姓名:</view>
                        <input placeholder="居民姓名" name="input" v-model="user_name"></input>
                    </view>
                    <view class="cu-form-group margin-top text-xl">
                        <view class="title">民族:</view>
                        <input placeholder="民族" name="input" v-model="user_minzu"></input>
                    </view>
                    <view class="cu-form-group margin-top text-xl">
                        <view class="title">手机号:</view>
                        <input placeholder="手机号(没有填:无)" name="input" v-model="user_tel"></input>
                    </view>
                    <view class="cu-form-group margin-top text-xl">
                        <view class="title">工作单位:</view>
                        <input placeholder="工作单位(没有填:无)" name="input" v-model="user_danwei"></input>
                    </view>
                    <view class="cu-form-group margin-top text-xl">
                        <view class="title">职位:</view>
                        <input placeholder="职位(没有填:无)" name="input" v-model="user_zhiwei"></input>
                    </view>
                    <view class="cu-form-group margin-top text-xl">
                        <view class="title">身份证号:</view>
                        <input placeholder="身份证号" name="input" v-model="user_no"></input>
                    </view>
                    <view class="cu-form-group margin-top text-xl">
                        <view class="title">出生日期:</view>
                        <input placeholder="出生日期(格式:2020-7-12)" name="input" v-model="user_date"></input>
                    </view>
                    <view class="cu-form-group margin-top text-xl">
                        <view class="title">特殊群体:</view>
                        <input placeholder="特殊群体情况(没有填:无)" name="input" v-model="user_teshu"></input>
                    </view>
                    <view class="cu-form-group margin-top">
                        <view class="title">是否是特殊群体:</view>
                        <switch @change="fun_user_is_teshu" :class="user_is_teshu?'checked':''" :checked="user_is_teshu?true:false"></switch>
                    </view>
                    <view class="cu-form-group margin-top">
                        <view class="title">是否是党员:</view>
                        <switch @change="fun_user_is_dangyuan" :class="user_is_dangyuan?'checked':''" :checked="user_is_dangyuan?true:false"></switch>
                    </view>
                    <view class="cu-form-group margin-top">
                        <view class="title">是否是农业户口:</view>
                        <switch @change="fun_user_is_nongyehukou" :class="user_is_nongyehukou?'checked':''" :checked="user_is_nongyehukou?true:false"></switch>
                    </view>
                    <view class="cu-form-group margin-top">
                        <view class="title">是否是户主:</view>
                        <switch @change="fun_user_is_huzhu" :class="user_is_huzhu?'checked':''" :checked="user_is_huzhu?true:false"></switch>
                    </view>
                    <view class="cu-form-group align-start margin-top">
                        <view class="title">户籍所在地:</view>
                        <textarea maxlength="-1" v-model="user_hujiadress" placeholder="户籍所在地"></textarea>
                    </view>
                    <view class="cu-form-group align-start margin-top">
                        <view class="title">备注:</view>
                        <textarea maxlength="-1" v-model="user_beizhu" placeholder="备注:(没有填:无)"></textarea>
                    </view>
                    
                    <view class="cu-form-group margin-top">
                        <view class="title">性别:</view>
                        <picker @change="PickerChange7" :value="index" :range="user_sex_list" :range-key="'title'">
                            <view class="picker">
                                {{user_sex_title}}
                            </view>
                        </picker>
                    </view>
                    <view class="cu-form-group margin-top">
                        <view class="title">文化程度:</view>
                        <picker @change="PickerChange8" :value="index" :range="user_wenhua_list" :range-key="'title'">
                            <view class="picker">
                                {{user_wenhua_title}}
                            </view>
                        </picker>
                    </view>
                    <view class="cu-form-group margin-top">
                        <view class="title">婚姻状况:</view>
                        <picker @change="PickerChange9" :value="index" :range="user_hunyin_list" :range-key="'title'">
                            <view class="picker">
                                {{user_hunyin_title}}
                            </view>
                        </picker>
                    </view>
                    <view class="cu-form-group margin-top">
                        <view class="title">权限:</view>
                        <picker @change="PickerChange10" :value="index" :range="user_power_list" :range-key="'title'">
                            <view class="picker">
                                {{user_power_title}}
                            </view>
                        </picker>
                    </view>

                    <view class="padding flex flex-direction">
                        <button class="cu-btn bg-cyan lg" @tap="addUser" >增加居民信息</button>
                    </view>
                    
                    <view class="user_list" v-for="(item,index) in newest_user_list" :key=index>
                        <view class="padding-xl radius shadow-warp bg-gray margin-top">
                            <view class="cu-form-group">
                                <view class="title">名字:</view>
                                <input name="input" disabled="true" v-model="item.name"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">民族:</view>
                                <input name="input" disabled="true" v-model="item.minzu"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">是否是党员:</view>
                                <input name="input" disabled="true" v-model="item.is_dangyuan"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">性别:</view>
                                <input name="input" disabled="true" v-model="item.sex"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">电话:</view>
                                <input name="input" disabled="true" v-model="item.mobile"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">身份证号:</view>
                                <input name="input" disabled="true" v-model="item.no"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">出生日期:</view>
                                <input name="input" disabled="true" v-model="item.chusheng"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">文化程度:</view>
                                <input name="input" disabled="true" v-model="item.wenhua"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">是否属于特殊群体:</view>
                                <input name="input" disabled="true" v-model="item.is_teshu"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">特殊群体:</view>
                                <input name="input" disabled="true" v-model="item.teshu"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">用户权限:</view>
                                <input name="input" disabled="true" v-model="item.power"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">婚姻状况:</view>
                                <input name="input" disabled="true" v-model="item.hunyin"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">现居地址:</view>
                                <input name="input" disabled="true" v-model="item.address"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">单位:</view>
                                <input name="input" disabled="true" v-model="item.danwei"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">职位:</view>
                                <input name="input" disabled="true" v-model="item.zhiwei"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">户籍性质:</view>
                                <input name="input" disabled="true" v-model="item.hujixz"></input>
                            </view>
                            <view class="cu-form-group">
                                <view class="title">户籍地址:</view>
                                <input name="input" disabled="true" v-model="item.huji"></input>
                            </view>
                            <view class="padding flex flex-direction">
                                <button class="cu-btn bg-red lg" @tap="DelUser(item.id)">删除此条居民记录</button>
                            </view>
                        </view>
                    </view>
                    
                    
                </view>    
                
                
            </view>
            <view class="edit" v-if="!wgy_can_edit">
                <view class="padding-xl radius shadow-warp bg-cyan margin-top text-center">
                    目前网格员不能进行数据编辑
                </view> 
            </view>
        </view>
        
        <view class="cu-modal" :class="modalName=='Modal'?'show':''">
            <view class="cu-dialog">
                <view class="cu-bar bg-white justify-end">
                    <view class="content">信息提示</view>
                    <view class="action" @tap="hideModal">
                        <text class="cuIcon-close text-red"></text>
                    </view>
                </view>
                <view class="padding-xl">
                    {{msg}}
                </view>
            </view>
        </view>
        
        <!-- 数据展示 -->
        <view class="zhanshi" v-show="!flag_edit">
            
            <scroll-view scroll-x class="bg-white nav" scroll-with-animation :scroll-left="scrollLeft">
                <view class="cu-item" :class="index==TabCur2?'text-green cur':''" v-for="(item,index) in data2.lou_list_re" :key="index" @tap="tabSelect2" :data-id="index" :data-item="item">
                    {{item.name}}
                </view>
            </scroll-view>
            
            <view class="padding-xl radius shadow-warp bg-cyan margin-top text-center">
                楼(街)长:{{louzhang}}
            </view> 
            
            <scroll-view scroll-x class="bg-white nav" scroll-with-animation :scroll-left="scrollLeft3">
                <view class="cu-item" :class="index==TabCur3?'text-green cur':''" v-for="(item,index) in danyuan_list" :key="index" @tap="tabSelect3" :data-id="index" :data-item="item">
                    {{item.name}}
                </view>
            </scroll-view>
            
            <view class="padding-xl radius shadow-warp bg-cyan margin-top text-center">
                单元(组)长:{{danyuanzhang}}
            </view> 
            
            
            <scroll-view scroll-x class="bg-white nav" scroll-with-animation :scroll-left="scrollLeft4">
                <view class="cu-item" :class="index==TabCur4?'text-green cur':''" v-for="(item,index) in zhuhu_list" :key="index" @tap="tabSelect4" :data-id="index" :data-item="item">
                    {{item.name}}
                </view>
            </scroll-view>
            
            <view class="padding-xl radius shadow-warp bg-cyan margin-top text-center">
                户主:{{huzhu}}
            </view> 
            
            <scroll-view scroll-x class="bg-white nav" scroll-with-animation :scroll-left="scrollLeft5">
                <view class="cu-item" :class="index==TabCur5?'text-green cur':''" v-for="(item,index) in jumin_list" :key="index" @tap="tabSelect5" :data-id="index" :data-item="item">
                    {{item.name}}
                </view>
            </scroll-view>
            
            <view class="bg-white margin-top">
                <view class="cu-form-group">
                    <view class="title">名字:</view>
                    <input name="input" disabled="true" v-model="userinfo.name"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">民族:</view>
                    <input name="input" disabled="true" v-model="userinfo.minzu"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">是否是党员:</view>
                    <input name="input" disabled="true" v-model="userinfo.is_dangyuan"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">性别:</view>
                    <input name="input" disabled="true" v-model="userinfo.sex"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">电话:</view>
                    <input name="input" disabled="true" v-model="userinfo.mobile"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">身份证号:</view>
                    <input name="input" disabled="true" v-model="userinfo.no"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">出生日期:</view>
                    <input name="input" disabled="true" v-model="userinfo.chusheng"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">文化程度:</view>
                    <input name="input" disabled="true" v-model="userinfo.wenhua"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">是否属于特殊群体:</view>
                    <input name="input" disabled="true" v-model="userinfo.is_teshu"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">特殊群体:</view>
                    <input name="input" disabled="true" v-model="userinfo.teshu"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">用户权限:</view>
                    <input name="input" disabled="true" v-model="userinfo.power"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">婚姻状况:</view>
                    <input name="input" disabled="true" v-model="userinfo.hunyin"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">现居地址:</view>
                    <input name="input" disabled="true" v-model="userinfo.address"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">单位:</view>
                    <input name="input" disabled="true" v-model="userinfo.danwei"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">职位:</view>
                    <input name="input" disabled="true" v-model="userinfo.zhiwei"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">户籍性质:</view>
                    <input name="input" disabled="true" v-model="userinfo.hujixz"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">户籍地址:</view>
                    <input name="input" disabled="true" v-model="userinfo.huji"></input>
                </view>        
            </view>
        </view>
    </view>
</template>

<script>
import {host,get,post} from '@/commons/post_and_get.js'
    export default {
        props: {
            data2:Object,
            wgy_can_edit:Boolean,
        },
        data() {
            return {
                // 切换 数据展示和编辑数据
                TabCur1:0,
                flag_edit:true,
                
                //切换不同楼
                TabCur2:0,
                scrollLeft: 0,
                louzhang:'暂无',
                danyuan_list:[],
                
                //切换不同单元
                TabCur3:0,
                scrollLeft3:0,
                danyuanzhang:'暂无',
                zhuhu_list:[],
                
                //切换不同住户
                TabCur4:0,
                scrollLeft4:0,
                huzhu:'暂无',
                jumin_list:[],
                
                //居民具体信息
                TabCur5:0,
                scrollLeft5:0,
                userinfo:{},
                
                //与编辑数据相关的数据变量
                TabCur6:0,
                flag_edit_danyuan:true,
                flag_edit_zhuhu:false,
                flag_edit_renyuan:false,
                
                danyuan_name:'',
                lou_name:'.',
                lou_id:'',
                newest_danyuan_list:[],
                modalName : null,
                msg:'',
                
                zhuhu_name:'',
                zhuhu_lou_name:'.',
                zhuhu_danyuan_name:'.',
                zhuhu_danyuan_id:'',
                zhuhu_danyuan_list:[],
                newest_zhuhu_list:[],
                
                user_lou_name:'.',
                user_danyuan_list:[],
                user_danyuan_name:'.',
                user_zhuhu_list:[],
                user_zhuhu_name:'.',
                user_zhuhu_id:'',
                
                user_name:'',
                user_minzu:'',
                user_tel:'',
                user_danwei:'',
                user_zhiwei:'',
                user_no:'',
                user_date:'',
                user_teshu:'',
                
                user_is_teshu:false,
                user_is_dangyuan:false,
                user_is_nongyehukou:false,
                user_is_huzhu:false,
                
                user_hujiadress:'',
                user_beizhu:'',
                
                user_sex:3,
                user_sex_title:'.',
                user_wenhua:1,
                user_wenhua_title:'.',
                user_hunyin:2,
                user_hunyin_title:'.',
                user_power:1,
                user_power_title:'.',
                
                user_sex_list:[{"num":1,"title":'男'},{"num":2,"title":'女'},{"num":3,"title":'不详'}],
                user_wenhua_list:[{"num":0,"title":"无学历"},{"num":1,"title":"小学"},{"num":2,"title":"初中"},{"num":3,"title":"高中"},{"num":4,"title":"中专"},{"num":5,"title":"大专"},{"num":6,"title":"本科"},{"num":7,"title":"硕士"},{"num":8,"title":"博士"}],
                user_hunyin_list:[{"num":1,"title":"未婚"},{"num":2,"title":"已婚"},{"num":3,"title":"离异"},{"num":4,"title":"丧偶"}],
                user_power_list:[{"num":1,"title":"普通用户"},{"num":1,"title":"单元(组)长"},{"num":3,"title":"楼(街)长"}],
                newest_user_list:[]
            };
        },
        methods:{
            //切换展示数据和编辑数据
            tabSelect1(e){
                this.TabCur1 = e.currentTarget.dataset.id;
                // console.log(this.TabCur1)
                if(this.TabCur1==0){
                    this.flag_edit=true
                }else{
                    this.flag_edit=false
                }
            },
            tabSelect2(e) {
                this.TabCur2 = e.currentTarget.dataset.id;
                this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
                // console.log(e.currentTarget.dataset.item)
                let item=e.currentTarget.dataset.item
                //获取楼主名
                if(item.lz){
                    for(let i=0;i<this.data2.all_user_list_re.length;i  ){
                        if(this.data2.all_user_list_re[i].id==item.lz){
                            this.louzhang=this.data2.all_user_list_re[i].name
                        }
                    }
                }else{
                    this.louzhang='暂无'
                }
                
                //生成单元列表
                this.danyuan_list=[]
                for(let j=0;j<this.data2.all_danyuan_list_re.length;j  ){
                    if(this.data2.all_danyuan_list_re[j].lou==item.id){
                        this.danyuan_list.push(this.data2.all_danyuan_list_re[j])
                    }
                }
                // console.log(this.danyuan_list)
                this.zhuhu_list=[],
                this.danyuanzhang='暂无'
                this.jumin_list=[],
                this.huzhu='暂无'
                this.userinfo={}
            },
            tabSelect3(e) {
                this.TabCur3 = e.currentTarget.dataset.id;
                this.scrollLeft3 = (e.currentTarget.dataset.id - 1) * 60
                // console.log(e.currentTarget.dataset.item)
                let item=e.currentTarget.dataset.item
                //获取单元主名
                if(item.dyz){
                    for(let i=0;i<this.data2.all_user_list_re.length;i  ){
                        if(this.data2.all_user_list_re[i].id==item.dyz){
                            this.danyuanzhang=this.data2.all_user_list_re[i].name
                        }
                    }
                }else{
                    this.danyuanzhang='暂无'
                }
                
                //生成住户列表
                this.zhuhu_list=[]
                for(let j=0;j<this.data2.all_zhuhu_list_re.length;j  ){
                    if(this.data2.all_zhuhu_list_re[j].dy==item.id){
                        this.zhuhu_list.push(this.data2.all_zhuhu_list_re[j])
                    }
                }
                // console.log(this.zhuhu_list)
                this.jumin_list=[],
                this.huzhu='暂无'
                this.userinfo={}
            },
            tabSelect4(e) {
                this.TabCur4 = e.currentTarget.dataset.id;
                this.scrollLeft4 = (e.currentTarget.dataset.id - 1) * 60
                // console.log(e.currentTarget.dataset.item)
                let item=e.currentTarget.dataset.item
                //获取户主名
                if(item.hz){
                    for(let i=0;i<this.data2.all_user_list_re.length;i  ){
                        if(this.data2.all_user_list_re[i].id==item.hz){
                            this.huzhu=this.data2.all_user_list_re[i].name
                        }
                    }
                }else{
                    this.huzhu='暂无'
                }
                
                //生成居民列表
                    //用户to住户 列表
                let z_to_u=[]
                // console.log('住户名:',item.name)
                for(let j=0;j<this.data2.all_zhuhutouser_list_re.length;j  ){
                    if(this.data2.all_zhuhutouser_list_re[j].zhhu==item.id){
                        z_to_u.push(this.data2.all_zhuhutouser_list_re[j])
                    }
                }
                // console.log('z_to_u:',z_to_u)
                //生成居民列表
                this.jumin_list=[]
                for(let x=0;x<this.data2.all_user_list_re.length;x  ){
                    for(let y=0;y<z_to_u.length;y  ){
                        if(z_to_u[y].user==this.data2.all_user_list_re[x].id){
                            this.jumin_list.push(this.data2.all_user_list_re[x])
                        }
                    }
                }
                // console.log('居民列表:',this.jumin_list)
                this.userinfo={}
                
            },
            tabSelect5(e) {
                this.TabCur5 = e.currentTarget.dataset.id;
                this.scrollLeft5 = (e.currentTarget.dataset.id - 1) * 60
                // console.log(e.currentTarget.dataset.item)
                
                let t=e.currentTarget.dataset.item
                if(t.sex==1){t.sex='男'}
                if(t.sex==2){t.sex='女'}
                if(t.sex==3){t.sex='不详'}
                if(t.hujixz==1){t.hujixz='农业户口'}
                if(t.hujixz==2){t.hujixz='非农业户口'}
                if(t.wenhua==0){t.wenhua='无'}
                if(t.wenhua==1){t.wenhua='小学'}
                if(t.wenhua==2){t.wenhua='初中'}
                if(t.wenhua==3){t.wenhua='高中'}
                if(t.wenhua==4){t.wenhua='中专'}
                if(t.wenhua==5){t.wenhua='大专'}
                if(t.wenhua==6){t.wenhua='本科'}
                if(t.wenhua==7){t.wenhua='硕士'}
                if(t.wenhua==8){t.wenhua='博士'}
                if(t.hunyin==1){t.hunyin='未婚'}
                if(t.hunyin==2){t.hunyin='已婚'}
                if(t.hunyin==3){t.hunyin='离异'}
                if(t.hunyin==4){t.hunyin='丧偶'}
                if(t.power==1){t.power='普通用户'}
                if(t.power==2){t.power='单元长(组长)'}
                if(t.power==3){t.power='楼长(街长)'}
                if(t.power==4){t.power='网格员'}
                if(t.power==5){t.power='网格长'}
                if(t.is_dangyuan){t.is_dangyuan='是'}
                if(!t.is_dangyuan){t.is_dangyuan='否'}
                if(t.is_teshu){t.is_teshu='是'}
                if(!t.is_teshu){t.is_teshu='否'}
                this.userinfo=t
            },
            
            //与编辑数据相关方法 
            tabSelect6(e){
                this.TabCur6 = e.currentTarget.dataset.id;
                if(this.TabCur6==0){
                    this.flag_edit_danyuan=true
                    this.flag_edit_zhuhu=false,
                    this.flag_edit_renyuan=false
                }
                if(this.TabCur6==1){
                    this.flag_edit_danyuan=false
                    this.flag_edit_zhuhu=true,
                    this.flag_edit_renyuan=false
                }
                if(this.TabCur6==2){
                    this.flag_edit_danyuan=false
                    this.flag_edit_zhuhu=false,
                    this.flag_edit_renyuan=true
                }
            },
            PickerChange1(e) {
                let lou=this.data2.lou_list_re[e.detail.value];
                this.lou_name=lou.name
                this.lou_id=lou.id
                // console.log(lou)
            },
            async addDanyuan(){
                let token=uni.getStorageSync('token');
                if(this.danyuan_name.length>2 && this.lou_id){
                    let x=await post('/user_operations/adddanyuan/',{'token':token,'lou_id':this.lou_id,'danyuan_name':this.danyuan_name})
                    // console.log(x)
                    if(x.status==200){
                        this.msg=x.data.msg
                        this.modalName='Modal',
                        this.danyuan_name=''
                    }
                    this.GetDanyuanAndDyz()
                }else{
                    this.msg='单元(组)名不能少于3个字且楼(街)名都不能为空!'
                    this.modalName='Modal'
                }
            },
            async GetDanyuanAndDyz(){
                let token=uni.getStorageSync('token');
                let y=await get('/user_operations/adddanyuan/',{'token':token})
                // console.log("最新单元列表:",y)
                this.newest_danyuan_list=[]
                for(let i=0;i<y.data.danyuan_list.length;i  ){
                    if(y.data.danyuan_list[i].dyz){
                        for(let j=0;j<y.data.all_dyz_list.length;j  ){
                            if(y.data.danyuan_list[i].dyz==y.data.all_dyz_list[j].id){
                                y.data.danyuan_list[i].dyz=y.data.all_dyz_list[j].name
                            }
                        }
                    }
                    for(let z=0;z<this.data2.lou_list_re.length;z  ){
                        if(y.data.danyuan_list[i].lou==this.data2.lou_list_re[z].id){
                            y.data.danyuan_list[i].lou=this.data2.lou_list_re[z].name
                        }
                    }
                }
                this.newest_danyuan_list=y.data.danyuan_list
                
            },
            hideModal(e) {
                this.modalName = null
            },
            async DelDanyuan(e){
                let token=uni.getStorageSync('token');
                let z=await get('/user_operations/deldanyuan/',{'token':token,'danyuan_id':e})
                // console.log(z)
                if(z.status==200){
                    this.GetDanyuanAndDyz()
                }else{
                    this.msg=z.data.msg
                    this.modalName='Modal'
                }
            },
              //住户相关方法
            PickerChange2(e){
                let lou=this.data2.lou_list_re[e.detail.value];
                this.zhuhu_lou_name=lou.name
                this.zhuhu_danyuan_list=[]
                for(let i=0;i<this.data2.all_danyuan_list_re.length;i  ){
                    if(this.data2.all_danyuan_list_re[i].lou==lou.id){
                        this.zhuhu_danyuan_list.push(this.data2.all_danyuan_list_re[i])
                    }
                }
                // console.log('zhuhu_danyuan_list',this.zhuhu_danyuan_list)
            },
            PickerChange3(e){
                if(this.zhuhu_danyuan_list.length>=1){
                    let dy=this.zhuhu_danyuan_list[e.detail.value];
                    this.zhuhu_danyuan_name=dy.name
                    this.zhuhu_danyuan_id=dy.id
                }else{
                    console.log('此楼无单元')
                }
                
            },
            async addZhuhu(){
                let token=uni.getStorageSync('token');
                if(this.zhuhu_name.length>2 && this.zhuhu_danyuan_id){
                    let x=await post('/user_operations/addzhuhu/',{'token':token,'dy_id':this.zhuhu_danyuan_id,'zhuhu_name':this.zhuhu_name})
                    // console.log(x)
                    if(x.status==200){
                        this.msg=x.data.msg
                        this.modalName='Modal',
                        this.zhuhu_name=''
                    }
                    this.GetZhuhu()
                }else{
                    this.msg='住户名不能少于3个字且单元(组)名都不能为空!'
                    this.modalName='Modal'
                }
            },
            async GetZhuhu(){
                let token=uni.getStorageSync('token');
                let y=await get('/user_operations/addzhuhu/',{'token':token})
                // console.log("最新住户列表:",y)
                this.newest_zhuhu_list=[]
                for(let i=0;i<y.data.zhuhu_list.length;i  ){
                    for(let j=0;j<this.newest_danyuan_list.length;j  ){
                        if(y.data.zhuhu_list[i].dy==this.newest_danyuan_list[j].id){
                            
                            y.data.zhuhu_list[i].dy=this.newest_danyuan_list[j].name
                        }
                    }
                }
                this.newest_zhuhu_list=y.data.zhuhu_list
            },
            async DelZhuhu(e){
                let token=uni.getStorageSync('token');
                let z=await get('/user_operations/delzhuhu/',{'token':token,'zhuhu_id':e})
                // console.log(z)
                if(z.status==200){
                    this.GetZhuhu()
                }else{
                    this.msg=z.data.msg
                    this.modalName='Modal'
                }
            },
             //居民相关
            PickerChange4(e){
                let lou=this.data2.lou_list_re[e.detail.value];
                this.user_lou_name=lou.name
                this.user_danyuan_list=[]
                for(let i=0;i<this.data2.all_danyuan_list_re.length;i  ){
                    if(this.data2.all_danyuan_list_re[i].lou==lou.id){
                        this.user_danyuan_list.push(this.data2.all_danyuan_list_re[i])
                    }
                }
                console.log('此楼内的单元:',this.user_danyuan_list)
            },
            PickerChange5(e){
                let danyuan=this.user_danyuan_list[e.detail.value]
                if(this.user_danyuan_list.length>=1){
                    this.user_danyuan_name=danyuan.name
                    this.user_zhuhu_list=[]
                    for(let i=0;i<this.data2.all_zhuhu_list_re.length;i  ){
                        if(this.data2.all_zhuhu_list_re[i].dy==danyuan.id){
                            this.user_zhuhu_list.push(this.data2.all_zhuhu_list_re[i])
                        }
                    }
                    console.log('此单元内的住户:',this.user_zhuhu_list)
                }else{
                    console.log('此楼无单元')
                }

            },
            PickerChange6(e){
                if(this.user_zhuhu_list.length>=1){
                    let zhuhu=this.user_zhuhu_list[e.detail.value];
                    this.user_zhuhu_name=zhuhu.name
                    this.user_zhuhu_id=zhuhu.id
                }else{
                    console.log('此单元无住户')
                }
            },
            fun_user_is_teshu(e) {
                this.user_is_teshu = e.detail.value
                // console.log(this.user_is_teshu)
            },
            fun_user_is_dangyuan(e){
                this.user_is_dangyuan=e.detail.value
            },
            fun_user_is_nongyehukou(e){
                this.user_is_nongyehukou=e.detail.value
            },
            fun_user_is_huzhu(e){
                this.user_is_huzhu=e.detail.value
            },
            PickerChange7(e){
                let x=this.user_sex_list[e.detail.value];
                this.user_sex=x.num
                this.user_sex_title=x.title
                // console.log('num:',this.user_sex,'title',this.user_sex_title)
            },
            PickerChange8(e){
                let x=this.user_wenhua_list[e.detail.value];
                this.user_wenhua=x.num
                this.user_wenhua_title=x.title
            },
            PickerChange9(e){
                let x=this.user_hunyin_list[e.detail.value];
                this.user_hunyin=x.num
                this.user_hunyin_title=x.title
            },
            PickerChange10(e){
                let x=this.user_power_list[e.detail.value];
                this.user_power=x.num
                this.user_power_title=x.title
            },
            async addUser(){
                // console.log('姓名',this.user_name,'民族',this.user_minzu,'手机号',this.user_tel,'工作单位',this.user_danwei)
                // console.log('职位',this.user_zhiwei,'身份证号',this.user_no,'出生日期',this.user_date,'特殊群体',this.user_teshu)
                // console.log('是否特殊群体',this.user_is_teshu,'是否党员',this.user_is_dangyuan,'是否农业户口',this.user_is_nongyehukou)
                // console.log('是否户主',this.user_is_huzhu,'户籍地址',this.user_hujiadress,'备注',this.user_beizhu)
                // console.log('性别',this.user_sex,'文化程度',this.user_wenhua,'婚姻状况',this.user_hunyin,'权限',this.user_power)
                // console.log('住户id',this.user_zhuhu_id)
                if(this.user_name && this.user_minzu && this.user_tel && this.user_danwei && this.user_zhiwei && this.user_no && this.user_date && this.user_teshu && this.user_hujiadress && this.user_beizhu 
&& this.user_zhuhu_id && this.user_sex && this.user_wenhua_title.length>=2 && this.user_hunyin_title.length>=2 && this.user_power_title.length>=2){
                    let token=uni.getStorageSync('token');
                    let x=await post('/user_operations/adduser/',{
                        'token':token,
                        'user_name':this.user_name,
                        'user_minzu':this.user_minzu,
                        'user_tel':this.user_tel,
                        'user_danwei':this.user_danwei,
                        'user_zhiwei':this.user_zhiwei,
                        'user_no':this.user_no,
                        'user_date':this.user_date,
                        'user_teshu':this.user_teshu,
                        'user_hujiadress':this.user_hujiadress,
                        'user_beizhu':this.user_beizhu,
                        'user_is_teshu':this.user_is_teshu,
                        'user_is_dangyuan':this.user_is_dangyuan,
                        'user_is_nongyehukou':this.user_is_nongyehukou,
                        'user_is_huzhu':this.user_is_huzhu,
                        'user_sex':this.user_sex,
                        'user_wenhua':this.user_wenhua,
                        'user_hunyin':this.user_hunyin,
                        'user_power':this.user_power,
                        'user_zhuhu_id':this.user_zhuhu_id
                    })
                    // console.log(x)
                    if(x.status==200){
                        this.GetUser()
                    }
                    this.msg=x.data.msg
                    this.modalName='Modal'
                    
                }else{
                    this.msg='表格有未填项!'
                    this.modalName='Modal'
                }
        
            },
            async GetUser(){
                let token=uni.getStorageSync('token');
                let y=await get('/user_operations/adduser/',{'token':token})
                // console.log("最新列表:",y)
                this.newest_user_list=[]
                for(let i=0;i<y.data.all_user.length;i  ){
                    for(let j=0;j<y.data.u2z_list.length;j  ){
                        if(y.data.u2z_list[j].user==y.data.all_user[i].id){
                            let t=y.data.all_user[i]
                            if(t.sex==1){t.sex='男'}
                            if(t.sex==2){t.sex='女'}
                            if(t.sex==3){t.sex='不详'}
                            if(t.hujixz==1){t.hujixz='农业户口'}
                            if(t.hujixz==2){t.hujixz='非农业户口'}
                            if(t.wenhua==0){t.wenhua='无'}
                            if(t.wenhua==1){t.wenhua='小学'}
                            if(t.wenhua==2){t.wenhua='初中'}
                            if(t.wenhua==3){t.wenhua='高中'}
                            if(t.wenhua==4){t.wenhua='中专'}
                            if(t.wenhua==5){t.wenhua='大专'}
                            if(t.wenhua==6){t.wenhua='本科'}
                            if(t.wenhua==7){t.wenhua='硕士'}
                            if(t.wenhua==8){t.wenhua='博士'}
                            if(t.hunyin==1){t.hunyin='未婚'}
                            if(t.hunyin==2){t.hunyin='已婚'}
                            if(t.hunyin==3){t.hunyin='离异'}
                            if(t.hunyin==4){t.hunyin='丧偶'}
                            if(t.power==1){t.power='普通用户'}
                            if(t.power==2){t.power='单元长(组长)'}
                            if(t.power==3){t.power='楼长(街长)'}
                            if(t.power==4){t.power='网格员'}
                            if(t.power==5){t.power='网格长'}
                            if(t.is_dangyuan){t.is_dangyuan='是'}
                            if(!t.is_dangyuan){t.is_dangyuan='否'}
                            if(t.is_teshu){t.is_teshu='是'}
                            if(!t.is_teshu){t.is_teshu='否'}
                            this.newest_user_list.push(t)
                        }
                    }
                }
            },
            async DelUser(e){
                // console.log(e)
                let token=uni.getStorageSync('token');
                let z=await get('/user_operations/deluser/',{'token':token,'user_id':e})
                // console.log(z)
                if(z.status==200){
                    this.GetUser()
                }else{
                    this.msg=z.data.msg
                    this.modalName='Modal'
                }
            }
                        
            
        },
        mounted() {
            this.GetDanyuanAndDyz()
            this.GetZhuhu()
            this.GetUser()
        }
    }
</script>

<style>

</style>

0 人点赞