
<template>
  <div class="mod-config">
    <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
      <el-form-item :label="'工厂编码：'">
        <el-input v-model="searchData.site" style="width: 130px"></el-input>
      </el-form-item>
      <el-form-item :label="'生产订单号：'">
        <el-input v-model="searchData.orderNo" style="width: 130px"></el-input>
      </el-form-item>
      <el-form-item :label="'订单日期：'">
        <el-date-picker
          style="width: 130px"
          v-model="searchData.date1"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="'至：'">
        <el-date-picker
          style="width: 130px"
          v-model="searchData.date2"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="'是否分卷：'">
        <el-select filterable v-model="searchData.slittedFlag" style="width: 130px">
          <el-option label="是" value="Y"></el-option>
          <el-option label="否" value="N"></el-option>
        </el-select>
        <el-button @click="getData()" type="primary" style="margin-left: 10px;margin-top: 0px">{{'查询'}}</el-button>
        <download-excel
          :fields="fields()"
          :data="exportData"
          type="xls"
          :name="exportName"
          :header="exportHeader"
          :footer="exportFooter"
          :fetch="createExportData"
          :before-generate="startDownload"
          :before-finish="finishDownload"
          worksheet="导出信息"
          class="el-button el-button--primary el-button--medium">
          {{ buttons.download }}
        </download-excel>
      </el-form-item>
    </el-form>
    <el-table
      :height="height"
      :data="dataList"
      border
      v-loading="dataListLoading"
      style="width: 100%;">
      <el-table-column
        header-align="center"
        align="center"
        width="70"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" @click="showModel(scope.row)">创建卷</a>
        </template>
      </el-table-column>
      <el-table-column
        v-for="(item,index) in columnList" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed==''?false:item.fixed"
        :width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                             style="width: 100px; height: 80px"/></span>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog width="800px" :title="'创建分卷'" :close-on-click-modal="false" v-drag :visible.sync="modelFlag">
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -10px;">
        <el-form-item :label="'工厂编号：'">
          <el-input v-model="dataForm.site" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="'关联单号1：'">
          <el-input v-model="dataForm.orderNo" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="'关联单号3：'">
          <el-input v-model="dataForm.orderItemNo" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item style="margin-top: 30px">
          <el-button @click="saveCRoll()" type="primary" style="width: 108px;margin-left: 142px;">创建</el-button>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
        <el-form-item :label="'供应商编号：'">
          <el-input v-model="dataForm.supplierID" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="'供应商名称：'">
          <el-input v-model="dataForm.supplierName" readonly style="width: 255px;"></el-input>
        </el-form-item>
        <el-form-item style="margin-top: 30px">
          <el-button @click="modelFlag=false" type="primary" style="width: 108px;margin-left: 142px;">关闭</el-button>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
        <el-form-item :label="'物料编码：'">
          <el-input v-model="dataForm.partNo" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="'物料名称：'">
          <el-input v-model="dataForm.partDescription" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="'规格型号：'">
          <el-input v-model="dataForm.spec" readonly style="width: 180px;"></el-input>
        </el-form-item>
        <el-form-item style="margin-top: 30px">
          <el-button @click="getSaveModel()" type="primary" style="margin-left: 82px;">供应商批号录入</el-button>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
        <el-form-item :label="'接收日期：'">
          <el-date-picker
            style="width: 120px"
            v-model="dataForm.receive"
            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="'送货单号：'">
          <el-input v-model="dataForm.suppDeliveryNote" disabled style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="'订单数量：'">
          <el-input v-model="dataForm.quantity" readonly style="width: 120px;"></el-input>
        </el-form-item>

      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
        <el-form-item :label="'每卷数量：'">
          <el-input v-model="dataForm.rollQty" type="number" style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="'卷数：'">
          <el-input v-model="dataForm.rollNumber" type="number" style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item style="margin-top: 30px">
          <el-button @click="insertData()" type="primary">插入</el-button>
          <el-checkbox style="margin-left: 108px" v-model="dataForm.checked">自动打印标签</el-checkbox>
        </el-form-item>
        <el-form-item :label="'材料编码：'">
          <el-input v-model="dataForm.sOPartNo" style="width: 120px;"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
        <el-form-item >
          <span slot="label" style="" @click="getBaseList(92)"><a herf="#">客户编号：</a></span>
          <el-input v-model="dataForm.customerID" style="width: 120px;" @change="getReferenceData();"></el-input>
        </el-form-item>
        <el-form-item >
          <span slot="label" style="" @click="getBaseList(5)"><a herf="#">产品编码：</a></span>
          <el-input v-model="dataForm.fGPartNo" style="width: 120px;" @change="getReferenceData();"></el-input>
        </el-form-item>
        <el-form-item :label="'参照名称：'">
          <el-input v-model="dataForm.referencePartDesc" readonly style="width: 220px;"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
        <el-form-item :label="'供应商编码：'">
          <el-input v-model="dataForm.supplierID" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="'供应商名称：'">
          <el-input v-model="dataForm.supplierName" readonly style="width: 220px;"></el-input>
        </el-form-item>
      </el-form>
      <el-tabs v-model="activeName" style="font-size: 11px">
        <el-tab-pane label="待分卷" name="first">
          <div style="width: 775px;margin-top: 8px;">
            <div style="width: 40%;float: left">
              <el-table
                height="200"
                :data="dataList1"
                border
                :vertical-align="'middle'"
                style="width: 100%;">
                <el-table-column
                  v-for="(item,index) in columnList1" :key="index"
                  :sortable="item.columnSortable"
                  :prop="item.columnProp"
                  :header-align="item.headerAlign"
                  :show-overflow-tooltip="item.showOverflowTooltip"
                  :align="item.align"
                  :fixed="item.fixed==''?false:item.fixed"
                  :width="item.columnWidth"
                  :label="item.columnLabel">
                  <template slot-scope="scope">
                    <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
                    <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                                       style="width: 100px; height: 80px"/></span>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <div style="width: 58%;float: left">
              <el-table
                height="200"
                :data="dataList2"
                border
                @row-dblclick="changeData"
                :vertical-align="'middle'"
                style="width: 100%;">
                <el-table-column
                  v-for="(item,index) in columnList2" :key="index"
                  :sortable="item.columnSortable"
                  :prop="item.columnProp"
                  :header-align="item.headerAlign"
                  :show-overflow-tooltip="item.showOverflowTooltip"
                  :align="item.align"
                  :fixed="item.fixed==''?false:item.fixed"
                  :width="item.columnWidth"
                  :label="item.columnLabel">
                  <template slot-scope="scope">
                    <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
                    <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                                       style="width: 100px; height: 80px"/></span>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
              <span style="margin-left: 5px">合计：卷数</span>
              <el-input v-model="sum1" style="width: 50px;" readonly></el-input>
              <span>总数量</span>
              <el-input v-model="sum2" style="width: 80px;" readonly></el-input>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane label="已分卷" name="second">
          <div style="width: 760px;margin-top: 0px">
            <el-table
              height="200"
              :data="dataList3"
              border
              :vertical-align="'middle'"
              style="width: 100%;">
              <el-table-column
                v-for="(item,index) in columnList3" :key="index"
                :prop="item.columnProp"
                :header-align="item.headerAlign"
                :align="item.align"
                :vertical-align="'middle'"
                :min-width="item.columnWidth"
                :label="item.columnLabel">
              </el-table-column>
            </el-table>
            <el-form :inline="true" label-position="top" label-width="100px">
              <div style="margin-top: 8px">
                <span style="margin-left: 5px">合计：卷数</span>
                <el-input v-model="sum3" style="width: 50px;" readonly></el-input>
                <span>总卷数量</span>
                <el-input v-model="sum4" style="width: 80px;" readonly></el-input>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane label="出库卷清单" name="third">
          <div style="margin-top: 0px;">
            <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
              <span> {{"卷号"}}:</span>
              <el-input v-model="dataForm2.rollNo" @change="rollNoOut()" style="width: 120px;"></el-input>
              <span>{{"(回车插入记录) 当前卷号："}}:</span>
              <el-input v-model="dataForm2.rollNo2" disabled style="width: 120px;"></el-input>
              <span style="margin-left: 20px"> {{"退料数量"}}:</span>
              <el-input v-model="dataForm2.fTotalQty2" style="width: 100px;"></el-input>
              <el-button @click="checkRoll()"  style="margin-left: 10px;margin-top: 0px">{{'结束卷'}}
              </el-button>
            </el-form>
            <el-table
              :height="210"
              :data="dataList4"
              border
              v-loading="dataListLoading"
              style="width: 100%;">
              <el-table-column
                v-for="(item,index) in columnList4" :key="index"
                :sortable="item.columnSortable"
                :prop="item.columnProp"
                :header-align="item.headerAlign"
                :show-overflow-tooltip="item.showOverflowTooltip"
                :align="item.align"
                :fixed="item.fixed==''?false:item.fixed"
                :width="item.columnWidth"
                :label="item.columnLabel">
                <template slot-scope="scope">
                  <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
                  <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                                     style="width: 100px; height: 80px"/></span>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
      </el-tabs>
      <el-footer style="height:10px;margin-top: 0px;text-align:center">

      </el-footer>
    </el-dialog>
    <el-dialog width="430px" :title="'供应商批号录入'" :close-on-click-modal="false" v-drag :visible.sync="modelFlag2">
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
        <el-form-item :label="'工厂编码：'">
          <el-input v-model="saveData.site" style="width: 80px"></el-input>
        </el-form-item>
        <el-form-item :label="'卷号：'">
          <el-input v-model="saveData.rollNo" style="width: 150px"></el-input>
          <el-button @click="goSaveSuppRollNo()" type="primary" style="margin-left: 10px;">保存</el-button>
          <el-button @click="modelFlag2=false" type="primary" style="margin-left: 10px;">关闭</el-button>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
        <el-form-item :label="'供应商批号：'">
          <el-input v-model="saveData.suppRollNo" style="width: 369px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:10px;margin-top: 20px;text-align:center">
      </el-footer>
    </el-dialog>
    <Chooselist ref="baseList"  @getBaseData="getBaseData"></Chooselist>
  </div>
</template>

<script>
  import Chooselist from '@/views/modules/common/Chooselist'
  import {

    getPartNoDetail,
    checkCustomerID

  } from "@/api/base/site.js"
  import {
    searchSAPSlittedOrder,
    searchCRollInfoDetail,
    saveCRollData,
    saveSuppRollNo,
    doSaveSuppRollNo,
    getTransRoll,
    saveFinishRoll,
    checkFinishRoll,
    saveRollNoOut,
    getReferenceData,
  } from "@/api/purchasingManagement/materialSplit.js"

  export default {
    //查询-SAP分卷订单
    name: "searchSAPSlittedOrder",
    components: {
      Chooselist
    },
    watch: {
      dataForm: {
        deep: true,
        handler: function (newV, oldV) {
          this.dataForm.customerID = this.dataForm.customerID.toUpperCase()
          this.dataForm.fGPartNo = this.dataForm.fGPartNo.toUpperCase()
        }
      }
    },
    data() {
      return {
        tagNo:'',
        // 导出 start
        exportData: [],
        exportName: "SAP分卷订单"+this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["SAP分卷订单"],
        exportFooter: [],
        // 导出 end
        height: 200,
        modelFlag: false,
        modelFlag2: false,
        modelInputFlag: true,
        selectList: [],
        activeName: 'first',
        buttons: {
          download:'导出',
        },
        searchData: {
          site: '',
          orderNo: '',
          date1:new Date(),
          date2:'',
          slittedFlag: 'N',
          user: this.$store.state.user.name
        },
        saveData: {
          site:'',
          rollNo:'',
          suppRollNo:'',
        },
        dataForm2: {
          rollNo: '',
          rollNo2: '',
          fTotalQty2: '',
        },
        dataForm: {
          site: '',
          orderNo: '',
          orderItemNo: '',
          supplierID: '',
          supplierName: '',
          partNo: '',
          partDescription: '',
          spec: '',
          receive: '',
          suppDeliveryNote: '',
          quantity: '',
          rollQty: '',
          rollNumber: '',
          customerID: '',
          fGPartNo: '',
          referencePartDesc: '',
          checked: false,
          referenceSupplierID:'',
          referenceSupplierName:'',
          sOPartNo: '',
        },
        sum1: '',
        sum2: '',
        sum3: '',
        sum4: '',
        columnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TableOrderNo',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "orderNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "生产订单号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TableOrderDate',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "orderDate",
            headerAlign: "center",
            align: "left",
            columnLabel: "订单日期",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TablePlanReceiptDate',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "planReceiptDate",
            headerAlign: "center",
            align: "left",
            columnLabel: "要求交货日期",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TableSupplierID',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "supplierID",
            headerAlign: "center",
            align: "left",
            columnLabel: "供应商编码",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TableStatus',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "status",
            headerAlign: "center",
            align: "left",
            columnLabel: "订单状态",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TableSupplierName',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "supplierName",
            headerAlign: "center",
            align: "left",
            columnLabel: "供应商名称",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 300
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TableOrderItemNo',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "orderItemNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "订单序号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TablePartNo',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "partNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "物料编码",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TablePartDescription',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "partDescription",
            headerAlign: "center",
            align: "left",
            columnLabel: "物料名称",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 300
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TableQuantity',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "quantity",
            headerAlign: "center",
            align: "right",
            columnLabel: "订单数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TableCancelledFlag',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "cancelledFlag",
            headerAlign: "center",
            align: "left",
            columnLabel: "是否取消",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TableSAPOrderNo',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "sAPOrderNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "SAP订单识别号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033TableSite',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单表",
            columnProp: "site",
            headerAlign: "center",
            align: "left",
            columnLabel: "工厂编号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70
          },
        ],
        dataList: [],
        dataList3: [],
        dataList2: [],
        dataList1: [],
        dataList4: [],
        dataListLoading: false,
        columnList1: [
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table1Number',
            tableId: "6033Table1",
            tableName: "查询SAP分卷订单待分卷左表",
            columnProp: "number",
            headerAlign: "center",
            align: "right",
            columnLabel: "次序号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 50
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table1RollQty',
            tableId: "6033Table1",
            tableName: "查询SAP分卷订单待分卷左表",
            columnProp: "rollQty",
            headerAlign: "center",
            align: "right",
            columnLabel: "每卷数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table1RollNumber',
            tableId: "6033Table1",
            tableName: "查询SAP分卷订单待分卷左表",
            columnProp: "rollNumber",
            headerAlign: "center",
            align: "left",
            columnLabel: "卷数",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 50
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table1ALLRollQty',
            tableId: "6033Table1",
            tableName: "查询SAP分卷订单待分卷左表",
            columnProp: "allRollQty",
            headerAlign: "center",
            align: "left",
            columnLabel: "总数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          }
        ],
        columnList2: [
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table2PartNo',
            tableId: "6033Table2",
            tableName: "查询SAP分卷订单待分卷右表",
            columnProp: "partNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "物料编码",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table2PartDescription',
            tableId: "6033Table2",
            tableName: "查询SAP分卷订单待分卷右表",
            columnProp: "partDescription",
            headerAlign: "center",
            align: "left",
            columnLabel: "物料名称",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 168
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table2OrderItemNo',
            tableId: "6033Table2",
            tableName: "查询SAP分卷订单待分卷右表",
            columnProp: "orderItemNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "订单序号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table2Quantity',
            tableId: "6033Table2",
            tableName: "查询SAP分卷订单待分卷右表",
            columnProp: "quantity",
            headerAlign: "center",
            align: "left",
            columnLabel: "订单数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          }
        ],
        columnList3: [
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table3RollNo',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单已分卷表",
            columnProp: "rollNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "卷号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table3RollQty',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单已分卷表",
            columnProp: "rollQty",
            headerAlign: "center",
            align: "right",
            columnLabel: "卷数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table3SuppDeliveryNote',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单已分卷表",
            columnProp: "suppDeliveryNote",
            headerAlign: "center",
            align: "left",
            columnLabel: "供应商送货单号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table3RollDate',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单已分卷表",
            columnProp: "rollDate",
            headerAlign: "center",
            align: "left",
            columnLabel: "入库日期",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table3CreatedDate',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单已分卷表",
            columnProp: "createdDate",
            headerAlign: "center",
            align: "left",
            columnLabel: "分卷日期",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table3CreatedBy',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单已分卷表",
            columnProp: "createdBy",
            headerAlign: "center",
            align: "left",
            columnLabel: "分卷人",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table3SuppRollNoFlag',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单已分卷表",
            columnProp: "suppRollNoFlag",
            headerAlign: "center",
            align: "left",
            columnLabel: "已录入供应商批号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table3SuppRollNo',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单已分卷表",
            columnProp: "suppRollNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "供应商批号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 300
          }
        ],
        columnList4: [
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table4TransNo',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单出库卷清单表",
            columnProp: "transNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "出库单号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table4TransDate',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单出库卷清单表",
            columnProp: "transDate",
            headerAlign: "center",
            align: "left",
            columnLabel: "出库日期",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table4SubNo',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单出库卷清单表",
            columnProp: "subNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "卷号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table4SubQty',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单出库卷清单表",
            columnProp: "subQty",
            headerAlign: "center",
            align: "right",
            columnLabel: "卷数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table4TransTypeDb',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单出库卷清单表",
            columnProp: "transTypeDb",
            headerAlign: "center",
            align: "left",
            columnLabel: "出入库类型",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table4UserName',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单出库卷清单表",
            columnProp: "userName",
            headerAlign: "center",
            align: "left",
            columnLabel: "经手人",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 6033,
            serialNumber: '6033Table4PartNo',
            tableId: "6033Table",
            tableName: "查询SAP分卷订单出库卷清单表",
            columnProp: "partNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "材料编码",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150
          }
        ],
      }
    },
    mounted() {
      this.$nextTick(() => {
        this.height = window.innerHeight - 200;
      })
    },
    methods: {
      getBaseData(val){
        if (this.tagNo === 92){
          this.dataForm.customerID = val.ConfigurationTemplateID
          this.getReferenceData();
        }
        if (this.tagNo === 5){
          this.dataForm.fGPartNo = val.PartNo
          this.getReferenceData();
        }
      },
      // 获取基础数据列表
      getBaseList(val){
        this.tagNo = val
        this.$nextTick(() => {
          let strVal = "";
          if (val === 5){
            strVal = this.dataForm.fGPartNo
          }
          if (val === 92){
            strVal = this.dataForm.customerID
          }
          this.$refs.baseList.init(val,strVal)
        })
      },
      getData() {
        searchSAPSlittedOrder(this.searchData).then(({data}) => {
          this.dataList = data.rows
        })
      },
      showModel(row) {
        this.dataForm2={};
        this.dataList1 = [];
        this.sum1 = 0;
        this.sum2 = 0;
        this.sum3 = 0;
        this.sum4 = 0;
        // this.dataForm = JSON.parse(JSON.stringify(row))
        // this.dataForm.fGPartNo='无';
        // this.dataForm.customerID='无';
        // this.dataForm.suppDeliveryNote='*';
        this.dataForm={
          site: row.site,
          orderNo: row.orderNo,
          orderItemNo: row.orderItemNo,
          supplierID: row.supplierID,
          supplierName: row.supplierName,
          partNo: row.partNo,
          partDescription: row.partDescription,
          spec: row.spec,
          receive: row.receive,
          suppDeliveryNote: '*',
          quantity: row.quantity,
          rollQty: row.rollQty,
          rollNumber: row.rollNumber,
          customerID: '无',
          fGPartNo: '无',
          referencePartDesc: '',
          checked: false,
          sOPartNo: row.sOPartNo,
        };
        var year = new Date().getFullYear(); //获取完整的年份(4位,1970-????)
        var month = new Date().getMonth() + 1; //获取当前月份(0-11,0代表1月)
        var day = new Date().getDate(); //获取当前日(1-31)
        if (month < 10) {
          month = "0" + month;
        }
        if (day < 10) {
          day = "0" + day;
        }
        var dateString = year + "-" + month + "-" + day;
        this.$set(this.dataForm, 'receive', dateString)
        this.getReferenceData();
        let inData = {
          site: row.site,
          orderRef1: row.orderNo,
          orderRef2: row.orderItemNo,
        }
        searchCRollInfoDetail(inData).then(({data}) => {
          this.dataList3 = data.rows
          for (let i = 0; i < data.total; i++) {
            this.sum4 += this.dataList3[i].rollQty;
          }
          this.sum3 = data.total;
        })
        this.getAllThePartNo();
        this.getTransRoll();
        this.modelFlag = true;
      },
      insertData(){
        if (this.dataForm.rollQty == '' || this.dataForm.rollQty == null || this.dataForm.rollQty <= 0) {
          this.$alert("请输入正确的每卷数量！", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if (this.dataForm.rollNumber == '' || this.dataForm.rollQty == null || this.dataForm.rollNumber <= 0) {
          this.$alert("请输入正确的卷数！", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if(this.dataList3.length>0){
          this.$confirm(`该订单已有分切卷，是否继续?`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.insertData2();
          })
        }else {
          this.insertData2();
        }
      },
      insertData2() {


        let newDate = {
          number: this.dataList1.length + 1,
          allRollQty: this.dataForm.rollQty * this.dataForm.rollNumber,
          site: this.dataForm.site,
          rollQty: this.dataForm.rollQty,
          rollNumber: this.dataForm.rollNumber,
          partNo: this.dataForm.partNo,
          supplierID: this.dataForm.supplierID,
          orderRef1: this.dataForm.orderNo,
          orderRef2: this.dataForm.orderNo,
          orderRef3: this.dataForm.orderItemNo,
          orderRef4: 'S',
          // suppDeliveryNote: this.dataForm.suppDeliveryNote,
          rollDate: this.dataForm.receive,
          createdBy: this.$store.state.user.name,
          statusDb: 'I',
          status: '已入库',
          suppRollNoFlag: 'N',
          sourceType: '分切入库',
          rolltype: '合格卷',
          rolltypeDb: 0,
          parttypeFlag: 'R',
          customerID: this.dataForm.customerID,
          refPartDesc:this.dataForm.referencePartDesc,
          refSupplierID:this.dataForm.referenceSupplierID,
          fGPartNo: this.dataForm.fGPartNo,
          orderRef5: this.dataForm.sOPartNo,
        }
        this.dataList1.push(newDate)
        this.sum1 = Number(this.sum1)+  Number(newDate.rollNumber);
        this.sum2 = Number(this.sum2)+ Number(newDate.allRollQty);
      },
      saveCRoll() {
        let inData = {
          site: this.dataForm.site,
          partNo: this.dataForm.fGPartNo
        }
        getPartNoDetail(inData).then(({data}) => {
          if (data.total > 0||this.dataForm.fGPartNo=='无') {
            let inData2 = {
              site: this.dataForm.site,
              configurationTemplateID: this.dataForm.customerID,
            }
            checkCustomerID(inData2).then(({data}) => {
                if (data.total > 0||this.dataForm.customerID=='无') {
        if(this.dataForm2.rollNo2==""||this.dataForm2.rollNo2==null){
          this.$alert("该订单下，该用户下没有扫描出库卷，不能分切  ！", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if (this.dataList1.length == 0) {
          this.$alert("没有待分卷信息！", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if (this.sum2 + this.sum4 < this.dataForm.quantity) {
          this.$confirm(`累计分切数量小于订单数量，是否继续?`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.doSaveCRoll()
          })
        }
        if (this.sum2 + this.sum4 === this.dataForm.quantity){
          this.doSaveCRoll()
        }
        if (this.sum2 + this.sum4 > this.dataForm.quantity) {
          this.$confirm(`累计分切数量大于订单数量，是否继续?`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.doSaveCRoll()
          })
        }
                } else {
                  this.$alert('该客户编号不存在', '错误', {
                    confirmButtonText: '确定'
                  })
                  return false;
                }
            })
          } else {
            this.$alert('该物料编码不存在', '错误', {
              confirmButtonText: '确定'
            })
            return false;
          }
        })
      },
      doSaveCRoll() {
        saveCRollData(this.dataList1).then(({data}) => {
          if (data && data.code == 200) {
            this.dataList1 = [];
            this.sum1 = 0;
            this.sum2 = 0;
            let inData = {
              site: this.dataForm.site,
              orderRef1: this.dataForm.orderNo,
              orderRef3: this.dataForm.orderItemNo,
            }
            searchCRollInfoDetail(inData).then(({data}) => {
              this.dataList3 = data.rows
              for (let i = 0; i < data.total; i++) {
                this.sum4 = Number(this.sum4)+ Number(this.dataList3[i].rollQty);
              }
              this.sum3 = data.total;
            })
            this.$message.success( '操作成功')
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      getPartNo() {
        let inData = {
          site: this.dataForm.site,
          partNo: this.dataForm.fGPartNo
        }
        getPartNoDetail(inData).then(({data}) => {
          if (data.total > 0||this.dataForm.fGPartNo=='无') {
          } else {
            this.dataForm.fGPartNo = '';
            this.dataForm = JSON.parse(JSON.stringify(this.dataForm));
            this.$alert('该物料编码不存在', '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      getCustomerID() {
        let inData = {
          site: this.dataForm.site,
          configurationTemplateID: this.dataForm.customerID,
        }
        checkCustomerID(inData).then(({data}) => {
          if (data.total > 0||this.dataForm.customerID=='无') {
          } else {
            this.dataForm.customerID = '';
            this.dataForm = JSON.parse(JSON.stringify(this.dataForm));
            this.$alert('该客户编号不存在', '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      getAllThePartNo() {
        let list = [];
        for (let i = 0; i < this.dataList.length; i++) {
          if (this.dataList[i].orderNo == this.dataForm.orderNo) {
            list.push(this.dataList[i]);
          }
        }
        this.dataList2 = list;
      },
      //双击切换订单
      changeData(row) {
        if (this.dataList1.length > 0) {
          this.$confirm(`切换订单将会清空待分卷信息，是否继续?`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.sum1 = 0;
            this.sum2 = 0;
            this.sum3 = 0;
            this.sum4 = 0;
            this.dataList1 = [];
            this.dataForm = {
              site: row.site,
              orderNo: row.orderNo,
              orderItemNo: row.orderItemNo,
              supplierID: row.supplierID,
              supplierName: row.supplierName,
              partNo: row.partNo,
              partDescription: row.partDescription,
              spec: row.spec,
              receive: row.receive,
              suppDeliveryNote: '*',
              quantity: row.quantity,
              rollQty: row.rollQty,
              rollNumber: row.rollNumber,
              customerID: '无',
              fGPartNo: '无',
              referencePartDesc: '',
              checked: false,
              sOPartNo: row.sOPartNo,
            };
            this.getReferenceData();
            this.$set(this.dataForm, 'receive', new Date());
            let inData = {
              site: this.dataForm.site,
              orderRef1: this.dataForm.orderNo,
              orderRef3: this.dataForm.orderItemNo,
            }
            searchCRollInfoDetail(inData).then(({data}) => {
              this.dataList3 = data.rows
              for (let i = 0; i < data.total; i++) {
                this.sum4 = Number(this.sum4) +Number(this.dataList3[i].rollQty);
              }
              this.sum3 = data.total;
            })
          })
        } else {
          this.sum1 = 0;
          this.sum2 = 0;
          this.sum3 = 0;
          this.sum4 = 0;
          this.dataList1 = [];
          this.dataForm = {
            site: row.site,
            orderNo: row.orderNo,
            orderItemNo: row.orderItemNo,
            supplierID: row.supplierID,
            supplierName: row.supplierName,
            partNo: row.partNo,
            partDescription: row.partDescription,
            spec: row.spec,
            receive: row.receive,
            suppDeliveryNote: '*',
            quantity: row.quantity,
            rollQty: row.rollQty,
            rollNumber: row.rollNumber,
            customerID: '无',
            fGPartNo: '无',
            referencePartDesc: '',
            checked: false,
            sOPartNo: row.sOPartNo,
          };
          this.getReferenceData();
          this.$set(this.dataForm, 'receive', new Date());
          let inData = {
            site: this.dataForm.site,
            orderRef1: this.dataForm.orderNo,
            orderRef3: this.dataForm.orderItemNo,
          }
          searchCRollInfoDetail(inData).then(({data}) => {
            this.dataList3 = data.rows
            for (let i = 0; i < data.total; i++) {
              this.sum4 += this.dataList3[i].rollQty;
            }
            this.sum3 = data.total;
          })
        }
      },
      //供应商批号录入
      getSaveModel() {
        this.saveData = {
          site:this.$store.state.user.site,
          rollNo:'',
          suppRollNo:''
        };
        this.modelFlag2 = true;
      },
      goSaveSuppRollNo() {
        if (this.saveData.site == '' || this.saveData.site == null) {
          this.$alert("请输入工厂编码！", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if (this.saveData.rollNo == '' || this.saveData.rollNo == null) {
          this.$alert("请输入卷号！", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if (this.saveData.suppRollNo == '' || this.saveData.suppRollNo == null) {
          this.$alert("请输入供应商批号！", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        saveSuppRollNo(this.saveData).then(({data}) => {
            if (data.rows == null) {
              this.$alert("该卷号不存在，请输入！", '错误', {
                confirmButtonText: '确定'
              })
              return false;
            } else {
              if (data.rows.suppRollNoFlag == 'Y') {
                this.$confirm(`该卷已经录入供应商批号,确认要重新录入吗？`, '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'

                }).then(() => {
                  doSaveSuppRollNo(this.saveData).then(({data}) => {
                    if (data && data.code == 200) {
                      this.modelFlag2 = false
                      this.$message({
                        message: '操作成功',
                        type: 'success',
                        duration: 1500,
                        onClose: () => {
                        }
                      })
                    } else {
                      this.$alert(data.msg, '错误', {
                        confirmButtonText: '确定'
                      })
                    }
                  })
                })
              } else {
                doSaveSuppRollNo(this.saveData).then(({data}) => {
                  if (data && data.code == 200) {
                    this.modelFlag2 = false
                    this.$message({
                      message: '操作成功',
                      type: 'success',
                      duration: 1500,
                      onClose: () => {
                      }
                    })
                  } else {
                    this.$alert(data.msg, '错误', {
                      confirmButtonText: '确定'
                    })
                  }
                })
              }
            }
          }
        )
      },
      //出库卷清单
      getTransRoll() {
        let inData = {
          site: this.dataForm.site,
          orderRef1: this.dataForm.orderNo,
          partNo: this.dataForm.sOPartNo,
          user:this.$store.state.user.name,
        }

        getTransRoll(inData).then(({data}) => {
          this.dataList4 = data.rows
          if(data.row2!=null) {
            this.dataForm2.rollNo2 = data.row2.rollNo
          }
        })
      },
      //结束卷
      checkRoll() {
        if (this.dataList1.length > 0) {
          this.$alert("该界面存在分卷尚未创建，请先创建！！", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if(this.dataForm2.rollNo2 ==""||this.dataForm2.rollNo2 ==null){
          this.$alert("请选择卷号！", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if (this.dataForm2.fTotalQty2 <= 0 || this.dataForm2.fTotalQty2 ==""||this.dataForm2.fTotalQty2 ==null) {
          this.$alert("请输入正确的每卷数量！", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        let inData = {
          site: this.dataForm.site,
          orderRef1: this.dataForm.orderNo,
          orderRef3: this.dataForm.orderItemNo,
          rollNo:this.dataForm2.rollNo2,
          fTotalQty2:this.dataForm2.fTotalQty2,
          sOPartNo:this.dataForm.sOPartNo,
          userId:this.$store.state.user.name,
        }
        checkFinishRoll(inData).then(({data}) => {
          if (data && data.code == 200) {
            console.log(data.obj)
            if(data.obj.successFlag=='Y'){
              this.saveRoll();
            }else {
              if(data.obj.ableFlag=='Y'){
                this.$confirm(data.obj.messageBox+`,是否继续`, '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'

                }).then(() => {
                    this.saveRoll();
                })
              }else {
                this.$alert(data.obj.messageBox, '错误', {
                  confirmButtonText: '确定'
                })
                return false;
              }
            }

          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      saveRoll(){
        let inData = {
          site: this.dataForm.site,
          orderRef1: this.dataForm.orderNo,
          orderRef3: this.dataForm.orderItemNo,
          rollNo:this.dataForm2.rollNo2,
          fTotalQty2:this.dataForm2.fTotalQty2,
          sOPartNo:this.dataForm.sOPartNo,
          userId:this.$store.state.user.name,
        }
        saveFinishRoll(inData).then(({data}) => {
          if (data && data.code == 200) {
            let newData={
              transNo:data.obj.transNo,
              transDate:data.obj.transDate,
              subNo:this.dataForm2.rollNo2,
              subQty:this.dataForm2.fTotalQty2,
              transTypeDb:"SIR",
              userName:this.$store.state.user.name,
              partNo:this.dataForm.sOPartNo,
            }
            this.dataList4.push(newData);
            this.dataForm2={};
            this.$message.success('操作成功')
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      rollNoOut(){
        if (this.dataForm2.rollNo == '' || this.dataForm2.rollNo == null) {
          this.$alert("卷号不能为空，请输入!", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        let inData={
          site:this.dataForm.site,
          partNo:this.dataForm.partNo,
          fGPartNo:this.dataForm.sOPartNo,
          rollNo:this.dataForm2.rollNo,
          orderRef1:this.dataForm.orderNo,
          orderRef3:this.dataForm.orderItemNo,
          user:this.$store.state.user.name,
        }
        saveRollNoOut(inData).then(({data}) => {
          if (data && data.code == 200) {
            let newData={
              transNo:data.obj.transNo,
              transDate:data.obj.transDate,
              subNo:this.dataForm2.rollNo,
              subQty:data.obj.qty,
              transTypeDb:"SI",
              userName:this.$store.state.user.name,
              partNo:this.dataForm.sOPartNo,
            }
            this.dataList4.push(newData);
            this.dataForm2.rollNo2=this.dataForm2.rollNo;
            this.dataForm2.rollNo='';
            this.$message.success('操作成功')
          } else {
            this.dataForm2.rollNo='';
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      //导出excel
      createExportData() {

        return this.dataList;

      },
      startDownload() {
        //  this.exportData = this.dataList

      },
      finishDownload() {

      },
      fields() {
        let json = "{"
        this.columnList.forEach((item, index) => {
          if (index == this.columnList.length - 1) {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
          } else {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
          }
        })
        json += "}"
        let s = eval("(" + json + ")")

        return s
      },
      // 导出 end
      getReferenceData(){
        let inData = {
          site: this.dataForm.site,
          partNo: this.dataForm.partNo,
          partDescription: this.dataForm.partDescription,
          customerID: this.dataForm.customerID,
          fGPartNo: this.dataForm.fGPartNo,
          supplierID: '*',
        }
        getReferenceData(inData).then(({data}) => {
          if (data.success) {
            if (data.rows.length > 0) {
              this.dataForm.referenceSupplierID = data.rows[0].SupplierID;
              this.dataForm.referencePartDesc = data.rows[0].PartDescription;
              this.dataForm.referenceSupplierName = data.rows[0].SupplierDesc;
            }
          }
        })
      },
    },
    created() {

    }
  }
</script>

<style>
  .el-textarea__inner {
    padding: 5px 5px;
  }
</style>

