Commit e90096eb by zhangmeng

init

parents
{
"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
# vue 插件—-门店选择联动
<<<<<<< HEAD
> A Vue.js Store select Plugin
## Install
```shell
npm install @gic-test/vue-gic-store-linkage -S
```
## how to use
```
// main.js
import vueGicStoreLinkage from '@gic-test/vue-gic-store-linkage'
Vue.use(vueGicStoreLinkage)
// 使用页面
<vue-gic-store-linkage :msg="sendChildData" ref="selectTree" @sendSelectGroupData="getSelectGroupData"></vue-gic-store-linkage>
data() {
return {
// 可传参数
sendChildData:{}, // 向子元素传递的对象
}
}
methods: {
//获得子元素传递的数据
getSelectGroupData() {
console.log(val)
}
},
```
This diff is collapsed. Click to expand it.
{"version":3,"file":"build.js","sources":["webpack:///build.js"],"mappings":"AAAA","sourceRoot":""}
\ No newline at end of file
<!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-store</title>
</head>
<body>
<div id="app"></div>
<script src="/dist/build.js"></script>
<!-- <script src="/dist/vue-gic-store.js"></script> -->
</body>
</html>
{
"_from": "@gic-test/vue-gic-store-group@^1.0.3",
"_id": "@gic-test/vue-gic-store-group@1.0.4",
"_inBundle": false,
"_integrity": "sha1-Ak5uUtJJstlqYY5RCAgCJSV3+jk=",
"_location": "/@gic-test/vue-gic-store-group",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@gic-test/vue-gic-store-group@^1.0.3",
"name": "@gic-test/vue-gic-store-group",
"escapedName": "@gic-test%2fvue-gic-store-group",
"scope": "@gic-test",
"rawSpec": "^1.0.3",
"saveSpec": null,
"fetchSpec": "^1.0.3"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "http://www.gicdev.com:7001/@gic-test/vue-gic-store-group/download/@gic-test/vue-gic-store-group-1.0.4.tgz",
"_shasum": "024e6e52d249b2d96a618e51080802252577fa39",
"_spec": "@gic-test/vue-gic-store-group@^1.0.3",
"_where": "C:\\Users\\Administrator\\Desktop\\private",
"bundleDependencies": false,
"dependencies": {
"axios": "^0.18.0",
"vue": "^2.5.11"
},
"deprecated": false,
"description": "vue-gic-store-group Plugin",
"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",
"element-ui": "^2.4.6",
"file-loader": "^1.1.4",
"less-loader": "^4.1.0",
"node-sass": "^4.5.3",
"sass-loader": "^6.0.6",
"url-loader": "^1.1.1",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.9.1"
},
"license": "MIT",
"main": "dist/build.js",
"name": "@gic-test/vue-gic-store-group",
"private": false,
"scripts": {
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot"
},
"version": "1.0.4"
}
<template>
<div style="padding:20px;">
<vue-gic-store-group :model="storeGroupData" @commit-store="getStoreGroup" width="200"></vue-gic-store-group>
</div>
</template>
<script>
import vueGicStoreGroup from './lib/component.vue'
export default {
name: 'app',
data () {
return {
storeGroupData:{"storeGroupId":"ff80808164c7266b0164cb9ee1550039","parentGroupId":"ff808081593917d90159398eca480016","groupLevel":2,"children":[],"storeGroupName":"给对方","label":"给对方","id":"ff80808164c7266b0164cb9ee1550039"}
}
},
components: {
vueGicStoreGroup
},
methods: {
getStoreGroup(val) {
console.log(JSON.stringify(val))
}
}
}
</script>
<style lang="scss">
* {
margin: 0;
padding: 0;
}
</style>
.fl {
float: left;
}
.fr {
float: right;
}
\ No newline at end of file
import axios from 'axios';
import qs from 'qs';
axios.defaults.timeout = 10000;
let base = "http://192.168.1.164:8282/gic/";
const timeout = 10000;
let token = ''//sessionStorage.getItem('user');
/*
*
* 统一 get 请求方法
* @url: 请求的 url
* @params: 请求带的参数
* @header: 带 token
*
*/
export const getRequest = (url, params) => {
return axios({
method: 'get',
url: `${base}${url}`,
data: {},
params: params,
headers: {'content-type': 'application/x-www-form-urlencoded'},// "token": token
});
}
<template>
<div class="plug-sg" :style="'width:'+width+'px;'">
<el-popover popper-class="plug-sg__popover" placement="bottom" trigger="click" v-model="popoverShow">
<el-input slot="reference" suffix-icon="el-icon-arrow-down" :value="newModel.label" :placeholder="newModel.label?'':placeholder"></el-input>
<el-tree
class="plug-sg__tree"
:style="'width:'+width+'px;'"
ref="tree"
:default-expand-all="true"
node-key="id"
:data="treeData"
:highlight-current="true"
@node-click="handleNodeClick">
</el-tree>
<div class="plug-sg__btn">
<el-button class="plug-sg__btn--cancel" size="mini" type="text" @click="close">取消</el-button>
<el-button size="mini" type="text" @click="submit">确定</el-button>
</div>
</el-popover>
</div>
</template>
<script>
import {stringify} from 'qs';
export default {
name:'vue-gic-store-group',
props:{
placeholder:{
type:String,
default:'请选择门店分组'
},
model:{
type:Object,
default(){
return {}
}
},
width:{
type:String,
default:'200'
},
},
data() {
return {
popoverShow:false,
treeData:[],
newModel:Object.assign({},this.model)
}
},
created(){
this.storeGroupList();
},
methods:{
storeGroupList() {
this.axios.post('api-admin/store-group-list',stringify({requestProject:'gic-web'})).then(res => {
const result = res.data.result;
function _rec(list) {
list.map(v => {
v.label = v.storeGroupName;
v.id = v.storeGroupId;
if (v.children instanceof Array && v.children.length>0) {
_rec(v.children);
}
})
}
_rec(result);
this.treeData = result;
this.$nextTick(_ => {
this.$refs.tree.setCurrentKey(this.newModel.id);
})
});
},
handleNodeClick(data,node,comp){
this.newModel = data;
},
submit(){
this.popoverShow = false;
this.$emit('commit-store',this.newModel);
},
close(){
this.popoverShow = false;
}
}
}
</script>
<style lang="scss">
.plug-sg {
display: inline-block;
width: 200px;
&__popover{
padding:10px 0 0 0;
}
&__btn{
height: 36px;
padding: 0 10px;
border-top:1px solid #ebeef5;
line-height: 34px;
text-align:right;
&--cancel {
color: #606266;
}
}
&__tree {
height: 260px;
width: 200px;
overflow-y: auto;
.el-tree-node__label {
text-overflow: ellipsis;
display: inline-block;
white-space: nowrap;
width: 100%;
overflow: hidden;
}
&::-webkit-scrollbar {
width: 0px;
height: 0px;
}
}
}
</style>
import component from './component.vue'
const install = {
install(Vue, options) {
Vue.component(component.name, component)
}
}
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(install);
}
export default install;
\ No newline at end of file
import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './assets/style.scss';
import axios from 'axios'
axios.defaults.baseURL = 'http://gicdev.demogic.com';
Vue.use(ElementUI);
axios.defaults.withCredentials = true
Vue.prototype.axios = axios
new Vue({
el: '#app',
render: h => h(App)
})
\ No newline at end of file
var path = require('path')
var webpack = require('webpack')
var isDev = process.env.NODE_ENV === 'development'
module.exports = {
entry: isDev ? './src/main.js' : './src/lib/index.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js',
library: 'vue-gic-store-group',
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]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
// options: {
// limit: 10000,
// name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
// }
}
]
},
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 = '#cheap-module-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
})
])
}
\ No newline at end of file
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