<template>
    <div class="propertyEditor">
      <ul class="detailUl">
        <li class="detailLi">
          <span class="liName">
            <span style="color: red;margin-right: 5rpx">*</span>
            父级
          </span>
          <div class="inputBox" @tap="showPop('父级')">
            <input placeholder="园区、楼盘、楼栋数" disabled class="myIpt" v-model="buildFa">
            <van-icon name="arrow-down" />
          </div>
        </li>
        <li class="detailLi">
          <span class="liName">
            <span style="color: red;margin-right: 5rpx">*</span>
            区域
          </span>
          <div class="inputBox">
            <input placeholder="请选择" disabled class="myIpt">
            <van-icon name="arrow-down" />
          </div>
        </li>
        <li class="detailLi">
          <span class="liName">
            <span style="color: red;margin-right: 5rpx">*</span>
            楼层
          </span>
          <div class="inputBox">
            <input placeholder="请选择" disabled class="myIpt">
            <van-icon name="arrow-down" />
          </div>
        </li>
        <li class="detailLi">
          <span class="liName">
            <span style="color: red;margin-right: 5rpx">*</span>
            出租单元名称
          </span>
           <input placeholder="请填写" class="myIpt" style="padding-right: 30rpx">
        </li>
        <li class="detailLi">
          <span class="liName">
            平面图号
          </span>
           <input placeholder="请填写" class="myIpt" style="padding-right: 30rpx">
        </li>
        <li class="detailLi">
          <span class="liName">
          <span style="color: red;margin-right: 5rpx">*</span>
            面积（㎡）
          </span>
           <input placeholder="请填写" class="myIpt" value="256" style="padding-right: 30rpx">
        </li>
        <li class="detailLi">
          <span class="liName">
          <span style="color: red;margin-right: 5rpx">*</span>
            用途
          </span>
          <div class="inputBox">
            <input placeholder="请选择" disabled class="myIpt">
            <van-icon name="arrow-down" />
          </div>
        </li>
        <li class="detailLi">
          <span class="liName">
            物业性质
          </span>
          <div class="inputBox">
            <input placeholder="请选择" disabled class="myIpt">
            <van-icon name="arrow-down" />
          </div>
        </li>
        <li class="detailLi">
          <span class="liName">
          <span style="color: red;margin-right: 5rpx">*</span>
            朝向
          </span>
          <div class="inputBox">
            <input placeholder="请选择" disabled class="myIpt">
            <van-icon name="arrow-down" />
          </div>
        </li>
        <li class="detailLi">
          <span class="liName">
          <span style="color: red;margin-right: 5rpx">*</span>
            装修情况
          </span>
          <div class="inputBox">
            <input placeholder="请选择" disabled class="myIpt">
            <van-icon name="arrow-down" />
          </div>
        </li>
        <li class="detailLi">
          <span class="liName">
            层高
          </span>
           <input placeholder="请填写" class="myIpt" style="padding-right: 30rpx">
        </li>
        <li class="detailLi2" >
          <div class="titleBox" >
            <span class="liName">承重情况</span>
          </div>
          <van-field
              autosize
              type="textarea"
              placeholder="请输入"
              class="myField"
              maxlength="1000"
              show-word-limit
          />
        </li>
        <li class="detailLi2" >
          <div class="titleBox" >
            <span class="liName">用电说明</span>
          </div>
          <van-field
              autosize
              type="textarea"
              placeholder="请输入"
              class="myField"
              maxlength="1000"
              show-word-limit
          />
        </li>
        <li class="detailLi2" >
          <div class="titleBox" >
            <span style="color: red;margin-right: 5rpx">*</span>
            <span class="liName">出租指导价（元/㎡/月）</span>
          </div>
          <van-field
              autosize
              type="textarea"
              placeholder="请输入"
              class="myField"
          />
        </li>
        <li class="detailLi2" >
          <div class="titleBox" >
            <span class="liName">备注</span>
          </div>
          <van-field
              autosize
              type="textarea"
              placeholder="请输入"
              class="myField"
              maxlength="1000"
              show-word-limit
          />
        </li>
        <li class="detailLi2" >
          <div class="titleBox" style="margin-bottom: 24rpx">
            <span class="liName">
              房型图
               <span style="color: #B3B3B3;font-size: 28rpx">（只能上传jpg/png格式，限制上传9张）</span>
            </span>
          </div>
          <van-uploader
              :max-count="9"
              @delete="deleteRYXXZP"
              :file-list="fileList"
              @after-read="uploadRYXXZP"
              :show-upload="true"
          />
        </li>
        <li class="detailLi2" >
          <div class="titleBox" style="margin-bottom: 24rpx">
            <span class="liName">
              室内外环境
            <span style="color: #B3B3B3;font-size: 28rpx">（只能上传jpg/png格式，限制上传6张）</span>
            </span>
          </div>
          <van-uploader
              :max-count="6"
              @delete="deleteRYXXZP2"
              :file-list="fileList2"
              @after-read="uploadRYXXZP2"
              :show-upload="true"
          />
        </li>
        <li class="detailLi2" style="position:relative;">
          <div class="titleBox" >
            <span class="liName">出租位置</span>
          </div>
          <van-field
              autosize
              type="textarea"
              placeholder="请选择地址"
              class="myField"
              style="padding-right: 120rpx;box-sizing: border-box"
          />
          <div class="locationBox">
            <van-icon name="location" />
            地图
          </div>
        </li>
        <li class="detailLi">
          <span class="liName">
            当前可用状态
          </span>
        <div class="inputBox">
          <input placeholder="请选择" disabled class="myIpt">
          <van-icon name="arrow-down" />
        </div>
        </li>
        <li class="detailLi" style="border-bottom: none">
          <span class="liName">
            租赁状态
          </span>
        <div class="inputBox">
          <input placeholder="请选择" disabled class="myIpt">
          <van-icon name="arrow-down" />
        </div>
        </li>
      </ul>
      <button class="commitBtn">保存</button>
      <van-popup
        :show="showTree"
         round position="bottom"
        custom-style="height:80%;"
      >
        <van-cascader
            :value="cascaderValue"
            title="请选择所在地区"
            :options="options"
            @close="showTree = false"
            @finish="onFinish"
            :field-names="fieldNames"
        />
      </van-popup>
      <van-popup
          :show="show"
          position="bottom"
          custom-style="height: 50%;"
      >
        <van-picker :columns="columns" show-toolbar @cancel="show=false" @confirm="onConfirm" />
      </van-popup>
    </div>
