/*
 * @Author: wenjing
 * @Date: 2024-06-27 13:10:11
 * @LastEditTime: 2024-11-14 13:54:11
 */
const imgInfo = require("../assets/common/info-warning.png");
let AupUtil = {
  keyPattern: /^[a-zA-Z0-9\-\(\)\u4e00-\u9fa5]+$/,
  keyErrMsg: '只能输入汉字、字母、数字或-',

  tagNamePattern: /^[a-zA-Z0-9_\u4e00-\u9fa5]+$/,
  tagNameErrMsg: '只能输入汉字、字母、数字、_',

  /**
   * element-ui confirm 二次封装
   * @param {Object} param
   * @returns {Object} Promise 点击了确认resolve()
   */
  confirm(data, vm) {
    const h = vm.$createElement;
    let config = {
      tip: "提示",
      btn: { confirm: "确 定", cancel: "取 消" },
      message: h("div", { style: "text-align:center" }, [
        h("img", { attrs: { src: `${imgInfo}` } }, ""),
        h("div", { style: "margin-top: 10px" }, ""), 
        h("span", { style: "font-size: 14px" }, data)
      ]),
      center: true
    };
    return new Promise(resolve => {
      vm.$confirm(config.content, config.tip, {
        confirmButtonText: config.btn.confirm,
        cancelButtonText: config.btn.cancel,
        message: config.message,
        dangerouslyUseHTMLString: true
      })
      .then(() => resolve())
      .catch(() => {});
    });
  },
}

export default AupUtil