Commit 0fd2e333 authored by 张伯涛's avatar 张伯涛

bug修改

parent b6ddaf4e
......@@ -184,7 +184,17 @@
</el-form-item>
<el-form-item label="链接地址:" prop="linkUrl">
<el-input v-model.trim="form.linkUrl" show-word-limit :maxlength="255" placeholder="请输入链接地址" />
<div style="display: flex">
<el-select v-model="addressType" style="width: 20%">
<el-option
v-for="(item,index) in addressTypeOptions"
:key="index"
:label="item.label"
:value="item.value"
/>
</el-select>
<el-input v-model.trim="form.linkUrl" show-word-limit :maxlength="255" placeholder="请输入链接地址" @blur="linkUrlBlur" />
</div>
</el-form-item>
<el-form-item label="排序:" prop="weight">
<el-input-number v-model.trim="form.weight" style="width: 100%" controls-position="right" :min="0" />
......@@ -294,8 +304,20 @@ export default {
},
showImg: false,
imagUrl: '',
addressType: '1',
// 表单参数
form: {},
form: {
bannerName: '',
bannerPicture: '',
linkUrl: '',
weight: '',
flag: '1',
type: '1'
},
addressTypeOptions: [
{ value: '1', label: 'http://' },
{ value: '2', label: 'https://' }
],
ruleForm: {
shops: [],
row: ''
......@@ -472,14 +494,14 @@ export default {
reset() {
this.form = {
businessId: undefined,
bannerPicture: undefined,
bannerName: undefined,
type: undefined,
weight: undefined,
remarks: undefined,
linkUrl: undefined,
flag: '1'
bannerName: '',
bannerPicture: '',
linkUrl: '',
weight: '',
flag: '1',
type: '1'
}
this.addressType = '1',
this.resetForm('form')
},
/** 查询按钮操作 */
......@@ -509,7 +531,14 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
this.form = { ...row }
this.form = JSON.parse(JSON.stringify(row))
if (this.form.linkUrl && (this.form.linkUrl.indexOf('http://') !== -1 || this.form.linkUrl.indexOf('https://') !== -1)) {
this.addressType = this.form.linkUrl.split('//')[0] === 'http:' ? '1' : '2'
this.form.linkUrl = this.form.linkUrl.split('//')[1]
} else {
this.addressType = '1'
this.form.linkUrl = ''
}
this.imageUrl = row.url
this.open = true
this.title = '修改banner'
......@@ -532,6 +561,12 @@ export default {
row.flag = row.flag === '0' ? '1' : '0'
})
},
/** 链接地址blur事件*/
linkUrlBlur() {
if (this.form.linkUrl.indexOf('http://') !== -1 || this.form.linkUrl.indexOf('https://') !== -1) {
this.form.linkUrl = this.form.linkUrl.split('//')[1]
}
},
/** 提交按钮 */
submitForm: function() {
this.$refs['form'].validate(valid => {
......@@ -542,9 +577,16 @@ export default {
this.form.unitId = unitId
}
if (this.form.businessId !== undefined) {
const typeName = this.addressType === '1' ? 'http://' : 'https://'
const temp = {
bannerId: this.form.businessId,
...this.form
businessId: this.form.businessId,
// ...this.form
bannerName: this.form.bannerName,
bannerPicture: this.form.bannerPicture,
linkUrl: this.form.linkUrl ? typeName + this.form.linkUrl : '',
weight: this.form.weight,
flag: this.form.flag,
type: this.form.type
}
updateCmsBanner(temp).then(response => {
this.msgSuccess('修改成功')
......@@ -552,7 +594,16 @@ export default {
this.getList()
})
} else {
addCmsBanner(this.form).then(response => {
const typeName = this.addressType === '1' ? 'http://' : 'https://'
const params = {
bannerName: this.form.bannerName,
bannerPicture: this.form.bannerPicture,
linkUrl: this.form.linkUrl ? typeName + this.form.linkUrl : '',
weight: this.form.weight,
flag: this.form.flag,
type: this.form.type
}
addCmsBanner(params).then(response => {
this.msgSuccess('新增成功')
this.open = false
this.getList()
......
......@@ -833,7 +833,9 @@
drag
:show-file-list="true"
:file-list="files"
:limit="1"
:http-request="handleUploadAddFile"
:on-exceed="handleExceed"
:on-remove="handleRemoveAddFile"
>
<i class="el-icon-upload" />
......@@ -1151,6 +1153,10 @@ export default {
this.saveFile = file.file
this.$refs.formModel.clearValidate('file')
},
/** 超出数量限制的回调*/
handleExceed() {
this.$message.warning('只能上传一个文件!')
},
/** 新增的附件上传删除*/
handleRemoveAddFile() {
console.log('remove')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment