mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-01-24 11:36:27 +08:00
100 lines
2.2 KiB
Go
100 lines
2.2 KiB
Go
|
<template>
|
||
|
<div>
|
||
|
<n-modal
|
||
|
v-model:show="isShowModal"
|
||
|
:show-icon="false"
|
||
|
preset="dialog"
|
||
|
:title="params?.@{.pk.TsName} > 0 ? '编辑 #' + params?.@{.pk.TsName} : '新建'"
|
||
|
:style="{
|
||
|
width: dialogWidth,
|
||
|
}"
|
||
|
>
|
||
|
<n-form
|
||
|
:model="params"
|
||
|
:rules="rules"
|
||
|
ref="formRef"
|
||
|
label-placement="left"
|
||
|
:label-width="80"
|
||
|
class="py-4"
|
||
|
>
|
||
|
@{.formItem}
|
||
|
</n-form>
|
||
|
<template #action>
|
||
|
<n-space>
|
||
|
<n-button @click="closeForm">取消</n-button>
|
||
|
<n-button type="info" :loading="formBtnLoading" @click="confirmForm">确定</n-button>
|
||
|
</n-space>
|
||
|
</template>
|
||
|
</n-modal>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script lang="ts" setup>
|
||
|
@{.script.import} import { rules, options, State, newState } from './model';
|
||
|
import { useMessage } from 'naive-ui';
|
||
|
import { adaModalWidth } from '@/utils/hotgo';
|
||
|
|
||
|
const emit = defineEmits(['reloadTable', 'updateShowModal']);
|
||
|
|
||
|
interface Props {
|
||
|
showModal: boolean;
|
||
|
formParams?: State;
|
||
|
}
|
||
|
|
||
|
const props = withDefaults(defineProps<Props>(), {
|
||
|
showModal: false,
|
||
|
formParams: () => {
|
||
|
return newState(null);
|
||
|
},
|
||
|
});
|
||
|
|
||
|
const isShowModal = computed({
|
||
|
get: () => {
|
||
|
return props.showModal;
|
||
|
},
|
||
|
set: (value) => {
|
||
|
emit('updateShowModal', value);
|
||
|
},
|
||
|
});
|
||
|
|
||
|
const params = computed(() => {
|
||
|
return props.formParams;
|
||
|
});
|
||
|
|
||
|
const message = useMessage();
|
||
|
const formRef = ref<any>({});
|
||
|
const dialogWidth = ref('75%');
|
||
|
const formBtnLoading = ref(false);
|
||
|
|
||
|
function confirmForm(e) {
|
||
|
e.preventDefault();
|
||
|
formBtnLoading.value = true;
|
||
|
formRef.value.validate((errors) => {
|
||
|
if (!errors) {
|
||
|
Edit(params.value).then((_res) => {
|
||
|
message.success('操作成功');
|
||
|
setTimeout(() => {
|
||
|
isShowModal.value = false;
|
||
|
emit('reloadTable');
|
||
|
});
|
||
|
});
|
||
|
} else {
|
||
|
message.error('请填写完整信息');
|
||
|
}
|
||
|
formBtnLoading.value = false;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
onMounted(async () => {
|
||
|
adaModalWidth(dialogWidth);
|
||
|
});
|
||
|
|
||
|
function closeForm() {
|
||
|
isShowModal.value = false;
|
||
|
}
|
||
|
|
||
|
@{.script.setup}
|
||
|
</script>
|
||
|
|
||
|
<style lang="less"></style>
|