Bladeren bron

修改教学点

lex-xin 4 jaren geleden
bovenliggende
commit
2f1a5651d0
2 gewijzigde bestanden met toevoegingen van 29 en 11 verwijderingen
  1. 12 5
      src/views/teacher/TeachingSchool.vue
  2. 17 6
      src/views/teacher/TeachingSet.vue

+ 12 - 5
src/views/teacher/TeachingSchool.vue

@@ -27,6 +27,7 @@ import MHeader from '@/components/MHeader'
 import MEmpty from '@/components/MEmpty'
 import { findVipSchoolByTeacher, schoolDel } from '@/api/teacher'
 import { browser }  from '@/common/common'
+import setLoading from '@/utils/loading'
 export default {
     name: 'teachingschool',
     components: { MHeader, MEmpty },
@@ -56,31 +57,37 @@ export default {
         this.getSchoolList()
     },
     mounted() {
-        
+
     },
     methods: {
-        getSchoolList() {
-            findVipSchoolByTeacher({ isDefault: 1 }).then(res => {
+        async getSchoolList() {
+            setLoading(true)
+            await findVipSchoolByTeacher({ isDefault: 1 }).then(res => {
                 let result = res.data
                 if(result.code == 200) {
                     this.schoolList = result.data
                 }
             })
+            setLoading(false)
         },
         onSchoolDel(item) {
             this.$dialog.confirm({
                 title: '提示',
                 message: '您确认删除吗?'
-            }).then(() => {
+            }).then(async () => {
                 // on confirm
-                schoolDel({ id: item.id }).then(res => {
+                setLoading(true)
+                await schoolDel({ id: item.id }).then(res => {
                     let result = res.data
+                    setLoading(false)
                     if(result.code == 200) {
                         this.$toast('删除成功')
                         this.getSchoolList()
                     } else {
                         this.$toast(result.msg)
                     }
+                }).catch(() => {
+                    setLoading(false)
                 })
             })
         },

+ 17 - 6
src/views/teacher/TeachingSet.vue

@@ -48,6 +48,7 @@
 /* eslint-disable */
 import MHeader from '@/components/MHeader'
 import { schoolAdd, schoolUpdate } from '@/api/teacher'
+import setLoading from '@/utils/loading'
 export default {
     name: 'teachingset',
     components: { MHeader },
@@ -124,7 +125,7 @@ export default {
                 }
             }
         },
-        onSubmit() { // 确定提交
+        async onSubmit() { // 确定提交
             if(!this.addressDetail) {
                 this.$toast('请选择教学地点')
                 return
@@ -135,11 +136,13 @@ export default {
             }
             // 添加教学点
             if(this.type == 'create') {
-                schoolAdd({
+                setLoading(true)
+                await schoolAdd({
                     name: this.teachingSchool,
                     address: this.addressDetail,
                     longitudeLatitude: this.lnglat
                 }).then(res => {
+                    setLoading(false)
                     let result = res.data
                     if(result.code == 200) {
                         this.$toast('添加成功')
@@ -147,14 +150,18 @@ export default {
                     } else {
                         this.$toast(result.msg)
                     }
+                }).catch(() => {
+                    setLoading(false)
                 })
             } else if(this.type == 'update') {
-                schoolUpdate({
+                setLoading(true)
+                await schoolUpdate({
                     id: this.$route.query.id,
                     name: this.teachingSchool,
                     address: this.addressDetail,
                     longitudeLatitude: this.lnglat
                 }).then(res => {
+                    setLoading(false)
                     let result = res.data
                     if(result.code == 200) {
                         this.$toast('修改成功')
@@ -162,6 +169,8 @@ export default {
                     } else {
                         this.$toast(result.msg)
                     }
+                }).catch(() => {
+                    setLoading(false)
                 })
             }
         },
@@ -169,7 +178,7 @@ export default {
             if(!this.search_value) return
             this.markers = [] // 重置位置
             let mapSearch = new AMap.PlaceSearch(this.searchOption)
-            
+
             // 目前只需要搜索第一条数据
             mapSearch.search(this.search_value, (status, sr) => {
                 if(sr && sr.poiList && sr.poiList.count) {
@@ -182,6 +191,8 @@ export default {
                     this.center = [pois.location.lng, pois.location.lat]
                 } else if (sr.poiList === undefined) {
                     throw new Error(sr);
+                } else if(sr.poiList && sr.poiList.pois.length <= 0) {
+                    this.$toast('请输入详细地址')
                 }
             })
         },
@@ -223,7 +234,6 @@ export default {
     left: 0;
     z-index: 99;
     padding: .1rem .23rem;
-    
     .van-cell {
         padding: .12rem;
         line-height: .24rem;
@@ -242,7 +252,8 @@ export default {
         color: @mColor;
     }
     .van-search__action {
-        background-color: #89C8C4;
+        // background-color: #89C8C4;
+        background-color: #14928A;
         color: #fff;
         border-radius: 0.15rem;
         position: absolute;