Browse Source

共享图片接口对接

luckysheet_xiaowang
是小王呀\24601 6 months ago
parent
commit
dff4b103cd
  1. 126
      src/views/modules/base/smartExcel/cpts/picture-add.vue
  2. 105
      src/views/modules/base/smartExcel/cpts/picture-collection.vue

126
src/views/modules/base/smartExcel/cpts/picture-add.vue

@ -11,7 +11,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="图片集封面" label-width="150px" prop="fileList"> <el-form-item label="图片集封面" label-width="150px" prop="coverPicture">
<template> <template>
<upload-image :defaultFileList="fileList" :limit="1" @change="onChangeFileList" <upload-image :defaultFileList="fileList" :limit="1" @change="onChangeFileList"
@file-removed="removedImg"></upload-image> @file-removed="removedImg"></upload-image>
@ -33,7 +33,7 @@
</div> </div>
<div class="div_btn"> <div class="div_btn">
<el-button size="small" @click="handleCancle"> </el-button> <el-button size="small" @click="handleCancle"> </el-button>
<el-button size="small" v-if="formType != 'detail'" type="primary" :disabled="btnDisable" <el-button size="small" type="primary"
@click="handleComfirm"> </el-button> @click="handleComfirm"> </el-button>
</div> </div>
@ -80,8 +80,10 @@
label:"本级和直接上下级组织共享" label:"本级和直接上下级组织共享"
}, },
], ],
formType:"add",
formData: formData:
{ {
coverPicture:"", coverPicture:"",
albumName:"", albumName:"",
sharedScope:"" sharedScope:""
@ -97,27 +99,15 @@
components: {Tinymce, UploadImage }, components: {Tinymce, UploadImage },
mounted() { mounted() {
this.activityType()
this.listServerOrg() this.listServerOrg()
}, },
methods: { methods: {
async activityType() {
this.$nextTick(() => {
if (!map) {
this.initMap(this.formData.latitude, this.formData.longitude);
console.log("map", map,this.formData.latitude, this.formData.longitude)
} else {
map.setCenter(this.formData.latitude, this.formData.longitude);
map.setMarker(this.formData.latitude, this.formData.longitude);
console.log("mapmapmap", map)
}
})
},
removedImg() { removedImg() {
this.formData.coverPic = '' this.formData.coverPicture = ''
}, },
onChangeFileList(e) { onChangeFileList(e) {
this.startLoading()
console.log(e, 'sssssb'); console.log(e, 'sssssb');
this.fileList = e.length > 0 ? e.map(item => ({ this.fileList = e.length > 0 ? e.map(item => ({
fileType: '0', fileType: '0',
@ -128,21 +118,21 @@
} else { } else {
this.formData.coverPicture = ''; this.formData.coverPicture = '';
} }
this.endLoading()
}, },
async initForm(type, activityId) { async initForm(type, activityId) {
this.startLoading() this.startLoading()
this.formType = type this.formType = type
console.log(type,activityId,"进行修改"); console.log(type,activityId,"进行修改");
if (type === 'edit') { if (type === 'edit') {
this.formData = activityId this.formData = activityId
if (activityId.coverPic) { if (activityId.coverPicture) {
let ob = { let ob = {
fileType: '0', fileType: '0',
fileUrl: activityId.coverPic fileUrl: activityId.coverPicture
}; };
this.fileList = [ob]; this.fileList = [ob];
this.formData.coverPic = ob.fileUrl; this.formData.coverPicture = ob.fileUrl;
} }
} else { } else {
@ -150,74 +140,20 @@
this.endLoading() this.endLoading()
}, },
async handleComfirm() {
async getDemandOptions() { if(!this.formData.albumName){
this.$http return this.$message.error("请输入图片集名称")
.post("/actual/base/serviceitem/listAllCategory",{})
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg);
} else {
console.log(res.data);
this.demandOptions = this.getFlagData(
this.getTreeData(res.data),
"usableFlag"
);
}
})
.catch(() => {
return this.$message.error("网络错误");
});
},
getFlagData(data, flag) {
if (!Array.isArray(data)) return [];
let arr1 = data.filter((item) => item[flag]);
let arr2 = arr1.map((item) => {
if (item.childCateList)
return { ...item, childCateList: this.getFlagData(item.childCateList, flag) };
else return item;
});
return arr2;
},
getTreeData(data) {
if (!Array.isArray(data)) return [];
let arr = data.map((item) => {
let _item = {};
if (item.childCateList) {
if (item.childCateList.length === 0)
_item = { ...item, childCateList: undefined };
else _item = { ...item, childCateList: this.getTreeData(item.childCateList) };
} else {
_item = { ...item };
}
return _item;
});
return arr;
},
async loadGrid() {
const url = "/gov/org/customergrid/gridoption"
let params = {
agencyId: this.agencyId
} }
if(!this.formData.coverPicture){
const { data, code, msg } = await requestPost(url, params) return this.$message.error("请上传封面图片")
}
if (code === 0) { if(!this.formData.sharedScope){
this.gridList = data return this.$message.error("请选择共享范围")
} else {
this.$message.error(msg)
} }
},
async handleComfirm() {
this.addActivity() this.addActivity()
}, },
async addActivity() { async addActivity() {
if(this.formType=="add"){
let url = '/actual/base/albums/save' let url = '/actual/base/albums/save'
const { data, code, msg } = await requestPost(url, this.formData) const { data, code, msg } = await requestPost(url, this.formData)
if (code === 0) { if (code === 0) {
@ -228,12 +164,22 @@
} else { } else {
this.$message.error(msg) this.$message.error(msg)
} }
console.log("sdlkfjklsdf ");
this.$emit('closeAdd') this.$emit('closeAdd')
}, }else{
let url = '/actual/base/albums/update'
const { data, code, msg } = await requestPost(url, this.formData)
if (code === 0) {
this.$message({
type: 'success',
message: '操作成功'
})
} else {
this.$message.error(msg)
}
this.$emit('closeAdd')
}
},
handleCancle() { handleCancle() {
console.log("sdlkfjklsdf "); console.log("sdlkfjklsdf ");
this.$emit('closeAdd') this.$emit('closeAdd')
@ -260,13 +206,13 @@
computed: { computed: {
dataRule() { dataRule() {
return { return {
columnId: [ albumName: [
{ required: true, message: '请输入图片集名称', trigger: 'blur' } { required: true, message: '请输入图片集名称', trigger: 'blur' }
], ],
title: [ sharedScope: [
{ required: true, message: '请选择共享范围', trigger: 'blur' } { required: true, message: '请选择共享范围', trigger: 'blur' }
], ],
fileList: [ coverPicture: [
{ required: true, message: '请选择图片集封面', trigger: 'blur' } { required: true, message: '请选择图片集封面', trigger: 'blur' }
] ]
} }

105
src/views/modules/base/smartExcel/cpts/picture-collection.vue

@ -13,24 +13,24 @@
<div style="margin: 30px 30px 100px 30px "> <div style="margin: 30px 30px 100px 30px ">
<div style="position: relative;"> <div style="position: relative;">
<div style="position: absolute;z-index: 10; right: 20px;top: -20px; "> <div style="position: absolute;z-index: 10; right: 20px;top: -20px; ">
<el-dropdown @command="onClickEdit"> <el-dropdown >
<span class="el-dropdown-link" style="color: blue;"> <span class="el-dropdown-link" style="color: blue;">
. . . . . .
</span> </span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="item">修改</el-dropdown-item> <el-dropdown-item @click.native="onClickEdit(item,'edit')">修改</el-dropdown-item>
<el-dropdown-item :command="item">删除</el-dropdown-item> <el-dropdown-item @click.native="onClickEdit(item,'del')">删除</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
<img :src="require(`@/assets/images/index/imageBackground.png`)" alt="" <img :src="require(`@/assets/images/index/imageBackground.png`)" alt=""
style=" position: absolute; cursor:pointer; height: 180px;width: 200px; "> style=" position: absolute; cursor:pointer; height: 180px;width: 200px; ">
<img :src="item.src ? `${item.src}` : require(`@/assets/images/index/noPictures.png`)" <img :src="item.coverPicture ? `${item.coverPicture}` : require(`@/assets/images/index/noPictures.png`)"
@click="onPictureList" alt="" style=" top: -20px; @click="onPictureList" alt="" style=" top: -20px;
left: -20px;; position: absolute; cursor:pointer; height: 180px; width: 200px;"> left: -20px;; position: absolute; cursor:pointer; height: 180px; width: 200px;">
</div> </div>
</div> </div>
<div style="position: relative; bottom: -120px;left: 30px; font-size: 14px;">{{ item.title }} <div style="position: relative; bottom: -120px;left: 30px; font-size: 14px;">{{ item.albumName }}
</div> </div>
</div> </div>
</div> </div>
@ -57,40 +57,6 @@ data() {
showPictureList:false, showPictureList:false,
formShow:false, formShow:false,
pictureList:[ pictureList:[
{
id:"1001",
src:"https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet-saas/dev/20250224/8b8a174ea85e48e684267ce1a3f10dd1.jpg",
title:"嘉定山社区网格巡查"
},
{
src:"https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet-saas/dev/20250224/8b8a174ea85e48e684267ce1a3f10dd1.jpg",
title:"嘉定山社区网格巡查"
},
{
src:"https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet-saas/dev/20250224/8b8a174ea85e48e684267ce1a3f10dd1.jpg",
title:"嘉定山社区网格巡查"
},
{
src:"https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet-saas/dev/20250224/8b8a174ea85e48e684267ce1a3f10dd1.jpg",
title:"嘉定山社区网格巡查"
},
{
src:"https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet-saas/dev/20250224/8b8a174ea85e48e684267ce1a3f10dd1.jpg",
title:"嘉定山社区网格巡查"
},
{
src:"https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet-saas/dev/20250224/8b8a174ea85e48e684267ce1a3f10dd1.jpg",
title:"嘉定山社区网格巡查"
},
{
src:"https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet-saas/dev/20250224/8b8a174ea85e48e684267ce1a3f10dd1.jpg",
title:"嘉定山社区网格巡查"
},
{
src:"",
title:"嘉定山社区网格巡查"
},
], ],
name:"", name:"",
pageNo: 1, pageNo: 1,
@ -106,13 +72,22 @@ mounted() {
this.getTableData() this.getTableData()
}, },
methods: { methods: {
onSelect(){ async getTableData() {
console.log(this.name,"dsflkjslkdf"); const url = "/actual/base/albums/page";
const { data, code, msg } = await requestGet(url, {
name:this.name,
});
if (code === 0) {
this.pictureList=data.list
} else {
this.$message.error(msg);
}
},
onSelect(){
this.getTableData()
}, },
closePictureList(){ closePictureList(){
console.log("dslkfjklsd");
this.showPictureList=false this.showPictureList=false
}, },
onPictureList(){ onPictureList(){
@ -120,8 +95,8 @@ methods: {
}, },
closeAdd(){ closeAdd(){
console.log("dsfjklsdfjl"); console.log("dsfjklsdfjl");
this.formShow=false this.formShow=false
this.getTableData()
}, },
onClick(type,id){ onClick(type,id){
console.log(type,"这是点击"); console.log(type,"这是点击");
@ -130,11 +105,43 @@ methods: {
this.$refs.ref_form.initForm(type,id); this.$refs.ref_form.initForm(type,id);
}); });
}, },
onClickEdit(item){ onClickEdit(item,val){
this.formShow=true console.log(item,val,"ds.lm;sd");
this.$nextTick(() => { if (val === 'del') {
this.$refs.ref_form.initForm("edit",item); this.$confirm("确认删除?", "提示", {
}); confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.handleDelete(item)
})
.catch(err => {
if (err == "cancel") {
}
});
} else {
this.formShow = true
this.$nextTick(() => {
this.$refs.ref_form.initForm("edit", item);
});
}
},
async handleDelete(row) {
const url = "/actual/base/albums/delete"
let ids = [row.id]
const { data, code, msg } = await requestPost(url, ids)
if (code === 0) {
this.$message({
type: "success",
message: "删除成功"
});
this.getTableData()
this.loadTable()
} else {
this.$message.error(msg)
}
}, },
}, },

Loading…
Cancel
Save