<template>
  <div class="customer-css">
    <!--  菜单按钮区域  -->
    <fieldset class="customer-field" style="width: 200px; padding: 0.35em 0.75em 0.425em;">
      <legend>菜单</legend>
      <el-form :inline="true" label-position="top" label-width="100px" style="">
        <el-form-item :label="''">
          <el-button type="primary" @click="refreshPageTables()" class="customer-bun-mid"
                     style="margin-left: 10px;  margin-bottom: 5px;">{{ buttons.searchButton }}
          </el-button>
        </el-form-item>
        <el-form-item :label="''">
          <el-button type="primary" @click="switchOperatorModal(0)" class="customer-bun-mid"
                     :disabled="reportButton.normalReportButton"
                     style="margin-left: 10px;  margin-bottom: 5px;">{{ buttons.reportButton }}
          </el-button>
        </el-form-item>
      </el-form>
    </fieldset>
    <!--  查询时间和产品  -->
    <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 5px;">
      <el-form-item :label=labels.siteNo>
        <el-input v-model="searchData.site" style="width: 85px"></el-input>
      </el-form-item>
      <el-form-item :label=labels.resourceId>
        <span slot="label" @click="getBaseList(95)"><a herf="#">机台编号:</a></span>
        <el-input v-model="searchData.resourceId" clearable style="width: 110px"></el-input>
      </el-form-item>
      <el-form-item :label=labels.planStartTime>
        <el-date-picker class="el-time-width"
                        style=""
                        v-model="searchData.planStartTime1"
                        value-format="yyyy-MM-dd">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="''">
        <el-date-picker class="el-time-width"
                        style="margin-top: 20px;"
                        v-model="searchData.planStartTime2"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        placeholder="">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label=labels.orderNo>
        <el-input v-model="searchData.orderNo" style="width: 120px" @keyup.enter.native="refreshPageTables"></el-input>
      </el-form-item>
      <el-form-item :label=labels.seqNo>
        <el-input v-model="searchData.seqNo" style="width: 120px" @keyup.enter.native="refreshPageTables"></el-input>
      </el-form-item>
      <el-form-item :label="''" style="margin-left: -5px;">
        <el-checkbox style="margin-top: 20px;" true-label="Y" false-label="N" v-model="searchData.closedFlag">{{ labels.showFinishedSeqNo }}
        </el-checkbox>
      </el-form-item>
    </el-form>

    <!-- 右键操作菜单  -->
    <el-form :inline="true">
      <el-form-item :label=labels.shopOrderList>
        <el-dropdown trigger="click" style="margin-top: 3px" class="customer-dropdown" @command="handleCommand">
          <el-button type="primary" @click="menuButtonFlag" :disabled="authEdit">
            {{ labels.primaryMenu }}<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu v-show="menuShow" slot="dropdown">
            <el-dropdown-item class="customer-li" command="0" :disabled="menuButton.prdButton">
              <span>{{ labels.shopOrderLabel }}</span>
            </el-dropdown-item>
            <hr width="95%"/>
            <el-dropdown-item class="customer-li" command="1" :disabled="menuButton.closedButton">{{
                labels.closeLabel
              }}
            </el-dropdown-item>
            <el-dropdown-item class="customer-li" command="2" :disabled="menuButton.openButton">{{ labels.openLabel }}
            </el-dropdown-item>
            <hr width="95%"/>
            <el-dropdown-item class="customer-li" command="3" :disabled="menuButton.pauseButton">{{
                labels.pauseLabel
              }}
            </el-dropdown-item>
            <el-dropdown-item class="customer-li" command="4" :disabled="menuButton.openReverseButton">
              {{ labels.reopenLabel }}
            </el-dropdown-item>
            <hr width="95%"/>
            <el-dropdown-item class="customer-li" command="5" :disabled="menuButton.createRecheckButton">
              {{ labels.createReCheckSeqNo }}
            </el-dropdown-item>
            <hr width="95%"/>
            <el-dropdown-item class="customer-li" command="6" :disabled="menuButton.canceledAllPrdButton">
              {{ labels.cancelAllScheduleOperations }}
            </el-dropdown-item>
            <hr width="95%"/>
<!--            <el-dropdown-item class="customer-li" command="7" :disabled="menuButton.costRollUpFlagButton">-->
<!--              {{ labels.prodIssued }}-->
<!--            </el-dropdown-item>-->
<!--            <el-dropdown-item class="customer-li" command="8" :disabled="menuButton.canceledCostRollUpFlagButton">-->
<!--              {{ labels.cancelProdIssued }}-->
<!--            </el-dropdown-item>-->
            <el-dropdown-item class="customer-li" command="查看物料库存"
                              :disabled="menuButton.partStockFlag">{{ labels.viewPartStock }}
            </el-dropdown-item>
            <hr width="95%"/>
<!--            <el-dropdown-item class="customer-li" command="9" :disabled="menuButton.manualFlagButton">-->
<!--              {{ labels.toolIssued }}-->
<!--            </el-dropdown-item>-->
<!--            <el-dropdown-item class="customer-li" command="10" :disabled="menuButton.canceledManualFlagButton">-->
<!--              {{ labels.cancelToolIssued }}-->
<!--            </el-dropdown-item>-->
<!--            <hr width="95%"/>-->
<!--            <el-dropdown-item class="customer-li" command="11" :disabled="menuButton.repairSOFlagButton">-->
<!--              {{ labels.printIssued }}-->
<!--            </el-dropdown-item>-->
<!--            <el-dropdown-item class="customer-li" command="12" :disabled="menuButton.canceledRepairSOFlagButton">-->
<!--              {{ labels.cancelPrintIssued }}-->
<!--            </el-dropdown-item>-->
<!--            <hr width="95%"/>-->
          </el-dropdown-menu>
        </el-dropdown>
