|
|
@@ -17,10 +17,15 @@
|
|
|
<el-option label="Article" value="2" :key="2"></el-option> <!-- 文章 -->
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item :label="form.type==='1' ? 'Url' : 'Article ID'"> <!-- '链接地址' '文章ID' -->
|
|
|
- <el-input v-model="form.content" style="width: 400px;">></el-input>
|
|
|
+ <el-form-item v-if="form.type==='1'" label="Url"> <!-- '链接地址' '文章ID' -->
|
|
|
+ <el-input v-model="url" style="width: 400px;"></el-input>
|
|
|
<span class="note"></span> <!-- 注:外链请明确输入 http://或https://,文章则不需要输入 -->
|
|
|
</el-form-item>
|
|
|
+ <el-form-item v-else label="Article"> <!-- '文章ID' -->
|
|
|
+ <el-select v-model="article" placeholder="Select Article" style="width: 400px;">
|
|
|
+ <el-option v-for="item in allArticle" :label="item.TITLE" :value="item.ID" :key="item.ID"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="Image"> <!-- 广告图片 -->
|
|
|
<leo-uploader :requestRoute="'ad/upload'" :defaultImageUrl="defaultImageUrl" width="400px" height="160px"
|
|
|
@on-success="handleSuccess"></leo-uploader>
|
|
|
@@ -36,6 +41,7 @@
|
|
|
<script>
|
|
|
import network from '../../utils/network'
|
|
|
import LeoUploader from '../../components/Uploader'
|
|
|
+import {SERVER_API_HTTP_TYPE,SERVER_API_DOMAIN} from '@/utils/config'
|
|
|
|
|
|
export default {
|
|
|
name: 'ad_edit',
|
|
|
@@ -46,16 +52,28 @@ export default {
|
|
|
this.form.title = response.oneData.TITLE
|
|
|
this.form.lid = response.oneData.LID
|
|
|
this.form.type = response.oneData.TYPE
|
|
|
+
|
|
|
+ this.imageAd = response.oneData.IMAGE;
|
|
|
+ this.form.image = SERVER_API_HTTP_TYPE + SERVER_API_DOMAIN + '/uploads/' + response.oneData.IMAGE;
|
|
|
+ this.defaultImageUrl = SERVER_API_HTTP_TYPE + SERVER_API_DOMAIN + '/uploads/' + response.oneData.IMAGE;
|
|
|
+
|
|
|
this.form.content = response.oneData.CONTENT
|
|
|
- this.form.image = response.oneData.IMAGE
|
|
|
- this.defaultImageUrl = response.oneData.IMAGE
|
|
|
+ if (response.oneData.TYPE === '1') {
|
|
|
+ this.url = response.oneData.CONTENT
|
|
|
+ } else {
|
|
|
+ this.article = response.oneData.CONTENT
|
|
|
+ }
|
|
|
+
|
|
|
this.allLocation = response.allLocation
|
|
|
+ this.allArticle = response.allArticle
|
|
|
+
|
|
|
this.loading = false
|
|
|
this.isEdit = true
|
|
|
})
|
|
|
} else {
|
|
|
network.getData('ad/add').then(response => {
|
|
|
this.allLocation = response.allLocation
|
|
|
+ this.allArticle = response.allArticle
|
|
|
this.loading = false
|
|
|
})
|
|
|
}
|
|
|
@@ -74,6 +92,10 @@ export default {
|
|
|
loading: false,
|
|
|
submitButtonStat: false,
|
|
|
isEdit: false,
|
|
|
+ imageAd: '',
|
|
|
+ allArticle: [],
|
|
|
+ url: '',
|
|
|
+ article: '',
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -83,6 +105,9 @@ export default {
|
|
|
if (this.$route.name === 'ad_edit') {
|
|
|
path = 'ad/edit/' + this.$route.params.id
|
|
|
}
|
|
|
+
|
|
|
+ this.form.image = this.imageAd
|
|
|
+ this.form.content = this.form.type === '1' ? this.url : this.article
|
|
|
network.postData(path, this.form).then(response => {
|
|
|
this.submitButtonStat = false
|
|
|
this.$message({
|
|
|
@@ -90,13 +115,27 @@ export default {
|
|
|
type: 'success'
|
|
|
})
|
|
|
this.$router.go(-1)
|
|
|
- }).catch(response => {
|
|
|
+ }).catch(_ => {
|
|
|
this.submitButtonStat = false
|
|
|
})
|
|
|
},
|
|
|
handleSuccess (imageUrl) {
|
|
|
- this.form.image = imageUrl
|
|
|
+ this.imageAd = imageUrl
|
|
|
+ this.form.image = SERVER_API_HTTP_TYPE + SERVER_API_DOMAIN + '/uploads/' + imageUrl;
|
|
|
+ this.defaultImageUrl = SERVER_API_HTTP_TYPE + SERVER_API_DOMAIN + '/uploads/' + imageUrl;
|
|
|
},
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ 'form.type': {
|
|
|
+ deep: true,
|
|
|
+ handler: function handler(modern) {
|
|
|
+ if (modern === '1') {
|
|
|
+ this.article = ''
|
|
|
+ } else {
|
|
|
+ this.url = ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|