<template>
  <div class="meta-container">
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <el-select
          v-model="query.status"
          clearable
          size="small"
          placeholder="选择状态"
          class="filter-item"
          style="width: 100px"
          @change="crud.toQuery"
        >
          <el-option
            v-for="item in 2"
            :key="item"
            :label="item == '1' ? '已设置' : '未设置'"
            :value="item"
          />
        </el-select>
        <el-input
          v-model="query.name"
          clearable
          size="small"
          placeholder="输入标签名称"
          style="width: 180px"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        />
        <rrOperation />
      </div>
      <crudOperation :permission="permission" />
    </div>
    <el-table
      ref="table"
      v-loading="crud.loading"
      :data="crud.data"
      style="width: 100%;"
      @selection-change="crud.selectionChangeHandler"
    >
      <el-table-column
        v-for="item in patrolLabelBatchTableOptions"
        :key="item.prop"
        :label="item.label"
        :prop="item.prop"
        :width="item.width"
        :align="item.align"
        :fixed="item.fixed"
        :sortable="item.sortable"
      >
      </el-table-column>
      <el-table-column
        v-if="checkPer(['admin', 'patrolLabel:edit', 'patrolLabel:del'])"
        label="操作"
        width="132"
        align="center"
        fixed="right"
      >
        <template slot-scope="scope">
          <div style="display:flex;">
            <el-button type="text" size="mini" style="margin-right:5px;" @click="handleLabelLocation(scope.row)" >修改</el-button>
            <el-button type="text" size="mini" style="margin-right:10px;" @click="resetLabelLocation(scope.row)">重置</el-button>
            <udOperation :data="scope.row" :permission="permission" />
          </div>
        </template>
      </el-table-column>
    </el-table>
    <!--分页组件-->
    <pagination />
  </div>
</template>

<script>
import permission from '@/directive/permission'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
// import { crudOperation, rrOperation, udOperation, pagination } from '@crud'
import crudComps from '@crud'
import DateRangePicker from '@/components/DateRangePicker'
import crudElement from '@/api/visual/element'
import { patrolLabelBatchTableOptions } from '../tableConfig'
//import VisualMap from '@/components/RelativeMap'
import { initData } from '@/api/data'

const defaultForm = {
  id: null,
  code: '',
  name: '',
  description: '',

  buildId: "",
  buildName: "",
  floorNo: 0,
  floorStr: "",
  extent: {
    buildId: "",
    floor: [],
    points: []
  },

  nfcCode: '',
  rfidCode: '',
  qrCode: '',
  barCode:'',
  
  location:'',
  GPSRail: '',
  Rail: '',
  scenePicUrl:[],
  reset:false
}
export default {
  name: 'patrolLabel',
  directives: { permission },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  components: {
    ...crudComps,
    DateRangePicker
  },
  cruds() {
    return CRUD({
      title: '巡检标签',
      url: 'patrol/label/getList',
      crudMethod: { ...crudElement },
      optShow: { add: false, edit: false, del: false, reset: true },
    })
  },
  data() {
    return {
      dataContent:'',
      permission: {
        add: ['admin', 'patrolLabel:add'],
        edit: ['admin', 'patrolLabel:edit'],
        del: ['admin', 'patrolLabel:del']
      },
      patrolLabelBatchTableOptions,
      rules: {
        code: [{ required: true, message: '请输入标签编号', trigger: 'blur' }],
        name: [{ required: true, message: '请输入标签名称', trigger: 'blur' }],
      },
      dataTypeList:[
        {label:"文本",value:"1"},
        {label:"状态",value:"2"},
        {label:"数值",value:"3"},
        {label:"位号",value:"4"},
      ],
      objectTypeList:[]
    }
  },
  created() {},
  computed: {
    crudCU() {
      return this.crud.status.cu > 0
    },
    VUE_APP_BASE_API() {
      return process.env.VUE_APP_BASE_API
    }
  },
  created() {
    // this.getIcons()
  },
  methods: {
    // 新增与编辑前做的操作
    [CRUD.HOOK.beforeToAdd](crud, form) {
      
    },
    // 提交前做的操作
    [CRUD.HOOK.afterValidateCU](crud) {
      
    },
    checkboxT(row, rowIndex) {
      return true
      // return row.id !== this.userInfo.id
    },
    handleLabelLocation(row) {
      console.log(row);
      this.form = row
      this.$emit('getData',this.form)
    },
    resetLabelLocation(row){
      console.log(row);
      this.form = row
      this.form.reset = true
      this.$emit('getData',this.form)
    },
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .vue-treeselect__control,
::v-deep .vue-treeselect__placeholder,
::v-deep .vue-treeselect__single-value {
  height: 30px;
  line-height: 30px;
}
</style>
