wuhongyu 5 years ago
parent
commit
e2224abdb8

+ 16 - 0
src/layout/duijiehui/duijiedetail.vue

@@ -26,6 +26,16 @@
               >
               </el-date-picker>
             </el-form-item>
+            <el-form-item label="省份">
+              <el-select v-model="form.province" placeholder="请选择省份" @change="changeshenge">
+                <el-option v-for="item in option" :key="item.code" :label="item.name" :value="item.code"> </el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item label="市">
+              <el-select v-model="form.place" placeholder="请选择市">
+                <el-option v-for="item in options" :key="item.code" :label="item.name" :value="item.code"> </el-option>
+              </el-select>
+            </el-form-item>
             <el-form-item label="简介">
               <el-input type="textarea" v-model="form.desc"></el-input>
             </el-form-item>
@@ -44,6 +54,8 @@ export default {
   name: 'columnDetail',
   props: {
     form: null,
+    option: null,
+    options: null,
   },
   components: {},
   data: () => ({}),
@@ -56,6 +68,10 @@ export default {
     returnBtn() {
       this.$router.push({ path: '/duijiehui/index' });
     },
+    changeshenge(value) {
+      console.log(value);
+      this.$emit('placesubmit', { value });
+    },
   },
 };
 </script>

+ 3 - 0
src/store/index.js

@@ -39,6 +39,8 @@ import authUser from '@common/store/user/auth-user';
 import role from '@common/store/user/role';
 import * as ustate from '@common/store/user/state';
 import * as umutations from '@common/store/user/mutations';
+import place from '@common/store/place/place';
+
 Vue.use(Vuex);
 
 export default new Vuex.Store({
@@ -75,6 +77,7 @@ export default new Vuex.Store({
     login,
     role,
     authUser,
+    place,
   },
   state: { ...ustate },
   mutations: { ...umutations },

+ 20 - 1
src/views/duijiehui/detail.vue

@@ -5,7 +5,7 @@
         <topInfo :topTitle="topTitle"></topInfo>
       </el-col>
       <el-col :span="24" class="main">
-        <duijiedetail :form="form" @submitDate="onSubmit"></duijiedetail>
+        <duijiedetail :form="form" @submitDate="onSubmit" @placesubmit="placesubmit" :option="option" :options="options"></duijiedetail>
       </el-col>
     </el-row>
   </div>
@@ -16,6 +16,7 @@ import topInfo from '@/layout/public/top.vue';
 import duijiedetail from '@/layout/duijiehui/duijiedetail.vue';
 import { createNamespacedHelpers, mapState } from 'vuex';
 const { mapActions: live } = createNamespacedHelpers('live');
+const { mapActions: place } = createNamespacedHelpers('place');
 export default {
   name: 'columnDetail',
   props: {},
@@ -27,9 +28,12 @@ export default {
     topTitle: '对接会详情',
     form: {},
     xinxi: {},
+    option: [],
+    options: [],
   }),
   created() {
     this.search();
+    this.searchinfo();
   },
   computed: {
     ...mapState(['user']),
@@ -44,6 +48,7 @@ export default {
     },
   },
   methods: {
+    ...place({ palcequery: 'query', transactiondtetle: 'delete' }),
     ...live({ livefetch: 'fetch', livelist: 'query', livecreate: 'create', liveupdate: 'update' }),
     async search() {
       if (this.$route.query.id) {
@@ -51,6 +56,20 @@ export default {
         this.$set(this, `form`, res.data);
       }
     },
+    async placesubmit({ value }) {
+      let level = 2;
+      let parent = value;
+      console.log(parent);
+      let res = await this.palcequery({ level, parent });
+      this.$set(this, `options`, res.data);
+    },
+
+    async searchinfo() {
+      // let parent = 220000;
+      let level = 1;
+      let res = await this.palcequery({ level });
+      this.$set(this, `option`, res.data);
+    },
     async onSubmit() {
       if (this.id) {
         let res = await this.liveupdate(this.form);

+ 26 - 7
src/views/duijiehui/index.vue

@@ -32,8 +32,8 @@
 import topInfo from '@/layout/public/top.vue';
 import dataTable from '@/components/data-table.vue';
 import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
-
 const { mapActions: live } = createNamespacedHelpers('live');
+const { mapActions: place } = createNamespacedHelpers('place');
 export default {
   name: 'index',
   props: {},
@@ -87,7 +87,10 @@ export default {
       { label: '对接会简介', prop: 'desc' },
       { label: '开始时间', prop: 'start_time' },
       { label: '报名截止时间', prop: 'join_end' },
+      { label: '省', prop: 'sheng' },
+      { label: '市', prop: 'shi' },
       { label: '对接会简介', prop: 'desc' },
+
       {
         label: '审核状态',
         prop: 'is_allowed',
@@ -114,16 +117,32 @@ export default {
   },
   methods: {
     ...live(['query', 'delete', 'update']),
+    ...place({ palcequery: 'query', palcefetch: 'fetch' }),
     async search({ skip = 0, limit = 10, ...info } = {}) {
       if (this.user.role != '1') info.user_id = this.user.uid;
-      const res = await this.query({ skip, limit, ...info });
-      if (this.$checkRes(res)) {
-        for (const val of res.data) {
-          val.role = this.user.role;
+      // const res = await this.query({ skip, limit, ...info });
+      // if (this.$checkRes(res)) {
+      //   for (const val of res.data) {
+      //     val.role = this.user.role;
+      //   }
+      let res = await this.query({ skip, limit });
+      for (const val of res.data) {
+        let parent = val.province;
+        let places = val.place;
+        let reslte = await this.palcequery({ level: 1, parent });
+        let resltes = await this.palcequery({ level: 2, parent });
+        var arr = reslte.data.filter(item => item.code === parent);
+        var cre = resltes.data.filter(item => item.code === places);
+        for (const shi of cre) {
+          val.shi = shi.name;
+        }
+        for (const sheng of arr) {
+          val.sheng = sheng.name;
         }
-        this.$set(this, `list`, res.data || []);
-        this.$set(this, `total`, res.total);
       }
+      console.log(res.data);
+      this.$set(this, `list`, res.data);
+      this.$set(this, `total`, res.total);
     },
     toEdit({ data }) {
       this.$router.push({ path: './detail', query: { id: data.id } });