2023-01-18 16:23:39 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
2023-02-08 20:29:34 +08:00
|
|
|
<n-spin :show="loading" description="请稍候...">
|
|
|
|
<n-modal
|
2023-12-29 20:08:00 +08:00
|
|
|
v-model:show="showModal"
|
|
|
|
:mask-closable="false"
|
2023-02-08 20:29:34 +08:00
|
|
|
:show-icon="false"
|
|
|
|
preset="dialog"
|
2023-12-29 20:08:00 +08:00
|
|
|
transform-origin="center"
|
|
|
|
:title="formValue.@{.pk.TsName} > 0 ? '编辑 #' + formValue.@{.pk.TsName} : '添加'"
|
2023-02-08 20:29:34 +08:00
|
|
|
:style="{
|
|
|
|
width: dialogWidth,
|
|
|
|
}"
|
2023-01-18 16:23:39 +08:00
|
|
|
>
|
2023-12-29 20:08:00 +08:00
|
|
|
<n-scrollbar style="max-height: 87vh" class="pr-5">
|
|
|
|
<n-form
|
|
|
|
:model="formValue"
|
|
|
|
:rules="rules"
|
|
|
|
ref="formRef"
|
|
|
|
:label-placement="settingStore.isMobile ? 'top' : 'left'"
|
|
|
|
:label-width="100"
|
|
|
|
class="py-4"
|
|
|
|
>
|
|
|
|
@{.formItem}
|
|
|
|
</n-form>
|
|
|
|
</n-scrollbar>
|
2023-01-18 16:23:39 +08:00
|
|
|
<template #action>
|
|
|
|
<n-space>
|
|
|
|
<n-button @click="closeForm">取消</n-button>
|
|
|
|
<n-button type="info" :loading="formBtnLoading" @click="confirmForm">确定</n-button>
|
|
|
|
</n-space>
|
|
|
|
</template>
|
2023-02-08 20:29:34 +08:00
|
|
|
</n-modal>
|
|
|
|
</n-spin>
|
2023-01-18 16:23:39 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
@{.script.import} import { rules, options, State, newState } from './model';
|
2023-12-29 20:08:00 +08:00
|
|
|
import { useProjectSettingStore } from '@/store/modules/projectSetting';
|
2023-01-18 16:23:39 +08:00
|
|
|
import { useMessage } from 'naive-ui';
|
|
|
|
import { adaModalWidth } from '@/utils/hotgo';
|
|
|
|
|
2023-12-29 20:08:00 +08:00
|
|
|
const emit = defineEmits(['reloadTable']);
|
2023-01-18 16:23:39 +08:00
|
|
|
const message = useMessage();
|
2023-12-29 20:08:00 +08:00
|
|
|
const settingStore = useProjectSettingStore();
|
2023-01-18 16:23:39 +08:00
|
|
|
const dialogWidth = ref('75%');
|
2023-12-29 20:08:00 +08:00
|
|
|
const loading = ref(false);
|
|
|
|
const showModal = ref(false);
|
|
|
|
const formValue = ref<State>(newState(null));
|
|
|
|
const formRef = ref<any>({});
|
2023-01-18 16:23:39 +08:00
|
|
|
const formBtnLoading = ref(false);
|
|
|
|
|
|
|
|
function confirmForm(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
formBtnLoading.value = true;
|
|
|
|
formRef.value.validate((errors) => {
|
|
|
|
if (!errors) {
|
2023-12-29 20:08:00 +08:00
|
|
|
Edit(formValue.value).then((_res) => {
|
2023-01-18 16:23:39 +08:00
|
|
|
message.success('操作成功');
|
|
|
|
setTimeout(() => {
|
2023-12-29 20:08:00 +08:00
|
|
|
showModal.value = false;
|
2023-01-18 16:23:39 +08:00
|
|
|
emit('reloadTable');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
message.error('请填写完整信息');
|
|
|
|
}
|
|
|
|
formBtnLoading.value = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeForm() {
|
2023-12-29 20:08:00 +08:00
|
|
|
showModal.value = false;
|
|
|
|
loading.value = false;
|
2023-01-18 16:23:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@{.script.setup}
|
2023-12-29 20:08:00 +08:00
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
openModal,
|
|
|
|
});
|
2023-01-18 16:23:39 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less"></style>
|