david 2 лет назад
Родитель
Сommit
4f2d1edf4c
2 измененных файлов с 13 добавлено и 2 удалено
  1. 9 0
      src/api/ad.js
  2. 4 2
      src/views/ad/edit.vue

+ 9 - 0
src/api/ad.js

@@ -75,3 +75,12 @@ export function fetchAdd(data) {
     data
   })
 }
+
+// get方式请求 /ad/add 获取下拉框数据
+export function fetchAddSelectList() {
+  return request({
+    url: '/v1/ad/add',
+    method: 'get',
+    params: {}
+  })
+}

+ 4 - 2
src/views/ad/edit.vue

@@ -54,7 +54,7 @@
 </template>
 
 <script>
-import { fetchDetail, fetchEdit, fetchAdd } from '@/api/ad'
+import { fetchDetail, fetchEdit, fetchAdd, fetchAddSelectList } from '@/api/ad'
 import tool from '@/utils/tool'
 import Upload from '@/components/Upload'
 import ElementUI from 'element-ui'
@@ -92,6 +92,7 @@ export default {
     }
   },
   mounted() {
+    console.log('roue.name--->'+this.$route.name)
     if (this.$route.name === 'ad-edit') {
       fetchDetail(this.$route.params.ID).then(response => {
         this.form.title = response.data.oneData.TITLE
@@ -112,13 +113,14 @@ export default {
           ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
       })
     } else {
-      fetchDetail(this.$route.params.ID).then(response => {
+      fetchAddSelectList().then(response => {
         this.allLocation = response.data.allLocation
         this.allArticle = response.data.allArticle
 
         this.loading = false
       }).catch((error) => {
           ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
+          this.loading = false
       })
     }
   },