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

50 lines
1.3 KiB
Vue
Raw Normal View History

2026-06-09 17:49:15 +08:00
<template>
2026-06-10 16:23:47 +08:00
<ali-oss-uploader v-model="currentValue" :max-count="maxCount" :max-size="maxSize" accept="image/*" :userId="userId"
2026-06-11 20:48:30 +08:00
:type="ossType" width="100%" :sortable="true" @input="onInput" @change="onChange" />
2026-06-09 17:49:15 +08:00
</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: 'FormItemImage',
2026-06-10 16:23:47 +08:00
components: { AliOssUploader },
2026-06-09 17:49:15 +08:00
props: {
2026-06-10 10:15:10 +08:00
value: { type: Array, default: function () { return []; } },
2026-06-10 16:23:47 +08:00
maxCount: { type: Number, default: 9 },
maxSize: { type: Number, default: 5 }
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 = Array.isArray(val) ? val.slice() : [];
2026-06-09 17:49:15 +08:00
},
immediate: true
}
},
methods: {
2026-06-10 16:23:47 +08:00
onInput: function (list) {
this.$emit('input', list);
2026-06-09 17:49:15 +08:00
},
2026-06-10 16:23:47 +08:00
onChange: function (list) {
this.$emit('change', list);
2026-06-09 17:49:15 +08:00
}
}
};
</script>