Commit 1d573610 by limin

init

0 parents
> 1%
last 2 versions
not dead
# Build and Release Folders
# Other files and folders
.settings/
main-container/node_modules/
module-basic-data/node_modules/
module-report/node_modules/
node_modules/
LICENSE
dist/
# Executables
*.swf
*.air
*.ipa
*.apk
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
# should NOT be excluded as they contain compiler settings and other important
# information for Eclipse / Flash Builder.
LICENSE
# glsx-components
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
This diff could not be displayed because it is too large.
{
"name": "glsx-components",
"description": "glsx vue components",
"version": "1.0.3",
"author": "limin <17653212@qq.com>",
"license": "MIT",
"main": "dist/glsx-components.common.js",
"private": false,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lib": "vue-cli-service build --target lib --name glsx-components ./src/packages/index.js"
},
"dependencies": {
"core-js": "^3.6.5",
"element-ui": "^2.15.6",
"glsx-common": "^1.3.2",
"vue": "^2.6.11"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"node-sass": "^4.14.1",
"sass-loader": "^8.0.0",
"vue-template-compiler": "^2.6.11"
}
}
No preview for this file type
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld msg="Welcome to Your Vue.js App" />
<GLExternal url="//localhost:8080/html/employee/index.html" :subscribe="subscribe"></GLExternal>
<GLButton @click="click" id="1-1-1-1" mode="button">232321321</GLButton>
<el-button type="primary">aaa</el-button>
<GLDialog :visible.sync="visible" title="aaaaaaaaa">
<div slot="footer">
<el-button size="small" @click="visible = false">取消</el-button>
<el-button type="primary" size="small">aaa</el-button>
</div>
</GLDialog>
<GLTable></GLTable>
</div>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
export default {
name: 'App',
components: {
HelloWorld
},
data() {
return {
visible: false
}
},
methods: {
subscribe(child) {
child.call('push', { src: this.src })
child.on('route-to', params => {
this.$history.push(params)
})
},
click() {
this.visible = true
}
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-09-21 10:36:52
* @LastEditors: limin
* @LastEditTime: 2021-09-24 18:37:14
* @FilePath: \npm\glsx-components\src\index.js
*/
import _Vue from 'vue'
const GLComponents = {}
const componentsFiles = require.context(`./components`, true, /.vue|js$/)
GLComponents.install = Vue => {
if (!Vue) {
window.Vue = Vue = _Vue
}
componentsFiles.keys().forEach(path => {
const component = componentsFiles(path).default
Vue.component(component.name, component)
})
}
export default GLComponents
import Vue from 'vue'
import App from './App.vue'
import { GLExternal, GLButton, GLDialog, GLTable } from './packages/index'
import '../dist/glsx-components.css'
Vue.use(GLExternal)
Vue.use(GLDialog)
Vue.use(GLTable)
Vue.use(GLButton, { permissions: ['1-1-1-1', '2-1-1-1', '3-1-1-1'], a: '1111' })
Vue.config.productionTip = false
new Vue({
render: h => h(App)
}).$mount('#app')
import GLButton from "./src/index.js";
// 为组件提供 install 安装方法,供按需引入
GLButton.install = function(Vue, { permissions } = {}) {
Vue.prototype.permissions = permissions;
Vue.component(GLButton.name, GLButton);
};
// 默认导出组件
export default GLButton;
/**
* type : primary,success,default,error,danger
* size: 按钮大小,参照elementui
* id: 权限判断id
* mode:按钮类型 是a标签还是button,可选值为:button、link
*/
// 权限校验
function judgePermissions(options) {
if (!options) {
return false
}
let _list = options.parent.permissions || []
const {
props: { id, mode }
} = options
let idx = _list.some(k => k == id)
// 如果没有权限,则返回空标签
if (!idx) {
return ''
}
if (mode == 'link') {
return 'a'
}
return 'button'
}
// 获取class
function getClass(context) {
let o = context.props
let _class = []
_class.push('el-' + o.mode)
_class.push('el-' + o.mode + '--' + o.type)
if (o.size) {
_class.push('el-' + o.mode + '--' + o.size)
}
if (o.class) {
_class.push(o.class)
}
return _class
}
export default {
functional: true,
name: 'GLButton',
props: {
a: String,
type: {
type: String,
default: 'default'
},
size: {
type: String,
default: 'medium'
},
id: {
type: [String, Number]
},
mode: {
type: String,
default: 'button'
},
class: {
type: String,
default: ''
}
},
render: function(createElement, context) {
let _props = context.props
let options = {
props: _props,
attrs: context.props,
class: getClass(context),
on: {
click: event => {
context.listeners.click && context.listeners.click('click', event)
}
}
}
return createElement(judgePermissions(context), options, context.children)
}
}
import GLDialog from './src/index.vue'
// 为组件提供 install 安装方法,供按需引入
GLDialog.install = function(Vue) {
Vue.component(GLDialog.name, GLDialog)
}
// 默认导出组件
export default GLDialog
<template>
<el-dialog :visible.sync="isVisible" v-bind="$props" v-on="$listeners" class="app-dialog" @close="handleClose">
<div slot="title" class="title-wrap">
<slot name="title" v-if="$slots.title" />
<span class="el-dialog__title" v-else>{{ title }}</span>
</div>
<slot></slot>
<!-- <template v-for="(index, name) in $slots" :slot="name">
<slot :name="name" />
</template> -->
<template slot="footer">
<slot name="footer" />
</template>
</el-dialog>
</template>
<script>
import { Dialog } from 'element-ui'
export default {
name: 'GLDialog',
components: {
[Dialog.name]: Dialog
},
props: {
...Dialog.props,
visible: {
type: Boolean,
default: false
},
showClose: {
type: Boolean,
default: false
},
title: {}
},
computed: {
isVisible: {
get() {
return this.visible
},
set(v) {
this.$emit('update:visible', v)
}
}
},
methods: {
handleClose() {
this.$emit('close')
}
}
}
</script>
<style lang="scss">
.app-dialog {
/deep/.el-dialog__header {
padding: 20px 20px 10px;
.title-wrap {
text-align: left;
}
}
/deep/ .el-dialog__footer {
padding: 15px;
background: #fff;
}
/deep/.el-dialog__body {
padding: 0;
border-top: 1px solid #eaeefb;
border-bottom: 1px solid #eaeefb;
min-height: 250px;
max-height: 636px;
overflow-y: auto;
.container {
> span {
display: block;
}
overflow-y: auto;
// max-height: 638px;
padding: 20px 20px;
}
&::-webkit-scrollbar {
width: 10px;
height: 10px;
}
/*正常情况下滑块的样式*/
&::-webkit-scrollbar-thumb {
background-color: rgba(0, 0, 0, 0.05);
border-radius: 10px;
box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.1);
}
/*鼠标悬浮在该类指向的控件上时滑块的样式*/
&::-webkit-scrollbar-thumb {
// background-color: rgba(0, 0, 0, 0.2);
background: #e9e8ff;
border-radius: 10px;
box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.1);
}
/*鼠标悬浮在滑块上时滑块的样式*/
// &::-webkit-scrollbar-thumb:hover {
// background-color: rgba(0, 0, 0, 0.4);
// box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.1);
// }
/*正常时候的主干部分*/
&::-webkit-scrollbar-track {
border-radius: 10px;
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0);
background-color: white;
}
/*鼠标悬浮在滚动条上的主干部分*/
&::-webkit-scrollbar-track:hover {
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.4);
background-color: rgba(0, 0, 0, 0.01);
}
}
}
</style>
import GLExternal from "./src/index.vue";
// 为组件提供 install 安装方法,供按需引入
GLExternal.install = function(Vue) {
Vue.component(GLExternal.name, GLExternal);
};
// 默认导出组件
export default GLExternal;
<template>
<div class="adapter-home" id="adapter-frame" ref="adapter-frame"></div>
</template>
<script>
import { Postmate } from "glsx-common";
export default {
name: "GLExternal",
props: {
url: {
type: String,
required: true,
},
subscribe: {
type: Function,
default: null,
},
},
data() {
return {
container: null,
};
},
mounted() {
this.container = this.$refs["adapter-frame"];
this.create();
},
methods: {
create() {
if (!this.url) throw new Error("url为空");
this.container.innerHTML = "";
var postmate = new Postmate({
container: this.container,
url: this.url,
name: "adapter-frame",
classListArray: ["gl-external-adapter-frame"],
})
.then((child) => {
child.get("height").then((height) => {
child.frame.setAttribute("scrolling", "no");
child.frame.style.height = `${height}px`;
});
this.subscribe && this.subscribe(child);
})
.catch((err) => {
console.log(err);
throw new Error("连接失败: " + this.url);
});
},
},
};
</script>
<style>
.gl-external-adapter-frame {
width: 100%;
min-height: calc(100vh - 90px);
border: 0;
overflow-y: hidden;
box-sizing: border-box;
/* position: absolute; */
transition: all 0.48s ease;
}
</style>
import GLTable from './src/index.vue'
// 为组件提供 install 安装方法,供按需引入
GLTable.install = function(Vue) {
Vue.component(GLTable.name, GLTable)
}
// 默认导出组件
export default GLTable
<!-- 表格+分页 -->
<template>
<div class="glsx-table">
<el-table :ref="tableParams.mutiSelectName + 'MutiTable' || 'MutiTable'" :data="getListApi ? data : tableData" :row-key="tableParams.mutiSelectUniqueKey || ''" v-loading="loading" :border="border" :highlight-current-row="true" :stripe="true" @sort-change="sortChange" @selection-change="handleSelect" :size="size" :header-cell-style="headerStyle">
<el-table-column v-if="tableParams.mutiSelectUniqueKey && tableParams.mutiSelectName" type="selection" width="55" :selectable="checkSelectable" :reserve-selection="true"></el-table-column>
<el-table-column v-if="hasNum" align="center" width="60px" label="序号" type="index" :index="index => index + (page[this.pageConf.pageNum] - 1) * page[this.pageConf.pageSize] + 1"></el-table-column>
<el-table-column v-for="(item, index) in tableColumns" :key="index" :label="item.label" :prop="item.prop" :width="item.width" :min-width="item.minWidth" :align="item.align || 'center'" :sortable="item.sortable">
<template slot-scope="scope">
<slot v-if="item.addHtml" :name="item.addHtml" :scope="scope.row" :prop="item.prop" :width="item.width"></slot>
<template v-else-if="item.formatter">
<span class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" :title="item.formatter(scope.row)" v-text="item.formatter(scope.row)"></span>
</template>
<template v-else-if="getListApi">
<span class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" :title="scope.row[item.prop]" v-text="scope.row[item.prop]"></span>
</template>
<template v-else>
<span class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" :title="tableData[scope.$index][item.prop]" v-text="tableData[scope.$index][item.prop]"></span>
</template>
<template v-if="item.addSymbol">
<span v-text="item.addSymbol"></span>
</template>
</template>
</el-table-column>
<el-table-column v-if="tableParams.tableOption" label="操作" :align="tableParams.tableOption.align || 'center'" :width="tableParams.tableOption.width || '200'" fixed="right">
<template slot-scope="scope">
<slot name="auth-button" :scope="scope.row"></slot>
</template>
</el-table-column>
<div slot="empty" class="emptyBg">
<img class="noDataImg" :src="noDataImg" v-if="noDataImg" alt="" />
<p>{{ noDataText }}</p>
<slot name="additionalContent"></slot>
</div>
</el-table>
<el-pagination v-if="hasPage" background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page[this.pageConf.pageNum]" :page-sizes="[10, 20, 30, 40]" :page-size="page[this.pageConf.pageSize]" :total="getListApi ? total : tableTotal" :layout="layout"></el-pagination>
</div>
</template>
<script>
import { Table, TableColumn, Pagination } from 'element-ui'
export default {
name: 'GLTable',
components: {
[Table.name]: Table,
[TableColumn.name]: TableColumn,
[Pagination.name]: Pagination
},
data() {
return {
loading: false,
data: [],
// 页码
page: {},
total: 10,
// 多选数组
mutiSelectArr: {},
tableColumns: []
}
},
props: {
size: {
type: String,
default: 'medium'
},
noDataImg: {
type: String,
default: ''
},
noDataText: {
type: String,
default: '暂无数据'
},
border: {
type: Boolean,
default: false
},
headerStyle: {
type: Object,
default: () => {}
},
// 搜索条件
searchForm: {
type: Object,
default: () => {}
},
// 是否定制表头
isCustomHead: {
type: Boolean,
default: false
},
// 表头展示
customHeadShowList: {
type: Array,
default: () => []
},
// 表格数据-外部传入
tableData: {
type: Array,
default: () => []
},
tableTotal: {
type: Number,
default: 0
},
// 获取列表接口
getListApi: {
type: Function,
default: null
},
// 搜索前操作
beforeSearchFn: {
type: Function,
default: () => {
return new Promise((resolve, reject) => {
resolve()
})
}
},
// 分页,默认有
hasPage: {
type: Boolean,
default: true
},
pageConf: {
type: Object,
default: () => ({ pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'totalCount' })
},
// 分页组件配置
layout: {
type: String,
default: 'sizes,total,->,prev,pager,next,jumper'
},
// 序号,默认有
hasNum: {
type: Boolean,
default: true
},
tableParams: {
type: Object,
default: () => {
return {
// 多选-判断来自哪个页面
// mutiSelectName: {
// type: String,
// default: ''
// },
// 多选-唯一标识-行数据的key
// mutiSelectUniqueKey: {
// type: String,
// default: ''
// },
// 设置禁止选中的行数据
checkSelectKey: {
type: String,
default: ''
},
// 设置禁止选中的值
checkSelectVal: {
type: Array,
default: () => []
},
// 后端返回列表参数名
listName: {
type: String,
default: ''
},
// 表格操作,默认没有
// tableOption: {
// type: Object,
// default: null
// },
// 表格栏
tableColumns: {
type: Array,
default: () => []
}
}
}
}
},
watch: {
customHeadShowList(val) {
this.isCustomHead && this.findShowHeadCol()
}
},
mounted() {
this.isCustomHead ? this.findShowHeadCol() : (this.tableColumns = this.tableParams.tableColumns)
this.page = {}
this.page[this.pageConf.pageSize] = 10
this.page[this.pageConf.pageNum] = 1
this.getListApi && this.refreshTable()
},
methods: {
findShowHeadCol() {
this.tableColumns = []
this.tableParams.tableColumns.forEach(item => {
let isCustomCol = item.hasOwnProperty('isCustomCol')
if (!isCustomCol || (isCustomCol && this.customHeadShowList.includes(item.label))) {
this.tableColumns.push(item)
}
})
},
// 设置禁止选中的行数据
checkSelectable(row) {
if (this.tableParams.checkSelectKey && this.tableParams.checkSelectVal.length > 0) {
return this.tableParams.checkSelectVal.indexOf(row[this.tableParams.checkSelectKey]) == -1
} else {
return true
}
},
// 排序
sortChange({ column, prop, order }) {
this.$emit('sortChange', { column, prop, order })
},
// 多选
handleSelect(val) {
this.mutiSelectArr[this.tableParams.mutiSelectName] = val
},
// 清空多选
clearMutiSelect() {
this.mutiSelectArr[this.tableParams.mutiSelectName] = []
this.$refs[this.tableParams.mutiSelectName + 'MutiTable'].clearSelection()
},
refreshTable(isResetPageNum = true, isClearMuti = true) {
this.beforeSearchFn().then(res => {
// 清空多选
isClearMuti && this.clearMutiSelect()
this.loading = true
isResetPageNum && (this.page[this.pageConf.pageNum] = 1)
var params = {
...this.page,
...this.searchForm
}
this.getListApi(params)
.then(res => {
this.data = this.findVal(res, this.tableParams.listName)
this.total = this.findVal(res, this.pageConf.totalCount)
this.loading = false
})
.catch(() => {
this.loading = false
})
})
},
// 找返回值
findVal(res, rankStr) {
var rankList = rankStr.split('.')
if (!rankStr) {
return res
}
return this.findVal(res[rankList[0]], rankList.splice(1).join('.'))
},
// 每页条数
handleSizeChange(value) {
this.page[this.pageConf.pageSize] = value
this.getListApi ? this.refreshTable(false, false) : this.$emit('refreshTable', this.page)
},
// 页码
handleCurrentChange(value) {
this.page[this.pageConf.pageNum] = value
this.getListApi ? this.refreshTable(false, false) : this.$emit('refreshTable', this.page)
}
}
}
</script>
<style>
.a-click {
cursor: pointer;
}
.el-table .cell {
line-height: 14px;
}
.glsx-table p {
margin: 10px 0;
}
.glsx-table .line-ellipsis {
display: -webkit-box;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
/* -webkit-line-clamp: 2; */
-webkit-box-orient: vertical;
}
.el-table-column--selection .cell {
padding-left: 14px !important;
padding-right: 14px !important;
}
.glsx-table .emptyBg .noDataImg {
display: inline-block;
margin-top: 150px;
height: 100%;
}
.glsx-table .emptyBg p {
margin-top: -20px;
height: 100%;
}
</style>
// 导入颜色选择器组件
import GLExternal from './External'
import GLButton from './Button'
import GLDialog from './Dialog'
import GLTable from './Table'
import '@/theme/index.css'
import '@/plugins/element.js'
// 存储组件列表
const components = [GLExternal, GLButton, GLDialog, GLTable]
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
const install = function(Vue) {
// 判断是否安装
if (install.installed) return
// 遍历注册全局组件
components.map(component => Vue.component(component.name, component))
}
// 判断是否是直接引入文件
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
}
export { GLExternal, GLButton, GLDialog, GLTable }
export default {
// 导出的对象必须具有 install,才能被 Vue.use() 方法安装
install
}
import Vue from 'vue'
// import 'element-ui/lib/theme-chalk/index.css'
import { Button, ButtonGroup, Loading } from 'element-ui'
Vue.use(Loading)
Vue.use(Button)
Vue.use(ButtonGroup)
No preview for this file type
No preview for this file type
This diff could not be displayed because it is too large.
const path = require("path");
const resolve = (dir) => path.join(__dirname, dir);
module.exports = {
chainWebpack: (config) => {
config.resolve.alias.set("@", resolve("src"));
},
configureWebpack: {
// webpack 设置,可覆盖默认配置
entry:
process.env.NODE_ENV == "development"
? "./src/main.js"
: "./src/index.js",
output: {
path: path.resolve(__dirname, "./dist"),
// publicPath: "/dist/",
filename: "glsx-components.js",
library: "glsx-components",
libraryTarget: "umd",
umdNamedDefine: true,
},
},
};
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!