Skip to content

Commit

Permalink
Merge pull request #15 from ZhonganTechENG/dev-1.1.0-beta
Browse files Browse the repository at this point in the history
Dev 1.1.0 beta
  • Loading branch information
chuanshuoye authored Apr 4, 2018
2 parents 6fdaabe + 78e0aa4 commit f54a414
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 26 deletions.
17 changes: 14 additions & 3 deletions build/webpack.umd.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,20 @@ module.exports = merge(baseWebpackConfig, {
entry: {
['zarm-vue.umd.js']: path.join(__dirname, '../src/index.js'),
},
externals: [
'vue',
],
externals: {
'vue': {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
},
'lodash': {
commonjs: 'lodash',
commonjs2: 'lodash',
amd: 'lodash',
root: '_'
}
},
output: {
path: path.resolve(__dirname, '../release'),
filename: '[name]',
Expand Down
4 changes: 2 additions & 2 deletions example/components/accordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<za-panel>
<za-panel-header title="手风琴模式" />
<za-panel-body>
<zaAccordion :multiple='false' animated>
<zaAccordion animated :multiple='true' >
<zaAccordionItem title="50元套餐" aiTag='0'>
<div>我是50元套餐内容</div>
<div>我是50元套餐内容</div>
Expand Down Expand Up @@ -111,7 +111,7 @@
<za-panel-header title="强制展开模式" />
<za-panel-body>
<zaAccordion open>
<zaAccordionItem title="50元套餐" open>
<zaAccordionItem title="50元套餐">
<div>我是50元套餐内容</div>
<div>我是50元套餐内容</div>
<div>我是50元套餐内容</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zarm-vue",
"version": "1.1.1",
"version": "1.1.2",
"description": "zarm in vue",
"author": "zhanwangye <[email protected]>",
"tags": [
Expand Down
23 changes: 16 additions & 7 deletions src/accordion/src/accordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@
<script>
export default {
name: 'zaAccordion',
components: {
// zaPopup
},
props: {
prefixCls: {
type: String,
default: 'za-accordion',
},
activeTag: {
type: Array,
default: () => [],
},
defaultActiveTag: {
type: Array,
default: () => [],
Expand All @@ -36,9 +29,25 @@ export default {
default: false,
},
},
data() {
return {
activeTag: [],
};
},
methods: {
onchange(index) {
const { multiple } = this;
this.$emit('change', index);
if (multiple) {
const accordionItemRefs = this.$children;
const aiTags = [];
accordionItemRefs.forEach(item => {
if (item.$options.name === 'zaAccordionItem') {
aiTags.push(item.aiTag);
}
});
this.activeTag = aiTags.filter(i => i === index);
}
},
},
};
Expand Down
47 changes: 34 additions & 13 deletions src/accordion/src/accordionItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,27 +154,48 @@ export default {
setActive() {
const self = this;
let activeStatus = false;
const activeTag = this.activeTag;
activeTag.some((child) => {
if (child.toString() === self.itemActiveTag.toString()) {
const { itemActiveTag, activeTag, itemAnimated } = this;
const multiple = this.$parent.multiple;
if (multiple) {
if (activeTag.indexOf(itemActiveTag) > -1) {
activeStatus = true;
return true;
} else {
activeStatus = false;
}
return false;
});
if (itemAnimated) {
this.setStyle(!activeStatus);
}
} else {
activeTag.some((child) => {
if (child.toString() === self.itemActiveTag.toString()) {
activeStatus = true;
return true;
}
return false;
});
}
self.active = activeStatus;
},
onClickItem() {
const itemAnimated = this.itemAnimated;
const open = this.open;
const active = this.active;
const { itemAnimated, open, active, activeTag, itemActiveTag } = this;
let activeStatus = false;
const multiple = this.$parent.multiple;
if (open) {
return;
}
this.active = !active;
if (itemAnimated) {
this.setStyle(active);
if (multiple) {
if (activeTag.indexOf(itemActiveTag) > -1) {
activeStatus = true;
} else {
activeStatus = false;
}
this.active = activeStatus;
} else {
this.active = !active;
if (itemAnimated) {
this.setStyle(active);
}
}
this.itemChange();
},
Expand Down

0 comments on commit f54a414

Please sign in to comment.