// 小区列表
<template>
  <div class="routerWapper">
    <!-- {{checkedKeys}} -->
    <div class="layoutMargin layoutPadding">
    <a-row>
        <a-col :span="4" style="height:100%; position:relative;" v-if="leftPanelShow">
          <span style="display: block; width: 90%; color:#1890ff; font-size: 16px; font-weight: 500; padding-bottom:5px; border-bottom:1px solid #1890ff;">
            标签筛选条件
          </span>
          <a-tree
            @check='onCheck'                
            checkable
            :tree-data="treeData"
            :replace-fields="replaceFields"
          />
        </a-col>

        <a-button v-if="!leftPanelShow" @click="showNHide" type='link' icon='right' style="position: absolute; left: -2%; top: 14%; color: grey"/>
        <a-button v-else @click="showNHide" type='link' icon='left' style="position: absolute; left: 14.5%; top: 14%; color: grey"/>

        <a-col :span="!!leftPanelShow ? 20 : 24" :style="!!leftPanelShow? `padding-left: 10px; border-left:1px solid #ccc;`:`padding-left: 10px;`">
        <!-- <p class="gayLine noline" /> -->
          <div class="portalTableOperates">
            <a-button type='primary' @click="searchXXXByLabel">查询</a-button>
            <a-tabs :default-active-key="tbl" @change="changeTbl">
              <a-tab-pane key="tbl_community" tab="小区">
                <TAM ref="childTab" :tableData="tableData_sect" :pagination="pagination" :tbl="tbl" />
              </a-tab-pane>
              <a-tab-pane key="tbl_building" tab="门牌">
                <TAM ref="childTab" :tableData="tableData_mpz" :pagination="pagination" :tbl="tbl" />
              </a-tab-pane>
              <a-tab-pane key="tbl_prop_company" tab="物业">
                <TAM ref="childTab" :tableData="tableData_wy" :pagination="pagination" :tbl="tbl" />
              </a-tab-pane>
              <a-tab-pane key="tbl_industry_council" tab="业委会">
                <TAM ref="childTab" :tableData="tableData_ywh" :pagination="pagination" :tbl="tbl" />
              </a-tab-pane>
            </a-tabs>
          </div>
        <!-- </div> -->
        <!-- <RouterWapper v-else></RouterWapper> -->
        </a-col>
    </a-row>
    </div>
  </div>
</template>

