Commit 4b2b922d by zhangquan

接口联调

1 parent 0a7542e3
<template>
<baseDialog
:is-show.sync="dialogVisible"
class="accountDailog"
:dialogConfig="{ width: '720px' }"
@handleClick="handleAddConfirm"
>
<div class="tableBox">
<div style="padding: 10px 50px">
<el-input
v-model="realSearchForm.merchantIdName"
placeholder="搜索门店名称"
maxlength="20"
clearable
size="small"
style="width: 300px; margin-right: 12px"
/>
<el-button size="small" type="primary" @click="searchList">
查询
</el-button>
</div>
<d2-table
ref="merchantTable"
:search-form="realSearchForm"
:table-params="tableParams"
:get-list-api="getListApi"
:before-search-fn="beforeSearchFn"
>
</d2-table>
</div>
</baseDialog>
</template>
<script>
import {
getAllMerchantList,
getMerchantListByScene,
getBrandList
} from "@api/contentManager"
import { deepClone } from "@/common/util"
export default {
name: "SelectGoodsTypeDialog",
props: {
config: {
type: Object,
require: true
},
dialogVisible: {
type: Boolean,
default: false
},
selectedRecord: {
type: Array,
default: () => []
}
},
data() {
return {
getListApi: getAllMerchantList,
realSearchForm: {
merchantIdName: ""
},
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: "list",
mutiSelectUniqueKey: "id",
mutiSelectName: "merchantIndex",
tableColumns: [
{
label: "门店名称",
prop: "merchantName"
}
]
}
}
},
mounted() {},
methods: {
beforeSearchFn() {
return new Promise((resolve) => {
if (this.config.scene == 0 || this.config.scene == 4) {
this.getListApi = getAllMerchantList
} else {
this.getListApi = getMerchantListByScene
this.realSearchForm.scene = this.config.scene
}
resolve()
})
},
searchList() {
this.$refs?.merchantTable?.refreshTable(true, true)
},
handleAddConfirm() {
const selectItemList =
this.$refs.merchantTable?.mutiSelectArr?.[
this.tableParams.mutiSelectName
]
if (selectItemList.length) {
this.$emit("confirmDialogFn", selectItemList)
} else {
this.$message("请勾选门店")
}
}
}
}
</script>
<style></style>
<template>
<div class="activity-img-box">
<template v-if="imageUrlArr && imageUrlArr.length > 0">
<div v-for="(item, index) in imageUrlArr" :key="index">
<div
class="pic-box"
:style="{ width: picOptions.width, height: picOptions.height }"
>
<img class="photo-activity" :src="item" alt="" />
<div
class="mask"
:style="{ width: picOptions.width, height: picOptions.height }"
>
<div class="pic-pane-close" @click="handleEnlarge(item)">
<img :src="require('@/assets/view.png')" alt="" />
</div>
<template v-if="picOptions.isClose">
<div class="pic-pane-close" @click="close('img', index)">
<img :src="require('@/assets/icon-delete.png')" alt="" />
</div>
</template>
</div>
</div>
</div>
</template>
<template
v-if="
(imageUrlArr && imageUrlArr.length < 10 && limit > 1) ||
(imageUrlArr && imageUrlArr.length == 0 && limit == 1)
"
>
<div class="upload-img">
<i class="el-icon-plus avatar-uploader-desc-icon"></i>
<div class="avatar-uploader-desc-word">上传照片</div>
<input
type="file"
ref="uploadImg"
class="upload-img"
style="opacity: 0"
accept=".jpg, .jpeg, .png"
@change="(e) => handleImgChange(e)"
/>
</div>
</template>
<el-dialog
class="image-dialog"
:visible.sync="dialogVisibleImg"
:append-to-body="true"
width="50%"
>
<img :src="dialogSrc" width="100%" v-if="dialogType == 'img'" />
<!-- <video width="100%" autoplay controls :src="dialogSrc" v-else></video> -->
</el-dialog>
</div>
</template>
<script>
import { uploadImg, uploadVideo } from "@/api/sys.base"
export default {
props: {
picOptions: {
type: Object,
default: () => {
return {
width: "104px",
height: "104px",
isClose: true,
limitSize: 10
}
}
},
imageUrlArr: {
type: Array,
default: () => []
},
limit: {
type: String,
default: "1"
},
index: {
type: Number,
default: -1
}
},
data() {
return {
dialogVisibleImg: false
}
},
methods: {
// 上传图片
handleImgChange(e) {
this.$notify({
title: "提示",
message: "图片上传中,请稍后"
})
var file = e.srcElement.files[0]
var reader = new FileReader()
// 默认1MB
const limitSize = this.picOptions.limitSize || 10
const isLt = file.size / 1024 / 1024 < limitSize
if (!isLt) {
this.$message.error("上传图片大小不能超过" + limitSize + "MB!")
return true
}
if (this.imageUrlArr.length > this.limit) {
this.$message.error("最多上传9张图片")
return
}
this.$emit("beforeUpload")
reader.readAsDataURL(file)
reader.onload = (e) => {
const imgFile = e.target.result
const arrBase64 = imgFile.split(",")
const splitStr = file.name.split(".")
const fileUrl = splitStr[splitStr.length - 1] + "@" + arrBase64[1]
uploadImg({
file: fileUrl,
compress: this.picOptions.compress || 0
})
.then((res) => {
if (res) {
this.$notify({
title: "提示",
message: "图片上传成功",
type: "success"
})
this.imageUrlArr.push(res)
this.$emit("change", {
arr: this.imageUrlArr,
key: this.picOptions.key,
index: this.index
})
}
e.target.value = ""
this.$refs.uploadImg.value = ""
})
.finally((end) => {
this.$emit("afterUpload", end)
})
}
},
// 预览图文
handleEnlarge(src, type) {
this.dialogVisibleImg = true
this.dialogSrc = src
this.dialogType = type ? type : "img"
},
// 删除图片/视频
close(type, index) {
switch (type) {
case "radio":
this.videoUrl = ""
this.videoImage = ""
break
case "img":
this.imageUrlArr.splice(index, 1)
this.$emit("change", {
arr: this.imageUrlArr,
key: this.picOptions.key,
id: 1,
index: this.index
})
break
default:
this.videoUrl = ""
}
}
}
}
</script>
<style scoped lang="scss">
.activity-img-box {
display: flex;
flex-wrap: wrap;
max-width: 600px;
.pic-box {
position: relative;
width: 104px;
height: 104px;
border-radius: 4px;
margin-right: 8px;
margin-bottom: 5px;
&:hover .mask {
opacity: 1;
}
.pic {
position: absolute;
object-fit: fill;
}
.photo-activity {
position: absolute;
width: 100%;
height: 100%;
}
.mask {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
background: rgba(0, 0, 0, 0.5);
color: #ffffff;
opacity: 0;
top: 0;
right: 0;
width: 104px;
height: 104px;
z-index: 999;
.pic-pane-close {
width: 16px;
height: 16px;
cursor: pointer;
margin-left: 24px;
&:first-child {
margin-left: 0;
}
img {
width: 100%;
display: block;
}
}
}
}
.upload-img {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 104px;
height: 104px;
background: rgba(0, 0, 0, 0.04);
border: 1px dashed rgba(0, 0, 0, 0.15);
border-radius: 4px;
input {
position: absolute;
// top: 0;
// left: 0;
width: 104px;
height: 104px;
}
}
.avatar-uploader-desc-word {
font-weight: 400;
font-size: 28rpx;
color: #666666;
margin-top: 8px;
}
.image-dialog {
::v-deep {
.el-dialog__header {
border-bottom: 0px;
padding: 0px;
}
}
}
}
</style>
...@@ -110,7 +110,6 @@ export default { ...@@ -110,7 +110,6 @@ export default {
}, },
mounted() { mounted() {
this.searchForm.goodsId = this.$route.params.id
var params = { currentPage: 1, pageSize: 100, merchantIdName: "" } var params = { currentPage: 1, pageSize: 100, merchantIdName: "" }
getMerchantList(params) getMerchantList(params)
.then((res) => { .then((res) => {
...@@ -192,6 +191,7 @@ export default { ...@@ -192,6 +191,7 @@ export default {
}, },
beforeSearchFn() { beforeSearchFn() {
return new Promise((resolve) => { return new Promise((resolve) => {
this.searchForm.goodsId = this.$route.params.id
this.realSearchForm = this.getParams() this.realSearchForm = this.getParams()
resolve() resolve()
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!