Browse Source

视频组件修改

yjf_v2
liwenxuan 2 years ago
parent
commit
f4b2191a48
  1. 21
      src/api/DesignForm/types.ts
  2. 10
      src/components/DesignForm/assembly/index.ts
  3. 156
      src/components/DesignForm/formControlAttr.vue
  4. 2
      src/components/DesignForm/public/form/form.vue
  5. 1
      src/components/DesignForm/public/form/formGroup.vue
  6. 33
      src/store/modules/lowcodevideo.ts
  7. 3
      src/views/sysworkflow/codepage/createform.vue
  8. 181
      src/widget/carousel/index.vue
  9. 40
      src/widget/carousel/lowcodeCarousel.vue
  10. 2
      src/widget/index.ts
  11. 4
      src/widget/videoupload/videoUploadPlay.vue

21
src/api/DesignForm/types.ts

@ -154,3 +154,24 @@ export interface PublicAtrr{
inputStyle?:string; inputStyle?:string;
vIf?:any; vIf?:any;
} }
//低代码视频单个属性对象
export interface VideoMsg {
CreatedAt: string
UpdatedAt: string
fileSize: bigint
id: bigint
key: string
name: string
physicspath: string
size: string
tag: string
type: number
url: string//视频地址
videoReady:boolean//当前视频是否成功上传
videoHeight?:number//视频高
videoWidth?:number//视频宽
videoAutoPlay:boolean//是否自动播放
attrId:string//字段标识 e.g : videoUpAndPlay1705024134559
poster?:string//海报帧url
loop:boolean//是否循环播放
}

10
src/components/DesignForm/assembly/index.ts

@ -316,6 +316,16 @@ const selectOption: any = [
modelValue: '' modelValue: ''
}, },
config: {} config: {}
},
{
type: 'lowcodeCarsusel',
label: '轮播图',
icon: '',
iconFont: 'fa-window-restore',
control: {
modelValue: ''
},
config: {}
} }
] ]
}, },

156
src/components/DesignForm/formControlAttr.vue

