<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <el-form
          :inline="true"
          class="demo-form-inline"
          label-position="right"
          label-width="90px"
          label-suffix=":"
        >
          <el-form-item label="点位编码">
            <el-input
              v-model="query.point_code"
              clearable
              placeholder="输入点位编码"
              class="filter-item"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>
          <el-form-item label="点位类型">
            <el-select
              v-model="query.point_type"
              clearable
              filterable
              size="mini"
              class="filter-item"
              @change="hand"
            >
              <el-option
                v-for="item in dict.BCUT_POINT_TYPE"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="生产区域">
            <el-select
              v-model="query.product_area"
              clearable
              filterable
              size="mini"
              class="filter-item"
              @change="hand"
            >
              <el-option
                v-for="item in dict.product_area"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="区域位置">
            <el-select
              v-model="query.point_location"
              clearable
              filterable
              size="mini"
              class="filter-item"
              @change="hand"
            >
              <el-option
                v-for="item in dict.point_location"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="是否启用">
            <el-switch
              v-model="query.is_used"
              active-value="0"
              inactive-value="1"
              active-color="#C0CCDA"
              inactive-color="#409EFF"
              @change="hand"
            />
          </el-form-item>
          <rrOperation />
        </el-form>
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="790px">
        <el-form ref="form" :model="form" :inline="true" :rules="rules" size="mini" label-width="120px">
          <el-form-item label="AGV点位编码">
            <el-input v-model="form.point_code" disabled style="width: 240px;" />
          </el-form-item>
          <el-form-item label="AGV点位名称">
            <el-input v-model="form.point_name" disabled style="width: 240px;" />
          </el-form-item>
          <el-form-item label="桁架点位编码1 ">
            <el-input v-model="form.truss_point_code1" disabled style="width: 240px;" />
          </el-form-item>
          <el-form-item label="桁架点位编码2">
            <el-input v-model="form.truss_point_code2" disabled style="width: 240px;" />
          </el-form-item>
          <el-form-item label="气胀轴编码1">
            <el-input v-model="form.qzz_no1" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="气胀轴编码2">
            <el-input v-model="form.qzz_no2" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="点位类型">
            <el-select
              v-model="form.point_type"
              clearable
              filterable
              size="mini"
              style="width: 240px;"
            >
              <el-option
                v-for="item in dict.BCUT_POINT_TYPE"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="生产区域">
            <el-select
              v-model="form.product_area"
              clearable
              filterable
              size="mini"
              style="width: 240px;"
            >
              <el-option
                v-for="item in dict.product_area"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="点位状态">
            <el-select
              v-model="form.point_status"
              clearable
              filterable
              size="mini"
              style="width: 240px;"
            >
              <el-option
                v-for="item in dict.CUT_POINT_STATUS"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="位置">
            <el-select
              v-model="form.point_location"
              clearable
              filterable
              size="mini"
              style="width: 240px;"
            >
              <el-option
                v-for="item in dict.point_location"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="规划">
            <el-input v-model="form.plan" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="是否启用" prop="is_used">
            <el-switch v-model="form.is_used" active-value="1" inactive-value="0" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remark" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" style="width: 240px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="point_code" label="AGV点位编码" :min-width="flexWidth('point_code',crud.data,'AGV点位编码')" />
        <el-table-column prop="point_name" label="AGV点位名称" :min-width="flexWidth('point_name',crud.data,'AGV点位名称')" />
        <el-table-column prop="truss_point_code1" label="桁架点位编码1 " :min-width="flexWidth('truss_point_code1',crud.data,'桁架点位编码1 ')" />
        <el-table-column prop="truss_point_code2" label="桁架点位编码2" :min-width="flexWidth('truss_point_code2',crud.data,'桁架点位编码2')" />
        <el-table-column prop="qzz_no1" label="气胀轴编码1" :min-width="flexWidth('qzz_no1',crud.data,'气胀轴编码1')" />
        <el-table-column prop="qzz_no2" label="气胀轴编码2" :min-width="flexWidth('qzz_no2',crud.data,'气胀轴编码2')" />
        <el-table-column prop="point_type" label="点位类型" :min-width="flexWidth('point_type',crud.data,'点位类型型')">
          <template slot-scope="scope">
            {{ dict.label.BCUT_POINT_TYPE[scope.row.point_type] }}
          </template>
        </el-table-column>
        <el-table-column prop="point_status" label="点位状态" :min-width="flexWidth('point_type',crud.data,'点位类型型')">
          <template slot-scope="scope">
            {{ dict.label.CUT_POINT_STATUS[scope.row.point_status] }}
          </template>
        </el-table-column>
        <el-table-column prop="product_area" label="生产区域" :min-width="flexWidth('product_area',crud.data,'生产区域')" />
        <el-table-column prop="point_location" label="位置" :min-width="flexWidth('point_location',crud.data,'位置')">
          <template slot-scope="scope">
            {{ dict.label.point_location[scope.row.point_location] }}
          </template>
        </el-table-column>
        <el-table-column prop="sort_seq" label="顺序号" :min-width="flexWidth('sort_seq',crud.data,'顺序号')" />
        <el-table-column prop="is_used" label="是否启用" :min-width="flexWidth('is_used',crud.data,'是否启用')">
          <template slot-scope="scope">
            {{ dict.label.IS_OR_NOT[scope.row.is_used] }}
          </template>
        </el-table-column>
        <el-table-column prop="remark" label="备注" :min-width="flexWidth('remark',crud.data,'备注')" />
        <el-table-column prop="create_name" label="创建人姓名" :min-width="flexWidth('create_name',crud.data,'创建人姓名')" />
        <el-table-column prop="create_time" label="创建时间" :min-width="flexWidth('create_time',crud.data,'创建时间')" />
        <el-table-column prop="update_optname" label="修改人姓名" :min-width="flexWidth('update_optname',crud.data,'修改人姓名')" />
        <el-table-column prop="update_time" label="修改时间" :min-width="flexWidth('update_time',crud.data,'修改时间')" />
        <el-table-column prop="plan" label="规划" :min-width="flexWidth('plan',crud.data,'规划')" />
        <el-table-column v-permission="[]" label="操作" width="120px" align="center" fixed="right">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :is-visiable-del="false"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudBstIvtCutpointivt from './bstIvtCutpointivt'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = {
  ivt_id: null,
  point_code: null,
  point_name: null,
  truss_point_code1: null,
  truss_point_code2: null,
  qzz_no1: null,
  qzz_no2: null,
  point_type: null,
  point_status: null,
  product_area: null,
  point_location: null,
  sort_seq: null,
  is_used: null,
  remark: null,
  create_id: null,
  create_name: null,
  create_time: null,
  update_optid: null,
  update_optname: null,
  update_time: null,
  plan: null
}
export default {
  name: 'BstIvtCutpointivt',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['IS_OR_NOT', 'product_area', 'BCUT_POINT_TYPE', 'CUT_POINT_STATUS', 'point_location'],
  cruds() {
    return CRUD({
      title: '分切区缓存点位库存',
      url: 'api/bstIvtCutpointivt',
      idField: 'ivt_id',
      sort: 'ivt_id,desc',
      crudMethod: { ...crudBstIvtCutpointivt },
      optShow: {
        add: false,
        edit: true,
        del: false,
        download: false,
        reset: true
      }
    })
  },
  data() {
    return {
      permission: {
      },
      rules: {
      }
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    hand(value) {
      this.crud.toQuery()
    }
  }
}
</script>

<style scoped>

</style>
