| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- <template>
- <view class="" >
- <u-toast ref="uToast"/>
- <view class="bg-white" style="padding: 10rpx 30rpx;margin: 20rpx;border-radius: 12rpx;">
- <u-form :label-style="labelStyle" label-width="150" :model="form" ref="uForm">
- <u-form-item label="房间名称" :required="true"><u-input v-model="form.name" placeholder="请输入房间名称"/></u-form-item>
- <u-form-item v-if="!$isEmpty(form.id)" label="门牌号" :required="true"><u-input v-model="form.houseNumber" placeholder="请输入门牌号"/></u-form-item>
- <u-form-item label="所属小区" :required="true">
- <u-input v-if="$isEmpty(form.id)" type="select" :select-open="residentialShow" v-model="residentialName" placeholder="请选择小区" @click="residentialShow=true"></u-input>
- <u-input v-else disabled v-model="form.residentialName" ></u-input>
- </u-form-item>
- <u-form-item label="所属楼栋" :required="true">
- <!-- 新增 -->
- <u-input v-if="$isEmpty(form.id)" type="select" :select-open="buildingShow" v-model="form.buildingName" placeholder="请选择小区" @click="showBuilding"></u-input>
- <!-- 修改 -->
- <u-input v-else disabled v-model="form.buildingName" ></u-input>
- </u-form-item>
- <u-form-item label="所属单元" :required="true">
- <u-input v-if="$isEmpty(form.id)" v-model="unitName" type="select" :select-open="unitShow" placeholder="请选择单元" @click="showUnit"></u-input>
- <u-input v-else v-model="form.unitName" disabled ></u-input>
- </u-form-item>
- <u-form-item label="面积">
- <u-input v-model="form.area" type="number" placeholder="请填写房间面积"></u-input>
- </u-form-item>
- <u-form-item label="户型">
- <u-input v-model="form.houseType" placeholder="请填写房间户型"></u-input>
- </u-form-item>
- <u-form-item label="楼层">
- <u-input v-model="form.floorName" placeholder="请填写房间楼层"></u-input>
- </u-form-item>
- <u-form-item label="装修">
- <u-input v-model="form.ornament" placeholder="请填写房间装修"></u-input>
- </u-form-item>
- <u-form-item label="朝向">
- <u-input v-model="form.orientation" placeholder="请填写房间朝向"></u-input>
- </u-form-item>
- <u-form-item label="序号">
- <u-number-box :min="1" :max="100" solt="right" v-model="form.serial" ></u-number-box>
- </u-form-item>
- <u-form-item label="备注" label-position="top">
- <u-input type="textarea" height="300" maxlength="300" v-model="form.remark" placeholder="请输入300字以内的备注介绍"></u-input>
- </u-form-item>
- </u-form>
- </view>
-
- <!-- 小区 -->
- <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="residentialConfirm(item)" hover-class="hoverClass" class="text-center padding-30 solid-bottom" v-for="(item,index) in residentialList" :key="index">
- <text>{{item.name}}</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>
-
- <view @click="confirm" class="bottom-bar" >
- <view class="cu-btn bg-blue radius" style="width: 70%;height: 84rpx;">
- 提交
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: '',
- data() {
- return {
- labelStyle:{
- "fontWeight":"600"
- },
- form:{
- name:'',
- residentialId:'',
- unitId:'',
- houseType:'',
- floor:'',
- orientation:'',
- serial:1,
- remark:''
- },
- //小区
- residentialName:'',
- residentialShow:false,
- residentialKeyword:'',
- residentialList:[],
- //楼栋
- buildingName:'',
- buildingShow:false,
- buildingKeyWord:'',
- buildingList:'',
- //单元
- unitName:'',
- unitList:[],
- unitShow:false
- };
- },
- onLoad(options) {
- //加载小区数据
- this.fetchResidentialList()
- if (!this.$isEmpty(options.id)) {
- this.form.id=options.id
- this.fetchDataDetail()
- uni.setNavigationBarTitle({
- title:"修改房间信息"
- })
- }
- },
- watch:{
- //小区
- residentialKeyword(){
- let that=this
- if (this.timer){
- clearTimeout(this.timer)
- }
- this.timer = setTimeout(() => {
- that.residentialList=[]
- that.getResidentailList()
- }, 500)
- },
- //楼栋
- buildingKeyWord(){
- let that=this
- if (this.timer){
- clearTimeout(this.timer)
- }
- this.timer = setTimeout(() => {
- that.buildingList=[]
- let params={
- residentialId:that.form.residentialId,
- name:that.buildingKeyWord
- }
- that.fetchBuildingList(params)
- }, 500)
- },
- },
- methods:{
- fetchDataDetail(){
- this.$api.room.pageBycondition({id:this.form.id}).then(res=>{
- this.form=res.list[0]
- })
- },
-
- //修改房间时,加载房间的数据
- /**
- * 获取小区数据列表
- */
- fetchResidentialList(){
- let params={
- isSelect: true,
- name:this.residentialKeyword
- }
- this.$api.residential.page(params).then(res=>{
- this.residentialList = res.list
- })
- },
- //点击选择小区时
- residentialConfirm(item){
- //赋值给提交的数据
- this.form.residentialId=item.id
- //赋值给回显的名称
- this.residentialName=item.name
- //加载楼栋信息
- this.buildingList=[]
- let params={
- residentialId:item.id
- }
- this.fetchBuildingList(params)
- this.residentialShow=false
- },
- showBuilding(){
- if (this.$isEmpty(this.residentialName)) {
- this.$showToast('请先选择小区','warning')
- return
- }
- this.buildingShow=true
- },
- showUnit(){
- if (this.$isEmpty(this.buildingName)) {
- this.$showToast('请先选择楼栋','warning')
- return
- }
- this.unitShow=true
- },
- /**
- * 获取楼栋列表
- * @param {Object}
- */
- fetchBuildingList(params){
- this.$api.building.page(params).then(res=>{
- this.buildingList=res.data.records
- })
- },
- /**
- * 选择楼栋
- */
- buildingConfirm(item){
- // 赋值给提交的数据
- this.form.buildingId=item.id
- //数据回显
- this.buildingName=item.name
- //加载单元列表
- this.fetchUnitList()
- this.buildingShow=false
- },
- /**
- * 获取单元列表
- */
- fetchUnitList(){
- let params={
- buildingId:this.form.buildingId,
- residentialId:this.form.residentialId
- }
- this.$api.unit.page(params).then(res=>{
- this.unitList = res.list
- })
- },
- /**
- * 点击选择单元
- * @param {Object}
- */
- unitConfirm(e){
- console.log(e);
- //赋值给提交的数据
- this.form.unitId=this.unitList[e[0]].id
- //赋值给回显的名称
- this.unitName=this.unitList[e[0]].name
- this.unitShow=false
- },
- confirm(){
- if (this.$isEmpty(this.form.name)) {
- this.$u.toast('请输入房间名称')
- return
- }
- if (this.$isEmpty(this.form.residentialId)) {
- this.$u.toast("请选择小区")
- return
- }
- if (this.$isEmpty(this.form.buildingId)) {
- this.$u.toast("请选择楼栋")
- return
- }
- if (this.$isEmpty(this.form.unitId)) {
- this.$u.toast('请选择单元')
- return
- }
- console.log(this.form);
- if (this.$isEmpty(this.form.id)) {
- return
- this.$api.room.add(this.form).then(res=>{
- if (res.data) {
- this.$dialog.showModal('操作成功',false).then(res=>{
- uni.navigateBack()
- })
- }else{
- this.$u.toast('操作失败')
- }
- })
- //新增
- }else{
- let {oldId,orgPosition,...params}=this.form
- //修改
- this.$api.room.update(params).then(res=>{
- if (res.data==true) {
- this.$dialog.showModal('操作成功',false).then(res=>{
- uni.navigateBack()
- })
- }else{
- this.$u.toast('操作失败')
- }
- })
- }
- }
-
- }
- };
- </script>
- <style lang="scss" scoped>
- page{
- background-color: #FFFFFF;
- }
- </style>
|