2025-03-15 18:38:27 +08:00
|
|
|
import Vue from 'vue';
|
2025-03-12 17:57:47 +08:00
|
|
|
|
2025-03-15 18:38:27 +08:00
|
|
|
import Cookies from 'js-cookie';
|
2025-03-12 17:57:47 +08:00
|
|
|
|
2025-03-15 18:38:27 +08:00
|
|
|
import Element from 'element-ui';
|
|
|
|
import './assets/styles/element-variables.scss';
|
2025-03-12 17:57:47 +08:00
|
|
|
|
2025-03-15 18:38:27 +08:00
|
|
|
import '@/assets/styles/index.scss'; // global css
|
|
|
|
import '@/assets/styles/ipad.scss'; // ipad global css
|
|
|
|
import '@/assets/styles/ruoyi.scss'; // ruoyi css
|
|
|
|
import { download } from '@/utils/request';
|
|
|
|
import App from './App';
|
|
|
|
import directive from './directive'; // directive
|
|
|
|
import plugins from './plugins'; // plugins
|
|
|
|
import router from './router';
|
|
|
|
import store from './store';
|
2025-03-12 17:57:47 +08:00
|
|
|
|
2025-03-15 18:38:27 +08:00
|
|
|
import { getConfigKey } from '@/api/system/config';
|
|
|
|
import { getDicts } from '@/api/system/dict/data';
|
2025-03-18 18:05:19 +08:00
|
|
|
import { checkPermi, checkRole } from '@/utils/permission';
|
2025-03-15 18:38:27 +08:00
|
|
|
import { addDateRange, handleTree, parseTime, resetForm, selectDictLabel, selectDictLabels } from '@/utils/ruoyi';
|
|
|
|
import './assets/icons'; // icon
|
|
|
|
import './permission'; // permission control
|
2025-03-12 17:57:47 +08:00
|
|
|
// 分页组件
|
2025-03-15 18:38:27 +08:00
|
|
|
import Pagination from '@/components/Pagination';
|
2025-03-12 17:57:47 +08:00
|
|
|
// 自定义表格工具组件
|
2025-03-15 18:38:27 +08:00
|
|
|
import RightToolbar from '@/components/RightToolbar';
|
2025-03-12 17:57:47 +08:00
|
|
|
// 富文本组件
|
2025-03-15 18:38:27 +08:00
|
|
|
import Editor from '@/components/Editor';
|
2025-03-12 17:57:47 +08:00
|
|
|
// 文件上传组件
|
2025-03-15 18:38:27 +08:00
|
|
|
import FileUpload from '@/components/FileUpload';
|
2025-03-12 17:57:47 +08:00
|
|
|
// 图片上传组件
|
2025-03-15 18:38:27 +08:00
|
|
|
import ImageUpload from '@/components/ImageUpload';
|
2025-03-12 17:57:47 +08:00
|
|
|
// 图片预览组件
|
2025-03-15 18:38:27 +08:00
|
|
|
import ImagePreview from '@/components/ImagePreview';
|
2025-03-12 17:57:47 +08:00
|
|
|
// 字典标签组件
|
2025-03-15 18:38:27 +08:00
|
|
|
import DictTag from '@/components/DictTag';
|
2025-03-12 17:57:47 +08:00
|
|
|
// 头部标签组件
|
2025-03-15 18:38:27 +08:00
|
|
|
import VueMeta from 'vue-meta';
|
2025-03-12 17:57:47 +08:00
|
|
|
// 字典数据组件
|
2025-03-15 18:38:27 +08:00
|
|
|
import DictData from '@/components/DictData';
|
2025-03-12 17:57:47 +08:00
|
|
|
// 过滤器
|
2025-03-15 18:38:27 +08:00
|
|
|
import filter from '@/utils/filter';
|
|
|
|
// 行内表单组件
|
|
|
|
import FormCol from '@/components/FormCol';
|
2025-03-12 17:57:47 +08:00
|
|
|
|
|
|
|
filter(Vue);
|
|
|
|
|
|
|
|
// 全局方法挂载
|
|
|
|
Vue.prototype.getDicts = getDicts
|
|
|
|
Vue.prototype.getConfigKey = getConfigKey
|
|
|
|
Vue.prototype.parseTime = parseTime
|
|
|
|
Vue.prototype.resetForm = resetForm
|
|
|
|
Vue.prototype.addDateRange = addDateRange
|
|
|
|
Vue.prototype.selectDictLabel = selectDictLabel
|
|
|
|
Vue.prototype.selectDictLabels = selectDictLabels
|
|
|
|
Vue.prototype.download = download
|
|
|
|
Vue.prototype.handleTree = handleTree
|
2025-03-18 18:05:19 +08:00
|
|
|
Vue.prototype.checkPermi = checkPermi
|
|
|
|
Vue.prototype.checkRole = checkRole
|
2025-03-12 17:57:47 +08:00
|
|
|
|
|
|
|
// 全局组件挂载
|
|
|
|
Vue.component('DictTag', DictTag)
|
|
|
|
Vue.component('Pagination', Pagination)
|
|
|
|
Vue.component('RightToolbar', RightToolbar)
|
|
|
|
Vue.component('Editor', Editor)
|
|
|
|
Vue.component('FileUpload', FileUpload)
|
|
|
|
Vue.component('ImageUpload', ImageUpload)
|
|
|
|
Vue.component('ImagePreview', ImagePreview)
|
2025-03-15 18:38:27 +08:00
|
|
|
Vue.component('FormCol', FormCol)
|
2025-03-12 17:57:47 +08:00
|
|
|
|
|
|
|
Vue.use(directive)
|
|
|
|
Vue.use(plugins)
|
|
|
|
Vue.use(VueMeta)
|
|
|
|
DictData.install()
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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! ! !
|
|
|
|
*/
|
|
|
|
|
|
|
|
Vue.use(Element, {
|
|
|
|
size: Cookies.get('size') || 'medium' // set element-ui default size
|
|
|
|
})
|
|
|
|
|
|
|
|
Vue.config.productionTip = false
|
|
|
|
|
|
|
|
new Vue({
|
|
|
|
el: '#app',
|
|
|
|
router,
|
|
|
|
store,
|
|
|
|
render: h => h(App)
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 全局添加table左右拖动效果的指令
|
|
|
|
Vue.directive('tableMove', {
|
|
|
|
bind: function (el, binding, vnode) {
|
|
|
|
var odiv = el // 获取当前表格元素
|
|
|
|
|
|
|
|
// 修改样式小手标志
|
|
|
|
// el.style.cursor = 'pointer'
|
|
|
|
el.querySelector('.el-table .el-table__body-wrapper').style.cursor = 'pointer'
|
|
|
|
|
|
|
|
var mouseDownAndUpTimer = null
|
|
|
|
var mouseOffset = 0
|
|
|
|
var mouseFlag = false
|
|
|
|
|
|
|
|
let bindRef = binding.value[0] //绑定的表格的ref属性
|
|
|
|
|
|
|
|
|
|
|
|
odiv.onmousedown = (e) => {
|
|
|
|
const ePath = composedPath(e)
|
|
|
|
// 拖拽表头不滑动
|
|
|
|
if (ePath.some(res => {
|
|
|
|
return res && res.className && res.className.indexOf('el-table__header') > -1
|
|
|
|
})) return
|
|
|
|
|
|
|
|
if (e.which !== 1) return
|
|
|
|
|
|
|
|
mouseOffset = e.clientX
|
|
|
|
mouseDownAndUpTimer = setTimeout(function () {
|
|
|
|
mouseFlag = true
|
|
|
|
}, 80)
|
|
|
|
}
|
|
|
|
|
|
|
|
odiv.onmouseup = (e) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
// 解决拖动列宽行不对齐问题--渲染表格
|
|
|
|
vnode.context.$refs[bindRef].doLayout()
|
|
|
|
}, 200)
|
|
|
|
if (mouseFlag) {
|
|
|
|
mouseFlag = false
|
|
|
|
} else {
|
|
|
|
clearTimeout(mouseDownAndUpTimer) // 清除延迟时间
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
odiv.onmouseleave = (e) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
// 解决拖动列宽行不对齐问题--渲染表格
|
|
|
|
vnode.context.$refs[bindRef].doLayout()
|
|
|
|
}, 200)
|
|
|
|
mouseFlag = false
|
|
|
|
}
|
|
|
|
|
|
|
|
odiv.onmousemove = (e) => {
|
|
|
|
if (e.which !== 1) return
|
|
|
|
|
|
|
|
const divData = odiv.querySelector('.el-table .el-table__body-wrapper')
|
|
|
|
if (mouseFlag && divData) {
|
|
|
|
// 设置水平方向的元素的位置
|
|
|
|
divData.scrollLeft -= (-mouseOffset + (mouseOffset = e.clientX))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 解决有些时候,在鼠标松开的时候,元素仍然可以拖动;
|
|
|
|
odiv.ondragstart = (e) => {
|
|
|
|
e.preventDefault()
|
|
|
|
}
|
|
|
|
|
|
|
|
odiv.ondragend = (e) => {
|
|
|
|
e.preventDefault()
|
|
|
|
}
|
|
|
|
|
|
|
|
// 点击复制文本
|
|
|
|
// odiv.onclick = (e) => {
|
|
|
|
// setTimeout(() => {
|
|
|
|
// if (mouseFlag) return
|
|
|
|
// if (e.target.nodeName === 'SPAN') {
|
|
|
|
// console.log(mouseFlag, e.target.nodeName, this)
|
|
|
|
// var aux = document.createElement('input')
|
|
|
|
// aux.setAttribute('value', e.target.outerText)
|
|
|
|
// document.body.appendChild(aux)
|
|
|
|
// aux.select()
|
|
|
|
// document.execCommand('copy')
|
|
|
|
// document.body.removeChild(aux)
|
|
|
|
// if (document.execCommand('copy')) {
|
|
|
|
// console.log('复制成功')
|
|
|
|
// } else {
|
|
|
|
// console.log('复制失败')
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }, 300)
|
|
|
|
// }
|
|
|
|
|
|
|
|
// 是否拖拽可选中文字
|
|
|
|
odiv.onselectstart = () => {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
//浏览器Event.path属性不存在
|
|
|
|
function composedPath(e) {
|
|
|
|
// 存在则直接return
|
|
|
|
if (e.path) {
|
|
|
|
return e.path
|
|
|
|
}
|
|
|
|
// 不存在则遍历target节点
|
|
|
|
let target = e.target
|
|
|
|
e.path = []
|
|
|
|
while (target.parentNode !== null) {
|
|
|
|
e.path.push(target)
|
|
|
|
target = target.parentNode
|
|
|
|
}
|
|
|
|
// 最后补上document和window
|
|
|
|
e.path.push(document, window)
|
|
|
|
return e.path
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|