<template>
  <div class="orderGroupDetailData">
    <div class="box1">
      <div class="boxTitle">
        <span class="blueTitle"></span>
        <span>集团编码: {{orderGroupMsg.code}}</span>
      </div>
      <el-button type="primary" plain size="small" style="float: right;" @click="returnOrderManage"><svg-icon icon-class="return"/> 返回</el-button>
      <div style="padding-left: 14px;">
        <el-row>
          <el-col :span='4'>
            <div class="blodTip">订单名称</div>
            <div class="lightTip" :title='orderGroupMsg.name'>{{orderGroupMsg.name}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">产品名称</div>
            <div class="lightTip" :title="orderGroupMsg.productName">{{orderGroupMsg.productName}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">产品规格</div>
            <div class="lightTip">{{orderGroupMsg.specifications}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">客户</div>
            <div class="lightTip">{{orderGroupMsg.customerName}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">包装要求</div>
            <div class="lightTip">{{getDictDataLabel(DICT_TYPE.PACK_SPEC, orderGroupMsg.packReq)}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">交货时间</div>
            <div class="lightTip">{{ parseTime(orderGroupMsg.deliveTime)}}</div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span='4'>
            <div class="blodTip">创建时间</div>
            <div class="lightTip">{{ parseTime(orderGroupMsg.createTime) }}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">计划加工数量</div>
            <div class="lightTip">{{orderGroupMsg.planQuantity}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">加工平方数(平方米)</div>
            <div class="lightTip">{{orderGroupMsg.planArea}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">状态</div>
            <div class="lightTip">{{getDictDataLabel(DICT_TYPE.ORDER_STATUS, orderGroupMsg.status)}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">实际开始时间</div>
            <div class="lightTip">{{ parseTime(orderGroupMsg.startProduceTime) }}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">实际完成时间</div>
            <div class="lightTip">{{ parseTime(orderGroupMsg.finishProduceTime) }}</div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span='4'>
            <div class="blodTip">实际生产数量</div>
            <div class="lightTip">{{orderGroupMsg.actualquantity }}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">完成比%</div>
            <div class="lightTip">{{orderGroupMsg.completeRate}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">废片数量</div>
            <div class="lightTip">{{orderGroupMsg.nokQuantity}}</div>
          </el-col>
        </el-row>
      </div>
    </div>
    <div class="box2" v-for="(item, index) in orderMsg" :key='index'>
      <div class="boxTitle">
        <span class="blueTitle"></span>
        <span>厂务订单编码: {{item.code}}</span>
      </div>
      <div style="padding-left: 14px;">
        <el-row>
          <el-col :span='4'>
            <div class="blodTip">订单名称</div>
            <div class="lightTip" :title="item.name">{{item.name}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">产品名称</div>
            <div class="lightTip" :title="item.productName">{{item.productName}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">产品规格</div>
            <div class="lightTip">{{item.specifications}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">创建时间</div>
            <div class="lightTip">{{ parseTime(item.createTime) }}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">计划开始时间</div>
            <div class="lightTip">{{ parseTime(item.planStartTime) }}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">计划完成时间</div>
            <div class="lightTip">{{ parseTime(item.planFinishTime) }}</div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span='4'>
            <div class="blodTip">计划加工数量</div>
            <div class="lightTip">{{item.planQuantity}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">加工平方数(平方米)</div>
            <div class="lightTip">{{item.planArea}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">预计用时(时)</div>
            <div class="lightTip">{{item.expectTime}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">状态</div>
            <div class="lightTip">{{getDictDataLabel(DICT_TYPE.ORDER_STATUS, item.status)}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">实际开始时间</div>
            <div class="lightTip">{{ parseTime(item.startProduceTime) }}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">实际完成时间</div>
            <div class="lightTip">{{ parseTime(item.finishProduceTime) }}</div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span='4'>
            <div class="blodTip">实际生产数量</div>
            <div class="lightTip">{{item.actualQuantity	}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">完成比%</div>
            <div class="lightTip">{{item.completeProp}}</div>
          </el-col>
          <el-col :span='4'>
            <div class="blodTip">废片数量</div>
            <div class="lightTip">{{item.nokQuantity}}</div>
          </el-col>
        </el-row>
      </div>
      <!-- 列表 -->
      <div class="boxTitle">
        <span class="blueTitle"></span>
        <span>工单信息</span>
      </div>
      <base-table
        :page="queryParams.pageNo"
        :limit="queryParams.pageSize"
        :table-props="tableProps"
        :table-data="item.coreWorkOrderRespVOS || []"
        :max-height="tableH"
      />
    </div>
  </div>
</template>
<script>
import { parseTime } from '@/utils/ruoyi'
import { publicFormatter } from '@/utils/dict'
import { orderGroupDetail } from '@/api/base/orderGroup'
const tableProps = [
  {
    prop: 'issueTime',
    label: '下发时间',
    filter: parseTime,
    minWidth: 160
  },
  {
    prop: 'name',
    label: '工单名',
    minWidth: 150,
    showOverflowtooltip: true
  },
  {
    prop: 'code',
    label: '工单编码',
    minWidth: 150
  },
  {
    prop: 'roomNameDict',
    label: '负责车间',
    minWidth: 120,
    filter: publicFormatter('workshop')
  },
  {
    prop: 'planQuantity',
    label: '计划加工量',
    width: 100
  },
  {
    prop: 'actualQuantity',
    label: '实际加工量',
    width: 100
  },
  {
    prop: 'actualArea',
    label: '加工平方数',
    width: 100
  },
  {
    prop: 'status',
    label: '状态',
    filter: publicFormatter('work_order_status')
  },
  {
    prop: 'startProduceTime',
    label: '开始时间',
    filter: parseTime,
    minWidth: 160
  },
  {
    prop: 'finishProduceTime',
    label: '结束时间',
    filter: parseTime,
    minWidth: 160
  },
  {
    prop: 'productLineNames',
    label: '关联产线',
    filter: (val) => val ? val.join(',') : '',
    showOverflowtooltip: true
  },
  {
    prop: 'workers',
    label: '负责人',
    showOverflowtooltip: true
  },
  {
    prop: 'remark',
    label: '备注',
    showOverflowtooltip: true
  }
]
export default {
  name: 'orderGroupDetailData',
  data() {
    return {
      orderGroupId: '',
      tableProps,
      orderMsg: [],
      tableH: 150,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 500
      },
      orderGroupMsg: {}
    }
  },
  mounted() {
    this.orderGroupId = location.href.split('?')[1].split('=')[1]
    this.getMsg()
  },
  methods: {
    getMsg() {
      orderGroupDetail({
        id: this.orderGroupId
      }).then(res => {
        this.orderGroupMsg = res.data
        if ( res.data.orderIdNum && res.data.orderIdNum > 0) {
          this.orderMsg = res.data.orderDetailVOS
        }else{
          this.orderMsg = []
        }
      })
    },
    // 返回
    returnOrderManage() {
      this.$router.push({path: '/order/base/order-group'})
    }
  }
}
</script>
<style lang='scss' scoped>
.orderGroupDetailData {
  height: calc(100vh - 120px - 8px);
  background-color: rgb(242, 244, 249);
  overflow: auto;
  .box1, .box2 {
    background-color: #fff;
    border-radius: 9px;
    .blodTip {
      height: 16px;
      font-size: 14px;
      font-weight: 600;
      color: rgba(0,0,0,0.85);
      margin-bottom: 8px;
    }
    .lightTip {
      height: 16px;
      font-size: 14px;
      font-weight: 400;
      color: rgba(102,102,102,0.75);
      margin-bottom: 12px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
  .box2 {
    height: 415px;
    padding: 12px 16px 0;
    margin: 8px 0;
  }
  .box1 {
    height: 215px;
    padding: 16px 16px 0 16px;
  }
  .boxTitle {
    display: inline-block;
    font-size: 16px;
    font-weight: 400;
    color: #000000;
    margin:0 10px 20px 0;
  }
  .blueTitle {
    content: '';
    display: inline-block;
    width: 4px;
    height: 18px;
    background-color: #0B58FF;
    border-radius: 1px;
    margin-right: 8px;
    vertical-align: bottom;
  }
}
</style>