PropertySettledForm.vue 16.3 KB
Newer Older
宋雄's avatar
宋雄 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-card title="物业集团基本信息">
          <a-row>
            <a-col :span="12">
              <a-form-model-item label="物业集团名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="propertyName">
                <a-input v-model="model.propertyName" placeholder="请输入物业集团名称"  ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="统一信用代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="creditCode">
                <a-input v-model="model.creditCode" placeholder="请输入统一信用代码"  ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="法人姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="legalName">
                <a-input v-model="model.legalName" placeholder="请输入法人姓名"  ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="注册资本" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="registCapital">
                <a-input-number v-model="model.registCapital" :min="1" placeholder="请输入注册资本" style="width: 100%" />
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactName">
                <a-input v-model="model.contactName" placeholder="请输入联系人"  ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="联系人电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactPhone">
                <a-input v-model="model.contactPhone" placeholder="请输入联系人电话"  ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="注册地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="registAdress">
                <area-cascader
                  v-model="model.registAdress"
                  :data="pcaa"
                  :level="1"
                  type="all"
                  @change="addressChange"
                  style="width:100%"
                />
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="详细地址" :labelCol="{ xs:{ span: 24 }, sm:{ span: 3 } }" :wrapperCol="wrapperCol" prop="addressInfo">
宋雄's avatar
宋雄 committed
51
                <a-input v-model="model.addressInfo" placeholder="请输入详细地址" @blur="addressBlur" ></a-input>
宋雄's avatar
宋雄 committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="" :offset="3" :pull="3" :labelCol="{ xs:{ span: 24 }, sm:{ span: 3 } }">
                <div class="hhh">
                  <div id="container" style="width:100%;height:200px"></div>
                </div>
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="集团logo" :labelCol="{ xs:{ span: 24 }, sm:{ span: 3 } }" :wrapperCol="wrapperCol" prop="logoUrl">
                <j-image-upload bizPath="scott/pic" v-model="model.logoUrl"></j-image-upload>
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="集团介绍" :labelCol="{ xs:{ span: 24 }, sm:{ span: 3 } }" :wrapperCol="wrapperCol" prop="groupInfo">
                <a-textarea v-model="model.groupInfo" placeholder="请输入集团介绍" :auto-size="{ minRows: 3, maxRows: 5 }" />
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-card>
        <a-card title="授权信息">
          <a-row>
            <!-- <a-col :span="12">
              <a-form-model-item label="试用日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="empowerType">
                <a-range-picker v-model="model.empowerDate" placeholder="请选择试用日期" />
              </a-form-model-item>
            </a-col> -->
            <a-col :span="12">
              <a-form-model-item label="授权开始日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="empowerBeginDate">
                <j-date placeholder="请选择授权开始日期" v-model="model.empowerBeginDate"  style="width: 100%" />
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="授权结束日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="empowerEndDate">
                <j-date placeholder="请选择授权结束日期" v-model="model.empowerEndDate"  style="width: 100%" />
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="试用小区数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ontrialCommunityNum">
                <a-input-number v-model="model.ontrialCommunityNum" placeholder="请输入试用小区数量" style="width: 100%" />
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="收费标准" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="chargingStandardId">
                <a-select v-model="model.chargingStandardId" placeholder="请选择收费标准" style="width: 100%">
                  <a-select-option v-for="item in costList" :key="item.id" :value="item.id">{{item.chargingName}}</a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="管理员账户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="adminLoginName">
                <a-input v-model="model.adminLoginName" placeholder="请输入管理员账户"  ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="管理员密码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="adminPassword">
                <a-input v-model="model.adminPassword" placeholder="请输入管理员密码"  ></a-input>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-card>
        <a-card title="合同附件">
          <a-row>
            <a-col :span="24">
              <a-form-model-item label="合同附件" :labelCol="{ xs:{ span: 24 }, sm:{ span: 3 } }" :wrapperCol="wrapperCol" prop="contractUrl">
                <j-upload v-model="model.contractUrl"></j-upload>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-card>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>
  const mapZoom = [5,8,10,12]
  let timer = null;
宋雄's avatar
宋雄 committed
131
  import { getPropertyChargruleListApi } from '@/api/api'
