<template>
  <ul class="nav nav-tabs" v-if="!tabConfig">
    <li role="presentation" class="active"><a href="#">调压箱信息</a></li>
  </ul>
  <ul class="nav nav-tabs" v-if="tabConfig">
    <li :class="{ active: activeTab === 0 }" @click="setActiveTab(0)">
      <a href="#">可选择用户</a>
    </li>
    <li :class="{ active: activeTab === 1 }" @click="setActiveTab(1)">
      <a href="#">调压箱内的用户</a>
    </li>
    <li>
      <button class="button_search button_spacing " @click="cancel()">返回</button>
    </li>

  </ul>
  <!-- 新增调压箱组件开始-->
  <div class="auto select-overspread" id="addBox" v-if="activeTab === 0">
    <validator name='v' v-if="activeTab === 0">
      <form class="form-horizontal" style="margin-top:20px;flex: 1;" v-if="tabConfig === false">
        <div class="row">
          <div class="col-sm-4" :class="[$v.f_adjustable_id.required ? 'has-error' : '']">
            <label for="f_adjustable_id" class="font_normal_body">&nbsp;&nbsp;&nbsp;编号&nbsp;&nbsp;&nbsp;</label>
            <input type="text" v-model="model.f_adjustable_id" @blur="changeid()"
                   v-validate:f_adjustable_id='{required: true }' class="input_search" style="width:60%"
                   placeholder="编号" v-next-el="name">
          </div>

          <div class="col-sm-4"
               :class="[$v.f_adjustable_name.required ? 'has-error' : '']">
            <label for="f_adjustable_name" class="font_normal_body">&nbsp;&nbsp;&nbsp;名称&nbsp;&nbsp;&nbsp;</label>
            <input type="text" v-model="model.f_adjustable_name" @blur="changename()"
                   v-validate:f_adjustable_name="{required: true }"
                   class="input_search" style="width:60%"
                   placeholder="名称" v-el:name v-next-el="address">
          </div>

          <div class="col-sm-4 "
               :class="[$v.adjustable_type.required ? 'select-error' : '']">
            <label for="f_adjustable_type" class="font_normal_body">装置类型</label>
            <input type="text" v-show="false" v-model="$refs.adjustable_type.selectedItems"
                   v-validate:adjustable_type='{required: true }'>
            <v-select :value.sync="model.f_adjustable_type" :options='adjustabletype' placeholder='装置类型'
                      close-on-select
                      v-model='model.f_adjustable_type' style="width: 60%" v-ref:adjustable_type></v-select>
          </div>
        </div>
        <div class="row">
          <div class="col-sm-12"
               :class="[$v.f_adjustable_address.required ? 'has-error' : '']">
            <label for="f_adjustable_address" class="font_normal_body">&nbsp;&nbsp;&nbsp;地址&nbsp;&nbsp;&nbsp;</label>
            <input type="text" v-model="model.f_adjustable_address" v-validate:f_adjustable_address='{required: true }'
                   class="input_search" style="width:85%" placeholder="地址" v-el:type v-next-el="street">
          </div>
        </div>
        <div class="row" style="color:red;text-align:center ">
          <div class="col-sm-4  ">
            <span v-if="haveid === true">编号重复</span>
          </div>
          <div class="col-sm-4  ">
            <span v-if="havename === true">名称重复</span>
          </div>
        </div>
        <div class="row">
          <div class="col-sm-4 "
               :class="[$v.f_adjustable_style.required ? 'has-error' : '']">
            <label for="f_adjustable_style" class="font_normal_body">&nbsp;&nbsp;&nbsp;型号&nbsp;&nbsp;&nbsp;</label>
            <input type="text" v-model="model.f_adjustable_style" v-validate:f_adjustable_style='{required: true }'
                   class="input_search" style="width:60%" placeholder="调压箱型号">
          </div>
          <div class="col-sm-4 ">
            <label for="f_in_pipe" class="font_normal_body">进口压力</label>
            <input type="text" v-model="model.f_in_pipe"
                   class="input_search" style="width:60%" placeholder="进口压力" v-el:inpipe v-next-el="outpipe">
          </div>
          <div class="col-sm-4 ">
            <label for="f_out_pipe" class="font_normal_body">出口压力</label>
            <input type="text" v-model="model.f_out_pipe" class="input_search" style="width:60%" placeholder="出口压力"
                   v-el:outpipe v-next-el="date">
          </div>
        </div>
        <div class="row">
          <div class="col-sm-4 ">
            <label for="f_operate_date" class="font_normal_body">安装日期</label>
            <datepicker placeholder="安装日期" style="width: 60%"
                        v-model="model.f_operate_date"
                        :value.sync="model.f_operate_date"
                        :format="'yyyy-MM-dd HH:mm:ss'"
                        v-el:date :disabled="!changedate"
                        v-next-el="openDate"
            >
            </datepicker>
          </div>
          <div class="col-sm-4 " :class="[$v.facturer.required ? 'has-error' : '']">
            <label for="f_manufacturer" class="font_normal_body">生产厂家</label>
            <input type="text" v-model="model.f_manufacturer" class="input_search" style="width:60%"
                   placeholder="生产厂家"
                   v-validate:facturer='{required: true }'>
          </div>
          <div class="col-sm-4 ">
            <label for="f_open_date" class="font_normal_body">启用日期</label>
            <datepicker placeholder="启用日期" style="width: 60%"
                        v-model="model.f_open_date"
                        :value.sync="model.f_open_date"
                        :format="'yyyy-MM-dd HH:mm:ss'"
                        v-el:openDate
                        v-next-el="remark">
            </datepicker>
          </div>
        </div>
        <div class="row">
          <div class="col-sm-12">
            <label for="f_remark" class="font_normal_body">&nbsp;&nbsp;&nbsp;备注&nbsp;&nbsp;&nbsp;</label>
            <textarea class="form-control" v-model="model.f_remark" rows="3" placeholder="备注" style="width:85%"
                      v-el:remark></textarea>
          </div>
        </div>
      </form>
      <div class="row auto" v-if="tabConfig === false">
        <div class="col-sm-12 form-group" :class="[$v.f_address.required ? 'has-error' : '']">
          <label for="f_address" class="font_normal_body">管理范围</label>
          <span>
              <button class="btn btn-info" type="button" style="width: max-content" v-if="!isedit"
                      @click="selectaddress()">选择地址</button>
            </span>
        </div>
      </div>
      <div style="margin-top:10px;margin-left: 20px" class="col-sm-12 form-group auto" v-for="row in areas"
           v-if="tabConfig === false">
        <div class="col-sm-12">
          <label for="f_manufacturer" class="font_normal_body">地址信息</label>
          <input type="text" v-model="row.f_adjustable_address" class="input_search" style="width:60%"
                 placeholder="立管编号" v-el:outpipe>
          <button type="button" class="glyphicon glyphicon-minus btn-danger" style="margin-top:8px;margin-left:10px"
                  @click.stop="delarr($index,row)"></button>
        </div>
      </div>
      <div class="col-sm-12 auto" v-for="row in riser"
           v-if="tabConfig === false">
        <div class="col-sm-6">
          <label for="f_manufacturer" class="font_normal_body">立管编号</label>
          <input type="text" v-model="row.f_value" class="input_search" style="width:60%" placeholder="立管编号"
                 v-el:outpipe>
          <button type="button" class="glyphicon glyphicon-minus btn-danger" style="margin-top:8px;margin-left:10px"
                  @click.stop="delriser($index,row)"></button>
          <button type="button" class="glyphicon glyphicon-plus btn-success" style="margin-top:8px;margin-left:10px"
                  @click.stop="addriser()"></button>
        </div>
      </div>
      <div style="text-align:right;height:auto;margin-top:30px;margin-right:50px;" v-if="tabConfig === false">
        <button class="button_search button_spacing" @click="confirm()" :disabled='!$v.valid '>保存</button>
        <button class="button_new button_spacing" @click="cancel()">取消</button>
      </div>
    </validator>
    <modal v-if="showselectaddress"
           :show.sync="showselectaddress"
           width="80%" title="地址信息"
           v-ref:modal large
           backdrop="false">
      <article slot="modal-body" class="modal-body" style="height: 700px;padding: 0!important;">
        <box-file-address-manage :f_filialeids="f_filialeids"
                                 :is-select="isSelect"
                                 :fileinfo="addressinfo"
                                 @address-valid="doNothing"
                                 :showselectaddress.sync="showselectaddress"
                                 v-ref:fileaddress></box-file-address-manage>
      </article>
      <footer slot="modal-footer" class="modal-footer">
        <button type="button" class="button_new button_spacing" @click='closeAddress()'>取消</button>
        <button type="button" class="button_search button_spacing" @click='confirmAddress()'>确认</button>
      </footer>
    </modal>
  </div>
  <!-- 新增调压箱组件结束-->
  <!--可选择用户组件开始-->
  <div v-if="tabConfig === true && activeTab === 0">
    <div id="boxlist" class="flex" style="flex:1; ">
      <criteria-paged :model="users" v-ref:paged>
        <criteria partial='criteria' @condition-changed='$parent.conditionSearch()' v-ref:cri>
          <div novalidate class="form-horizontal  select-overspread auto" partial>
            <div class="row">
              <div class="col-sm-4 form-group">
                <label class="font_normal_body">客户编号</label>
                <input type="text" class="input_search" v-model="model.f_userinfo_code"
                       condition="f_userinfo_code like '%{}%'" style="width:60%" placeholder='客户编号'>
              </div>
              <div class="col-sm-4 form-group">
                <label class="font_normal_body">客户名称</label>
                <input type="text" class="input_search" v-model="model.f_user_name"
                       condition="f_user_name like '%{}%'" style="width:60%" placeholder='客户名称'>
              </div>
              <div class="col-sm-4 form-group">
                <label class="font_normal_body">详细地址</label>
                <input type="text" class="input_search" v-model="model.f_address"
                       condition="address.f_address like '%{}%'" style="width:60%" placeholder='详细地址'>
              </div>
              <div class="col-sm-4 form-group">
                <label class="font_normal_body">小&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;区</label>
                <input type="text" class="input_search" v-model="model.f_residential_area"
                       condition="address.f_residential_area like '%{}%'" style="width:60%" placeholder='小区'>
              </div>
              <div class="col-sm-4 form-group">
                <label class="font_normal_body">楼&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号</label>
                <input type="text" class="input_search" v-model="model.f_building"
                       condition="address.f_building like '%{}%'" style="width:60%" placeholder='楼号'>
              </div>
              <div class="col-sm-4 form-group">
                <label class="font_normal_body">单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;元</label>
                <input type="text" class="input_search" v-model="model.f_unit"
                       condition="address.f_unit like '%{}%'" style="width:60%" placeholder='单元'>
              </div>
              <div class="col-sm-4 form-group">
                <label class="font_normal_body">楼&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;层</label>
                <input type="text" class="input_search" v-model="model.f_floor"
                       condition="address.f_floor like '%{}%'" style="width:60%" placeholder='楼层'>
              </div>
              <div class="col-sm-4 form-group">
                <label class="font_normal_body">门&nbsp;&nbsp;牌&nbsp;&nbsp;号</label>
                <input type="text" class="input_search" v-model="model.f_room"
                       condition="address.f_room like '%{}%'" style="width:60%" placeholder='门牌号'>
              </div>
              <div class="col-sm-4 form-group">
                <label class="font_normal_body">绑定状态</label>
                <v-select :options='$parent.$parent.stat' v-model="model.f_adjustable_id" :value.sync="model.f_adjustable_id"
                          condition="files.f_adjustable_id is {}" placeholder='绑定状态' close-on-select>
                </v-select>
              </div>

              <div class="span" style="float:right;">
                <button class="button_search button_spacing" type="button" style="width: max-content;margin-left: auto;"
                        @click="search">查询
                </button>
                <button class="button_new button_spacing" type="button" style="width: max-content;margin-left: auto;"
                        @click="$parent.$parent.clear()">清除
                </button>
                <button class="button_search button_spacing" type="button" style="width: max-content;margin-left: auto;"
                        @click="$parent.$parent.insAll">移入所选
                </button>
              </div>
            </div>
          </div>
        </criteria>
        <data-grid :model="$parent.users" partial='list' class="list_area table_sy" v-ref:grid>
          <template partial='head'>
            <tr>
              <th>
                <input type="checkbox" id="checked" @click.stop="$parent.$parent.$parent.selectAllSelect"></input>
              </th>
              <th>序号</th>
              <th>用户编号</th>
              <th>用户名称</th>
              <th>小区</th>
              <th>楼号</th>
              <th>单元</th>
              <th>楼层</th>
              <th>门牌号</th>
              <th>详细地址</th>
              <th>绑定状态</th>
              <th>操作</th>
            </tr>
          </template>
          <template partial='body'>
            <td>
              <input type="checkbox" class="check"></input>
            </td>
            <td style="text-align: center;">{{ $index + 1 }}</td>
            <td>{{ row.f_userinfo_code }}</td>
            <td v-show="false">{{ row.f_userinfo_id }}</td>
            <td>{{ row.f_user_name }}</td>
            <td>{{ row.f_residential_area }}</td>
            <td>{{ row.f_building }}</td>
            <td>{{ row.f_unit }}</td>
            <td>{{ row.f_floor }}</td>
            <td>{{ row.f_room }}</td>
            <td>{{ row.f_address }}</td>
            <td>{{ row.f_adjustable_id !== null ? '已绑定' : '未绑定' }}</td>
            <td style="text-align:center">
              <button class="btn btn-link " type="button" style="width: max-content"
                      @click="$parent.$parent.$parent.insOne(row.f_userinfo_id)">移入
              </button>
            </td>
          </template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
  <!--可选择用户组件结束-->

</template>
<script>

import {HttpResetClass, PagedList} from 'vue-client'

export default {
  data () {
    return {
      users: new PagedList('rs/sql/optionalAdjustBoxUsers', 20),
      tabs: ['调压箱信息', '调压箱信息'], // 选项卡标题
      stat: [{label: '已绑定', value: 'not null'}, {label: '未绑定', value: 'null'}],
      activeTab: 0, // 默认第一个选项卡激活
      tabConfig: this.tabconfig,
      isshow: false,
      tempPosition: {
        position: { // 经纬度信息
          lng: 0, // 经度
          lat: 0  // 纬度
        },
        formattedAddress: '' // 地址信息
      },
      model: {
        f_adjustable_id: '',
        f_adjustable_name: '',
        f_adjustable_address: '',
        f_adjustable_type: '',
        f_adjustable_style: '',
        f_in_pipe: '',
        f_out_pipe: '',
        f_operate_date: '',
        f_open_date: '',
        f_manufacturer: '',
        f_remark: '',
        f_adjustable_lng: '', // 经度
        f_adjustable_lat: ''  // 纬度
      },
      riser: [{}],
      areas: [],
      showselectaddress: false,
      f_filialeids: null,
      delrow: [],
      delarrdata: [],
      haveid: false,
      havename: false,
      changedate: true,
      adjustabletype: this.$appdata.getParam('装置类型'),
      manufacturer: this.$appdata.getParam('生产厂家'),
      mapShow: true
    }
  },
  props: ['data', 'tabconfig'],
  watch: {
    'data' (val) {
      this.datatomodel()
      this.users.search(`1=1`)
    }
  },
  ready () {
    this.setActiveTab(0)
    this.users.search(`1=1`)
    console.log('tab--------------->', this.tabConfig)
    if (this.tabconfig === true) {
      this.$emit('sendindex', 0)
    }
    console.log(this.$login.f)
    this.f_filialeids = this.$login.f.orgid
    try {
      var map = new AMap.Map('container')
    } catch (e) {
      this.mapShow = false
    }
    console.log(this.$login.toStandardTimeString())
    this.datatomodel()
  },
  methods: {
    clear () {
      console.log('clear')
      Object.keys(this.$refs.paged.$refs.cri.model).forEach((key) => {
        this.$refs.paged.$refs.cri.model[key] = []
      })
    },
    conditionSearch () {
      console.log('条件查询触发')
      console.log(this.$refs.paged.$refs.cri.condition)
      this.users.search(`${this.$refs.paged.$refs.cri.condition} and 1=1`)
    },
    refresh () {
      this.$parent.$refs.list.$refs.paged.$refs.cri.search()
    },
    selectAllSelect () {
      console.log('执行')
      const checkboxes = document.querySelectorAll('.check')
      checkboxes.forEach(checkbox => {
        checkbox.checked = event.target.checked
      })
    },
    clearSelect () {
      const checkboxes = document.querySelectorAll('.check')
      checkboxes.forEach(checkbox => {
        checkbox.checked = false
      })
    },
    clearChecked () {
      const checkboxes = document.querySelectorAll('#checked')
      checkboxes.forEach(checkbox => {
        checkbox.checked = false
      })
    },
    insUser (f_userinfo_id) {
      console.log('移入------->', f_userinfo_id)
      let sql = `UPDATE t_userfiles
                 SET f_adjustable_id = ${this.data.id}
                 WHERE f_userinfo_id = ${f_userinfo_id}`
      console.log(sql)
      this.$resetpost('/rs/logic/runSQL', {data: {sql: sql}}).then(
        (res) => {
          this.users.search(`1=1`)
        }
      )
    },
    insOne (f_userinfo_id) {
      console.log('权限相关', this.$login)
      this.$showMessage('确认移入此用户？', ['confirm', 'cancel']).then(
        (response) => {
          if (response === 'confirm') {
            this.insUser(f_userinfo_id)
            this.refresh()
          }
        })
    },
    insAll () {
      this.$showMessage('确认移入所选？', ['confirm', 'cancel']).then(
        (response) => {
          if (response === 'confirm') {
            const checkboxes = document.querySelectorAll('.check:checked')
            const selectedUserinfoIds = []
            checkboxes.forEach(checkbox => {
              const userinfoId = checkbox.parentElement.nextElementSibling.nextElementSibling.nextElementSibling.textContent
              selectedUserinfoIds.push(userinfoId)
            })
            console.log('ids-------->', selectedUserinfoIds)
            if (selectedUserinfoIds.length === 0) {
              this.$showMessage('所选为空')
              return
            }
            // 发送selectedUserinfoIds到后台处理
            this.$resetpost('/rs/logic/addAdjustBoxUsers', {
              data: {
                ids: selectedUserinfoIds,
                f_adjustable_id: this.data.id
              }
            }).then(
              (res) => {
                console.log(res)
                this.users.search(`1=1`)
                this.clearSelect()
                this.clearChecked()
                this.refresh()
              }
            )
          }
        })
    },
    search () {
      this.$refs.paged.$refs.cri.search()
    },
    setActiveTab (index) {
      this.$emit('sendindex', index)
      console.log('-------------->开始传index', index)

      this.activeTab = index // 设置激活的选项卡索引
      this.users.search(`1=1`)
    },
    selectaddress () {
      this.showselectaddress = true
    },
    closeAddress () {
      this.showselectaddress = false
    },
    confirmAddress () {
      console.log(this.$refs.fileaddress.$refs.addresslist.rows)
      if (this.areas.length > 0) {
        let arr = this.$refs.fileaddress.$refs.addresslist.rows
        for (let i = 0; i < arr.length; i++) {
          this.areas.push(arr[i])
        }
      } else {
        this.areas = this.$refs.fileaddress.$refs.addresslist.rows
      }
      this.showselectaddress = false
    },
    async confirm () {
      this.model.f_adjustable_id = `${this.model.f_adjustable_id}`
      this.model.f_adjustable_state = '正常'
      this.model.f_adjustable_type = this.model.f_adjustable_type[0] ? this.model.f_adjustable_type[0] : ''
      this.model.f_manufacturer = this.model.f_manufacturer

      this.model.f_operator = this.$login.f.name
      this.model.f_operatorid = this.$login.f.id
      this.model.f_orgid = this.$login.f.orgid
      this.model.f_filialeid = this.$login.f.orgid
      this.model.f_orgname = this.$login.f.orgs
      this.model.f_depid = this.$login.f.depids
      this.model.f_depname = this.$login.f.deps
      let attibute = []
      for (var i = 0; i < this.riser.length; i++) {
        var params = {
          id: this.riser[i].id,
          f_table_name: `t_adjustablebox`,
          f_field_name: 'id',
          f_value: this.riser[i].f_value,
          f_chinese_name: '立管编号',
          f_operator: this.$login.f.name,
          f_operatorid: this.$login.f.id,
          f_orgid: this.$login.f.orgid,
          f_orgname: this.$login.f.orgs
        }
        attibute.push(params)
      }
      let http = new HttpResetClass()
      let res = await http.load('post', `rs/logic/saveAdjustBoxNew`, {
        data: {
          model: this.model,
          attibute: attibute,
          areas: this.areas
        }
      }, {resolveMsg: '调压箱保存成功', rejectMsg: '保存失败!!!'})
      if (this.riser[0]) {

      }
      if (this.delrow.length > 0) {
        for (var i = 0; i < this.delrow.length; i++) {
          await this.$resetdelete('rs/entity/t_attribute', {id: this.delrow[i]}, {
            warnMsg: null,
            resolveMsg: null,
            rejectMsg: null
          })
        }
      }
      if (this.delarrdata.length > 0) {
        await this.$resetpost('rs/logic/deleteAdjustArea', {data: {area: this.delarrdata}}, {
          warnMsg: null,
          resolveMsg: null,
          rejectMsg: null
        })
      }
      this.$dispatch('success', '调压箱保存成功', this.model, res)
      this.riser = [{}]
      this.areas = []
      this.model = {
        f_adjustable_id: '',
        f_adjustable_name: '',
        f_adjustable_address: '',
        f_adjustable_type: '',
        f_adjustable_style: '',
        f_in_pipe: '',
        f_out_pipe: '',
        f_operate_date: '',
        f_open_date: '',
        f_manufacturer: '',
        f_remark: '',
        f_adjustable_lng: '', // 经度
        f_adjustable_lat: ''  // 纬度
      },
        this.delrow = []
    },
    delarr (index, row) {
      if (index !== -1) {
        this.areas.splice(index, 1)
      }
      if (row.id) {
        this.delarrdata.push(row.id)
      }
    },
    delriser (index, row) {
      if (this.riser.length > 1) {
        this.riser.splice(index, 1)
        if (row.id) {
          this.delrow.push(row.id)
        }
      }
    },
    addriser () {
      this.riser.push({})
    },
    async datatomodel () {
      console.log('data-------->', this.data)
      this.delrow = []
      this.$nextTick(() => {
        if (JSON.stringify(this.data) === '{}') {
          Object.assign(this.$data.model, this.$options.data().model)
          delete this.model.id
          this.model.f_in_pipe = 'MPa'
          this.model.f_out_pipe = 'KPa'
          this.changedate = true
          this.model.f_operate_date = this.$login.toStandardTimeString()
          this.model.f_open_date = this.$login.toStandardTimeString()
        } else {
          this.model = Object.assign(this.model, {}, this.data)
          this.model.f_adjustable_type = this.model.f_adjustable_type ? [this.model.f_adjustable_type] : ''
          this.model.f_manufacturer = this.model.f_manufacturer ? [this.model.f_manufacturer] : ''
          // this.model.f_adjustable_style = this.model.f_adjustable_style ? [this.model.f_adjustable_style] : ''
          this.model.f_operate_date ? this.changedate = false : this.changedate = true
        }
      })
      if (this.data.id) {
        var data = await this.$resetpost('rs/sql/saleSingleTable', {
          data: {
            tablename: 't_attribute',
            condition: `f_table_name = 't_adjustablebox' and f_parent_id = '${this.data.id}' and f_chinese_name ='立管编号'`
          }
        }, {resolveMsg: null, rejectMsg: '获取调压箱失败'})
        this.riser = data.data
        let param = {
          tablename: 't_adjustable_area',
          item: 'f_adjustable_address',
          condition: `f_adjustable_id = '${this.data.id}'`
        }
        var address = await this.$resetpost('rs/sql/saleSingleTable', {data: param}, {
          resolveMsg: null,
          rejectMsg: '获取调压箱失败'
        })
        this.areas = address.data
      }

      if (this.riser.length === 0) {
        this.riser = [{}]
      }
    },
    cancel () {
      this.$dispatch('close')
      this.setActiveTab(0)
    },
    modify () {
      this.model = Object.assign({}, this.gasmessage)
      this.model.f_meter_type = this.model.f_meter_type[0]
      this.getArrParam()
      this.transfer()
      this.data = {}
    },
    changeid () {
      this.$resetpost('rs/sql/saleSingleTable', {
        data: {
          tablename: 't_adjustablebox',
          condition: `f_adjustable_id = '${this.model.f_adjustable_id}' and f_orgid = '${this.$login.f.orgid}'`
        }
      }, {resolveMsg: null, rejectMsg: null})
        .then((res) => {
          res.data.length > 0 ? this.haveid = true : this.haveid = false
        })
    },
    changename () {
      this.$resetpost('rs/sql/saleSingleTable', {
        data: {
          tablename: 't_adjustablebox',
          condition: `f_adjustable_name = '${this.model.f_adjustable_name}' and f_orgid = '${this.$login.f.orgid}'`
        }
      }, {resolveMsg: null, rejectMsg: null})
        .then((res) => {
          res.data.length > 0 ? this.havename = true : this.havename = false
        })
    },
    openModal () {
      this.isshow = true
    },
    closeModal () {
      this.isshow = false
    },
    getmylocation (res) {
      this.tempPosition = res
    },
    confirmLocation () {
      this.model.f_adjustable_address = this.tempPosition.formattedAddress
      this.model.f_adjustable_lng = this.tempPosition.position.lng
      this.model.f_adjustable_lat = this.tempPosition.position.lat
      this.isshow = false
    }
  }
}
</script>
<style lang="less">
#addBox {
  #addboxmap {
    height: 300px;
  }

  .glyphicon:hover {
    color: red;
  }
  .glyphicon {
    color: blue;
    cursor: pointer;
  }
}
</style>
