This commit is contained in:
孟帅
2024-11-27 18:44:19 +08:00
parent 6254505a7d
commit 2fd3854aeb
69 changed files with 656 additions and 245 deletions

View File

@@ -92,6 +92,34 @@
return adaModalWidth(840);
});
// 提交表单
function confirmForm(e) {
e.preventDefault();
formRef.value.validate((errors) => {
if (!errors) {
formBtnLoading.value = true;
Edit(formValue.value)
.then((_res) => {
message.success('操作成功');
closeForm();
emit('reloadTable');
})
.finally(() => {
formBtnLoading.value = false;
});
} else {
message.error('请填写完整信息');
}
});
}
// 关闭表单
function closeForm() {
showModal.value = false;
loading.value = false;
}
// 打开模态框
function openModal(state: State) {
showModal.value = true;
@@ -121,33 +149,6 @@
});
}
// 提交表单
function confirmForm(e) {
e.preventDefault();
formRef.value.validate((errors) => {
if (!errors) {
formBtnLoading.value = true;
Edit(formValue.value)
.then((_res) => {
message.success('操作成功');
closeForm();
emit('reloadTable');
})
.finally(() => {
formBtnLoading.value = false;
});
} else {
message.error('请填写完整信息');
}
});
}
// 关闭表单
function closeForm() {
showModal.value = false;
loading.value = false;
}
defineExpose({
openModal,
});

View File

@@ -49,13 +49,13 @@
import { adaTableScrollX } from '@/utils/hotgo';
import Edit from './edit.vue';
const dict = useDictStore();
const dialog = useDialog();
const message = useMessage();
const { hasPermission } = usePermission();
const actionRef = ref();
const searchFormRef = ref<any>({});
const editRef = ref();
const dict = useDictStore();
const checkedIds = ref([]);
@@ -64,7 +64,7 @@
title: '操作',
key: 'action',
fixed: 'right',
render(record) {
render(record: State) {
return h(TableAction as any, {
style: 'button',
actions: [

View File

@@ -1,11 +1,9 @@
import { h, ref } from 'vue';
import { NTag } from 'naive-ui';
import { cloneDeep } from 'lodash-es';
import { FormSchema } from '@/components/Form';
import { isNullObject } from '@/utils/is';
import { defRangeShortcuts } from '@/utils/dateUtil';
import { renderOptionTag } from '@/utils';
import { useDictStore } from '@/store/modules/dict';
import type { FormRules } from 'naive-ui/es/form/src/interface';
const dict = useDictStore();
@@ -39,7 +37,7 @@ export function newState(state: State | Record<string, any> | null): State {
}
// 表单验证规则
export const rules: FormRules = {
export const rules = {
name: {
required: true,
trigger: ['blur', 'input'],
@@ -137,23 +135,8 @@ export const columns = [
key: 'status',
align: 'left',
width: -1,
render(row) {
if (isNullObject(row.status)) {
return ``;
}
return h(
NTag,
{
style: {
marginRight: '6px',
},
type: dict.getType('sys_normal_disable', row.status),
bordered: false,
},
{
default: () => dict.getLabel('sys_normal_disable', row.status),
}
);
render(row: State) {
return renderOptionTag('sys_normal_disable', row.status);
},
},
{
@@ -167,4 +150,4 @@ export const columns = [
// 加载字典数据选项
export function loadOptions() {
dict.loadOptions(['sys_normal_disable']);
}
}