This commit is contained in:
孟帅
2024-07-21 22:21:02 +08:00
parent 7d8330f72f
commit a37d088360
440 changed files with 6303 additions and 3339 deletions

View File

@@ -45,6 +45,7 @@
const emit = defineEmits(['reloadTable']);
const message = useMessage();
const settingStore = useProjectSettingStore();
@{ if eq .options.DictOps.Has true }const dict = useDictStore();@{end}
const loading = ref(false);
const showModal = ref(false);
const formValue = ref<State>(newState(null));
@@ -54,6 +55,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;
@{ if eq .options.Step.IsTreeTable true }
@@ -86,31 +115,6 @@
});
}
function confirmForm(e) {
e.preventDefault();
formBtnLoading.value = true;
formRef.value.validate((errors) => {
if (!errors) {
Edit(formValue.value).then((_res) => {
message.success('操作成功');
setTimeout(() => {
closeForm();
emit('reloadTable');
});
});
} else {
message.error('请填写完整信息');
}
formBtnLoading.value = false;
loading.value = false;
});
}
function closeForm() {
showModal.value = false;
loading.value = false;
}
defineExpose({
openModal,
});

View File

@@ -40,7 +40,7 @@
@{end}
@{ if eq .options.Step.HasBatchDel true }
<n-button v-if="hasPermission(['/@{.apiPrefix}/delete'])" type="error" icon-placement="left" @click="handleEdit(selectedState)" :disabled="selectedState.@{.pk.TsName} < 1">
<n-button v-if="hasPermission(['/@{.apiPrefix}/delete'])" type="error" icon-placement="left" @click="handleDelete(selectedState)" :disabled="selectedState.@{.pk.TsName} < 1">
<template #icon>
<div class="flex items-center">
<n-icon size="14">
@@ -183,7 +183,7 @@
<script lang="ts" setup>
@{.import}
@{ if eq .options.DictOps.Has true }const dict = useDictStore();@{end}
const dialog = useDialog();
const message = useMessage();
const { hasPermission } = usePermission();
@@ -194,7 +194,6 @@
@{ if eq .options.Step.HasCheck true }const checkedIds = ref([]);@{end}
@{ if and (eq .options.Step.IsTreeTable true) (eq .options.Step.IsOptionTreeTable false) }const expandedKeys = ref([]);
const allTreeKeys = ref([]);@{end}
@{ if eq .options.Step.IsOptionTreeTable true }const expandedKeys = ref([]);
const pattern = ref('');
const selectedState = ref<State>(newState(null));
@@ -205,7 +204,7 @@
title: '操作',
key: 'action',
fixed: 'right',
render(record) {
render(record: State) {
return h(TableAction as any, {
style: 'button',
actions: [
@@ -391,7 +390,7 @@
// 修改状态
function handleStatus(record: Recordable, status: number) {
Status({ @{.pk.TsName}: record.@{.pk.TsName}, status: status }).then((_res) => {
message.success('设为' + getOptionLabel(options.value.sys_normal_disable, status) + '成功');
message.success('设为' + dict.getLabel('sys_normal_disable', status) + '成功');
setTimeout(() => {
reloadTable();
});
@@ -414,6 +413,7 @@
}@{end}
@{ if eq .options.Step.IsOptionTreeTable true }
// 选中树节点
function handleSelected(keys, option) {
if (keys.length) {
selectedState.value = newState(option[0]);
@@ -423,10 +423,12 @@
}
}
// 展开指定节点
function handleOnExpandedKeys(keys) {
expandedKeys.value = keys;
}
// 展开全部节点
function handleAllExpanded() {
if (expandedKeys.value.length) {
expandedKeys.value = [];
@@ -445,10 +447,10 @@
});
}@{end}
@{ if eq .dictOptions.Has true }
@{ if or (eq .dictOptions.Has true) (eq .options.Step.IsOptionTreeTable true) }
onMounted(() => {
loadOptions();@{ if eq .options.Step.IsOptionTreeTable true }
firstLoadTreeOption();@{end}
@{ if eq .dictOptions.Has true }loadOptions();@{end}
@{ if eq .options.Step.IsOptionTreeTable true }firstLoadTreeOption();@{end}
});@{end}
</script>

View File

@@ -1,5 +1,7 @@
@{.import}
@{.const}
export class State {@{range .stateItems}
public @{.Name} = @{.DefaultValue}; // @{.Dc}@{end}
@@ -30,25 +32,9 @@ export function newState(state: State | Record<string, any> | null): State {
@{.columns}
@{ if eq .dictOptions.Has true }
// 字典数据选项
export const options = ref({
@{range .options.DictOps.Types} @{.}: [] as Option[],
@{end}});
// 加载字典数据选项
export function loadOptions() {
Dicts({
types: @{ToTSArray .options.DictOps.Types},
}).then((res) => {
options.value = res;
for (const item of schemas.value) {
switch (item.field) {@{range .options.DictOps.Schemas}
case '@{.Field}':
item.componentProps.options = options.value.@{.Type};
break;@{end}
}
}
});
dict.loadOptions(@{ToTSArray .options.DictOps.Types});
}
@{end}

View File

@@ -3,7 +3,7 @@
<n-drawer v-model:show="showModal" :width="dialogWidth">
<n-drawer-content title="@{.tableComment}详情" closable>
<n-spin :show="loading" description="请稍候...">
<n-descriptions label-placement="left" class="py-2" column="1">
<n-descriptions label-placement="left" class="py-2" :column="1">
@{.item}
</n-descriptions>
</n-spin>
@@ -16,11 +16,13 @@
import { computed, ref } from 'vue';
import { useMessage } from 'naive-ui';
import { View } from '@{.importWebApi}';
import { State, newState, options } from './model';
import { adaModalWidth, getOptionLabel, getOptionTag } from '@/utils/hotgo';
import { State, newState } from './model';
import { adaModalWidth } from '@/utils/hotgo';
import { getFileExt } from '@/utils/urlUtils';
@{ if eq .options.DictOps.Has true }import { useDictStore } from '@/store/modules/dict';@{end}
const message = useMessage();
@{ if eq .options.DictOps.Has true }const dict = useDictStore();@{end}
const loading = ref(false);
const showModal = ref(false);
const formValue = ref(newState(null));
@@ -34,11 +36,12 @@
};
});
//下载
// 下载
function download(url: string) {
window.open(url);
}
// 打开模态框
function openModal(state: State) {
showModal.value = true;
loading.value = true;