@ -588,13 +588,45 @@ const attrList = computed(() => {
path: 'config.componentName', path: 'config.componentName',
vShow: ['component'] vShow: ['component']
}, },
{
label: '轮播图设置',
value: config.carousel,
path: 'config.carousel',
type: 'carousel',
vIf: state.isSearch,
vShow: ['lowcodeCarsusel']
},
{ {
label: '上传视频', label: '上传视频',
value: config.disabledAdd, value: config.uploadvideo,
path: 'config.disabledAdd', path: 'config.uploadvideo',
type: 'uploadvideo', type: 'uploadvideo_url',
vIf: state.isSearch, vIf: state.isSearch,
vHide: ['uploadvideo'] vShow: ['videoUpAndPlay']
},
{
label: '视频自动播放',
value: config.uploadvideo,
path: 'config.uploadvideo',
type: 'uploadvideo_autoPlay',
vIf: state.isSearch,
vShow: ['videoUpAndPlay']
},
{
label: '视频高度',
value: config.uploadvideo,
path: 'config.uploadvideo',
type: 'uploadvideo_height',
vIf: state.isSearch,
vShow: ['videoUpAndPlay']
},
{
label: '视频宽度',
value: config.uploadvideo,
path: 'config.uploadvideo',
type: 'uploadvideo_width',
vIf: state.isSearch,
vShow: ['videoUpAndPlay']
}, },
{ {
label: '上传地址', label: '上传地址',
@ -1221,28 +1253,72 @@ const isNotWrite = (val:any) =>{
//liwenxuan 20240108 vidioupload start //liwenxuan 20240108 vidioupload start
import uselowcodevideoStore from '@/store/modules/lowcodevideo' import uselowcodevideoStore from '@/store/modules/lowcodevideo'
import { VideoMsg } from '@/api/DesignForm/types'
const lowcodevideoStore = uselowcodevideoStore(); const lowcodevideoStore = uselowcodevideoStore();
const videoAutoPlay = ref(false);
const videoHeight = ref(400);
const videoWidth = ref(700);
//const emits = defineEmits(["addedVideo"]); //const emits = defineEmits(["addedVideo"]);
// //
function videoUploadOk(response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) { function videoUploadOk(response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) {
//pinia //,videoMsg
lowcodevideoStore.videoResource = response.data.url; const videoMsg:VideoMsg = {
lowcodevideoStore.videoReady = true; CreatedAt: '',
UpdatedAt: '',
fileSize: 0n,
id: 0n,
key: '',
name: '',
physicspath: '',
size: '',
tag: '',
type: 0,
url: '',
videoAutoPlay: false,
videoReady: false,
attrId: '',
loop: false
}
videoMsg.url = response.data.url;
videoMsg.videoReady = true;
console.log(response) console.log(response)
console.log(lowcodevideoStore); console.log(lowcodevideoStore);
lowcodevideoStore.videoMsg.CreatedAt = response.data.CreatedAt; videoMsg.CreatedAt = response.data.CreatedAt;
lowcodevideoStore.videoMsg.UpdatedAt = response.data.UpdatedAt; videoMsg.UpdatedAt = response.data.UpdatedAt;
lowcodevideoStore.videoMsg.fileSize = response.data.fileSize; videoMsg.fileSize = response.data.fileSize;
lowcodevideoStore.videoMsg.id = response.data.id; videoMsg.id = response.data.id;
lowcodevideoStore.videoMsg.key = response.data.key; videoMsg.key = response.data.key;
lowcodevideoStore.videoMsg.name = response.data.name; videoMsg.name = response.data.name;
lowcodevideoStore.videoMsg.physicspath = response.data.physicspath; videoMsg.physicspath = response.data.physicspath;
lowcodevideoStore.videoMsg.size = response.data.size; videoMsg.size = response.data.size;
lowcodevideoStore.videoMsg.tag = response.data.tag; videoMsg.tag = response.data.tag;
lowcodevideoStore.videoMsg.type = response.data.type; videoMsg.type = response.data.type;
lowcodevideoStore.videoMsg.url = response.data.url;
//emits("addedVideo",videoArr) //emits("addedVideo",videoArr)''
console.log("response.data.url----2------>",response.data.url)
//formConfig.value["hjk"] = 250
console.log("formConfig----3------>",formConfig.value)
console.log("attrList----1------>",attrList.value)
if(attrList.value.length > 0){
attrList.value.forEach((item:any)=>{
// console.log("attrList---item-1------>",item.type)
console.log("attrList---item-1------>",item)
if(item.type === "uploadvideo_url"){
item.config={
videoConfig:[
{
videoUrl:response.data.url,
videoAutoPlay:videoAutoPlay,
videoHeight:videoHeight,
videoWidth:videoWidth
}
]
}
}
});
}
console.log("attrList---item-2------>",attrList.value)
} }
// //
@ -1265,6 +1341,23 @@ function videoUploadErr(error: Error, uploadFile: UploadFile, uploadFiles: Uploa
lowcodevideoStore.videoResource = resdurl; lowcodevideoStore.videoResource = resdurl;
} */ } */
//liwenxuan 20240108 vidioupload end //liwenxuan 20240108 vidioupload end
//liwenxuan 20240111 carousel start
const direction = ref('ltr')
const drawer = ref(false)
const handleClose = (done: () => void) => {
ElMessageBox.confirm('Are you sure you want to close this?')
.then(() => {
done()
})
.catch(() => {
// catch error
})
}
//liwenxuan 20240111 carousel end
</script> </script>
<template> <template>
<div class="sidebar-tools"> <div class="sidebar-tools">
@ -1273,7 +1366,7 @@ function videoUploadErr(error: Error, uploadFile: UploadFile, uploadFiles: Uploa
<el-form size="small" class="form"> <el-form size="small" class="form">
<div class=""><h3>通用属性</h3></div> <div class=""><h3>通用属性</h3></div>
<template v-for="(item, index) in attrList" :key="index"> <template v-for="(item, index) in attrList" :key="index">
{{ item.inputStyle }}
<el-form-item :label="item.label"> <el-form-item :label="item.label">
<el-select <el-select
v-if="item.type === 'select'" v-if="item.type === 'select'"
@ -1298,18 +1391,34 @@ function videoUploadErr(error: Error, uploadFile: UploadFile, uploadFiles: Uploa
v-model="item.value" v-model="item.value"
@change="controlChange(item, $event)" @change="controlChange(item, $event)"
/> />
<el-row v-else-if="item.type === 'uploadvideo'">
<el-row v-else-if="item.type === 'uploadvideo_url'">
<el-upload <el-upload
v-if="!lowcodevideoStore.videoReady" v-if="!lowcodevideoStore.videoReady"
:action="uploadUrl" :before-remove="beforeRemove" :action="uploadUrl" :before-remove="beforeRemove"
:on-success="videoUploadOk" :show-file-list="true" :on-success="videoUploadOk" :show-file-list="true"
:on-error="videoUploadErr" :on-error="videoUploadErr"
accept=".mp4,.MOV,.WMV,.FLV,.AVI,.AVCHD,.WebM,.MKV,.rmvb"> accept=".mp4,.MOV,.WMV,.FLV,.AVI,.AVCHD,.WebM,.MKV,.rmvb">
<el-button type="primary">点此上传</el-button> <el-button type="primary">点此上传</el-button>
</el-upload> </el-upload>
<el-button v-if="lowcodevideoStore.videoReady" type="primary">已上传</el-button> <el-button v-if="lowcodevideoStore.videoReady" type="primary">已上传,点击修改</el-button>
</el-row>
<el-row v-else-if="item.type === 'uploadvideo_autoPlay'">
<el-switch v-model="videoAutoPlay" />
</el-row>
<el-row v-else-if="item.type === 'uploadvideo_width'">
<el-input-number v-model="videoWidth" :step="50" :max="4096"/>
</el-row>
<el-row v-else-if="item.type === 'uploadvideo_height'">
<el-input-number v-model="videoHeight" :step="50" :max="2160"/>
</el-row> </el-row>
<el-row v-else-if="item.type === 'carousel'">
<el-button type="primary" append-to-body="true" modal="true" @click="drawer = true" >轮播图设置</el-button>
</el-row>
<el-input <el-input
v-else v-else
@ -1320,6 +1429,7 @@ function videoUploadErr(error: Error, uploadFile: UploadFile, uploadFiles: Uploa
/> />
</el-form-item> </el-form-item>
</template> </template>
<template v-if="controlData.config"> <template v-if="controlData.config">

2
src/components/DesignForm/public/form/form.vue

@ -164,7 +164,7 @@ const forEachGetFormModel = (list: FormList[], obj: any) => {
// tProp // tProp
provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) => { provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) => {
// console.log("--constControlChange-->",key, value, data, tProp,type,attribute) console.log("监听表单--constControlChange-->",key, value, data, tProp,type,attribute)
if (typeof props.changeKeyVal === 'function') { if (typeof props.changeKeyVal === 'function') {
props.changeKeyVal(key, value,type,attribute) props.changeKeyVal(key, value,type,attribute)
} }

1
src/components/DesignForm/public/form/formGroup.vue

@ -427,6 +427,7 @@ onMounted(()=>{
</template> </template>
<VideoUpAndPlay v-else-if="element.type === 'videoUpAndPlay'" :data="element" /> <VideoUpAndPlay v-else-if="element.type === 'videoUpAndPlay'" :data="element" />
<LowcodeCarsusel v-else-if="element.type === 'lowcodeCarsusel'" :data="element" />
<SignatureMap v-else-if="element.type === 'signaturemap'" :data="element" /> <SignatureMap v-else-if="element.type === 'signaturemap'" :data="element" />
<OrgCentent v-else-if="element.type === 'orgCentent'" :data="element" /> <OrgCentent v-else-if="element.type === 'orgCentent'" :data="element" />
<BaiduMap v-else-if="element.type === 'baidumap'" :data="element" /> <BaiduMap v-else-if="element.type === 'baidumap'" :data="element" />

33
src/store/modules/lowcodevideo.ts

@ -1,19 +1,7 @@
//定义组合式API仓库 //定义组合式API仓库
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { ref, computed,watch,reactive} from 'vue'; import { ref, computed,watch,reactive} from 'vue';
type VideoMsg = { import { VideoMsg } from '@/api/DesignForm/types'
CreatedAt: string
UpdatedAt: string
fileSize: bigint
id: bigint
key: string
name: string
physicspath: string
size: string
tag: string
type: number
url: string
}
/* type VideoObj = {} */ /* type VideoObj = {} */
@ -21,9 +9,9 @@ type VideoMsg = {
let uselowcodevideoStore = defineStore('lowcodevideo', () => { let uselowcodevideoStore = defineStore('lowcodevideo', () => {
//视频地址 //视频地址
const videoResource = ref<string>(); //const videoResource = ref<string>();
//是否上传成功 //是否上传成功
const videoReady = ref(false); //const videoReady = ref(false);
//成功后接受的视频详细信息 //成功后接受的视频详细信息
const videoMsg = reactive<VideoMsg>({ const videoMsg = reactive<VideoMsg>({
CreatedAt: '', CreatedAt: '',
@ -36,16 +24,23 @@ let uselowcodevideoStore = defineStore('lowcodevideo', () => {
size: '', size: '',
tag: '', tag: '',
type: 0, type: 0,
url: '' url: '',
videoAutoPlay:false,
videoHeight:400,
videoWidth:700,
videoReady:false,
attrId:'',//字段标识 e.g : videoUpAndPlay1705024134559
}); });
const videoMsgUse = reactive<VideoMsg[]>([])
const videoOnShowIndex = ref(0);//当当前表单有多个视频控件时,字段配置栏目前所展示的视频属性在pinia数组中的索引,用来在formControlAttr.vue中的dom属性上绑定显示数据
//表单视频信息数组 //表单视频信息数组
/* const videoArr = reactive<> */ /* const videoArr = reactive<> */
//务必要返回一个对象:属性与方法可以提供给组件使用 //务必要返回一个对象:属性与方法可以提供给组件使用
return { return {
videoReady, videoOnShowIndex,
videoResource, videoMsgUse,
videoMsg,
} }
}); });

3
src/views/sysworkflow/codepage/createform.vue

@ -890,6 +890,9 @@ const editversionstaus = (id:string) =>{
:customerformid="props.formid" :customerformid="props.formid"
@open-dialog="openAceEditDrawer" @open-dialog="openAceEditDrawer"
/> />
<!-- liwenxuan 轮播图设置界面 20240112 start -->
<!-- liwenxuan 轮播图设置界面 20240112 end -->
<ace-drawer <ace-drawer
v-model="drawer.visible" v-model="drawer.visible"
:title="drawer.title" :title="drawer.title"

181
src/widget/carousel/index.vue

@ -0,0 +1,181 @@
<!--
@ 作者: 李文轩
@ 时间: 2024-01-02 13:49:57
@ 备注:
-->
<template>
<el-form-item
v-bind="data.item"
:prop="tProp || data.name"
:class="config.className"
:rules="itemRules as any"
:label="getLabel(data.item as FormItem)"
>
<input v-model="value" type="hidden" >
</el-form-item>
<LowcodeCarousel></LowcodeCarousel>
</template>
<script lang='ts' setup>
import LowcodeCarousel from './lowcodeCarousel.vue';
import {
constControlChange,
constFormProps,
} from '@/api/DesignForm/utils'
import validate from '@/api/DesignForm/validate'
import { FormItem, FormList } from '@/api/DesignForm/types'
const props = withDefaults(
defineProps<{
data: FormList
tablekey: any
numrun?: number
modelValue?: any //
tProp?: string // form-itemprop
}>(),
{}
)
const emits = defineEmits<{
(e: 'update:modelValue', numVal: any): void
}>()
const formProps = inject(constFormProps, {}) as any
const type = computed(() => {
return formProps.value.type
})
const config = computed(() => {
return props.data.config || {}
})
const changeEvent = inject(constControlChange, '') as any
const value = computed({
get() {
if (props.tProp) {
//
return props.modelValue
} else {
return formProps.value.model[props.data.name]
}
},
set(newVal: any) {
if (props.tProp) {
emits('update:modelValue', newVal)
}
updateModel(newVal)
}
})
const updateModel = (val: any) => {
let controlAttribute = ""
if(props.data.control){
if(props.data.control.type){
controlAttribute = props.data.control.type
}
}
changeEvent &&
changeEvent({
key: props.data.name,
value: val,
data: props.data,
tProp: props.tProp,
type: props.data.type,
attribute: controlAttribute
})
}
const getLabel = (ele: FormItem) => {
const showColon = formProps.value.showColon ? ':' : ''
if (ele) {
return ele.showLabel ? '' : ele.label + showColon
} else {
return ''
}
}
// item
const itemRules = computed(() => {
let temp
const itemR: any = props.data.item?.rules || []
const customR = formatCustomRules()
// undefined
if (itemR?.length || customR?.length) {
temp = [...customR, ...itemR]
}
return temp
})
// customRulesrules
const formatCustomRules = () => {
const rulesReg: any = {}
validate &&
validate.forEach(item => {
rulesReg[item.type] = item.regExp
})
// 使provide
const temp: any = []
props.data.customRules?.forEach((item: any) => {
if (!item.message && item.type !== 'methods') {
return //
}
let obj = {}
if (item.type === 'required') {
obj = { required: true }
} else if (item.type === 'rules') {
//
obj = { pattern: item.rules }
} else if (item.type === 'methods') {
//
const methods: any = item.methods
if (methods) {
obj = { validator: inject(methods, {}) }
}
} else if (item.type) {
obj = { pattern: rulesReg[item.type as string] }
}
// push
let message: any = { message: item.message }
if (!item.message) {
// 使validatormessage使 callback(new Error('x'));
message = {}
}
temp.push(
Object.assign(
{
trigger: item.trigger || 'blur'
},
obj,
message
)
)
})
return temp
}
</script>
<style lang='scss' scoped>
.imgbox{
padding: 0 5px;
max-width: 300px;
max-height: 200px;
width: 100%;
height: 200px;
.image-slot {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
background: var(--el-fill-color-light);
color: var(--el-text-color-secondary);
font-size: 30px;
}
}
</style>

40
src/widget/carousel/lowcodeCarousel.vue

@ -0,0 +1,40 @@
<template>
<el-carousel class="lowcodeCarsousel">
<el-carousel-item v-for="item in 4" :key="item">
<h3 class="small justify-center" text="2xl">{{ item }}</h3>
</el-carousel-item>
</el-carousel>
</template>
<script setup lang="ts">
</script>
<style scoped>
.lowcodeCarsousel{
height:300px;
width:550px;
}
.demonstration {
color: var(--el-text-color-secondary);
}
.el-carousel__item h3 {
color: #475669;
opacity: 0.75;
line-height: 150px;
margin: 0;
text-align: center;
}
.el-carousel__item:nth-child(2n) {
background-color: #99a9bf;
}
.el-carousel__item:nth-child(2n + 1) {
background-color: #d3dce6;
}
</style>

2
src/widget/index.ts

@ -8,6 +8,7 @@ import baiduMap from './baidumap/index.vue'
import orgCentent from './org/index.vue' import orgCentent from './org/index.vue'
import signatureMap from './writingboard/index.vue' import signatureMap from './writingboard/index.vue'
import videoUpAndPlay from './videoupload/index.vue' import videoUpAndPlay from './videoupload/index.vue'
import lowcodeCarsusel from './carousel/index.vue'
export default (app: any) => { export default (app: any) => {
app.component('SerialNumber', serialNumber) app.component('SerialNumber', serialNumber)
@ -17,4 +18,5 @@ export default (app: any) => {
app.component('OrgCentent', orgCentent) app.component('OrgCentent', orgCentent)
app.component('SignatureMap', signatureMap) app.component('SignatureMap', signatureMap)
app.component('VideoUpAndPlay',videoUpAndPlay) app.component('VideoUpAndPlay',videoUpAndPlay)
app.component('LowcodeCarsusel',lowcodeCarsusel)
} }

4
src/widget/videoupload/videoUploadPlay.vue

@ -1,11 +1,13 @@
<template> <template>
<video :src="lowcodevideoStore.videoResource" loop controls style="width:70%;max-width: 800px;"></video> <video :src="videoUrl" loop controls></video>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import uselowcodevideoStore from '@/store/modules/lowcodevideo' import uselowcodevideoStore from '@/store/modules/lowcodevideo'
const lowcodevideoStore = uselowcodevideoStore(); const lowcodevideoStore = uselowcodevideoStore();
const videoUrl = "";
</script> </script>

Loading…
Cancel
Save