<!--        <el-button @click="userSetting" type="primary">{{ buttons.settingTable }}</el-button>-->
<!--        <el-button v-if="showDefault" @click="saveColumnList()" type="primary">{{ buttons.defaultTable }}</el-button>-->
        <download-excel
          :fields="fields()"
          :data="exportList"
          type="xls"
          :name="exportName"
          :header="exportHeader"
          :footer="exportFooter"
          :defaultValue="exportDefaultValue"
          :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-main style="margin-left: -20px; margin-top: -20px; width: 104%;">
      <el-table @row-click="setCurrentRow"
                :height="height"
                highlight-current-row
                :data="produceScheduleList"
                border
                v-loading="dataListLoading"
                style="width: 100%;">
        <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-main>

    <!-- 切换操作员 -->
    <comSwitchOperator ref="comSwitchOperator" :close-on-click-modal="false"
                       :visible.sync="showOperatorFlag"
                       @initOperatorData="initOperatorData"
                       @notInitOperatorData="notInitOperatorData">

    </comSwitchOperator>

    <!-- 正常报工的组件 -->
    <comProduceReportNormal :close-on-click-modal="false"
                            :visible.sync="showReportFlag" ref="comProduceReportNormal">

    </comProduceReportNormal>
    <!-- 分切报工的组件 -->
    <comSplitOrderReport :close-on-click-modal="false"
                         :visible.sync="showSplitReportFlag" ref="comSplitOrderReport">

    </comSplitOrderReport>


    <!-- 正常的结束派工单组件 -->
    <comFinishSchedule :close-on-click-modal="false"
                       :visible.sync="showFinishScheduleFlag" ref="comFinishSchedule"
                       @processFinishScheduleOperation="processFinishScheduleOperation">

    </comFinishSchedule>
    <!-- fqc报工的组件 -->
    <fqcProduceReportNormal :close-on-click-modal="false"
                            :visible.sync="fqcShowReportFlag" ref="fqcProduceReportNormal">
    </fqcProduceReportNormal>

    <!-- 返工重检   -->
    <reworkInspectReport :close-on-click-modal="false"
                         :visible.sync="reworkShowReportFlag" ref="reworkInspectReport"></reworkInspectReport>
    <!-- FQC分卷   -->
    <fqcSplitRollReport :close-on-click-modal="false"
                        :visible.sync="fqcRollShowReportFlag" ref="fqcSplitRollReport"></fqcSplitRollReport>
    <!-- 创建重检派工单   -->
    <createRecheck ref="createRecheck"></createRecheck>
    <!-- 换包装   -->
    <changePackaging :close-on-click-modal="false"
                     :visible.sync="changePackagingFlag" ref="changePackaging"></changePackaging>

    <!-- 物料库存查询 -->
    <comPartStock ref="comPartStock" :close-on-click-modal="false"
                  :visible.sync="showPartStockFlag">
    </comPartStock>

    <!--列表的组件-->
    <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>

    <!-- 动态列    -->
    <column v-if="visible" ref="column" @refreshData="getTableUserColumn" v-drag></column>
  </div>
</template>

<script>

import {
  getProduceScheduleList,
  reportCheck,
  getUserSpecialSecurity,
  closeOrOpenProduceOrder,
  pauseOrOpenProduceOrder,
  costRollUpProduceOrder,
  manualProduceOrder,
  repairSOFlagProduceOrder,
  workbenchCancelallops,
  getShopOrder,
  getScheduleMultiReportSpecialAuth,/* 获取派工单的特殊权限 */
  getResourceByUser
} from '@/api/yieldReport/produce_order.js'

/* 动态表头 */
import {
  saveTableDefaultList,
  getTableDefaultListLanguage,
  getTableUserListLanguage,
  removerDefault,
  removerUser
} from '@/api/table.js'

/* 引入组件 */
import Chooselist from '@/views/modules/common/Chooselist_eam'
import comSwitchOperator from './com_switch_operator'/* 切换操作员 */
import comProduceReportNormal from './com_produce_report_normal'/* 报工的组件 */
import comFinishSchedule from './com_finish_schedule'/* 结束派工的组件 */
import fqcProduceReportNormal from './otherReport/fqc_produce_report_normal'/* 结束派工的组件 */
import reworkInspectReport from './otherReport/rework_inspect_report'/* 结束派工的组件 */
import fqcSplitRollReport from './otherReport/fqc_split_roll_report'/* 结束派工的组件 */
import changePackaging from './otherReport/change_packaging'/* 结束派工的组件 */
import createRecheck from './com_create_recheck'
import Com_split_schedule from '../schedule/com_split_schedule'
import comSplitOrderReport from './com_split_order_report'
import comPartStock from '../common/com_part_stock'
import column from '@/views/modules/common/column'
/* 展示物料库存的组件 */
/* 分切报工 */

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

var functionId = '104003006';

