| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391 |
- <template>
- <view >
- <u-toast ref="uToast"/>
- <view class="bg-white" style="padding: 10rpx 30rpx;margin: 20rpx;border-radius: 12rpx;">
- <u-form :label-style="labelStyle" label-width="180" :model="form" ref="uForm">
- <u-form-item label="住户姓名" :required="true"><u-input v-model="form.name" placeholder="请输入住户姓名"/></u-form-item>
- <u-form-item label="性别" :required="true">
- <u-input type="select" :select-open="sexShow" v-model="sexValue" placeholder="请选择性别" @click="sexShow=true"></u-input>
- </u-form-item>
-
- <u-form-item label="所属小区" :required="true">
- <u-input type="select" :select-open="residentialShow" v-model="residentialName" placeholder="请选择小区" @click="residentialShow=true"></u-input>
- </u-form-item>
- <u-form-item label="所属楼栋" :required="true">
- <!-- 新增 -->
- <u-input type="select" :select-open="buildingShow" v-model="buildingName" placeholder="请选择楼栋" @click="showBuilding"></u-input>
- </u-form-item>
- <u-form-item label="所属单元" :required="true">
- <u-input v-model="unitName" type="select" :select-open="unitShow" placeholder="请选择单元" @click="showUnit"></u-input>
- </u-form-item>
- <u-form-item label="所属房间" :required="true">
- <u-input type="select" :select-open="roomShow" v-model="roomName" placeholder="请选择房间" @click="showRoom"></u-input>
- </u-form-item>
- <u-form-item label="住户类型" :required="true">
- <u-input type="select" :select-open="typeShow" v-model="typeName" placeholder="请选择房间" @click="typeShow=true"></u-input>
- </u-form-item>
- <u-form-item label="手机号" :required="true">
- <u-input v-model="form.tel" placeholder="请填写手机号"></u-input>
- </u-form-item>
- <u-form-item label="证件类型">
- <text>身份证</text>
- </u-form-item>
- <u-form-item label="证件号码">
- <u-input v-model="form.idCard" placeholder="请填写证件号码" type="idcard"></u-input>
- </u-form-item>
- <u-form-item label="籍贯">
- <u-input v-model="form.birthPlace" placeholder="请填写籍贯"></u-input>
- </u-form-item>
- <u-form-item label="备注" label-position="top">
- <u-input type="textarea" placeholder="请填写备注" v-model="form.remark" />
- </u-form-item>
- </u-form>
- </view>
-
-
- <!-- 性别 -->
- <u-select @confirm="sexConfirm" v-model="sexShow" :list="sexList"></u-select>
-
-
- <!-- 小区 -->
- <u-popup border-radius="60" height="60%" mode="bottom" v-model="residentialShow">
- <view class="fixed cu-bar search bg-white">
- <view class="search-form round">
- <text class="cuIcon-search"></text>
- <u-input style="width: 90%;" v-model="residentialKeyword" type="text" :adjust-position="false" placeholder="请输入关键字搜索" confirm-type="search"/>
- </view>
- </view>
- <scroll-view v-if="!$isEmpty(residentialList)" style="padding-top: 110rpx;height: 100%;" :scroll-y="true" >
- <view @click="residentailConfirm(item)" hover-class="hoverClass" class="text-center padding-30 solid-bottom" v-for="(item,index) in residentialList" :key="index">
- <text>{{item.label}}</text>
- </view>
- <u-divider v-if="residentialList.length>=10" height="80">只显示十条数据</u-divider>
- </scroll-view>
- <u-empty v-else name="search"></u-empty>
- </u-popup>
-
- <!-- 楼栋 -->
- <u-popup border-radius="60" height="60%" mode="bottom" v-model="buildingShow">
- <view class="fixed cu-bar search bg-white">
- <view class="search-form round">
- <text class="cuIcon-search"></text>
- <u-input style="width: 90%;" v-model="buildingKeyWord" type="text" :adjust-position="false" placeholder="请输入关键字搜索" confirm-type="search"/>
- </view>
- </view>
- <scroll-view v-if="!$isEmpty(buildingList)" style="padding-top: 110rpx;height: 100%;" :scroll-y="true" >
- <view @click="buildingConfirm(item)" hover-class="hoverClass" class="text-center padding-30 solid-bottom" v-for="(item,index) in buildingList" :key="index">
- <text>{{item.name}}</text>
- </view>
- <u-divider v-if="buildingList.length>=10" height="80">只显示十条数据</u-divider>
- </scroll-view>
- <u-empty v-else name="search"></u-empty>
- </u-popup>
-
- <!-- 单元 -->
- <u-picker @confirm="unitConfirm" range-key="name" :range="unitList" v-model="unitShow" mode="selector"></u-picker>
- <!-- 房间-->
- <u-select @confirm="roomConfirm" v-model="roomShow" :list="roomList"></u-select>
-
- <!-- 住户类型 -->
- <u-select @confirm="typeConfirm" v-model="typeShow" :list="typeList"></u-select>
-
- <view @click="confirm" style="display: flex;justify-content: center;">
- <view class="cu-btn bg-blue radius" style="width: 70%;height: 84rpx;margin: 20rpx 0;">
- 提交
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: '',
- data() {
- return {
- labelStyle:{
- "fontWeight":"600"
- },
- form:{},
- // 性别
- sexValue:'', //回显
- sexShow:false,
- sexList:[
- {
- value:'1',
- label:'男'
- },
- {
- value:'2',
- label:'女'
- },
- ],
-
-
- //小区
- residentialName:'',
- residentialShow:false,
- residentialKeyword:'',
- residentialList:[],
-
-
- //楼栋
- buildingName:'',
- buildingShow:false,
- buildingKeyWord:'',
- buildingList:'',
-
-
- //单元
- unitName:'',
- unitList:[],
- unitShow:false,
-
- //房间
- roomName:'', //回显
- roomShow:false,
- roomList:[],
-
- //筛选
- searchList:[],
-
- //住户类型
- typeName:'', //回显
- typeShow:false,
- typeList:[
- {
- value:'0',
- label:'业主'
- },
- {
- value:'1',
- label:'成员'
- },
- {
- value:'2',
- label:'租户'
- },
- ],
-
- };
- },
- onLoad(options) {
- this.getResidentailList({})
- },
- watch:{
- residentialKeyword(){
- let that=this
- //节流函数
- if (this.timer){
- clearTimeout(this.timer)//阻止setTimeout函数的执行
- }
- this.timer = setTimeout(() => {
- that.residentialList=[]
- let params = {
- // isSelect: true,
- name: that.residentialKeyword
- }
- this.getResidentailList(params)
- }, 500)
- },
- buildingKeyWord(){
- let that=this
- //节流函数
- if (this.timer){
- clearTimeout(this.timer)//阻止setTimeout函数的执行
- }
- this.timer = setTimeout(() => {
- that.buildingList=[]
- let params={
- residentialId:that.form.residentialId,
- name:that.buildingKeyWord
- }
- that.fetchBuildingList(params)
- }, 500)
- },
- },
- onShow() {
-
- },
- methods:{
- // 性别
- sexConfirm(e){
- this.sexValue=e[0].label
- this.form.sex=e[0].value
- },
- //获取小区列表
- getResidentailList(params){
- let list = [];
- this.$api.residential.page(params).then(res=>{
- let list=[]
- res.data.records.forEach(item=>{
- let obj={
- label:item.name,
- value:item.id
- }
- list.push(obj)
- })
- this.residentialList = list;
- })
- },
- //小区确认
- residentailConfirm(res){
- this.form.residentialId=res.value
- this.residentialName=res.label
- this.residentialShow=false
- //获取楼栋列表
- let params={
- residentialId:res.value
- }
- this.fetchBuildingList(params)
-
- },
- /**
- * 获取楼栋列表
- * @param {Object}
- */
- fetchBuildingList(params){
- this.$api.building.page(params).then(res=>{
- this.buildingList=res.data.records
- })
- },
- //点击选择楼栋,获取单元列表
- buildingConfirm(res){
- this.form.buildingId=res.id
- this.buildingName = res.name
- this.buildingShow = false
- let params={
- residentialId:this.form.residentialId,
- buildingId:res.id
- }
- this.getUnitByResidentialId(params)
- },
- //楼栋
- showBuilding(){
- if (this.$isEmpty(this.form.residentialId)) {
- this.$showToast('请先选择小区','error')
- return
- }
- this.buildingShow=true
- },
- //单元
- getUnitByResidentialId(params){
- this.$api.unit.page(params).then(res=>{
- this.unitList=res.data.records
- })
- },
- showUnit(){
- if (this.$isEmpty(this.form.residentialId)) {
- this.$showToast('请先选择小区','error')
- return
- }
- if (this.$isEmpty(this.form.buildingId)) {
- this.$showToast('请先选择楼栋','error')
- return
- }
- this.unitShow=true
- },
- unitConfirm(index){
- this.unitName=this.unitList[index].name
- this.form.unitId=this.unitList[index].id
- this.fetchRoomList()
- },
- //房间
- fetchRoomList(){
- let params={
- unitId:this.form.unitId,
- // isSelect:true
- }
- this.$api.room.pageBycondition(params).then(res=>{
- this.roomList=[]
- res.data.records.forEach(item=>{
- let list={
- label:item.name,
- value:item.id
- }
- this.roomList.push(list)
- })
- })
- },
- roomConfirm(e){
- this.roomName=e[0].label
- this.form.roomId=e[0].value
- },
- showRoom(){
- if (this.$isEmpty(this.form.residentialId)) {
- this.$showToast('请先选择小区','error')
- return
- }
- if (this.$isEmpty(this.form.buildingId)) {
- this.$showToast('请先选择楼栋','error')
- return
- }
- if (this.$isEmpty(this.form.unitId)) {
- this.$showToast('请先选择单元','error')
- return
- }
- this.roomShow=true
- },
- //住户类型
- typeConfirm(e){
- this.typeName=e[0].label
- this.form.type=e[0].value
- },
- confirm(){
- if (this.$isEmpty(this.form.name)) {
- this.$showToast('请输入姓名','error')
- return
- }
- if (this.$isEmpty(this.form.sex)) {
- this.$showToast('请选择性别',"error")
- return
- }
- if (this.$isEmpty(this.form.residentialId)) {
- this.$showToast('请选择小区','error')
- return
- }
- if (this.$isEmpty(this.form.unitId)) {
- this.$showToast('请选择单元','error')
- return
- }
- if (this.$isEmpty(this.form.roomId)) {
- this.$showToast('请选择房间','error')
- return
- }
- if (this.form.type==-1) {
- this.$showToast('请选择住户类型','error')
- return
- }
- if (this.$isEmpty(this.form.tel)) {
- this.$showToast('请填写手机号码','error')
- return
- }
- if (!this.$verify.phone(this.form.tel)) {
- this.$showToast('手机格式不正确','error')
- return
- }
- if (!this.$isEmpty(this.form.idCard)) {
- if (!this.$verify.idCard(this.form.idCard)) {
- this.$showToast('身份证号码不正确','error')
- return
- }
- }
- //添加住户
- this.$api.user.add(this.form).then(res=>{
- if (res.code==200) {
- this.$dialog.showModal('操作成功',false).then(res=>{
- this.$navigateBack()
- })
- }else{
- this.$showToast(res.msg,'error')
- }
- })
-
-
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- </style>
|