Browse Source

修改图片上传操作

lwx_v4
超级管理员 1 year ago
parent
commit
5c88a12475
  1. 4
      src/components/DesignForm/app/formPage.vue
  2. 2
      src/components/DesignForm/public/form/form.vue
  3. 2
      src/components/DesignForm/public/form/form2.vue
  4. 11
      src/components/DesignForm/public/form/formGroup.vue
  5. 4
      src/components/DesignForm/public/form/formItem.vue
  6. 24
      src/widget/lowcodeimage/index.vue
  7. 112
      src/widget/lowcodeimage/lowcodeImage.vue

4
src/components/DesignForm/app/formPage.vue

@ -1063,7 +1063,7 @@ function optionsValue3Get2(data: any,fieldName: string){
}"
>
<FormGroup :tableinfo="formData.form" :numrun="numrun" :data="formData.list" :purview="formData.powerstr" :node-key="nodeKey" />
<FormGroup :tableinfo="formData.form" :numrun="numrun" :data="formData.list" :alldata="formData" :purview="formData.powerstr" :node-key="nodeKey" />
<slot></slot>
</el-form>
@ -1088,7 +1088,7 @@ function optionsValue3Get2(data: any,fieldName: string){
}"
>
<FormGroup :tableinfo="formData.form" :numrun="numrun" :data="formData.list" @optionsValue3Get2="optionsValue3Get2"/>
<FormGroup :tableinfo="formData.form" :numrun="numrun" :data="formData.list" :alldata="formData" @optionsValue3Get2="optionsValue3Get2"/>
<slot></slot>
</el-form>

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

