优化广告、广告位

This commit is contained in:
zjl 2024-12-12 13:44:34 +08:00
parent fae37e2738
commit 888bb91f26
18 changed files with 132 additions and 52 deletions

View File

@ -142,33 +142,37 @@
import UploadImg from '@/components/Upload/Image.vue'; import UploadImg from '@/components/Upload/Image.vue';
import { useLockFn } from '@/utils/useLockFn'; import { useLockFn } from '@/utils/useLockFn';
/**
* 定义变量
*/
const emit = defineEmits(['success', 'update:visible']); const emit = defineEmits(['success', 'update:visible']);
const formRef = ref(); const formRef = ref();
const message = useMessage();
const adSortList = ref([]);
const editorRef = ref();
/** /**
* 定义表单参数 * 定义表单参数
*/ */
const message = useMessage();
const adSortList = ref([]);
const editorRef = ref();
const formData = reactive({ const formData = reactive({
id: '', id: '',
title: '', title: '',
adSortId: undefined, adSortId: '',
cover: '', cover: '',
type: undefined, type: '',
note: '', note: '',
content: '', content: '',
url: '', url: '',
width: '', width: '',
height: '', height: '',
adTime: null, adTime: [],
startTime: '', startTime: '',
endTime: '', endTime: '',
click: '', click: '',
status: 1, status: 1,
sort: 0, sort: 0,
}); });
/** /**
* 定义接收的参数 * 定义接收的参数
*/ */
@ -184,12 +188,10 @@
default: 0, default: 0,
}, },
}); });
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.adId ? '编辑广告' : '添加广告',
subBtuText: '确定',
width: 1350,
});
/**
* 定义常量数据
*/
const typeList = [ const typeList = [
{ label: '图片', value: 1 }, { label: '图片', value: 1 },
{ label: '文字', value: 2 }, { label: '文字', value: 2 },
@ -197,6 +199,15 @@
{ label: '推荐', value: 4 }, { label: '推荐', value: 4 },
]; ];
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.adId ? '编辑广告' : '添加广告',
subBtuText: '确定',
width: 1350,
});
/** /**
* 执行提交 * 执行提交
*/ */
@ -223,6 +234,7 @@
}); });
}; };
const { isLock: subLoading, lockFn: submit } = useLockFn(handleSubmit); const { isLock: subLoading, lockFn: submit } = useLockFn(handleSubmit);
/** /**
* 关闭窗体 * 关闭窗体
*/ */
@ -255,6 +267,7 @@
let list = await getAdSortAllList(); let list = await getAdSortAllList();
adSortList.value = list ? list : []; adSortList.value = list ? list : [];
}; };
/** /**
* 钩子函数 * 钩子函数
*/ */
@ -264,7 +277,10 @@
setFormData(); setFormData();
} }
}); });
//
/**
* 定义函数
*/
defineExpose({ defineExpose({
openModal, openModal,
}); });

View File

@ -27,7 +27,6 @@
</template> </template>
新建 新建
</n-button> </n-button>
<n-button <n-button
type="error" type="error"
@click="handleDelete" @click="handleDelete"
@ -63,12 +62,13 @@
import { getAdList, adDelete, adBatchDelete } from '@/api/content/ad'; import { getAdList, adDelete, adBatchDelete } from '@/api/content/ad';
import { columns } from './columns'; import { columns } from './columns';
import { PlusOutlined, DeleteOutlined, FormOutlined } from '@vicons/antd'; import { PlusOutlined, DeleteOutlined, FormOutlined } from '@vicons/antd';
import CreateModal from './CreateModal.vue';
import editDialog from './edit.vue'; import editDialog from './edit.vue';
import { basicModal, useModal } from '@/components/Modal';
import { schemas } from './querySchemas'; import { schemas } from './querySchemas';
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/**
* 定义参数
*/
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();
const basicTableRef = ref(); const basicTableRef = ref();
@ -76,14 +76,20 @@
const editVisible = ref(false); const editVisible = ref(false);
const adId = ref(0); const adId = ref(0);
const rowKeys = ref([]); const rowKeys = ref([]);
const exportLoading = ref(false);
const showModal = ref(false); const showModal = ref(false);
/**
* 定义查询参数
*/
const formParams = reactive({ const formParams = reactive({
name: '', title: '',
status: '', status: '',
adSortId: '',
}); });
/**
* 定义操作栏
*/
const actionColumn = reactive({ const actionColumn = reactive({
width: 200, width: 200,
title: '操作', title: '操作',
@ -113,24 +119,36 @@
}, },
}); });
function addTable() { /**
showModal.value = true; * 加载数据列表
} * @param res 参数
*/
const loadDataTable = async (res) => { const loadDataTable = async (res) => {
rowKeys.value = []; rowKeys.value = [];
const result = await getAdList({ ...formParams, ...res }); const result = await getAdList({ ...formParams, ...res });
return result; return result;
}; };
/**
* 数据行选中事件
* @param keys 参数
*/
function onCheckedRow(keys) { function onCheckedRow(keys) {
rowKeys.value = keys; rowKeys.value = keys;
} }
/**
* 刷新数据表
* @param noRefresh 参数
*/
function reloadTable(noRefresh = '') { function reloadTable(noRefresh = '') {
basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 }); basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
} }
/**
* 执行提交表单
* @param values 参数
*/
function handleSubmit(values: Recordable) { function handleSubmit(values: Recordable) {
for (const key in formParams) { for (const key in formParams) {
formParams[key] = ''; formParams[key] = '';
@ -141,6 +159,10 @@
reloadTable(); reloadTable();
} }
/**
* 执行重置
* @param values 参数
*/
function handleReset(values: Recordable) { function handleReset(values: Recordable) {
for (const key in formParams) { for (const key in formParams) {
formParams[key] = ''; formParams[key] = '';
@ -151,6 +173,9 @@
reloadTable(); reloadTable();
} }
/**
* 执行注册
*/
const [register, {}] = useForm({ const [register, {}] = useForm({
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' }, gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
labelWidth: 80, labelWidth: 80,
@ -175,6 +200,7 @@
await nextTick(); await nextTick();
createModalRef.value.openModal(); createModalRef.value.openModal();
} }
/** /**
* 执行删除 * 执行删除
* @param id 参数 * @param id 参数

View File

@ -62,11 +62,11 @@
const emit = defineEmits(['success', 'update:visible']); const emit = defineEmits(['success', 'update:visible']);
const formRef = ref(); const formRef = ref();
const message = useMessage();
/** /**
* 定义表单参数 * 定义表单参数
*/ */
const message = useMessage();
const formData = reactive({ const formData = reactive({
id: '', id: '',
name: '', name: '',
@ -91,16 +91,25 @@
default: 0, default: 0,
}, },
}); });
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.adSortId ? '编辑广告位' : '添加广告位', /**
subBtuText: '确定', * 定义数据源
width: 600, */
});
const typeList = [ const typeList = [
{ label: '网站', value: 1 }, { label: '网站', value: 1 },
{ label: '手机站', value: 2 }, { label: '手机站', value: 2 },
{ label: '移动端', value: 3 }, { label: '移动端', value: 3 },
]; ];
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.adSortId ? '编辑广告位' : '添加广告位',
subBtuText: '确定',
width: 600,
});
/** /**
* 执行提交 * 执行提交
*/ */
@ -149,7 +158,10 @@
setFormData(); setFormData();
} }
}); });
//
/**
* 定义函数
*/
defineExpose({ defineExpose({
openModal, openModal,
}); });

View File

@ -27,7 +27,6 @@
</template> </template>
新建 新建
</n-button> </n-button>
<n-button <n-button
type="error" type="error"
@click="handleDelete" @click="handleDelete"
@ -63,12 +62,13 @@
import { getAdSortList, adSortDelete, adSortBatchDelete } from '@/api/content/adSort'; import { getAdSortList, adSortDelete, adSortBatchDelete } from '@/api/content/adSort';
import { columns } from './columns'; import { columns } from './columns';
import { PlusOutlined, DeleteOutlined, FormOutlined } from '@vicons/antd'; import { PlusOutlined, DeleteOutlined, FormOutlined } from '@vicons/antd';
import CreateModal from './CreateModal.vue';
import editDialog from './edit.vue'; import editDialog from './edit.vue';
import { basicModal, useModal } from '@/components/Modal';
import { schemas } from './querySchemas'; import { schemas } from './querySchemas';
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/**
* 定义参数
*/
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();
const basicTableRef = ref(); const basicTableRef = ref();
@ -76,14 +76,19 @@
const editVisible = ref(false); const editVisible = ref(false);
const adSortId = ref(0); const adSortId = ref(0);
const rowKeys = ref([]); const rowKeys = ref([]);
const exportLoading = ref(false);
const showModal = ref(false); const showModal = ref(false);
/**
* 定义查询参数
*/
const formParams = reactive({ const formParams = reactive({
name: '', name: '',
type: '', type: '',
}); });
/**
* 定义操作栏
*/
const actionColumn = reactive({ const actionColumn = reactive({
width: 200, width: 200,
title: '操作', title: '操作',
@ -113,24 +118,36 @@
}, },
}); });
function addTable() { /**
showModal.value = true; * 加载数据列表
} * @param res 参数
*/
const loadDataTable = async (res) => { const loadDataTable = async (res) => {
rowKeys.value = []; rowKeys.value = [];
const result = await getAdSortList({ ...formParams, ...res }); const result = await getAdSortList({ ...formParams, ...res });
return result; return result;
}; };
/**
* 数据行选中事件
* @param keys 参数
*/
function onCheckedRow(keys) { function onCheckedRow(keys) {
rowKeys.value = keys; rowKeys.value = keys;
} }
/**
* 加载数据列表
* @param noRefresh 参数
*/
function reloadTable(noRefresh = '') { function reloadTable(noRefresh = '') {
basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 }); basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
} }
/**
* 执行提交表单
* @param values 参数
*/
function handleSubmit(values: Recordable) { function handleSubmit(values: Recordable) {
for (const key in formParams) { for (const key in formParams) {
formParams[key] = ''; formParams[key] = '';
@ -141,6 +158,10 @@
reloadTable(); reloadTable();
} }
/**
* 执行重置
* @param values 参数
*/
function handleReset(values: Recordable) { function handleReset(values: Recordable) {
for (const key in formParams) { for (const key in formParams) {
formParams[key] = ''; formParams[key] = '';
@ -151,6 +172,9 @@
reloadTable(); reloadTable();
} }
/**
* 执行注册
*/
const [register, {}] = useForm({ const [register, {}] = useForm({
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' }, gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
labelWidth: 80, labelWidth: 80,
@ -166,6 +190,7 @@
await nextTick(); await nextTick();
createModalRef.value.openModal(); createModalRef.value.openModal();
}; };
/** /**
* 执行编辑 * 执行编辑
*/ */
@ -175,6 +200,7 @@
await nextTick(); await nextTick();
createModalRef.value.openModal(); createModalRef.value.openModal();
} }
/** /**
* 执行删除 * 执行删除
* @param id 参数 * @param id 参数

View File

@ -123,7 +123,7 @@
import { buildTree } from '@/utils/auth'; import { buildTree } from '@/utils/auth';
/** /**
* 定义常量 * 定义参数
*/ */
const emit = defineEmits(['success', 'update:visible']); const emit = defineEmits(['success', 'update:visible']);
const formRef = ref(); const formRef = ref();

View File

@ -67,7 +67,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -67,7 +67,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -95,7 +95,7 @@
import { useLockFn } from '@/utils/useLockFn'; import { useLockFn } from '@/utils/useLockFn';
/** /**
* 定义常量 * 定义参数
*/ */
const emit = defineEmits(['success', 'update:visible']); const emit = defineEmits(['success', 'update:visible']);
const formRef = ref(); const formRef = ref();

View File

@ -67,7 +67,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -67,7 +67,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -67,7 +67,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -67,7 +67,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -71,7 +71,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -71,7 +71,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -71,7 +71,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -58,7 +58,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -58,7 +58,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -58,7 +58,7 @@
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义常量 * 定义参数
*/ */
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();