Commit 02a6cb05 by 无尘

add people plugin

parent 955251f7
{
"presets": [
["env", { "modules": false }],
"stage-3"
]
}
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
.DS_Store
node_modules/
npm-debug.log
yarn-error.log
# Editor directories and files
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
\ No newline at end of file
vue-gic-people # vue 插件—-人群筛选器
\ No newline at end of file >>> HEAD
> A Vue.js filter people Plugin
## Install
```shell
npm install @gic-test/vue-gic-people -S
```
## how to use
```
// main.js
import vueGicPeople from '@gic-test/vue-gic-people'
Vue.use(vueGicPeople)
// 使用页面
<vue-gic-people :projectName="projectName" :useId="useId" :hasSearchData="hasSearchData" :sceneValue="sceneValue" ref="peopleFilter" @findFilter="findFilter" @getBackData="getBackData" @editHide= "editHide" @editShow="editShow" @hideBtn="hideBtn"></vue-gic-people>
// 按钮根据当前使用场景设置,有的无保存
<div v-if="toggleTag">
<button @click="getData">确定</button>
<button @click="cancelFilter">取消</button>
</div>
<div v-if="saveTag">
<button @click="saveTempData">保存</button>
</div>
data() {
return {
// 可传参数
projectName: '', // 当前项目名
sceneValue: 'member', // 场景值
useId: '', // 模板id
hasSearchData: '' , // 当前页回显的数据(接口返回)
toggleTag: false, // 控制(确认取消)按钮显示的参数,仅供参考,可自行修改
saveTag: false, // 控制(保存)按钮显示的参数,仅供参考,可自行修改
}
},
beforeMount() {
// (如果需要传递数据)请求的数据最好在这里写
},
methods: {
// 父组件调用子组件方法,触发父组件事件
getData() {
var that = this
that.$refs.peopleFilter.confirmSet()
},
// 子组件触发父组件事件,返回过滤条件数据
findFilter(value){
var that = this
console.log(value)
},
// 取消
cancelFilter(){
var that = this
that.$refs.peopleFilter.cancelSet()
},
// 获取需要回显的数据, 供保存时候使用
getBackData(val) {
var that = this
console.log(val)
that.getSaveData = val;
},
// 显示编辑,保存按钮隐藏,确认按钮显示 (子组件会调用)
editShow() {
var that = this
console.log('editShow')
that.toggleTag= true
that.saveTag = false
},
// 显示保存按钮,隐藏确认按钮显示 (子组件会调用)
editHide() {
var that = this
console.log('editHide')
that.toggleTag = false
that.saveTag = true
},
// 隐藏保存按钮和确认按钮 (子组件会调用)
hideBtn() {
var that = this
that.toggleTag= false;
that.saveTag = false
},
// 保存当前模板,对接保存接口
saveTempData() {
var that = this
console.log('save')
}
}
```
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>vue-gic-people</title>
</head>
<body>
<div id="app"></div>
<!-- <script src="/dist/build.js"></script> -->
<script src="/dist/vue-gic-people.js"></script>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "@gic-test/vue-gic-people",
"description": "vue-gic-people Plugin",
"author": "fairyly <498745097@qq.com>",
"version": "1.1.40",
"license": "MIT",
"private": false,
"main": "dist/vue-gic-people.js",
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"@riophae/vue-treeselect": "0.0.35",
"axios": "^0.18.0",
"localforage": "^1.7.2",
"vue": "^2.5.11"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-3": "^6.24.1",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
"less-loader": "^4.1.0",
"node-sass": "^4.5.3",
"sass-loader": "^6.0.6",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.1"
}
}
<template>
<div id="app">
<vue-gic-people :projectName="projectName" :useId="useId" :hasSearchData="hasSearchData" :sceneValue="sceneValue" ref="peopleFilter" @findFilter="findFilter" @getBackData="getBackData" @editHide= "editHide" @editShow="editShow" @hideBtn="hideBtn"></vue-gic-people>
<!-- // 按钮根据当前使用场景设置,有的无保存 -->
<div v-if="toggleTag">
<button @click="getData">确定</button>
<button @click="cancelFilter">取消</button>
</div>
<div v-else>
<button @click="saveTempData">保存</button>
</div>
</div>
</template>
<script>
import vueGicPeople from './lib/vue-gic-people'
export default {
name: 'app',
data () {
return {
projectName: '', // 当前项目名
sceneValue: 'member', // 场景值
useId: '', // 模板id
hasSearchData: '' , // 当前页回显的数据(接口返回)
toggleTag: true, // 控制(确认取消)按钮显示的参数,仅供参考,可自行修改
saveTag: false, // 控制(保存)按钮显示的参数,仅供参考,可自行修改
}
},
components: {
vueGicPeople
},
methods: {
// 父组件调用子组件方法,触发父组件事件
getData() {
var that = this
that.$refs.peopleFilter.confirmSet()
},
// 子组件触发父组件事件,返回过滤条件数据
findFilter(value){
var that = this
console.log(value)
},
// 取消
cancelFilter(){
that.$refs.peopleFilter.cancelSet()
},
// 获取需要回显的数据, 供保存时候使用
getBackData(val) {
var that = this
console.log(val)
that.getSaveData = val;
},
// 显示编辑,保存按钮隐藏,确认按钮显示 (子组件会调用)
editShow() {
var that = this
console.log('editShow')
that.toggleTag= true
that.saveTag = false
},
// 显示保存按钮,隐藏确认按钮显示 (子组件会调用)
editHide() {
var that = this
console.log('editHide')
that.toggleTag = false
that.saveTag = true
},
// 隐藏保存按钮和确认按钮 (子组件会调用)
hideBtn() {
var that = this
console.log('hideBtn')
that.toggleTag= false;
that.saveTag = false
},
// 保存当前模板,对接保存接口
saveTempData() {
var that = this
console.log('save')
}
},
beforeMount() {
// (如果需要传递数据)请求的数据最好在这里写
},
}
</script>
<style lang="scss">
* {
margin: 0;
padding: 0;
}
</style>
import vueGicPeople from './vue-gic-people.vue' // 导入组件
const GicPeople = {
install(Vue, options) {
Vue.component(vueGicPeople.name, vueGicPeople) // vueGicPeople.name 组件的name属性
// 类似通过 this.$xxx 方式调用插件的 其实只是挂载到原型上而已
// Vue.prototype.$xxx // 最终可以在任何地方通过 this.$xxx 调用
// 虽然没有明确规定用$开头 但是大家都默认遵守这个规定
}
}
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(GicPeople);
}
export default GicPeople
// export {
// vueGicPeople
// }
import Vue from 'vue'
import App from './App.vue'
new Vue({
el: '#app',
render: h => h(App)
})
var path = require('path')
var webpack = require('webpack')
module.exports = {
// entry: './src/main.js',
entry: './src/lib/index.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
// filename: 'build.js',
filename: 'vue-gic-people.js',
library: 'vue-gic-people',
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
],
},
{
test: /\.sass$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
],
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
// the "scss" and "sass" values for the lang attribute to the right configs here.
// other preprocessors should work out of the box, no loader config like this necessary.
'scss': [
'vue-style-loader',
'css-loader',
'sass-loader'
],
'sass': [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
]
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment