<template>
  <div class="app-container">
    <el-card>
      <el-row>
        <!--<span>部门名称:</span>-->
        <!--<el-select v-model="DepartmentValue" style="width:200px" placeholder="请选择" size="small" clearable @change="searchMaterialCategory">-->
        <!--<el-option-->
        <!--v-for="item in Department"-->
        <!--:key="item.value"-->
        <!--:label="item.label"-->
        <!--:value="item.value">-->
        <!--</el-option>-->
        <!--</el-select>-->
        <span>物料类别:</span>
        <el-select
          v-model="MaterialCategoryValue"
          style="width:200px"
          placeholder="请选择"
          size="small"
          clearable
          @change="searchMaterialVariety">
          <el-option
            v-for="item in MaterialCategory"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <span>物料品种:</span>
        <el-select
          v-model="MaterialVarietyValue"
          style="width:200px"
          placeholder="请选择"
          size="small"
          clearable
          @change="searchMaterial">
          <el-option
            v-for="item in MaterialVariety"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <el-button
          type="warning"
          icon="el-icon-refresh"
          size="small"
          style="margin-left: 15px"
          @click="CategoryMaintenance">维护物料类别
        </el-button>
      </el-row>
      <el-row>
        <span>物料名称:</span>
        <el-input v-model="MaterialName" placeholder="物料名称" size="small" clearable style="margin-top: 15px;width:200px"/>
        <span>物料全称:</span>
        <el-input
          v-model="FullNameOfMaterial"
          placeholder="物料全称"
          size="small"
          clearable
          style="margin-top: 15px;width:200px"/>
        <span>物料规格:</span>
        <el-input
          v-model="MaterialSpecification"
          placeholder="物料规格"
          size="small"
          clearable
          style="margin-top: 15px;width:200px"/>
        <span>物料型号:</span>
        <el-input
          v-model="MaterialModel"
          placeholder="物料型号"
          size="small"
          clearable
          style="margin-top: 15px;width:200px"/>
      </el-row>
      <el-row>
        <span>计算单位:</span>
        <el-select
          v-model="MeasurementUnitValue"
          style="margin-top: 15px;width:200px"
          placeholder="请选择"
          size="small"
          clearable>
          <el-option
            v-for="item in MeasurementUnit"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <span>物料来源:</span>
        <el-select
          v-model="MaterialSourceValue"
          style="margin-top: 15px;width:200px"
          placeholder="请选择"
          size="small"
          clearable>
          <el-option
            v-for="item in MaterialSource"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <span style="margin-left: 25px">供货商:</span>
        <el-input
          v-model="supplier"
          placeholder="供货商"
          size="small"
          clearable
          style="margin-top: 15px;width:200px"
          @dblclick.native="param=0;openSupplier()"/>
        <el-button
          type="success"
          icon="el-icon-search"
          size="small"
          style="margin-top: 15px;margin-left: 15px"
          @click="pageCurrent=1;searchMaterial()">查询
        </el-button>
        <el-button type="primary" icon="el-icon-circle-plus-outline" size="small" @click="handleAdd()">增加</el-button>
      </el-row>
    </el-card>

    <el-card style="margin-top: 15px">
      <el-table
        :data="tableData"
        style="width: 100%"
        height="440"
        size="mini"
        highlight-current-row
        border>
        <el-table-column align="center" label="物料名称">
          <template slot-scope="scope">
            {{ scope.row.物料名称 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="物料规格">
          <template slot-scope="scope">
            {{ scope.row.物料规格 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="物料型号">
          <template slot-scope="scope">
            {{ scope.row.物料型号 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="供货商">
          <template slot-scope="scope">
            {{ scope.row.供货商 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="参考价格">
          <template slot-scope="scope">
            {{ scope.row.参考价格 }}
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" align="center" width="200">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              icon="el-icon-edit"
              @click="handleEdit(scope.row)">编辑
            </el-button>
            <el-button
              size="mini"
              type="danger"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)">删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="pageCurrent"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="pageSize"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/>
      </div>
    </el-card>

    <el-dialog :visible.sync="dialogFormVisible" title="选择供货商" center width="400px">
      <el-input v-model="supplier1" placeholder="供货商" size="small" clearable style="width:200px"/>
      <el-button
        type="success"
        icon="el-icon-search"
        size="small"
        style="margin-left: 15px; margin-bottom: 10px"
        @click="pageCurrent1=1;searchSupplier()">查询
      </el-button>
      <el-table
        :data="tableData1"
        size="mini"
        highlight-current-row
        border
        @row-click="selectSupplier">
        <el-table-column align="center" label="供货商">
          <template slot-scope="scope">
            {{ scope.row.供货商 }}
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="pageCurrent1"
          :page-sizes="[10, 20, 30]"
          :page-size="pageSize1"
          :total="total1"
          small
          layout="sizes, prev, pager, next"
          @size-change="handleSizeChange1"
          @current-change="handleCurrentChange1"/>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitSupplier">提交</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="title" :visible.sync="dialogFormVisible1" center style="min-height: 300px" width="800px">
      <el-form ref="form" :model="form" :rules="rules" label-position="left" label-width="110px" class="demo-ruleForm">
        <el-row>
          <el-col :span="12">
            <el-form-item label="物料类别" prop="物料类别流水号">
              <el-select
                v-model="form.物料类别流水号"
                style="width:200px"
                placeholder="请选择"
                size="small"
                clearable
                @change="searchMaterialVariety1">
                <el-option
                  v-for="item in MaterialCategory1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料品种" prop="物料品种流水号">
              <el-select v-model="form.物料品种流水号" style="width:200px" placeholder="请选择" size="small" clearable>
                <el-option
                  v-for="item in MaterialVariety1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="物料名称" prop="物料名称">
              <el-input v-model="form.物料名称" placeholder="物料名称" size="small" clearable style="width:200px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料全名" prop="物料全名">
              <el-input v-model="form.物料全名" placeholder="物料全名" size="small" clearable style="width:200px"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="物料规格" prop="物料规格">
              <el-input v-model="form.物料规格" placeholder="物料规格" size="small" clearable style="width:200px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料型号" prop="物料型号">
              <el-input v-model="form.物料型号" placeholder="物料型号" size="small" clearable style="width:200px"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="计量单位" prop="计量单位流水号">
              <el-select v-model="form.计量单位流水号" style="width:200px" placeholder="请选择" size="small">
                <el-option
                  v-for="item in MeasurementUnit"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料来源" prop="物料来源流水号">
              <el-select v-model="form.物料来源流水号" style="width:200px" placeholder="请选择" size="small">
                <el-option
                  v-for="item in MaterialSource"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="供货商" prop="供货商">
              <el-input
                v-model="form.供货商"
                placeholder="供货商"
                size="small"
                clearable
                style="width:200px"
                @click.native="param=1;openSupplier()"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel('form')">取消</el-button>
        <el-button v-show="title==='增加'" type="primary" @click="submitAdd('form')">确定</el-button>
        <el-button v-show="title==='编辑'" type="primary" @click="submitEdit('form')">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogFormVisible2" title="物料类别维护" center width="1200px">
      <div style="width: 47%;display: inline-block">
        <el-card>
          <span>物料类别:</span>
          <el-input v-model="MaterialCategory2" placeholder="物料类别" size="mini" clearable style="width:100px"/>
          <span>类别编号:</span>
          <el-input v-model="CategoryNumber" placeholder="类别编号" size="mini" clearable style="width:100px"/>
          <el-button type="primary" size="mini" style="margin-left: 10px" @click="handleAdd1">增加</el-button>
          <el-button type="warning" size="mini" @click="handleEdit1">编辑</el-button>
          <br>
        </el-card>
        <el-card>
          <el-table
            :data="tableData2"
            size="mini"
            height="328"
            highlight-current-row
            border
            @row-click="selectMaterialCategory">
            <el-table-column align="center" label="物料类别">
              <template slot-scope="scope">
                {{ scope.row.物料类别 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="类别编号">
              <template slot-scope="scope">
                {{ scope.row.类别编号 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="ID">
              <template slot-scope="scope">
                {{ scope.row.物料类别ID }}
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="danger"
                  @click="handleDelete1(scope.row)">删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </div>
      <div style="width: 49%;display: inline-block;margin-left: 20px">
        <el-card>
          <span>品种编号:</span>
          <el-input v-model="VarietyNumber" placeholder="品种编号" size="mini" clearable style="width:100px"/>
          <span>物料品种:</span>
          <el-input v-model="MaterialVariety2" placeholder="物料品种" size="mini" clearable style="width:100px"/>
          <span>规格1:</span>
          <el-input v-model="Specifications1" placeholder="规格1" size="mini" clearable style="width:100px"/>
          <br>
          <span style="margin-left: 30px">规格2:</span>
          <el-input v-model="Specifications2" placeholder="规格2" size="mini" clearable style="width:100px"/>
          <el-button type="primary" size="mini" style="margin-left: 10px" @click="handleAdd2">增加</el-button>
          <el-button type="warning" size="mini" @click="handleEdit2">编辑</el-button>
        </el-card>
        <el-card>
          <el-table
            :data="tableData3"
            size="mini"
            height="300"
            highlight-current-row
            border
            @row-click="selectMaterialVariety">
            <el-table-column align="center" label="品种编号">
              <template slot-scope="scope">
                {{ scope.row.品种编号 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="物料品种">
              <template slot-scope="scope">
                {{ scope.row.物料品种 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="规格1">
              <template slot-scope="scope">
                {{ scope.row.规格1 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="规格2">
              <template slot-scope="scope">
                {{ scope.row.规格2 }}
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="danger"
                  @click="handleDelete2(scope.row)">删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import {
  initDepartmentName,
  initMaterialCategory,
  initMaterialVariety,
  initMeasurementUnit,
  initMaterialSource,
  searchmaterial,
  getSupplier,
  addData,
  editData,
  deleteData,
  searchCategory,
  searchVarieties,
  editCategory,
  addCategory,
  deleteCategory,
  editVariety,
  addVariety,
  deleteVariety
} from '@/api/PurchasingCenter/MaterialManagement'

export default {
  data() {
    return {
      DepartmentValue: '', // 部门名称
      Department: [], // 部门数组
      MaterialCategoryValue: '', // 物料类别
      MaterialCategory: [], // 物料类别数组
      MaterialVarietyValue: '', // 物料品种
      MaterialVariety: [], // 物料品种数组
      MaterialName: '', // 物料名称
      FullNameOfMaterial: '', // 物料全称
      MaterialSpecification: '', // 物料规格
      MaterialModel: '', // 物料型号
      MeasurementUnitValue: '', // 计量单位
      MeasurementUnit: [], // 计量单位数组
      MaterialSourceValue: '', // 物料来源
      MaterialSource: [], // 物料来源数组
      supplier: '', // 供货商
      supplier1: '', // 供货商（弹框）
      supplierValue: '', // 供货商流水号
      ReferencePrice: '', // 参考价格
      supplierValue1: '',
      MaterialCategory1: [],
      MaterialVariety1: [],
      MaterialCategory2: '', // 物料类别
      CategoryNumber: '', // 类别编号
      VarietyNumber: '', // 品种编号
      MaterialVariety2: '', // 物料品种
      Specifications1: '', // 规格1
      Specifications2: '', // 规格2
      MaterialCategoryNum: '', // 物料类别流水号
      MaterialVarietyNum: '', // 物料品种流水号
      param: 0,
      tableData: [],
      pageCurrent: 1,
      pageSize: 10,
      total: null,
      tableData1: [],
      pageCurrent1: 1,
      pageSize1: 10,
      total1: null,
      tableData2: [],
      tableData3: [],
      dialogFormVisible: false,
      dialogFormVisible1: false,
      dialogFormVisible2: false,
      check1: '',
      check2: '',
      check3: '',
      check4: '',
      check5: '',
      check6: '',
      check7: '',
      check8: '',
      check9: '',
      check10: '',
      title: '',
      form: {
        物料流水号: '',
        物料类别流水号: '',
        物料品种流水号: '',
        物料名称: '',
        物料全名: '',
        物料规格: '',
        物料型号: '',
        计量单位流水号: '',
        物料来源流水号: '',
        供货商: ''
      },
      rules: {
        物料名称: [{ required: true, message: '请输入物料名称', trigger: 'blur' }],
        供货商: [{ required: true, message: '请选择供货商', trigger: 'change' }],
        物料类别流水号: [{ required: true, message: '请选择物料类别', trigger: 'change' }],
        物料品种流水号: [{ required: true, message: '请选择物料品种', trigger: 'change' }],
        计量单位流水号: [{ required: true, message: '请选择计量单位', trigger: 'change' }],
        物料来源流水号: [{ required: true, message: '请选择物料来源', trigger: 'change' }]
      }
    }
  },
  created() {
    this.fetchData()
    this.searchMaterialCategory()
  },
  methods: {
    fetchData() {
      this.getSelect(initDepartmentName, ['物料部门名称', '物料部门流水号'], 'Department') // 物料部门
      this.getSelect(initMeasurementUnit, ['计量单位', '计量单位流水号'], 'MeasurementUnit') // 计量单位
      this.getSelect(initMaterialSource, ['物料来源', '物料来源流水号'], 'MaterialSource') // 物料来源
    },
    searchMaterialCategory() { // 获取物料类别
      this.MaterialCategory = []
      this.MaterialVariety = []
      this.MaterialCategoryValue = ''
      this.MaterialVarietyValue = ''
      this.getSelect(initMaterialCategory, ['物料类别', '物料类别流水号'], 'MaterialCategory', [0, this.DepartmentValue])
    },
    searchMaterialVariety() { // 初始化物料品种
      this.MaterialVariety = []
      this.MaterialVarietyValue = ''
      this.getSelect(initMaterialVariety, ['物料品种', '物料品种流水号'], 'MaterialVariety', this.MaterialCategoryValue)
    },
    searchMaterial() { // 物料查询
      this.MaterialName !== '' ? this.check1 = 1 : this.check1 = 0 // 物料名称
      this.FullNameOfMaterial !== '' ? this.check2 = 1 : this.check2 = 0 // 物料全称
      this.MaterialSpecification !== '' ? this.check3 = 1 : this.check3 = 0 // 物料规格
      this.MaterialModel !== '' ? this.check4 = 1 : this.check4 = 0 // 物料型号
      this.MaterialCategoryValue !== '' ? this.check5 = 1 : this.check5 = 0 // 物料类别
      this.MaterialVarietyValue !== '' ? this.check6 = 1 : this.check6 = 0 // 物料品种
      this.MeasurementUnitValue !== '' ? this.check7 = 1 : this.check7 = 0 // 计量单位
      this.MaterialSourceValue !== '' ? this.check8 = 1 : this.check8 = 0 // 物料来源
      this.supplier !== '' ? this.check9 = 1 : this.check9 = 0 // 供货商
      searchmaterial(this.check1, this.MaterialName, this.check2, this.FullNameOfMaterial, this.check3, this.MaterialSpecification, this.check4, this.MaterialModel, this.pageCurrent, this.pageSize, this.check5, this.MaterialCategoryValue, this.check6, this.MaterialVarietyValue, this.check7, this.MeasurementUnitValue, this.check8, this.MaterialSourceValue, this.check9, this.supplierValue).then(response => {
        this.tableData = response.data.result
        this.total = parseInt(response.data.output[0].ItemCount)
      })
    },
    openSupplier() {
      this.dialogFormVisible = true
      this.supplier1 = ''
      this.check10 = 0
      this.pageCurrent1 = 1
      this.pageSize1 = 10
      this.getTable(getSupplier, [this.check10, this.supplier1, this.pageCurrent1, this.pageSize1], ['tableData1', 'total1'])
    },
    searchSupplier() {
      this.supplier1 !== '' ? this.check10 = 1 : this.check10 = 0
      this.getTable(getSupplier, [this.check10, this.supplier1, this.pageCurrent1, this.pageSize1], ['tableData1', 'total1'])
    },
    selectSupplier(row) {
      if (this.param === 0) {
        this.supplierValue = row.供货商流水号
      } else if (this.param === 1) {
        this.supplierValue1 = row.供货商流水号
      }
      this.supplier1 = row.供货商
    },
    submitSupplier() {
      if (this.param === 0) {
        this.supplier = this.supplier1
      } else if (this.param === 1) {
        this.form.供货商 = this.supplier1
      }
      this.dialogFormVisible = false
    },
    cancel() { // 取消
      this.dialogFormVisible1 = false
    },
    searchMaterialVariety1() { // 物料品种
      this.MaterialVariety1 = []
      this.form.物料品种流水号 = ''
      this.getSelect(initMaterialVariety, ['物料品种', '物料品种流水号'], 'MaterialVariety1', this.form.物料类别流水号)
    },
    handleEdit(row) {
      this.supplierValue1 = ''
      this.MaterialCategory1 = []
      this.MaterialVariety1 = []
      this.supplierValue1 = row.供货商流水号
      this.getSelect(initMaterialCategory, ['物料类别', '物料类别流水号'], 'MaterialCategory1')
      this.getSelect(initMaterialVariety, ['物料品种', '物料品种流水号'], 'MaterialVariety1', row.物料类别流水号)
      this.editForm(row, 'form', [this.title = '编辑', this.dialogFormVisible1 = true])
    },
    submitEdit() {
      this.editTable(editData, [this.form.物料流水号, this.form.物料品种流水号, this.form.物料名称, this.form.物料全名, this.form.物料规格, this.form.物料型号, this.form.计量单位流水号, this.form.物料来源流水号, this.supplierValue1], 'form', function() {
        this.searchMaterial()
        this.dialogFormVisible1 = false
      })
    },
    handleAdd() {
      this.supplierValue1 = ''
      this.MaterialCategory1 = []
      this.MaterialVariety1 = []
      this.getSelect(initMaterialCategory, ['物料类别', '物料类别流水号'], 'MaterialCategory1')
      this.addForm('form', [this.dialogFormVisible1 = true, this.title = '增加'])
    },
    submitAdd() { // 提交增加
      this.addTable(addData, [this.form.物料品种流水号, this.form.物料名称, this.form.物料全名, this.form.物料规格, this.form.物料型号, this.form.计量单位流水号, this.form.物料来源流水号, this.supplierValue1], 'form', function() {
        this.dialogFormVisible1 = false
        this.searchMaterial()
      })
    },
    handleDelete(row) { // 删除
      this.deleteRow(deleteData, row.物料流水号, function() {
        this.searchMaterial()
      })
    },
    CategoryMaintenance() {
      this.dialogFormVisible2 = true
      this.getData(searchCategory, 'tableData2')
    },
    selectMaterialCategory(row) {
      this.MaterialCategory2 = row.物料类别
      this.CategoryNumber = row.类别编号
      this.MaterialCategoryNum = row.物料类别流水号
      this.getData(searchVarieties, 'tableData3', row.物料类别流水号)
    },
    selectMaterialVariety(row) {
      this.MaterialVarietyNum = row.物料品种流水号
      this.VarietyNumber = row.品种编号
      this.MaterialVariety2 = row.物料品种
      this.Specifications1 = row.规格1
      this.Specifications2 = row.规格2
    },
    handleEdit1() {
      editCategory(this.MaterialCategoryNum, this.MaterialCategory2, this.CategoryNumber).then(response => {
        if (response.data[0].result === '1') {
          this.$message.success('编辑成功')
          this.getData(searchCategory, 'tableData2')
          this.tableData3 = []
        } else {
          this.$message.error('编辑失败')
        }
      })
    },
    handleAdd1() {
      addCategory(this.MaterialCategory2, this.CategoryNumber).then(response => {
        if (response.data[0].result === '1') {
          this.$message.success('增加成功')
          this.getData(searchCategory, 'tableData2')
          this.tableData3 = []
        } else {
          this.$message.error('增加失败')
        }
      })
    },
    handleDelete1(row) {
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteCategory(row.物料类别流水号).then(response => {
          if (response.data[0].result === '1') {
            this.$message.success('删除成功')
            this.getData(searchCategory, 'tableData2')
            this.tableData3 = []
          } else {
            this.$message.error('删除失败')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    handleEdit2() {
      editVariety(this.MaterialVarietyNum, this.MaterialCategoryNum, this.MaterialVariety2, this.VarietyNumber, this.Specifications1, this.Specifications2).then(response => {
        if (response.data[0].result === '1') {
          this.$message.success('编辑成功')
          this.getData(searchVarieties, 'tableData3', this.MaterialCategoryNum)
        } else {
          this.$message.error('编辑失败')
        }
      })
    },
    handleAdd2() {
      addVariety(this.MaterialCategoryNum, this.MaterialVariety2, this.VarietyNumber, this.Specifications1, this.Specifications2).then(response => {
        if (response.data[0].result === '1') {
          this.$message.success('增加成功')
          this.getData(searchVarieties, 'tableData3', this.MaterialCategoryNum)
        } else {
          this.$message.error('增加失败')
        }
      })
    },
    handleDelete2(row) {
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteVariety(row.物料品种流水号).then(response => {
          if (response.data[0].result === '1') {
            this.$message.success('删除成功')
            this.getData(searchVarieties, 'tableData3', this.MaterialCategoryNum)
          } else {
            this.$message.error('删除失败')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.pageCurrent = 1
      this.searchMaterial()
    },
    handleCurrentChange(val) {
      this.pageCurrent = val
      this.searchMaterial()
    },
    handleSizeChange1(val) {
      this.pageSize1 = val
      this.pageCurrent1 = 1
      this.supplier1 !== '' ? this.check10 = 1 : this.check10 = 0
      this.getTable(getSupplier, [this.check10, this.supplier1, this.pageCurrent1, this.pageSize1], ['tableData1', 'total1'])
    },
    handleCurrentChange1(val) {
      this.pageCurrent1 = val
      this.supplier1 !== '' ? this.check10 = 1 : this.check10 = 0
      this.getTable(getSupplier, [this.check10, this.supplier1, this.pageCurrent1, this.pageSize1], ['tableData1', 'total1'])
    }
  }
}
</script>

<style scoped>
  span {
    margin: 10px 0px 10px 10px;
  }
</style>
