master
xy 2 years ago
parent 212fc1b25e
commit efce408990

@ -6,12 +6,14 @@
:visible.sync="isShow"
direction="rtl"
>
<Button shape="circle"
type="primary"
:style="{
'margin':'0 0 10px 20px'
}"
@click="isShowModal = true">
<Button
shape="circle"
type="primary"
:style="{
margin: '0 0 10px 20px',
}"
@click="isShowModal = true"
>
目标选择</Button
>
<xy-table :list="list" :table-item="table">
@ -30,14 +32,18 @@
@on-selection-change="selectionChange"
></Table>
<div style="display: flex; justify-content: center; margin: 10px 0">
<Page :total="pointTotal"
size="small"
show-elevator
show-total
@on-change="e => {
pointSelect.page = e;
getPoints();
}"/>
<Page
:total="pointTotal"
size="small"
show-elevator
show-total
@on-change="
(e) => {
pointSelect.page = e;
getPoints();
}
"
/>
</div>
<span slot="footer" class="dialog-footer">
@ -63,17 +69,17 @@ export default {
{
label: "指标名称",
prop: "target.name",
minWidth: 200
minWidth: 200,
},
{
label: "半年(程)指标值",
prop: "target.half_target",
width: 180
width: 180,
},
{
label: "全年(程)指标值",
prop: "target.year_target",
width: 180
width: 180,
},
{
label: "创建时间",
@ -204,8 +210,7 @@ export default {
},
],
selections: [], //
selectedIds: [],
};
},
methods: {
@ -242,11 +247,7 @@ export default {
},
selectionChange(selection) {
this.selections = Array.from(
new Set(
selection.map((item) => item.id)
)
);
this.selections = Array.from(new Set(selection.map((item) => item.id)));
console.log(this.selections);
},
@ -262,13 +263,18 @@ export default {
this.spanArr1 = [];
try {
const res = await pointIndex(this.pointSelect);
let selectedIds = Array.from(new Set(this.list.map((item) => item.target_id)));
this.points = res.data.map(item => {
let selectedIds = Array.from(
new Set(this.list.map((item) => item.target_id))
);
this.selectedIds = selectedIds;
this.points = res.data.map((item) => {
return {
...item,
_checked: !!selectedIds.find(i => i === item.id) || !!this.selections.find(i => i === item.id),
_disabled: !!selectedIds.find(i => i === item.id),
}
_checked:
!!selectedIds.find((i) => i === item.id) ||
!!this.selections.find((i) => i === item.id),
_disabled: !!selectedIds.find((i) => i === item.id),
};
});
this.pointTotal = res.total;
@ -310,19 +316,21 @@ export default {
},
submit() {
Promise.all(
this.selections.map((target_id) => {
return save({
let promiseAll = [];
this.selections.forEach((target_id) => {
if (this.selectedIds.indexOf(target_id) !== -1) return;
promiseAll.push(
save({
target_id,
plan_id: this.getPlanId(),
});
})
).then((res) => {
})
);
});
Promise.all(promiseAll).then((res) => {
this.getList();
this.isShowModal = false;
});
},
},
computed: {},
watch: {
@ -333,15 +341,15 @@ export default {
}
},
isShowModal(val) {
if(val){
if (val) {
this.getPoints();
}else{
} else {
this.selections = [];
resetSelect(this.pointSelect);
this.points = [];
this.pointTotal = 0;
}
}
},
},
};
</script>

Loading…
Cancel
Save