/**
 * perm 操作权限处理
 * 指令用法：
 *  <el-button v-code">编辑</el-button>
 *  文本输入框code为编号输入框，unit为单位输入框
 */

export default {
  mounted: async (el: HTMLElement, binding: any) => {
    var inputElements = el.getElementsByTagName("input")[0];
    var { value } = binding;
    inputElements.addEventListener("input", function (event) {
      if (value == "code") {
        event.target.value = event.target.value.replace(/[\u4e00-\u9fa5]/g, "");
      } else if (value == "unit") {
        event.target.value = event.target.value.replace(/\d+/g, "");
      }
    });
  },
};
