Commit bc495238 by Jaxon

fix(marketingPushStrategy): 修复表单验证及上传配置问题

为营销推送策略相关组件做以下优化:
1.  在actionsItem组件注入elForm实例,在消息类型切换时触发对应表单项校验
2.  优化pageConfig组件的上传功能:拆分图片和视频的上传大小限制,更新上传提示文案与表单校验规则
1 parent 7283ebfc
......@@ -54,14 +54,17 @@
</template>
<script>
import { isFunction } from "lodash-es";
import MessageType from "@/views/marketingManagement/marketingPushStrategy/components/messageType";
import { MessageTypeEnum } from "@/views/marketingManagement/marketingPushStrategy/constant";
export default {
name: "",
components: {
MessageType,
},
inject: ["elForm"],
props: {
showDelActionBtn: {
type: Boolean,
......@@ -148,8 +151,13 @@ export default {
handleActionTypeChange(e) {
this.$emit("input", { ...this.item, actionType: e });
},
handleMessageTypeChange(e) {
async handleMessageTypeChange(e) {
this.$emit("input", e);
if (this?.elForm?.validateField && isFunction(this?.elForm?.validateField)) {
await this.$nextTick();
this?.elForm?.validateField(`${this.propPrefix}.messageType`);
}
},
handleRemoveActions() {
this.$emit("remove");
......
......@@ -53,9 +53,10 @@
accept="image/jpeg,image/png,image/bmp,video/mp4"
list-type="text"
type="file"
:file-size="50"
:limit="10"
:show-file-list="false"
@beforeUpload="handleBeforeUpload"
@beforeUploadValidate="handleBeforeUploadValidate"
@change="handleUploadChange"
@error="handleUploadError"
@progress="handleUploadProgress"
......@@ -69,7 +70,7 @@
</div>
</template>
</VenusOssUpload>
<el-popover content="支持JPG\JPEG\PNG\BMP\MP4格式"
<el-popover content="支持JPG/JPEG/PNG/BMP/MP4格式,图片不超过10M,视频不超过50M"
placement="top-start"
trigger="hover">
<i slot="reference" class="el-icon-warning-outline"></i>
......@@ -200,7 +201,7 @@ export default {
{ required: true, message: "请选择素材间隔", trigger: ["change"] },
],
materialJson: [
{ required: true, message: "请上传素材", trigger: ["change"] },
{ required: true, message: "请至少上传1个图片或视频", trigger: ["change"] },
],
},
......@@ -287,6 +288,20 @@ export default {
percentage: 0,
};
},
handleBeforeUploadValidate(payload) {
if (!payload) {
return;
}
if (payload.fileType === "image") {
payload.maxFileSize = 10;
payload.message = "仅允许上传不超过10M的图片";
return;
}
if (payload.fileType === "video") {
payload.maxFileSize = 50;
payload.message = "仅允许上传不超过50M的视频";
}
},
handleBeforeUpload(file) {
if (!file)
return;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!