Commit 7bead4a4 authored by zhengke's avatar zhengke

双击 替换图

parent d838a7d1
...@@ -53,17 +53,17 @@ ...@@ -53,17 +53,17 @@
</template> </template>
<div class="addTemplateBox q-mb-lg fz14"> <div class="addTemplateBox q-mb-lg fz14">
<div class="row flex-end q-mb-lg"> <div class="row flex-end q-mb-lg">
<!-- :limit="1" -->
<el-button type="primary" size="small" style="color: #ffff;"> <el-button type="primary" size="small" style="color: #ffff;">
<el-upload <el-upload
ref="upload" ref="upload"
:on-change="(uploadFile:any, uploadFiles:any)=> uploadFontHandler(uploadFile, uploadFiles,datas.params.fontFamily)" :on-change="(uploadFile:any, uploadFiles:any)=> uploadFontHandler(uploadFile, uploadFiles,datas.params.fontFamily)"
action="" action=""
multiple :limit="1"
:auto-upload="false" :auto-upload="false"
accept=".ttf, .woff, otf" accept=".ttf, .woff, otf"
:show-file-list="false" :show-file-list="false"
:on-exceed="handleExceed"> :on-exceed="handleExceed"
>
<template #trigger> <template #trigger>
<span class="text-white">{{datas.params.id?'替换':'上传'}}字体</span> <span class="text-white">{{datas.params.id?'替换':'上传'}}字体</span>
</template> </template>
...@@ -90,13 +90,13 @@ ...@@ -90,13 +90,13 @@
</div> </div>
</div> </div>
<div class="text-center"> <div class="text-center">
<el-button class="MarketIndexButtom MarketRec" type="primary" @click="ConfirmCreation(0)" <el-button class="MarketIndexButtom MarketRec" type="primary" @click="ConfirmCreation"
:loading="requestLoading"> :loading="requestLoading">
确认{{datas.params.id?'编辑':'新增'}} 确认{{datas.params.id?'编辑':'新增'}}
</el-button> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, ref, inject, onMounted, watch} from "vue"; import { reactive, ref, inject, onMounted, watch} from "vue";
...@@ -149,7 +149,6 @@ ...@@ -149,7 +149,6 @@
const fonts = ref<{fontFamily:string,uploadType:number,selectedFont?:string}[]>() const fonts = ref<{fontFamily:string,uploadType:number,selectedFont?:string}[]>()
const uploadingIndex = ref(-1) const uploadingIndex = ref(-1)
const upload = ref<UploadInstance>() const upload = ref<UploadInstance>()
const fliesNum = ref(0 as number)
const close = () => { const close = () => {
datas.params = { datas.params = {
...@@ -169,7 +168,7 @@ ...@@ -169,7 +168,7 @@
upload.value.submit() upload.value.submit()
} }
const ConfirmCreation = async (type:any) => { const ConfirmCreation = async () => {
//添加、编辑字体 //添加、编辑字体
if(!datas.params.label)return ElMessage({ if(!datas.params.label)return ElMessage({
message:'请输入名称', message:'请输入名称',
...@@ -195,9 +194,7 @@ ...@@ -195,9 +194,7 @@
message: `操作${datas.params.label}成功`, message: `操作${datas.params.label}成功`,
type: 'success', type: 'success',
}) })
if(fliesNum.value) fliesNum.value-- datas.addEditVisible = false
if(!type||(type&&!fliesNum.value)) datas.addEditVisible = false
console.log(fliesNum.value,'----4')
datas.requestLoading = false datas.requestLoading = false
querySearchHandler() querySearchHandler()
}else{ }else{
...@@ -205,8 +202,6 @@ ...@@ -205,8 +202,6 @@
message:'字体上传失败,请重试', message:'字体上传失败,请重试',
type:'error' type:'error'
}) })
if(fliesNum.value) fliesNum.value--
console.log(fliesNum.value,'----5')
datas.requestLoading = false datas.requestLoading = false
} }
} }
...@@ -263,8 +258,6 @@ ...@@ -263,8 +258,6 @@
} }
const uploadFontHandler = async (uploadFile:any, uploadFiles:any, fontName:string) => { const uploadFontHandler = async (uploadFile:any, uploadFiles:any, fontName:string) => {
fliesNum.value = uploadFiles.length
console.log(fliesNum.value,'----0')
const ns = uploadFile.name.toLowerCase().split('.') const ns = uploadFile.name.toLowerCase().split('.')
const n = ns[ns.length-1] const n = ns[ns.length-1]
const acceptFile = ['ttf','otf','woff'] const acceptFile = ['ttf','otf','woff']
...@@ -272,8 +265,6 @@ ...@@ -272,8 +265,6 @@
ElMessage.error({ ElMessage.error({
message:`不支持此类文件上传,目前只支持${acceptFile.join(',')}等文件上传` message:`不支持此类文件上传,目前只支持${acceptFile.join(',')}等文件上传`
}) })
if(fliesNum.value) fliesNum.value--
console.log(fliesNum.value,'----01')
return; return;
} }
uploadingIndex.value = dataList.value?.findIndex(x=>x.fontFamily==fontName)??-1 uploadingIndex.value = dataList.value?.findIndex(x=>x.fontFamily==fontName)??-1
...@@ -284,8 +275,6 @@ ...@@ -284,8 +275,6 @@
} catch (error) { } catch (error) {
ElMessage.error({message:'字体无法识别,请更换'}) ElMessage.error({message:'字体无法识别,请更换'})
uploadingIndex.value=-1 uploadingIndex.value=-1
if(fliesNum.value) fliesNum.value--
console.log(fliesNum.value,'----1')
return return
} }
...@@ -293,8 +282,6 @@ ...@@ -293,8 +282,6 @@
if(flagIndex>0){ if(flagIndex>0){
ElMessage.error({message:`${info.name} 字体已存在,请选择使用已有字体`}) ElMessage.error({message:`${info.name} 字体已存在,请选择使用已有字体`})
uploadingIndex.value=-1 uploadingIndex.value=-1
if(fliesNum.value) fliesNum.value--
console.log(fliesNum.value,'----2')
return return
} }
let url = await FileService.uploadToFontServerAsync(uploadFile?.raw) let url = await FileService.uploadToFontServerAsync(uploadFile?.raw)
...@@ -315,18 +302,16 @@ ...@@ -315,18 +302,16 @@
datas.params.fontUrl = url datas.params.fontUrl = url
datas.params.reduceName = reduceName datas.params.reduceName = reduceName
datas.params.reduceUrl = reduceUrl datas.params.reduceUrl = reduceUrl
await ConfirmCreation(1) await ConfirmCreation()
}else{ }else{
ElMessage({ ElMessage({
message:'上传失败,请重试', message:'上传失败,请重试',
type:'error' type:'error'
}) })
if(fliesNum.value) fliesNum.value--
console.log(fliesNum.value,'----3')
} }
} catch (error) { } catch (error) {
} }
} }
const tableScrollHandler = ()=>{ const tableScrollHandler = ()=>{
if(queryObj.pageCount>queryObj.pageIndex){ if(queryObj.pageCount>queryObj.pageIndex){
queryObj.value.pageIndex++ queryObj.value.pageIndex++
...@@ -350,8 +335,8 @@ ...@@ -350,8 +335,8 @@
} catch (error) { } catch (error) {
loading.value = false loading.value = false
} }
} }
querySearchHandler() querySearchHandler()
</script> </script>
<style scoped> <style scoped>
......
...@@ -112,7 +112,7 @@ const { filter } = useFilter(filters) ...@@ -112,7 +112,7 @@ const { filter } = useFilter(filters)
const { imgReplaceVisible } = storeToRefs(useScreenStore()) const { imgReplaceVisible } = storeToRefs(useScreenStore())
const openDataReplace = () => { const openDataReplace = () => {
imgReplaceVisible.value = true if(!props.elementInfo.lock) imgReplaceVisible.value = true
} }
const handleSelectElement = (e: MouseEvent | TouchEvent) => { const handleSelectElement = (e: MouseEvent | TouchEvent) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment