<template>
|
<app-list-wrapper v-bind="listWrapperProps">
|
<template #header-button="scope">
|
<el-button
|
size="small"
|
type="danger"
|
icon="Delete"
|
:disabled="!scope.selected.id"
|
@click="onDelete(scope.selected)"
|
>
|
</el-button>
|
<el-button
|
size="small"
|
type="primary"
|
icon="Edit"
|
:disabled="!scope.selected.id"
|
@click="onDialog(scope.selected)">
|
</el-button>
|
<el-button
|
icon="Plus"
|
size="small"
|
type="primary"
|
:disabled="!scope.selected.id"
|
@click="onDialog({parent:scope.selected})">
|
</el-button>
|
</template>
|
<app-list-tree
|
v-bind="treeProps"
|
>
|
</app-list-tree>
|
</app-list-wrapper>
|
<discount-dialog v-bind="discountDialogProps"/>
|
</template>
|
|
<script setup>
|
import DiscountDialog from './DiscountDialog';
|
import {useI18n} from 'vue-i18n';
|
|
const {t} = useI18n();
|
import {useAppStore, useEntityStore} from '@/store/modules';
|
import {modal} from '@/plugins';
|
|
const props = defineProps({
|
subActive: {
|
type: Function,
|
default: () => {
|
}
|
}
|
});
|
|
const entityStore = useEntityStore();
|
const appStore = useAppStore();
|
|
const treeRef = ref();
|
const listWrapperRef = ref();
|
const discountDialogRef = ref();
|
|
const treeProps = {
|
ref: treeRef,
|
expandOnClickNode: false,
|
nodeKey: 'id',
|
props: {
|
children: 'children',
|
label: 'name',
|
},
|
defaultExpandAll: true,
|
subRequest: async () => {
|
const {data} = await entityStore.getEntityTree({
|
dataName: "v_discount_policy",
|
filter: "1=1"
|
});
|
return data['entityset'];
|
},
|
subActive: (row) => {
|
listWrapperRef.value.setSelected(row)
|
props.subActive(row);
|
}
|
}
|
|
const discountDialogProps = {
|
ref: discountDialogRef,
|
subReload() {
|
treeRef.value.onReload(false);
|
}
|
};
|
|
const listWrapperProps = {
|
ref: listWrapperRef,
|
title: t('views.agm.agmParams.IndexPage.GroupList.title'),
|
complementHeight: 99,
|
};
|
|
const onDialog = (row) => {
|
discountDialogRef.value.onOpen(row);
|
};
|
|
const onDelete = async (row) => {
|
await modal.confirm("是否确认删除?");
|
|
await entityStore.deleteEntity({
|
dataName: 'hd_discount_policy',
|
id: row.id
|
});
|
|
treeRef.value.onReload(true);
|
};
|
|
onMounted(() => {
|
treeRef.value.onReload(false);
|
});
|
|
|
</script>
|