Selaa lähdekoodia

Merge branch 'develop/3.1.7' into test

DESKTOP-SVI9JE1\muzen 1 vuosi sitten
vanhempi
commit
39dbbeb2ca

+ 40 - 1
src/mixin/index.js

@@ -10,6 +10,8 @@ import { list as functionList } from '@/api/device/function'
 
 import { options as blogClass } from '@/api/music/blogclass'
 
+import { options as mapList } from '@/api/operation/map'
+
 // 设备列表
 const devMixin = {
   data() {
@@ -615,6 +617,42 @@ const systemMixin = {
   }
 }
 
+// 省市区
+const mapMixin = {
+  data() {
+    return {
+      mapOptions: []
+    }
+  },
+  async mounted() {
+    await this.getMapOptions()
+  },
+  methods: {
+    // 省市区
+    getMapOptions() {
+      return new Promise((reslove, reject) => {
+        mapList().then(res => {
+          if (res.code === 0) {
+            reslove(this.mapOptions = res.data)
+          }
+        })
+      })
+    },
+    
+    areaFormatter(row) {
+      if (this.mapOptions.length > 0) {
+        let province = this.mapOptions.find(i => i.id == row.province)
+        let provinceName = province.name
+        let city = province.childList.length > 0 ? province.childList.find(i => i.id == row.city) : ''
+        let cityName = city ? `-${city.name}` : ''
+        let area = city && city.childList.length > 0 ? city.childList.find(i => i.id == row.area) : ''
+        let areaName = area ? `-${area.name}` : ''
+        return `${provinceName}${cityName}${areaName}`
+      }
+    },
+  }
+}
+
 export {
   devMixin,
   devModeMixin,
@@ -640,5 +678,6 @@ export {
   coverMixin,
   channelMixin,
   systemMixin,
-  blogClassMixin
+  blogClassMixin,
+  mapMixin
 }

+ 15 - 4
src/views/music/radio/detail.vue

@@ -10,6 +10,10 @@
             :disabled="disabledJoinType(item.joinType)" />
         </el-select>
       </el-form-item>
+      <el-form-item label="城市筛选:" prop="cascader">
+        <el-cascader v-model="form.cascader" :options="mapOptions" placeholder="请选择省市区"  clearable
+          :props="{ value: 'id', label: 'name', children: 'childList', checkStrictly: true }" style="width: 100%" />
+      </el-form-item>
       <el-form-item v-if="form.platformId !== 4" label="地域分类:" prop="addressClassifyId">
         <el-select v-model="form.addressClassifyId" placeholder="请选择地域分类">
           <el-option v-for="item in addressOptions" :key="item.value" :value="item.value.toString()"
@@ -45,13 +49,14 @@
 
 <script>
 import { submit, detail } from '@/api/music/radio'
-import { platformMixin, addressMixin, contentMixin } from '@/mixin/index'
+import { platformMixin, addressMixin, contentMixin, mapMixin } from '@/mixin/index'
 export default {
-  mixins: [platformMixin, addressMixin, contentMixin],
+  mixins: [platformMixin, addressMixin, contentMixin, mapMixin],
   data() {
     return {
       // 表单
       form: {
+        addressClassifyId: null,
         status: 1
       },
       // 校验
@@ -59,6 +64,9 @@ export default {
         name: [{
           required: true, message: '请输入电台名称', trigger: 'blur'
         }],
+        cascader: [{
+          required: true, message: '请选择省市区', trigger: 'change'
+        }],
         addressClassifyId: [{
           required: true, message: '请选择地域分类', trigger: 'change'
         }],
@@ -96,6 +104,7 @@ export default {
       detail(this.form.id).then(res => {
         if (res.code === 0) {
           this.form = res.data
+          this.form.cascader = [res.data.province, res.data.city, res.data.area]
         }
       })
     },
@@ -107,10 +116,12 @@ export default {
     getSubmit() {
       this.$refs.form.validate((valid) => {
         if (valid) {
-          let title = this.form.id ? `编辑成功!` : `新增成功!`
+          this.form.province = this.form.cascader[0]
+          this.form.city = this.form.cascader[1]
+          this.form.area = this.form.cascader[2]
           submit(this.form).then(res => {
             if (res.code === 0) {
-              this.$message.success(`${title}`)
+              this.$message.success(`提交成功!`)
               this.cancel()
             }
           })

+ 7 - 2
src/views/music/radio/index.vue

@@ -10,6 +10,10 @@
           <el-option v-for="item in platformOptions" :key="item.value" :value="item.value" :label="item.label" />
         </el-select>
       </el-form-item>
+      <el-form-item label="城市筛选:">
+        <el-cascader v-model="form.list" :options="mapOptions" placeholder="请选择省市区" clearable
+          :props="{ value: 'id', label: 'name', children: 'childList', checkStrictly: true }" />
+      </el-form-item>
       <el-form-item label="地域分类:">
         <el-select v-model="form.addressClassifyId" placeholder="请选择地域分类" clearable>
           <el-option v-for="item in addressOptions" :key="item.value" :value="item.value" :label="item.label" />
@@ -46,6 +50,7 @@
           <el-image v-if="scope.row.thumb" :src="scope.row.thumb" />
         </template>
       </el-table-column>
+      <el-table-column label="地区" align="center" :formatter="areaFormatter" />
       <el-table-column label="地域分类" prop="addressClassifyId" align="center" :formatter="addressFormatter" />
       <el-table-column label="广播分类" prop="contentClassifyName" align="center" :formatter="contentFormatter" />
       <el-table-column label="资源平台" prop="platformId" align="center" :formatter="platformFormatter" />
@@ -70,11 +75,11 @@
 </template>
 
 <script>
-import { platformMixin, onOrOffMixin, addressMixin, contentMixin } from '@/mixin/index'
+import { platformMixin, onOrOffMixin, addressMixin, contentMixin, mapMixin } from '@/mixin/index'
 import { list, change, remove } from '@/api/music/radio'
 import Audio from '@/components/Audio/index.vue'
 export default {
-  mixins: [platformMixin, onOrOffMixin, addressMixin, contentMixin],
+  mixins: [platformMixin, onOrOffMixin, addressMixin, contentMixin, mapMixin],
   components: {
     Audio
   },

+ 4 - 14
src/views/operation/map/detail.vue

@@ -11,7 +11,7 @@
         <el-input v-model="form.linkPhone" placeholder="请输入联系电话" />
       </el-form-item>
       <el-form-item label="城市筛选:" prop="cascader">
-        <el-cascader style="width: 100%" v-model="form.cascader" :options="options" placeholder="请选择省市区"
+        <el-cascader style="width: 100%" v-model="form.cascader" :options="mapOptions" placeholder="请选择省市区"
           :props="{ value: 'id', label: 'name', children: 'childList', checkStrictly: true }" />
       </el-form-item>
       <el-form-item label="详细地址:" prop="address">
@@ -32,8 +32,10 @@
 </template>
 
 <script>
-import { detail, options, submit } from '@/api/operation/map'
+import { mapMixin } from '@/mixin/index'
+import { detail, submit } from '@/api/operation/map'
 export default {
+  mixins: [ mapMixin ],
   data() {
     return {
       // 表单
@@ -41,8 +43,6 @@ export default {
         icon: '',
         status: 0
       },
-      // 省市区
-      options: [],
       // 校验
       rules: {
         name: [{
@@ -69,7 +69,6 @@ export default {
     }
   },
   mounted() {
-    this.getOptions()
     if (this.$route.query.id) {
       this.getDetail()
       this.disabled = Boolean(this.$route.query.boolean)
@@ -91,15 +90,6 @@ export default {
       this.form.icon = e.file
     },
 
-    // 省市区
-    getOptions() {
-      options().then(res => {
-        if (res.code === 0) {
-          this.options = res.data
-        }
-      })
-    },
-
     cancel() {
       this.$tab.closeOpenPage("/operation/map")
     },

+ 5 - 27
src/views/operation/map/index.vue

@@ -6,7 +6,7 @@
         <el-input v-model="form.name" placeholder="请输入门店名称" clearable />
       </el-form-item>
       <el-form-item label="城市筛选:">
-        <el-cascader v-model="form.list" :options="options" placeholder="请选择省市区" clearable
+        <el-cascader v-model="form.list" :options="mapOptions" placeholder="请选择省市区" clearable
           :props="{ value: 'id', label: 'name', children: 'childList', checkStrictly: true }" />
       </el-form-item>
       <el-form-item label="当前状态:">
@@ -59,8 +59,10 @@
 </template>
 
 <script>
-import { list, options, change, remove } from '@/api/operation/map'
+import { mapMixin } from '@/mixin/index'
+import { list, change, remove } from '@/api/operation/map'
 export default {
+  mixins: [mapMixin],
   data() {
     return {
       // 遮罩层
@@ -73,8 +75,6 @@ export default {
       },
       // 总数据
       total: 0,
-      // 省市区
-      options: [],
       // 列表
       tableData: [],
       // 当前状态
@@ -94,8 +94,7 @@ export default {
       this.form.area = val[2]
     }
   },
-  async mounted() {
-    await this.getOptions()
+  mounted() {
     this.getList()
   },
   methods: {
@@ -126,17 +125,6 @@ export default {
       this.getList()
     },
 
-    // 省市区
-    getOptions() {
-      return new Promise((reslove, reject) => {
-        options().then(res => {
-          if (res.code === 0) {
-            reslove(this.options = res.data)
-          }
-        })
-      })
-    },
-
     // 新增、 编辑、 查看
     getDetail(id, boolean) {
       this.$router.push({
@@ -173,16 +161,6 @@ export default {
     },
 
     // 字典翻译
-    areaFormatter(row) {
-      let province = this.options.find(i => i.id == row.province)
-      let provinceName = province.name
-      let city = province.childList.length > 0 ? province.childList.find(i => i.id == row.city) : ''
-      let cityName = city ? `-${city.name}` : ''
-      let area = city && city.childList.length > 0 ? city.childList.find(i => i.id == row.area) : ''
-      let areaName = area ? `-${area.name}` : ''
-      return `${provinceName}${cityName}${areaName}`
-    },
-
     statusFormatter(row) {
       return this.selectDictLabel(this.statusOptions, row.status)
     }