图片上传

master
lion 3 years ago
parent 86aac60c44
commit 4df083b62b

@ -2,5 +2,5 @@
ENV = 'development' ENV = 'development'
# base api # base api
#VUE_APP_BASE_API = https://yybtest.ali251.langye.net/ VUE_APP_BASE_API = https://yybtest.ali251.langye.net/
VUE_APP_BASE_API = https://yunyubang.ali251.langye.net/ #VUE_APP_BASE_API = https://yunyubang.ali251.langye.net/

@ -0,0 +1,9 @@
import request from '@/utils/request'
export function uploads(data) {
return request({
url: '/api/admin/upload-file',
method: 'post',
data
})
}

@ -30,3 +30,4 @@ export function getAuthMenu(token) {
params: { token } params: { token }
}) })
} }

@ -102,6 +102,7 @@ export default {
}, },
beforeUpload(file) { beforeUpload(file) {
console.log(file) console.log(file)
return
if((file.size/1000) > 1024){ if((file.size/1000) > 1024){
Message({ Message({
type:'warning', type:'warning',

@ -0,0 +1,142 @@
<template>
<div class="tinymce">
<Editor v-model="myValue" :init="init" :disabled="disabled"></Editor>
<EditorImage
:show="showImg"
class="tinymce__upload"
@successCBK="imageSuccessCBK"
@updateshow="updateshow"
></EditorImage>
</div>
</template>
<script>
import EditorImage from "@/components/XyTinymce/EditorImage.vue";
import tinymce from "tinymce/tinymce";
import Editor from "@tinymce/tinymce-vue";
import "tinymce/skins/ui/oxide/skin.css";
import "@/assets/tinymce/langs/zh_CN";
import "tinymce/themes/silver/theme";
import "tinymce/plugins/media";
import "tinymce/plugins/lists";
import "tinymce/plugins/table";
import "tinymce/plugins/hr";
import "tinymce/plugins/autolink";
import "tinymce/plugins/help";
import "tinymce/plugins/visualblocks";
import "tinymce/plugins/fullscreen";
import "tinymce/plugins/textpattern";
import "tinymce/plugins/contextmenu";
import "tinymce/plugins/wordcount";
import "tinymce/plugins/colorpicker";
import "tinymce/plugins/textcolor";
import "tinymce/icons/default"
import 'tinymce/plugins/code'
export default {
components: {
Editor,
EditorImage,
},
props: {
height: {
type: Number,
default: 300,
},
value: {
type: String,
default: "",
},
disabled: {
type: Boolean,
default: false,
},
plugins: {
type: [String, Array],
default:
"code paste preview searchreplace autolink directionality visualblocks visualchars fullscreen image template codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern help emoticons autosave ",
},
toolbar: {
type: [String, Array],
default: ` undo redo restoredraft | code | assignment | cut copy paste pastetext | forecolor backcolor bold italic underline strikethrough anchor | alignleft aligncenter alignright alignjustify outdent indent |
styleselect formatselect fontselect fontsizeselect | table image charmap emoticons hr pagebreak |bullist numlist | blockquote subscript superscript removeformat |
insertdatetime print preview | fullscreen | bdmap indent2em lineheight formatpainter axupimgs`,
},
menubar: {
type: String,
default: "edit insert view format table CardBtn",
},
},
data() {
return {
myValue: this.value,
showImg:false,
init: {
language_url: "@/asset/tinymce/langs/zh_CN.js", //
language: "zh_CN",
height: this.height,
plugins: this.plugins,
fontsize_formats: "8px 10px 12px 14px 16px 18px 24px 28px 36px",
toolbar: this.toolbar,
branding: false,
menubar: this.menubar,
setup: (editor) => {
let _this = this
// assignment toolbar
editor.ui.registry.addButton('assignment', {
text: `<i class="el-icon-position" style="font-size: 16px">上传</i>`,
// tooltip: '',
onAction: () => {
this.showImg = true
// _this.showEdit = true
},
})
},
//base64
//ajaxhttps://www.tiny.cloud/docs/configure/file-image-upload/#images_upload_handler
// images_upload_handler: (blobInfo, success, failure) => {
// const img = 'data:image/jpeg;base64,' + blobInfo.base64()
// success(img)
// },
},
};
},
methods: {
updateshow(val){
this.showImg = val
},
imageSuccessCBK(arr) {
console.log("arr",arr)
arr.forEach(
(v) => (this.myValue += `<img class="wscnph" src="${v.url}" >`)
);
},
},
computed: {},
mounted() {
tinymce.init({});
},
watch: {
value(newValue) {
this.myValue = newValue;
},
myValue(newValue) {
this.$emit("input", newValue);
},
},
};
</script>
<style scoped lang="scss">
.tinymce {
position: relative;
&__upload {
z-index: 2;
position: absolute;
right: 4px;
top: 0px;
}
::v-deep .tox.tox-tinymce.tox-fullscreen{
z-index:0
}
}
</style>

@ -1,17 +1,13 @@
<template> <template>
<div class="tinymce"> <div class="tinymce">
<Editor v-model="myValue" :init="init" :disabled="disabled"></Editor> <Editor v-model="myValue" :init="init" :disabled="disabled"></Editor>
<EditorImage
:show="showImg"
class="tinymce__upload"
@successCBK="imageSuccessCBK"
@updateshow="updateshow"
></EditorImage>
</div> </div>
</template> </template>
<script> <script>
import EditorImage from "@/components/XyTinymce/EditorImage.vue"; import {
uploads
} from '@/api/uploads.js'
import tinymce from "tinymce/tinymce"; import tinymce from "tinymce/tinymce";
import Editor from "@tinymce/tinymce-vue"; import Editor from "@tinymce/tinymce-vue";
import "tinymce/skins/ui/oxide/skin.css"; import "tinymce/skins/ui/oxide/skin.css";
@ -32,10 +28,11 @@ import "tinymce/plugins/colorpicker";
import "tinymce/plugins/textcolor"; import "tinymce/plugins/textcolor";
import "tinymce/icons/default" import "tinymce/icons/default"
import 'tinymce/plugins/code' import 'tinymce/plugins/code'
import "tinymce/plugins/image"
import "tinymce/plugins/imagetools"
export default { export default {
components: { components: {
Editor, Editor
EditorImage,
}, },
props: { props: {
height: { height: {
@ -52,13 +49,12 @@ export default {
}, },
plugins: { plugins: {
type: [String, Array], type: [String, Array],
default: default: "code image paste preview searchreplace autolink directionality visualblocks visualchars fullscreen template codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern help emoticons autosave ",
"code paste preview searchreplace autolink directionality visualblocks visualchars fullscreen image template codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern help emoticons autosave ",
}, },
toolbar: { toolbar: {
type: [String, Array], type: [String, Array],
default: ` undo redo restoredraft | code | assignment | cut copy paste pastetext | forecolor backcolor bold italic underline strikethrough anchor | alignleft aligncenter alignright alignjustify outdent indent | default: ` undo redo restoredraft | code | image | imagetools | assignment | cut copy paste pastetext | forecolor backcolor bold italic underline strikethrough anchor | alignleft aligncenter alignright alignjustify outdent indent |
styleselect formatselect fontselect fontsizeselect | table image charmap emoticons hr pagebreak |bullist numlist | blockquote subscript superscript removeformat | styleselect formatselect fontselect fontsizeselect | table charmap emoticons hr pagebreak | bullist numlist | blockquote subscript superscript removeformat |
insertdatetime print preview | fullscreen | bdmap indent2em lineheight formatpainter axupimgs`, insertdatetime print preview | fullscreen | bdmap indent2em lineheight formatpainter axupimgs`,
}, },
menubar: { menubar: {
@ -70,6 +66,7 @@ export default {
return { return {
myValue: this.value, myValue: this.value,
showImg: false, showImg: false,
imgUploadUrl: `${process.env.VUE_APP_BASE_API}/api/admin/upload-file`,
init: { init: {
language_url: "@/asset/tinymce/langs/zh_CN.js", // language_url: "@/asset/tinymce/langs/zh_CN.js", //
language: "zh_CN", language: "zh_CN",
@ -79,18 +76,25 @@ export default {
toolbar: this.toolbar, toolbar: this.toolbar,
branding: false, branding: false,
menubar: this.menubar, menubar: this.menubar,
setup: (editor) => { //
let _this = this images_upload_url: this.imgUploadUrl,
// assignment toolbar images_upload_handler: (blobInfo, success, failure) => {
editor.ui.registry.addButton('assignment', { this.handleImgUpload(blobInfo, success, failure);
text: `<i class="el-icon-position" style="font-size: 16px">上传</i>`,
// tooltip: '',
onAction: () => {
this.showImg = true
// _this.showEdit = true
},
})
}, },
// setup: (editor) => {
// let _this = this
// // assignment toolbar
// editor.ui.registry.addButton('assignment', {
// text: `<i class="el-icon-position" style="font-size: 16px"></i>`,
// // tooltip: '',
// onAction: () => {
// this.showImg = true
// // _this.showEdit = true
// },
// })
// },
//base64 //base64
//ajaxhttps://www.tiny.cloud/docs/configure/file-image-upload/#images_upload_handler //ajaxhttps://www.tiny.cloud/docs/configure/file-image-upload/#images_upload_handler
// images_upload_handler: (blobInfo, success, failure) => { // images_upload_handler: (blobInfo, success, failure) => {
@ -110,6 +114,27 @@ export default {
(v) => (this.myValue += `<img class="wscnph" src="${v.url}" >`) (v) => (this.myValue += `<img class="wscnph" src="${v.url}" >`)
); );
}, },
handleImgUpload(blobInfo, success, failure) {
console.log("我要上传", blobInfo);
let self = this;
let file = blobInfo.blob();
const isLt2M = file.size / 1024 < 1024;
if (!isLt2M) {
failure("上传失败图片不可超过1M!");
return false;
}
let formdate = new FormData();
formdate.append("file", blobInfo.blob()); //imageFile
uploads(formdate).then(res => {
if (res) {
let url = res.url;
success(url); //url
} else {
failure(res.errmsg);
this.$message.error(res.errmsg);
}
})
}
}, },
computed: {}, computed: {},
mounted() { mounted() {
@ -129,12 +154,14 @@ export default {
<style scoped lang="scss"> <style scoped lang="scss">
.tinymce { .tinymce {
position: relative; position: relative;
&__upload { &__upload {
z-index: 2; z-index: 2;
position: absolute; position: absolute;
right: 4px; right: 4px;
top: 0px; top: 0px;
} }
::v-deep .tox.tox-tinymce.tox-fullscreen { ::v-deep .tox.tox-tinymce.tox-fullscreen {
z-index: 0 z-index: 0
} }

@ -137,7 +137,7 @@ export default {
// align:"right" // align:"right"
// }, // },
{ {
label:"开放名额", label:"总活动名额",
width: 140, width: 140,
prop:'member_sum', prop:'member_sum',
formatter:(cell,data,value)=>{ formatter:(cell,data,value)=>{
@ -160,7 +160,7 @@ export default {
} }
}, },
{ {
label:"报名数", label:"报名数",
width: 140, width: 140,
prop:'total', prop:'total',
customFn: (cell) => { customFn: (cell) => {

@ -159,6 +159,25 @@
</div> </div>
</div> </div>
</template> </template>
<template v-slot:applyDate>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>预约报名日期
</div>
<div class="xy-table-item-content">
<el-date-picker
align='center'
style="width: 360px;"
v-model="form.applyDate"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</div>
</div>
</template>
<template v-slot:address> <template v-slot:address>
<div class="xy-table-item"> <div class="xy-table-item">
<div class="xy-table-item-label"> <div class="xy-table-item-label">
@ -202,7 +221,7 @@
<template v-slot:memberSum> <template v-slot:memberSum>
<div class="xy-table-item"> <div class="xy-table-item">
<div class="xy-table-item-label"> <div class="xy-table-item-label">
活动人数 活动人数
</div> </div>
<div class="xy-table-item-content"> <div class="xy-table-item-content">
<el-input-number :precision="0" :controls="false" v-model="form.memberSum" placeholder="请输入活动人数" clearable style="width: 300px;"></el-input-number> <el-input-number :precision="0" :controls="false" v-model="form.memberSum" placeholder="请输入活动人数" clearable style="width: 300px;"></el-input-number>
@ -229,25 +248,6 @@
</div> </div>
</div> </div>
</template> </template>
<template v-slot:applyDate>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>报名日期
</div>
<div class="xy-table-item-content">
<el-date-picker
align='center'
style="width: 360px;"
v-model="form.applyDate"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</div>
</div>
</template>
<!-- <template v-slot:money> <!-- <template v-slot:money>
<div class="xy-table-item"> <div class="xy-table-item">
<div class="xy-table-item-label"> <div class="xy-table-item-label">
@ -358,14 +358,16 @@ companykeyword:"",
recommend:"", recommend:"",
//slogan:"", //slogan:"",
date:"", date:"",
applyDate:[],
address:'', address:'',
relationName:"", relationName:"",
phoneNumber:"", phoneNumber:"",
group:"", group:"",
startMemberSum:"",
memberSum:"", memberSum:"",
startMemberSum:"",
greatServices:"", greatServices:"",
applyDate:[], // applyDate:[],
// money:0.00, // money:0.00,
activePlaybill:"", activePlaybill:"",
sort:0, sort:0,
@ -548,8 +550,8 @@ companykeyword:"",
relationName:res.relation_name, relationName:res.relation_name,
phoneNumber:res.phone_number, phoneNumber:res.phone_number,
group:res.group, group:res.group,
startMemberSum:res.start_member_sum,
memberSum:res.member_sum, memberSum:res.member_sum,
startMemberSum:res.start_member_sum,
greatServices:res.great_services, greatServices:res.great_services,
applyDate:[res.apply_start,res.apply_end], applyDate:[res.apply_start,res.apply_end],
// money:Number(res.money), // money:Number(res.money),
@ -557,6 +559,7 @@ companykeyword:"",
sort:res.sort, sort:res.sort,
content:res?.content, content:res?.content,
} }
}, },
compareDate(d1, d2) { compareDate(d1, d2) {
@ -566,12 +569,12 @@ companykeyword:"",
}, },
submit(){ submit(){
let start_date = this.form.date[0] let end_date = this.form.date[1]
let apply_end = this.form.applyDate[1] let apply_end = this.form.applyDate[1]
if(this.compareDate(apply_end,start_date)){ if(this.compareDate(apply_end,end_date)){
Message({ Message({
type:'warning', type:'warning',
message:'截止报名日期不能晚于活动开始日期' message:'截止报名日期不能晚于活动结束日期'
}) })
return return

@ -112,7 +112,7 @@ export default {
}).then(res => { }).then(res => {
Message({ Message({
type:'success', type:'success',
message:'新增活动成功' message:'新增活动关联方成功'
}) })
this.isShow = false this.isShow = false
this.$emit('refresh') this.$emit('refresh')
@ -128,7 +128,7 @@ export default {
}).then(res => { }).then(res => {
Message({ Message({
type:'success', type:'success',
message:'编辑活动成功' message:'编辑活动关联方成功'
}) })
this.isShow = false this.isShow = false
this.$emit('refresh') this.$emit('refresh')

@ -283,6 +283,7 @@
label: "客户服务地址", label: "客户服务地址",
width: 220, width: 220,
align: "left", align: "left",
prop:'customAddress',
customFn: (row) => { customFn: (row) => {
return ( <div style = { return ( <div style = {
{ {
@ -300,36 +301,25 @@
this.isShowEdit = true; this.isShowEdit = true;
} }
} }
} }>
>
{ {
row.order.member_address ? row.order.member_address : "修改服务地址" row.order.member_address ? row.order.member_address : "修改服务地址"
} </div> ) } </div> )
} }
}, },
{ {
label: "用户信息", prop: "member.name",
Fprop: 'member',
multiHd: [{
prop: "name",
label: "姓名", label: "姓名",
width: 110, width: 110
customFn: (row) => {
return (row.row.member?.name)
}
}, },
{ {
prop: "wechat_nickname", prop: "member.wechat_nickname",
label: "微信昵称", label: "微信昵称",
width: 110, width: 110
customFn: (row) => {
return (row.row.member?.wechat_nickname)
}
}, },
{ {
label: "头像", label: "头像",
prop:'member.avatar',
width: 80, width: 80,
customFn: (row) => { customFn: (row) => {
return ( < div style = { return ( < div style = {
@ -339,40 +329,27 @@
justifyContent: 'center' justifyContent: 'center'
} }
} > <el-avatar src = { } > <el-avatar src = {
row.row.member?.avatar row.member?.avatar
} > </el-avatar></div > ) } > </el-avatar></div > )
} }
}, },
{ {
prop: "phone", prop: "member.phone",
label: "联系电话", label: "联系电话",
width: 120, width: 120
customFn: (row) => {
return (row.row.member?.phone)
}
}, },
{ {
prop: "area", prop: "member.area",
label: "区域", label: "区域",
width: 110, width: 110
customFn: (row) => {
return (row.row.member?.area)
}
}, },
{ {
prop: "due_date", prop: "member.due_date",
label: "预产期", label: "预产期",
width: 120, width: 120
customFn: (row) => {
return (row.row.member?.due_date)
}
}
],
}, },
{ {
label: '订单明细',
multiHd: [{
prop: "product_type.name", prop: "product_type.name",
label: "产品类型", label: "产品类型",
width: 100 width: 100
@ -388,7 +365,7 @@
width: 160, width: 160,
align: "left", align: "left",
customFn: (row) => { customFn: (row) => {
return row.row.assign_merchant.map(item => { return row.assign_merchant.map(item => {
return ( <div> { return ( <div> {
item.username item.username
} </div>) } </div>)
@ -399,9 +376,101 @@
prop: "state_name", prop: "state_name",
label: "状态", label: "状态",
width: 120 width: 120
}
]
}, },
// {
// label: "",
// prop: 'member',
// multiHd: [{
// prop: "name",
// label: "",
// width: 110,
// customFn: (row) => {
// return (row.row.member?.name)
// }
// },
// {
// prop: "wechat_nickname",
// label: "",
// width: 110,
// customFn: (row) => {
// return (row.row.member?.wechat_nickname)
// }
// },
// {
// label: "",
// width: 80,
// customFn: (row) => {
// return ( < div style = {
// {
// display: 'flex',
// alignItems: 'center',
// justifyContent: 'center'
// }
// } > <el-avatar src = {
// row.row.member?.avatar
// } > </el-avatar></div > )
// }
// },
// {
// prop: "phone",
// label: "",
// width: 120,
// customFn: (row) => {
// return (row.row.member?.phone)
// }
// },
// {
// prop: "area",
// label: "",
// width: 110,
// customFn: (row) => {
// return (row.row.member?.area)
// }
// },
// {
// prop: "due_date",
// label: "",
// width: 120,
// customFn: (row) => {
// return (row.row.member?.due_date)
// }
// }
// ],
// },
// {
// label: '',
// prop:'orderInfo',
// multiHd: [{
// prop: "product_type.name",
// label: "",
// width: 100
// },
// {
// prop: "merchant.username",
// label: "",
// align: "left",
// width: 160
// },
// {
// label: "",
// width: 160,
// align: "left",
// customFn: (row) => {
// return row.row.assign_merchant.map(item => {
// return ( <div> {
// item.username
// } </div>)
// })
// }
// },
// {
// prop: "state_name",
// label: "",
// width: 120
// }
// ]
// },
{ {
prop: "order.member_comment", prop: "order.member_comment",
@ -521,6 +590,8 @@
merchant_id: this.select.merchant.id, merchant_id: this.select.merchant.id,
order_state: this.select.orderStates.key, order_state: this.select.orderStates.key,
member_id:this.memberId, member_id:this.memberId,
sort_name:'paid_at',
sort_type:'DESC',
...this.select ...this.select
}) })
this.select.is_merchant = is_merchant; this.select.is_merchant = is_merchant;

@ -948,6 +948,9 @@ export default {
::v-deep .el-input__inner { ::v-deep .el-input__inner {
text-align: left; text-align: left;
} }
::v-deep .avue-dialog{
z-index:2374
}
</style> </style>
<style> <style>
.avatar-uploader .el-upload { .avatar-uploader .el-upload {

Loading…
Cancel
Save