</template>

<script>
import {
  getTreeData2,
} from "@/js_sdk/http";
export default {
  name: "propertyEditor",
  data(){
    return{
      fileList: [],
      fileList2: [],
      buildFa:'',
      show:false,
      showTree:false,
      cascaderValue: null,
      fieldNames: {
        text: 'label',
        value: 'value',
        children: 'children',
      },
      options:[

      ],
      columns: ['杭州', '宁波', '温州', '嘉兴', '湖州']
    }
  },
  onLoad(){
    this.getTree()
  },
  methods:{
    getTree(){
      getTreeData2().then(res=>{
        console.log(res.data)
        this.options = res.data
      })
    },
    showPop(e){
      this.showTree = true
    },
    onFinish(e){
      console.log(e)
      const fieldValue = e.detail.selectedOptions
          .map((option) => option.label)
          .join('/');
      this.buildFa = fieldValue
      this.showTree = false
    },
    onConfirm(e){
      console.log(e)
      this.show = false
    },
    deleteRYXXZP(event) {
      this.fileList.splice(event.detail.index, 1);
      this.$forceUpdate();
    },
    deleteRYXXZP2(event) {
      this.fileList.splice(event.detail.index, 1);
      this.$forceUpdate();
    },
    uploadRYXXZP(event) {
      console.log(event)
      let that = this;
      const { file } = event.detail;
      uni.uploadFile({
        url: that.$constant.BASE_URI + "/wx/fileController/upload",
        filePath: file.url,
        name: "file",
        formData: { user: "test" },
        success(res) {
          // 上传完成需要更新 fileList
          let data = JSON.parse(res.data);
          that.fileList.push({
            imgUrl: "/FileController/download/" + data.data[0],
            id: data.data[0],
            url:
                that.$constant.BASE_URI +
                "/FileController/download/" +
                data.data[0],
            isImage: true,
          });
        },
        fail(res) {},
      });
    },
    uploadRYXXZP2(event) {
      console.log(event)
      let that = this;
      const { file } = event.detail;
      uni.uploadFile({
        url: that.$constant.BASE_URI + "/wx/fileController/upload",
        filePath: file.url,
        name: "file",
        formData: { user: "test" },
        success(res) {
          // 上传完成需要更新 fileList
          let data = JSON.parse(res.data);
          that.fileList.push({
            imgUrl: "/FileController/download/" + data.data[0],
            id: data.data[0],
            url:
                that.$constant.BASE_URI +
                "/FileController/download/" +
                data.data[0],
            isImage: true,
          });
        },
        fail(res) {},
      });
    },
  }
}
</script>

<style lang="scss">
.propertyEditor{
  padding-bottom: 150rpx;
  .detailUl{
    margin-top: 20rpx;
    background: white;
    padding: 24rpx 32rpx;
    .liName{
      font-size: 32rpx;
      color: rgba(51, 51, 51, 1);
      white-space: nowrap;
      .callNumber{
        color: rgba(24, 23, 42, 1);
        font-size: 36rpx;
        font-weight: 600;
      }
      .callName{
        color: rgba(102, 102, 102, 1);
        font-size: 28rpx;
      }
    }
    .phoneIcon{
      width: 64rpx;
      height: 64rpx;
    }
    .detailLi{
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 32rpx 0;
      border-bottom: 2rpx solid #E6E6E6;
      .liInfo{
        display: inline-block;
        text-align: right;
        max-width: 428rpx;
        color: rgba(102, 102, 102, 1);
        font-size: 32rpx;
        line-height: 38rpx;
        overflow: hidden;
        word-wrap: break-word;
      }
      .inputBox{
        display: flex;
        align-items: center;
      }
      .myIpt{
        text-align: right;
        margin-right: 20rpx;
        color: rgba(102, 102, 102, 1);
      }
    }
    .detailLi2{
      display: flex;
      flex-direction: column;
      padding: 32rpx 0;
      border-bottom: 2rpx solid #E6E6E6;
      .detailLi2BoxTop{
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        margin: 12rpx 0;
        .checkItem{
          width: 128rpx;
          height: 64rpx;
          font-size: 28rpx;
          color: #666666;
          display: flex;
          align-items: center;
          justify-content: center;
          background: #F5F7FA;
          border-radius: 8rpx;
          margin: 12rpx 0;
        }
        .checked{
          background: #0365F9;
          color: white;
        }
      }
      .locationBox{
        position: absolute;
        right: 24rpx;
        top: 100rpx;
      }
      .van-cell {
        background: #F5F7FA !important;
        border-radius: 8rpx;
        font-size: 28rpx;
        margin-top: 16rpx;
      }
    }
  }
  .commitBtn{
    width: 654rpx;
    height: 96rpx;
    background: rgba(3, 101, 249, 1);
    margin: 64rpx 48rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36rpx;
    color: white;
  }
}
</style>
