|
|
|
<template>
|
|
|
|
<el-dialog :visible.sync="visible"
|
|
|
|
:title="'修改定制功能'"
|
|
|
|
:width="diaWidth+'%'"
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
:before-close="handleClose"
|
|
|
|
:close-on-press-escape="false">
|
|
|
|
<el-form :inline="true"
|
|
|
|
:model="dataForm"
|
|
|
|
:rules="dataRule"
|
|
|
|
ref="dataForm"
|
|
|
|
:label-width="'120px'">
|
|
|
|
<div style="margin-top:20px">
|
|
|
|
<el-form-item label="默认功能名称"
|
|
|
|
prop="customizedName">
|
|
|
|
<div class="item_width_1">
|
|
|
|
<span>{{dataForm.customizedName}}</span></div>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="功能名称"
|
|
|
|
prop="functionName">
|
|
|
|
<el-tooltip class="item"
|
|
|
|
effect="dark"
|
|
|
|
content="请输入2-5个字"
|
|
|
|
placement="bottom-start">
|
|
|
|
<el-input class="item_width_1"
|
|
|
|
:maxlength="5"
|
|
|
|
:minlength="2"
|
|
|
|
v-model="dataForm.functionName"
|
|
|
|
placeholder="功能名称"></el-input>
|
|
|
|
</el-tooltip>
|
|
|
|
</el-form-item>
|
|
|
|
</div>
|
|
|
|
<div style="margin-top:20px">
|
|
|
|
<el-form-item prop="defaultLargeImg"
|
|
|
|
label="默认大图标">
|
|
|
|
<div class="item_width_1">
|
|
|
|
<img :src="dataForm.defaultLargeImg"
|
|
|
|
style="width:70px;height:70px"
|
|
|
|
class="function-icon">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item prop="iconLargeImg"
|
|
|
|
label="大图标">
|
|
|
|
<el-upload class="item_width_1 avatar-uploader"
|
|
|
|
:action="uploadUlr"
|
|
|
|
:show-file-list="false"
|
|
|
|
:on-success="function (res, file) { return handleImgSuccess(res, file, 'large')}"
|
|
|
|
:before-upload="beforeImgUpload">
|
|
|
|
<img v-if="dataForm.iconLargeImg"
|
|
|
|
:src="dataForm.iconLargeImg"
|
|
|
|
style="width:70px;height:70px"
|
|
|
|
class="function-icon">
|
|
|
|
<i v-else
|
|
|
|
class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
|
|
|
|
|
</el-upload>
|
|
|
|
<el-button class="btn_reset"
|
|
|
|
type="primary"
|
|
|
|
size="mini"
|
|
|
|
@click="resetLargeImg">恢复默认</el-button>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
</div>
|
|
|
|
<div style="margin-top:10px">
|
|
|
|
<el-form-item prop="defaultSmallImg"
|
|
|
|
label="默认小图标">
|
|
|
|
<div class="item_width_1">
|
|
|
|
<img :src="dataForm.defaultSmallImg"
|
|
|
|
style="width:40px;height:40px"
|
|
|
|
class="function-icon">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<el-form-item prop="iconSmallImg"
|
|
|
|
label="小图标">
|
|
|
|
<el-upload class="item_width_1 avatar-uploader"
|
|
|
|
:action="uploadUlr"
|
|
|
|
:show-file-list="false"
|
|
|
|
:on-success="function (res, file) { return handleImgSuccess(res, file, 'small')}"
|
|
|
|
:before-upload="beforeImgUpload">
|
|
|
|
<img v-if="dataForm.iconSmallImg"
|
|
|
|
:src="dataForm.iconSmallImg"
|
|
|
|
style="width:40px;height:40px"
|
|
|
|
class="function-icon">
|
|
|
|
<i v-else
|
|
|
|
class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
|
|
|
|
|
</el-upload>
|
|
|
|
<el-button class="btn_reset"
|
|
|
|
type="primary"
|
|
|
|
size="mini"
|
|
|
|
@click="resetSmallImg">恢复默认</el-button>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</el-form>
|
|
|
|
<template slot="footer">
|
|
|
|
<el-button @click="visible = false">{{ $t('cancel') }}</el-button>
|
|
|
|
<el-button type="primary"
|
|
|
|
@click="saveForm()">{{ $t('confirm') }}</el-button>
|
|
|
|
</template>
|
|
|
|
</el-dialog>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex'
|
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
visible: false,
|
|
|
|
|
|
|
|
dataForm: {
|
|
|
|
customerId: '',
|
|
|
|
functionId: '',
|
|
|
|
customizedName: '', // 默认名称
|
|
|
|
functionName: '', // 自定义名称
|
|
|
|
defaultLargeImg: '', // 默认大图标
|
|
|
|
iconLargeImg: '', // 自定义大图标
|
|
|
|
defaultSmallImg: '', // 默认小图标
|
|
|
|
iconSmallImg: ''// 自定义小图标
|
|
|
|
|
|
|
|
},
|
|
|
|
uploadUlr: window.SITE_CONFIG['apiURL'] + '/oss/file/function/upload'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created () {
|
|
|
|
// this.queryFunctionList()
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
dataRule () {
|
|
|
|
return {
|
|
|
|
functionName: [
|
|
|
|
{ required: true, message: '功能名称不能为空', trigger: 'blur' },
|
|
|
|
{ min: 2, max: 5, message: '功能名称长度在 2 到 5 个字符', trigger: 'blur' }
|
|
|
|
],
|
|
|
|
iconLargeImg: [
|
|
|
|
{ required: true, message: '大图标不能为空', trigger: 'blur' }
|
|
|
|
],
|
|
|
|
iconSmallImg: [
|
|
|
|
{ required: true, message: '小图标不能为空', trigger: 'blur' }
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
diaWidth () {
|
|
|
|
console.log(this.resolution)
|
|
|
|
return this.resolution === 'small' ? 60 : 40
|
|
|
|
},
|
|
|
|
...mapGetters(['clientHeight', 'resolution']),
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
init (dataForm) {
|
|
|
|
console.log(dataForm)
|
|
|
|
this.visible = true
|
|
|
|
// this.dataForm=dataForm
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
Object.assign(this.dataForm, dataForm)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 重置大图标
|
|
|
|
resetLargeImg () {
|
|
|
|
this.dataForm.iconLargeImg = this.dataForm.defaultLargeImg
|
|
|
|
},
|
|
|
|
// 重置小图标
|
|
|
|
resetSmallImg () {
|
|
|
|
this.dataForm.iconSmallImg = this.dataForm.defaultSmallImg
|
|
|
|
},
|
|
|
|
|
|
|
|
// 上传大图标成功
|
|
|
|
handleImgSuccess (res, file, type) {
|
|
|
|
if (res.code === 0 && res.msg === 'success') {
|
|
|
|
if (type === 'large') {
|
|
|
|
this.dataForm.iconLargeImg = res.data.url
|
|
|
|
} else if (type === 'small') {
|
|
|
|
this.dataForm.iconSmallImg = 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
|
|
|
|
},
|
|
|
|
|
|
|
|
saveForm () {
|
|
|
|
this.$refs['dataForm'].validate((valid, messageObj) => {
|
|
|
|
if (!valid) {
|
|
|
|
app.util.validateRule(messageObj)
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// console.log(this.dataForm)
|
|
|
|
// const url = 'https://nei.netease.com/api/apimock-v2/e3b1d0eb88e905f6c7ee559b2d6bb7ad/oper/customize/customerfunctiondetail/updatecustomerfunction'
|
|
|
|
const url = '/oper/customize/customerfunctiondetail/updatecustomerfunction'
|
|
|
|
window.app.ajax.post(url, this.dataForm,
|
|
|
|
(data, rspMsg) => {
|
|
|
|
this.$message({
|
|
|
|
type: 'success',
|
|
|
|
message: '保存成功'
|
|
|
|
})
|
|
|
|
this.visible = false
|
|
|
|
this.$emit('editDiaOK')
|
|
|
|
},
|
|
|
|
(rspMsg, data) => {
|
|
|
|
this.endLoading()
|
|
|
|
this.$message.error(rspMsg)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handleClose () {
|
|
|
|
this.visible = false
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.function-icon {
|
|
|
|
width: 28px;
|
|
|
|
}
|
|
|
|
.item_width_1 {
|
|
|
|
width: 200px;
|
|
|
|
}
|
|
|
|
.item_width_2 {
|
|
|
|
width: 700px;
|
|
|
|
}
|
|
|
|
.block {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
.btn_reset {
|
|
|
|
vertical-align: bottom;
|
|
|
|
margin-left: 10px;
|
|
|
|
}
|
|
|
|
</style>
|