<template>
  <div class="customer-css">
    <el-dialog :title="titleCon" v-drag v-bind="$attrs" v-on="$listeners"
               width="920px" style="height: 680px;" class="customer-dialog">
      <el-form :inline="true" label-position="top" style="height: 495px;"
               label-width="80px">
        <!-- 菜单信息 -->
        <el-row>
          <el-col :span="24">
            <el-form-item :label=labels.currentTime>
              <el-date-picker disabled="disabled" style="width: 145px;"
                              v-model="pageData.reportedTime"
                              format="yyyy-MM-dd HH:mm:ss"
                              value-format="yyyy-MM-dd HH:mm:ss"
                              placeholder="">
              </el-date-picker>
            </el-form-item>
            <el-form-item class="customer-button">
              <el-button class="customer-bun-min" type="primary" @click="refreshPageData" style="margin-left: 10px; margin-bottom: 5px;">
              {{buttons.refreshButton}}</el-button>
            </el-form-item>
            <el-form-item class="customer-button">
              <el-button  class="customer-bun-min"   :disabled="buttonTags.finishRollFlag" type="primary" @click="finishRollBun"  style="margin-left: 10px; margin-bottom: 5px;">
              {{buttons.finishRoll}}</el-button>
            </el-form-item>
            <el-form-item class="customer-button">
              <el-button  class="customer-bun-min" type="primary" @click="closeDialog" style="margin-left: 10px; margin-bottom: 5px;">
              {{buttons.closeButton}}</el-button>
            </el-form-item>
            <el-button v-if="showDefault" @click="saveMultiLanguage()" type="primary">对语言设置</el-button>
          </el-col>
        </el-row>
        <!--  卷数量统计 班次信息  -->
        <el-form>
          <fieldset class="customer-fieldset" style="width: 495px;">
            <legend>{{labels.rollQtySum}}</legend>
            <el-form-item class="customer-item">
              <el-checkbox disabled="disabled" style="margin-top: 15px;" true-label="Y" false-label="N"
                           v-model="pageData.reportedFlag">{{labels.whetherReport}}</el-checkbox>
            </el-form-item>
            <el-form-item class="customer-item" :label=labels.approvedQty style="margin-top: -10px;">
              <!--<el-input v-model="pageData.approvedQty" type="number"  @blur="checkValidApprovedQty"-->
              <el-input v-if="this.preItemNo<=0" v-model="pageData.approvedQty" @blur="checkValidApprovedQty" type="number" style="width: 80px;" ></el-input>
              <el-input v-if="this.preItemNo>0"  disabled class="customer-input-color-red"  v-model="pageData.approvedQty" @blur="checkValidApprovedQty" type="number" style="width: 80px;" ></el-input>
            </el-form-item>
            <el-form-item class="customer-item" :label=labels.defectedQty style="margin-top: -10px;">
              <el-input v-model="pageData.defectedQty" :disabled="showNumFlag" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
            </el-form-item>
            <el-form-item class="customer-item" :label=labels.totalQty style="margin-top: -10px;">
              <el-input v-model="pageData.totalQty" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
            </el-form-item>
            <el-form-item class="customer-item" :label=labels.otherRollQty style="margin-top: -10px;">
              <el-input v-model="pageData.otherRollQty" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
            </el-form-item>
          </fieldset>
          <!-- 操作员信息和班次信息 -->
          <fieldset class="customer-fieldset"
                    style="margin-left: 500px; margin-top: -70px; width: 400px;">
            <legend>{{labels.operatorScheduleInfo}}</legend>
            <el-form-item class="customer-item" :label=labels.operatorId>
              <el-input v-model="operatorData.operatorId" disabled="disabled" style="width: 80px;" ></el-input>
            </el-form-item>
            <el-form-item class="customer-item" :label=labels.operatorName>
              <el-input v-model="operatorData.operatorName" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
            </el-form-item>
            <el-form-item class="customer-item" :label=labels.scheduledDate>
              <el-input v-model="pageData.scheduledDate" disabled="disabled" style="width: 80px;" ></el-input>
            </el-form-item>
            <el-form-item class="customer-item" :label=labels.shiftNo>
              <el-input v-model="pageData.shiftDesc" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
            </el-form-item>
            <el-button type="info" :disabled="buttonTags.selectShiftFlag" plain @click="selectSchduleShiftModal"
                       style="margin-left: -10px; margin-top: 10px; height: 20px; padding: 3px 3px;">
              <icon-svg name="ellipsis" style="height: 10px; width: 10px;" ></icon-svg>
            </el-button>

          </fieldset>
        </el-form>
        <!-- 卷生产时间统计产量报告 -->
        <el-form style="margin-top: 5px;">
            <fieldset class="customer-fieldset" style="width: 320px; margin-top: -10px;">
              <legend>{{labels.rollTimeSum}}</legend>
              <!-- 调机时间 -->
              <el-row style="margin-top: -10px;">
                <el-col :span="24">
                  <el-form-item  :label=labels.totalTuningTime >
                    <el-input v-model="pageData.totalSetupTime" class="customer-input-color-red" readonly="readonly" style="width: 80px;" ></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.totalTuningDownTime >
                    <el-input v-model="pageData.totalDowntimeTimeSetup" class="customer-input-color-red" readonly="readonly" style="width: 100px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.totalPureTuningTime >
                    <el-input v-model="pageData.totalPureSetupTime" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <!-- 生产时间 -->
              <el-row>
                <el-col :span="24">
                  <el-form-item  :label=labels.totalProdTime>
                    <el-input v-model="pageData.totalProdTime" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.totalProdDownTime>
                    <el-input v-model="pageData.totalDowntimeTimeProd" class="customer-input-color-red" readonly="readonly" style="width: 100px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.totalPureProdTime >
                    <el-input v-model="pageData.totalPureProdTime" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <!-- 制造时间 -->
              <el-row>
                <el-col :span="24">
                  <el-form-item  :label=labels.totalManufTime>
                    <el-input v-model="pageData.totalManufactureTime" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.totalManufDownTime>
                    <el-input v-model="pageData.totalManufactureDowntimeTime" class="customer-input-color-red" readonly="readonly" style="width: 100px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.totalPureManufTime>
                    <el-input v-model="pageData.totalPureManufactureTime" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </fieldset>
            <!-- 产量报告 -->
            <fieldset class="customer-fieldset"
                      style="margin-left: 325px; margin-top: -143px; width: 575px;">

              <legend>{{ labels.produceReport }}</legend>
              <!-- 开工时间 -->
              <el-row>
                <el-col :span="24">
                  <el-form-item  :label=labels.startTime>
                    <el-input v-model="pageData.eventTime" disabled="disabled" style="width: 130px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.finishTime>
                    <el-input v-model="pageData.tillTime" disabled="disabled" style="width: 130px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.prodTime >
                    <el-input v-model="pageData.sfdcProdTime" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.tuningTime>
                    <el-input v-model="pageData.sfdcSetupTime" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.manufTime>
                    <el-input v-model="pageData.sfdcManufactureTime" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <!-- 合格数量 -->
              <el-row>
                <el-col :span="24">
                  <el-form-item  :label=labels.sfdcApprovedQty>
                    <el-input v-model="pageData.sfdcApprovedQty" class="customer-input-color-red" readonly="readonly" style="width: 130px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.sfdcDefectedQty>
                    <el-input v-model="pageData.defectedQty" class="customer-input-color-red" readonly="readonly" style="width: 130px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.sfdcReportedQty >
                    <el-input v-model="pageData.sfdcReportedQty" class="customer-input-color-red" readonly="readonly" style="width: 80px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.tuningDown>
                    <el-input v-model="pageData.sfdcSetupDownTime" style="width: 80px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.manufTuning >
                    <el-input v-model="pageData.sfdcProdSetupTime" style="width: 80px;"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <!-- 备注 -->
              <el-row>
                <el-col :span="24">
                  <el-form-item  :label=labels.remark>
                    <el-input v-model="pageData.remark"  style="width: 430px;"></el-input>
                  </el-form-item>
                  <el-form-item  :label=labels.downTime>
                    <el-input v-model="pageData.sfdcDownTime" style="width: 80px;"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </fieldset>
        </el-form>
        <!-- 主材料 -->
        <el-form>
          <fieldset class="customer-fieldset" style="width: 830px;">
            <legend>{{labels.primaryMaterial}}</legend>
            <el-table
              height="180"
              :data="sfdcMaterialList"
              :cell-style="customerCellStyle" :cell-class-name="customerCellClassName"
              border
              v-loading="dataListLoading"
              style="width: 100%; margin-top: -5px;">
              <el-table-column
                v-for="(item,index) in columnMaterialArray" :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">
                  <!--<el-input type="number" class="table-input" align="right" @blur="checkValidQty(scope.row)"-->
                  <el-input type="number" class="table-input" align="right" v-if="item.columnHidden"
                            v-model="scope.row[item.columnProp]"></el-input>
                  <span v-else>{{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>
          </fieldset>
        </el-form>
      </el-form>


    </el-dialog>

    <!-- 异常原因录入的组件 -->
    <comExceptionReason ref="comExceptionReason" :close-on-click-modal="false"
                    :visible.sync="showExceptionFlag"
                    @initExceptionReason = "initExceptionReason">

    </comExceptionReason>

    <!-- 班次选择组件 -->
    <comSelectShift ref="comSelectShift" :close-on-click-modal="false"
                        :visible.sync="showShiftFlag"
                        @initScheduleShift = "initScheduleShift">
    </comSelectShift>
  </div>

</template>

<script>
  /*添加组件*/
  import comExceptionReason from "./com_exception_reason";//异常远远
  import comSelectShift from "./com_select_shift";//班次选择的组件
import {
  getCurrentRollReportedQty,
  countSfdcTimeQty,
  getScheduleShiftData,
  getSfdcTimeMaxAndMinTime,
  getSfdcTimeData,
  getSfdcReportedData,
  getSfdcMaterialByRollNo,
  checkFinishRollWithNoFqc,
  finishRollWithNoFqc,
  getSORoutingPreviousOperationItemNo,
  getSfdcFlowLabelData,/*执行打印的请求*/
} from '@/api/yieldReport/com_finish_roll.js';

  /*打印标签专用的js*/
  import {
    printSfdcLabel,
  } from "@/views/modules/yieldReport/print_roll_label.js";

  import {
    searchSysLanguagePackList,
    searchSysLanguageParam,
    searchFunctionButtonList,
    saveButtonList,
    searchSysLanguage,
    searchLanguageListByLanguageCode,
    saveSysLanguageOne,
    searchPageLanguageData,
    removerLanguage,
    saveSysLanguageList
  } from "@/api/sysLanguage.js";

  var functionId = 'C10000005';

export default {
  name: "com_finish_roll",
  data() {
    return {
      titleCon: '结束卷',
      showDefault: false,
      showExceptionFlag: false,
      showShiftFlag: false,
      showNumFlag:false,
      sfdcTimeList: [],
      preItemNo: 0,
      scheduleData: {
        site: this.$store.state.user.site,
        username: this.$store.state.user.name,
        seqNo: '',
        orderNo: '',
        itemNo: 0,
        partNo: '',
        workCenterNo: '',
        workCenterDesc: '',
        resourceDesc: '',
        rollNo: '',
        partDesc: '',
        planStartTime: '',
        planFinishTime: '',
        qtyRequiredOriginal: 0,
        reportedTime: this.dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'),
        scheduledDate: '',
        shiftNo: '',
        preItemDesc: '',
        nextItemDesc: '',
        nextItemNo: 0,
        operatorId: '',
        functionName: '',
        currentRollFlag: false
      },
      pageData: {
        site: this.$store.state.user.site,
        username: this.$store.state.user.name,
        orderNo: '',
        itemNo: 0,
        seqNo: '',
        rollNo: '',
        resourceId: '',
        scheduledDate: '',
        shiftNo: '',
        reportedTime: this.dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'),
        reportedFlag: 'N',
        approvedQty: 0,
        defectedQty: 0,
        totalQty: 0,
        editNewRollQty: 0,
        otherRollQty: '',
        shiftDesc: '',
        totalSetupTime: 0,
        totalDowntimeTimeSetup: 0,
        totalPureSetupTime: 0,
        totalProdTime: 0,
        totalDowntimeTimeProd: 0,
        totalPureProdTime: 0,
        totalManufactureTime: 0,
        totalManufactureDowntimeTime: 0,
        totalPureManufactureTime: 0,
        sfdcProdTime: 0,//生产时间
        sfdcSetupTime: 0,//调机时间
        sfdcManufactureTime: 0,//制造时间
        sfdcSetupDownTime: 0,//调机停机时间
        sfdcProdSetupTime: 0,//生产调机时间
        sfdcDownTime: 0,//停机时间
        eventTime: '',
        tillTime: '',
        sfdcApprovedQty: 0,
        sfdcDefectedQty: 0,
        sfdcReportedQty: 0,
        remark: '',
        exceptionFlag: 'N',
        exceptionReason: '',
        operatorId: '',
        operatorName: '',
        createNewRollFlag: 'N',
      },
      operatorData: {
        site: this.$store.state.user.site,
        username: this.$store.state.user.name,
        operatorId: '',
        operatorName: '',
        status: '',
        seqNo: '',
        showFlag: false
      },
      sfdcMaterialList: [],
      columnMaterialArray: [
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303MaterialReportDate',
          tableId: "5303Material",
          tableName: "派工单材料",
          columnProp: "reportDate",
          headerAlign: "center",
          align: "center",
          columnLabel: "报告时间",
          columnWidth: 125,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303MaterialReportedBy',
          tableId: "5303Material",
          tableName: "派工单材料",
          columnProp: "reportedBy",
          headerAlign: "center",
          align: "center",
          columnLabel: "报告人",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303MaterialRmRollNo',
          tableId: "5303Material",
          tableName: "派工单材料",
          columnProp: "rmRollNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "材料卷号",
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303MaterialPartNo',
          tableId: "5303Material",
          tableName: "派工单材料",
          columnProp: "partNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "零部件编码",
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303MaterialStartDate',
          tableId: "5303Material",
          tableName: "派工单材料",
          columnProp: "startDate",
          headerAlign: "center",
          align: "center",
          columnLabel: "开始使用时间",
          columnWidth: 125,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303MaterialTransQty',
          tableId: "5303Material",
          tableName: "派工单材料",
          columnProp: "transQty",
          headerAlign: "center",
          align: "center",
          columnLabel: "数量",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303MaterialNetIssueQty',
          tableId: "5303Material",
          tableName: "派工单材料",
          columnProp: "netIssueQty",
          headerAlign: "center",
          align: "center",
          columnLabel: "本卷耗用数量",
          columnWidth: 100,
          columnHidden: true,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303MaterialKeyRMFlag',
          tableId: "5303Material",
          tableName: "派工单材料",
          columnProp: "keyRMFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "是否主材",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303MaterialSAPBOMItemNo',
          tableId: "5303Material",
          tableName: "派工单材料",
          columnProp: "sAPBOMItemNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "SAP BOM序号",
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        }
      ],
      buttonTags:{
        selectShiftFlag: true,
        finishRollFlag: true,
      },
      dataListLoading: false,
      buttons: {
        refreshButton: '刷新',
        finishRoll: '结束卷',
        closeButton: '关闭',
      },
      buttonList: [
        {
          functionId: functionId,
          languageValue: '刷新',
          objectId: 'refreshButton',
          objectType: 'button',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '结束卷',
          objectId: 'finishRoll',
          objectType: 'button',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '关闭',
          objectId: 'closeButton',
          objectType: 'button',
          tableId: '*'
        },
      ],
      queryButton: {
        functionId: functionId,
        table_id: '*',
        languageCode: this.$i18n.locale,
        objectType: 'button'
      },
      labels: {
        titleCon: '结束卷操作 ',
        seqNoName: '派工单号:',
        currentTime: '当前时间',
        rollQtySum: '卷数量统计',
        whetherReport: '是否报告产量',
        approvedQty: '总良品数量',
        defectedQty: '总不良品数量',
        totalQty: '总数量',
        otherRollQty: '其他卷数量',
        operatorScheduleInfo: '人员排程班次信息',
        operatorId: '操作员',
        operatorName: '操作员姓名',
        scheduledDate: '排产日期',
        shiftNo: '班次',
        rollTimeSum: '卷生产时间统计',
        totalTuningTime: '总调机时间',
        totalTuningDownTime: '总调机过程停机时间',
        totalPureTuningTime: '净调机时间',
        totalProdTime: '总生产时间',
        totalProdDownTime: '总生产过程停机时间',
        totalPureProdTime: '净生产时间',
        totalManufTime: '总制造时间',
        totalManufDownTime: '总制造过程停机时间 ',
        totalPureManufTime: '净制造时间:',
        produceReport: '产量报告',
        startTime: '开工时间',
        finishTime: '完工时间',
        prodTime: '生产时间',
        tuningTime: '调机时间',
        manufTime: '制造时间',
        sfdcApprovedQty: '合格数量',
        sfdcDefectedQty: '不合格数量',
        sfdcReportedQty: '报告数量',
        tuningDown: '调机停机',
        manufTuning: '生产调机',
        remark: '备注',
        downTime: '停机时间',
        primaryMaterial: '主材料 ',
      },
      labelsList: [
        {
          functionId: functionId,
          languageValue: '结束卷操作 ',
          objectId: 'titleCon',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '派工单号:',
          objectId: 'seqNoName',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '当前时间',
          objectId: 'currentTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '卷数量统计 ',
          objectId: 'rollQtySum',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '是否报告产量 ',
          objectId: 'whetherReport',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '总良品数量',
          objectId: 'approvedQty',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '总不良品数量',
          objectId: 'defectedQty',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '总数量',
          objectId: 'totalQty',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '其他卷数量',
          objectId: 'otherRollQty',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '人员排程班次信息',
          objectId: 'operatorScheduleInfo',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '操作员',
          objectId: 'operatorId',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '操作员姓名',
          objectId: 'operatorName',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '排产日期',
          objectId: 'scheduledDate',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '班次',
          objectId: 'shiftNo',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '卷生产时间统计',
          objectId: 'rollTimeSum',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '总调机时间',
          objectId: 'totalTuningTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '总调机过程停机时间',
          objectId: 'totalTuningDownTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '净调机时间',
          objectId: 'totalPureTuningTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '总生产时间',
          objectId: 'totalProdTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '总生产过程停机时间',
          objectId: 'totalProdDownTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '净生产时间',
          objectId: 'totalPureProdTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '总制造时间',
          objectId: 'totalManufTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '总制造过程停机时间',
          objectId: 'totalManufDownTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '净制造时间',
          objectId: 'totalPureManufTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '产量报告',
          objectId: 'roduceReport',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '开工时间 ',
          objectId: 'startTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '完工时间:',
          objectId: 'finishTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '生产时间',
          objectId: 'prodTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '调机时间',
          objectId: 'tuningTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '制造时间',
          objectId: 'manufTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '合格数量',
          objectId: 'sfdcApprovedQty',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '不合格数量',
          objectId: 'sfdcDefectedQty',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '报告数量',
          objectId: 'sfdcReportedQty',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '调机停机',
          objectId: 'tuningDown',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '生产调机 ',
          objectId: 'manufTuning',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '备注',
          objectId: 'remark',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '停机时间',
          objectId: 'downTime',
          objectType: 'label',
          tableId: '*'
        }, {
          functionId: functionId,
          languageValue: '主材料',
          objectId: 'primaryMaterial',
          objectType: 'label',
          tableId: '*'
        },
      ],
      queryLabel: {
        functionId: functionId,
        table_id: '*',
        languageCode: this.$i18n.locale,
        objectType: 'label'
      },
    }
  },
  components: {
    comExceptionReason,/*异常原因的组件*/
    comSelectShift,/*班次选择的组件*/
  },
  methods: {
    sORoutingPreviousOperationItemNo(){
      getSORoutingPreviousOperationItemNo( this.pageData).then(({data})=>{
        if (data.code==0){
          if (data.itemNo>0){
            this.showNumFlag = true
          }else {
            this.showNumFlag = false
          }
        }
      })

    },
    /*初始化页面参数*/
    init(scheduleData, operatorData) {
      //初始化参数
      this.scheduleData = scheduleData;
      //初始化参数
      this.pageData.orderNo = scheduleData.orderNo;
      this.pageData.itemNo = scheduleData.itemNo;
      this.pageData.seqNo = scheduleData.seqNo;
      this.pageData.rollNo = scheduleData.rollNo;
      this.pageData.scheduledDate = scheduleData.scheduledDate;
      this.pageData.shiftNo = scheduleData.shiftNo;
      this.pageData.resourceId = scheduleData.resourceId;
      this.pageData.operatorId = operatorData.operatorId;
      this.pageData.operatorName = operatorData.operatorName;

      this.preItemNo = scheduleData.preItemNo
      //this.scheduleData.reportedTime = this.dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss');
      //重置时间
      this.pageData.reportedTime = this.dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss');
      //初始化操作员对象
      this.operatorData = JSON.parse(JSON.stringify(operatorData));
      //初始化标题
      this.titleCon = this.labels.titleCon+this.labels.seqNoName+scheduleData.seqNo;
      //处理异常的原因
      this.pageData.exceptionFlag = 'N';
      this.pageData.exceptionReason =  '';
      //刷新当前派工单的信息
      this.refreshPageData();
    },
    /*关闭modal*/
    closeDialog(){
      //刷新报工的页面
      this.$emit('refreshPageData');
      //关闭当前的页面
      this.$emit('update:visible', false);
    },

    /*生产过程的停机组件*/
    exceptionReasonModal() {
      //1.首先调用菜单判断方式  打开生产过程的停机的页面
      //checkProduceButton('produceDownFlag');
      //打开生产过程的工具的页面
      this.$nextTick(() => {
        this.show = true;
        this.$refs.comProduceDown.init(this.scheduleData, this.operatorData)
      });
    },

    /*刷新当前的页面参数*/
    async refreshPageData(){
      //首先关闭报工按钮
      this.buttonTags.finishRollFlag = true;
      //1.刷新当前卷的报工数据
      await getCurrentRollReportedQty(this.scheduleData).then(({data}) => {
        this.pageData.approvedQty = data.row.approvedQty;
        this.pageData.defectedQty = data.row.defectedQty;
        this.pageData.totalQty = data.row.totalQty;
        this.pageData.otherRollQty = data.row.otherRollQty;
      })
      //2.刷新当前卷的时间信息
      await countSfdcTimeQty(this.scheduleData).then(({data}) => {
        this.pageData.totalSetupTime = data.row.totalSetupTime;
        this.pageData.totalDowntimeTimeSetup = data.row.totalDowntimeTimeSetup;
        this.pageData.totalPureSetupTime = data.row.totalPureSetupTime;
        this.pageData.totalProdTime = data.row.totalProdTime;
        this.pageData.totalDowntimeTimeProd = data.row.totalDowntimeTimeProd;
        this.pageData.totalPureProdTime = data.row.totalPureProdTime;
        this.pageData.totalManufactureTime = data.row.totalManufactureTime.toFixed(2);
        this.pageData.totalManufactureDowntimeTime = data.row.totalManufactureDowntimeTime;
        this.pageData.totalPureManufactureTime = data.row.totalPureManufactureTime.toFixed(2);
        //先预设一些参数  后期方法再计算
        //生产时间=总生产时间
        this.pageData.sfdcProdTime = this.pageData.totalProdTime;
        //调机时间=总调机时间
        this.pageData.sfdcSetupTime = this.pageData.totalSetupTime;
        //制造时间=总制造时间
        this.pageData.sfdcManufactureTime = this.pageData.totalManufactureTime;
        //调机停机=总调机过程停机时间
        this.pageData.sfdcSetupDownTime = this.pageData.totalDowntimeTimeSetup;
        //生产调机=总生产过程停机时间
        this.pageData.sfdcProdSetupTime = this.pageData.totalDowntimeTimeProd;
        //停机时间=总制造过程停机时间
        this.pageData.sfdcDownTime = this.pageData.totalManufactureDowntimeTime;
      });
        //3.刷新派工单的班次信息
      await getScheduleShiftData(this.pageData).then(({data}) => {
        let specialAuth = 'N';
           //区分是否存在班次
          if(data.code == 500){
            this.pageData.shiftDesc = '无班次';//重置班次
            this.pageData.scheduledDate = '';//重置排产日期
            this.pageData.shiftNo = '';
          }else{
            this.pageData.shiftDesc = data.row.shiftDesc;//重置班次
            this.pageData.scheduledDate = data.row.scheduledDate.substring(0, 10);//重置排产日期
            this.pageData.shiftNo = data.row.shiftNo;
            //设置结果
            specialAuth = data.row.specialAuth;
          }
          //根据不同设置不同的属性
          if("Y" === specialAuth){
            this.buttonTags.selectShiftFlag = false;
          }else{
            this.buttonTags.selectShiftFlag = true;
          }
        });
        //4.刷新当前卷的最早和最晚时间
       await getSfdcTimeMaxAndMinTime(this.scheduleData).then(({data}) => {
          this.pageData.eventTime = data.row.eventTime;
          this.pageData.tillTime = data.row.tillTime;
        });
        //5.刷新当前卷的Sfdc表的时间
       await getSfdcTimeData(this.scheduleData).then(({data}) => {
          //先判断是否成功查询
          if(data.resultCode == 200){
            //判断是否操作成功
            this.pageData.eventTime = data.row.finishTime;
            this.pageData.sfdcProdTime = data.row.sfdcProdTime;
            this.pageData.sfdcSetupTime = data.row.sfdcSetupTime;
            this.pageData.sfdcManufactureTime = data.row.sfdcManufactureTime;
            this.pageData.sfdcDownTime = data.row.sfdcDownTime;
            this.pageData.sfdcSetupDownTime = data.row.sfdcSetupDownTime;
            this.pageData.sfdcProdSetupTime = data.row.sfdcProdSetupTime;
          }else{
            //暂时不处理数据
          }
        });
        //6.刷新当前卷的报工数据
        await getSfdcReportedData(this.scheduleData).then(({data}) => {
          this.pageData.sfdcApprovedQty = this.pageData.approvedQty - data.row.approveQty;
          this.pageData.sfdcDefectedQty = this.pageData.defectedQty - data.row.defectQty;
          this.pageData.sfdcReportedQty = this.pageData.sfdcApprovedQty + this.pageData.sfdcDefectedQty;
        });
        //刷新当前卷的时间数据
        await getSfdcMaterialByRollNo(this.scheduleData).then(({data}) => {
          this.sfdcMaterialList = data.rows;
          //只有数据全部刷新后  才可以报工
          setTimeout(()=>{
            this.buttonTags.finishRollFlag = false;
          }, 1000);
        });
    },

    /*刷新当前卷的报工数据汇总*/
    refreshCurrentRollReportedQty(){
      getCurrentRollReportedQty(this.scheduleData).then(({data}) => {
        this.pageData.approvedQty = data.row.approvedQty;
        this.pageData.defectedQty = data.row.defectedQty;
        this.pageData.totalQty = data.row.totalQty;
        this.pageData.otherRollQty = data.row.otherRollQty;
      })
    },

    //刷新当前卷的时间信息
    refreshCurrentRollTimeQty(){
      countSfdcTimeQty(this.scheduleData).then(({data}) => {
        this.pageData.totalSetupTime = data.row.totalSetupTime;
        this.pageData.totalDowntimeTimeSetup = data.row.totalDowntimeTimeSetup;
        this.pageData.totalPureSetupTime = data.row.totalPureSetupTime;
        this.pageData.totalProdTime = data.row.totalProdTime;
        this.pageData.totalDowntimeTimeProd = data.row.totalDowntimeTimeProd;
        this.pageData.totalPureProdTime = data.row.totalPureProdTime;
        this.pageData.totalManufactureTime = data.row.totalManufactureTime;
        this.pageData.totalManufactureDowntimeTime = data.row.totalManufactureDowntimeTime;
        this.pageData.totalPureManufactureTime = data.row.totalPureManufactureTime;
      });
    },

    //刷新派工单的班次信息
    refreshScheduleShiftData(){
      getScheduleShiftData(this.scheduleData).then(({data}) => {
        //区分是否存在班次
        if(data.code == 500){
          this.pageData.shiftDesc = data.row.shiftDesc;//重置班次
          this.pageData.scheduledDate = '';//重置排产日期
          this.pageData.shiftNo = '';
        }else{
          this.pageData.shiftDesc = data.row.shiftDesc;//重置班次
          this.pageData.scheduledDate = data.row.scheduledDate.substring(0, 10);//重置排产日期
          this.pageData.shiftNo = data.row.shiftNo;
        }
      });
    },

    //刷新当前卷的时间信息
    refreshCurrentRollMaxAndMinTime(){
      getSfdcTimeMaxAndMinTime(this.scheduleData).then(({data}) => {
        this.pageData.eventTime = data.row.eventTime;
        this.pageData.tillTime = data.row.tillTime;
      });
    },

    //刷新当前卷的Sfdc的信息
    refreshSfdcTimeData(){
      getSfdcTimeData(this.scheduleData).then(({data}) => {
        //判断是否操作成功
        this.pageData.eventTime = data.row.finishTime;
        this.pageData.sfdcProdTime = data.row.sfdcProdTime;
        this.pageData.sfdcSetupTime = data.row.sfdcSetupTime;
        this.pageData.sfdcManufactureTime = data.row.sfdcManufactureTime;
        this.pageData.sfdcDownTime = data.row.sfdcDownTime;
        this.pageData.sfdcSetupDownTime = data.row.sfdcSetupDownTime;
        this.pageData.sfdcProdSetupTime = data.row.sfdcProdSetupTime;
      });
    },

    //刷新当前卷的报工数据
    refreshSfdcData(){
      getSfdcReportedData(this.scheduleData).then(({data}) => {
        this.pageData.sfdcApprovedQty = this.pageData.approvedQty - data.row.approveQty;
        this.pageData.sfdcDefectedQty = this.pageData.defectedQty - data.row.defectQty;
        this.pageData.sfdcReportedQty = this.pageData.sfdcApprovedQty + this.pageData.sfdcDefectedQty;
      });
    },

    //刷新当前卷的时间数据
    refreshSfdcMaterialTable(){
      getSfdcMaterialByRollNo(this.scheduleData).then(({data}) => {
        this.sfdcMaterialList = data.rows;
      });
    },



    /*检查数据是否有效*/
    checkValidQty(row){
      //判断当前是否为空
      if(row.netIssueQty == ''){
        this.$message.error('材料上本卷耗用数量不能为空!');
        row.netIssueQty = 0;//重新赋值
        return false;
      }
      //判断当前是否有效
      if(row.netIssueQty <= 0){
        this.$message.error('材料耗用数量必须大于0!');
        return false;
      }
      //判断是否超限
      if(row.netIssueQty > row.transQty){
        this.$message.error('材料耗用数量大于发料数量!');
        row.netIssueQty = 0;//重新赋值
        return false;
      }

    },

    /*添加定制的css类*/
    customerCellClassName({row, column, rowIndex, columnIndex}) {
      if(column.property == 'netIssueQty'){
        return 'customer-number-cell';
      }
    },

    /*添加定制的cess样式*/
    customerCellStyle({row, column, rowIndex, columnIndex}) {
      if(column.property == 'netIssueQty'){
        return 'padding: 0px 0px;';
      }
    },

    /*检验良品的总数量*/
    checkValidApprovedQty(){
      //调用刷新的方法
      this.refreshSfdcData();
      this.pageData.totalQty = parseFloat(this.pageData.approvedQty) + parseFloat(this.pageData.defectedQty);
    },

    /*结束当前的操作*/
    finishRollBun(){
      //首先判断数值是否通过判断
      let approvedQty = this.pageData.approvedQty;
      if(approvedQty == null || approvedQty == ''){
        //this.$message.error('请输入良品总数量!');
        this.pageData.approvedQty = 0;//重新赋值
        approvedQty = 0;
        //return false;
      }
      if(approvedQty < 0){
        this.$message.error('良品总数量必须大于等于0!');
        this.pageData.approvedQty = 0;//重新赋值
        return false;
      }
      //班次判断
      if(this.pageData.shiftDesc == '无班次'){
        this.$message.error('该时间段内没有匹配的班次信息,请联系相关人员！!');
        return false;
      }

      //验证通过提交到后台
      let postData = {'pageData': JSON.stringify(this.pageData), 'materialList': JSON.stringify(this.sfdcMaterialList)};

      //先调用检查方法
      checkFinishRollWithNoFqc(postData).then(({data}) => {
        //判断是否成功
        if(data.code == 500){
          this.$message.error(data.msg);
        }else if (data.resultMap.resultCode == '201'){
          //打开异常原因录入的界面
          this.$confirm(data.resultMap.resultMsg, '提示', {
            confirmButtonText: '确认',
            celButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.showExceptionReasonModal();
          });
        }else{
          //执行结束卷操作
          this.finishRollOperation();
        }
      });

    },

    /*结束卷的具体操作*/
    finishRollOperation(){
      //验证通过提交到后台
      let postData = {'pageData': JSON.stringify(this.pageData), 'materialList': JSON.stringify(this.sfdcMaterialList)};
      //处理信息
      finishRollWithNoFqc(postData).then(({data}) => {
        //判断操作是否成功
        if(data.code == 500){
          this.$message.error(data.msg);
        }else{
          //判断是否打印卷标签
          if(data.rollNo != ''){
            //需要打印标签
            let printRow = {site: this.pageData.site, orderNo: this.pageData.orderNo,
              rollNo: data.rollNo};
            this.printSfdcFlowLabel(printRow);
            //延时一秒关闭  --预防没有出标签
            setTimeout(() => {
              this.closeDialog();
            }, 1000);
          }else{
            //关闭当前的页面
            this.closeDialog();
          }
        }
      })
    },

    /*打开异常原因录入页面*/
    showExceptionReasonModal(){
      //1.首先调用菜单判断方式  打开生产过程的材料的页面
      //checkProduceButton('produceMaterialFlag');
      //打开生产过程的工具的页面
      this.$nextTick(() => {
        this.showExceptionFlag = true;
        this.$refs.comExceptionReason.init();
      });
    },

    /*处理异常的原因*/
    initExceptionReason(exceptionReason){
      //处理异常的原因
      this.pageData.exceptionFlag = 'Y';
      this.pageData.exceptionReason =  exceptionReason;
      //然后提交结束卷的数据
      this.finishRollOperation();
    },

    /*打开班次选择页面*/
    selectSchduleShiftModal(){
      //1.首先调用菜单判断方式  打开生产过程的材料的页面
      //checkProduceButton('produceMaterialFlag');
      //打开生产过程的工具的页面
      this.$nextTick(() => {
        this.showShiftFlag = true;
        this.$refs.comSelectShift.init(this.pageData);
      });
    },

    /*修改页面的班次和排产的时间*/
    initScheduleShift(scheduleDate, shiftDesc, username){
      //重置班次和排产的时间
      this.pageData.scheduledDate = scheduleDate.substring(0, 10);
      this.pageData.shiftDesc = shiftDesc;
      this.pageData.shiftNo = shiftDesc;
      this.pageData.remark = username+"更改了班次."
    },

    /*打印流转标签*/
    printSfdcFlowLabel(sfdcRow){
      //先查询打印的卷信息
      getSfdcFlowLabelData(sfdcRow).then(({data}) => {
        //开始打印标签
        if(data.code === 200){
          let printList = data.printList;
          printSfdcLabel(printList);
        }else{
          this.$message.error(data.msg);
        }
      });
    },

    /// 保存 默认配置 列
    async saveMultiLanguage() {
      // 保存页面 button label title 属性
      let buttons = this.buttonList;
      let labels = this.labelsList;
      await saveButtonList(buttons)
      await saveButtonList(labels)
      this.getMultiLanguageList()
    },

    getMultiLanguageList() {
      //首先查询当前按钮的多语言
      searchFunctionButtonList(this.queryButton).then(({data}) => {
        if (JSON.stringify(data.data) != '{}') {
          this.buttons = data.data
        } else {
          // saveButtonList(this.buttonList).then(({data}) => {
          // })
        }
      });
      //其次查询当前标签的多语言
      searchFunctionButtonList(this.queryLabel).then(({data}) => {
        if (JSON.stringify(data.data) != '{}') {
          this.labels = data.data
        } else {
          // saveButtonList(this.buttonList).then(({data}) => {
          // })
        }
      });
    },

  },
  created() {
    // this.factoryList()
    // this.getLanguageList()
    this.getMultiLanguageList()//刷新按钮
  }
}

</script>

<style scoped lang="scss">
/*调节页面button和input的上下间距*/
.customer-css .customer-button{
  margin-top: 25px;
}

/*调节样式*/
.customer-item{
  margin-top: -10px;
}
/*fieldset下table的样式*/
.customer-fieldset /deep/ .el-table__header th.is-leaf{
  line-height: 16px;
}

/deep/ .customer-tab .el-tabs__content{
  padding: 0px !important;
}

/*table中input*/
div.table-input /deep/ input.el-input__inner{
  text-align: right;
}

/*当前按钮的通用样式*/
.customer-css .customer-bun-mid{
  width: 65px;
  text-align: center;
}

.customer-css .customer-bun-min{
  width: 50px;
  text-align: center;
}

.customer-css .customer-bun-max{
  width: 80px;
  text-align: center;
}
/*当前按钮的通用样式*/
.customer-css .el-button--medium {
  padding: 5px 5px;
}

/*统一的input内容颜色样式*/
.customer-input-color-red /deep/ .el-input__inner {
  color: red;
}

</style>
