// 初始化校验
export const initRules = (prop) => {
  const rules = {};
  prop
    .filter((column) => column.required)
    .forEach((column) => {
      const message = `${column.name}不能为空`;
      rules[column.prop] = [
        { required: true, message: message, trigger: "change"},
      ];
    });
  return rules;
};

export const initParams = (prop, key = "key", value = "value") =>
  Object.fromEntries(prop.map((item) => [item[key], item[value]]));

// export const initParams = (prop, key = "key", value = "value") => {
//   // get params
//   const object1 = Object.fromEntries(
//     prop.map(({ item, attr }) => [item[key], attr[value]])
//   );
//   // get mapping params
//   const object2 = {};
//   prop
//     .filter((item) => item.attr.dataMapping)
//     .map(({ attr: { dataMapping } }) => {
//       for (let key in dataMapping) {
//         object2[key] = null;
//       }
//     });
//   return { ...object1, ...object2 };
// };