/**
 * @description 将字符串转换为配置名和数量的数组
 * @param arg_status 字符串，格式为"配置名1*数量1+配置名2*数量2+..."
 * @returns {Array} cfgname,qty
 */
export function f_checkpz(arg_status: string) {
  let s_mtrl_config_expr: any = [];
  let s_mtrl_config_union: any = [];

  // 分离利用'+'号分割字符串
  arg_status.split("+").forEach((str, i) => {
    let [cfgname, qty] = str.split("*");
    s_mtrl_config_expr.push({ cfgname: cfgname.trim(), qty: qty ? qty.trim() : "1" });
  });

  // 分离利用'*'号分割出配置名和数量
  s_mtrl_config_expr.forEach((config: any) => {
    let found = s_mtrl_config_union.find((item: any) => item.cfgname === config.cfgname);
    if (found) {
      found.qty = (Number(found.qty) + Number(config.qty)).toString();
    } else {
      s_mtrl_config_union.push({ cfgname: config.cfgname, qty: config.qty });
    }
  });

  return s_mtrl_config_union;
}
