添加卡片右键菜单和点击事件.
This commit is contained in:
@@ -42,6 +42,22 @@
|
||||
</a-dropdown>
|
||||
</a-space>
|
||||
</template>
|
||||
<!-- 右键菜单 -->
|
||||
<template #contextMenu="{ record }">
|
||||
<!-- 修改 -->
|
||||
<a-doption v-permission="['${package.ModuleName}:${typeHyphen}:update']"
|
||||
@click="emits('openUpdate', record)">
|
||||
<icon-edit />
|
||||
修改
|
||||
</a-doption>
|
||||
<!-- 删除 -->
|
||||
<a-doption v-permission="['${package.ModuleName}:${typeHyphen}:delete']"
|
||||
class="span-red"
|
||||
@click="deleteRow(record.id)">
|
||||
<icon-delete />
|
||||
删除
|
||||
</a-doption>
|
||||
</template>
|
||||
<!-- 过滤条件 -->
|
||||
<template #filterContent>
|
||||
<a-form :model="formModel"
|
||||
@@ -54,7 +70,7 @@
|
||||
:wrapper-col-props="{ span: 18 }">
|
||||
#foreach($field in ${table.fields})
|
||||
<!-- $field.comment -->
|
||||
<a-form-item field="${field.propertyName}" label="${field.comment}" label-col-flex="50px">
|
||||
<a-form-item field="${field.propertyName}" label="${field.comment}">
|
||||
#if(${vue.enums.containsKey(${field.propertyName})})
|
||||
<a-select v-model="formModel.${field.propertyName}"
|
||||
:options="toOptions(${vue.enums.get(${field.propertyName}).className})"
|
||||
@@ -96,13 +112,13 @@
|
||||
import { objectTruthKeyCount, resetObject } from '@/utils';
|
||||
import fieldConfig from '../types/card.fields';
|
||||
import { delete${vue.featureEntity}, get${vue.featureEntity}Page, ${vue.featureEntity}QueryRequest, ${vue.featureEntity}QueryResponse } from '@/api/${vue.module}/${vue.feature}';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { Message, Modal } from '@arco-design/web-vue';
|
||||
|
||||
const { loading, setLoading } = useLoading();
|
||||
const cardColLayout = useColLayout();
|
||||
const pagination = usePagination();
|
||||
const list = ref<${vue.featureEntity}QueryResponse[]>([]);
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openUpdateConfig']);
|
||||
const emits = defineEmits(['openAdd', 'openUpdate']);
|
||||
|
||||
const formModel = reactive<${vue.featureEntity}QueryRequest>({
|
||||
searchValue: undefined,
|
||||
@@ -117,18 +133,26 @@
|
||||
});
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async (id: number) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await delete${vue.featureEntity}(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
await fetchCardData();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
const deleteRow = (id: number) => {
|
||||
Modal.confirm({
|
||||
title: '删除前确认?',
|
||||
titleAlign: 'start',
|
||||
content: '确定要删除这条记录吗?',
|
||||
okText: '删除',
|
||||
onOk: async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await delete${vue.featureEntity}(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
await fetchCardData();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 添加后回调
|
||||
@@ -175,4 +199,5 @@
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user