<template>
  <div class="customer-css" >
    <el-dialog v-drag
               width="975px" class="customer-dialog"
               :title="titleCon" v-bind="$attrs" v-on="$listeners">
      <!--  显示信息  -->
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -5px;" >
        <el-row style="width: 560px;">
          <el-form-item :label="'生产订单号:'">
            <el-input v-model="pageData.orderNo" readonly="readonly" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'要求完工日期:'">
            <el-input v-model="pageData.needDate" readonly="readonly" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'工厂编号:'">
            <el-input v-model="pageData.site" readonly="readonly" 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-row>
        <el-row style="width: 560px;">
          <el-form-item :label="'工序:'">
            <el-input v-model="pageData.itemNo" readonly="readonly" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'工序名称:'">
            <el-input v-model="pageData.itemDesc" readonly="readonly" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'待排产数量:'">
            <el-input v-model="pageData.qtyToSchedule" readonly="readonly" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'可用机台:'">
            <el-select v-model="pageData.resourceId" @change="refreshPageTables" style="width: 120px" placeholder="请选择">
              <el-option
                v-for="(item, index) in resourceList"
                :key="index"
                :label="item.resourceDesc"
                :value="item.resourceId"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-row>
        <el-row style="width: 560px;">
          <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: -5px;">
            <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-left: 0px; margin-top: 20px;">
            <el-checkbox v-model="pageData.closeModal" class="customer-checkbox" true-label="Y" false-label="N" style="margin-top: 5px;"
                         label="排产后关闭对话框"></el-checkbox>
          </el-form-item>
          <el-form-item :label="'本次排产数量:'" style="margin-left: 0px;">
            <el-input v-model="pageData.scheduledQty" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="''" style="margin-top: 20px;">
            <el-button class="customer-bun-min" type="primary" @click="startScheduleOrderBun" style="margin-left: 10px; margin-bottom: 5px;">排产</el-button>
          </el-form-item>
        </el-row>
    </el-form>

      <!--  机台班次信息  -->
      <el-main style="margin-left: 520px; margin-top: -160px; width: 452px;">
        <el-table
        height="145"
        :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"
          :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: 100%; padding: 0px;">
        <el-form :inline="true"  label-position="top" label-width="100px">
          <el-form-item :label="'明细记录'">
          </el-form-item>
        </el-form>
        <el-table
          :height="height"
          :data="orderScheduleList"
          border
          highlight-current-row
          ref="scheduleTable"
          @row-dblclick="warnCancelScheduleConfirm"
          v-loading="dataListLoading"
          style="margin-top: -20px; width: 955px;">
          <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"
            :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-dialog>
  </div>
</template>

<script>
import {
  getShopOrderByCon,
  getOrderAvailableResource,/*获取可用的机台数据*/
  getOrderScheduleList,
  getResourceRestList,/*刷新机台班次的数据*/
  scheduleOrderWithExpand,/*执行特殊的排产操作*/
  cancelSoSchedule,/*取消排产*/
} from '@/api/schedule/com_schedule_order_expand.js'

