<template>
  <div class="customer-css" >
    <!--  菜单按钮区域  -->
    <fieldset class="customer-field" style="margin-top: -3px; width: 612px; padding: 0.35em 0.35em 0.35em;" >
      <legend>菜单</legend>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -5px;" >
      <el-form-item :label="''" style="margin-left: 30px;">
        <el-button class="customer-bun-min" type="primary" @click="refreshPageTables" style="margin-left: 10px; margin-bottom: 5px;">刷新</el-button>
      </el-form-item>
      <el-form-item :label="''">
        <el-button class="customer-bun-min" type="primary" @click="moveUpScheduleBun" style="margin-left: 10px; margin-bottom: 5px;">上移</el-button>
      </el-form-item>
      <el-form-item :label="''">
          <el-button class="customer-bun-min" type="primary" @click="moveDownScheduleBun" style="margin-left: 10px; margin-bottom: 5px;">下移</el-button>
        </el-form-item>
      </el-form>
    </fieldset>
    <!--  排序规则  -->
    <fieldset class="customer-field" style="margin-left: 640px; margin-top: -41px; width: 135px;" >
      <legend>排序</legend><br>
      <el-form :inline="true" style="margin-top: -10px; margin-bottom: 10px;" label-position="top" label-width="100px" >
        <el-form-item :label="''" style="margin-bottom: 10px;">
          <el-radio-group v-model="pageData.sortField">
            <el-radio label="needDate">要求完工日期</el-radio>
            <el-radio label="orderNo">订单号</el-radio>
            <el-radio label="partNo">产品编码</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
    </fieldset>
    <!--  查询时间和产品  -->
    <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -32px;" >
      <el-form-item :label="'录入日期:'">
        <el-date-picker class="el-time-width"
                        style=""
                        v-model="pageData.enterTime1"
                        value-format="yyyy-MM-dd">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="''" style="margin-top: -10px;">
        <el-date-picker class="el-time-width"
                        style="margin-top: 30px;"
                        v-model="pageData.enterTime2"
                        value-format="yyyy-MM-dd" placeholder="">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="'要求完工日期:'">
        <el-date-picker class="el-time-width"
                        style=""
                        v-model="pageData.needTime1"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd" placeholder="">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="''" style="margin-top: -10px;">
        <el-date-picker class="el-time-width"
                        style="margin-top: 30px;"
                        v-model="pageData.needTime2"
                        value-format="yyyy-MM-dd" placeholder="">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="'产成品编码:'">
        <el-input v-model="pageData.partNo" style="width: 120px"></el-input>
      </el-form-item>
    </el-form>

    <!-- 排产信息   -->
    <fieldset class="customer-field" style="margin-top: 0px; width: 612px; padding: 0.125em;" >
      <legend>排产信息</legend>
      <!--  排产日期  -->
      <el-form :inline="true" label-position="top" label-width="100px"  style="margin-top: -5px;">
        <el-form-item :label="'排产日期:'">
          <el-date-picker class="el-time-width"
                          style=""
                          v-model="pageData.scheduleDate"
                          value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="''" style="margin-top: -10px;">
          <el-checkbox v-model="pageData.specifiedTime" true-label="Y"  false-label="N" style="margin-top: 28px; margin-right: -20px;" ></el-checkbox>
          <el-time-picker
            format="HH:mm"
            arrow-control
            style="margin-top: 30px; width: 65px"
            v-model="pageData.scheduleTime"
            value-format="HH:mm">
          </el-time-picker>
        </el-form-item>
        <el-form-item :label="''" style="margin-top: -10px; margin-left: -5px;">
          <el-checkbox style="margin-top: 28px;" label="仅查看前道工序已排产的工序" name="type"></el-checkbox>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 5px;">
        <el-form-item :label="'工厂编号:'">
          <el-input v-model="pageData.site" style="width: 85px"></el-input>
        </el-form-item>
        <el-form-item>
          <span slot="label" style="" @click="getBaseList(88)"><a herf="#">机台编号:</a></span>
          <el-input v-model="pageData.resourceId" @blur="getCurrentWorkCenterNoByResourceId" style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'加工中心编码:'">
          <el-input v-model="pageData.workCenterNo" readonly="readonly" style="width: 120px"></el-input>
        </el-form-item>
      </el-form>
      <!--  记录示意图  -->
      <fieldset style="margin-left: 380px; margin-top: -88px; width: 180px;">
        <legend>记录示意图</legend>
        <el-form :inline="true" label-position="top" label-width="100px" class="customer-card">
          <el-form-item :label="'已关闭,已达数量'">
            <el-card class="customer-el-card customer-el-card-pink"></el-card>
          </el-form-item>
          <el-form-item :label="'已关闭,未达数量'">
            <el-card class="customer-el-card customer-el-card-orange"></el-card>
          </el-form-item>
          <el-form-item :label="'未关闭,未达数量'">
            <el-card class="customer-el-card customer-el-card-blue"></el-card>
          </el-form-item>
        </el-form>
      </fieldset>
      <!--  等待订单  -->
      <fieldset style="margin-left: 585px; margin-top: -93px; width: 180px; margin-bottom: 5px;">
        <legend>等待订单</legend>
        <el-form :inline="true" label-position="left" label-width="100px" class="customer-border">
          <el-form-item :label="'等待时间(分钟):'" >
            <el-input type="number" v-model="pageData.waitTimes"
                      style="margin-top: 3px; width: 48px;">
            </el-input>
          </el-form-item>
          <el-form-item :label="''" style="text-align: center; margin-top: 15px; margin-bottom: 9px;">
            <el-button type="primary" @click="addWaitScheduleBun" style="margin-left: 30px; margin-top: 10px; margin-bottom: 15px;">插入等待订单</el-button>
          </el-form-item>
        </el-form>
      </fieldset>

    </fieldset >
    <!--  机台班次信息  -->
    <el-main style="margin-left: 770px; margin-top: -215px; width: 452px;">
      <el-table
        height="192"
        :data="resourceShiftList"
        border
        v-loading="dataListLoading"
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in columnTimeArray" :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>

    <!--  工单主表信息  -->
    <el-main style="margin-left: -20px; margin-top: -35px; width: 104%;">
      <el-form :inline="true"  label-position="top" label-width="100px">
        <el-form-item :label="'主记录'">
        </el-form-item>
        <el-dropdown trigger="click" class="customer-dropdown" size="small" @command="orderHandleCommand">
          <el-button type="primary" @click="controlPrimaryMenuBun">
            主菜单<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item class="customer-li" command="生产工单"
                              :disabled="primaryMenuButton.shopOrderFlag">生产订单</el-dropdown-item>
            <el-dropdown-item class="customer-li" command="工作日历"
                              :disabled="primaryMenuButton.workCalendarOutFlag">工作日历</el-dropdown-item>
            <hr width="95%" />
            <el-dropdown-item class="customer-li" command="批量维护工作日历"
                              :disabled="primaryMenuButton.batchWorkCalendarFlag">批量维护工作日历</el-dropdown-item>
            <hr width="95%" />
            <el-dropdown-item class="customer-li" command="分批排产"
                              :disabled="primaryMenuButton.splitScheduleFlag">分批排产</el-dropdown-item>
            <hr width="95%" />
            <el-dropdown-item class="customer-li"  command="重新排产"
                              :disabled="primaryMenuButton.reScheduleOrderFlag">重新排产</el-dropdown-item>
            <hr width="95%"/>
            <el-dropdown-item class="customer-li"  command="更改工艺路线"
                              :disabled="primaryMenuButton.updateProductRouting">更改工艺路线</el-dropdown-item>
            <el-dropdown-item class="customer-li"  command="更改工艺路线版本"
                              :disabled="primaryMenuButton.updateProductRouting">更改工艺路线版本</el-dropdown-item>
            <hr width="95%" />
            <el-dropdown-item class="customer-li"  command="查看物料库存"
                              :disabled="primaryMenuButton.partStockFlag">查看物料库存</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
        <el-button @click="userSetting('5303Order')" type="primary">{{ buttons.settingTable }}</el-button>
        <el-button v-if="showDefault" @click="saveColumnList('5303Order')" type="primary">{{ buttons.defaultTable }}</el-button>
      </el-form>
      <el-table
        :height="height - 50"
        :data="shopOrderList"
        border
        ref="routingTable"
        highlight-current-row
        @row-click="setCurrentRoutingRow"
        :row-class-name="routingRowClassName"
        @row-dblclick="startScheduleOperation"
        v-loading="dataListLoading"
        style="margin-top: -20px; width: 100%;">
        <el-table-column
          v-for="(item,index) in columnOrderArray" :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>
    <!--  工单明细表信息  -->
    <el-main style="margin-top: -15px; width: 104%; padding: 0px;">
      <el-form :inline="true"  label-position="top" label-width="100px">
        <el-form-item :label="'明细记录'">
        </el-form-item>
        <el-dropdown trigger="click" class="customer-dropdown" size="mini" @command="scheduleHandleCommand">
          <el-button type="primary" @click="controlDetailMenuBun">
            明细菜单<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item class="customer-li" command="生产工单"
                              :disabled="detailMenuButton.shopOrderFlag">生产订单</el-dropdown-item>
            <el-dropdown-item class="customer-li" command="工作日历"
                              :disabled="detailMenuButton.workCalendarOutFlag">工作日历</el-dropdown-item>
            <hr width="95%"/>
            <el-dropdown-item class="customer-li" command="更改等待时间"
                              :disabled="detailMenuButton.changeWaitTimeFlag">更改等待时间</el-dropdown-item>
            <el-dropdown-item class="customer-li" command="根据工艺路线调整"
                              :disabled="detailMenuButton.changeScheduleByRoutingFlag">根据工艺路线调整</el-dropdown-item>
            <hr width="95%"/>
            <el-dropdown-item class="customer-li"  command="根据工作日历调整"
                              :disabled="detailMenuButton.changeScheduleByRoutingFlag">根据工作日历调整</el-dropdown-item>
            <hr width="95%"/>
            <el-dropdown-item class="customer-li"  command="查看物料库存"
                              :disabled="detailMenuButton.partStockFlag">查看物料库存</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
        <el-button @click="userSetting('5303Schedule')" type="primary">{{ buttons.settingTable }}</el-button>
        <el-button v-if="showDefault" @click="saveColumnList('5303Schedule')" type="primary">{{ buttons.defaultTable }}</el-button>
      </el-form>
      <el-table class="schedule-table"
        :height="height + 50"
        :data="orderScheduleList"
        border
        highlight-current-row
        ref="scheduleTable"
        :row-class-name="scheduleRowClassName"
        :row-style="controlRowStyle"
        @row-click="setCurrentSchedulingRow"
        @current-change="currentSchedulingRow"
        @row-dblclick="warnCancelScheduleConfirm"
        v-loading="dataListLoading"
        style="margin-top: -20px; width: 96%;">
        <el-table-column
          v-for="(item,index) in columnOrderScheduleArray" :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>

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

    <!-- 分批排产的组件 -->
    <comSplitSchedule ref="comSplitSchedule" :close-on-click-modal="false"
                      :visible.sync="showSplitScheduleFlag"
                      @initAddSplitSchedule="initAddSplitSchedule">

    </comSplitSchedule>

    <!-- 工作日历外的组件 -->
    <comWorkCalendarOut ref="comWorkCalendarOut" :close-on-click-modal="false"
                      :visible.sync="showWorkCalendarOut">

    </comWorkCalendarOut>

    <!-- 批量工作日历的组件 -->
    <comBatchWorkCalendar ref="comBatchWorkCalendar" :close-on-click-modal="false"
                    :visible.sync="showBatchWorkCalendar">
    </comBatchWorkCalendar>

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

    <!-- 更改等待时间 -->
    <comChangeWaitTime ref="comChangeWaitTime" :close-on-click-modal="false"
                  :visible.sync="showChangeWaitTime"
                       @changeScheduleWaitTimes="changeScheduleWaitTimes">
    </comChangeWaitTime>

    <updateProductRouting ref="updateProductRouting" :close-on-click-modal="false"
                          :visible.sync="updateProductRouting"
                         >
      </updateProductRouting>

    <updateRoutingRev ref="updateRoutingRev" :close-on-click-modal="false"
                          :visible.sync="updateRoutingRev"
                      @updateRoutingRevClosed="updateRoutingRevClosed"
    >
    </updateRoutingRev>

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