export default {
  data() {
    return {
      height: 800,
      authEdit: false,
      authAdd: false,
      authDelete: false,
      menuId: this.$route.meta.menuId,
      menuShow: false,
      showOperatorFlag: false,
      showReportFlag: false,
      showSplitReportFlag: false,
      showDefault: false,
      visible: false,
      fqcShowReportFlag: false,
      reworkShowReportFlag: false,
      fqcRollShowReportFlag: false,
      showFinishScheduleFlag: false,
      changePackagingFlag: false,
      showPartStockFlag: false,
      searchData: {
        site: this.$store.state.user.site,
        resourceId: '',
        orderNo: '',
        seqNo: '',
        planStartTime1: '',
        planStartTime2: '',
        closedFlag: 'N',
        status: 1,
        username: this.$store.state.user.name,
        searchFlag: false,
        exportFlag: "N",
      },
      currentRow: {},
      operatorData: {
        site: this.$store.state.user.site,
        username: this.$store.state.user.name,
        userDisplay: this.$store.state.user.userDisplay,
        operatorId: '',
        operatorName: '',
        status: '',
        showFlag: false
      },
      produceScheduleList: [],
      dataListLoading: false,
      columnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceSerialNumber',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'serialNumber',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '序号',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceOrderNo',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'orderNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '生产订单号',
          columnWidth: 120,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceSeqNo',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'seqNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '派工单号',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceItemNo',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'itemNo',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '生产工序',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceItemDesc',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'itemDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '工序名称',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceResourceId',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'resourceId',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '生产机台',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProducePartNo',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'partNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '产品编码',
          columnWidth: 120,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProducePartDesc',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'partDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '产品名称',
          columnWidth: 200,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceSpec',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'spec',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '规格型号',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceQtyRequired',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'qtyRequired',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '需求数量',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceQtyReported',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'qtyReported',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '完工数量',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceQtyToReport',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'qtyToReport',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '未完数量',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceTimeRequired',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'timeRequired',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '需求时间',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceTimeReported',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'timeReported',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '累计工时(m)',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceQtyApprove',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'qtyApprove',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '合格数量',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceQtyScrapt',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'qtyScrapt',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '不良数量',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceScheduledDate',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'scheduledDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '排产日期',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProducePlanStartTime',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'planStartTime',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '计划开工时间',
          columnWidth: 130,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProducePlanFinishTime',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'planFinishTime',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '计划完工时间',
          columnWidth: 130,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceShiftNo',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'shiftNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '班次',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceMachSetupTime',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'machSetupTime',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '调机时间',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceMachRunFactor',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'machRunFactor',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '单位产出',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceFactorUnit',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'factorUnit',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '产出单位',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceEfficiency',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'efficiency',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '效率',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceNextItemNo',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'nextItemNo',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '下道工序号',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceNextItemDesc',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'nextItemDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '下道工序名称',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProducePreItemNo',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'preItemNo',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '前道工序号',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProducePreItemDesc',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'preItemDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '前道工序名称',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceCustomerName',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'customerName',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '客户名称',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceCustPartNo',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'custPartNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '客户料号',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProducePreResourceInfo',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'preResourceInfo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '上工序机台信息',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProducePreQtyFinished',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'preQtyFinished',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '上工序完工数',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceNeedDate',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'needDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '生产订单要求完工日期',
          columnWidth: 160,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceClosedFlag',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'closedFlag',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '已关闭',
          columnWidth: 50,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceBarcodeId',
          tableId: '5302Produce',
          tableName: '条形码',
          columnProp: 'barcodeId',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '条形码',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceRemark',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'remark',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '备注',
          columnWidth: 200,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceCrewSize',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'crewSize',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '操作工人数',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceOutWorkFlag',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'outWorkFlag',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '是否外协',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceScheduledSeqNo',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'scheduledSeqNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '次序号',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceParkFlag',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'parkFlag',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '暂停',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceQtyRequiredOriginal',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'qtyRequiredOriginal',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '原始派工单需求数量',
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceClosedBy',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'closedBy',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '关闭人',
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5302,
          serialNumber: '5302ProduceClosedDate',
          tableId: '5302Produce',
          tableName: '待生产工单',
          columnProp: 'closedDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '关闭日期',
          columnWidth: 130,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        }
      ],
      reportButton: {
        normalReportButton: true,
        fqcReportButton: true,
        reworkReportButton: true,
        packReportButton: true,
        fqcSegmentReportButton: true,
        slitReportButton: true
      },
      menuButton: {
        prdButton: true,
        openButton: true,
        closedButton: true,
        pauseButton: true,
        openReverseButton: true,
        costRollUpFlagButton: true,
        canceledCostRollUpFlagButton: false,
        manualFlagButton: false,
        canceledManualFlagButton: false,
        repairSOFlagButton: false,
        canceledRepairSOFlagButton: false,
        canceledAllPrdButton: false,
        createRecheckButton: false,
        partStockFlag: true/* 查看物料库存 */
      },
      queryTable: {
        userId: this.$store.state.user.name,
        functionId: this.$route.meta.menuId,
        tableId: '5302Produce',
        languageCode: this.$i18n.locale
      },
      // 用户table 查询参数
      queryTableUser: {
        userId: this.$store.state.user.name,
        functionId: this.$route.meta.menuId,
        tableId: '5302Produce',
        status: true,
        languageCode: this.$i18n.locale
      },
      // 用户table 配置集合
      userColumnList: [],
      buttons: {
        searchButton: '查询',
        reportButton: '报工',
        fqcReportButton: 'FQC报工',
        reworkInspectReport: '返工重检',
        repackageReport: '换包装',
        fqcSplitRollReport: 'FQC分卷',
        splitReport: '分切报工',
        settingTable: '设置列表',
        defaultTable: '设置默认配置',
      },
      queryButton: {
        functionId: functionId,
        table_id: '*',
        languageCode: this.$i18n.locale,
        objectType: 'button'
      },
      labels: {
        menuLabel: '菜单',
        siteNo: '工厂编号:',
        resourceId: '机台编号:',
        planStartTime: '计划开工时间:',
        orderNo: '生产订单号:',
        seqNo: '派工单号:',
        showFinishedSeqNo: '显示已结束派工单',
        shopOrderList: '生产工单列表 ',
        primaryMenu: '主菜单',
        shopOrderLabel: '生产订单',
        closeLabel: '关闭',
        openLabel: '打开',
        pauseLabel: '暂停',
        reopenLabel: '重新开工',
        createReCheckSeqNo: '创建重检派工单',
        cancelAllScheduleOperations: '取消所有派工单操作',
        prodIssued: '生产已排料',
        cancelProdIssued: '取消生产已排料',
        viewPartStock: '查看物料库存',
        toolIssued: '刀模已发',
        cancelToolIssued: '取消刀模已发',
        printIssued: '印版已发',
        cancelPrintIssued: '取消印版已发',
        pleaseSelectSchedule: '请先选择派工单!',
        confirmLabel: '确定',
        cancelLabel: '取消',
        sureCloseThisSchedule: '确定要关闭当前派工单吗？',
        closeScheduleLabel: '关闭派工单',
        sureOpenThisSchedule: '确定要打开当前派工单吗？',
        surePauseThisSchedule: '确定要暂停当前派工单吗？？',
        sureReopenThisSchedule: '确定要重开当前派工单吗？',
        sureCancelScheduleAllOperations: '确定取消所有派工单操作？',
        sureThisOrderMaterialIsIssued: '确定该订单的料已排？',
        sureCancelThisOrderMaterialIssued: '确定要撤销该订单的排料？',
        cancelOrderMaterialIssued: '撤销订单排料',
        sureThisOrderToolIsIssued: '确定该订单的刀模已发？',
        sureCancelThisOrderToolIssued: '确定要撤销该订单的刀模已发？',
        sureThisOrderPrintIsIssued: '确定该订单的印版已发？',
        sureCancelThisOrderPrintIssued: '确定要撤销该订单的印版已发？',
        thisScheduleCantReport: '当前派工单无法使用报工!',
        thisOrderIsNotSplitOrder: '当前工单非分切工单!',
        thisScheduleIsNotFqc: '当前派工单非FQC报工派工单!',
        thisOrderIsNotSpecialOrder: '该订单不是特殊订单，不能采用该功能！',
        operatorCantBeUsed: '操作员信息不可用!',
      },
      queryLabel: {
        functionId: functionId,
        table_id: '*',
        languageCode: this.$i18n.locale,
        objectType: 'label'
      },
      // 导出 start
      exportList: [],
      exportName: "生产工单",
      exportHeader: [],
      exportFooter: [],
      exportDefaultValue: "",
      // 导出 end
    }
  },
  components: {
    Chooselist, /* 选择的组件 */
    Com_split_schedule,
    comSwitchOperator, /* 切换用户的组件 */
    comProduceReportNormal, /* 报工页面的组件 */
    comSplitOrderReport, /* 分切报工 */
    comFinishSchedule, /* 结束派工单的组件 */
    fqcProduceReportNormal, /* FQC报工 */
    reworkInspectReport, /* 返工重建 */
    fqcSplitRollReport, /* FQC分卷 */
    createRecheck, /* 创建重检派工单 */
    changePackaging, /* 换包装 */
    comPartStock, /* 展示物料库存的组件 */
    column/* 动态列 */
  },
  mounted() {
    this.$nextTick(() => {
      this.height = window.innerHeight - 235
    })
  },
  methods: {


    // 控制是否显示功能
    menuButtonFlag() {
      this.menuShow = false
      if (JSON.stringify(this.currentRow) == '{}') {
        this.menuButton.prdButton = true
        this.menuButton.openButton = true
        this.menuButton.closedButton = true
        this.menuButton.pauseButton = true
        this.menuButton.costRollUpFlagButton = true
        this.menuButton.canceledCostRollUpFlagButton = true
        this.menuButton.manualFlagButton = true
        this.menuButton.canceledManualFlagButton = true
        this.menuButton.repairSOFlagButton = true
        this.menuButton.canceledRepairSOFlagButton = true
        this.menuButton.canceledAllPrdButton = true
        this.menuButton.createRecheckButton = true
      } else {
        let currentRow = null
        // 获取订单信息
        let searchOrder = {
          orderNo: this.currentRow.orderNo,
          seqNo: this.currentRow.seqNo,
          site: this.currentRow.site,
          username: this.$store.state.user.name,
          searchFlag: true,
          exportFlag: 'N',
        }
        getProduceScheduleList(searchOrder).then(({data}) => {
          // 设置查询数据
          currentRow = data.rows[0]
          if (currentRow == null) {
            return
          }
          // this.menuButton.canceledAllPrdButton = false
          this.menuButton.createRecheckButton = false
          this.menuButton.partStockFlag = false
          // 判断是否具有该页面权限
          let menList = JSON.parse(sessionStorage.getItem('dynamicMenuRoutes') || '[]').filter(item => item.path == 'shopOrder-shopOrder/shopOrder')
          if (menList.length > 0) {
            this.menuButton.prdButton = false
          }
          let canceledAllPrd = {
            userSpecialSecurityNo: 232,
            username: this.$store.state.user.name
          }
          getUserSpecialSecurity(canceledAllPrd).then(({data}) => {
            if (data.userSpecialSecurity == 'Y') {
              this.menuButton.canceledAllPrdButton = false
            } else {
              this.menuButton.canceledAllPrdButton = true
            }
          })
          // 关闭按钮
          if (currentRow.closedFlag == 'N') {
            let data = {
              userSpecialSecurityNo: 230,
              username: this.$store.state.user.name
            }
            getUserSpecialSecurity(data).then(({data}) => {
              if (data.userSpecialSecurity == 'Y') {
                this.menuButton.closedButton = false
              } else {
                this.menuButton.closedButton = true
              }
            })
          } else {
            this.menuButton.closedButton = true
          }
          // 打开按钮
          if (currentRow.closedFlag == 'Y') {
            let data = {
              userSpecialSecurityNo: 231,
              username: this.$store.state.user.name
            }
            getUserSpecialSecurity(data).then(({data}) => {
              if (data.userSpecialSecurity == 'Y') {
                this.menuButton.openButton = false
              } else {
                this.menuButton.openButton = true
              }
            })
          } else {
            this.menuButton.openButton = true
          }
          // 暂停
          if (currentRow.closedFlag == 'N' && currentRow.parkFlag == 'N') {
            this.menuButton.pauseButton = false
          } else {
            this.menuButton.pauseButton = true
          }
          // 重开
          if (currentRow.closedFlag == 'N' && currentRow.parkFlag == 'Y') {
            this.menuButton.openReverseButton = false
          } else {
            this.menuButton.openReverseButton = true
          }
          //  生产排料
          if (currentRow.matIssueFlag == 'N') {
            // 获取特殊权限
            let data = {
              userSpecialSecurityNo: 238,
              username: this.$store.state.user.name
            }
            getUserSpecialSecurity(data).then(({data}) => {
              if (data.userSpecialSecurity == 'Y') {
                this.menuButton.costRollUpFlagButton = false
              } else {
                this.menuButton.costRollUpFlagButton = true
              }
            })
          } else {
            this.menuButton.costRollUpFlagButton = true
          }
          //  取消生产排料
          if (currentRow.matIssueFlag == 'Y') {
            // 获取特殊权限
            let data = {
              userSpecialSecurityNo: 238,
              username: this.$store.state.user.name
            }
            getUserSpecialSecurity(data).then(({data}) => {
              if (data.userSpecialSecurity == 'Y') {
                this.menuButton.canceledCostRollUpFlagButton = false
              } else {
                this.menuButton.canceledCostRollUpFlagButton = true
              }
            })
          } else {
            this.menuButton.canceledCostRollUpFlagButton = true
          }
          // 刀模已发 确认
          if (currentRow.toolIssueFlag == 'N') {
            // 获取特殊权限
            let data = {
              userSpecialSecurityNo: 258,
              username: this.$store.state.user.name
            }
            getUserSpecialSecurity(data).then(({data}) => {
              if (data.userSpecialSecurity == 'Y') {
                this.menuButton.manualFlagButton = false
              } else {
                this.menuButton.manualFlagButton = true
              }
            })
          } else {
            this.menuButton.manualFlagButton = true
          }
          // 刀模已发 取消
          if (currentRow.toolIssueFlag == 'Y') {
            // 获取特殊权限
            let canceledAllPrdData = {
              userSpecialSecurityNo: 259,
              username: this.$store.state.user.name
            }
            getUserSpecialSecurity(canceledAllPrdData).then(({data}) => {
              if (data.userSpecialSecurity == 'Y') {
                this.menuButton.canceledManualFlagButton = false
              } else {
                this.menuButton.canceledManualFlagButton = true
              }
            })
          } else {
            this.menuButton.canceledManualFlagButton = true
          }
          // 印版已发 确认
          if (currentRow.plateIssueFlag == 'N') {
            // 获取特殊权限
            let data = {
              userSpecialSecurityNo: 259,
              username: this.$store.state.user.name
            }
            getUserSpecialSecurity(data).then(({data}) => {
              if (data.userSpecialSecurity == 'Y') {
                this.menuButton.repairSOFlagButton = false
              } else {
                this.menuButton.repairSOFlagButton = true
              }
            })
          } else {
            this.menuButton.repairSOFlagButton = true
          }
          // 印版已发 取消
          if (currentRow.plateIssueFlag == 'Y') {
            // 获取特殊权限
            let data = {
              userSpecialSecurityNo: 259,
              username: this.$store.state.user.name
            }
            getUserSpecialSecurity(data).then(({data}) => {
              if (data.userSpecialSecurity == 'Y') {
                this.menuButton.canceledRepairSOFlagButton = false
              } else {
                this.menuButton.canceledRepairSOFlagButton = true
              }
            })
          } else {
            this.menuButton.canceledRepairSOFlagButton = true
          }
          this.menuShow = true
        })
      }
    },
    /* 区分不同的菜单  调用不同的方法  调用不同的方法 */
    handleCommand(val) {
      // 区分是哪一个方法调用
      // 页面跳转
      if (val == '0') {
        if (JSON.stringify(this.currentRow) == '{}') {
          this.$message.error(this.labels.pleaseSelectSchedule)
          return false
        }
        this.$router.push({
          path: '/shopOrder-shopOrder/shopOrder',
          query: {
            order: this.currentRow.orderNo,
            site: this.currentRow.site,
            user: this.$store.state.user.name
          }
        })
      }

      if (val === '查看物料库存') {
        // 判断是否选择好了工单
        if (this.currentRow == null || this.currentRow == {}) {
          // 重置按钮
          this.menuButton.partStockFlag = true
          // 返回错误
          this.$message.error(this.labels.pleaseSelectSchedule)
          return false
        }
        let tempData = {'site': this.currentRow.site, 'orderNo': this.currentRow.orderNo}
        // 打开组件  需要的数据 展示需要的数据
        this.$nextTick(() => {
          this.showPartStockFlag = true
          this.$refs.comPartStock.init(tempData)
        })
      }
      // 关闭
      if (val == '1') {
        // 调用提示的方法
        this.$confirm(this.labels.sureCloseThisSchedule, this.labels.closeScheduleLabel, {
          confirmButtonText: this.labels.confirmLabel,
          cancelButtonText: this.labels.cancelLabel,
          type: 'warning'
        }).then(() => {
          let data = {
            username: this.$store.state.user.name,
            itemNo: this.currentRow.itemNo,
            site: this.currentRow.site,
            orderNo: this.currentRow.orderNo,
            seqNo: this.currentRow.seqNo,
            closedFlag: 'Y'
          }
          closeOrOpenProduceOrder(data).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      }
      // 打开
      if (val == '2') {
        // 调用提示的方法
        this.$confirm(this.labels.sureOpenThisSchedule, this.labels.closeScheduleLabel, {
          confirmButtonText: this.labels.confirmLabel,
          cancelButtonText: this.labels.cancelLabel,
          type: 'warning'
        }).then(() => {
          let data = {
            username: this.$store.state.user.name,
            itemNo: this.currentRow.itemNo,
            site: this.currentRow.site,
            orderNo: this.currentRow.orderNo,
            seqNo: this.currentRow.seqNo,
            closedFlag: 'N'
          }
          closeOrOpenProduceOrder(data).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      }
      // 暂停
      if (val == '3') {
        // 调用提示的方法
        this.$confirm(this.labels.surePauseThisSchedule, this.labels.closeScheduleLabel, {
          confirmButtonText: this.labels.confirmLabel,
          cancelButtonText: this.labels.cancelLabel,
          type: 'warning'
        }).then(() => {
          let data = {
            username: this.$store.state.user.name,
            itemNo: this.currentRow.itemNo,
            site: this.currentRow.site,
            orderNo: this.currentRow.orderNo,
            seqNo: this.currentRow.seqNo,
            parkFlag: 'Y'
          }
          pauseOrOpenProduceOrder(data).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      }
      // 重开
      if (val == '4') {
        // 调用提示的方法
        this.$confirm(this.labels.sureReopenThisSchedule, this.labels.closeScheduleLabel, {
          confirmButtonText: this.labels.confirmLabel,
          cancelButtonText: this.labels.cancelLabel,
          type: 'warning'
        }).then(() => {
          let data = {
            username: this.$store.state.user.name,
            itemNo: this.currentRow.itemNo,
            site: this.currentRow.site,
            orderNo: this.currentRow.orderNo,
            seqNo: this.currentRow.seqNo,
            parkFlag: 'N'
          }
          pauseOrOpenProduceOrder(data).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      }
      // 创建重检派工单
      if (val == '5') {
        this.$nextTick(() => {
          this.$refs.createRecheck.init(this.currentRow)
        })
      }
      // 取消所有派工单操作
      if (val == '6') {
        // 调用提示的方法
        this.$confirm(this.labels.sureCancelScheduleAllOperations, this.labels.shopOrderLabel, {
          confirmButtonText: this.labels.confirmLabel,
          cancelButtonText: this.labels.cancelLabel,
          type: 'warning'
        }).then(() => {
          let data = {
            orderNo: this.currentRow.orderNo,
            itemNo: this.currentRow.itemNo,
            site: this.currentRow.site,
            seqNo: this.currentRow.seqNo,
            username: this.searchData.username,
            userDisplay: this.searchData.userDisplay
          }
          workbenchCancelallops(data).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
            } else {
              this.$message.warning(data.msg)
            }
          })
        })
      }
      // 生产已排料 确认
      if (val == '7') {
        // 调用提示的方法
        this.$confirm(this.labels.sureThisOrderMaterialIsIssued, this.labels.prodIssued, {
          confirmButtonText: this.labels.confirmLabel,
          cancelButtonText: this.labels.cancelLabel,
          type: 'warning'
        }).then(() => {
          let data = {
            site: this.currentRow.site,
            orderNo: this.currentRow.orderNo,
            itemNo: this.currentRow.itemNo,
            seqNo: this.currentRow.seqNo,
            username: this.$store.state.user.name,
            matIssueFlag: 'Y',
            orderChangeStatus: '订单已排料'
          }
          costRollUpProduceOrder(data).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
            } else {
              this.$message.warning(data.msg)
            }
          })
        })
      }
      // 生产已排料 取消
      if (val == '8') {
        // 调用提示的方法
        this.$confirm(this.labels.sureCancelThisOrderMaterialIssued, this.labels.cancelOrderMaterialIssued, {
          confirmButtonText: this.labels.confirmLabel,
          cancelButtonText: this.labels.cancelLabel,
          type: 'warning'
        }).then(() => {
          let data = {
            site: this.currentRow.site,
            orderNo: this.currentRow.orderNo,
            itemNo: this.currentRow.itemNo,
            seqNo: this.currentRow.seqNo,
            matIssueFlag: 'N',
            orderChangeStatus: '撤销订单排料'
          }
          costRollUpProduceOrder(data).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
            } else {
              this.$message.warning(data.msg)
            }
          })
        })
      }
      // 刀模 确认
      if (val == '9') {
        this.$confirm(this.labels.sureCancelThisOrderToolIssued, this.labels.toolIssued, {
          confirmButtonText: this.labels.confirmLabel,
          cancelButtonText: this.labels.cancelLabel,
          type: 'warning'
        }).then(() => {
          let data = {
            site: this.currentRow.site,
            orderNo: this.currentRow.orderNo,
            itemNo: this.currentRow.itemNo,
            seqNo: this.currentRow.seqNo,
            toolIssueFlag: 'Y',
            orderChangeStatus: '订单刀模已发'
          }
          manualProduceOrder(data).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
            } else {
              this.$message.warning(data.msg)
            }
          })
        })
      }
      // 刀模 取消
      if (val == '10') {
        this.$confirm(this.labels.sureCancelThisOrderToolIssued, this.labels.toolIssued, {
          confirmButtonText: this.labels.confirmLabel,
          cancelButtonText: this.labels.cancelLabel,
          type: 'warning'
        }).then(() => {
          let data = {
            site: this.currentRow.site,
            orderNo: this.currentRow.orderNo,
            itemNo: this.currentRow.itemNo,
            seqNo: this.currentRow.seqNo,
            toolIssueFlag: 'N',
            orderChangeStatus: '撤销订单刀模已发'
          }
          manualProduceOrder(data).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
            } else {
              this.$message.warning(data.msg)
            }
          })
        })
      }
      // 印版已发
      if (val == '11') {
        this.$confirm(this.labels.sureThisOrderPrintIsIssued, this.labels.printIssued, {
          confirmButtonText: this.labels.confirmLabel,
          cancelButtonText: this.labels.cancelLabel,
          type: 'warning'
        }).then(() => {
          let data = {
            site: this.currentRow.site,
            orderNo: this.currentRow.orderNo,
            itemNo: this.currentRow.itemNo,
            seqNo: this.currentRow.seqNo,
            plateIssueFlag: 'Y',
            orderChangeStatus: '订单印版已发'
          }
          repairSOFlagProduceOrder(data).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
            } else {
              this.$message.warning(data.msg)
            }
          })
        })
      }
      // 印版已发 取消
      if (val == '12') {
        this.$confirm(this.labels.sureCancelThisOrderPrintIssued, this.labels.printIssued, {
          confirmButtonText: this.labels.confirmLabel,
          cancelButtonText: this.labels.cancelLabel,
          type: 'warning'
        }).then(() => {
          let data = {
            site: this.currentRow.site,
            orderNo: this.currentRow.orderNo,
            itemNo: this.currentRow.itemNo,
            seqNo: this.currentRow.seqNo,
            plateIssueFlag: 'N',
            orderChangeStatus: '订单印版已发'
          }
          repairSOFlagProduceOrder(data).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
            } else {
              this.$message.warning(data.msg)
            }
          })
        })
      }
    },
    // FQC 报工
    fqcReportModal() {
      // 首先判断是否选择好派工单
      if (JSON.stringify(this.currentRow) == '{}') {
        this.$message.error(this.labels.pleaseSelectSchedule)
        return false
      }
      // 打开操作员切换功能
      this.fqcShowReportFlag = true
      this.$nextTick(() => {
        this.$refs.fqcProduceReportNormal.init(this.currentRow.seqNo, this.operatorData)
      })
    },
    // FQC 分卷
    fqcSplitRollModal() {
      if (JSON.stringify(this.currentRow) == '{}') {
        this.$message.error(this.labels.pleaseSelectSchedule)
        return false
      }
      // 打开操作员切换功能
      this.fqcRollShowReportFlag = true
      this.$nextTick(() => {
        this.$refs.fqcSplitRollReport.init(this.currentRow.seqNo, this.operatorData)
      })
    },
    // 返工重捡
    reworkInspectModal() {
      // 首先判断是否选择好派工单
      if (JSON.stringify(this.currentRow) == '{}') {
        this.$message.error(this.labels.pleaseSelectSchedule)
        return false
      }
      // 打开操作员切换功能
      this.reworkShowReportFlag = true
      this.$nextTick(() => {
        this.$refs.reworkInspectReport.init(this.currentRow.seqNo, this.operatorData)
      })
    },
    // 换包装
    changePackaging() {
      // 首先判断是否选择好派工单
      if (JSON.stringify(this.currentRow) == '{}') {
        this.$message.error(this.labels.pleaseSelectSchedule)
        return false
      }
      // 打开操作员切换功能
      this.changePackagingFlag = true
      this.$nextTick(() => {
        this.$refs.changePackaging.init(this.currentRow.seqNo, this.operatorData)
      })
    },

    /* 查询派工单 */
    getProduceScheduleList() {
      // 开始真的查询;
      this.searchData.searchFlag = true
      getProduceScheduleList(this.searchData).then(({data}) => {
        // 设置查询数据
        this.produceScheduleList = data.rows
      })
    },

    /* 刷新页面table */
    refreshPageTables() {
      this.currentRow = {}
      this.getProduceScheduleList()
    },
    /* 设置选中行的参数 */
    setCurrentRow(row, column, event) {
      this.currentRow = JSON.parse(JSON.stringify(row))
    },

    // 设置参数
    initOperatorData(operatorData) {
      this.showOperatorFlag = false
      this.operatorData = JSON.parse(JSON.stringify(operatorData))
      if (operatorData.reportType == 0) {
        // 切换到报工组件
        this.switchProduceReportModal()
      }

      if (operatorData.reportType == 1) {
        // 切换到fqc报工组件
        this.fqcReportModal()
      }

      if (operatorData.reportType == 2) {
        // 切换到返工 重检组件
        this.reworkInspectModal()
      }
      if (operatorData.reportType == 3) {
        // 切换到fqc分卷组件
        this.fqcSplitRollModal()
      }
      if (operatorData.reportType == 4) {
        // 换包装
        this.changePackaging()
      }

      /* 分切报工 */
      if (operatorData.reportType == 8) {
        // 分切报工
        this.showSplitOrderReportModal()
      }
    },

    notInitOperatorData(val) {
      // 注意：现在关闭对话框时会自动设置为当前登录人，不再清空操作员信息
      // 关闭切换用户模态框
      this.showOperatorFlag = false
      if (val == 0) {
        // 切换到报工组件
        this.switchProduceReportModal()
      }

      if (val == 1) {
        // 切换到fqc报工组件
        this.fqcReportModal()
      }

      if (val == 2) {
        // 切换到返工 重检组件
        this.reworkInspectModal()
      }
      if (val == 3) {
        // 切换到fqc分卷组件
        this.fqcSplitRollModal()
      }
      if (val == 4) {
        // 切换到换包装
        this.changePackaging()
      }

      // 分切报工
      if (val == 8) {
        // 分切报工
        this.showSplitOrderReportModal()
      }
    },
    // 切换员工modal
    switchOperatorModal(val) {
      // 首先判断是否选择好派工单
      if (JSON.stringify(this.currentRow) == '{}') {
        this.$message.error(this.labels.pleaseSelectSchedule)
        return false
      }
      //获取下一道工序
      let nextItemNo = this.currentRow.nextItemNo;

      if (val == 0) {
        let orderType = this.currentRow.orderType
        let workCenterNo = this.currentRow.workCenterNo
        // if (orderType != 'S' || workCenterNo === 'FQC' || nextItemNo == 0) {
        //   // 验证通过
        //   this.$message.error(this.labels.thisScheduleCantReport)
        //   return false
        // }
        let data = {
          site: this.currentRow.site,
          resourceId: this.currentRow.resourceId,
          workCenterNo: this.currentRow.workCenterNo,
          seqNo: this.currentRow.seqNo,
          username: this.$store.state.user.name
        }
        reportCheck(data).then(({data}) => {
          if (data.code == 0) {
            // 打开操作员切换功能
            this.showOperatorFlag = true
            this.$nextTick(() => {
              this.$refs.comSwitchOperator.init(val, this.currentRow, false, false)
            })
          }
          if (data.code == 300) {
            this.$message.warning(data.msg)
          }
          if (data.code == 400) {
            this.$confirm(`${data.msg}`, '提示', {
              confirmButtonText: this.labels.confirmLabel,
              cancelButtonText: this.labels.cancelLabel,
              type: 'warning'
            }).then(() => {
              // 打开操作员切换功能
              this.showOperatorFlag = true
              this.$nextTick(() => {
                this.$refs.comSwitchOperator.init(val, this.currentRow, false, false)
              })
            })
          }
        })
      } else if (val == 8) { // 处理 分切工单
        // 判断当前工单是否是分切工单
        let orderType = this.currentRow.orderType
        if (orderType === 'D') {
          this.showOperatorFlag = true
          this.$refs.comSwitchOperator.init(val, this.currentRow, false, false)
        } else {
          this.$message.error(this.labels.thisOrderIsNotSplitOrder)
          return false
        }
      } else if (val == 1) { // 处理 FQC
        // 判断订单类型和加工中心
        let workCenterNo = this.currentRow.workCenterNo
        if (workCenterNo === 'FQC' || nextItemNo == 0) {
          this.showOperatorFlag = true
          this.$refs.comSwitchOperator.init(val, this.currentRow, false, false)
        } else {
          this.$message.error(this.labels.thisScheduleIsNotFqc)
          return false
        }
      } else {
        if (val == 4) {
          getShopOrder(this.currentRow).then(({data}) => {
            if (data.code == 0) {
              if (data.data == 'P') {
                // 打开操作员切换功能
                this.showOperatorFlag = true
                this.$nextTick(() => {
                  this.$refs.comSwitchOperator.init(val, this.currentRow, false, false)
                })
              } else {
                this.$alert(this.labels.thisOrderIsNotSpecialOrder, '提示', {
                  confirmButtonText: this.labels.confirmLabel
                })
              }
            }
          })
        } else {
          // 打开操作员切换功能
          this.showOperatorFlag = true
          this.$nextTick(() => {
            this.$refs.comSwitchOperator.init(val, this.currentRow, false, false)
          })
        }
      }
    },

    // 切换报工modal
    switchProduceReportModal() {
      // 首先判断是否选择好派工单
      if (JSON.stringify(this.currentRow) == '{}') {
        this.$message.error(this.labels.pleaseSelectSchedule)
        return false
      }
      // 打开操作员切换功能
      this.showReportFlag = true
      this.$nextTick(() => {
        this.$refs.comProduceReportNormal.init(this.currentRow.seqNo, this.operatorData)
      })
    },

    // 打开分切报工的
    showSplitOrderReportModal() {
      // 首先判断是否选择好派工单
      if (JSON.stringify(this.currentRow) == '{}') {
        this.$message.error(this.labels.pleaseSelectSchedule)
        return false
      }
      this.$nextTick(() => {
        // 打开分切报工功能
        this.showSplitReportFlag = true
        this.$refs.comSplitOrderReport.init(this.currentRow.seqNo, this.operatorData)
      })
    },

    // 打开结束派工单的modal
    showFinishScheduleModal() {
      // 首先判断是否选择好派工单
      if (JSON.stringify(this.currentRow) == '{}') {
        this.$message.error(this.labels.pleaseSelectSchedule)
        return false
      }
      // 打开操作员切换功能
      this.showFinishScheduleFlag = true
      this.$nextTick(() => {
        this.$refs.comFinishSchedule.init(this.currentRow, this.operatorData)
      })
    },

    // 结束派工单后刷新页面
    processFinishScheduleOperation() {
      // 刷新当前页面的数据
      this.refreshPageTables()
    },

    // 保存操作员的信息
    saveOperatorData() {
      // 查询操作员信息
      getOperatorData(this.operatorData).then(({data}) => {
        let operatorData = data.row
        let status = operatorData.status
        this.operatorData.operatorName = data.row.operatorName
        // 重置操作员信息状态
        this.operatorData.status = status
        // 判断是否验证通过
        if (status == 'N') {
          this.operatorFlag = false
        } else {
          this.operatorFlag = true
        }
        if (!this.operatorFlag) {
          this.$message.error(this.labels.operatorCantBeUsed)
        }
      })
        // 判断是否检查通过--不通过不在继续
        .then(() => {
          if (!this.operatorFlag) {
            return false
          }
          // 关闭操作员切换功能
          this.operatorData.showFlag = false
          // 打开组件
          this.showReportFlag = true
          // 打开报工操作页面
          this.$nextTick(() => {
            this.$refs.comProduceReportNormal.init(this.currentRow.seqNo, this.operatorData)
          })
        })
    },

    /* 列表方法的回调 */
    getBaseData(val) {
      if (this.tagNo === 95) {
        this.searchData.resourceId = val.ResourceID
      }
    },

    // 获取基础数据列表
    getBaseList(val) {
      this.tagNo = val
      this.$nextTick(() => {
        let strVal = ''
        if (val === 95) {
          strVal = this.searchData.resourceId
        }
        this.$refs.baseList.init(val, strVal, " AND WorkCenterNo <> 'FQC'")
      })
    },

    // 打开页面设置
    userSetting() {
      this.visible = true
      let queryTable = {
        userId: this.$store.state.user.name,
        functionId: this.$route.meta.menuId,
        tableId: '5302Produce',
        languageCode: this.$i18n.locale
      }
      this.$nextTick(() => {
        this.$refs.column.init(queryTable)
      })
    },
    // 获取 用户保存的 格式列
    getTableUserColumn() {
      getTableUserListLanguage(this.queryTableUser).then(({data}) => {
        if (data && data.code == 0 && data.rows.length > 0) {
          // this.columnList = []
          this.columnList = data.rows
        } else {
          this.getColumnList()
        }
      })
    },
    // 保存 默认配置 列
    async saveColumnList() {
      // 删除所有的该页面下保存的数据
      if (this.userColumnList) {
        // 删除 user自定义的数据
        await removerUser(this.queryTable)
      }
      // 删除默认配置
      await removerDefault(this.queryTable)
      // 保存页面 table属性
      let sumColumnList = this.columnList// concat(this.columnList1);
      sumColumnList = sumColumnList.map(item => {
        return item = {
          tableId: item.tableId,
          tableName: item.tableName,
          columnProp: item.columnProp,
          columnLabel: item.columnLabel,
          columnHidden: item.columnHidden,
          columnImage: item.columnImage,
          columnSortable: item.columnSortable,
          columnWidth: item.columnWidth,
          format: item.format,
          functionId: this.$route.meta.menuId,
          sortLv: item.sortLv,
          status: true,
          fixed: item.fixed,
          serialNumber: item.serialNumber,
          columnType: item.columnType,
          align: item.align
        }
      })

      await saveTableDefaultList(sumColumnList)
      // 保存页面 button label title 属性
      /* let buttons = this.buttonList.map(item => {
         return item = {
           functionId: this.$route.meta.menuId,
           languageValue: item.languageValue,
           objectId: item.objectId,
           objectType: item.objectType,
           tableId: item.tableId
         }
       })
       await saveButtonList(buttons) */
      this.getFunctionButtonList()
      this.getColumnList()
    },
    // 获取 tableDefault 列
    getColumnList() {
      getTableDefaultListLanguage(this.queryTable).then(({data}) => {
        if (data && data.code == 0) {
          // this.showDefault = false
          this.columnList = data.rows
        } else {
          // this.showDefault = true
        }
      })
    },

    //获取按钮的权限数据
    getButtonAuthData() {
      let updateFlag = this.isAuth(this.menuId + ":revise");
      let fullControFlag = this.isAuth(this.menuId + ":fullContro");
      let deleteFlag = this.isAuth(this.menuId + ":remove");
      //处理页面的权限数据
      this.authEdit = !updateFlag && !fullControFlag;
      this.authAdd = !fullControFlag;
      this.authDelete = !deleteFlag;
    },


    //获取多语言的信息
    getMultiLanguageList() {
      //首先查询当前按钮的多语言
      searchFunctionButtonList(this.queryButton).then(({data}) => {
        if (data && data.code == 0) {
          this.buttons = data.data
        } else {
          // saveButtonList(this.buttonList).then(({data}) => {
          // })
        }
      });
      //其次查询当前标签的多语言
      searchFunctionButtonList(this.queryLabel).then(({data}) => {
        if (data && data.code == 0) {
          this.labels = data.data
        } else {
          // saveButtonList(this.buttonList).then(({data}) => {
          // })
        }
      });
    },
    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
    },

    //导出excel
    async createExportData() {
      // 开始真的查询;
      this.searchData.searchFlag = true;
      this.searchData.exportFlag = "Y";
      await getProduceScheduleList(this.searchData).then(({data}) => {
        // 设置查询数据
        this.exportList = data.rows
      })
      //重置判断是否是导出的sql
      this.searchData.exportFlag = "N";
      return this.exportList;
    },
    startDownload() {
      //  this.exportData = this.dataList

    },
    finishDownload() {

    },

  },

  created() {
    // 根据登陆人员的username 查询机台授权表中的权限，筛选出对应的机台（默认第一个）
    let tempData = {
      username: this.$store.state.user.name,
    }
    getResourceByUser(tempData).then(({data}) => {
      if (data.code === 0) {
        if (data.rows.length > 0) {
          this.searchData.resourceId = data.rows[0].resourceID
        }
      }

      // 等待getResourceByUser执行完成后，再查询生产排程列表
      this.searchData.searchFlag = true;
      // 不查询
      getProduceScheduleList(this.searchData).then(({data}) => {
        // 设置查询数据
        //this.searchData.searchFlag = false;
        this.searchData.exportFlag = 'N';
        this.produceScheduleList = data.rows
      })
    })

    /* 获取报工的特殊权限 */
    getScheduleMultiReportSpecialAuth(this.searchData).then(({data}) => {
      let authMap = data.authMap
      // 区分是否打开按钮
      if (authMap.normalReportFlag === 'Y') {
        this.reportButton.normalReportButton = false
      } else {
        this.reportButton.normalReportButton = true
      }
      if (authMap.fqcReportFlag === 'Y') {
        this.reportButton.fqcReportButton = false
      } else {
        this.reportButton.fqcReportButton = true
      }
      if (authMap.reworkReportFlag === 'Y') {
        this.reportButton.reworkReportButton = false
      } else {
        this.reportButton.reworkReportButton = true
      }
      if (authMap.packReportFlag === 'Y') {
        this.reportButton.packReportButton = false
      } else {
        this.reportButton.packReportButton = true
      }
      if (authMap.fqcSegmentReportFlag === 'Y') {
        this.reportButton.fqcSegmentReportButton = false
      } else {
        this.reportButton.fqcSegmentReportButton = true
      }
      if (authMap.slitReportFlag === 'Y') {
        this.reportButton.slitReportButton = false
      } else {
        this.reportButton.slitReportButton = true
      }
    })
    // 获取动态表头的信息
    // this.getTableUserColumn()


    //获取按钮的权限
    this.getButtonAuthData();
    //
    // this.getMultiLanguageList();  //刷新多语言的信息

  }

}
</script>

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

