|
|
@ -11,29 +11,10 @@ |
|
|
|
width="700px" |
|
|
|
> |
|
|
|
<a-form :form="form" @submit="handleSubmit" v-if="editItem"> |
|
|
|
<!-- 页面路径 --> |
|
|
|
<!-- <a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="页面路径"> |
|
|
|
<a-input |
|
|
|
placeholder="页面路径" |
|
|
|
v-decorator="[ |
|
|
|
'pagePath', |
|
|
|
{ |
|
|
|
rules: [ |
|
|
|
{ required: true, message: '页面路径不能为空' }, |
|
|
|
{ whitespace: true, message: '页面路径不能为空' }, |
|
|
|
{ max: 140, massage: '页面路径最多140个字符' }, |
|
|
|
], |
|
|
|
}, |
|
|
|
]" |
|
|
|
/> |
|
|
|
</a-form-item>--> |
|
|
|
<!-- 跳转类型 --> |
|
|
|
<a-form-item |
|
|
|
:label-col="formItemLayout.labelCol" |
|
|
|
:wrapper-col="formItemLayout.wrapperCol" |
|
|
|
label="跳转类型" |
|
|
|
> |
|
|
|
<a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="跳转类型"> |
|
|
|
<a-select |
|
|
|
:value="jumpType" |
|
|
|
@change="getUse($event, 'jumpType')" |
|
|
|
class="ml-3" |
|
|
|
placeholder="请选择想要修改的跳转类型" |
|
|
@ -47,17 +28,14 @@ |
|
|
|
:label-col="formItemLayout.labelCol" |
|
|
|
:wrapper-col="formItemLayout.wrapperCol" |
|
|
|
label="图片跳转路径" |
|
|
|
v-if="editItem.jumpType === 1" |
|
|
|
v-if="editData.jumpType === 1" |
|
|
|
> |
|
|
|
<a-input class="ml-3" placeholder="图片跳转路径" v-model="editData.jumpUrl" /> |
|
|
|
</a-form-item> |
|
|
|
<!-- 状态 --> |
|
|
|
<a-form-item |
|
|
|
:label-col="formItemLayout.labelCol" |
|
|
|
:wrapper-col="formItemLayout.wrapperCol" |
|
|
|
label="状态" |
|
|
|
> |
|
|
|
<a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="状态"> |
|
|
|
<a-select |
|
|
|
:value="recStatus" |
|
|
|
@change="getUse($event, 'recStatus')" |
|
|
|
class="ml-3" |
|
|
|
placeholder="请选择想要修改的状态" |
|
|
@ -67,41 +45,21 @@ |
|
|
|
</a-select> |
|
|
|
</a-form-item> |
|
|
|
<!-- 页面显示位置 --> |
|
|
|
<a-form-item |
|
|
|
:label-col="formItemLayout.labelCol" |
|
|
|
:wrapper-col="formItemLayout.wrapperCol" |
|
|
|
label="页面显示位置" |
|
|
|
> |
|
|
|
<a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="页面显示位置"> |
|
|
|
<a-select |
|
|
|
:value="showPage" |
|
|
|
@change="getUse($event, 'showPage')" |
|
|
|
class="ml-3" |
|
|
|
placeholder="请选择想要修改的页面显示位置" |
|
|
|
style="width: 100%" |
|
|
|
> |
|
|
|
<a-select-option |
|
|
|
:key="item.page" |
|
|
|
:value="item.page" |
|
|
|
v-for="item in enable2" |
|
|
|
>{{ item.name }}</a-select-option> |
|
|
|
<a-select-option :key="item.page" :value="item.page" v-for="item in enable2">{{ item.name }}</a-select-option> |
|
|
|
</a-select> |
|
|
|
</a-form-item> |
|
|
|
<!-- 图片 --> |
|
|
|
<a-form-item |
|
|
|
:label-col="formItemLayout.labelCol" |
|
|
|
:wrapper-col="formItemLayout.wrapperCol" |
|
|
|
label="图片" |
|
|
|
> |
|
|
|
<a-upload |
|
|
|
:action="upload" |
|
|
|
:before-upload="beforeUpload" |
|
|
|
@change="handleChange" |
|
|
|
class="ml-3" |
|
|
|
list-type="picture" |
|
|
|
name="files" |
|
|
|
> |
|
|
|
<a-button v-show="fileList.length - 0 === 0"> |
|
|
|
<a-icon type="upload" />更换图片 |
|
|
|
</a-button> |
|
|
|
<a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="图片"> |
|
|
|
<a-upload :action="upload" :before-upload="beforeUpload" @change="handleChange" class="ml-3" list-type="picture" name="files"> |
|
|
|
<a-button v-show="fileList.length - 0 === 0"> <a-icon type="upload" />更换图片 </a-button> |
|
|
|
</a-upload> |
|
|
|
</a-form-item> |
|
|
|
<a-form-item class="d-flex flex-row-reverse"> |
|
|
@ -114,8 +72,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
// import { upTeam } from 'config/api'; |
|
|
|
import { upload, addCarousel } from 'config/api'; |
|
|
|
import { upload, updateCarousel } from 'config/api'; |
|
|
|
|
|
|
|
const formItemLayout = { |
|
|
|
labelCol: { span: 6 }, |
|
|
@ -209,14 +166,44 @@ export default { |
|
|
|
showPage: '', |
|
|
|
url: '', |
|
|
|
}, |
|
|
|
jumpType: '', |
|
|
|
recStatus: '', |
|
|
|
showPage: '', |
|
|
|
}; |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
editItem(val) { |
|
|
|
this.editData.jumpType = this.editItem.jumpType; |
|
|
|
this.editData.jumpUrl = this.editItem.jumpUrl; |
|
|
|
this.editData.recStatus = this.editItem.recStatus; |
|
|
|
this.editData.showPage = this.editItem.showPage; |
|
|
|
this.editData.url = this.editItem.url; |
|
|
|
this.jumpType = this.enable1[this.editItem.jumpType]; |
|
|
|
this.recStatus = this.enable[this.editItem.recStatus]; |
|
|
|
for (let i = 0; i < this.enable2.length; i++) { |
|
|
|
if (this.enable.showPage === this.enable2[i].page) { |
|
|
|
this.showPage = this.enable2[i].name; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 改变搜索条件 |
|
|
|
getUse(e, str) { |
|
|
|
this.editData[str] = e; |
|
|
|
if (str === 'jumpType' && e === 0) { |
|
|
|
this.editData.jumpUrl = ''; |
|
|
|
for (let i = 0; i < this.enable2.length; i++) { |
|
|
|
if (this.enable.showPage === this.enable2[i].page) { |
|
|
|
this.showPage = this.enable2[i].name; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (str === 'jumpType') { |
|
|
|
this.jumpType = this.enable1[e]; |
|
|
|
} |
|
|
|
if (str === 'recStatus') { |
|
|
|
this.recStatus = this.enable[e]; |
|
|
|
} |
|
|
|
}, |
|
|
|
// 上传文件事件 |
|
|
@ -230,21 +217,36 @@ export default { |
|
|
|
}, |
|
|
|
// 提交表单 |
|
|
|
handleSubmit(e) { |
|
|
|
console.log(this.editData); |
|
|
|
if (this.fileList.length) { |
|
|
|
this.editData.url = this.fileList[0]; |
|
|
|
} |
|
|
|
e.preventDefault(); |
|
|
|
this.form.validateFieldsAndScroll(async (err, values) => { |
|
|
|
if (!err) { |
|
|
|
try { |
|
|
|
// const params = { param: values }; |
|
|
|
// const res = await upTeam(params); |
|
|
|
// const { data, msg, code } = res.data; |
|
|
|
// this.$emit('closeModal'); |
|
|
|
// if (code === 200) { |
|
|
|
// this.$message.success('修改成功') |
|
|
|
// // TODO: 填到列表中 |
|
|
|
// } else { |
|
|
|
// throw msg; |
|
|
|
// } |
|
|
|
const params = { |
|
|
|
param: { |
|
|
|
id: this.editItem.id, |
|
|
|
jumpType: this.editData.jumpType, |
|
|
|
jumpUrl: this.editData.jumpUrl, |
|
|
|
recStatus: this.editData.recStatus, |
|
|
|
showPage: this.editData.showPage, |
|
|
|
url: this.editData.url, |
|
|
|
}, |
|
|
|
}; |
|
|
|
const res = await updateCarousel(params); |
|
|
|
const { data, msg, code } = res.data; |
|
|
|
if (code === 200) { |
|
|
|
this.$emit('closeModal'); |
|
|
|
this.$emit('editSearch'); |
|
|
|
this.$message.success('修改成功'); |
|
|
|
this.jumpType = ''; |
|
|
|
this.recStatus = ''; |
|
|
|
this.showPage = ''; |
|
|
|
// TODO: 填到列表中 |
|
|
|
} else { |
|
|
|
throw msg; |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
this.$message.error(error || '修改失败'); |
|
|
|
} |
|
|
|