mrr.sj.front/components/dynamic-form/FormItemVideo.vue

97 lines
2.0 KiB
Vue
Raw Normal View History

2026-06-09 17:49:15 +08:00
<template>
2026-06-10 16:23:47 +08:00
<view>
<ali-oss-uploader v-if="!currentValue" :max-count="1" :max-size="maxSize" accept="video/*" :userId="userId"
:type="ossType" width="100%" @input="onInput" @change="onChange" />
<view v-else class="video-wrapper">
<video :src="currentValue" class="preview-video" controls />
2026-06-09 17:49:15 +08:00
<view class="delete-btn" @click="deleteVideo">
<text class="delete-icon">&times;</text>
</view>
</view>
</view>
</template>
<script>
2026-06-10 16:23:47 +08:00
import AliOssUploader from '../ali-oss-uploader/ali-oss-uploader.vue'
2026-06-09 17:49:15 +08:00
export default {
2026-06-10 10:15:10 +08:00
name: 'FormItemVideo',
2026-06-10 16:23:47 +08:00
components: { AliOssUploader },
2026-06-09 17:49:15 +08:00
props: {
2026-06-10 16:23:47 +08:00
value: { type: String, default: '' },
maxSize: { type: Number, default: 100 }
2026-06-09 17:49:15 +08:00
},
2026-06-10 10:15:10 +08:00
data: function () {
2026-06-09 17:49:15 +08:00
return {
2026-06-10 16:23:47 +08:00
currentValue: ''
2026-06-09 17:49:15 +08:00
};
},
2026-06-10 16:23:47 +08:00
computed: {
userId: function () {
return this.$store && this.$store.state && this.$store.state.sjInfo
? this.$store.state.sjInfo.id : null;
},
ossType: function () {
var artisanType = getApp().globalData ? getApp().globalData.artisanType : 0;
return (artisanType || 0) + 1;
}
},
2026-06-09 17:49:15 +08:00
watch: {
value: {
2026-06-10 10:15:10 +08:00
handler: function (val) {
2026-06-10 16:23:47 +08:00
this.currentValue = val || '';
2026-06-09 17:49:15 +08:00
},
immediate: true
}
},
methods: {
2026-06-10 16:23:47 +08:00
onInput: function (val) {
this.currentValue = val;
this.$emit('input', val);
},
onChange: function (val) {
this.$emit('change', val);
2026-06-09 17:49:15 +08:00
},
2026-06-10 10:15:10 +08:00
deleteVideo: function () {
2026-06-10 16:23:47 +08:00
this.currentValue = '';
2026-06-10 10:15:10 +08:00
this.$emit('input', '');
2026-06-09 17:49:15 +08:00
}
}
};
</script>
<style scoped>
2026-06-10 16:23:47 +08:00
.video-wrapper {
position: relative;
2026-06-10 10:15:10 +08:00
width: 200rpx;
height: 200rpx;
2026-06-09 17:49:15 +08:00
}
2026-06-10 10:15:10 +08:00
.preview-video {
width: 200rpx;
height: 200rpx;
2026-06-09 17:49:15 +08:00
border-radius: 8rpx;
}
2026-06-10 10:15:10 +08:00
2026-06-09 17:49:15 +08:00
.delete-btn {
position: absolute;
2026-06-10 16:23:47 +08:00
top: -10rpx;
right: -10rpx;
2026-06-10 10:15:10 +08:00
width: 40rpx;
height: 40rpx;
2026-06-10 16:23:47 +08:00
background-color: #ff4d4f;
color: white;
2026-06-09 17:49:15 +08:00
border-radius: 50%;
display: flex;
justify-content: center;
2026-06-10 16:23:47 +08:00
align-items: center;
font-size: 32rpx;
z-index: 1;
2026-06-09 17:49:15 +08:00
}
2026-06-10 10:15:10 +08:00
2026-06-09 17:49:15 +08:00
.delete-icon {
color: #ffffff;
font-size: 32rpx;
}
</style>