城阳pc工作端前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

176 lines
4.5 KiB

<template>
<div>
<c-dialog :title="'修改系统信息'"
:visible="diaVisible"
:width="40"
@ok="save"
@cancel="diaCancel">
<el-card shadow="never"
class="aui-card--fill">
<el-form
:model="formData"
:rules="dataRule"
ref="ref_form"
style="margin:0 auto;width:860px"
:label-width="'100px'">
<el-form-item prop="platformName"
label="系统名称">
<el-input v-model="formData.platformName" style="width: 100%;"></el-input>
</el-form-item>
<el-form-item prop="icon"
label="Logo">
<el-upload :headers="$getElUploadHeaders()" class="item_width_1 avatar-uploader"
:action="uploadUlr"
:show-file-list="false"
:on-success="handleImgSuccess"
:before-upload="beforeImgUpload">
<img v-if="formData.icon"
:src="formData.icon"
style="width:70px;height:70px"
class="function-icon">
<i v-else
class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
</el-form-item>
</el-form>
</el-card>
</c-dialog>
</div>
</template>
<script>
/* eslint-disable */
import CForm from '@c/CForm'
import CDialog from '@c/CDialog'
import { mapGetters } from 'vuex'
import { Loading } from 'element-ui' // 引入Loading服务
let loading // 加载动画
export default {
data () {
return {
diaVisible: false,
formData: {},//父组件传来的
formData2: {
logo: ''
},
optionData: {
},
uploadUlr: window.SITE_CONFIG['apiURL'] + '/oss/file/function/upload',
customerId: ''
}
},
components: {
CForm, CDialog
},
mounted () {
},
computed: {
tableHeight () {
return this.clientHeight - 60 - 80 - 80 - 50 - 400
},
...mapGetters(['clientHeight']),
dataRule () {
return {
logo: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
]
}
}
},
methods: {
// eslint-disable-next-line
initData (row, customerId) {
this.diaVisible = true
this.$nextTick(() => {
this.formData = row
this.formData2.logo = row.logo
this.customerId = customerId
})
},
// 上传logo成功
handleImgSuccess (res, file) {
if (res.code === 0 && res.msg === 'success') {
this.formData.icon = res.data.url
} else {
this.$message.error(res.msg)
}
},
beforeImgUpload (file) {
// const isPNG = file.type === 'image/png'
const isLt1M = file.size / 1024 / 1024 < 1
// if (!isPNG) {
// this.$message.error('上传图片只能是 PNG 格式!')
// }
if (!isLt1M) {
this.$message.error('上传图片大小不能超过 1MB!')
}
// return isPNG && isLt1M
return isLt1M
},
save () {
this.$refs['ref_form'].validate((valid) => {
if (valid) {
if (!this.formData.icon || this.formData.icon === '') {
this.$message.error('请上传Logo!')
return false
}
this.startLoading()
// let url = 'https://nei.netease.com/api/apimock-v2/e3b1d0eb88e905f6c7ee559b2d6bb7ad/oper/crm/customer/updatecustomer'
let url = '/third/thirdplatform/customer/update-customize-platform-info'
// 表单对象
let _data = {
...this.formData,
customerId: this.customerId
}
window.app.ajax.post(url, _data,
(data, rspMsg) => {
this.endLoading()
this.$message.success('修改成功')
this.$emit('refresh', this.formData)
this.diaCancel()
},
(rspMsg, data) => {
this.endLoading()
this.$message.error(rspMsg)
})
}
})
},
diaCancel () {
this.diaVisible = false
},
// 开启加载动画
startLoading () {
loading = Loading.service({
lock: true, // 是否锁定
text: '正在加载……', // 加载中需要显示的文字
background: 'rgba(0,0,0,.7)' // 背景颜色
})
},
// 结束加载动画
endLoading () {
// clearTimeout(timer);
if (loading) {
loading.close()
}
}
}
}
</script>