Skip to content

Commit 6ff0afb

Browse files
committed
优化
1 parent 5eb2791 commit 6ff0afb

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

src/components/widget-form-list.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,11 @@ export default {
133133
handleWidgetAdd(evt) {
134134
const newIndex = evt.newIndex;
135135
136-
//为拖拽到容器的元素添加唯一 key
137-
const key = Date.parse(new Date()) + '_' + Math.ceil(Math.random() * 99999)
136+
const elKey = Date.now() + '_' + Math.ceil(Math.random() * 1000000);
138137
let newObj = this.$util.deepClone(this.pageData[this.list][newIndex]);
139-
// 绑定键值
140-
newObj.key = this.pageData[this.list][newIndex].type + '_' + key;
141-
this.$set(this.pageData[this.list], newIndex, newObj)
138+
139+
newObj.key = this.pageData[this.list][newIndex].type + '_' + elKey;
140+
this.$set(this.pageData[this.list], newIndex, newObj);
142141
this.$store.commit('setSelectWg', this.pageData[this.list][newIndex]);
143142
this.$store.commit('setConfigTab', "widget");
144143
},
@@ -162,7 +161,7 @@ export default {
162161
},
163162
handleWidgetClone(index) {
164163
let cloneData = this.$util.deepClone(this.pageData[this.list][index]);
165-
cloneData.key = this.pageData[this.list][index].type + '_' + Date.parse(new Date()) + '_' + Math.ceil(Math.random() * 99999)
164+
cloneData.key = this.pageData[this.list][index].type + '_' + Date.now() + '_' + Math.ceil(Math.random() * 1000000)
166165
this.pageData[this.list].splice(index, 0, cloneData)
167166
this.$nextTick(() => {
168167
this.$store.commit('setSelectWg', this.pageData[this.list][index + 1])

src/store/modules/common.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// import api from "../../assets/js/api.js"
2-
31
const state = {
42
pageData: {
53
list: [],
@@ -11,16 +9,12 @@ const state = {
119
selectTheme: ""
1210
}
1311

14-
const actions = {
15-
// getBusinessTypeList({commit}) {
16-
// api.vkcPost2("supermarketloan/crm/qualitycontrol/findAllBusinessTypes", "", res => {
17-
// commit(types.BUSINESS_TYPE_LIST, res);
18-
// });
19-
// }
20-
}
12+
// const actions = {
13+
14+
// }
2115

2216
// const getters = {
23-
// businessTypeList: state => state.businessTypeList
17+
// selectTheme: state => state.selectTheme
2418
// }
2519

2620
const mutations = {
@@ -40,6 +34,5 @@ const mutations = {
4034

4135
export default {
4236
state,
43-
actions,
4437
mutations
4538
}

0 commit comments

Comments
 (0)