<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input v-model="search.keyWord" placeholder="关键字" style="width: 200px;" class="filter-item" />
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="searchData">
        搜索
      </el-button>

      <el-button
        v-if="webType && isChoose == false"
        class="filter-item"
        style="margin-left: 10px;"
        type="primary"
        icon="el-icon-plus"
        @click="handleCreateAdd">
        增加版芯档案
      </el-button>
      <div class="top-right-btn">
        <el-tooltip class="item" effect="dark" content="刷新" placement="top">
          <el-button size="mini" circle icon="el-icon-refresh" @click="getList" />
        </el-tooltip>
      </div>
    </div>
    <el-table
      :data="tableData"
      v-loading="listLoading"
      class="tb-edit"
      style="width: 100%;margin-bottom: 20px;"
      row-key="id"
      border
      highlight-current-row
      @row-click="handleCurrentChange"
      default-expand-all>
      <el-table-column
        prop="templateName"
        width="130px"
        label="版芯名称">
      </el-table-column>
      <el-table-column
        prop="plateSize"
        label="版芯尺寸">
      </el-table-column>
      <el-table-column
        prop="paperCutSize"
        label="开纸尺寸">
      </el-table-column>

      <el-table-column
        label="面数">
        <template slot-scope="{row}">
        <span v-if="row.faceCount==1">
          单面
        </span>
        <span v-else-if="row.faceCount==2">
          双面
        </span>
      </template>
      </el-table-column>
      <el-table-column
        prop="trunKind"
        label="翻版方式">
        <template slot-scope="{row}">
        <span v-if="row.trunKind==4">
          单面
        </span>
          <span v-else-if="row.trunKind==1">
          正反
        </span>

          <span v-else-if="row.trunKind==3">
          自翻
        </span>

          <span v-else-if="row.trunKind==2">
          滚翻
        </span>
        </template>
      </el-table-column>
      <el-table-column
        prop="holdPlace"
        label="咬口位置">
        <template slot-scope="{row}">
        <span v-if="row.holdPlace==1">
          靠下
        </span>
          <span v-else-if="row.holdPlace==0">
          靠上
        </span>

          <span v-else-if="row.holdPlace==2">
          靠左
        </span>

          <span v-else-if="row.holdPlace==3">
          靠右
        </span>
        </template>
      </el-table-column>
      <el-table-column
        prop="materialSize"
        label="版材尺寸">
      </el-table-column>
      <el-table-column align="center" label="状态" class-name="status-col">
        <template slot-scope="{row}">
          <el-tag v-if="row.voidFlag==0" type="success">
            启用
          </el-tag>
          <el-tag v-else-if="row.voidFlag==1" type="danger">
            禁用
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作"  fixed='left' align="center" width="230" class-name="small-padding fixed-width">
        <template slot-scope="{row}">
          <template v-if="webType">
            <template v-if="!isChoose">
              <el-button @click="handleUpdate(row)" type="primary" size="mini">
                编辑
              </el-button>
              <el-button @click="editStatus(row.id,'1')" type="danger" v-if="row.voidFlag==0" size="mini">
                禁用
              </el-button>
              <el-button @click="editStatus(row.id,'0')" v-else-if="row.voidFlag==1" size="mini">
                启用
              </el-button>
            </template>
            <template v-else>
              <el-button @click="chooseThis(row)" type="primary" size="mini">
                选择
              </el-button>
            </template>
          </template>
          <template v-else>
            <el-button @click="ERPChoose(row)" type="primary" size="mini">
              选择
            </el-button>
          </template>
        </template>
      </el-table-column>

    </el-table>