宋雄's avatar
宋雄 committed
132
  import { httpAction, getAction } from '@/api/manage'
宋雄's avatar
宋雄 committed
133
  import { isMobile } from '@/utils/validate'
宋雄's avatar
宋雄 committed
134 135 136 137 138 139 140 141 142 143 144 145

  export default {
    name: 'PropertySettledForm',
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
宋雄's avatar
宋雄 committed
146 147 148 149 150 151 152
      const validateToNextPhone = (rule, value, callback)=> {
        if (value && isMobile(value)) {
          callback();
        } else {
          callback('请输入正确的联系人电话!');
        }
      }
宋雄's avatar
宋雄 committed
153 154 155
      return {
        pcaa: this.$Jpcaa,
        model:{
宋雄's avatar
宋雄 committed
156 157 158 159 160
          propertyName: '',
          creditCode: '',
          legalName: '',
          registCapital: undefined,
          contactName: '',
宋雄's avatar
宋雄 committed
161
          contactPhone: '',
宋雄's avatar
宋雄 committed
162
          registAdress: [],
宋雄's avatar
宋雄 committed
163 164 165 166 167 168
          provinceName: '',
          provinceCode: '',
          cityName: '',
          cityCode: '',
          countyName: '',
          countyCode: '',
宋雄's avatar
宋雄 committed
169 170 171 172 173 174
          addressInfo: '',
          logoUrl: '',
          groupInfo: '',
          empowerBeginDate: '',
          empowerEndDate: '',
          ontrialCommunityNum: undefined,
宋雄's avatar
宋雄 committed
175
          chargingStandardId: '',
宋雄's avatar
宋雄 committed
176
          contractUrl: '',
宋雄's avatar
宋雄 committed
177 178
          adminLoginName: '',
          adminPassword: '123456',
宋雄's avatar
宋雄 committed
179 180
          longitude: '',
          latitude: ''
宋雄's avatar
宋雄 committed
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
        },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
          propertyName: [{ required: true, message: '请输入物业集团名称', trigger: 'blur' }],
          creditCode: [{ required: true, message: '请输入统一信用代码', trigger: 'blur' }],
          legalName: [{ required: true, message: '请输入法人代表', trigger: 'blur' }],
          registCapital: [{ required: true, message: '请输入注册资本', trigger: 'blur' }],
          contactName: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
宋雄's avatar
宋雄 committed
197 198 199 200
          contactPhone: [
            { required: true, message: '请输入联系人电话', trigger: 'blur' },
            { validator: validateToNextPhone }
          ],
宋雄's avatar
宋雄 committed
201 202 203 204 205 206 207 208 209
          registAdress: [{ required: true, message: '请选择注册地址', trigger: 'change' }],
          addressInfo: [{ required: true, message: '请输入详细地址', trigger: 'blur' }],
          logoUrl: [{ required: true, message: '请上传集团LOGO', trigger: 'change' }],
          chargingStandardId: [{ required: true, message: '请选择收费标准', trigger: 'change' }],
          adminLoginName: [{ required: true, message: '请输入管理员账号', trigger: 'blur' }],
          adminPassword: [{ required: true, message: '请输入管理员密码', trigger: 'blur' }],
          contractUrl: [{ required: true, message: '请上传合同附件', trigger: 'change' }]
        },
        url: {
宋雄's avatar
宋雄 committed
210 211 212
          add: "/property-central/property/propertySettled/add",
          edit: "/property-central/property/propertySettled/edit",
          queryById: "/property-central/property/propertySettled/queryById"
宋雄's avatar
宋雄 committed
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
        },
        costList: [],
        mapRef: null,
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    watch: {
      'model.contactPhone': {
        handler(newV, oldV) {
          this.model.adminLoginName = newV
        }
      },
      'model.addressInfo': {
        handler(newV) {
          if(newV) {
            clearTimeout(timer)
            timer = setTimeout(()=> {
              // this.getLongitude(this.model.categoryCodes[0], this.model.categoryCodes.join('') + newV, mapZoom[3])
            }, 1000)
          }
        }
      }
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
      this.onLoadCostList()
    },
    mounted() {
      this.mapRef = new BMapGL.Map("container");          // 创建地图实例 
      var point = new BMapGL.Point(108.5525, 34.3237);  // 创建点坐标 
      this.mapRef.centerAndZoom(point, mapZoom[0]);
      // var zoomCtrl = new BMapGL.ZoomControl();  // 添加缩放控件
      // this.mapRef.addControl(zoomCtrl);
      this.mapRef.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
      this.mapRef.addEventListener('click',  e=>this.getAddress(e));
    },
    methods: {
      async onLoadCostList() {
宋雄's avatar
宋雄 committed
256 257
        let data = await getPropertyChargruleListApi()
        this.costList = data.result
宋雄's avatar
宋雄 committed
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
      },
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      addressChange(val) {
        const province = Object.keys(val[0])[0]
        const city = Object.keys(val[1])[0]
        const county = Object.keys(val[2])[0]
        this.model.provinceName = val[0][province]
        this.model.provinceCode = province
        this.model.cityName = val[1][city]
        this.model.cityCode = city
        this.model.countyName = val[2][county]
        this.model.countyCode = county
        if(this.model.addressInfo) {
          this.getLongitude(this.model.provinceName, (this.model.provinceName + this.model.cityName + this.model.countyName + this.model.addressInfo), mapZoom[3])
        }
      },
宋雄's avatar
宋雄 committed
280 281 282 283 284
      addressBlur(val) {
        if(this.model.provinceName) {
          this.getLongitude(this.model.provinceName, (this.model.provinceName + this.model.cityName + this.model.countyName + val.target.value), mapZoom[3])
        }
      },
宋雄's avatar
宋雄 committed
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
      getAddress(e) {
        let _this = this;
        // 创建地理编码实例      
        var myGeo = new BMapGL.Geocoder();      
        // 根据坐标得到地址描述    
        myGeo.getLocation(new BMapGL.Point(e.latlng.lng, e.latlng.lat), function(result){      
          if(result) {
            _this.mapRef.clearOverlays();
            _this.model.registAdress = [result.addressComponents.province, result.addressComponents.city, result.addressComponents.district]
            _this.model.addressInfo = result.addressComponents.street + result.addressComponents.streetNumber
            _this.model.longitude = result.point.lng
            _this.model.latitude = result.point.lat
            _this.positionMap(e.latlng.lng, e.latlng.lat, mapZoom[3], result.address)
            console.log(result)
          }
        });
      },
      positionMap(mapCenterLng, mapCenterLat, mapzoom, address) {
        var point = new BMapGL.Point(mapCenterLng, mapCenterLat);  // 创建点坐标
        this.mapRef.centerAndZoom(point, mapzoom);
        var marker = new BMapGL.Marker(point, {title: address});        // 创建标注
        this.mapRef.addOverlay(marker);                     // 将标注添加到地图中
        let _this = this;
        // marker.addEventListener("click", function(){ 
          var label = new BMapGL.Label(address, {       // 创建文本标注
              position: point,                          // 设置标注的地理位置
              offset: new BMapGL.Size(0, -55)           // 设置标注的偏移量
          })
          _this.mapRef.addOverlay(label);                        // 将标注添加到地图中
          label.setStyle({                              // 设置label的样式
            color: '#333',
            fontSize: '14px',
            padding: '4px 10px',
            border: '1px solid #1E90FF',
            borderRadius: '4px',
            transform: 'translateX(-40%)'
          })
        // });
      },
      getLongitude(city, address, zoom) {
        let _this = this
        var myGeo = new BMapGL.Geocoder();
        myGeo.getPoint(address, function(point){
          if(point){
              _this.mapRef.clearOverlays();
宋雄's avatar
宋雄 committed
330 331
              _this.model.longitude = point.lng
              _this.model.latitude = point.lat
宋雄's avatar
宋雄 committed
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
              _this.positionMap(point.lng, point.lat, zoom, address)
          }else{
            console.log('您选择的地址没有解析到结果!');
          }
        }, city)
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
              method = 'put';
            }
宋雄's avatar
宋雄 committed
353
            this.model.registAdress = undefined
宋雄's avatar
宋雄 committed
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    },
    beforeDestroy() {
      clearTimeout(timer)
      this.mapRef.removeEventListener('click',  e=>this.getAddress(e));
    }
  }
</script>