优化选卡界面渲染
This commit is contained in:
parent
97cc55fc91
commit
54e38e32bb
@ -132,7 +132,6 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.renderType = "normal";
|
this.renderType = "normal";
|
||||||
}
|
}
|
||||||
console.log(6);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -1131,8 +1131,6 @@ export default {
|
|||||||
scrollData = [].concat(table3, table1, table2);
|
scrollData = [].concat(table3, table1, table2);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(5);
|
|
||||||
|
|
||||||
return scrollData;
|
return scrollData;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1141,7 +1139,6 @@ export default {
|
|||||||
this.showSlotHeader = this.$slots.header !== undefined;
|
this.showSlotHeader = this.$slots.header !== undefined;
|
||||||
this.showSlotFooter = this.$slots.footer !== undefined;
|
this.showSlotFooter = this.$slots.footer !== undefined;
|
||||||
this.rebuildData = this.makeDataWithSortAndFilter();
|
this.rebuildData = this.makeDataWithSortAndFilter();
|
||||||
console.log(2);
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.handleResize();
|
this.handleResize();
|
||||||
@ -1156,7 +1153,6 @@ export default {
|
|||||||
this.handleResize();
|
this.handleResize();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(3);
|
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
off(window, "resize", this.handleResize);
|
off(window, "resize", this.handleResize);
|
||||||
@ -1176,7 +1172,6 @@ export default {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.cloneData = deepCopy(this.data);
|
this.cloneData = deepCopy(this.data);
|
||||||
}, 0);
|
}, 0);
|
||||||
console.log(1);
|
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
},
|
},
|
||||||
@ -1192,7 +1187,6 @@ export default {
|
|||||||
this.rightFixedColumnRows = this.makeColumnRows("right", colsWithId);
|
this.rightFixedColumnRows = this.makeColumnRows("right", colsWithId);
|
||||||
this.rebuildData = this.makeDataWithSortAndFilter();
|
this.rebuildData = this.makeDataWithSortAndFilter();
|
||||||
this.handleResize();
|
this.handleResize();
|
||||||
console.log(4);
|
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
},
|
},
|
||||||
|
@ -14,6 +14,8 @@ const state = {
|
|||||||
cards: [], // RD订单卡列表
|
cards: [], // RD订单卡列表
|
||||||
relations: [],
|
relations: [],
|
||||||
selected: [],
|
selected: [],
|
||||||
|
counts: 0, // 选择的卡数量
|
||||||
|
selectedMapped: [], // 选择的卡索引
|
||||||
orderParams: {},
|
orderParams: {},
|
||||||
cardParams: {},
|
cardParams: {},
|
||||||
real_companies: [],
|
real_companies: [],
|
||||||
@ -32,28 +34,10 @@ const getters = {
|
|||||||
relationObj: state => state.relationObj,
|
relationObj: state => state.relationObj,
|
||||||
orders: state => state.real_orders,
|
orders: state => state.real_orders,
|
||||||
cards: state => state.cards,
|
cards: state => state.cards,
|
||||||
order_group: (state) => {
|
selected: state => state.selected,
|
||||||
let order_group = {};
|
selectedMapped: state => state.selectedMapped,
|
||||||
|
counts: state => state.counts,
|
||||||
for (const index in state.order_group) {
|
order_group: state => state.order_group,
|
||||||
if (state.order_group.hasOwnProperty(index)) {
|
|
||||||
const element = state.order_group[index];
|
|
||||||
|
|
||||||
order_group[index] = element.map(el => {
|
|
||||||
return state.cards.find(e => {
|
|
||||||
return e._rowIndex === el;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return order_group;
|
|
||||||
},
|
|
||||||
selected: (state) => {
|
|
||||||
return state.selected.map(el => {
|
|
||||||
return state.cards.find(e => { return e._rowIndex === el; });
|
|
||||||
});
|
|
||||||
},
|
|
||||||
total: (state) => {
|
total: (state) => {
|
||||||
if (!state.cards.length) {
|
if (!state.cards.length) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -63,24 +47,15 @@ const getters = {
|
|||||||
return acc + cur.counts;
|
return acc + cur.counts;
|
||||||
}, 0);
|
}, 0);
|
||||||
},
|
},
|
||||||
counts: (state, getters) => {
|
|
||||||
if (!getters.selected.length) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return getters.selected.reduce((acc, cur) => {
|
|
||||||
return acc + cur.counts;
|
|
||||||
}, 0);
|
|
||||||
},
|
|
||||||
getFilterUsedCards: () => (cards) => {
|
getFilterUsedCards: () => (cards) => {
|
||||||
return cards.filter(item => item.virtual_order_id === 0);
|
return cards.filter(item => item.virtual_order_id === 0);
|
||||||
},
|
},
|
||||||
getSelectedByOrderId: (state, getters) => (order_id) => {
|
getSelectedByOrderId: (state) => (order_id) => {
|
||||||
if (typeof order_id !== 'object') {
|
if (typeof order_id !== 'object') {
|
||||||
order_id = [order_id];
|
order_id = [order_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
return getters.selected.filter(item => {
|
return state.selected.filter(item => {
|
||||||
return order_id.includes(item.order_id);
|
return order_id.includes(item.order_id);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -128,6 +103,12 @@ const mutations = {
|
|||||||
},
|
},
|
||||||
SET_SELECTED(state, data) {
|
SET_SELECTED(state, data) {
|
||||||
state.selected = data;
|
state.selected = data;
|
||||||
|
},
|
||||||
|
SET_SELECTED_COUNTS(state, value) {
|
||||||
|
state.counts = value;
|
||||||
|
},
|
||||||
|
SET_SELECTED_MAPPED(state, data) {
|
||||||
|
state.selectedMapped = data;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -141,6 +122,8 @@ const actions = {
|
|||||||
context.commit('SET_REAL_ORDERS', []);
|
context.commit('SET_REAL_ORDERS', []);
|
||||||
context.commit('SET_CARDS', []);
|
context.commit('SET_CARDS', []);
|
||||||
context.commit('SET_SELECTED', []);
|
context.commit('SET_SELECTED', []);
|
||||||
|
context.commit('SET_SELECTED_MAPPED', []);
|
||||||
|
context.commit('SET_SELECTED_COUNTS', 0);
|
||||||
},
|
},
|
||||||
getRelations(context, params) {
|
getRelations(context, params) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -221,7 +204,6 @@ const actions = {
|
|||||||
row._rowIndex = row.sim + row.order_id;
|
row._rowIndex = row.sim + row.order_id;
|
||||||
});
|
});
|
||||||
context.commit('PUSH_CARDS', data);
|
context.commit('PUSH_CARDS', data);
|
||||||
console.log('cards', data);
|
|
||||||
resolve(data);
|
resolve(data);
|
||||||
} else {
|
} else {
|
||||||
reject(res);
|
reject(res);
|
||||||
@ -254,15 +236,23 @@ const actions = {
|
|||||||
pushSelected(context, array) {
|
pushSelected(context, array) {
|
||||||
let selected = JSON.parse(JSON.stringify(context.getters.selected));
|
let selected = JSON.parse(JSON.stringify(context.getters.selected));
|
||||||
selected = remove_selected(selected, array);
|
selected = remove_selected(selected, array);
|
||||||
|
|
||||||
array.map(el => { selected.push(el); });
|
array.map(el => { selected.push(el); });
|
||||||
|
let mapped = selected.map(el => { return el._rowIndex; });
|
||||||
context.commit('SET_SELECTED', selected.map(el => { return el._rowIndex; }));
|
context.commit('SET_SELECTED', selected);
|
||||||
|
context.commit('SET_SELECTED_MAPPED', mapped);
|
||||||
|
context.commit('SET_SELECTED_COUNTS', selected.reduce((acc, cur) => {
|
||||||
|
return acc + cur.counts;
|
||||||
|
}, 0));
|
||||||
},
|
},
|
||||||
removeSelected(context, array) {
|
removeSelected(context, array) {
|
||||||
let selected = JSON.parse(JSON.stringify(context.getters.selected));
|
let selected = JSON.parse(JSON.stringify(context.getters.selected));
|
||||||
selected = remove_selected(selected, array);
|
selected = remove_selected(selected, array);
|
||||||
context.commit('SET_SELECTED', selected.map(el => { return el._rowIndex; }));
|
let mapped = selected.map(el => { return el._rowIndex; });
|
||||||
|
context.commit('SET_SELECTED', selected);
|
||||||
|
context.commit('SET_SELECTED_MAPPED', mapped);
|
||||||
|
context.commit('SET_SELECTED_COUNTS', selected.reduce((acc, cur) => {
|
||||||
|
return acc + cur.counts;
|
||||||
|
}, 0));
|
||||||
},
|
},
|
||||||
removeSelectedByOrderId(context, order_id) {
|
removeSelectedByOrderId(context, order_id) {
|
||||||
if (typeof order_id !== 'object') {
|
if (typeof order_id !== 'object') {
|
||||||
|
@ -24,15 +24,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
relationObj: {
|
...mapGetters(['orders', 'cards', 'selected', 'selectedMapped', 'counts', 'getFilterUsedCards', 'getSelectedByOrderId', 'relations', 'relationObj', 'real_companies', 'real_packages'])
|
||||||
get() {
|
|
||||||
return this.$store.state.order.relationObj;
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
this.$store.commit('SET_RELATION_OBJ', value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
...mapGetters(['orders', 'cards', 'selected', 'counts', 'getFilterUsedCards', 'getSelectedByOrderId', 'relations', 'real_companies', 'real_packages'])
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -74,9 +66,7 @@ export default {
|
|||||||
return acc + cur.counts;
|
return acc + cur.counts;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
let counts = this.selected.reduce((acc, cur) => {
|
let counts = this.counts;
|
||||||
return acc + cur.counts;
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
value = !!counts;
|
value = !!counts;
|
||||||
indeterminate = total !== counts;
|
indeterminate = total !== counts;
|
||||||
@ -212,9 +202,9 @@ export default {
|
|||||||
let value = false;
|
let value = false;
|
||||||
let indeterminate = false;
|
let indeterminate = false;
|
||||||
|
|
||||||
value = !!this.selected.length;
|
value = !!this.selectedMapped.length;
|
||||||
|
|
||||||
indeterminate = this.selected.length && this.selected.length !== this.showCards.length;
|
indeterminate = this.selectedMapped.length && this.selectedMapped.length !== this.showCards.length;
|
||||||
return h("Checkbox", {
|
return h("Checkbox", {
|
||||||
props: {
|
props: {
|
||||||
indeterminate: value && indeterminate,
|
indeterminate: value && indeterminate,
|
||||||
@ -233,7 +223,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
render: (h, context) => {
|
render: (h, context) => {
|
||||||
let value = this.selected.findIndex(el => { return el._rowIndex === context.row._rowIndex; }) !== -1;
|
let value = this.selectedMapped.indexOf(context.row._rowIndex) !== -1;
|
||||||
return h("Checkbox", {
|
return h("Checkbox", {
|
||||||
props: {
|
props: {
|
||||||
value: value,
|
value: value,
|
||||||
@ -248,12 +238,6 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: "序号",
|
|
||||||
key: "_index",
|
|
||||||
width: 135,
|
|
||||||
sortable: true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: "SIM",
|
title: "SIM",
|
||||||
key: "sim",
|
key: "sim",
|
||||||
@ -403,6 +387,8 @@ export default {
|
|||||||
},
|
},
|
||||||
clearSelect() {
|
clearSelect() {
|
||||||
this.$store.commit('SET_SELECTED', []);
|
this.$store.commit('SET_SELECTED', []);
|
||||||
|
this.$store.commit('SET_SELECTED_MAPPED', []);
|
||||||
|
this.$store.commit('SET_SELECTED_COUNTS', 0);
|
||||||
},
|
},
|
||||||
cannel() {
|
cannel() {
|
||||||
this.clear();
|
this.clear();
|
||||||
@ -486,14 +472,14 @@ export default {
|
|||||||
if (this.type !== 0) {
|
if (this.type !== 0) {
|
||||||
let group = {};
|
let group = {};
|
||||||
|
|
||||||
for (let index = 0; index < this.selected.length; index++) {
|
for (let index = 0; index < this.selectedMapped.length; index++) {
|
||||||
const element = this.selected[index];
|
const element = this.selected[index];
|
||||||
let key = element.company_id + '_' + element.package_id;
|
let key = element.company_id + '_' + element.package_id;
|
||||||
|
|
||||||
if (group.hasOwnProperty(key)) {
|
if (group.hasOwnProperty(key)) {
|
||||||
group[key].push(element._rowIndex);
|
group[key].push(element);
|
||||||
} else {
|
} else {
|
||||||
group[key] = [element._rowIndex];
|
group[key] = [element];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,11 +495,7 @@ export default {
|
|||||||
return this.$Message.error('订单错误');
|
return this.$Message.error('订单错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
let counts = this.selected.reduce((acc, cur) => {
|
if (this.orderObj.counts !== this.counts) {
|
||||||
return acc + cur.counts;
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
if (this.orderObj.counts !== counts) {
|
|
||||||
return this.$Message.error('选择的卡数量不正确');
|
return this.$Message.error('选择的卡数量不正确');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,23 +53,7 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
relationObj: {
|
...mapGetters(['selected', 'selectedMapped', 'counts', 'orders', 'order_group', 'relations', 'relationObj'])
|
||||||
get() {
|
|
||||||
return this.$store.state.order.relationObj;
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
this.$store.commit('SET_RELATION_OBJ', value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
order_group: {
|
|
||||||
get() {
|
|
||||||
return this.$store.getters.order_group;
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
this.$store.commit('SET_ORDER_GROUP', value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
...mapGetters(['selected', 'counts', 'orders', 'relations'])
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
show(bool) {
|
show(bool) {
|
||||||
@ -91,7 +75,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.selected.length && !Object.keys(this.order_group).length) {
|
if (this.selectedMapped.length && !Object.keys(this.order_group).length) {
|
||||||
this.setParamsByReal(this.selected);
|
this.setParamsByReal(this.selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +87,7 @@ export default {
|
|||||||
},
|
},
|
||||||
counts(value) {
|
counts(value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
if (this.selected.length && !Object.keys(this.order_group).length) {
|
if (this.selectedMapped.length && !Object.keys(this.order_group).length) {
|
||||||
this.setParamsByReal(this.selected);
|
this.setParamsByReal(this.selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +155,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.post();
|
this.post();
|
||||||
}
|
}
|
||||||
} else if (this.selected.length) {
|
} else if (this.selectedMapped.length) {
|
||||||
this.params.selected = this.selected.map(el => {
|
this.params.selected = this.selected.map(el => {
|
||||||
return { order_id: el.order_id, counts: el.counts, sim: el.sim };
|
return { order_id: el.order_id, counts: el.counts, sim: el.sim };
|
||||||
});
|
});
|
||||||
@ -366,18 +350,7 @@ export default {
|
|||||||
let mapped = JSON.parse(JSON.stringify(this.order_group));
|
let mapped = JSON.parse(JSON.stringify(this.order_group));
|
||||||
this.$store.dispatch('removeSelected', mapped[this.groupIndex]);
|
this.$store.dispatch('removeSelected', mapped[this.groupIndex]);
|
||||||
delete mapped[this.groupIndex];
|
delete mapped[this.groupIndex];
|
||||||
|
this.$store.commit('SET_ORDER_GROUP', mapped);
|
||||||
let group = {};
|
|
||||||
|
|
||||||
for (const k in mapped) {
|
|
||||||
const element = mapped[k];
|
|
||||||
|
|
||||||
group[k] = element.map(el => {
|
|
||||||
return el._rowIndex;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$store.commit('SET_ORDER_GROUP', group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$Message.success('操作成功');
|
this.$Message.success('操作成功');
|
||||||
|
1
public/css/chunk-3e2248ef.ced8e72d.css
Normal file
1
public/css/chunk-3e2248ef.ced8e72d.css
Normal file
@ -0,0 +1 @@
|
|||||||
|
[data-v-2c5314c6] .ivu-table-cell{word-break:keep-all}
|
2
public/js/app.62107448.js
Normal file
2
public/js/app.62107448.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/app.62107448.js.map
Normal file
1
public/js/app.62107448.js.map
Normal file
File diff suppressed because one or more lines are too long
2
public/js/app.ca03786e.js
Normal file
2
public/js/app.ca03786e.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/app.ca03786e.js.map
Normal file
1
public/js/app.ca03786e.js.map
Normal file
File diff suppressed because one or more lines are too long
2
public/js/chunk-3e2248ef.c312da93.js
Normal file
2
public/js/chunk-3e2248ef.c312da93.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/chunk-3e2248ef.c312da93.js.map
Normal file
1
public/js/chunk-3e2248ef.c312da93.js.map
Normal file
File diff suppressed because one or more lines are too long
2
public/js/chunk-cc3e3910.2afb37d0.js
Normal file
2
public/js/chunk-cc3e3910.2afb37d0.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/chunk-cc3e3910.2afb37d0.js.map
Normal file
1
public/js/chunk-cc3e3910.2afb37d0.js.map
Normal file
File diff suppressed because one or more lines are too long
2
public/js/chunk-cc3e3910.72194745.js
Normal file
2
public/js/chunk-cc3e3910.72194745.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/chunk-cc3e3910.72194745.js.map
Normal file
1
public/js/chunk-cc3e3910.72194745.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-2bc30b38.e8c4cfa7.css rel=prefetch><link href=/css/chunk-cc3e3910.48b8d490.css rel=prefetch><link href=/js/chunk-00ae0766.3874cd10.js rel=prefetch><link href=/js/chunk-07a274ec.c3ad5dec.js rel=prefetch><link href=/js/chunk-2bc30b38.23fc3fe0.js rel=prefetch><link href=/js/chunk-cc3e3910.6c368787.js rel=prefetch><link href=/css/app.d71a8195.css rel=preload as=style><link href=/css/chunk-vendors.5803e894.css rel=preload as=style><link href=/js/app.ef71b9d2.js rel=preload as=script><link href=/js/chunk-vendors.ed6443e8.js rel=preload as=script><link href=/css/chunk-vendors.5803e894.css rel=stylesheet><link href=/css/app.d71a8195.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有启用JavaScript,程序不能正常工作,若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ed6443e8.js></script><script src=/js/app.ef71b9d2.js></script></body></html>
|
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-3e2248ef.ced8e72d.css rel=prefetch><link href=/css/chunk-cc3e3910.48b8d490.css rel=prefetch><link href=/js/chunk-00ae0766.3874cd10.js rel=prefetch><link href=/js/chunk-07a274ec.c3ad5dec.js rel=prefetch><link href=/js/chunk-3e2248ef.c312da93.js rel=prefetch><link href=/js/chunk-cc3e3910.2afb37d0.js rel=prefetch><link href=/css/app.d71a8195.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.62107448.js rel=preload as=script><link href=/js/chunk-vendors.ed6443e8.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.d71a8195.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有启用JavaScript,程序不能正常工作,若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ed6443e8.js></script><script src=/js/app.62107448.js></script></body></html>
|
Loading…
x
Reference in New Issue
Block a user