</style>

<!--当前页面的标签样式-->
<style scoped lang="scss">

/*针对el-card*/
.customer-card .el-form-item__content {
  margin-top: -15px;
}

.customer-card .el-form-item {
  height: 22px;
}

.customer-border .el-form-item__content {
  margin-top: -30px;
}

/*全局年与日类型  宽度*/
div.el-time-width {
  width: 110px !important;
}

/* 全局时间右边框*/
.customer-css input.el-input__inner {
  height: 22px !important;
  padding-right: 0px !important;
}

/* 控制el-card标签的数据*/
div.customer-el-card {
  margin-left: 110px;
  margin-top: -15px;
  height: 20px;
  width: 60px;
}

/* 颜色控制 */
div.customer-el-card-pink {
  background: #FF00FF;
}

div.customer-el-card-orange {
  background: #FFD700;
}

div.customer-el-card-blue {
  background: #0000CD;
}

/*清掉样式*/
.el-radio + .el-radio {
  margin-left: 0px;
}

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

/*当前按钮的通用样式*/
.customer-css .el-button--medium {
  padding: 5px 5px;
}

/*添加主菜单和明细菜单的样式*/
.customer-css .customer-dropdown .el-button--primary {
  padding: 2px;
  font-size: 12px;
}

.el-dropdown-menu--medium .el-dropdown-menu__item {
  line-height: 18px;
  padding: 0 17px;
  font-size: 12px;
}

hr {
  margin-top: 0px;
}


/*控制上下间距*/
</style>
