优化友链

This commit is contained in:
zjl 2024-12-12 12:49:48 +08:00
parent 83fb0988bd
commit a87d8b4bad
3 changed files with 53 additions and 15 deletions

View File

@ -16,7 +16,7 @@ export const columns = [
{
title: '友链名称',
key: 'name',
width: 100,
width: 150,
},
{
title: '友链类型',

View File

@ -101,13 +101,17 @@
const formData = reactive({
id: '',
name: '',
type: undefined,
type: '',
url: '',
form: undefined,
form: '',
image: '',
status: 1,
sort: 0,
});
/**
* 定义数据源
*/
const optionData = {
typeList: [
{ label: '友情链接', value: 1 },
@ -118,6 +122,7 @@
{ label: '图片链接', value: 2 },
],
};
/**
* 定义接收的参数
*/
@ -133,13 +138,18 @@
default: 0,
},
});
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.linkId ? '编辑友链' : '添加友链',
subBtuText: '确定',
width: 600,
});
/**
* 执行提交
* 执行提交表单
*/
const handleSubmit = async () => {
formRef.value
@ -184,7 +194,10 @@
setFormData();
}
});
//
/**
* 定义函数
*/
defineExpose({
openModal,
});

View File

@ -27,7 +27,6 @@
</template>
新建
</n-button>
<n-button
type="error"
@click="handleDelete"
@ -63,12 +62,13 @@
import { getLinkList, linkDelete, linkBatchDelete } from '@/api/content/link';
import { columns } from './columns';
import { PlusOutlined, DeleteOutlined, FormOutlined } from '@vicons/antd';
import CreateModal from './CreateModal.vue';
import editDialog from './edit.vue';
import { basicModal, useModal } from '@/components/Modal';
import { schemas } from './querySchemas';
import { renderIcon } from '@/utils';
/**
* 定义常量
*/
const message = useMessage();
const dialog = useDialog();
const basicTableRef = ref();
@ -76,15 +76,19 @@
const editVisible = ref(false);
const linkId = ref(0);
const rowKeys = ref([]);
const exportLoading = ref(false);
const showModal = ref(false);
/**
* 定义查看参数
*/
const formParams = reactive({
name: '',
});
/**
* 定义操作栏
*/
const actionColumn = reactive({
width: 400,
width: 200,
title: '操作',
align: 'center',
key: 'action',
@ -112,24 +116,36 @@
},
});
function addTable() {
showModal.value = true;
}
/**
* 加载数据列表
* @param res 参数
*/
const loadDataTable = async (res) => {
rowKeys.value = [];
const result = await getLinkList({ ...formParams, ...res });
return result;
};
/**
* 数据行选中事件
* @param keys 参数
*/
function onCheckedRow(keys) {
rowKeys.value = keys;
}
/**
* 刷新数据列表
* @param noRefresh 参数
*/
function reloadTable(noRefresh = '') {
basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
}
/**
* 执行提交表单
* @param values 参数
*/
function handleSubmit(values: Recordable) {
for (const key in formParams) {
formParams[key] = '';
@ -140,6 +156,10 @@
reloadTable();
}
/**
* 执行重置
* @param values 参数
*/
function handleReset(values: Recordable) {
for (const key in formParams) {
formParams[key] = '';
@ -150,6 +170,9 @@
reloadTable();
}
/**
* 执行注册
*/
const [register, {}] = useForm({
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
labelWidth: 80,
@ -165,6 +188,7 @@
await nextTick();
createModalRef.value.openModal();
};
/**
* 执行编辑
*/
@ -174,6 +198,7 @@
await nextTick();
createModalRef.value.openModal();
}
/**
* 执行删除
* @param id 参数