Skip to content

Commit

Permalink
修复名单导入不能叠加问题
Browse files Browse the repository at this point in the history
  • Loading branch information
vito committed Dec 27, 2019
1 parent a8e64a6 commit c78ed69
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 134 deletions.
38 changes: 26 additions & 12 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,24 @@
<span
class="key"
:style="{
fontSize: list[item] && list[item].name ? '36px' : null,
lineHeight: list[item] && list[item].name ? '80px' : null
fontSize: list[item - 1] && list[item - 1].name ? '36px' : null,
lineHeight:
list[item - 1] && list[item - 1].name ? '80px' : null
}"
v-if="list[item] && list[item].name"
v-if="list[item - 1] && list[item - 1].name"
>
{{ item }}
</span>
<span
class="cont"
:style="{
fontSize: list[item] && list[item].name ? '36px' : null,
lineHeight: list[item] && list[item].name ? '80px' : null
fontSize: list[item - 1] && list[item - 1].name ? '36px' : null,
lineHeight:
list[item - 1] && list[item - 1].name ? '80px' : null
}"
>
<span v-if="list[item] && list[item].name">
{{ list[item].name }}
<span v-if="list[item - 1] && list[item - 1].name">
{{ list[item - 1].name }}
</span>
<span v-else>
{{ item }}
Expand All @@ -66,7 +68,12 @@
</transition>

<LotteryConfig :visible.sync="showConfig" @resetconfig="reloadTagCanvas" />
<Tool @toggle="toggle" @resetConfig="reloadTagCanvas" :running="running" />
<Tool
@toggle="toggle"
@resetConfig="reloadTagCanvas"
:running="running"
:closeRes="closeRes"
/>
<Result :visible.sync="showResult"></Result>

<span class="copy-right">
Expand Down Expand Up @@ -134,10 +141,10 @@ export default {
},
datas() {
const datas = [];
for (let index = 0; index < this.config.number; index++) {
for (let index = 1; index <= this.config.number; index++) {
const listData = this.list.find(d => d.key === index);
datas.push({
key: index + 1,
key: index,
name: listData ? listData.name : ''
});
}
Expand Down Expand Up @@ -214,16 +221,23 @@ export default {
reloadTagCanvas() {
window.TagCanvas.Reload('rootcanvas');
},
closeRes() {
this.showRes = false;
},
toggle(form) {
const { speed, config } = this;
if (this.running) {
window.TagCanvas.SetSpeed('rootcanvas', speed());
this.showRes = true;
this.running = !this.running;
this.$nextTick(() => {
this.reloadTagCanvas();
});
} else {
this.showRes = false;
if (!form) {
return;
}
const { number } = config;
const { category, mode, qty, remain, allin } = form;
let num = 1;
Expand Down Expand Up @@ -251,8 +265,8 @@ export default {
});
this.result = data;
window.TagCanvas.SetSpeed('rootcanvas', [5, 1]);
this.running = !this.running;
}
this.running = !this.running;
}
}
};
Expand Down Expand Up @@ -298,7 +312,7 @@ export default {
animation: bounce-in 1.5s;
}
.bounce-leave-active {
animation: bounce-in 0.2s reverse;
animation: bounce-in 0s reverse;
}
}
#main {
Expand Down
12 changes: 6 additions & 6 deletions src/components/Tool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ import { clearData, conversionCategoryName } from '@/helper/index';
export default {
props: {
running: Boolean
running: Boolean,
closeRes: Function
},
computed: {
config: {
Expand Down Expand Up @@ -165,7 +166,7 @@ export default {
.then(() => {
clearData();
this.$store.commit('setClearStore');
this.closeRes && this.closeRes();
this.$message({
type: 'success',
message: '重置成功!'
Expand Down Expand Up @@ -209,9 +210,8 @@ export default {
);
},
startHandler() {
if (this.running) {
this.$emit('toggle');
} else {
this.$emit('toggle');
if (!this.running) {
this.showSetwat = true;
}
},
Expand All @@ -224,7 +224,7 @@ export default {
const rows = listStr.split('\n');
if (rows && rows.length > 0) {
rows.forEach(item => {
const rowList = item.split('\t');
const rowList = item.split(/\t|\s/);
if (rowList.length >= 2) {
const key = Number(rowList[0].trim());
const name = rowList[1].trim();
Expand Down
6 changes: 3 additions & 3 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export default new Vuex.Store({
setList(state, list) {
const arr = state.list;
list.forEach(item => {
const arrItem = arr.find(data => data.key === item.key);
if (arrItem) {
arrItem.name === item.name;
const arrIndex = arr.findIndex(data => data.key === item.key);
if (arrIndex > -1) {
arr[arrIndex].name = item.name;
} else {
arr.push(item);
}
Expand Down
Loading

0 comments on commit c78ed69

Please sign in to comment.