|
|
@@ -124,12 +124,13 @@
|
|
|
<el-input v-model="onboardForm.scene_directions" type="textarea" :rows="3"
|
|
|
placeholder="谁/通过什么媒介(APP/web/小程序)/主要为谁提供什么服务/用于在什么场景给什么人群转账" maxlength="1024" show-word-limit />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="场景截图" prop="scene_image" required>
|
|
|
- <el-upload ref="uploadRef" :action="''" :auto-upload="false"
|
|
|
- :file-list="onboardFiles" :on-change="handleOnboardFileChange" :limit="5"
|
|
|
- list-type="picture-card" accept="image/*,.pdf">
|
|
|
+ <el-form-item label="转账场景截图" prop="scene_image" required>
|
|
|
+ <el-upload ref="uploadRef" :http-request="handleOnboardUpload" :file-list="onboardFiles"
|
|
|
+ :limit="5" list-type="picture-card" accept=".jpg,.jpeg,.png,.pdf"
|
|
|
+ :before-upload="handleBeforeUpload" :on-remove="handleOnboardFileRemove">
|
|
|
<el-icon><Plus /></el-icon>
|
|
|
</el-upload>
|
|
|
+ <div class="upload-tip">支持 jpg / png / pdf,最多 5 个文件</div>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="站点信息">
|
|
|
<el-checkbox-group v-model="onboardSiteTypes">
|
|
|
@@ -858,6 +859,7 @@ const SITE_TYPE_OPTIONS = [
|
|
|
const onboardFormRef = ref<FormInstance>();
|
|
|
const onboardLoading = ref(false);
|
|
|
const onboardFiles = ref<any[]>([]);
|
|
|
+const onboardImageIds = ref<string[]>([]);
|
|
|
const uploadRef = ref();
|
|
|
const onboardSiteTypes = ref<string[]>([]);
|
|
|
const onboardSites = reactive<Record<string, string>>({});
|
|
|
@@ -873,26 +875,53 @@ const onboardRules: FormRules = {
|
|
|
scene_directions: [{ required: true, message: "请填写场景说明", trigger: "blur" }],
|
|
|
};
|
|
|
|
|
|
-function handleOnboardFileChange(file: any) {
|
|
|
- onboardFiles.value.push(file);
|
|
|
+const ALLOWED_EXTENSIONS = [".jpg", ".jpeg", ".png", ".pdf"];
|
|
|
+
|
|
|
+function handleBeforeUpload(file: File) {
|
|
|
+ const ext = "." + file.name.split(".").pop()?.toLowerCase();
|
|
|
+ if (!ALLOWED_EXTENSIONS.includes(ext)) {
|
|
|
+ ElMessage.error("仅支持 jpg / png / pdf 格式");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (file.size > 5 * 1024 * 1024) {
|
|
|
+ ElMessage.error("文件大小不能超过 5MB");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+/** 自定义上传 — 选图即调用 image.upload */
|
|
|
+async function handleOnboardUpload(option: any) {
|
|
|
+ try {
|
|
|
+ const res = await AccountAPI.uploadImage(option.file, currentEnterpriseId.value!);
|
|
|
+ const imageId = res.data.data?.image_id;
|
|
|
+ if (imageId) {
|
|
|
+ onboardImageIds.value.push(imageId);
|
|
|
+ option.onSuccess();
|
|
|
+ } else {
|
|
|
+ option.onError(new Error("上传失败"));
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ option.onError(e);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function handleOnboardFileRemove(_file: any, fileList: any) {
|
|
|
+ // 移除对应位置的 image_id
|
|
|
+ const idx = fileList.findIndex((f: any) => f.uid === _file.uid);
|
|
|
+ if (idx >= 0) onboardImageIds.value.splice(idx, 1);
|
|
|
}
|
|
|
|
|
|
async function handleOnboardSubmit() {
|
|
|
if (!onboardFormRef.value) return;
|
|
|
await onboardFormRef.value.validate(async (valid) => {
|
|
|
if (!valid) return;
|
|
|
- if (onboardFiles.value.length === 0) {
|
|
|
- ElMessage.warning("请上传场景截图");
|
|
|
+ if (onboardImageIds.value.length === 0) {
|
|
|
+ ElMessage.warning("请上传转账场景截图");
|
|
|
return;
|
|
|
}
|
|
|
onboardLoading.value = true;
|
|
|
try {
|
|
|
- const imageIds: string[] = [];
|
|
|
- for (const f of onboardFiles.value) {
|
|
|
- const res = await AccountAPI.uploadImage(f.raw, currentEnterpriseId.value!);
|
|
|
- const id = res.data.data?.image_id;
|
|
|
- if (id) imageIds.push(id);
|
|
|
- }
|
|
|
// 构建 sites JSON
|
|
|
let sites: string | undefined;
|
|
|
if (onboardSiteTypes.value.length > 0) {
|
|
|
@@ -906,7 +935,7 @@ async function handleOnboardSubmit() {
|
|
|
enterprise_id: currentEnterpriseId.value!,
|
|
|
scene_code: onboardForm.scene_code,
|
|
|
scene_directions: onboardForm.scene_directions,
|
|
|
- scene_image: imageIds.join(","),
|
|
|
+ scene_image: onboardImageIds.value.join(","),
|
|
|
sites,
|
|
|
alipay_user_id: enterpriseStore.getCurrentEnterprise?.identity || "",
|
|
|
});
|
|
|
@@ -927,6 +956,7 @@ async function handleOnboardSubmit() {
|
|
|
function handleOnboardReset() {
|
|
|
onboardFormRef.value?.resetFields();
|
|
|
onboardFiles.value = [];
|
|
|
+ onboardImageIds.value = [];
|
|
|
onboardSiteTypes.value = [];
|
|
|
Object.keys(onboardSites).forEach(k => delete onboardSites[k]);
|
|
|
}
|