|
|
@@ -25,7 +25,9 @@ const searchFormProps = reactive<VxeFormProps<TagQuery>>({
|
|
|
titleWidth: 100,
|
|
|
titleAlign: 'right',
|
|
|
titleColon: true,
|
|
|
- data: {},
|
|
|
+ data: {
|
|
|
+ types: ['1', '2'],
|
|
|
+ },
|
|
|
items: [
|
|
|
{ field: 'name', title: '标签名称', span: 8, itemRender: { name: 'VxeInput' } },
|
|
|
{
|
|
|
@@ -46,6 +48,14 @@ const searchFormProps = reactive<VxeFormProps<TagQuery>>({
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
+ { field: 'types', title: '标签分类', span: 8, itemRender: {
|
|
|
+ name: 'VxeCheckboxGroup',
|
|
|
+ options: [
|
|
|
+ { label: '系统', value: '1' },
|
|
|
+ { label: '个人', value: '2' },
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
{
|
|
|
span: 8, itemRender: {
|
|
|
name: 'VxeButtonGroup',
|
|
|
@@ -59,7 +69,7 @@ const searchFormProps = reactive<VxeFormProps<TagQuery>>({
|
|
|
});
|
|
|
const searchFormEmits: VxeFormListeners<TagQuery> = {
|
|
|
submit({ data }) { model.value = { ...data }; },
|
|
|
- reset({ data }) { model.value = { ...data }; },
|
|
|
+ reset({ data }) { model.value = { ...data, }; },
|
|
|
};
|
|
|
|
|
|
const gridRef = ref<VxeGridInstance<TagModel>>();
|
|
|
@@ -88,44 +98,10 @@ const gridOptions = reactive<VxeGridProps<TagModel>>({
|
|
|
{ field: 'name', title: '标签名称' },
|
|
|
{ field: 'parentName', title: '上级标签' },
|
|
|
{ field: 'updateTime', title: '最近一次修改时间' },
|
|
|
- { field: 'nickName', title: '创建者' },
|
|
|
- {
|
|
|
- field: 'status', title: '启用状态', align: 'center', minWidth: 90, cellRender: {
|
|
|
- name: 'VxeSwitch',
|
|
|
- props: {
|
|
|
- openLabel: '启用', openValue: '0',
|
|
|
- closeLabel: '停用', closeValue: '1',
|
|
|
- },
|
|
|
- events: {
|
|
|
- change({ row, rowIndex }, { value }) {
|
|
|
- row.status = { '1': '0', '0': '1' }[ value as string ] as any;
|
|
|
- updateTagStatus(row, rowIndex, value);
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- title: '操作',
|
|
|
- align: 'center',
|
|
|
- width: 120,
|
|
|
- cellRender: {
|
|
|
- name: 'VxeButtonGroup',
|
|
|
- props: {
|
|
|
- mode: 'text',
|
|
|
- },
|
|
|
- options: [
|
|
|
- { content: '修改', status: 'warning', name: 'editTag' },
|
|
|
- { content: '删除', status: 'error', name: 'deleteTag' },
|
|
|
- ],
|
|
|
- events: {
|
|
|
- click({ row, rowIndex }, { name }) {
|
|
|
- let method;
|
|
|
- if ( name === 'editTag' ) { method = editTag; } else if ( name === 'deleteTag' ) { method = deleteTag; }
|
|
|
- method?.(row, rowIndex);
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
+ { field: 'createBy', title: '创建者' },
|
|
|
+ { field: 'status', title: '启用状态', align: 'center', minWidth: 90, slots: { default: 'cell-status' }, },
|
|
|
+ { field: 'category', title: '标签分类' },
|
|
|
+ { title: '操作', align: 'center', width: 120, slots: { default: 'cell-operation' }, },
|
|
|
],
|
|
|
data: [],
|
|
|
});
|
|
|
@@ -148,7 +124,7 @@ onMounted(() => {
|
|
|
model.value = toRaw(searchFormProps.data);
|
|
|
});
|
|
|
|
|
|
-function updateTagStatus(model: TagModel, index: number, status: TagModel['status']) {
|
|
|
+function updateTagStatus(status: TagModel['status'], model: TagModel, index?: number) {
|
|
|
const { id, name } = model;
|
|
|
const label = { '1': '停用', '0': '启用' }[ status ];
|
|
|
VxeUI.modal.confirm({
|
|
|
@@ -168,7 +144,7 @@ function updateTagStatus(model: TagModel, index: number, status: TagModel['statu
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function deleteTag(model: TagModel, index: number) {
|
|
|
+function deleteTag(model: TagModel, index?: number) {
|
|
|
const { name } = model;
|
|
|
VxeUI.modal.confirm({
|
|
|
title: `删除标签`,
|
|
|
@@ -220,6 +196,20 @@ function editTag(model?: TagModel, index?: number) {
|
|
|
<template #toolbar-extra>
|
|
|
<vxe-button style="margin-right: 12px;" icon="vxe-icon-repeat" circle @click="refresh(page)"></vxe-button>
|
|
|
</template>
|
|
|
+
|
|
|
+ <template #cell-status="{ row }">
|
|
|
+ <vxe-switch :modelValue="row.status" :disabled="!row.editable"
|
|
|
+ openLabel="启用" openValue="0"
|
|
|
+ closeLabel="停用" closeValue="1"
|
|
|
+ @change="updateTagStatus($event.value, row)"
|
|
|
+ ></vxe-switch>
|
|
|
+ </template>
|
|
|
+ <template #cell-operation="{ row }">
|
|
|
+ <vxe-button-group mode="text">
|
|
|
+ <vxe-button content="修改" :disabled="!row.editable" status="warning" @click="editTag(row)"></vxe-button>
|
|
|
+ <vxe-button content="删除" :disabled="!row.deletable" status="error" @click="deleteTag(row)"></vxe-button>
|
|
|
+ </vxe-button-group>
|
|
|
+ </template>
|
|
|
</vxe-grid>
|
|
|
</main>
|
|
|
<footer class="flex-none">
|
|
|
@@ -236,5 +226,21 @@ function editTag(model?: TagModel, index?: number) {
|
|
|
.page-container {
|
|
|
padding: 0 24px;
|
|
|
max-height: var(--page-main-container);
|
|
|
+
|
|
|
+ :deep(.vxe-checkbox-group) {
|
|
|
+ .vxe-checkbox {
|
|
|
+ .vxe-checkbox--input {
|
|
|
+ margin-right: 4px;
|
|
|
+ transform: translateY(2px);
|
|
|
+ }
|
|
|
+ & + .vxe-checkbox {
|
|
|
+ margin-left: 8px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.vxe-checkbox--icon) {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|