Commit 0b8b9c46 by cwq0219

商户编辑修改

1 parent 8f32d129
...@@ -52,12 +52,43 @@ ...@@ -52,12 +52,43 @@
> >
</el-amap> </el-amap>
</div> </div>
<span v-else-if="i.isImg">
<img <img
v-else-if="i.isImg"
class="detail-logo" class="detail-logo"
:src="i.value" :src="i.value"
alt="" 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 <gl-input
v-else-if="isEdit && editOptions.includes(i.name)" v-else-if="isEdit && editOptions.includes(i.name)"
v-model="merchantInfo[i.name]" v-model="merchantInfo[i.name]"
...@@ -130,13 +161,16 @@ ...@@ -130,13 +161,16 @@
>确 定</el-button> >确 定</el-button>
</span> </span>
</gl-dialog> </gl-dialog>
<gl-dialog width="30%" :visible.sync="imgDialogVisible">
<img width="100%" :src="dialogImageUrl" alt="">
</gl-dialog>
</div> </div>
</template> </template>
<script> <script>
import VueAMap from 'vue-amap' import VueAMap from 'vue-amap'
import Vue from 'vue' import Vue from 'vue'
import { bizMethods, request } from '@/api' import { businessManagenMethods, bizMethods, request } from '@/api'
import notice from '@/common/notice' import notice from '@/common/notice'
var marker = [] var marker = []
const amapManager = new VueAMap.AMapManager() const amapManager = new VueAMap.AMapManager()
...@@ -162,10 +196,16 @@ export default { ...@@ -162,10 +196,16 @@ export default {
IdChange: [0, 0, 0], IdChange: [0, 0, 0],
activeName: 'first', activeName: 'first',
merchantInfo: {}, merchantInfo: {},
tempMerchantInfo: {},
isEdit: false, isEdit: false,
tempAddr: '', fileList: [],
uploadAction: '',
imgDialogVisible: false,
dialogImageUrl: '',
// tempAddr: '',
isMarkAddr: false, isMarkAddr: false,
editOptions: ['address', 'merchantChannelName', 'contactor', 'contactPhone', 'phone', 'email'], editOptions: ['address', 'contactor', 'contactPhone', 'phone', 'email'],
channelList: [],
List: [ List: [
{ {
name: 'merchantName', name: 'merchantName',
...@@ -350,6 +390,9 @@ export default { ...@@ -350,6 +390,9 @@ export default {
}, },
mounted() { mounted() {
this.hasLocation = false this.hasLocation = false
this.uploadAction = `${
this.$get_session_common_config().axios.fileUploadURL
}/gps/common/uploadFile`
this.$root.eventBus.$on('params', (params) => { this.$root.eventBus.$on('params', (params) => {
this.activeName = 'first' this.activeName = 'first'
this.isVisible = false this.isVisible = false
...@@ -374,18 +417,39 @@ export default { ...@@ -374,18 +417,39 @@ export default {
// 编辑,取消 // 编辑,取消
handleEdit(isCancel) { handleEdit(isCancel) {
this.isMarkAddr = false this.isMarkAddr = false
if (!this.isEdit) {
this.tempMerchantInfo = JSON.parse(JSON.stringify(this.merchantInfo))
this.getChannelList()
}
// 保存 // 保存
if (!isCancel && this.isEdit) { if (!isCancel && this.isEdit) {
this.merchantInfo.lng = this.center[0]
this.merchantInfo.lat = this.center[1]
console.log('调保存接口--') console.log('调保存接口--')
console.log(this.merchantInfo) console.log(this.merchantInfo)
this.isEdit = !this.isEdit this.isEdit = !this.isEdit
} else { } else {
// 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.getAddress(this.merchantInfo.lng, this.merchantInfo.lat)
}
}
this.isEdit = !this.isEdit 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 // 切换tab
handleClick(tab, event) { handleClick(tab, event) {
switch (tab.name) { switch (tab.name) {
...@@ -409,8 +473,8 @@ export default { ...@@ -409,8 +473,8 @@ export default {
params.method = bizMethods.Detail params.method = bizMethods.Detail
request.req(params).then(res => { request.req(params).then(res => {
this.merchantInfo = res this.merchantInfo = res
// this.merchantInfo.lng = '113.939723' // this.merchantInfo.lng = ''
// this.merchantInfo.lat = '22.525351' // this.merchantInfo.lat = ''
this.assignBasicInfo() this.assignBasicInfo()
this.IdChange[0] = 0 this.IdChange[0] = 0
this.basicLoading = false this.basicLoading = false
...@@ -439,7 +503,7 @@ export default { ...@@ -439,7 +503,7 @@ export default {
getAddress(lng, lat) { getAddress(lng, lat) {
amapManager._map.remove(marker) amapManager._map.remove(marker)
marker = [] marker = []
this.center = [+lng, +lat] if (lng && lat) this.center = [+lng, +lat]
var geocoder = new AMap.Geocoder({ var geocoder = new AMap.Geocoder({
radius: 1000, radius: 1000,
extensions: 'all' extensions: 'all'
...@@ -453,15 +517,15 @@ export default { ...@@ -453,15 +517,15 @@ export default {
}) })
marker.push(mar) marker.push(mar)
amapManager._map.add(marker) amapManager._map.add(marker)
this.tempAddr = result.regeocode.formattedAddress this.hasLocation = true
this.markAddr() this.merchantInfo.lng = this.center[0]
this.merchantInfo.lat = this.center[1]
this.List[10].value = result.regeocode.formattedAddress
} }
}) })
}, },
markAddr() { markAddr() {
this.hasLocation = true this.hasLocation = true
this.List[10].value = this.tempAddr
// console.log(this.center)
}, },
// 员工信息 // 员工信息
getStaffInfo() { getStaffInfo() {
...@@ -508,6 +572,30 @@ export default { ...@@ -508,6 +572,30 @@ export default {
}, },
handleDetailClose() { handleDetailClose() {
this.detailVisible() 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 { ...@@ -542,6 +630,10 @@ export default {
height: 300px; height: 300px;
border: 1px solid #ebeef5; border: 1px solid #ebeef5;
} }
.upload-demo {
display: inline-block;
margin-left: 20px;
}
.detail { .detail {
margin: 12px; margin: 12px;
font-size: 14px; font-size: 14px;
...@@ -553,6 +645,8 @@ export default { ...@@ -553,6 +645,8 @@ export default {
display: inline-block; display: inline-block;
} }
.detail-basic { .detail-basic {
height: 580px;
overflow: auto;
border: 1px solid #ebeef5; border: 1px solid #ebeef5;
background: #fafafa; background: #fafafa;
padding: 10px 20px; padding: 10px 20px;
...@@ -573,7 +667,8 @@ export default { ...@@ -573,7 +667,8 @@ export default {
.detail-logo { .detail-logo {
width: 40px; width: 40px;
height: 40px; height: 40px;
vertical-align: text-top; vertical-align: middle;
cursor: pointer;
} }
.el-tabs__header{ .el-tabs__header{
background-color: #fafafa; background-color: #fafafa;
...@@ -581,5 +676,8 @@ export default { ...@@ -581,5 +676,8 @@ export default {
.detail .el-input { .detail .el-input {
width: 50%; width: 50%;
} }
.el-select>.el-input {
width: 100%;
}
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!