
/*
* 公用renderer
* */

/*
*  合计
* */
function summaryFormat (v1) {
  var num = v1.value;
  if (isNaN(num)) { num = 0; }
  var n = 2;
  if (num === null || num === 'null' || num === undefined || num === 'undefined') { return ''; }
  if (isNaN(num)) { return num; }
  let data = (num + '').split('.');
  num = data[0];
  if (n) {
    num = Number(num);
    num.toFixed(n);
  }
  num = String(num);
  var re = /(-?\d+)(\d{3})/;
  while (re.test(num)) {
    num = num.replace(re, '$1,$2');
  }
  if (data[1] !== '' && data[1] !== null && data[1] !== undefined) {
    num = num + '.' + Math.floor(Number('0.' + data[1]) * 100);
  }
  return num;
}

/*
*  生产模块renderer
* */
// 订单属性
function filterOrderNature (e) {
  var val = e.value;
  if (val === '需加工') {
    return '<span class="color-success">' + val + '</span>';
  }
  return val;
}
// 特殊要求
function teshuyaoqiuRenderer (e) {
  if (e.row.customer_alpha_no) {
    return '<a class="el-button--text rp-teshuyaoqiu" ' +
      '_rowIndex="' + e.rowIndex + '">' + e.row.customer_alpha_no + '</a>';
  } else {
    return '';
  }
}
var proOrderStatus_rp = {
  '0PAA09': '订单已退销售',
  '0PAA10': '订单已接收',
  '0PAA12': '订单下发',
  '0PAA20': '订单已完成',
  '0PAA97': '充当',
  '0PAA98': '脱单',
  '0PDA10': '分条设计完成',
  '0PLW01': '计划已编制',
  '0PLW02': '计划已下发',
  '0PLW03': '开始分条作业',
  '0PLW09': '剪废',
  '0PLW10': '分条作业完成',
  '0PLWXX': '计划已失效',
  '0PPK01': '计划已编制',
  '0PPK02': '计划已下发',
  '0PPK03': '开始分条作业',
  '0PPK10': '分条作业完成',
  '0PPKXX': '计划已失效',
  '5BLW01': '计划已编制',
  '5BLW02': '计划已下发',
  '5BLW03': '开始分条作业',
  '5BLW09': '分条剪废',
  '5BLW10': '分条作业完成',
  '5BLW33': '等待分条判定',
  '5BLW40': '分条判定完成',
  '5BPK03': '等待包装作业',
  '5BPK05': '正在包装作业',
  '5BPK10': '包装作业完成',
  '5BPK33': '等待包装判定',
  '5BPK40': '包装判定完成',
  '5BYA05': '物料在库',
  '5BYS03': '物料待出库',
  '5BYS10': '物料已出库',
  '5BYZ03': '等待装车',
  '5BYZ10': '已发运',
  '5BZA03': '等待退库'
};
function orderStatusRenderer (e) {
  return proOrderStatus_rp[e.value];
}
/*
 *  物流模块renderer
 * */
// 有效状态
function filterValidFlag (e) {
  if (e.value === '1' || e.value === 1) {
    return '<span class="color-success">有效</span>';
  } else if (e.value === '0' || e.value === 0) {
    return '<span class="color-danger">无效</span>';
  }
}
var logisticsStorageAttr_rp = {
  '500201': '原料库',
  '500202': '在制品库',
  '500203': '成品库',
  '500204': '客户库'
}
// 仓库属性
function filterStorageAttr (e) {
  console.log('e', e);
  return logisticsStorageAttr_rp[e.value]
  // return this.$store.state.logisticsStorageAttr_rp[e.value];
}
// 区域属性
function filterAreaAttr (e) {
  return e.value
  // return this.$store.state.logisticsAreaAttr_rp[e.value];
}
// 规格
function filterSize (e) {
  return toFormatNum(e.record.thick) + '*' + toFormatNum(e.record.width);
}
function filterNum (e) {
  return toFormatNum(e.value);
}
function toFormatNum (num, n) {
  if (num === null || num === 'null' || num === undefined || num === 'undefined') { return ''; }
  if (isNaN(num)) { return num; }
  if (n) {
    num = Number(num);
    num.toFixed(n);
  }
  num = String(num);
  var re = /(-?\d+)(\d{3})/;
  while (re.test(num)) {
    num = num.replace(re, '$1,$2');
  }
  return num;
}