<script>
  import updateProductRouting from "../common/updateProductRouting";
  import Chooselist from '@/views/modules/common/Chooselist';/*列表组件*/
  import comSplitSchedule from '@/views/modules/schedule/com_split_schedule';/*分批排产的modal*/
  import comWorkCalendarOut from "../common/com_work_calendar_out";/*工作日历外组件*/
  import comBatchWorkCalendar from "../common/com_batch_work_calendar";/*批量维护工作日历外组件*/
  import comPartStock from "../common/com_part_stock";/*展示物料库存的组件*/
  import comChangeWaitTime from "./com_change_wait_time";/*修改等待派工单的等待时间*/
  import column from '@/views/modules/common/column';/*动态表头*/

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

  import updateRoutingRev from "../common/updateRoutingRev";
import {
  getResourceRestList,
  getShopOrderList,
  getOrderScheduleList,
  getCurrentWorkCenterNoByResourceId,
  scheduleWorkOrder,
  cancelSoSchedule,
  addWaitSchedule,
  reScheduleWorkOrders,
  moveUpSchedule,
  moveDownSchedule,
  updateScheduleWaitTimes,
  refreshScheduleByRouting,
  refreshScheduleByCalendar,
} from '@/api/schedule/order_schedule.js'

export default {
  data() {
    return {
      height: 200,
      tagNo: '',
      showDefault: false,
      visible: false,
      updateProductRouting:false,
      showWorkCalendarOut: false,
      showBatchWorkCalendar: false,
      showSplitScheduleFlag: false,
      updateRoutingRev:false,
      showPartStockFlag: false,
      showChangeWaitTime: false,
      scheduleIndex: -1,
      modelFlag: false,
      modelInputFlag: true,
      currentRoutingRow: {},
      currentSchedlingRow: {},
      selectList: [],
      pageData: {
        site: this.$store.state.user.site,
        username: this.$store.state.user.name,
        orderNo: '',
        itemNo: '',
        seqNo: 0,
        resourceId: '',
        workCenterNo: '',
        enterTime1: '',
        enterTime2: '',
        needTime1: '',
        needTime2: '',
        scheduleDate: this.dayjs(new Date()).format('YYYY-MM-DD'),
        scheduleTime: '08:30',
        specifiedTime: 'N',
        scheduledQty: 0,
        waitTimes: 0,
        scheduleSeqNo: 0,
        planStartTime: '',
        calendarId: '',
        calendarDesc: '',
        status: 1,
        sortField: 'needDate',
      },
      resourceShiftList: [],
      shopOrderList: [],
      orderScheduleList: [],
      dataListLoading: false,
      columnTimeArray: [
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5301ShiftShiftDate',
          tableId: "5301Shift",
          tableName: "工作日历",
          columnProp: "shiftDate",
          headerAlign: "center",
          align: "center",
          columnLabel: "日期",
          columnWidth: 90,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5301ShiftShiftInfo',
          tableId: "5301Shift",
          tableName: "工作日历",
          columnProp: "shiftInfo",
          headerAlign: "center",
          align: "center",
          columnLabel: "休息时间览表",
          columnWidth: 320,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        }
      ],
      columnOrderArray: [
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderOrderNo',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "orderNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "订单号",
          columnWidth: 90,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderItemNo',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "itemNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "工序号",
          columnWidth: 90,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderItemDesc',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "itemDesc",
          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: 5303,
          serialNumber: '5303OrderNeedDate',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "needDate",
          headerAlign: "center",
          align: "center",
          columnLabel: "要求完工日期",
          columnWidth: 120,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderPartNo',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "partNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "产品编码",
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderCustomerName',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "customerName",
          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: 5303,
          serialNumber: '5303OrderCustPartNo',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "custPartNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "客户产品料号",
          columnWidth: 120,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderPartDesc',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "partDesc",
          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: 5303,
          serialNumber: '5303OrderLotSize',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "lotSize",
          headerAlign: "center",
          align: "center",
          columnLabel: "订单量",
          columnWidth: 90,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderQtyToSchedule',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "qtyToSchedule",
          headerAlign: "center",
          align: "center",
          columnLabel: "待排产数量",
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderQtyScheduled',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "qtyScheduled",
          headerAlign: "center",
          align: "center",
          columnLabel: "已排产数量",
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderQtyReported',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "qtyReported",
          headerAlign: "center",
          align: "center",
          columnLabel: "已报工数量",
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderSpec',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "spec",
          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: 5303,
          serialNumber: '5303OrderSite',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "site",
          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: 5303,
          serialNumber: '5303OrderWorkCenterNo',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "workCenterNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "加工中心",
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderNextItemNo',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "nextItemNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "下道工序",
          columnWidth: 100,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderNextItemDesc',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "nextItemDesc",
          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: 5303,
          serialNumber: '5303OrderNextScheduledFlag',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "nextScheduledFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "下道工序已排产",
          columnWidth: 120,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderPreItemNo',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "preItemNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "上道工序",
          columnWidth: 90,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderPreItemDesc',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "preItemDesc",
          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: 5303,
          serialNumber: '5303OrderPreScheduledFlag',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "preScheduledFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "上道工序已排产",
          columnWidth: 120,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderScheduledFlag',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "scheduledFlag",
          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: 5303,
          serialNumber: '5303OrderAvailResource',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "availResource",
          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: 5303,
          serialNumber: '5303OrderEnterDate',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "enterDate",
          headerAlign: "center",
          align: "center",
          columnLabel: "录入日期",
          columnWidth: 125,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderScheduleToPlanTime',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "scheduleToPlanTime",
          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: 5303,
          serialNumber: '5303OrderMachRunFactor',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "machRunFactor",
          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: 5303,
          serialNumber: '5303OrderMachSetupTime',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "machSetupTime",
          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: 5303,
          serialNumber: '5303OrderFactorUnit',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "factorUnit",
          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: 5303,
          serialNumber: '5303OrderQtyScheduledPreOps',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "qtyScheduledPreOps",
          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: 5303,
          serialNumber: '5303OrderQtyApprovedPreOps',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "qtyApprovedPreOps",
          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: 5303,
          serialNumber: '5303OrderOriSOOrderNo',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "oriSOOrderNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "SAP参考号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303OrderEficiency',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "efficiency",
          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: 5303,
          serialNumber: '5303OrderCostRollUpFlag',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "costRollUpFlag",
          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: 5303,
          serialNumber: '5303OrderManualFlag',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "manualFlag",
          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: 5303,
          serialNumber: '5303OrderRepairSOFlag',
          tableId: "5303Order",
          tableName: "工单表",
          columnProp: "repairSOFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "印版已发",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
      ],
      columnOrderScheduleArray: [
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303ScheduleScheduledSeqNo',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "scheduledSeqNo",
          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: 5303,
          serialNumber: '5303SchedulePlanStartTime',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "planStartTime",
          headerAlign: "center",
          align: "center",
          columnLabel: "计划开工时间",
          columnWidth: 125,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303SchedulePlanFinishTime',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "planFinishTime",
          headerAlign: "center",
          align: "center",
          columnLabel: "计划完工时间",
          columnWidth: 125,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303ScheduleTimeRequired',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "timeRequired",
          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: 5303,
          serialNumber: '5303ScheduleOrderNo',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "orderNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "订单号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303ScheduleNeedDate',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "needDate",
          headerAlign: "center",
          align: "center",
          columnLabel: "需求日期",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303ScheduleItemNo',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "itemNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "工序号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303ScheduleItemDesc',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "itemDesc",
          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: 5303,
          serialNumber: '5303SchedulePartNo',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "partNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "产品编码",
          columnWidth: 120,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303SchedulePartDesc',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "partDesc",
          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: 5303,
          serialNumber: '5303OrderSpec',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "spec",
          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: 5303,
          serialNumber: '5303ScheduleQtyRequired',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "qtyRequired",
          headerAlign: "center",
          align: "center",
          columnLabel: "待生产数量",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303ScheduleQtyRequired',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "qtyRequired",
          headerAlign: "center",
          align: "center",
          columnLabel: "派工单需求数量",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303ScheduleQtyReported',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "qtyReported",
          headerAlign: "center",
          align: "center",
          columnLabel: "已报告数量",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303SchedulePreItemNo',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "preItemNo",
          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: 5303,
          serialNumber: '5303SchedulePreItemDesc',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "preItemDesc",
          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: 5303,
          serialNumber: '5303SchedulePreScheduledFlag',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "preScheduledFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "前道工序是否排产",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303ScheduleNextItemNo',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "nextItemNo",
          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: 5303,
          serialNumber: '5303ScheduleNextItemDesc',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "nextItemDesc",
          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: 5303,
          serialNumber: '5303ScheduleNextScheduledFlag',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "nextScheduledFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "后道工序是否排产",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303ScheduleResourceId',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "resourceId",
          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: 5303,
          serialNumber: '5303ScheduleCustomerName',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "customerName",
          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: 5303,
          serialNumber: '5303ScheduleEnterDate',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "enterDate",
          headerAlign: "center",
          align: "center",
          columnLabel: "录入日期",
          columnWidth: 125,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303ScheduleAvailResource',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "availResource",
          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: 5303,
          serialNumber: '5303ScheduleWorkCenterNo',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "workCenterNo",
          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: 5303,
          serialNumber: '5303ScheduleMachRunFactor',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "machRunFactor",
          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: 5303,
          serialNumber: '5303ScheduleMachSetupTime',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "machSetupTime",
          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: 5303,
          serialNumber: '5303ScheduleFactorUnit',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "factorUnit",
          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: 5303,
          serialNumber: '5303ScheduleSite',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "site",
          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: 5303,
          serialNumber: '5303ScheduleQtyScheduledPreOps',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "qtyScheduledPreOps",
          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: 5303,
          serialNumber: '5303ScheduleDelayFlag',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "laterShipFlag",
          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: 5303,
          serialNumber: '5303ScheduleClosedFlag',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "closedFlag",
          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: 5303,
          serialNumber: '5303ScheduleParkFlag',
          tableId: "5303Schedule",
          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: 5303,
          serialNumber: '5303ScheduleTimeRequired',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "timeRequired",
          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: 5303,
          serialNumber: '5303SchedulePreOpsPlanFinishTime',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "earlierItemFlag",
          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: 5303,
          serialNumber: '5303ScheduleRemark',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "remark",
          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: 5303,
          serialNumber: '5303ScheduleOriSOOrderNo',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "oriSOOrderNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "SAP参考号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5303,
          serialNumber: '5303ScheduleCustPartNo',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "custPartNo",
          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: 5303,
          serialNumber: '5303ScheduleEficiency',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "eficiency",
          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: 5303,
          serialNumber: '5303ScheduleDelayHours',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "delayHours",
          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: 5303,
          serialNumber: '5303ScheduleCostRollUpFlag',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "costRollUpFlag",
          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: 5303,
          serialNumber: '5303Schedule',
          tableId: "5303Schedule",
          tableName: "排产明细表",
          columnProp: "finishPreItemFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "排产完成时间早于上工序",
          columnWidth: 120,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: ''
        }
      ],
      calendarOutList: [],
      primaryMenuButton: {
        updateProductRouting:true,
        shopOrderFlag: true,
        workCalendarOutFlag: true,
        batchWorkCalendarFlag: true,
        splitScheduleFlag: true,
        reScheduleOrderFlag: true,
        partStockFlag: true,
      },
      detailMenuButton: {
        shopOrderFlag: true,
        workCalendarOutFlag: true,
        changeWaitTimeFlag: true,
        changeScheduleByRoutingFlag: true,
        changeScheduleByCalendarFlag: true,
        partStockFlag: true,
      },
      buttons: {
        settingLanguageList: '按语言设置',
        edit: '编辑',
        delete: '删除',
        deleteList: '批量删除',
        cz: '操作',
        search: '查询',
        download: '导出',
        settingTable: '设置列表',
        defaultTable: '设置默认配置',
        list: "列表",
        addList: '批量添加',
        settingLanguage: "按控件设置"
      },
      queryTable:{
        userId: this.$store.state.user.name,
        functionId: this.$route.meta.menuId,
        tableId: "5303Order",
        languageCode: this.$i18n.locale
      },
      // 用户table 查询参数
      queryTableUser: {
        userId: this.$store.state.user.name,
        functionId: this.$route.meta.menuId,
        tableId: "5303Order",
        status: true,
        languageCode: this.$i18n.locale
      },
      // 用户table 配置集合
      userColumnList: [],
    }
  },

  /*组件*/
  components: {
    updateRoutingRev,
    Chooselist,/*列表的组件*/
    comSplitSchedule,/* 分批排产的组件 */
    comWorkCalendarOut,/*工作日历外组件*/
    comBatchWorkCalendar,/*批量维护工作日历外组件*/
    comPartStock,/*展示物料库存的组件*/
    comChangeWaitTime,/*修改等待派工单的等待时间*/
    updateProductRouting,/*修改工艺路线*/
    column,/*动态列*/
  },

  mounted() {
    this.$nextTick(() => {
      this.height = (window.innerHeight - 340) / 2;
    })
  },
  methods: {
    /*获取机台班次信息的方法*/
    getResourceShiftData() {
      let queryData = {
        site: this.$store.state.user.site,
        workCenterNo: this.pageData.workCenterNo,
        resourceId: this.pageData.resourceId,
        scheduleDate: this.pageData.scheduleDate
      }
      getResourceRestList(queryData).then(({data}) => {
        this.resourceShiftList = data.rows
        this.pageData.calendarId = data.calendarRow.calendarId;
        this.pageData.calendarDesc = data.calendarRow.calendarDesc;
      })
    },

    /*获取工单信息*/
    getShopOrderList() {
      getShopOrderList(this.pageData).then(({data}) => {
        this.shopOrderList = data.rows;
        //清空已经选好的行数据
        this.currentRoutingRow = null;
      })
    },

    /*获取派工单的信息*/
    getOrderScheduleList() {
      getOrderScheduleList(this.pageData).then(({data}) => {
        this.orderScheduleList = data.rows;
        //清空已经选好的行数据
        this.currentSchedlingRow = null;
        //判断是否需要选中当前行
        if(this.scheduleIndex >= 0){
          //选中当前是的行
          setTimeout(() =>{
            this.$refs.scheduleTable.setCurrentRow(this.orderScheduleList[this.scheduleIndex]);
          },300);
        }
      })
    },

    /*刷新页面table*/
    refreshPageTables(){
      this.getResourceShiftData();
      this.getShopOrderList();
      this.getOrderScheduleList();
    },

     /*列表方法的回调*/
    getBaseData(val){
      if (this.tagNo === 88){
        this.pageData.resourceId = val.ResourceID;
        //调用方法获取加工中心
        this.getCurrentWorkCenterNoByResourceId();
      }else if(this.tagNo == 24){
        this.pageData.workCenterNo = val.WorkCenterNo;
      }
    },

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

    /*区分不同的菜单  调用不同的方法  调用不同的方法*/
    orderHandleCommand(menuName){
      //区分是哪一个方法调用
      if('生产工单' === menuName){
        //判断是否选择好了工单
        if(this.currentRoutingRow == null || this.currentRoutingRow == {}){
          //重置按钮
          this.primaryMenuButton.shopOrderFlag = true;
          //返回错误
          this.$message.error('请选择工单!');
          return false;
        }
        this.$router.push({
          path: '/shopOrder-shopOrder/shopOrder',
          query: {
            site: this.$store.state.user.site,
            order: this.currentRoutingRow.orderNo,
            user: this.$store.state.user.name
          }
        })
      }else if('工作日历' === menuName){
        //判断是否选择好了工单
        if(this.currentRoutingRow == null || this.currentRoutingRow == {}){
          //重置按钮
          this.primaryMenuButton.workCalendarOutFlag = true;
          //返回错误
          //this.$message.error('请选择工单!');
          //return false;
        }
        let tempData = {'site': this.pageData.site, 'calendarId': this.pageData.calendarId,
          'calendarDesc': this.pageData.calendarDesc, 'scheduledDate': this.pageData.scheduleDate};
        //打开组件  需要的数据 展示需要的数据
        this.$nextTick(() => {
          this.showWorkCalendarOut = true;
          this.$refs.comWorkCalendarOut.init(tempData);
        })

      }else if('批量维护工作日历' === menuName){
        //判断是否选择好了工单
        if(this.currentRoutingRow == null || this.currentRoutingRow == {}){
          //重置按钮
          this.primaryMenuButton.workCalendarOutFlag = true;
          //返回错误
          //this.$message.error('请选择工单!');
          //return false;
        }
        let tempData = {'site': this.pageData.site, 'calendarId': this.pageData.calendarId,
          'calendarDesc': this.pageData.calendarDesc, 'scheduledDate': this.pageData.scheduleDate};
        //打开组件  需要的数据 展示需要的数据
        this.$nextTick(() => {
          this.showBatchWorkCalendar = true;
          this.$refs.comBatchWorkCalendar.init(tempData);
        })
      }else if('分批排产' === menuName){
        //判断是否选择好了工单
        if(this.currentRoutingRow == null || this.currentRoutingRow == {}){
          //重置按钮
          this.primaryMenuButton.workCalendarOutFlag = true;
          //返回错误
          this.$message.error('请选择工单!');
          return false;
        }
        this.openSplitScheduleModal();
      }else if('重新排产' === menuName){
        //判断是否选择好了工单
        if(this.currentRoutingRow == null || this.currentRoutingRow == {}){
          //重置按钮
          this.primaryMenuButton.workCalendarOutFlag = true;
          //返回错误
          //this.$message.error('请选择工单!');
          //return false;
        }
        //调用提示的方法
       this.warnReScheduleConfirm();
      }else if('查看物料库存' === menuName){
        //判断是否选择好了工单
        if(this.currentRoutingRow == null || this.currentRoutingRow == {}){
          //重置按钮
          this.primaryMenuButton.partStockFlag = true;
          //返回错误
          this.$message.error('请选择工单!');
          return false;
        }
        let tempData = {'site': this.pageData.site, 'orderNo': this.currentRoutingRow.orderNo};
        //打开组件  需要的数据 展示需要的数据
        this.$nextTick(() => {
          this.showPartStockFlag = true;
          this.$refs.comPartStock.init(tempData);
        })
      }else if('更改工艺路线' === menuName) {
        //判断是否选择好了工单
        if (this.currentRoutingRow == null || this.currentRoutingRow == {}) {
          //重置按钮
          this.detailMenuButton.updateProductRouting = true;
          //返回错误
          this.$message.error('请选择工单!');
          return false;
        }
        let tempData = {'site': this.pageData.site, 'orderNo': this.currentRoutingRow.orderNo,'partNo': this.currentRoutingRow.partNo,'partDesc': this.currentRoutingRow.partDesc};
        //打开组件  需要的数据 展示需要的数据
        this.$nextTick(() => {
          this.updateProductRouting = true;
          this.$refs.updateProductRouting.init(tempData);
        })
      }else if('更改工艺路线版本' === menuName) {
        //判断是否选择好了工单
        if (this.currentRoutingRow == null || this.currentRoutingRow == {}) {
          //重置按钮
          this.detailMenuButton.updateProductRouting = true;
          //返回错误
          this.$message.error('请选择工单!');
          return false;
        }
        let tempData = {'site': this.pageData.site, 'orderNo': this.currentRoutingRow.orderNo,'partNo': this.currentRoutingRow.partNo};
        //打开组件  需要的数据 展示需要的数据
        this.$nextTick(() => {
          this.updateRoutingRev = true;
          this.$refs.updateRoutingRev.init(tempData);
        })
      }
    },

    /*区分不同的菜单  调用不同的方法  调用不同的方法*/
    scheduleHandleCommand(menuName){
      //区分是哪一个方法调用
      if('生产工单' === menuName){
        //判断是否选择好了工单
        if(this.currentSchedlingRow == null || this.currentSchedlingRow == {}){
          //重置按钮
          this.detailMenuButton.shopOrderFlag = true;
          //返回错误
          this.$message.error('请选择派工单!');
          return false;
        }
        this.$router.push({
          path: '/shopOrder-shopOrder/shopOrder',
          query: {
            site: this.$store.state.user.site,
            user: this.$store.state.user.name,
            order: this.currentSchedlingRow.orderNo,
          }
        })
      }else if('工作日历' === menuName){
        //判断是否选择好了工单
        if(this.currentSchedlingRow == null || this.currentSchedlingRow == {}){
          //重置按钮
          this.detailMenuButton.workCalendarOutFlag = true;
          //返回错误
          this.$message.error('请选择派工单!');
          return false;
        }
        let tempData = {'site': this.pageData.site, 'calendarId': this.pageData.calendarId,
          'calendarDesc': this.pageData.calendarDesc, 'scheduledDate': this.pageData.scheduleDate};
        //打开组件  需要的数据 展示需要的数据
        this.$nextTick(() => {
          this.showWorkCalendarOut = true;
          this.$refs.comWorkCalendarOut.init(tempData);
        })

      }else if('更改等待时间' === menuName){
        //判断是否选择好了工单
        if(this.currentSchedlingRow == null || this.currentSchedlingRow == {}){
          //重置按钮
          this.detailMenuButton.changeWaitTimeFlag = true;
          //返回错误
          this.$message.error('请选择派工单!');
          return false;
        }
        let waitTimes = parseFloat(this.currentSchedlingRow.timeRequired) * 60;
        //等待时间取整
        waitTimes = parseInt(waitTimes);
        let tempData = {'site': this.pageData.site, 'orderNo': this.currentSchedlingRow.orderNo,
          'itemNo': this.currentSchedlingRow.itemNo, 'seqNo': this.currentSchedlingRow.seqNo,
          'waitTimes': waitTimes};
        //打开组件  需要的数据 展示需要的数据
        this.$nextTick(() => {
          this.showChangeWaitTime = true;
          this.$refs.comChangeWaitTime.init(tempData);
        })
      }else if('根据工艺路线调整' === menuName){
        //判断是否选择好了工单
        if(this.currentSchedlingRow == null || this.currentSchedlingRow == {}){
          //重置按钮
          this.detailMenuButton.changeScheduleByRoutingFlag = true;
          //返回错误
          this.$message.error('请选择派工单!');
          return false;
        }
        this.changeScheduleByRouting(this.currentSchedlingRow);
      }else if('根据工作日历调整' === menuName){
        //判断是否选择好了工单
        if(this.currentSchedlingRow == null || this.currentSchedlingRow == {}){
          //重置按钮
          this.detailMenuButton.changeScheduleByCalendarFlag = true;
          //返回错误
          this.$message.error('请选择派工单!');
          return false;
        }
        //调用提示的方法
        this.warnChangeScheduleByCalendar(this.currentSchedlingRow);
      }else if('查看物料库存' === menuName){
        //判断是否选择好了工单
        if(this.currentSchedlingRow == null || this.currentSchedlingRow == {}){
          //重置按钮
          this.detailMenuButton.partStockFlag = true;
          //返回错误
          this.$message.error('请选择工单!');
          return false;
        }
        let tempData = {'site': this.pageData.site, 'orderNo': this.currentSchedlingRow.orderNo};
        //打开组件  需要的数据 展示需要的数据
        this.$nextTick(() => {
          this.showPartStockFlag = true;
          this.$refs.comPartStock.init(tempData);
        })
      }
    },

    /*打开分批排产*/
    openSplitScheduleModal(){
      let routingRow = this.currentRoutingRow;
      //首先判断是否选好
      if(null == routingRow){
        this.$message.error("请先单击选择行!")
        return false;
      }
      //调用分批排产的方法
      this.showSplitScheduleFlag = true;
      //调用组件
      this.$refs.comSplitSchedule.init(this.currentRoutingRow);
    },

    /*获取当前的机台对应的加工中心*/
    getCurrentWorkCenterNoByResourceId(){
      getCurrentWorkCenterNoByResourceId(this.pageData).then(({data}) => {
        //区分是否成功
        if (data.code == 500) {
          //this.$message.error(data.msg);
        } else{
          this.pageData.workCenterNo = data.workCenterNo;
        }
        this.pageData.workCenterNo = data.workCenterNo;
      });
    },

    /*设置当前行的下标*/
    routingRowClassName({row, rowIndex}){
      row.index = rowIndex;
      //判断当前行颜色参数
      if(row.qtyScheduled  > 0){
        return 'customer-row-gray';
      }
    },



    /*设置工艺的行*/
    setCurrentRoutingRow(row, column, event) {
      this.currentRoutingRow = row;
    },

    /*设置当前派工单行的下标*/
    scheduleRowClassName({row, rowIndex}){
      row.index = rowIndex;
    },

    /*设置派工单的行*/
    setCurrentSchedulingRow(row, column, event) {
      this.currentSchedlingRow = JSON.parse(JSON.stringify(row));
      //设置当前的序号
      this.scheduleIndex = row.index;
    },

    /*当前值发生变化的时候修改*/
    currentSchedulingRow(row, oldRow){
      //判断是否是获取焦点的事件
      if(row){
        this.currentSchedlingRow = JSON.parse(JSON.stringify(row));
        //设置当前的序号
        this.scheduleIndex = row.index;
      }
    },

    /*开始排产的操作*/
    startScheduleOperation(row, $event, column){
      //判断排产的加工中心和机台是否为空
      if(this.pageData.workCenterNo == null || '' == this.pageData.workCenterNo){
        this.$message.error('加工中心不能为空!')
        return false;
      }
      if(this.pageData.resourceId == null || '' == this.pageData.resourceId){
        this.$message.error('机台不能为空!')
        return false;
      }
      //赋值排产的数量
      let scheduledQty = row.qtyToSchedule;
      row.qtyScheduled = scheduledQty;
      row.qtyToSchedule = parseFloat(row.qtyToSchedule) -  parseFloat(row.qtyScheduled);
      this.pageData.scheduledQty = scheduledQty;
      //设置工单和工序
      this.pageData.orderNo = row.orderNo;
      this.pageData.itemNo = row.itemNo;
      //执行排产的方法
     this.scheduleWorkOrderOperation(scheduledQty);
    },

    /*分批排产*/
    initAddSplitSchedule(scheduledQty){
      //设置工单和工序
      this.pageData.orderNo = this.currentRoutingRow.orderNo;
      this.pageData.itemNo = this.currentRoutingRow.itemNo;
      //判断排产的加工中心和机台是否为空
      if(this.pageData.workCenterNo == null || '' == this.pageData.workCenterNo){
        this.$message.error('加工中心不能为空!')
        return false;
      }
      if(this.pageData.resourceId == null || '' == this.pageData.resourceId){
        this.$message.error('机台不能为空!')
        return false;
      }
      this.currentRoutingRow.qtyScheduled =  parseFloat(this.currentRoutingRow.qtyScheduled) + parseFloat(scheduledQty);
      this.currentRoutingRow.qtyToSchedule =  parseFloat(this.currentRoutingRow.qtyToSchedule) -  parseFloat(scheduledQty);
      //执行排产的方法
      this.scheduleWorkOrderOperation(scheduledQty);
    },

    /*排产生产工单*/
    scheduleWorkOrderOperation(scheduledQty){
      //重置请求的参数
      this.pageData.scheduledQty = scheduledQty;
      scheduleWorkOrder(this.pageData).then(({data}) => {
        if(data.code == 500){
          this.currentRoutingRow.qtyScheduled =  parseFloat(this.currentRoutingRow.qtyScheduled) - parseFloat(scheduledQty);
          this.currentRoutingRow.qtyToSchedule =  parseFloat(this.currentRoutingRow.qtyToSchedule) +  parseFloat(scheduledQty);
          this.$message.error(data.msg);
          this.pageData.scheduledQty = 0;
        }else{
          this.$message.success(data.msg);
          //刷新明细的报工页面
          this.getOrderScheduleList();
        }
      });
    },

    /*提示取消派工单*/
    warnCancelScheduleConfirm(row, $event, column){
      //提示操作
      this.$confirm('确实要取消该派工单吗?', '提示', {
        confirmButtonText: '确认',
        celButtonText: '取消',
        type: 'warning'
      }).then(() =>{
        //执行创建新卷的操作
        this.cancelScheduleBun(row);
      });
    },

    /*取消派工单的操作*/
    cancelScheduleBun(scheduleRow){
      //设置参数
      this.pageData.orderNo = scheduleRow.orderNo;
      this.pageData.itemNo = scheduleRow.itemNo;
      this.pageData.seqNo = scheduleRow.seqNo;
      this.pageData.scheduledQty = scheduleRow.qtyRequired;
      this.pageData.workCenterNo = scheduleRow.workCenterNo;
      this.pageData.resourceId = scheduleRow.resourceId;
      this.pageData.scheduleSeqNo = scheduleRow.scheduledSeqNo;
      this.pageData.planStartTime = scheduleRow.planStartTime;
      //取消排产
      cancelSoSchedule(this.pageData).then(({data}) => {
        if(data.code == 500){
          this.$message.error(data.msg);
        }else{
          this.$message.success(data.msg);
          //刷新排产的数据
          this.getShopOrderList();
          //刷新明细的数据
          this.getOrderScheduleList();
        }
      });
    },

    /*分批排产*/
    addWaitScheduleBun(){
      //重置请求的参数
     let waitTimes = this.pageData.waitTimes;
     if(waitTimes <= 0){
       this.$message.error('等待时间必须大于零!')
       return false;
     }
      //发送请求
      //判断排产的加工中心和机台是否为空
      if(this.pageData.workCenterNo == null || '' == this.pageData.workCenterNo){
        this.$message.error('加工中心不能为空!')
        return false;
      }
      if(this.pageData.resourceId == null || '' == this.pageData.resourceId){
        this.$message.error('机台不能为空!')
        return false;
      }
      //执行排产的方法
      this.addWaitScheduleOperation();
    },

    /*插入等待的派工单信息*/
    addWaitScheduleOperation(){
      addWaitSchedule(this.pageData).then(({data}) => {
        if(data.code == 500){
          this.$message.error(data.msg);
        }else{
          this.$message.success(data.msg);
          //刷新明细
          this.getOrderScheduleList();
        }
      });
    },

    /*提示取消派工单*/
    warnReScheduleConfirm(){
      //判断加工中心和机台
      //判断排产的加工中心和机台是否为空
      if(this.pageData.workCenterNo == null || '' == this.pageData.workCenterNo){
        this.$message.error('加工中心不能为空!')
        return false;
      }
      if(this.pageData.resourceId == null || '' == this.pageData.resourceId){
        this.$message.error('机台不能为空!')
        return false;
      }
      //提示操作
      this.$confirm('确实要对排产清单中的未完成派工单进行排产吗?', '提示', {
        confirmButtonText: '确认',
        celButtonText: '取消',
        type: 'warning'
      }).then(() =>{
        //执行创建新卷的操作
        this.initReScheduleWorkOrders();
      });
    },

    /*重新排产的方法*/
    initReScheduleWorkOrders(){
      reScheduleWorkOrders(this.pageData).then(({data}) => {
        if(data.code != 200){
          this.$message.error(data.msg);
        }else{
          this.$message.success(data.msg);
          //刷新明细的报工页面
          this.getOrderScheduleList();
        }
      });
    },

    /*上移派工单*/
    moveUpScheduleBun(){
      //判断是否选择好了移动的行
      let scheduleRow = this.currentSchedlingRow;
      if(null == scheduleRow || scheduleRow == ''){
        this.$message.error('请先选择处理的行!');
        return false;
      }
      //判断是否是第一行
      if(scheduleRow.index == 0){
        this.$message.error('已经是首行,无法继续上行!');
        return false;
      }
      //请求的参数
      let requestData = {'site': this.pageData.site,
                         'workCenterNo': this.pageData.workCenterNo,
                         'resourceId': this.pageData.resourceId,
                         'scheduleSeqNo': scheduleRow.scheduledSeqNo};
      //请求处理当前的参数
      moveUpSchedule(requestData).then(({data}) => {
        if(data.code != 200){
          this.$message.error(data.msg);
        }else{
          this.$message.success(data.msg);
          //重置当前行
          this.scheduleIndex = this.scheduleIndex - 1;
          //刷新派工单的数据
          this.getOrderScheduleList();
        }
      });
    },

    /*上移派工单*/
    moveDownScheduleBun(){
      //判断是否选择好了移动的行
      let scheduleRow = this.currentSchedlingRow;
      if(null == scheduleRow || scheduleRow == ''){
        this.$message.error('请先选择处理的行!');
        return false;
      }
      let countNums = this.orderScheduleList.length;
      //判断是否是第一行
      if(scheduleRow.index == countNums - 1){
        this.$message.error('已经是末行,无法继续下行!');
        return false;
      }
      //请求的参数
      let requestData = {'site': this.pageData.site,
        'workCenterNo': this.pageData.workCenterNo,
        'resourceId': this.pageData.resourceId,
        'scheduleSeqNo': scheduleRow.scheduledSeqNo};
      //请求处理当前的参数
      moveDownSchedule(requestData).then(({data}) => {
        if(data.code != 200){
          this.$message.error(data.msg);
        }else{
          this.$message.success(data.msg);
          //重置当前行
          this.scheduleIndex = this.scheduleIndex + 1;
          //刷新派工单的数据
          this.getOrderScheduleList();
        }
      });
    },

    /*判断主菜单的样式*/
    controlPrimaryMenuBun(){
      //没有选择行 所有的按钮都是灰色
      if(this.currentRoutingRow == null || this.currentRoutingRow == {}){
        this.primaryMenuButton.shopOrderFlag = true;
        this.primaryMenuButton.workCalendarOutFlag = false;
        this.primaryMenuButton.batchWorkCalendarFlag = false;
        this.primaryMenuButton.splitScheduleFlag = true;
        this.primaryMenuButton.reScheduleOrderFlag = false;
        this.primaryMenuButton.partStockFlag = true;
        this.primaryMenuButton.updateProductRouting=true;
      }else{
        // 判断是否具有该页面权限
        let menList = JSON.parse(sessionStorage.getItem('dynamicMenuRoutes') || '[]')
          .filter(item => item.path == 'shopOrder-shopOrder/shopOrder')
        if (menList.length>0){
          this.primaryMenuButton.shopOrderFlag = false;
        }
        this.primaryMenuButton.workCalendarOutFlag = false;
        this.primaryMenuButton.batchWorkCalendarFlag = false;
        this.primaryMenuButton.splitScheduleFlag = false;
        this.primaryMenuButton.reScheduleOrderFlag = false;
        this.primaryMenuButton.partStockFlag = false;
        this.primaryMenuButton.updateProductRouting=false;
      }
    },

    /*控制明细菜单是否显示*/
    controlDetailMenuBun(){
      //没有选择行 所有的按钮都是灰色
      if(this.currentSchedlingRow == null || this.currentSchedlingRow == {}){
        this.detailMenuButton.shopOrderFlag = true;
        this.detailMenuButton.workCalendarOutFlag = true;
        this.detailMenuButton.changeWaitTimeFlag = true;
        this.detailMenuButton.changeScheduleByRoutingFlag = true;
        this.detailMenuButton.changeScheduleByCalendarFlag = true;
        this.detailMenuButton.partStockFlag = true;
      }else{
        // 判断是否具有该页面权限
        let menList = JSON.parse(sessionStorage.getItem('dynamicMenuRoutes') || '[]')
          .filter(item => item.path == 'shopOrder-shopOrder/shopOrder')
        //如果存在权限
        if (menList.length > 0){
          this.detailMenuButton.shopOrderFlag = false;
        }
        this.detailMenuButton.workCalendarOutFlag = false;
        //需要判断是否是等待工单(只有等待工单才可以修改时间)
        if(this.currentSchedlingRow.orderNo === '9999'){
          this.detailMenuButton.changeWaitTimeFlag = false;
        }else{
          this.detailMenuButton.changeWaitTimeFlag = true;
        }
        this.detailMenuButton.changeScheduleByRoutingFlag = false;
        this.detailMenuButton.changeScheduleByCalendarFlag = false;
        //等待订单无法查询物料库存
        if(this.currentSchedlingRow.orderNo === '9999'){
          this.detailMenuButton.partStockFlag = true;
        }else{
          this.detailMenuButton.partStockFlag = false;
        }
      }
    },

    /*调整等待派工单的等待时间*/
    changeScheduleWaitTimes(tempData){
      //修改当前等待派工单的等待时间
      let requestData = {'site': tempData.site, 'orderNo': tempData.orderNo, 'itemNo': tempData.itemNo,
      'seqNo': tempData.seqNo, 'waitTimes': tempData.waitTimes, 'workCenterNo': this.pageData.workCenterNo,
      'resourceId': this.pageData.resourceId, 'scheduleSeqNo': this.currentSchedlingRow.scheduledSeqNo};
      updateScheduleWaitTimes(requestData).then(({data}) => {
        if(data.code != 200){
          this.$message.error(data.msg);
        }else{
          this.$message.success(data.msg);
          //刷新派工单的数据
          this.getOrderScheduleList();
        }
      });
    },

    /*根据工艺路线调整派工单*/
    changeScheduleByRouting(tempData){
      //修改当前等待派工单的等待时间
      let requestData = {'site': tempData.site, 'orderNo': tempData.orderNo, 'itemNo': tempData.itemNo,
        'seqNo': tempData.seqNo, 'workCenterNo': this.pageData.workCenterNo,
        'resourceId': this.pageData.resourceId, 'scheduleSeqNo': this.currentSchedlingRow.scheduledSeqNo};
      refreshScheduleByRouting(requestData).then(({data}) => {
        if(data.code != 200){
          this.$message.error(data.msg);
        }else{
          this.$message.success(data.msg);
          //刷新派工单的数据
          this.getOrderScheduleList();
        }
      });
    },

    /*提示是否按照工作日历调整派工单*/
    warnChangeScheduleByCalendar(scheduleRow){
      //提示操作
      this.$confirm('确实要要从该派工单开始,根据工作日历调整排产吗?', '提示', {
        confirmButtonText: '确认',
        celButtonText: '取消',
        type: 'warning'
      }).then(() =>{
        //执行创建新卷的操作
        this.changeScheduleByCalendar(scheduleRow);
      });
    },

    /*根据日历调整派工单*/
    changeScheduleByCalendar(tempData){
      //修改当前等待派工单的等待时间
      let requestData = {'site': tempData.site, 'orderNo': tempData.orderNo, 'itemNo': tempData.itemNo,
        'seqNo': tempData.seqNo, 'workCenterNo': this.pageData.workCenterNo,
        'resourceId': this.pageData.resourceId, 'scheduleSeqNo': this.currentSchedlingRow.scheduledSeqNo};
      refreshScheduleByCalendar(requestData).then(({data}) => {
        if(data.code != 200){
          this.$message.error(data.msg);
        }else{
          this.$message.success(data.msg);
          //刷新派工单的数据
          this.getOrderScheduleList();
        }
      });
    },
    updateRoutingRevClosed(){
      this.getShopOrderList();
    },

    /*控制单行的背景颜色*/
    controlRowStyle({row, rowIndex}){
      let colorStyle = row.colorStyle;
      //区分不同的样式对应不同的颜色
      if(colorStyle == 'firstColor'){
        return "background-color: #FF00FF";
      }else if(colorStyle == 'secondColor'){
        return "background-color: #FFD700";
      }else if(colorStyle == 'thirdColor'){
        return "background-color: #0000CD";
      }
    },

    // 打开页面设置
    userSetting(tableId) {
      this.visible = true;
      let queryTable = {
        userId: this.$store.state.user.name,
        functionId: this.$route.meta.menuId,
        tableId: tableId,
        languageCode: this.$i18n.locale
      }
      this.$nextTick(() => {
        this.$refs.column.init(queryTable);
      });
    },
    // 获取 用户保存的 格式列
    getTableUserColumn(tableId) {
      //判断是否是null
      if(!(null === tableId || "" === tableId)){
        this.queryTableUser.tableId = tableId;
      }
      getTableUserListLanguage(this.queryTableUser).then(({data}) => {
        if (data.rows.length > 0) {
          //this.columnList = []
          //如果是订单表
          if('5303Order' === tableId){
            this.columnOrderArray = data.rows;
          }else if('5303Schedule' === tableId){
            this.columnOrderScheduleArray = data.rows;
          }
        } else {
          this.getColumnList(tableId);
        }

      })
    },
    // 保存 默认配置 列
    async saveColumnList(tableId) {
      //重置tableId
      this.queryTable.tableId = tableId;
      this.queryTableUser.tableId = tableId;
      // 删除所有的该页面下保存的数据
      if (this.userColumnList) {
        //删除 user自定义的数据
        await removerUser(this.queryTable)
      }
      // 删除默认配置
      await removerDefault(this.queryTable)
      // 保存页面 table属性
      let sumColumnList = this.columnOrderArray.concat(this.columnOrderScheduleArray);
      sumColumnList = sumColumnList.map(item => {
        return item = {
          tableId: item.tableId,
          tableName: item.tableName,
          columnProp: item.columnProp,
          columnLabel: item.columnLabel,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          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(tableId) {
      //判断是否是null
      if(!(null === tableId || "" === tableId)){
        this.queryTable.tableId = tableId;
      }
      getTableDefaultListLanguage(this.queryTable).then(({data}) => {
        if (!data.rows.length == 0) {
          // this.showDefault = false
          //如果是订单表
          if('5304Order' === tableId){
            this.columnOrderArray = data.rows;
          }else if('5304Schedule' === tableId){
            this.columnOrderScheduleArray = data.rows;
          }
        } else {
          // this.showDefault = true
        }
      })
    },


  },
  created() {
    //获取动态表头的信息
    this.getTableUserColumn('5303Order');
    //执行查询休息时间数据
    this.getResourceShiftData();
    //查询工单的数据
    this.getShopOrderList();
    //查询派工的数据
    this.getOrderScheduleList();

    //延迟操作
    setTimeout(item =>{
      //分布执行
      this.getTableUserColumn('5303Schedule');
    },3000);
  },

  watch:{
    pageData: {
      deep: true,
      handler: function (newV, oldV) {
        this.pageData.resourceId = this.pageData.resourceId.toUpperCase();
      }
    }
  },
}
</script>

<!--当前页面的标签样式-->
<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: 60px;
  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;
}

/*灰色的表格行背景颜色*/
.customer-css /deep/ tr.customer-row-gray:hover {
  background: #7e819e;
}

/*灰色的表格行背景颜色*/
.customer-css /deep/ tr.customer-row-gray > td{
  background: #7e819e;
}

/*去掉悬浮的样式*/
/*.customer-css /deep/ tr:hover > td{
  background-color: transparent !important;
}

.customer-css /deep/ tr.hover-row.current-row > td{
  background-color: transparent !important;
}

.customer-css /deep/ tr.hover-row > td{
  background-color: transparent !important;
}*/

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

/*设置间距*/
.el-dropdown-menu /deep/ li.customer-li{
  font-size: 12px;
  line-height: 16px;
  padding: 4px 8px;
}

.el-input /deep/ .el-icon-time{
  display: none;
}
/*控制上下间距*/
hr {
  margin-top: 0px;
}


//el-table 取消鼠标悬浮时行高亮效果
/*/deep/ .schedule-table tbody tr:hover >td  {
  background-color: unset !important;
}*/

/deep/ .schedule-table tbody tr:hover:not(.current-row) >td  {
  background-color: unset !important;
}


</style>