<!--    <pagination v-show="listData.total>0" :total="listData.total" :page.sync="listData.page" :limit.sync="listData.pageSize" @pagination="getList" />-->

    <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" :close-on-click-modal="false" width="900px">
      <el-form label-width="100px" label-position="right" size="mini">
        <el-tabs v-model="activeName">
          <el-tab-pane label="版式信息" name="first">
            <el-row :gutter="20">
              <el-col :span="22">
                <el-form-item label="模板名称">
                  <el-input v-model="form.templateName"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="版芯尺寸">
                  <el-input v-model="form.plateSize" style="width: 240px"></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item label="开纸尺寸">
                  <el-input v-model="form.paperCutSize" style="width: 240px"></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item label="纸张开数">
                  <el-select v-model="form.idPaperCutInfo" filterable placeholder="请选择" style="width: 240px">
                    <el-option
                      v-for="item in paperCutInfoOption"
                      :key="item.id"
                      :label="item.cutName"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="面数">
                  <el-select v-model="form.faceCount"  placeholder="请选择" style="width: 240px">
                    <el-option
                      label="单面"
                      :value="1">
                    </el-option>
                    <el-option
                      label="双面"
                      :value="2">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="翻版方式">
                  <el-select v-model="form.trunKind" filterable placeholder="请选择" style="width: 240px">
                    <el-option
                      v-for="item in trunKindOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="咬口位置">
                  <el-select v-model="form.holdPlace" filterable placeholder="请选择" style="width: 240px">
                    <el-option
                      v-for="item in holdPlaceOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="侧规">
                  <el-select v-model="form.sidePlace" filterable placeholder="请选择" style="width: 240px">
                    <el-option
                      label="靠身"
                      :value="0">
                    </el-option>
                    <el-option
                      label="靠外"
                      :value="1">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="版材尺寸">
                  <el-input v-model="form.materialSize" style="width: 240px" ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="固定长边">
                  <el-input v-model="form.modWidthFixed" style="width: 240px" ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="默认机型">
                  <el-select v-model="form.idMachineInfo" placeholder="请选择" style="width: 240px">
                    <el-option
                      v-for="item in machineOption"
                      :key="item.id"
                      :label="item.typeName"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="22">
                <el-form-item label="页面留白">
                  <el-card>
                    <el-row :gutter="20">
                      <el-col :span="4" :offset="10">
                        <el-input-number :controls="false" :precision="1" v-model="form.pageBlankTop"></el-input-number>
                      </el-col>
                    </el-row>
                    <br>
                    <el-row :gutter="20">
                      <el-col :span="4" :offset="1">
                        <el-input-number :controls="false" :precision="1" v-model="form.pageBlankLeft"></el-input-number>
                      </el-col>
                      <el-col :span="4" :offset="14">
                        <el-input-number :controls="false" :precision="1" v-model="form.pageBlankRight"></el-input-number>
                      </el-col>
                    </el-row>
                    <br>
                    <el-row :gutter="20">
                      <el-col :span="4" :offset="10">
                        <el-input-number :controls="false" :precision="1" v-model="form.pageBalnkBottom"></el-input-number>
                      </el-col>
                    </el-row>
                  </el-card>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item>
                  <el-checkbox v-model="form.plateWithRegionFlag">按拼版区域进行组版</el-checkbox>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item>
                  <el-checkbox v-model="form.exchangeHoldPlace">上下咬口调换</el-checkbox>
                </el-form-item>
              </el-col>

            </el-row>
          </el-tab-pane>
          <el-tab-pane label="版面信息" name="second">
            <el-card>
              <div slot="header" class="clearfix">
                <span>垂直十字线（距离为中心点计算）</span>
              </div>
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item label="水平尺寸">
                    <el-input-number :controls="false" :precision="1" v-model="form.distanceWidthVertocal" style="width: 240px"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="垂直尺寸">
                    <el-input-number :controls="false" :precision="1" v-model="form.distanceHeightVertocal" style="width: 240px"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="距页面">
                    <el-input-number :controls="false" :precision="1" v-model="form.distancePlateVertocal" style="width: 240px"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="距咬口">
                    <el-input-number :controls="false" :precision="1" v-model="form.distanceHoldVertocal" style="width: 240px"></el-input-number>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-card>
            <el-card>
              <div slot="header" class="clearfix">
                <span>水平十字线（距离为中心点计算）</span>
              </div>
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item label="水平尺寸">
                    <el-input-number :controls="false" :precision="1" v-model="form.distanceWidthHorizontal" style="width: 240px"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="垂直尺寸">
                    <el-input-number :controls="false" :precision="1" v-model="form.distanceHeightHorizontal" style="width: 240px"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="距页面">
                    <el-input-number :controls="false" :precision="1" v-model="form.distancePlateHorizontal" style="width: 240px"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="距咬口">
                    <el-input-number :controls="false" :precision="1" v-model="form.distanceHoldHorizontal" style="width: 240px"></el-input-number>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-card>
            <el-card>
              <div slot="header" class="clearfix">
                <span>梯尺/测控条</span>
              </div>
              <el-row :gutter="20">
                <el-col :span="24">
                  <el-form-item>
                    <el-checkbox v-model="form.drawTChiPDF">绘制梯尺</el-checkbox>
                  </el-form-item>
                </el-col>
                <el-col :span="24">
                  <el-form-item label="梯尺尺寸">
                    <el-input v-model="form.tchiPDFSize" style="width: 240px"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="24">
                  <el-form-item label="梯尺文件">
                    <el-input v-model="form.tchiPDFFile"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-card>
          </el-tab-pane>
          <el-tab-pane label="固定区域" name="third">
            <el-row :gutter="20">
              <el-col :span="24">
                <el-form-item label="裁切方向">
                  <el-select v-model="form.fixedSizeDirection">
                    <el-option
                      label="垂直方向"
                      :value="0"
                    ></el-option>
                    <el-option
                      label="水平方向"
                      :value="1"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-button type="primary" size="mini" @click="addFixedItem()">增加区域</el-button>
