mirror of
				https://github.com/bufanyun/hotgo.git
				synced 2025-11-04 16:23:43 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			86 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
<template>
 | 
						|
  <div>
 | 
						|
    <n-spin :show="loading" description="请稍候...">
 | 
						|
      <n-modal
 | 
						|
        v-model:show="showModal"
 | 
						|
        :mask-closable="false"
 | 
						|
        :show-icon="false"
 | 
						|
        preset="dialog"
 | 
						|
        transform-origin="center"
 | 
						|
        :title="formValue.@{.pk.TsName} > 0 ? '编辑 #' + formValue.@{.pk.TsName} : '添加'"
 | 
						|
        :style="{
 | 
						|
          width: dialogWidth,
 | 
						|
        }"
 | 
						|
      >
 | 
						|
        <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>
 | 
						|
        <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>
 | 
						|
    </n-spin>
 | 
						|
  </div>
 | 
						|
</template>
 | 
						|
 | 
						|
<script lang="ts" setup>
 | 
						|
@{.script.import}  import { rules, options, State, newState } from './model';
 | 
						|
  import { useProjectSettingStore } from '@/store/modules/projectSetting';
 | 
						|
  import { useMessage } from 'naive-ui';
 | 
						|
  import { adaModalWidth } from '@/utils/hotgo';
 | 
						|
 | 
						|
  const emit = defineEmits(['reloadTable']);
 | 
						|
  const message = useMessage();
 | 
						|
  const settingStore = useProjectSettingStore();
 | 
						|
  const dialogWidth = ref('75%');
 | 
						|
  const loading = ref(false);
 | 
						|
  const showModal = ref(false);
 | 
						|
  const formValue = ref<State>(newState(null));
 | 
						|
  const formRef = ref<any>({});
 | 
						|
  const formBtnLoading = ref(false);
 | 
						|
 | 
						|
  function confirmForm(e) {
 | 
						|
    e.preventDefault();
 | 
						|
    formBtnLoading.value = true;
 | 
						|
    formRef.value.validate((errors) => {
 | 
						|
      if (!errors) {
 | 
						|
        Edit(formValue.value).then((_res) => {
 | 
						|
          message.success('操作成功');
 | 
						|
          setTimeout(() => {
 | 
						|
            showModal.value = false;
 | 
						|
            emit('reloadTable');
 | 
						|
          });
 | 
						|
        });
 | 
						|
      } else {
 | 
						|
        message.error('请填写完整信息');
 | 
						|
      }
 | 
						|
      formBtnLoading.value = false;
 | 
						|
    });
 | 
						|
  }
 | 
						|
 | 
						|
  function closeForm() {
 | 
						|
    showModal.value = false;
 | 
						|
    loading.value = false;
 | 
						|
  }
 | 
						|
 | 
						|
@{.script.setup}
 | 
						|
 | 
						|
  defineExpose({
 | 
						|
    openModal,
 | 
						|
  });
 | 
						|
</script>
 | 
						|
 | 
						|
<style lang="less"></style>
 |