export default {
  data() {
    return {
      height: 320,
      titleCon: '排产扩展',
      showPartStockFlag: false,
      showChangeWaitTime: false,
      resourceList: [],
      pageData: {
        site: this.$store.state.user.site,
        username: this.$store.state.user.name,
        orderNo: '',
        itemNo: '',
        itemDesc: '',
        resourceId: '',
        workCenterNo: '',
        scheduleDate: this.dayjs(new Date()).format('YYYY-MM-DD'),
        scheduleTime: '08:30',
        specifiedTime: 'N',
        needDate: '',
        qtyToSchedule: 0,
        scheduledQty: 0,
        closeModal: 'Y',
        calendarId: '',
        checkFlag: true
      },
      resourceShiftList: [],
      orderScheduleList: [],
      dataListLoading: false,
      columnTimeArray: [
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          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: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          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: false
        }
      ],
      columnOrderScheduleArray: [
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleScheduledSeqNo',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "scheduledSeqNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "排产序号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301SchedulePlanStartTime',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "planStartTime",
          headerAlign: "center",
          align: "center",
          columnLabel: "计划开工时间",
          columnWidth: 125,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301SchedulePlanFinishTime',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "planFinishTime",
          headerAlign: "center",
          align: "center",
          columnLabel: "计划完工时间",
          columnWidth: 125,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleTimeRequired',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "timeRequired",
          headerAlign: "center",
          align: "center",
          columnLabel: "计划时间",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleOrderNo',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "orderNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "订单号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleNeedDate',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "needDate",
          headerAlign: "center",
          align: "center",
          columnLabel: "需求日期",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleItemNo',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "itemNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "工序号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleItemDesc',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "itemDesc",
          headerAlign: "center",
          align: "center",
          columnLabel: "工序名称",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301SchedulePartNo',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "partNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "产品编码",
          columnWidth: 120,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301SchedulePartDesc',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "partDesc",
          headerAlign: "center",
          align: "center",
          columnLabel: "产品名称",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301OrderSpec',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "spec",
          headerAlign: "center",
          align: "center",
          columnLabel: "规格型号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleQtyRequired',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "qtyRequired",
          headerAlign: "center",
          align: "center",
          columnLabel: "待生产数量",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleQtyRequired',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "qtyRequired",
          headerAlign: "center",
          align: "center",
          columnLabel: "派工单需求数量",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleQtyReported',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "qtyReported",
          headerAlign: "center",
          align: "center",
          columnLabel: "已报告数量",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301SchedulePreItemNo',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "preItemNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "前道工序",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301SchedulePreItemDesc',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "preItemDesc",
          headerAlign: "center",
          align: "center",
          columnLabel: "前道工序名称",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301SchedulePreScheduledFlag',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "preScheduledFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "前道工序是否排产",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleNextItemNo',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "nextItemNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "后道工序",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleNextItemDesc',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "nextItemDesc",
          headerAlign: "center",
          align: "center",
          columnLabel: "后道工序名称",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleNextScheduledFlag',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "nextScheduledFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "后道工序是否排产",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleResourceId',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "resourceId",
          headerAlign: "center",
          align: "center",
          columnLabel: "机台号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleCustomerName',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "customerName",
          headerAlign: "center",
          align: "center",
          columnLabel: "客户名称",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleEnterDate',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "enterDate",
          headerAlign: "center",
          align: "center",
          columnLabel: "录入日期",
          columnWidth: 125,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleAvailResource',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "availResource",
          headerAlign: "center",
          align: "center",
          columnLabel: "可用机台",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleWorkCenterNo',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "workCenterNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "加工中心",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleMachRunFactor',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "machRunFactor",
          headerAlign: "center",
          align: "center",
          columnLabel: "单位产出",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleMachSetupTime',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "machSetupTime",
          headerAlign: "center",
          align: "center",
          columnLabel: "调机时间",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleFactorUnit',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "factorUnit",
          headerAlign: "center",
          align: "center",
          columnLabel: "产出单位",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleSite',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "site",
          headerAlign: "center",
          align: "center",
          columnLabel: "工厂编号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleQtyScheduledPreOps',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "qtyScheduledPreOps",
          headerAlign: "center",
          align: "center",
          columnLabel: "前道工序已排产数量",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleDelayFlag',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "laterShipFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "晚于发货时间",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleClosedFlag',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "closedFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "是否关闭",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleParkFlag',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "parkFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "暂停",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleTimeRequired',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "timeRequired",
          headerAlign: "center",
          align: "center",
          columnLabel: "派工单需求工时",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleEarlierItemFlag',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "earlierItemFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "派工单早于上工序",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleRemark',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "remark",
          headerAlign: "center",
          align: "center",
          columnLabel: "备注",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleOriSOOrderNo',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "oriSOOrderNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "SAP参考号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleCustPartNo',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "custPartNo",
          headerAlign: "center",
          align: "center",
          columnLabel: "客户产品料号",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleEficiency',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "eficiency",
          headerAlign: "center",
          align: "center",
          columnLabel: "效率",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301ScheduleDelayHours',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "delayHours",
          headerAlign: "center",
          align: "center",
          columnLabel: "延误小时数",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301Schedule',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "costRollUpFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "已排料",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5301,
          serialNumber: '5301Schedule',
          tableId: "5301Schedule",
          tableName: "排产明细表",
          columnProp: "finishPreItemFlag",
          headerAlign: "center",
          align: "center",
          columnLabel: "排产完成时间早于上工序",
          columnWidth: 80,
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: false
        }
      ],
    }
  },

  mounted() {

  },
  methods: {

    /*刷新当前页面的数据*/
    init(orderRow){
      //设置参数
      this.pageData.orderNo = orderRow.orderNo;
      this.pageData.itemNo = orderRow.itemNo;
      this.pageData.scheduledQty = 0;
      this.pageData.closeModal = 'Y';
      //清空参数
      this.resourceList = [];
      this.resourceShiftList = [];
      this.pageData.resourceId = '';
      this.pageData.workCenterNo = '';
      this.orderScheduleList = [];
      //页面的参数
      this.refreshShopOrderData(orderRow);
    },

    //刷新派工单的数据
    refreshShopOrderData() {
      getShopOrderByCon(this.pageData).then(({data}) => {
        //刷新排产的数量
        this.pageData.qtyToSchedule = data.row.qtyToSchedule;
        this.pageData.needDate = data.row.needDate;
        this.pageData.workCenterNo = data.row.workCenterNo;
        this.pageData.itemDesc = data.row.itemDesc;
        //刷新当前的可用机台
        this.getOrderAvailableResourceData();
      });
    },

    /*获取可用机台的*/
    getOrderAvailableResourceData(){
      getOrderAvailableResource(this.pageData).then(({data}) => {
        this.resourceList = data.rows;
        //判断是否只有一个  默认选中第一个
        if(data.rows.length == 1){
          this.pageData.resourceId = data.rows[0].resourceId;
          //刷新列表数据
          this.getOrderScheduleList();
          //刷新班次的数据
          this.getResourceShiftData();
        }
      });
    },

    /*关闭modal*/
    closeDialog(){
      this.$emit('update:visible', false);
    },

    /*获取派工单的信息*/
    getOrderScheduleList() {
      getOrderScheduleList(this.pageData).then(({data}) => {
        this.orderScheduleList = data.rows;
      })
    },

    /*获取机台班次信息的方法*/
    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;
      })
    },

    /*刷新页面table*/
    refreshPageTables(){
      this.getOrderScheduleList();
      //刷新机台班次的信息
      this.getResourceShiftData();
    },

    /*开始排产*/
    startScheduleOrderBun(){
      let scheduledQty = this.pageData.scheduledQty;
      if(scheduledQty == null || scheduledQty == ''){
        this.$message.error('请输入本次排产数量!')
        return false;
      }
      //判断数量是否超限
      if(this.pageData.scheduledQty <= 0){
        this.$message.error('本次排产数量必须大于零!')
        return false;
      }
      //验证可用机台
      let resourceId = this.pageData.resourceId;
      if(resourceId == null || resourceId == '' || resourceId == '请选择'){
        this.$message.error('请选择可用机台!')
        return false;
      }
      let qtyToSchedule = parseFloat(this.pageData.qtyToSchedule);
      if(qtyToSchedule < scheduledQty){
        this.$message.error('排产数量超过本次待排产数量!')
        return false;
      }
      //执行排产时的操作
      this.scheduleOrderOperation(true);
    },

    /*排产生产工单*/
    scheduleOrderOperation(checkFlag){
      //设置是否校验数量
      this.pageData.checkFlag = checkFlag;
      scheduleOrderWithExpand(this.pageData).then(({data}) => {
        if(data.code == 500){
          this.$message.error(data.msg);
        }else if(data.code == 201){
          this.$confirm(data.msg, '提示', {
            confirmButtonText: '确认',
            celButtonText: '取消',
            type: 'warning'
          }).then(() => {
            //排产不校验
            this.scheduleOrderOperation(false);
          });
        }else{
          //清掉上一次排产数量
          this.pageData.scheduledQty = 0;
          this.$message.success(data.msg);
          //判断是否是分批排产
          if(this.pageData.closeModal == 'N'){
            //刷新明细的报工页面
            this.refreshShopOrderData();
            //刷新列表
            this.getOrderScheduleList();
          }else{
            //关闭当前的页面
            this.closeDialog();
          }
          //后续排产都要校验数量
          this.pageData.checkFlag = true;
        }
      });
    },

    /*提示取消派工单*/
    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.refreshShopOrderData();
          //刷新列表
          this.getOrderScheduleList();
        }
      });
    },

  },
  created() {
    //执行查询休息时间数据
  }
}
</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 .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;
}

/*modal中table的样式*/
.customer-css /deep/ .el-table__header th.is-leaf{
  line-height: 16px;
}

</style>
