Commit 0b8b9c46 by cwq0219

商户编辑修改

1 parent 8f32d129
......@@ -52,12 +52,43 @@
>
</el-amap>
</div>
<img
v-else-if="i.isImg"
class="detail-logo"
:src="i.value"
alt=""
<span v-else-if="i.isImg">
<img
class="detail-logo"
:src="i.value"
alt=""
@click="handleImg()"
>
<gl-upload
v-if="isEdit"
class="upload-demo"
name="file"
:action="uploadAction"
:limit="2"
:before-upload="beforeUpload"
:on-success="handleSuccess"
:on-error="handleError"
:on-remove="handleRemove"
:file-list="fileList">
<gl-button
size="small"
>上传图片</gl-button>
</gl-upload>
</span>
<gl-select
v-else-if="i.name == 'merchantChannelName' && isEdit"
style="width: 50%;"
v-model="merchantInfo.merchantChannelName"
placeholder="请选择渠道"
>
<gl-option
v-for="item in channelList"
:key="item.confId"
:label="item.confKey"
:value="item.confId"
>
</gl-option>
</gl-select>
<gl-input
v-else-if="isEdit && editOptions.includes(i.name)"
v-model="merchantInfo[i.name]"
......@@ -130,13 +161,16 @@
>确 定</el-button>
</span>
</gl-dialog>
<gl-dialog width="30%" :visible.sync="imgDialogVisible">
<img width="100%" :src="dialogImageUrl" alt="">
</gl-dialog>
</div>
</template>
<script>
import VueAMap from 'vue-amap'
import Vue from 'vue'
import { bizMethods, request } from '@/api'
import { businessManagenMethods, bizMethods, request } from '@/api'
import notice from '@/common/notice'
var marker = []
const amapManager = new VueAMap.AMapManager()
......@@ -162,10 +196,16 @@ export default {
IdChange: [0, 0, 0],
activeName: 'first',
merchantInfo: {},
tempMerchantInfo: {},
isEdit: false,
tempAddr: '',
fileList: [],
uploadAction: '',
imgDialogVisible: false,
dialogImageUrl: '',
// tempAddr: '',
isMarkAddr: false,
editOptions: ['address', 'merchantChannelName', 'contactor', 'contactPhone', 'phone', 'email'],
editOptions: ['address', 'contactor', 'contactPhone', 'phone', 'email'],
channelList: [],
List: [
{
name: 'merchantName',
......@@ -350,6 +390,9 @@ export default {
},
mounted() {
this.hasLocation = false
this.uploadAction = `${
this.$get_session_common_config().axios.fileUploadURL
}/gps/common/uploadFile`
this.$root.eventBus.$on('params', (params) => {
this.activeName = 'first'
this.isVisible = false
......@@ -374,18 +417,39 @@ export default {
// 编辑,取消
handleEdit(isCancel) {
this.isMarkAddr = false
if (!this.isEdit) {
this.tempMerchantInfo = JSON.parse(JSON.stringify(this.merchantInfo))
this.getChannelList()
}
// 保存
if (!isCancel && this.isEdit) {
this.merchantInfo.lng = this.center[0]
this.merchantInfo.lat = this.center[1]
console.log('调保存接口--')
console.log(this.merchantInfo)
this.isEdit = !this.isEdit
} else {
this.getAddress(this.merchantInfo.lng, this.merchantInfo.lat)
// this.getAddress(this.merchantInfo.lng, this.merchantInfo.lat)
if (isCancel) {
this.merchantInfo = JSON.parse(JSON.stringify(this.tempMerchantInfo))
if (!this.merchantInfo.lng && !this.merchantInfo.lat) {
amapManager._map.remove(marker)
this.hasLocation = false
this.List[10].value = '无位置信息'
} else {
this.getAddress(this.merchantInfo.lng, this.merchantInfo.lat)
}
}
this.isEdit = !this.isEdit
}
},
getChannelList() {
const params = {}
params.method = businessManagenMethods.Channel
request.req(params).then(res => {
this.channelList = res.merchantDictList
}).catch(err => {
notice.errorTips(err)
})
},
// 切换tab
handleClick(tab, event) {
switch (tab.name) {
......@@ -409,8 +473,8 @@ export default {
params.method = bizMethods.Detail
request.req(params).then(res => {
this.merchantInfo = res
// this.merchantInfo.lng = '113.939723'
// this.merchantInfo.lat = '22.525351'
// this.merchantInfo.lng = ''
// this.merchantInfo.lat = ''
this.assignBasicInfo()
this.IdChange[0] = 0
this.basicLoading = false
......@@ -439,7 +503,7 @@ export default {
getAddress(lng, lat) {
amapManager._map.remove(marker)
marker = []
this.center = [+lng, +lat]
if (lng && lat) this.center = [+lng, +lat]
var geocoder = new AMap.Geocoder({
radius: 1000,
extensions: 'all'
......@@ -453,15 +517,15 @@ export default {
})
marker.push(mar)
amapManager._map.add(marker)
this.tempAddr = result.regeocode.formattedAddress
this.markAddr()
this.hasLocation = true
this.merchantInfo.lng = this.center[0]
this.merchantInfo.lat = this.center[1]
this.List[10].value = result.regeocode.formattedAddress
}
})
},
markAddr() {
this.hasLocation = true
this.List[10].value = this.tempAddr
// console.log(this.center)
},
// 员工信息
getStaffInfo() {
......@@ -508,6 +572,30 @@ export default {
},
handleDetailClose() {
this.detailVisible()
},
handleImg() {
this.dialogImageUrl = this.merchantInfo.merchantPortrait
this.imgDialogVisible = true
},
// 图片上传
// 上传附件,限制用户上传的附件格式和大小
beforeUpload(file) {
const fileType = ['image/jpeg', 'image/jpg', 'image/gif', 'image/png']
const isFileType = fileType.includes(file.type)
const isLT20M = file.size / 1024 / 1024 < 20
!isFileType && this.$message.error('上传图片只能是 JPG, JPGE, GIF或PNG 格式!')
!isLT20M && this.$message.error('上传附件大小不能超过20M')
return isLT20M
},
handleSuccess(res, file, fileList) {
this.fileList = [{ name: file.name, url: file.response.data }]
this.merchantInfo.merchantPortrait = file.response.data
},
handleError() {
this.$message.error('上传失败,请重新上传!')
},
handleRemove(file, fileList) {
this.merchantInfo.merchantPortrait = ''
}
}
}
......@@ -542,6 +630,10 @@ export default {
height: 300px;
border: 1px solid #ebeef5;
}
.upload-demo {
display: inline-block;
margin-left: 20px;
}
.detail {
margin: 12px;
font-size: 14px;
......@@ -553,6 +645,8 @@ export default {
display: inline-block;
}
.detail-basic {
height: 580px;
overflow: auto;
border: 1px solid #ebeef5;
background: #fafafa;
padding: 10px 20px;
......@@ -573,7 +667,8 @@ export default {
.detail-logo {
width: 40px;
height: 40px;
vertical-align: text-top;
vertical-align: middle;
cursor: pointer;
}
.el-tabs__header{
background-color: #fafafa;
......@@ -581,5 +676,8 @@ export default {
.detail .el-input {
width: 50%;
}
.el-select>.el-input {
width: 100%;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!