<!--                <el-button type="danger" size="mini">删除区域</el-button>-->
              </el-col>
            </el-row>
            <el-table :data="form.fixedItemList" border style="margin-top: 10px">
              <el-table-column label="起始位置">
                <template slot-scope="{row}">
                  <el-input-number :controls="false" :precision="1" v-model="row.startPos"></el-input-number>
                </template>
              </el-table-column>
              <el-table-column label="结束位置">
                <template slot-scope="{row}">
                  <el-input-number :controls="false" :precision="1" v-model="row.endPos"></el-input-number>
                </template>
              </el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button type="danger" size="mini" @click="deleteFixedItem(scope)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <span style="display:inline-block;color:blue; font-weight: 600;margin-top: 10px">固定区域表示空白区域，不放置任何文件</span>
          </el-tab-pane>
          <el-tab-pane label="拼版区域" name="fourth">
            <el-row :gutter="20">
              <el-col :span="24">
                <el-button type="primary" size="mini" @click="addRegionItem()">增加区域</el-button>
                <!--                <el-button type="danger" size="mini">删除区域</el-button>-->
              </el-col>
            </el-row>
            <el-table :data="form.regionItemList" border style="margin-top: 10px">
              <el-table-column label="起始位置X">
                <template slot-scope="{row}">
                  <el-input-number :controls="false" :precision="1" v-model="row.regionLeftX" style="width: 80px" size="mini"></el-input-number>
                </template>
              </el-table-column>
              <el-table-column label="起始位置Y">
                <template slot-scope="{row}">
                  <el-input-number :controls="false" :precision="1" v-model="row.regionLeftY" style="width: 80px" size="mini"></el-input-number>
                </template>
              </el-table-column>
              <el-table-column label="结束位置X">
                <template slot-scope="{row}">
                  <el-input-number :controls="false" :precision="1" v-model="row.regionBottomX" style="width: 80px" size="mini"></el-input-number>
                </template>
              </el-table-column>
              <el-table-column label="结束位置Y">
                <template slot-scope="{row}">
                  <el-input-number :controls="false" :precision="1" v-model="row.regionBottomY" style="width: 80px" size="mini"></el-input-number>
                </template>
              </el-table-column>
              <el-table-column label="裁刀方式">
                <template slot-scope="{row}">
                  <el-select v-model="row.knifeKind" style="width: 90px" size="mini">
                    <el-option
                    label="水平通刀"
                    :value="0"></el-option>
                    <el-option
                      label="垂直通刀"
                      :value="1"></el-option>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column label="固定长边">
                <template slot-scope="{row}">
                  <el-input-number :controls="false" :precision="1" v-model="row.modWidthFixed" style="width: 80px" size="mini"></el-input-number>
                </template>
              </el-table-column>
              <el-table-column label="排序">
                <template slot-scope="{row}">
                  <el-input-number :controls="false" :precision="0" v-model="row.orderIndex" style="width: 80px" size="mini"></el-input-number>
                </template>
              </el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button type="danger" size="mini" @click="deleteRegionItem(scope)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogStatus==='1'?addBtn():editBtn()">确 定</el-button>
      </div>
    </el-dialog>
    <!--    <servicedialog @tableRefresh="tableRefresh" ref="menuDialog" :dialogStatus="dialogStatus" :menuId="menuId" :titleDialog="titleDialog" :dialogVisible="dialogVisible"/>-->
    <cancledialog @tableRefresh="tableRefresh" ref="confirmDialog"></cancledialog>
  </div>
</template>

<script>
import { getPlateSizeTemplateList, addPlateSizeTemplate, getPlateSizeTemplateInfo, updatePlateSizeTemplate } from '@/api/baseInfo/plateSizeTemplate'
import { getInfo } from '@/api/baseInfo/paperCutInfoList/paperCutInfoList'
import { getPrinterNameList } from '@/api/baseInfo/machineInfo'
import Cancledialog from '@/components/Dialog/Cancledialog.vue'
import Pagination from '@/components/Pagination'

const form = {
  templateName: '', // 模板名称,
  plateSize: '', // 版芯尺寸,
  paperCutSize: '', // 开纸尺寸,
  idPaperCutInfo: '', // 纸张开数/选择纸张开数id,
  faceCount: '', // 面数/下拉选择 1=单面 2=双面,
  trunKind: '', // 翻版方式/下拉选择 0=单面 1=正反 2=自翻 3=滚翻,
  holdPlace: '', // 咬口/下拉选择 0=靠下 1=靠上 2=靠左 3=靠右,
  sidePlace: '', // 侧规/下拉选择 0=靠身 1=靠外,
  materialSize: '', // 版材尺寸,
  idMachineInfo: '', // 默认机型/从机型档案中选择,
  modWidthFixed: '', // 固定长边/用于按模拼版,
  pageBlankTop: '', // 页面留白-上,
  pageBlankLeft: '', // 页面留白-左,
  pageBalnkBottom: '', // 页面留白-下,
  pageBlankRight: '', // 页面留白-右,
  plateWithRegionFlag: '', // 按拼版区域进行组版,
  exchangeHoldPlace: '', // 上下咬口调换,
  distanceHoldVertocal: '', // 垂直十字线-距咬口,
  distancePlateVertocal: '', // 垂直十字线-距页面,
  distanceWidthVertocal: '', // 垂直十字线-水平尺寸,
  distanceHeightVertocal: '', // 垂直十字线-垂直尺寸,
  distanceHoldHorizontal: '', // 水平十字线-距咬口,
  distancePlateHorizontal: '', // 水平十字线-距页面,
  distanceWidthHorizontal: '', // 水平十字线-水平尺寸,
  distanceHeightHorizontal: '', // 水平十字线-垂直尺寸,
  drawTChiPDF: '', // 绘制梯尺,
  tchiPDFFile: '', // 梯尺文件名,
  tchiPDFSize: '', // 梯尺尺寸,
  fixedSizeDirection: '', // 固定区域-裁切方向,
  fixedItemList: [], // 固定区域子表,
  regionItemList: []// 拼版区域子表,
}
export default {
  name: 'PlateSizeTemplate',
  components: {
    Cancledialog, Pagination
  },
  props: {
    isChoose: {
      type: Boolean,
      default: false
    }
  },
  watch: {
    'form.faceCount'(val) {
      console.log(val)
      if (val == 1) {
        this.form.trunKind = 1
      }
    }
  },
  data() {
    return {
      webType: true,
      dialogStatus: 1, // 1增加，2修改
      dialogTitle: '',
      dialogVisible: false,
      search: {
        keyWord: ''
      },
      form: Object.assign({}, form),
      activeName: 'first',
      typeOptions: [],
      trunKindOptions: [
        {
          label: '正反',
          value: 1
        },
        {
          label: '滚翻',
          value: 2
        },
        {
          label: '自翻',
          value: 3
        },
        {
          label: '单面',
          value: 4
        }
      ],
      holdPlaceOptions: [
        {
          label: '靠上',
          value: 0
        },
        {
          label: '靠下',
          value: 1
        },
        {
          label: '靠左',
          value: 2
        },
        {
          label: '靠右',
          value: 3
        }
      ],
      paperCutInfoOption: [],
      machineOption: [],

      confirmdialog: false,
      listLoading: false,
      tableData: []
    }
  },
  mounted() {
    this.getList()
    this.getPaperCutInfo()
    this.getMachineInfo()
    if (this.$route.query.type === undefined) {
      this.webType = true
    } else {
      this.webType = false
    }
  },
  methods: {
    // 获取列表
    getList() {
      const _that = this
      _that.listLoading = true
      var params = _that.search
      var data = {
        'params': JSON.stringify(params)
      }
      // console.log(data);
      getPlateSizeTemplateList(data).then(response => {
        // console.log('获取版芯档案列表',response)
        const data = response.data
        // //  组合表单数据
        _that.tableData = data
        // _that.listData.total = response.total
        // console.log(_that.tableData)
        _that.listLoading = false
      }).catch(err => {
        _that.$message.error(err)
        _that.listLoading = false
      })
    },

    // 获取纸张开数列表
    getPaperCutInfo() {
      const _that = this
      var data = {}
      getInfo(data).then(response => {
        const data = response.data
        console.log(data)
        _that.paperCutInfoOption = data
        // eslint-disable-next-line handle-callback-err
      }).catch(err => {
        _that.listLoading = false
      })
    },
    // 获取机型列表
    getMachineInfo() {
      const _that = this
      var data = {}
      getPrinterNameList(data).then(response => {
        const data = response.data
        console.log(data)
        _that.machineOption = data
        // eslint-disable-next-line handle-callback-err
      }).catch(err => {
        _that.listLoading = false
      })
    },

    // 增加固定区域
    addFixedItem() {
      const _that = this
      var fixedItem = {
        startPos: '',
        endPos: ''
      }
      _that.form.fixedItemList.push(fixedItem)
    },
    deleteFixedItem(scope) {
      this.form.fixedItemList.splice(scope.$index, 1)
    },
    // 增加拼版区域
    addRegionItem() {
      const _that = this
      var regionItem = {
        regionLeftX: '',
        regionLeftY: '',
        regionBottomX: '',
        regionBottomY: '',
        knifeKind: '',
        modWidthFixed: '',
        orderIndex: ''
      }
      _that.form.regionItemList.push(regionItem)
    },
    // 删除拼版区域
    deleteRegionItem(scope) {
      this.form.regionItemList.splice(scope.$index, 1)
    },

    // 增加版芯档案
    handleCreateAdd() {
      // 增加系统目录
      const _that = this
      _that.form = Object.assign({}, form)
      _that.form.fixedItemList = []
      _that.form.regionItemList = []
      _that.dialogTitle = '增加版芯档案'
      _that.activeName = 'first'
      _that.dialogStatus = '1'
      _that.dialogVisible = true
    },
    // 刷新变革
    tableRefresh() {
      // 刷新变革
      this.getList()
    },
    // 增加版芯档案
    addBtn() {
      const _that = this
      var info = JSON.stringify(_that.form)
      var data = {
        'sizeTemplate': info
      }
      // console.log(data);
      // return

      addPlateSizeTemplate(data).then(res => {
        // console.log(res);
        if (res.httpCode == 200) {
          _that.dialogVisible = false
          _that.$message({
            message: '增加成功',
            type: 'success'
          })
          _that.tableRefresh()
        } else {
          _that.$message.error(res.msg)
        }
      }).catch(err => {
        _that.$message.error(err)
        _that.dialogVisible = true
      })
    },

    getPlateSizeTemplate(id) {
      var _that = this
      var data = {
        idTemplate: id
      }

      getPlateSizeTemplateInfo(data).then(res => {
        console.log('获取信息', res)
        const data = res.data
        _that.form = {
          id: data.id,
          templateName: data.templateName, // 模板名称,
          plateSize: data.plateSize, // 版芯尺寸,
          paperCutSize: data.paperCutSize, // 开纸尺寸,
          idPaperCutInfo: data.idPaperCutInfo, // 纸张开数/选择纸张开数id,
          faceCount: data.faceCount, // 面数/下拉选择 1=单面 2=双面,
          trunKind: data.trunKind, // 翻版方式/下拉选择 4=单面 1=正反 3=自翻 2=滚翻,
          holdPlace: data.holdPlace, // 咬口/下拉选择 1=靠下 0=靠上 2=靠左 3=靠右,
          sidePlace: data.sidePlace, // 侧规/下拉选择 0=靠身 1=靠外,
          materialSize: data.materialSize, // 版材尺寸,
          idMachineInfo: data.idMachineInfo, // 默认机型/从机型档案中选择,
          modWidthFixed: data.modWidthFixed, // 固定长边/用于按模拼版,
          pageBlankTop: data.pageBlankTop, // 页面留白-上,
          pageBlankLeft: data.pageBlankLeft, // 页面留白-左,
          pageBalnkBottom: data.pageBalnkBottom, // 页面留白-下,
          pageBlankRight: data.pageBlankRight, // 页面留白-右,
          plateWithRegionFlag: data.plateWithRegionFlag, // 按拼版区域进行组版,
          exchangeHoldPlace: data.exchangeHoldPlace, // 上下咬口调换,
          distanceHoldVertocal: data.distanceHoldVertocal, // 垂直十字线-距咬口,
          distancePlateVertocal: data.distancePlateVertocal, // 垂直十字线-距页面,
          distanceWidthVertocal: data.distanceWidthVertocal, // 垂直十字线-水平尺寸,
          distanceHeightVertocal: data.distanceHeightVertocal, // 垂直十字线-垂直尺寸,
          distanceHoldHorizontal: data.distanceHoldHorizontal, // 水平十字线-距咬口,
          distancePlateHorizontal: data.distancePlateHorizontal, // 水平十字线-距页面,
          distanceWidthHorizontal: data.distanceWidthHorizontal, // 水平十字线-水平尺寸,
          distanceHeightHorizontal: data.distanceHeightHorizontal, // 水平十字线-垂直尺寸,
          drawTChiPDF: data.drawTChiPDF, // 绘制梯尺,
          tchiPDFFile: data.tchiPDFFile, // 梯尺文件名,
          tchiPDFSize: data.tchiPDFSize, // 梯尺尺寸,
          fixedSizeDirection: data.fixedSizeDirection, // 固定区域-裁切方向,
          fixedItemList: data.fixedItemList, // 固定区域子表,
          regionItemList: data.regionItemList // 拼版区域子表,
        }
        if ( data.exchangeHoldPlace == 1) {
          _that.form.exchangeHoldPlace = true
        } else {
          _that.form.exchangeHoldPlace = false
        }
        if ( data.plateWithRegionFlag == 1) {
          _that.form.plateWithRegionFlag = true
        } else {
          _that.form.plateWithRegionFlag = false
        }
        if ( data.drawTChiPDF == 1) {
          _that.form.drawTChiPDF = true
        } else {
          _that.form.drawTChiPDF = false
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    // 唤起修改
    handleUpdate(row) {
      const _that = this
      _that.form = Object.assign({}, form)
      _that.form.fixedItemList = []
      _that.form.regionItemList = []
      _that.activeName = 'first'

      _that.dialogTitle = '修改版芯档案'
      _that.dialogVisible = true
      _that.dialogStatus = '2'

      var idPrint = row.id
      _that.getPlateSizeTemplate(idPrint)
    },
    // 修改版芯档案
    editBtn() {
      const _that = this
      var info = JSON.stringify(_that.form)
      var data = {
        'sizeTemplate': info
      }

      updatePlateSizeTemplate(data).then(res => {
        // console.log(res);
        if (res.httpCode == 200) {
          _that.dialogVisible = false
          _that.$message({
            message: '修改成功',
            type: 'success'
          })
          _that.tableRefresh()
        } else {
          _that.$message.error(res.msg)
        }
      }).catch(err => {
        _that.$message.error(err)
        _that.dialogVisible = true
      })
    },

    // 启用禁用
    editStatus(id, status) {
      var _that = this
      var printerTypeInfo = {
        id: id,
        voidFlag: status
      }
      var params = {
        'sizeTemplate': JSON.stringify(printerTypeInfo)
      }

      var url = '/doc/voidPlateSizeTemplate'
      _that.$refs.confirmDialog.updataClick(params, url)
    },

    // 搜索
    searchData() {
      this.getList()
    },

    // 行内编辑
    handleCurrentChange(row, event, column) {
      // console.log(row, event, column, event.currentTarget);
    },
    handleEdit(index, row) {
      // console.log('修改行内');
      // console.log(index, row);
      var _that = this
      // _that.getPaper(row.id);
      var data = {
        'id': row.id,
        'paperPrice': row.paperPrice
      }
      // console.log('修改后form',_that.form);return;
      savePaperInfoPrice(data).then(res => {
        // console.log(res);
        if (res.httpCode == 200) {
          _that.$message({
            message: '修改成功',
            type: 'success'
          })
          _that.tableRefresh()
        } else {
          _that.$message.error(res.msg)
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    // 弹窗内选择操作
    chooseThis(row) {
      // console.log('点击选择');
      this.$emit('choosePaper', row)
    },
    ERPChoose(row) {
      // this.$message.error(row)
      dyERP.sendJson(JSON.stringify(row))
    }

  }
}
</script>
<style>
/*处理input type = number的上下箭头*/
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}
input[type="number"]{
  -moz-appearance: textfield;
}
</style>
<style lang="scss" scoped>
.filter-container {
  margin-bottom: 15px;
}

.tb-edit .el-input {
  display: none
}
.tb-edit .current-row .el-input {
  display: block
}
.tb-edit .current-row .el-input+span {
  display: none
}

</style>

