| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- import Vue from "vue";
- import ElementUI from "element-ui";
- import "./assets/icon/iconfont.css";
- import dayjs from "dayjs";
- import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
- import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
- import isBetween from "dayjs/plugin/isBetween";
- import numeral from "numeral";
- import lodash from "lodash";
- import qs from "qs";
- import PortalVue from "portal-vue";
- Vue.use(PortalVue);
- import { permission } from "@/utils/directivePage";
- import { getTenantId } from "@/utils/auth";
- dayjs.extend(isSameOrBefore);
- dayjs.extend(isSameOrAfter);
- dayjs.extend(isBetween);
- import * as constant from "@/constant";
- import "normalize.css/normalize.css"; // A modern alternative to CSS resets
- import "babel-polyfill";
- // import './theme/index.css'
- // import './global.scss'
- // import 'element-ui/lib/theme-chalk/index.css'
- import locale from "element-ui/lib/locale/lang/zh-CN"; // lang i18n
- import "@/styles/index.scss"; // global css
- import "@/styles/iconfont/iconfont.css"; // 字体图标,主要用于菜单图标
- // import '@/assets/element-variables.scss'
- import App from "./App";
- import store from "./store";
- import installComponents from "@/components/install";
- import router from "./router";
- import "./utils/vueFilter";
- import "./utils/directive";
- // Vue.use(vueFilter)
- import "@/icons"; // icon
- import "@/permission"; // permission control
- import { Message } from "element-ui";
- const showMessage = Symbol("showMessage");
- // imkit 为核心模块
- import { defineCustomElements } from "@rongcloud/imkit";
- defineCustomElements();
- class DonMessage {
- success(options, single = true) {
- this[showMessage]("success", options, single);
- }
- warning(options, single = true) {
- this[showMessage]("warning", options, single);
- }
- info(options, single = true) {
- this[showMessage]("info", options, single);
- }
- error(options, single = true) {
- this[showMessage]("error", options, single);
- }
- [showMessage](type, options, single) {
- // console.log(type, options, Message)
- let params = {
- message: options,
- offset: 90
- };
- if (single) {
- // 判断是否已存在Message
- if (document.getElementsByClassName("el-message").length === 0) {
- Message[type](params);
- }
- } else {
- Message[type](params);
- }
- }
- }
- // 修改默认属性
- ElementUI.Dialog.props.closeOnClickModal.default = false;
- // ElementUI.Dialog.props.destroyOnClose.default = true;
- // (ElementUI.Input)
- // 全局修改选择如果value与label都为数字0则清空
- const SelectValueWatch = ElementUI.Select.watch.value;
- ElementUI.Select.watch.value = function(newValue, oldValue) {
- SelectValueWatch.call(this, newValue, oldValue);
- if (
- this.selected &&
- this.selected.value === 0 &&
- this.selected.currentLabel === 0 &&
- newValue !== oldValue
- ) {
- this.handleClearClick.call(this, {
- stopPropagation: () => {}
- });
- }
- };
- // Vue.use(ElementUI)
- Vue.use(installComponents);
- // 命名根据需要,DonMessage只是在文章中使用
- export const $message = new DonMessage();
- Vue.prototype.$message = $message;
- // 全局移除数字滚动
- document.addEventListener("mousewheel", function() {
- if (document.activeElement.type === "number") {
- document.activeElement.blur();
- }
- });
- // 费用审核输入框回车之后失去焦点有问题,所以注释
- // document.addEventListener('keydown', function (event) {
- // if (event.keyCode == 13) {
- // setTimeout(() => {
- // document.activeElement.blur()
- // }, 300)
- // }
- // })
- /**
- * If you don't want to use mock-server
- * you want to use MockJs for mock api
- * you can execute: mockXHR()
- *
- * Currently MockJs will be used in the production environment,
- * please remove it before going online! ! !
- */
- // import { mockXHR } from '../mock'
- // if (process.env.NODE_ENV === 'production') {
- // mockXHR()
- // }
- // 高德地址
- import VueAMap from "vue-amap";
- Vue.use(VueAMap);
- // 检测浏览器是否缩放
- // import '@/utils/zoom'
- Vue.prototype.$ELEMENT = {
- size: "medium",
- zIndex: 3000
- };
- // set ElementUI lang to EN
- Vue.use(ElementUI, {
- locale
- });
- Vue.config.productionTip = false;
- Vue.prototype.$bus = new Vue();
- // 将selects全局混入当前vue实例中
- Vue.mixin({
- computed: {
- selects() {
- return store.state.selects;
- },
- $helpers() {
- return {
- dayjs,
- numeral,
- lodash,
- qs,
- permission,
- tenantId: getTenantId()
- };
- },
- $constant() {
- return constant;
- }
- },
- methods: {
- isNumber(val, max) {
- // 只能输入正整数,且可以限制最大值,用法:@input="e => (form.cloud_room_up_limit = isNumber(e, 7))"
- val = val.replace(/\b(0+)+[^0-9]*/gi, "");
- if (val > max) {
- val = max;
- }
- return val;
- },
- keyupEvent(e, input) {
- // 正数,小数2位 @keyup.native='keyupEvent($event)'
- e.target.value = e.target.value.replace(/[^\d.]/g, "");
- e.target.value = e.target.value.replace(/\.{2,}/g, ".");
- e.target.value = e.target.value.replace(/^\./g, "0.");
- e.target.value = e.target.value.replace(
- /^\d*\.\d*\./g,
- e.target.value.substring(0, e.target.value.length - 1)
- );
- e.target.value = e.target.value.replace(/^0[^\.]+/g, "0");
- e.target.value = e.target.value.replace(/^(\d+)\.(\d\d).*$/, "$1.$2");
- },
- changeHash(value) {
- const origin = window.location.origin;
- history.replaceState(
- "",
- "",
- `${origin}/#${this.$route.path}?opt=${value}`
- );
- },
- getFullPermission(str) {
- let routeName = this.$route.path;
- return str + routeName;
- }
- }
- });
- new Vue({
- el: "#app",
- router,
- store,
- render: h => h(App)
- });
|