wupengfei
2 天以前 5e9f3642abe24502ded3668515bea220e0fc5190
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<template>
  <ProDialog
    title="批量登记"
    v-model="visible"
    @close="onDialogClose"
    destroy-on-close
    draggable
    width="700px"
  >
    <ProForm :model="form" ref="dialogForm" label-width="120px">
      <ProFormItemV2 prop="ids" class="pro-form-item-label-hidden">
        <div class="batchEntryRewardBody">
          <el-transfer
            v-model="deleteList"
            filterable
            :filter-method="filterMethod"
            filter-placeholder="请输入搜索内容"
            :data="form.companyList"
            :titles="['登记', '不登记']"
            :props="prop"
            @change="handleChange"
          />
        </div>
      </ProFormItemV2>
      <ProFormItemV2 label="登记类型:" prop="incomeType" required>
        <ProFormRadio
          v-model="form.incomeType"
          :value-enum="incomeTypeEnum"
          :button-style="false"
          @change="handleIncomeTypeChange"
        />
      </ProFormItemV2>
      <ProFormItemV2
        label="登记金额:"
        prop="amount"
        :check-rules="[{ message: '请输入登记金额', type: 'number' }]"
      >
        <ProFormInputNumber
          v-model="form.amount"
          :controls="false"
          :min="0"
          unit="元"
          :precision="2"
        ></ProFormInputNumber>
      </ProFormItemV2>
      <ProFormItemV2
        label="上传登记凭证:"
        prop="fileUrl"
        :check-rules="[{ message: '请上传登记凭证', type: 'upload' }]"
      >
        <ProFormUpload
          v-model:file-url="form.fileUrl"
          :limitFileSize="50"
          accept="doc,docx,pdf,xls,xlsx,jpg/jpeg,png"
        ></ProFormUpload>
      </ProFormItemV2>
    </ProForm>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="emit('onCancel')">取 消</el-button>
        <el-button type="primary" @click="handleConfirm">确 定</el-button>
      </span>
    </template>
  </ProDialog>
</template>
 
<script setup lang="ts">
import { FormInstance, TransferPropsAlias } from 'element-plus';
import {
  ProDialog,
  ProForm,
  ProFormItemV2,
  ProFormInputNumber,
  ProFormRadio,
  ProFormUpload,
  UploadUserFile,
} from '@bole-core/components';
import { Message } from '@bole-core/core';
import { IncomeTypeEnumText, IncomeTypeEnum } from '@/constants';
import * as parkBountyApplyServices from '@/services/api/ParkBountyApply';
 
defineOptions({
  name: 'BatchRegisterDialog',
});
 
type Props = {
  /**
   * @deprecated
   */
  financeSumAmount?: number;
};
 
const props = withDefaults(defineProps<Props>(), {});
 
const visible = defineModel({ type: Boolean });
 
type Form = {
  title?: string;
  parkBountyApplyDetailIds: string[];
  amount: number;
  companyList: API.GetNotTransferCompanyNameListOutput[];
  incomeType: IncomeTypeEnum;
  parkBountyApplyId: string;
  showSuportPlatRecharge: boolean;
 
  fileUrl: UploadUserFile[];
};
 
const form = defineModel<Form>('form');
 
const incomeTypeEnum = computed(() => {
  return [
    {
      label: IncomeTypeEnumText[IncomeTypeEnum.Fiscal],
      value: IncomeTypeEnum.Fiscal,
    },
    form.value.showSuportPlatRecharge && {
      label: IncomeTypeEnumText[IncomeTypeEnum.Platform],
      value: IncomeTypeEnum.Platform,
    },
  ].filter(Boolean);
});
 
const deleteList = ref<string[]>([]);
 
watch(visible, (value, oldValue) => {
  if (value && !oldValue) {
    getParkBountyApplyBatchFinanceEnterprise();
  }
});
 
async function getParkBountyApplyBatchTransferEnterprise() {
  try {
    let res = await parkBountyApplyServices.getParkBountyApplyBatchTransferRegEnterprise({
      parkBountyApplyId: form.value.parkBountyApplyId,
    });
    if (res) {
      form.value.companyList = res;
      form.value.parkBountyApplyDetailIds = res.map((x) => x.parkBountyApplyDetailId);
      deleteList.value = [];
    }
  } catch (error) {}
}
 
async function getParkBountyApplyBatchFinanceEnterprise() {
  try {
    let res = await parkBountyApplyServices.getParkBountyApplyBatchFinanceRegEnterprise({
      parkBountyApplyId: form.value.parkBountyApplyId,
    });
    if (res) {
      form.value.companyList = res;
      form.value.parkBountyApplyDetailIds = res.map((x) => x.parkBountyApplyDetailId);
      deleteList.value = [];
    }
  } catch (error) {}
}
function handleIncomeTypeChange() {
  if (form.value.incomeType === IncomeTypeEnum.Fiscal) {
    getParkBountyApplyBatchFinanceEnterprise();
  } else {
    getParkBountyApplyBatchTransferEnterprise();
  }
}
 
function handleChange(ids: string[]) {
  form.value.parkBountyApplyDetailIds = form.value.companyList
    .filter((item) => !ids.includes(item.companyId))
    .map((item) => item.parkBountyApplyDetailId);
}
 
const emit = defineEmits<{
  (e: 'onConfirm'): void;
  (e: 'onCancel'): void;
}>();
 
const dialogForm = ref<FormInstance>();
 
function onDialogClose() {
  if (!dialogForm.value) return;
  dialogForm.value.resetFields();
}
 
function handleConfirm() {
  if (!form.value.parkBountyApplyDetailIds.length) {
    Message.warnMessage('请选择入账企业');
    return;
  }
  if (!dialogForm.value) return;
  dialogForm.value.validate((valid) => {
    if (valid) {
      emit('onConfirm');
    } else {
      return;
    }
  });
}
 
const prop = {
  label: 'name',
  key: 'companyId',
} as TransferPropsAlias;
 
const filterMethod = (query: string, item: API.GetCompanyNameListOutput) => {
  return item.name.toLowerCase().includes(query.toLowerCase());
};
</script>
 
<style lang="scss" scoped>
.batchEntryRewardBody {
  display: flex;
  justify-content: center;
  width: 100%;
}
</style>