<script>
import TAM from '@/views/components/tableAndMutWithoutMulSel.vue'
const treeData = []
export default {
  name: 'basicInfo',
  components: {
    TAM
  },
  data() {
    return {
      treeData,
      tbl: 'tbl_community', 
      selectedKeys: [],
      replaceFields: {
        children: 'children',
        title: 'labelName',
        key: 'id'
      },
      checkedKeys: [],
      simpleSearchForm: true, // 展示、收取简单搜索开关，true为简单搜索

      levelType: [
        {
          name: '高层',
          key: '1'
        },
        {
          name: '多层',
          key: '2'
        },
        {
          name: '别墅',
          key: '3'
        },
      ],
      leftPanelShow: true,
      finishDate: [
        {
          name: '2000年以前',
          key: '1'
        },
        {
          name: '2000年以后',
          key: '2'
        },
      ],
      neighbourType: [
        {
          name: '未成立',
          key: '1'
        },
        {
          name: '已成立',
          key: '2'
        },
        {
          name: '前期筹备中',
          key: '3'
        },
      ],
      wuyeServiceType: [
        {
          name: '专业委托物业管理（前期阶段）',
          key: '1'
        },
        {
          name: '专业委托物业管理（业主大会阶段）',
          key: '2'
        },
        {
          name: '无人管理',
          key: '3'
        },
        {
          name: '自治管理',
          key: '4'
        },
        {
          name: '直管物业（公房）',
          key: '5'
        },
        {
          name: '单位自管（公房）',
          key: '6'
        },
      ],
      customKeyEnable: false, // cookie里存的是否开启自定义字段
      typeList: [ //小区性质的数据
        {
          name: '商品房',
          key: '01'
        },
        {
          name: '动迁房',
          key: '02'
        },
        {
          name: '共有产权保障房',
          key: '03'
        },
        {
          name: '售后房',
          key: '04'
        },
        {
          name: '直管公房',
          key: '05'
        },
        {
          name: '混合',
          key: '06'
        },
        {
          name: '系统公房',
          key: '07'
        },
        {
          name: '集体土地集资房',
          key: '08'
        },
        {
          name: '军产',
          key: '09'
        },
        {
          name: '私产',
          key: '10'
        },
        {
          name: '公租房',
          key: '11'
        },

      ],
      searchList: [], // 动态渲染的搜索列表
      keyCodeList: [], // 动态搜索的keycode列表
      searchParams: {}, // 搜索的列表
      searchForm: {},
      street: [], // 街道数据
      hos: [], // 房办数据
      wuye: [], // 物业数据
      columns: [ //表格展示的列
        {
          title: '小区名称',
          dataIndex: 'stNameFrst',
          key: 'stNameFrst'
        },
        {
          title: '小区地址',
          dataIndex: 'addrFrst',
          key: 'addrFrst'
        }, {
          title: '房管办',
          dataIndex: 'hoName',
          key: 'hoName'
        },
        {
          title: '街道',
          dataIndex: 'strName',
          key: 'strName'
        },
        {
          title: '小区性质',
          dataIndex: 'stKind',
          key: 'stKind'
        }, {
          title: '小区类型',
          dataIndex: 'sectType',
          key: 'sectType'
        }, {
          title: '物业服务企业',
          dataIndex: 'cspName',
          key: 'cspName'
        }, {
          title: '小区管理处',
          dataIndex: 'csName',
          key: 'csName'
        },
        {
          title: '是否成立业主大会',
          dataIndex: 'hocId',
          key: 'hocId'
        },
        {
          title: '操作',
          dataIndex: 'action',
          width: 160,
          scopedSlots: {
            customRender: 'action'
          }
        }
      ],
      pagination: { // 分页信息
        pageNo: 1,
        pageSize: 20,
        current: 1,
        defaultCurrent: 1,
        defaultPageSize: 20,
        showQuickJumper: true,
        onChange: this.pageChange,
        showSizeChanger: true,
        onShowSizeChange: this.showSizeChange,
        pageSizeOptions: ['10', '20', '50', '100'],
        total: 0, // 小区总数
        showTotal: total => `总条数: ${total}`,
        totStCnstArea: '', // 房屋总面积 平方米
        totUnits: '', // 总门牌数  幢
        totHous: '', // 总分户数   户
      },
      tableData_sect: [],
      tableData_mpz: [],
      tableData_wy: [],
      tableData_ywh: [],
      stLevel: '',
      cspServiceType: '',
      tableName: '', // 邻里小汇
      formed: '', // 邻里小汇
      type: '', // 邻里小汇
      isBeforeTwoThousand: '',
      twoThousandValue: '',
      personalizedKey: ''
    }
  },
  beforeCreate() { // 页面进来创建form
    this.form = this.$form.createForm(this)
  },
  computed: {
    formItemLabelCol() {
      let labelCol = {}
      if (this.simpleSearchForm) {
        labelCol = { span: 0 }
      } else {
        labelCol = { span: 8 }
      }
      return labelCol
    },
    formItemWrapperCol() {
      let wrapperCol = {}
      if (this.simpleSearchForm) {
        wrapperCol = { span: 24 }
      } else {
        wrapperCol = { span: 16 }
      }
      return wrapperCol
    }
  },
  created () { // 进页面获取数据
    this.customKeyEnable=this.$cookie.get('customKeyEnable')
    this.getHos()
    this.getWy()
    this.getStreet()
  },
  mounted(){
    console.log(this.$api.BASE_URL.indexOf('211.136.105')!=-1 )

    if(this.$route.name == 'basicInfoByLabel'){
      this.$nextTick(function () {
        this.getLabelList()
      })
    }
  },
  methods: {
    changeTbl(tbl) {
      this.tbl = tbl
      if(this.checkedKeys.length > 0) {
        this.$ajax.get({
          url: this.$api.GET_ID_INFO_BY_LABEL,
          params: {
            tableName: this.tbl,
            labelId_in: this.checkedKeys.toString()
          }
        }).then(res => {
          let keyType = ''
          if (res.code == 200) {
            switch (this.tbl) {
            case 'tbl_community':
              if(res.data.content.sectId_in == '') {
                this.clearAllTableData()
              } else {
                this.getListSect(res.data.content)
              }
              break

            case 'tbl_building':
              if(res.data.content.unit_in == '') {
                this.clearAllTableData()
              } else {
                this.getListMpz(res.data.content)
              }
              break

            case 'tbl_prop_company': 
              if(res.data.content.cspId_in == '') {
                this.clearAllTableData()
              } else {
                this.getListWy(res.data.content)
              }
              break

            case 'tbl_industry_council': 
              if(res.data.content.hocId_in == '') {
                this.clearAllTableData()
              } else {
                this.getListYwh(res.data.content)
              }
              break
            
            default:
              break
            }
          }
        })
      } else {
        this.clearAllTableData()
      }
    },
    clearAllTableData() {
      this.tableData_sect = []
      this.tableData_mpz = []
      this.tableData_wy = []
      this.tableData_ywh = []
    },
    searchXXXByLabel() {

      if(this.checkedKeys.length > 0) {
        this.$ajax.get({
          url: this.$api.GET_ID_INFO_BY_LABEL,
          params: {
            tableName: this.tbl,
            labelId_in: this.checkedKeys.toString()
          }
        }).then(res => {
          let keyType = ''
          if (res.code == 200) {
            switch (this.tbl) {
            case 'tbl_community':
              if(res.data.content.sectId_in == '') {
                this.clearAllTableData()
              } else {
                this.getListSect(res.data.content)
              }
              break

            case 'tbl_building':
              if(res.data.content.unit_in == '') {
                this.clearAllTableData()
              } else {
                this.getListMpz(res.data.content)
              }
              break

            case 'tbl_prop_company': 
              if(res.data.content.cspId_in == '') {
                this.clearAllTableData()
              } else {
                this.getListWy(res.data.content)
              }
              break

            case 'tbl_industry_council': 
              if(res.data.content.hocId_in == '') {
                this.clearAllTableData()
              } else {
                this.getListYwh(res.data.content)
              }
              break
            
            default:
              break
            }
          }
        })
      } else {
        this.clearAllTableData()
      }
    },
    onCheck(keys, node) {
      // console.log(keys, node.node.$children.length)
      // this.checkedKeys = []
      for(let i = 0; i < keys.length; i++) {
        console.log(keys[i])
        this.checkedKeys.push(keys[i])
      }

      // cf
      
    },
    getLabelList() {
      this.$ajax.get({
        url: this.$api.GET_LABEL_LIST,
      }).then(res => {
        if (res.code == 200) {
          this.treeData = this.$com.confirm(res, 'data.content', [])
          console.log(JSON.stringify(this.treeData))
        }
      })
    },
    showNHide() {
      this.leftPanelShow = !this.leftPanelShow
    },
    onSelect(selectedKeys, node) {
      console.log(selectedKeys, node.node.$children.length)
    },
    getConfig() {
      this.$ajax.get({
        url: this.$api.GET_CONFIG,
      }).then(res => {
        if (res.code === '200') {
          let inner = res.data.content
          this.personalizedKey = inner.formedKey
        }
      })
    },
    closeMoreSearch() {
      this.simpleSearchForm = true
    },
    showMoreSearch() {
      this.simpleSearchForm = false
    },
    pageChange(page){ //分页切换
      this.pagination.pageNo = page
      this.pagination.current = page
      this.getList()
    },
    showSizeChange(current, size) { //每页条数切换
      this.pagination.pageNo = 1
      this.pagination.current = 1
      this.pagination.pageSize = size
      this.getList()
    },
    reset(){ // 重置表单
      this.form.resetFields()

      this.stLevel = ''
      this.cspServiceType = ''
      this.type = ''
      this.isBeforeTwoThousand = ''

      this.pagination.pageNo = 1
      this.pagination.current = 1
      this.pagination.pageSize = 20
      this.getList()
    },
    search() { // 搜索按钮
      this.pagination.current = 1
      this.pagination.pageNo = 1
      //需要发送ajax
      this.getList()
    },
    changeWy(value){ // 切换物业
      let query=JSON.parse(JSON.stringify(this.$route.query))
      query={id: '', name: ''}
      this.$router.push({path: '/houseData/basicInfoByLabel', query: query})
      this.form.setFieldsValue({
        'c.cspId': value
      })
      this.search()
    },
    changeStreet(value) { // 切换街道
      this.form.setFieldsValue({
        'c.streetId': value
      })
      this.search()
    },
    changeIsHoc(value) { // 切换是否成立业主大会
      this.form.setFieldsValue({
        'isHoc': value
      })
      this.search()
    },
    changeType(val) { // 切换小区性质
      this.form.setFieldsValue({
        'stKind_in': val
      })
      this.getList()
    },
    handleChangefb(value) { //切换房办
      this.form.setFieldsValue({
        'c.hoId': value
      })
      this.search()
    },
    handleChangeZdy(i, e){ // 自定义字段 - 搜索条件的 change
      if (Object.prototype.toString.call(e)== '[object Array]') {
        e2 = e.join(',')
      } else if (Object.prototype.toString.call(e)== '[object Object]') {
        e2 = this.$moment(e).format('YYYY-MM-DD')
      }
      this.form.setFieldsValue({ // 传入的i 是i.keyCode   将form表单设置成最新的值
        i: e2
      })
      setTimeout(() => { // 延时器,去掉会拿不到最新的value
        this.getList()
      }, 0)
    },
    getListSect(id){ // 获取小区数据
      //处理动态的搜索条件,耦合到搜索列表
      this.$ajax.get({
        url: this.$api.GET_BASIC_LIST,
        params: {
          pageSize: this.pagination.pageSize,
          pageNo: this.pagination.pageNo,
          ...id
        },
        
      }).then(res => {
        if (res.code == 200 ) {
          /**
           * 存导出的数据? 暂时废弃
           */
          // searchParams.token = this.$cookie.get('token')
          // let a = this.tbl + '?'
          // for(let k in searchParams){
          //   a = a+k+'='+ searchParams[k]+ '&'
          // }
          // this.exportParams = a
          //   小区的展示统计量信息数据
          this.pagination.total= this.$com.confirm(res, 'data.totalRows', 0)
          this.pagination.totStCnstArea= this.$com.confirm(res, 'data.totStCnstArea', 0)
          this.pagination.totUnits= this.$com.confirm(res, 'data.totUnits', 0)
          this.pagination.totHous= this.$com.confirm(res, 'data.totHous', 0)

          this.tableData_sect = this.$com.confirm(res, 'data.content', [])
          // 处理显示的字段
          this.tableData_sect.forEach(col => {
            if (col.stKind == '01') {
              col.stKind = '商品房'
            } else if(col.stKind == '02') {
              col.stKind = '动迁房'
            }else if(col.stKind == '03') {
              col.stKind = '共有产权保障房'
            }else if(col.stKind == '04') {
              col.stKind = '售后房'
            }else if(col.stKind == '05') {
              col.stKind = '直管公房'
            }else if(col.stKind == '06') {
              col.stKind = '混合'
            }else if(col.stKind == '07') {
              col.stKind = '系统公房'
            }else if(col.stKind == '08') {
              col.stKind = '集体土地集资房'
            }else if(col.stKind == '09') {
              col.stKind = '军产'
            }else if(col.stKind == '10') {
              col.stUseType = '私产'
            }else if(col.stKind == '11') {
              col.stUseType = '公租房'
            }
            if (col.sectType == '1') {
              col.sectType = '住宅'
            } else if(col.sectType == '2') {
              col.sectType = '非住宅'
            }else if(col.sectType == '3') {
              col.sectType = '虚拟小区'
            }
            if (col.hocId == '' || col.hocId == null || col.hocId == 0) {
              col.hocId = '否'
            } else {
              col.hocId = '是'
            }
            if (col.hocId == '' || col.hocId == null || col.hocId == 0) {
              col.hocId = '否'
            } else {
              col.hocId = '是'
            }
            //特殊处理更新时间
            if (!!col.syncTime) {
              col.syncTime = col.syncTime.slice(0, 4)+'-'+col.syncTime.slice(4, 6)+'-'+col.syncTime.slice(6, 8)+' '+col.syncTime.slice(8, 10)+':'+col.syncTime.slice(10, 12)+':'+col.syncTime.slice(12, 14)
            } 
          })
        }
      })
    },
    getListMpz(id){ // 获取小区数据
      //处理动态的搜索条件,耦合到搜索列表
      this.$ajax.get({
        url: this.$api.GET_BUILDINGS_LIST,
        params: {
          pageSize: this.pagination.pageSize,
          pageNo: this.pagination.pageNo,
          ...id
        },
      }).then(res => {
        if (res.code == 200 ) {
          /**
           * 存导出的数据? 暂时废弃
           */
          // searchParams.token = this.$cookie.get('token')
          // let a = this.tbl + '?'
          // for(let k in searchParams){
          //   a = a+k+'='+ searchParams[k]+ '&'
          // }
          // this.exportParams = a
          //   小区的展示统计量信息数据
          this.pagination.total= this.$com.confirm(res, 'data.totalRows', 0)
          this.pagination.totStCnstArea= this.$com.confirm(res, 'data.totStCnstArea', 0)
          this.pagination.totUnits= this.$com.confirm(res, 'data.totUnits', 0)
          this.pagination.totHous= this.$com.confirm(res, 'data.totHous', 0)

          this.tableData_mpz = this.$com.confirm(res, 'data.content', [])
          // 处理显示的字段
          this.tableData_mpz.forEach(col => {
            if (col.stKind == '01') {
              col.stKind = '商品房'
            } else if(col.stKind == '02') {
              col.stKind = '动迁房'
            }else if(col.stKind == '03') {
              col.stKind = '共有产权保障房'
            }else if(col.stKind == '04') {
              col.stKind = '售后房'
            }else if(col.stKind == '05') {
              col.stKind = '直管公房'
            }else if(col.stKind == '06') {
              col.stKind = '混合'
            }else if(col.stKind == '07') {
              col.stKind = '系统公房'
            }else if(col.stKind == '08') {
              col.stKind = '集体土地集资房'
            }else if(col.stKind == '09') {
              col.stKind = '军产'
            }else if(col.stKind == '10') {
              col.stUseType = '私产'
            }else if(col.stKind == '11') {
              col.stUseType = '公租房'
            }
            if (col.sectType == '1') {
              col.sectType = '住宅'
            } else if(col.sectType == '2') {
              col.sectType = '非住宅'
            }else if(col.sectType == '3') {
              col.sectType = '虚拟小区'
            }
            if (col.hocId == '' || col.hocId == null || col.hocId == 0) {
              col.hocId = '否'
            } else {
              col.hocId = '是'
            }
            if (col.hocId == '' || col.hocId == null || col.hocId == 0) {
              col.hocId = '否'
            } else {
              col.hocId = '是'
            }
            //特殊处理更新时间
            if (!!col.syncTime) {
              col.syncTime = col.syncTime.slice(0, 4)+'-'+col.syncTime.slice(4, 6)+'-'+col.syncTime.slice(6, 8)+' '+col.syncTime.slice(8, 10)+':'+col.syncTime.slice(10, 12)+':'+col.syncTime.slice(12, 14)
            } 
          })
        }
      })
    },
    getListWy(id){ // 获取小区数据
      //处理动态的搜索条件,耦合到搜索列表
      this.$ajax.get({
        url: this.$api.GET_WY_AND_YWH_LIST,
        params: {
          tableName: this.tbl,
          pageSize: this.pagination.pageSize,
          pageNo: this.pagination.pageNo,
          ...id
        },
      }).then(res => {
        if (res.code == 200 ) {
          /**
           * 存导出的数据? 暂时废弃
           */
          // searchParams.token = this.$cookie.get('token')
          // let a = this.tbl + '?'
          // for(let k in searchParams){
          //   a = a+k+'='+ searchParams[k]+ '&'
          // }
          // this.exportParams = a
          //   小区的展示统计量信息数据
          this.pagination.total= this.$com.confirm(res, 'data.totalRows', 0)
          this.pagination.totStCnstArea= this.$com.confirm(res, 'data.totStCnstArea', 0)
          this.pagination.totUnits= this.$com.confirm(res, 'data.totUnits', 0)
          this.pagination.totHous= this.$com.confirm(res, 'data.totHous', 0)

          this.tableData_wy = this.$com.confirm(res, 'data.content', [])
          // 处理显示的字段
          this.tableData_wy.forEach(col => {
            if (col.stKind == '01') {
              col.stKind = '商品房'
            } else if(col.stKind == '02') {
              col.stKind = '动迁房'
            }else if(col.stKind == '03') {
              col.stKind = '共有产权保障房'
            }else if(col.stKind == '04') {
              col.stKind = '售后房'
            }else if(col.stKind == '05') {
              col.stKind = '直管公房'
            }else if(col.stKind == '06') {
              col.stKind = '混合'
            }else if(col.stKind == '07') {
              col.stKind = '系统公房'
            }else if(col.stKind == '08') {
              col.stKind = '集体土地集资房'
            }else if(col.stKind == '09') {
              col.stKind = '军产'
            }else if(col.stKind == '10') {
              col.stUseType = '私产'
            }else if(col.stKind == '11') {
              col.stUseType = '公租房'
            }
            if (col.sectType == '1') {
              col.sectType = '住宅'
            } else if(col.sectType == '2') {
              col.sectType = '非住宅'
            }else if(col.sectType == '3') {
              col.sectType = '虚拟小区'
            }
            if (col.hocId == '' || col.hocId == null || col.hocId == 0) {
              col.hocId = '否'
            } else {
              col.hocId = '是'
            }
            if (col.hocId == '' || col.hocId == null || col.hocId == 0) {
              col.hocId = '否'
            } else {
              col.hocId = '是'
            }
            //特殊处理更新时间
            if (!!col.syncTime) {
              col.syncTime = col.syncTime.slice(0, 4)+'-'+col.syncTime.slice(4, 6)+'-'+col.syncTime.slice(6, 8)+' '+col.syncTime.slice(8, 10)+':'+col.syncTime.slice(10, 12)+':'+col.syncTime.slice(12, 14)
            } 
          })
        }
      })
    },
    getListYwh(id){ // 获取小区数据
      //处理动态的搜索条件,耦合到搜索列表
      this.$ajax.get({
        url: this.$api.GET_WY_AND_YWH_LIST,
        params: {
          tableName: this.tbl,
          pageSize: this.pagination.pageSize,
          pageNo: this.pagination.pageNo,
          ...id
        },
      }).then(res => {
        if (res.code == 200 ) {
          /**
           * 存导出的数据? 暂时废弃
           */
          // searchParams.token = this.$cookie.get('token')
          // let a = this.tbl + '?'
          // for(let k in searchParams){
          //   a = a+k+'='+ searchParams[k]+ '&'
          // }
          // this.exportParams = a
          //   小区的展示统计量信息数据
          this.pagination.total= this.$com.confirm(res, 'data.totalRows', 0)
          this.pagination.totStCnstArea= this.$com.confirm(res, 'data.totStCnstArea', 0)
          this.pagination.totUnits= this.$com.confirm(res, 'data.totUnits', 0)
          this.pagination.totHous= this.$com.confirm(res, 'data.totHous', 0)

          this.tableData_ywh = this.$com.confirm(res, 'data.content', [])
          // 处理显示的字段
          this.tableData_ywh.forEach(col => {
            if (col.stKind == '01') {
              col.stKind = '商品房'
            } else if(col.stKind == '02') {
              col.stKind = '动迁房'
            }else if(col.stKind == '03') {
              col.stKind = '共有产权保障房'
            }else if(col.stKind == '04') {
              col.stKind = '售后房'
            }else if(col.stKind == '05') {
              col.stKind = '直管公房'
            }else if(col.stKind == '06') {
              col.stKind = '混合'
            }else if(col.stKind == '07') {
              col.stKind = '系统公房'
            }else if(col.stKind == '08') {
              col.stKind = '集体土地集资房'
            }else if(col.stKind == '09') {
              col.stKind = '军产'
            }else if(col.stKind == '10') {
              col.stUseType = '私产'
            }else if(col.stKind == '11') {
              col.stUseType = '公租房'
            }
            if (col.sectType == '1') {
              col.sectType = '住宅'
            } else if(col.sectType == '2') {
              col.sectType = '非住宅'
            }else if(col.sectType == '3') {
              col.sectType = '虚拟小区'
            }
            if (col.hocId == '' || col.hocId == null || col.hocId == 0) {
              col.hocId = '否'
            } else {
              col.hocId = '是'
            }
            if (col.hocId == '' || col.hocId == null || col.hocId == 0) {
              col.hocId = '否'
            } else {
              col.hocId = '是'
            }
            //特殊处理更新时间
            if (!!col.syncTime) {
              col.syncTime = col.syncTime.slice(0, 4)+'-'+col.syncTime.slice(4, 6)+'-'+col.syncTime.slice(6, 8)+' '+col.syncTime.slice(8, 10)+':'+col.syncTime.slice(10, 12)+':'+col.syncTime.slice(12, 14)
            } 
          })
        }
      })
    },
    getStreet(){ //获取街道下拉
      this.$ajax.get({
        url: this.$api.GET_STREET_LIST,
        params: {
          pageSize: 10000
        }
      }).then(res => {
        this.street = this.$com.confirm(res, 'data.content', [])
      })
    },
    getHos(){ // 获取房办的下拉选项
      this.$ajax.get({
        url: this.$api.GET_HOS_LIST,
        params: {
          pageSize: 100000,
          sectType_in: '1'
        }
      }).then(res => {
        this.hos = this.$com.confirm(res, 'data.content', [])
      })
    },
    getWy(){ // 获取物业的下拉选项
      this.$ajax.get({
        url: this.$api.GET_PROPCOMPANIES_LIST,
        params: {
          pageSize: 100000,
          sectType_in: '1'
        }
      }).then(res => {
        this.wuye= this.$com.confirm(res, 'data.content', [])
      })
    },
    /**
     * 从vuex中或已存储的搜索条件，判断此条件是否为当前路由的 。如果是则使用
     */
    getSearchParams(){
      const searchParams = !this.$store.state.listSearchParams?null:this.$store.state.listSearchParams[this.$route.name]
      if(!!searchParams && !!searchParams.routeName && (this.$route.name == searchParams.routeName)){
        if(!!searchParams.params){
          Object.keys(searchParams.params).forEach(elem => {
            switch (elem) {
            case 'stNameFrst_l':
              this.form.setFieldsValue({ 'stNameFrst_l': searchParams.params[elem] })
              break
            case 'addrFrst_l':
              this.form.setFieldsValue({ 'addrFrst_l': searchParams.params[elem] })
              break
            case 'c.cspId':
              if (searchParams.params[elem] != '') {
                this.form.setFieldsValue({ 'c.cspId': searchParams.params[elem] })
              }
              break
            case 'c.hoId':
              if (searchParams.params[elem] != '') {
                this.form.setFieldsValue({ 'c.hoId': searchParams.params[elem] })
              }
              break
            case 'stKind_in':
              if (searchParams.params[elem] != '') {
                this.form.setFieldsValue({ 'stKind_in': searchParams.params[elem] })
              }
              break
            case 'c.streetId':
              if (searchParams.params[elem] != '') {
                this.form.setFieldsValue({ 'c.streetId': searchParams.params[elem] })
              }
              break
            case 'isHoc':
              if (searchParams.params[elem] != '') {
                this.form.setFieldsValue({ 'isHoc': searchParams.params[elem] })
              }
              break
            default:
              break
            }
            // 无法回显自定义的值,store里面有数据但是会报 You cannot set a form field before rendering a field associated with the value.
            // setTimeout(()=>{
            //   this.form.setFieldsValue({ elem : searchParams.params[elem] })
            // },0)
          })
        }
        if(!!searchParams.pagination){
          if(!!searchParams.pagination.pageNo){
            this.pagination.pageNo = searchParams.pagination.pageNo
            this.pagination.current = searchParams.pagination.current
            this.pagination.pageSize = searchParams.pagination.pageSize
          }
        }
      }
      this.getList()
    },
    test() {
      console.log('ajsdojsidjoasd')
    },
    toView(row){ // 操作里面去详情
      this.$router.push({path: `/houseData/basicInfoByLabel/${row.id}`, query: {id: row.id, name: row.cspName}})
    },
    toBul(row){
      this.$router.push({path: '/houseData/buildings', query: {id: row.id}})
    },
    toShebei(row){
      this.$router.push({path: `/houseData/shebei/${row.id}`})
    },
    exportList(){ //导出功能
      const formValue = this.form.getFieldsValue()
      let newUrl = this.tbl + '?'
      let newObj = {}

      //拼接除 c.xxx 和 是否成立业主大会 之外的数据
      for(const k in formValue){
        if (k!= 'isHoc') { // 排除isHoc  是否成立业主大会   后续判断
          if (formValue[k]!= undefined ) { // 判断是否值为 undefined
            if ( k == 'c') { // 排除 c.xxx 的键
              newObj = formValue[k] //有c.xx存入 b对象  下面处理,
            } else if(Object.prototype.toString.call(formValue[k])== '[object Array]'){
              // 数组的话就拼接字符串
              newUrl += k +'=' + formValue[k].join(',') + '&'
            }else if (Object.prototype.toString.call(formValue[k]) === '[object Object]') {
              //时间格式对象就转换成字符串
              newUrl += k +'=' +this.$moment(formValue[k]).format('YYYY-MM-DD') +'&'
            }else {
              newUrl += k +'=' +formValue[k] +'&' //没有特殊情况  直接拼接到 newUrl
            }
          }
        }
      }
      // 处理 c.xxx 里面的数据
      for(const k in newObj ){
        if (newObj[k] != undefined) { // 排除值为undefined的键
          newUrl += 'c.'+ k +'=' +newObj[k].split('#')[1] +'&' // 拼接到 newUrl
        }
      }
      // 处理是否成立业主大会
      if (formValue.isHoc) {
        if (formValue.isHoc=='false') { // 判断业主大会是否选择了,  再根据 选项   拼接参数到 newUrl
          newUrl= newUrl+ 'hocId=null&'
        } else {
          newUrl= newUrl+ 'hocId_ne=null&'
        }
      }
      let token = this.$cookie.get('token') // 获取token 并拼接到 newUrl
      newUrl += 'sectType=1&access_token=' + token.split('bearer ')[1]
      window.open (this.$api.BASE_URL+'/service-basicdatasync-ddd/export/'+ newUrl)
    },
    /**
     * 导出二维码
     */
    exportEWM(){
      const formValue = this.form.getFieldsValue()
      let token = this.$cookie.get('token')
      let selectedKeys = this.$refs.childTab.rowSelection.selectedRowKeys
      if(selectedKeys.length>0){
        let sectId=selectedKeys.join(',')
        // console.log('https://hm.omniview.pro/common/public/qrCodeGenerate?sectId='+sectId+'&token='+token)
        window.open (this.$api.GET_EXPORT_EWM+'?sectId='+sectId+'&access_token=' + token.split('bearer ')[1] )
      }else{
        let streetsId = formValue.c.streetId
        if(streetsId){
          streetsId=streetsId.split('#')[1]
        }else{
          streetsId=''
        }
        let stNameFrst_l = formValue.stNameFrst_l?formValue.stNameFrst_l:''
        // console.log(this.$api.GET_EXPORT_EWM+'?streetId='+streetsId+'&stNameFrst_l='+stNameFrst_l+'&token='+token)
        window.open (this.$api.GET_EXPORT_EWM+'?streetId='+streetsId+'&stNameFrst_l='+stNameFrst_l+'&access_token=' + token.split('bearer ')[1])
      }
    },
    changeLevel(val) {
      console.log(val)
      this.stLevel = val.join(',')

      // if(val.indexOf('1')!=-1 && val.indexOf('2')!=-1) {
      //   this.stLevel = '8'
      // } else {
      //   this.stLevel = val[0]
      // }

      // this.getList()
    },
    changeServiceType(val) {
      this.cspServiceType = val
      this.getList()
    },
    changeNeighbourType(val) {
      switch (val) {
      case '1':
        this.tableName = 'tbl_community'
        this.formed = ''
        this.type = 'un'
        break

      case '2':
        this.tableName = 'tbl_community'
        this.formed = '10,' + (this.$moment().format('L').split('/')).join('')
        this.type = 'bet'
        break

      case '3':
        this.tableName = 'tbl_community'
        this.formed = '前期筹备中'
        this.type = 'l'
        break

      default:
        this.type = ''
        this.formed = ''
        break
      }

      // this.getList()
    },
    changeFinishDate(val) {
      switch (val) {
      case '1':
        this.isBeforeTwoThousand = '1'
        break

      case '2':
        this.isBeforeTwoThousand = '2'
        break

      default:
        this.isBeforeTwoThousand = 'none'
        break
      }
      // this.getList()
    }
  },

}
</script>

<style>
</style>

