const planType = [
    { label: '所有计划类型', value: null },
    { label: '内销计划', value: '1' },
    { label: '外销计划', value: '2' },
    { label: '预制计划', value: '3' }
]
const planStatus = [
    { label: '待发布', value: '2' },
    { label: '发布失败', value: '3' },
    { label: '待生产', value: '4' },
    { label: '生产中', value: '5' },
    { label: '已完成', value: '6' },
    { label: '已延期', value: '7' },
    { label: '待下达', value: '8' },
]
export const btnList = [
    {
        name: '退料',
        type: '1',
        bjColor: '#157A2C'
    },
    {
        name: '变更',
        type: '2',
        bjColor: '#3490DE'
    },

    {
        name: '不良品',
        type: '3',
        bjColor: '#39D9AC'
    },
    {
        name: '补料',
        type: '4',
        bjColor: '#6639A6'
    },
    {
        name: '报修',
        type: '5',
        bjColor: '#858585'
    },
    {
        name: '报损',
        type: '6',
        bjColor: '#FF4D4F'
    },


]

export function transitionData(data, type) {
    return {
        code: data.code,//编码
        productionPlanCode: data.productionPlanCode || data.code,//编码
        planTypeName: data.planType && planType.find((i) => i.value == data.planType).label,//计划类型
        planType: data.planType,//计划类型
        model: data.model,//型号
        relationId: data.id,//关联id
        productCode: data.productCode,//产品编码
        productName: data.productName,//产品名称
        specifications: data.specifications,//规格
        requiredFormingNum: type == 1 ? data.salesOrders[0]?.requiredFormingNum : (data.formingNum + ' ' +( data.unit&&data.unit||'')),//要求生产数量
        sumOrderWeight: type == 1 ? (data.sumOrderWeight + data.weightUnit) : (data.formingWeight + ' ' + (data.newWeightUnit || data.weightUnit)),//要求生产重量
        formedNum: data.formedNum && (data.formedNum + ' ' + data.unit),//以生产数量
        formedWeight: data.formedWeight && (data.formedWeight + ' ' + data.weightUnit),//以生产数量
        batchNo: data.batchNo,//批次号
        brandNo: data.brandNo,//牌号
        priority: type == 1 ? data.salesOrders[0]?.priority : data.priority,//优先级
        produceRoutingId: data.produceRoutingId,//工艺id
        produceRoutingName: data.produceRoutingName,//工艺名称
        produceVersionId: data.produceVersionId,//工序id
        produceVersionName: data.produceVersionName,//工序
        status: planStatus.find((i) => i.value == (type == 1 ? data.salesOrders[0]?.status : data.status)).label,//状态
        createTime: data.createTime,//
        createUserName: '',//创建人
        deliveryTime: type == 1 ? data.salesOrders[0]?.deliveryTime : data.planCompleteTime,//计划结束时间
        reqMoldTime: type == 1 ? data.salesOrders[0]?.reqMoldTime : data.planStartTime,//计划开始时间
        teamName: data.teamName,//班组
        teamId: data.teamId//班组
    }
}
export function transitionUnacceptedProduct(data) {
    return {
        poList: [
            {
                productName: data.relationJson.productName,
                productCode: data.relationJson.productCode,
                brandNo: data.relationJson.brandNo,
                unqualifiedQuantity: parseInt(data.relationJson.requiredFormingNum),
                produceRoutingId: data.relationJson.produceRoutingId,
                produceRoutingName: data.relationJson.produceRoutingName,
                produceTaskId: data.relationJson.produceVersionId,
                produceTaskName: data.relationJson.produceVersionName,
                unqualifiedReason: ''
            }
        ],
        code: '',
        unqualifiedQuantity: parseInt(data.relationJson.requiredFormingNum),
        type: '',
        status: null,
        reviewerId: null,
        reviewerName: '',
        createUserName: '',
        unqualifiedSourceCode: data.code,
        unqualifiedSourceId: data.id,
        produceRoutingId: data.relationJson.produceRoutingId,
        produceRoutingName: data.relationJson.produceRoutingName,
        produceTaskId: data.relationJson.produceVersionId,
        produceTaskName: data.relationJson.produceVersionName,
        batchNo: data.relationJson.batchNo
    }
}
