wupengfei
2025-04-02 d82fea569f9bb487364d667cdf3af626cf06f20e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<template>
  <ProDialog
    title="批量减员"
    v-model="innerVisible"
    destroy-on-close
    draggable
    bodyNoPaddingBottom
    @close="onDialogClose"
  >
    <ProForm :model="form" ref="dialogForm" label-width="120px">
      <ProFormItemV2 label="保单号:" prop="orderNo" :check-rules="[{ message: '请输入保单号' }]">
        <ProFormText
          placeholder="请输入保单号"
          v-model.trim="form.orderNo"
          :maxlength="30"
        ></ProFormText>
      </ProFormItemV2>
      <ProFormItemV2
        label="上传增员名单:"
        prop="url"
        :check-rules="[{ message: '请上传增员名单', type: 'upload' }]"
      >
        <ProFormUpload v-model:file-url="form.url" :limit="1" :limitFileSize="10" accept="xlsx,xls">
          <el-button style="margin-right: 10px" type="primary" size="small" icon="Upload"
            >文件上传</el-button
          >
          <el-button
            style="margin-left: 10px"
            type="primary"
            link
            @click.stop="downloadImportEntryStaff"
            >模板下载</el-button
          >
        </ProFormUpload>
      </ProFormItemV2>
    </ProForm>
    <template #footer>
      <span class="dialog-footer">
        <el-button type="primary" @click="handleConfirm">确 定</el-button>
      </span>
    </template>
  </ProDialog>
</template>
 
<script setup lang="ts">
import { InsuranceOrderTempPath } from '@/constants';
import {
  ProDialog,
  UploadUserFile,
  ProForm,
  ProFormItemV2,
  ProFormText,
  ProFormUpload,
} from '@bole-core/components';
import { downloadFileByUrl, Message } from '@bole-core/core';
import { FormInstance } from 'element-plus';
 
defineOptions({
  name: 'BatchDownsizingDialog',
});
 
type Props = {
  modelValue: boolean;
  form?: {
    checkOrderNo: string;
    orderNo: string;
    url: UploadUserFile[];
    downsizingInsuranceList: string[];
  };
};
 
const props = withDefaults(defineProps<Props>(), {
  modelValue: false,
});
 
const emit = defineEmits<{
  (e: 'update:modelValue', value: boolean): void;
  (e: 'update:form', value: Props['form']): void;
  (e: 'onConfirm'): void;
  (e: 'onCancel'): void;
}>();
 
const innerVisible = computed({
  get() {
    return props.modelValue;
  },
  set(val) {
    emit('update:modelValue', val);
  },
});
 
const innerForm = computed({
  get() {
    return props.form;
  },
  set(val) {
    emit('update:form', val);
  },
});
 
const dialogForm = ref<FormInstance>();
 
function onDialogClose() {
  if (!dialogForm.value) return;
  dialogForm.value.resetFields();
}
 
function handleConfirm() {
  if (!dialogForm.value) return;
  dialogForm.value.validate((valid) => {
    if (valid) {
      if (innerForm.value.orderNo !== innerForm.value.checkOrderNo) {
        Message.errorMessage('保单号不一致,减员失败');
        return;
      }
      emit('onConfirm');
    } else {
      return;
    }
  });
}
 
function downloadImportEntryStaff() {
  downloadFileByUrl(InsuranceOrderTempPath, '保单导入模板');
}
</script>