Commit 1bd11330 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-linkage Plugin
![预览图1](http://115.159.76.241/vue-plugins/vue-gic-store-linkage/raw/master/preview/1.jpg)
![预览图2](http://115.159.76.241/vue-plugins/vue-gic-store-linkage/raw/master/preview/2.jpg)
## 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" @sendSelectGroupData="getSelectGroupData"></vue-gic-store-linkage>
data() {
return {
// 可传参数
sendChildData: {
storeType:0, //门店类型 0:全部门店 1:门店分组 (对应下面storeGroupIds)2:部分门店 (对应下面storeIds)
storeGroupIds:'', //门店分组 字符串数组,用逗号隔开
storeIds:[] //部分门店 数组对象 对象格式 {storeName:'门店1',storeId:'xxxxxxxxxxxxxx'} 传这种形式是为了回显
},
}
}
methods: {
//获得子元素传递的数据
getSelectGroupData() {
console.log(val)
}
},
```
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("vue-gic-store-linkage",[],t):"object"==typeof exports?exports["vue-gic-store-linkage"]=t():e["vue-gic-store-linkage"]=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/dist/",t(t.s=3)}([function(e,t,r){"use strict";var o=r(11),n=r.n(o);t.a={name:"vue-gic-store-linkage",props:{msg:{type:Object},disabled:{type:Boolean,default:!1}},data:function(){return{options:[{value:"0",label:"所有门店"},{value:"1",label:"门店分组"},{value:"2",label:"部分门店"}],defaultProps:{children:"children",label:"storeGroupName"},dataObj:[],showShopTree:!1,showSearchList:!1,searchValue:"",selecData:[],selectListId:[],storeList:[],shopGroupValue:"已选择0个门店分组",selectList:[],storeIds:[],checkedKeys:[],groupIds:"",storeType:"0"}},watch:{msg:function(e,t){this.init(e)}},created:function(){this.init(this.msg)},mounted:function(){this.getGroupTreeData()},methods:{init:function(e){e.storeList&&e&&e.storeList.length>0&&(this.selecData=e.storeList||[]),e.storeType&&(this.storeType=e.storeType.toString(),"1"==this.storeType?(this.groupIds=e.storeGroupIds,this.shopGroupValue="已选择"+e.storeGroupIds.split(",").length+"个门店分组",this.checkedKeys=e.storeGroupIds.split(",").filter(function(e){return!!e})):"2"==this.storeType&&(this.storeIds=Object.assign([],e.storeIds)),this.getGroupTreeData())},getGroupTreeData:function(){var e=this;this.axios.get("/api-admin/store-group-list",{params:{requestProject:"gic-web"}}).then(function(t){var r=t.data;0==r.errorCode&&(e.dataObj=r.result)})},getSearchData:function(){var e=this;this.axios.post("/api-plug/query-store-by-code-name",n.a.stringify({requestProject:"gic-web",searchParam:this.searchValue,selectedIds:this.selectListId.join(","),flag:"1"})).then(function(t){var r=t.data;0==r.errorCode&&(e.selectList=r.result)})},selectShop:function(){this.emitObj()},toggleShopTree:function(){this.disabled||(this.showShopTree=!this.showShopTree)},groupBtnSure:function(){if(this.showShopTree=!1,!this.disabled){var e=this.$refs.shopGroupTree.getCheckedKeys(),t=e.length;this.groupIds=e.join(","),this.shopGroupValue="已选择"+t+"个门店分组",this.emitObj()}},toggleSearchShop:function(){this.showSearchList=!this.showSearchList},showSearchTree:function(){this.showSearchList=!0},hideSearch:function(){this.showSearchList=!1},hideTree:function(){this.showShopTree=!1,this.showSearchList=!1},selectShopSuccess:function(e,t){this.storeIds.map(function(e){return e.storeId}).indexOf(e.storeId)>-1||(this.storeIds.push(e),this.emitObj())},removeData:function(e){this.disabled||(this.storeIds.splice(e,1),this.emitObj())},emitObj:function(){var e={storeGroupIds:this.groupIds,storeIds:this.storeIds,storeType:parseInt(this.storeType)};this.$emit("sendSelectGroupData",e)}}}},function(e,t,r){"use strict";var o=Object.prototype.hasOwnProperty,n=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),s=function(e){for(var t;e.length;){var r=e.pop();if(t=r.obj[r.prop],Array.isArray(t)){for(var o=[],n=0;n<t.length;++n)void 0!==t[n]&&o.push(t[n]);r.obj[r.prop]=o}}return t},i=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},o=0;o<e.length;++o)void 0!==e[o]&&(r[o]=e[o]);return r},a=function e(t,r,n){if(!r)return t;if("object"!=typeof r){if(Array.isArray(t))t.push(r);else{if("object"!=typeof t)return[t,r];(n.plainObjects||n.allowPrototypes||!o.call(Object.prototype,r))&&(t[r]=!0)}return t}if("object"!=typeof t)return[t].concat(r);var s=t;return Array.isArray(t)&&!Array.isArray(r)&&(s=i(t,n)),Array.isArray(t)&&Array.isArray(r)?(r.forEach(function(r,s){o.call(t,s)?t[s]&&"object"==typeof t[s]?t[s]=e(t[s],r,n):t.push(r):t[s]=r}),t):Object.keys(r).reduce(function(t,s){var i=r[s];return o.call(t,s)?t[s]=e(t[s],i,n):t[s]=i,t},s)},l=function(e,t){return Object.keys(t).reduce(function(e,r){return e[r]=t[r],e},e)},c=function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}},p=function(e){if(0===e.length)return e;for(var t="string"==typeof e?e:String(e),r="",o=0;o<t.length;++o){var s=t.charCodeAt(o);45===s||46===s||95===s||126===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122?r+=t.charAt(o):s<128?r+=n[s]:s<2048?r+=n[192|s>>6]+n[128|63&s]:s<55296||s>=57344?r+=n[224|s>>12]+n[128|s>>6&63]+n[128|63&s]:(o+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(o)),r+=n[240|s>>18]+n[128|s>>12&63]+n[128|s>>6&63]+n[128|63&s])}return r},u=function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],o=0;o<t.length;++o)for(var n=t[o],i=n.obj[n.prop],a=Object.keys(i),l=0;l<a.length;++l){var c=a[l],p=i[c];"object"==typeof p&&null!==p&&-1===r.indexOf(p)&&(t.push({obj:i,prop:c}),r.push(p))}return s(t)},d=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},f=function(e){return null!==e&&void 0!==e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))};e.exports={arrayToObject:i,assign:l,compact:u,decode:c,encode:p,isBuffer:f,isRegExp:d,merge:a}},function(e,t,r){"use strict";var o=String.prototype.replace,n=/%20/g;e.exports={default:"RFC3986",formatters:{RFC1738:function(e){return o.call(e,n,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),n={install:function(e,t){e.component(o.a.name,o.a)}};"undefined"!=typeof window&&window.Vue&&window.Vue.use(n),t.default=n},function(e,t,r){"use strict";function o(e){r(5)}var n=r(0),s=r(14),i=r(10),a=o,l=i(n.a,s.a,!1,a,null,null);t.a=l.exports},function(e,t,r){var o=r(6);"string"==typeof o&&(o=[[e.i,o,""]]),o.locals&&(e.exports=o.locals);r(8)("13345048",o,!0,{})},function(e,t,r){t=e.exports=r(7)(!1),t.push([e.i,'.select-shop{position:relative}.select-shop__left{width:200px;margin-right:7px;position:relative;display:inline-block;vertical-align:top}.select-shop__popover{width:200px;padding:10px 0 0}.select-shop__right{width:200px;display:inline-block;vertical-align:top;font-size:14px;position:relative}.select-shop__right--total{position:absolute;right:1px;top:5px;height:30px;line-height:30px;border-radius:3px;background:#fff;opacity:.9;padding:0 5px;font-size:12px;cursor:pointer}.select-shop__tree{padding:0;overflow-y:auto;height:260px;box-sizing:border-box;position:relative}.select-shop__tree::-webkit-scrollbar{width:0;height:0}.select-shop__tree .el-tree-node__label{text-overflow:ellipsis;display:inline-block;white-space:nowrap;width:100%;overflow:hidden}.select-shop__btn--wrap{padding:0 15px;border-top:1px solid #ebeef5;height:36px;line-height:34px;text-align:right}.select-shop__tag--input{padding:0 4px;line-height:36px;overflow:hidden;white-space:nowrap}.select-shop__tag--tips{padding-left:8px;line-height:36px}.select-shop__search{box-shadow:0 2px 12px 0 rgba(0,0,0,.1)}.select-shop__search--input{padding:10px 10px 0}.select-shop__search--list .no-data{height:34px;line-height:34px;text-align:center;color:#606266}.select-shop__search--list ul{padding:0 10px}.select-shop__search--list ul li{font-size:14px;position:relative;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#606266;height:34px;line-height:34px;box-sizing:border-box;cursor:pointer}.select-shop__search--list ul li:hover{background-color:#f5f7fa}.select-shop__search--list ul li.on{color:#409eff;background-color:#fff;font-weight:700}.select-shop__search--list ul li.on:after{position:absolute;right:20px;font-family:element-icons;content:"\\E611";font-size:12px;font-weight:700;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.select-shop__search--tip{font-size:12px;background-color:#f6f8f9;height:30px;line-height:30px;padding-left:10px;color:#606266;box-sizing:border-box}.select-shop__tag{box-sizing:border-box;border-color:transparent;margin:2px 0 2px 6px;background-color:#f0f2f5;height:24px;padding:2px 8px;line-height:22px;color:#909399;border-radius:4px;font-size:12px;display:inline-block}.select-shop__tag .dele-icon{padding-left:5px;cursor:pointer}.select-shop__popper--tag{margin:4px}',""])},function(e,t){function r(e,t){var r=e[1]||"",n=e[3];if(!n)return r;if(t&&"function"==typeof btoa){var s=o(n);return[r].concat(n.sources.map(function(e){return"/*# sourceURL="+n.sourceRoot+e+" */"})).concat([s]).join("\n")}return[r].join("\n")}function o(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var o=r(t,e);return t[2]?"@media "+t[2]+"{"+o+"}":o}).join("")},t.i=function(e,r){"string"==typeof e&&(e=[[null,e,""]]);for(var o={},n=0;n<this.length;n++){var s=this[n][0];"number"==typeof s&&(o[s]=!0)}for(n=0;n<e.length;n++){var i=e[n];"number"==typeof i[0]&&o[i[0]]||(r&&!i[2]?i[2]=r:r&&(i[2]="("+i[2]+") and ("+r+")"),t.push(i))}},t}},function(e,t,r){function o(e){for(var t=0;t<e.length;t++){var r=e[t],o=p[r.id];if(o){o.refs++;for(var n=0;n<o.parts.length;n++)o.parts[n](r.parts[n]);for(;n<r.parts.length;n++)o.parts.push(s(r.parts[n]));o.parts.length>r.parts.length&&(o.parts.length=r.parts.length)}else{for(var i=[],n=0;n<r.parts.length;n++)i.push(s(r.parts[n]));p[r.id]={id:r.id,refs:1,parts:i}}}}function n(){var e=document.createElement("style");return e.type="text/css",u.appendChild(e),e}function s(e){var t,r,o=document.querySelector("style["+y+'~="'+e.id+'"]');if(o){if(h)return g;o.parentNode.removeChild(o)}if(b){var s=f++;o=d||(d=n()),t=i.bind(null,o,s,!1),r=i.bind(null,o,s,!0)}else o=n(),t=a.bind(null,o),r=function(){o.parentNode.removeChild(o)};return t(e),function(o){if(o){if(o.css===e.css&&o.media===e.media&&o.sourceMap===e.sourceMap)return;t(e=o)}else r()}}function i(e,t,r,o){var n=r?"":o.css;if(e.styleSheet)e.styleSheet.cssText=m(t,n);else{var s=document.createTextNode(n),i=e.childNodes;i[t]&&e.removeChild(i[t]),i.length?e.insertBefore(s,i[t]):e.appendChild(s)}}function a(e,t){var r=t.css,o=t.media,n=t.sourceMap;if(o&&e.setAttribute("media",o),v.ssrId&&e.setAttribute(y,t.id),n&&(r+="\n/*# sourceURL="+n.sources[0]+" */",r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */"),e.styleSheet)e.styleSheet.cssText=r;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(r))}}var l="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!l)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var c=r(9),p={},u=l&&(document.head||document.getElementsByTagName("head")[0]),d=null,f=0,h=!1,g=function(){},v=null,y="data-vue-ssr-id",b="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());e.exports=function(e,t,r,n){h=r,v=n||{};var s=c(e,t);return o(s),function(t){for(var r=[],n=0;n<s.length;n++){var i=s[n],a=p[i.id];a.refs--,r.push(a)}t?(s=c(e,t),o(s)):s=[];for(var n=0;n<r.length;n++){var a=r[n];if(0===a.refs){for(var l=0;l<a.parts.length;l++)a.parts[l]();delete p[a.id]}}}};var m=function(){var e=[];return function(t,r){return e[t]=r,e.filter(Boolean).join("\n")}}()},function(e,t){e.exports=function(e,t){for(var r=[],o={},n=0;n<t.length;n++){var s=t[n],i=s[0],a=s[1],l=s[2],c=s[3],p={id:e+":"+n,css:a,media:l,sourceMap:c};o[i]?o[i].parts.push(p):r.push(o[i]={id:i,parts:[p]})}return r}},function(e,t){e.exports=function(e,t,r,o,n,s){var i,a=e=e||{},l=typeof e.default;"object"!==l&&"function"!==l||(i=e,a=e.default);var c="function"==typeof a?a.options:a;t&&(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0),r&&(c.functional=!0),n&&(c._scopeId=n);var p;if(s?(p=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},c._ssrRegister=p):o&&(p=o),p){var u=c.functional,d=u?c.render:c.beforeCreate;u?(c._injectStyles=p,c.render=function(e,t){return p.call(t),d(e,t)}):c.beforeCreate=d?[].concat(d,p):[p]}return{esModule:i,exports:a,options:c}}},function(e,t,r){"use strict";var o=r(12),n=r(13),s=r(2);e.exports={formats:s,parse:n,stringify:o}},function(e,t,r){"use strict";var o=r(1),n=r(2),s={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},i=Date.prototype.toISOString,a={delimiter:"&",encode:!0,encoder:o.encode,encodeValuesOnly:!1,serializeDate:function(e){return i.call(e)},skipNulls:!1,strictNullHandling:!1},l=function e(t,r,n,s,i,l,c,p,u,d,f,h){var g=t;if("function"==typeof c)g=c(r,g);else if(g instanceof Date)g=d(g);else if(null===g){if(s)return l&&!h?l(r,a.encoder):r;g=""}if("string"==typeof g||"number"==typeof g||"boolean"==typeof g||o.isBuffer(g)){if(l){return[f(h?r:l(r,a.encoder))+"="+f(l(g,a.encoder))]}return[f(r)+"="+f(String(g))]}var v=[];if(void 0===g)return v;var y;if(Array.isArray(c))y=c;else{var b=Object.keys(g);y=p?b.sort(p):b}for(var m=0;m<y.length;++m){var _=y[m];i&&null===g[_]||(v=Array.isArray(g)?v.concat(e(g[_],n(r,_),n,s,i,l,c,p,u,d,f,h)):v.concat(e(g[_],r+(u?"."+_:"["+_+"]"),n,s,i,l,c,p,u,d,f,h)))}return v};e.exports=function(e,t){var r=e,i=t?o.assign({},t):{};if(null!==i.encoder&&void 0!==i.encoder&&"function"!=typeof i.encoder)throw new TypeError("Encoder has to be a function.");var c=void 0===i.delimiter?a.delimiter:i.delimiter,p="boolean"==typeof i.strictNullHandling?i.strictNullHandling:a.strictNullHandling,u="boolean"==typeof i.skipNulls?i.skipNulls:a.skipNulls,d="boolean"==typeof i.encode?i.encode:a.encode,f="function"==typeof i.encoder?i.encoder:a.encoder,h="function"==typeof i.sort?i.sort:null,g=void 0!==i.allowDots&&i.allowDots,v="function"==typeof i.serializeDate?i.serializeDate:a.serializeDate,y="boolean"==typeof i.encodeValuesOnly?i.encodeValuesOnly:a.encodeValuesOnly;if(void 0===i.format)i.format=n.default;else if(!Object.prototype.hasOwnProperty.call(n.formatters,i.format))throw new TypeError("Unknown format option provided.");var b,m,_=n.formatters[i.format];"function"==typeof i.filter?(m=i.filter,r=m("",r)):Array.isArray(i.filter)&&(m=i.filter,b=m);var x=[];if("object"!=typeof r||null===r)return"";var w;w=i.arrayFormat in s?i.arrayFormat:"indices"in i?i.indices?"indices":"repeat":"indices";var j=s[w];b||(b=Object.keys(r)),h&&b.sort(h);for(var O=0;O<b.length;++O){var S=b[O];u&&null===r[S]||(x=x.concat(l(r[S],S,j,p,u,d?f:null,m,h,g,v,_,y)))}var k=x.join(c),C=!0===i.addQueryPrefix?"?":"";return k.length>0?C+k:""}},function(e,t,r){"use strict";var o=r(1),n=Object.prototype.hasOwnProperty,s={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:o.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},i=function(e,t){for(var r={},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),l=0;l<a.length;++l){var c,p,u=a[l],d=u.indexOf("]="),f=-1===d?u.indexOf("="):d+1;-1===f?(c=t.decoder(u,s.decoder),p=t.strictNullHandling?null:""):(c=t.decoder(u.slice(0,f),s.decoder),p=t.decoder(u.slice(f+1),s.decoder)),n.call(r,c)?r[c]=[].concat(r[c]).concat(p):r[c]=p}return r},a=function(e,t,r){for(var o=t,n=e.length-1;n>=0;--n){var s,i=e[n];if("[]"===i)s=[],s=s.concat(o);else{s=r.plainObjects?Object.create(null):{};var a="["===i.charAt(0)&&"]"===i.charAt(i.length-1)?i.slice(1,-1):i,l=parseInt(a,10);!isNaN(l)&&i!==a&&String(l)===a&&l>=0&&r.parseArrays&&l<=r.arrayLimit?(s=[],s[l]=o):s[a]=o}o=s}return o},l=function(e,t,r){if(e){var o=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,s=/(\[[^[\]]*])/,i=/(\[[^[\]]*])/g,l=s.exec(o),c=l?o.slice(0,l.index):o,p=[];if(c){if(!r.plainObjects&&n.call(Object.prototype,c)&&!r.allowPrototypes)return;p.push(c)}for(var u=0;null!==(l=i.exec(o))&&u<r.depth;){if(u+=1,!r.plainObjects&&n.call(Object.prototype,l[1].slice(1,-1))&&!r.allowPrototypes)return;p.push(l[1])}return l&&p.push("["+o.slice(l.index)+"]"),a(p,t,r)}};e.exports=function(e,t){var r=t?o.assign({},t):{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.ignoreQueryPrefix=!0===r.ignoreQueryPrefix,r.delimiter="string"==typeof r.delimiter||o.isRegExp(r.delimiter)?r.delimiter:s.delimiter,r.depth="number"==typeof r.depth?r.depth:s.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:s.arrayLimit,r.parseArrays=!1!==r.parseArrays,r.decoder="function"==typeof r.decoder?r.decoder:s.decoder,r.allowDots="boolean"==typeof r.allowDots?r.allowDots:s.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:s.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:s.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:s.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:s.strictNullHandling,""===e||null===e||void 0===e)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof e?i(e,r):e,a=r.plainObjects?Object.create(null):{},c=Object.keys(n),p=0;p<c.length;++p){var u=c[p],d=l(u,n[u],r);a=o.merge(a,d,r)}return o.compact(a)}},function(e,t,r){"use strict";var o=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"select-shop",on:{click:e.hideTree}},[r("el-select",{staticClass:"select-shop__left",attrs:{placeholder:"请选择",disabled:e.disabled},on:{change:e.selectShop},model:{value:e.storeType,callback:function(t){e.storeType=t},expression:"storeType"}},e._l(e.options,function(e){return r("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),e._v(" "),r("el-popover",{directives:[{name:"show",rawName:"v-show",value:"1"==e.storeType,expression:"storeType=='1'"}],attrs:{"popper-class":"select-shop__popover",placement:"top-start",trigger:"click"},model:{value:e.showShopTree,callback:function(t){e.showShopTree=t},expression:"showShopTree"}},[r("div",{staticClass:"el-input__inner select-shop__right",attrs:{slot:"reference"},on:{click:function(t){return t.preventDefault(),t.stopPropagation(),e.toggleShopTree(t)}},slot:"reference"},[e._v(e._s(e.shopGroupValue))]),e._v(" "),r("div",{staticClass:"select-shop__tree"},[r("el-tree",{ref:"shopGroupTree",attrs:{data:e.dataObj,"show-checkbox":"","default-expand-all":"","default-checked-keys":e.checkedKeys,"node-key":"storeGroupId","highlight-current":"",props:e.defaultProps}})],1),e._v(" "),r("div",{staticClass:"select-shop__btn--wrap"},[r("el-button",{staticStyle:{color:"#303133"},attrs:{type:"text",size:"small"},on:{click:function(t){return t.preventDefault(),t.stopPropagation(),e.hideTree(t)}}},[e._v("取消")]),e._v(" "),r("el-button",{attrs:{type:"text",size:"small"},on:{click:function(t){return t.preventDefault(),t.stopPropagation(),e.groupBtnSure(t)}}},[e._v("确定")])],1)]),e._v(" "),r("div",{directives:[{name:"show",rawName:"v-show",value:"2"==e.storeType,expression:"storeType=='2'"}],staticClass:"select-shop__right"},[r("div",{staticClass:"el-input__inner select-shop__tag--input",on:{click:function(t){return t.preventDefault(),t.stopPropagation(),e.toggleSearchShop(t)}}},[e._l(e.storeIds,function(t,o){return r("span",{key:o,staticClass:"select-shop__tag"},[e._v(e._s(t.storeName)),r("i",{staticClass:"dele-icon el-icon-error",on:{click:function(t){t.preventDefault(),t.stopPropagation(),e.removeData(o)}}})])}),e._v(" "),e.storeIds.length?e._e():r("span",{staticClass:"select-shop__tag--tips"},[e._v("请选择门店")])],2),e._v(" "),r("el-popover",{attrs:{placement:"top-start","popper-class":"select-shop__popper",width:"300",trigger:"hover"}},[e._l(e.storeIds,function(t,o){return r("el-tag",{key:t.storeId,staticClass:"select-shop__popper--tag",attrs:{closable:""},on:{close:function(t){e.removeData(o)}}},[e._v("\n\t\t\t\t\t"+e._s(t.storeName)+"\n\t\t\t\t")])}),e._v(" "),r("span",{directives:[{name:"show",rawName:"v-show",value:e.storeIds.length>1,expression:"storeIds.length>1"}],staticClass:"select-shop__right--total",attrs:{slot:"reference"},slot:"reference"},[e._v("共"+e._s(e.storeIds.length)+"项")])],2),e._v(" "),r("transition",{attrs:{name:"slide-fade"}},[r("div",{directives:[{name:"show",rawName:"v-show",value:e.showSearchList,expression:"showSearchList"}],staticClass:"select-shop__search",on:{mouseover:function(t){e.showSearchList=!0},mouseout:function(t){e.showSearchList=!1}}},[r("div",{staticClass:"select-shop__search--input",on:{click:function(e){e.stopPropagation()}}},[r("el-input",{staticClass:"input-name",attrs:{"prefix-icon":"el-icon-search",size:"small",clearable:"",placeholder:"输入搜索内容"},nativeOn:{keydown:function(t){if(!("button"in t)&&e._k(t.keyCode,"enter",13,t.key,"Enter"))return null;e.getSearchData()},keyup:function(t){e.getSearchData()}},model:{value:e.searchValue,callback:function(t){e.searchValue=t},expression:"searchValue"}})],1),e._v(" "),r("div",{staticClass:"select-shop__search--list"},[e.selectList.length>0?r("ul",e._l(e.selectList,function(t,o){return r("li",{key:o,on:{click:function(r){r.preventDefault(),r.stopPropagation(),e.selectShopSuccess(t,o)}}},[r("span",[e._v(e._s(t.storeName))])])})):r("p",{staticClass:"no-data"},[e._v("无搜索内容")]),e._v(" "),r("p",{staticClass:"select-shop__search--tip"},[e._v("最多显示5条数据")])])])])],1)],1)},n=[],s={render:o,staticRenderFns:n};t.a=s}])});
//# sourceMappingURL=build.js.map
\ No newline at end of file
{"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-linkage",
"_id": "@gic-test/vue-gic-store-linkage@1.0.6",
"_inBundle": false,
"_integrity": "sha1-thiyJQQFMXVnC87YfqkPSCK7XzU=",
"_location": "/@gic-test/vue-gic-store-linkage",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "@gic-test/vue-gic-store-linkage",
"name": "@gic-test/vue-gic-store-linkage",
"escapedName": "@gic-test%2fvue-gic-store-linkage",
"scope": "@gic-test",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "http://www.gicdev.com:7001/@gic-test/vue-gic-store-linkage/download/@gic-test/vue-gic-store-linkage-1.0.6.tgz",
"_shasum": "b618b22504053175670bced87ea90f4822bb5f35",
"_spec": "@gic-test/vue-gic-store-linkage",
"_where": "C:\\Users\\Administrator\\Desktop\\private",
"bundleDependencies": false,
"dependencies": {
"axios": "^0.18.0",
"vue": "^2.5.11"
},
"deprecated": false,
"description": "vue-gic-store-linkage 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-linkage",
"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.6"
}
<template>
<div style="padding:20px;">
<vue-gic-store-linkage :model="storeGroupData" @commit-store="getStoreGroup" width="200"></vue-gic-store-linkage>
</div>
</template>
<script>
import vueGicStoreLinkage from './lib/component.vue'
export default {
name: 'app',
data () {
return {
storeGroupData:{"storeGroupId":"ff80808164c7266b0164cb9ee1550039","parentGroupId":"ff808081593917d90159398eca480016","groupLevel":2,"children":[],"storeGroupName":"给对方","label":"给对方","id":"ff80808164c7266b0164cb9ee1550039"}
}
},
components: {
vueGicStoreLinkage
},
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="select-shop" @click="hideTree" >
<el-select v-model="storeType" @change="selectShop" placeholder="请选择" class="select-shop__left" :disabled="disabled">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-popover v-model="showShopTree" v-show="storeType=='1'" popper-class ="select-shop__popover" placement="top-start" trigger="click">
<div class="el-input__inner select-shop__right" slot="reference" @click.prevent.stop="toggleShopTree">{{shopGroupValue}}</div>
<div class="select-shop__tree">
<el-tree
ref="shopGroupTree"
:data="dataObj"
show-checkbox
default-expand-all
:default-checked-keys="checkedKeys"
node-key="storeGroupId"
highlight-current
:props="defaultProps">
</el-tree>
</div>
<div class="select-shop__btn--wrap">
<el-button @click.prevent.stop="hideTree" type="text" size="small" style="color:#303133">取消</el-button>
<el-button @click.prevent.stop="groupBtnSure" type="text" size="small">确定</el-button>
</div>
</el-popover>
<div v-show="storeType=='2'" class="select-shop__right">
<div class="el-input__inner select-shop__tag--input" @click.prevent.stop="toggleSearchShop">
<span v-for="(item,index) in storeIds" :key="index" class="select-shop__tag">{{item.storeName}}<i @click.prevent.stop="removeData(index)" class="dele-icon el-icon-error"></i></span>
<span class="select-shop__tag--tips" v-if="!storeIds.length">请选择门店</span>
</div>
<el-popover placement="top-start" popper-class="select-shop__popper" width="300" trigger="hover">
<el-tag class="select-shop__popper--tag" v-for="(tag,index) in storeIds" :key="tag.storeId" @close="removeData(index)" closable>
{{tag.storeName}}
</el-tag>
<span slot="reference" class="select-shop__right--total" v-show="storeIds.length>1">{{storeIds.length}}</span>
</el-popover>
<transition name="slide-fade">
<div class="select-shop__search" @mouseover="showSearchList = true" @mouseout="showSearchList = false" v-show="showSearchList" >
<div class="select-shop__search--input" @click.stop="">
<el-input @keydown.enter.native="getSearchData()" @keyup.native="getSearchData()" class="input-name" prefix-icon="el-icon-search" size="small" clearable v-model="searchValue" placeholder="输入搜索内容" ></el-input>
</div>
<div class="select-shop__search--list">
<ul v-if="selectList.length>0">
<li @click.prevent.stop="selectShopSuccess(item,index)" v-for="(item,index) in selectList" :key="index"><span>{{item.storeName}}</span></li>
</ul>
<p v-else class="no-data">无搜索内容</p>
<p class="select-shop__search--tip">最多显示5条数据</p>
</div>
</div>
</transition>
</div>
</div>
</template>
<script>
import qs from 'qs';
export default {
name: "vue-gic-store-linkage",
props:{
msg:{
type:Object
},
disabled:{
type:Boolean,
default:false
}
},
data(){
return {
options: [{value: '0',label: '所有门店'}, {value: '1',label: '门店分组'}, {value: '2',label: '部分门店'}],
defaultProps: {children: 'children',label: 'storeGroupName'},
dataObj:[],
showShopTree: false, // 显示门店的树级结构
showSearchList:false, // 显示部分门店的搜索结果
searchValue:'', // 部分门店的下拉框的搜索值
selecData:[],
selectListId:[], // 选中的门店的id
storeList:[], // 店员管理 -- 企业部门 -- 编辑企业成员
shopGroupValue:'已选择0个门店分组',
selectList:[],
storeIds:[],
checkedKeys:[], // 默认选中的门店分组
groupIds:'',
storeType: '0',
}
},
watch:{
msg(oldVal,newVal){
this.init(oldVal)
}
},
created(){
this.init(this.msg)
},
mounted(){
this.getGroupTreeData(); // 获得门店分组的数据
},
methods:{
init(dataObj){ // 初始化
if(dataObj.storeList){
if(dataObj && dataObj.storeList.length>0){ // 店员管理 -- 企业部门 -- 编辑企业成员
this.selecData = dataObj.storeList || []
}
}
if(dataObj.storeType){
this.storeType = dataObj.storeType.toString();
if(this.storeType == '1'){
this.groupIds = dataObj.storeGroupIds;
this.shopGroupValue = '已选择'+(dataObj.storeGroupIds.split(',').length)+'个门店分组';
this.checkedKeys = dataObj.storeGroupIds.split(',').filter(v => !!v);
} else if (this.storeType == '2') {
this.storeIds = Object.assign([],dataObj.storeIds)
}
this.getGroupTreeData();
}
},
getGroupTreeData(){
this.axios.get('/api-admin/store-group-list',{
params: {
requestProject:'gic-web'
}
}).then((res)=>{
var data = res.data;
if(data.errorCode==0){
this.dataObj = data.result;
}
})
},
getSearchData(){ // 部分门店的查询
this.axios.post('/api-plug/query-store-by-code-name',qs.stringify({
requestProject:'gic-web',
searchParam:this.searchValue,
selectedIds:this.selectListId.join(','),
flag:'1'
})).then((res)=>{
var data = res.data;
if(data.errorCode==0){
this.selectList = data.result;
}
})
},
selectShop(){ // 选择门店
this.emitObj();
},
toggleShopTree(){
if (this.disabled) return;
// 门店分组的树结构 1
this.showShopTree = !this.showShopTree
},
groupBtnSure(){ // 选择门店分组的确定按钮
this.showShopTree = false;
if (this.disabled) return;
var storeGroupList = this.$refs.shopGroupTree.getCheckedKeys();
var len = storeGroupList.length;
this.groupIds = storeGroupList.join(',');
this.shopGroupValue = '已选择'+len+'个门店分组';
this.emitObj();
},
toggleSearchShop(){ // 部分门店的树结构 -- 自定义 2
this.showSearchList = !this.showSearchList
},
showSearchTree(){ // 部分门店的搜索
this.showSearchList = true;
},
hideSearch(){ // 隐藏搜索结果框
this.showSearchList = false;
},
hideTree(){
this.showShopTree=false; // 门店分组
this.showSearchList = false; // 部分门店
},
selectShopSuccess(item,index){ // 成功选择部分门店
if (this.storeIds.map(v => v.storeId).indexOf(item.storeId) > -1 ) return;
this.storeIds.push(item);
this.emitObj();
},
removeData(index){ // 移出部分门店
if (this.disabled) return;
this.storeIds.splice(index,1);
this.emitObj();
},
emitObj() {
let obj = {
storeGroupIds:this.groupIds,
storeIds:this.storeIds,
storeType:parseInt(this.storeType)
}
this.$emit('sendSelectGroupData',obj);
}
}
}
</script>
<style lang="scss">
@import './style.scss';
</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
.select-shop {
position: relative;
&__left {
width: 200px;
margin-right: 7px;
position: relative;
display: inline-block;
vertical-align: top;
}
&__popover {
width: 200px;
padding: 10px 0 0 0;
}
&__right {
width: 200px;
display: inline-block;
vertical-align: top;
font-size: 14px;
position: relative;
&--total {
position: absolute;
right: 1px;
top: 5px;
height: 30px;
line-height: 30px;
border-radius: 3px;
background: #fff;
opacity: 0.9;
padding: 0 5px;
font-size: 12px;
cursor: pointer;
}
}
&__tree {
padding: 0;
overflow-y: auto;
height: 260px;
box-sizing: border-box;
position: relative;
&::-webkit-scrollbar {
width: 0;
height: 0;
}
.el-tree-node__label {
text-overflow: ellipsis;
display: inline-block;
white-space: nowrap;
width: 100%;
overflow: hidden;
}
}
&__btn--wrap {
padding: 0px 15px;
border-top: 1px solid #ebeef5;
height: 36px;
line-height: 34px;
text-align: right;
}
&__tag--input {
padding: 0 4px;
line-height: 36px;
overflow: hidden;
white-space: nowrap;
}
&__tag--tips {
padding-left: 8px;
line-height: 36px;
}
&__search {
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
&--input {
padding: 10px 10px 0 10px;
}
&--list {
.no-data {
height: 34px;
line-height: 34px;
text-align: center;
color: #606266;
}
ul {
padding: 0 10px;
li {
font-size: 14px;
position: relative;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #606266;
height: 34px;
line-height: 34px;
box-sizing: border-box;
cursor: pointer;
&:hover {
background-color: #f5f7fa;
}
&.on {
color: #409eff;
background-color: #fff;
font-weight: 700;
&:after {
position: absolute;
right: 20px;
font-family: element-icons;
content: "\E611";
font-size: 12px;
font-weight: 700;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
}
}
}
}
&--tip {
font-size: 12px;
background-color: #f6f8f9;
height: 30px;
line-height: 30px;
padding-left: 10px;
color: #606266;
box-sizing: border-box;
}
}
&__tag {
box-sizing: border-box;
border-color: transparent;
margin: 2px 0 2px 6px;
background-color: #f0f2f5;
height: 24px;
padding: 2px 8px;
line-height: 22px;
color: #909399;
border-radius: 4px;
font-size: 12px;
display: inline-block;
.dele-icon {
padding-left: 5px;
cursor: pointer;
}
}
&__popper {
&--tag {
margin: 4px;
}
}
}
\ 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-linkage',
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