// 生成临时UUID
export function getUUID() {
  var len = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
  var radix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 16;
  var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
  var uuid = [],
    i;
  radix = radix || chars.length;
  if (len) {
    for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
  } else {
    var r;
    uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
    uuid[14] = '4';
    for (i = 0; i < 36; i++) {
      if (!uuid[i]) {
        r = 0 | Math.random() * 16;
        uuid[i] = chars[i == 19 ? r & 0x3 | 0x8 : r];
      }
    }
  }
  return uuid.join('');
}
export function getRichFormData(config) {
  var obj = {},
    node = null,
    specl = {};
  for (var key in config) {
    if (['input', 'date', 'textarea', 'radio', 'checkbox', 'editable-div'].includes(config[key].type)) {
      obj[key] = '';
    }
    if (['input', 'date', 'textarea'].includes(config[key].type)) {
      node = document.getElementById(key);
      if (node) {
        obj[key] = node.value;
        if (config[key].name == 'caseCauseManageName' || config[key].label == '案由') {
          specl['caseCauseManageName'] = node.value;
        }
      }
    } else if (['radio'].includes(config[key].type)) {
      node = document.getElementsByName(config[key].name);
      if (node) for (var i = 0; i < node.length; i++) {
        if (node[i].checked) {
          obj[key] = node[i].value;
        }
      }
    } else if (['checkbox'].includes(config[key].type)) {
      obj[key] = [];
      node = document.getElementsByName(config[key].name);
      if (node) for (var _i = 0; _i < node.length; _i++) {
        if (node[_i].checked) {
          obj[key].push(node[_i].value);
        }
      }
      obj[key] = obj[key].join("；");
    } else if (['editable-div'].includes(config[key].type)) {
      node = document.getElementById(key);
      if (node) {
        obj[key] = node.innerHTML;
      }
    }
  }
  return {
    data: obj,
    specl: specl
  };
}