@ -1633,7 +1633,7 @@ defineExpose({
}"
>
<FormGroup :tableinfo="formData.form" :numrun="numrun" :data="formData.list" @optionsValue3Get2="optionsValue3Get2"/>
<FormGroup :tableinfo="formData.form" :numrun="numrun" :data="formData.list" :alldata="formData" @optionsValue3Get2="optionsValue3Get2"/>
<slot></slot>
</el-form>

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

@ -489,7 +489,7 @@ watch(
'detail-form': type === 3 || type === 4
}"
>
<FormGroup :data="formData.list" />
<FormGroup :data="formData.list" :alldata="formData" />
<slot></slot>
</el-form>
</div>

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

@ -28,6 +28,7 @@ const props = withDefaults(
numrun?:number
nodeKey?:string
purview?:any[]
alldata?:any
}>(),
{
data: () => {
@ -372,7 +373,7 @@ onUnmounted(() => {
store.setControlAttr({})
})
onMounted(()=>{
console.log('非设计模式才触发事件',props.nodeKey,"---------------->",props.purview)
// console.log('',props.nodeKey,"---------------->",props.purview)
// console.log('formGroup onMounted',props.data,dataList.value,props.tableinfo)
})
@ -389,7 +390,7 @@ function optionsValue3Get1(data: any,fieldName: string){
</script>
<template>
<draggable
itemKey="id"
:list="dataList"
@ -573,10 +574,12 @@ function optionsValue3Get1(data: any,fieldName: string){
<!--拥有者-->
<OwnerPage v-else-if="element.type === 'owner'" :data="element" :tablekey="props.tableinfo" :numrun="props.numrun" />
<!--所属部门-->
<DeptOrgPage v-else-if="element.type === 'deptOrg'" :data="element" :tablekey="props.tableinfo" :numrun="props.numrun" />
<DeptOrgPage v-else-if="element.type === 'deptOrg'" :data="element" :form-props="formProps" :tablekey="props.tableinfo" />
<DigitPage v-else-if="element.type === 'digitpage'" :data="element" />
<AssociatedForms v-else-if="element.type === 'associatedForms'" :data="element" :form-props="formProps" :tablekey="props.tableinfo" />
<LowcodeImage v-else-if="element.type === 'lowcodeImage'" :data="element" />
<LowcodeImage v-else-if="element.type === 'lowcodeImage'" :data="element" :tablekey="props.tableinfo" :form-table-set-up="props.alldata" >
</LowcodeImage>
<LowcodeTransfer v-else-if="element.type === 'lowcodeTransfer'" :data="element" />
<VideoUpAndPlay v-else-if="element.type === 'videoUpAndPlay'" :data="element" />
<LowcodeCarsusel v-else-if="element.type === 'lowcodeCarsusel'" :data="element" />

4
src/components/DesignForm/public/form/formItem.vue

@ -531,7 +531,7 @@ const imgUploadApiUrl = import.meta.env.VITE_APP_BASE_API+"/api/upordown"
@ 功能: 判断此组件是否可见
*/
const judgeIsShow = (key:string) => {
console.log("判断此组件是否可见---->",props.nodeKey,props.purview)
// console.log("---->",props.nodeKey,props.purview)
if(props.nodeKey != undefined && props.purview != undefined && props.purview != null && props.purview != null && props.purview != "" && props.purview != "") {
if(props.purview.length < 1){
return true;
@ -543,7 +543,7 @@ const judgeIsShow = (key:string) => {
if(item.powerAry && item.powerAry.length > 0){
item.powerAry.forEach((itm)=>{
if(itm.id == key){
console.log("判断此组件是否可见",itm,itm.id == key,"--------->",itm.isLook)
// console.log("",itm,itm.id == key,"--------->",itm.isLook)
isShow = itm.isLook
}

24
src/widget/lowcodeimage/index.vue

@ -4,6 +4,7 @@
@ 备注:
-->
<template>
<div>
<el-form-item
v-bind="data.item"
:prop="tProp || data.name"
@ -11,10 +12,10 @@
:rules="itemRules as any"
:label="getLabel(data.item as FormItem)"
>
<input v-model="value" type="hidden" >
<el-input v-show="false" v-model="value" placeholder="请输入"></el-input>
</el-form-item>
<LowcodeImage :data="props.data"></LowcodeImage>
<LowcodeImage :data="props.data" :imgUrl="value" :tablekey="props.tablekey" :form-table-set-up="props.formTableSetUp" @updateCont= "updateCont" ></LowcodeImage>
</div>
</template>
<script lang='ts' setup>
import LowcodeImage from './lowcodeImage.vue';
@ -31,6 +32,7 @@ const props = withDefaults(
numrun?: number
modelValue?: any //
tProp?: string // form-itemprop
formTableSetUp?:any
}>(),
{}
)
@ -54,8 +56,9 @@ const value = computed({
//
return props.modelValue
} else {
return formProps.value.model[props.data.name]
return formProps.value.model[props.data.name]?formProps.value.model[props.data.name]:props.data.control.imgUrl
}
// return 107
},
set(newVal: any) {
if (props.tProp) {
@ -154,8 +157,15 @@ const formatCustomRules = () => {
/**
@ 作者: 秦东
@ 时间: 2024-07-30 13:29:15
@ 功能: 更新数据
*/
const updateCont = (val:any) =>{
//console.log("---->",val)
value.value = val
}
@ -178,4 +188,4 @@ const formatCustomRules = () => {
font-size: 30px;
}
}
</style>
</style>

112
src/widget/lowcodeimage/lowcodeImage.vue

@ -1,21 +1,30 @@
<template>
<img referrerpolicy="no-referrer" :src="url" :style="styleObject" :fit="fit" :class="[boderAndShadowClassIsActive ? boderAndShadowClass : '', radiusClassIsActive ? radiusClass : '',mp, floatFlag ? floatStyle : '']" @click="handleLink(props.data?.control)" />
</template>
<script setup >
import errimg from '@/assets/404_images/imgNotFound.png'
import { uploadUrl,getRequest } from '@/api/DesignForm'
const props = defineProps({
// eslint-disable-next-line vue/require-default-prop
tablekey:{
type: Object,
default(){
return {}
}
},
data: {
type: Object,
}
default(){
return {}
}
},
formTableSetUp:{
type: Object,
default(){
return {}
}
},
imgUrl:{
type:String,
default:""
}
})
/*
@ -23,11 +32,15 @@ const props = defineProps({
let styleObject = {
}
let url = props.data?.control.imgUrl
const emits = defineEmits(["updateCont"]);
const url = ref(props.data?.control.imgUrl?props.data?.control.imgUrl:props.imgUrl)
if(props.data?.control.imgUrl===''){
url = errimg
url.value = errimg
}else{
url = props.data?.control.imgUrl
url.value = props.data?.control.imgUrl
}
const fitNum = props.data?.control.fit
@ -122,7 +135,76 @@ function handleLink(item){
window.open(url, '_blank')
}
//
const beforeAvatarUpload = (rawFile) => {
// console.log("",rawFile.type)
let imgType = ['image/jpeg','image/jpg','image/png','image/gif','image/svg']
if (!imgType.includes(rawFile.type)) {
ElMessage.error('您上传的不是图片!')
return false
} else if (rawFile.size / 1024 / 1024 > 200) {
ElMessage.error('您上传到额图片大于 200MB!')
return false
}
return true
}
//
const handleAvatarSuccess = (
response,
uploadFile
) => {
// imageUrl.value = URL.createObjectURL(uploadFile.raw!)
// console.log("",response,uploadFile)
url.value = response.data.url
let oldFormSetUp = props.formTableSetUp
if(props.formTableSetUp && props.formTableSetUp.list && props.formTableSetUp.list.length > 0){
oldFormSetUp.list.forEach((item)=>{
if(item.name && item.name == props.data.name){
item.control.imgUrl = response.data.url
item.control.link = response.data.url
}
})
}
// props.setimgurl=response.data.url
// emits("update:setimgurl",response.data.url)
// console.log("------>",oldFormSetUp)
emits("updateCont",response.data.url)
}
watch(() =>props.imgUrl,(val)=>{
// console.log("props.imgUrl.value ",props.data.control.link && (props.data.control.link == "" || props.data.control.link == "undefined") )
if(props.imgUrl && props.imgUrl != "" && props.imgUrl != "undefined"){
url.value = props.imgUrl
if((props.data.control.link == "" || props.data.control.link == "undefined") ){
props.data.control.link = props.imgUrl
}
}
},{ deep: true });
</script>
<template>
<div>
<img v-if="url!=errimg" referrerpolicy="no-referrer" :src="url" :style="styleObject" :fit="fit" :class="[boderAndShadowClassIsActive ? boderAndShadowClass : '', radiusClassIsActive ? radiusClass : '',mp, floatFlag ? floatStyle : '']" @click="handleLink(props.data?.control)" />
<el-upload
v-else
class="upload-demo"
:action="uploadUrl"
:limit="1"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
>
<img referrerpolicy="no-referrer" :src="url" :style="styleObject" :fit="fit" :class="[boderAndShadowClassIsActive ? boderAndShadowClass : '', radiusClassIsActive ? radiusClass : '',mp, floatFlag ? floatStyle : '']" />
</el-upload>
</div>
</template>
<style>
.boderAndShadow {

Loading…
Cancel
Save