reloaded 5 years ago
parent
commit
297f1f7350
2 changed files with 28 additions and 15 deletions
  1. 1 8
      src/views/communication/index.vue
  2. 27 7
      src/views/communication/parts/demand.vue

+ 1 - 8
src/views/communication/index.vue

@@ -14,7 +14,7 @@
           <div class="w_1200">
             <el-col :span="24">
               <el-col :span="8" class="left">
-                <demand :demandlist="demandlist"></demand>
+                <demand></demand>
               </el-col>
               <el-col :span="16" class="right"><right :ztytList="ztytList" :jswdList="jswdList" :hyyjList="hyyjList" :kjpxList="kjpxList"></right></el-col>
             </el-col>
@@ -51,13 +51,6 @@ export default {
   },
   data: function() {
     return {
-      demandlist: [
-        {
-          title: 'ceshiceceshiceshichiceshiceshiceshiceshiceshiceshi',
-          date: '2019-03-04',
-        },
-        { title: '16条', date: '2019-03-04' },
-      ],
       ztytList: [
         {
           title: '试测试测',

+ 27 - 7
src/views/communication/parts/demand.vue

@@ -8,8 +8,8 @@
       <el-col :span="24" class="info">
         <el-col :span="24" v-for="(item, index) in demandlist" :key="index" class="list">
           <span></span>
-          <span class="textOver">{{ item.title }}</span>
-          <span>{{ item.date }}</span>
+          <span class="textOver">{{ item.name }}</span>
+          <span>{{ item.meta | getDate }}</span>
         </el-col>
       </el-col>
       <el-col :span="24" class="anniu">
@@ -21,18 +21,38 @@
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: demand } = createNamespacedHelpers('demand');
+const moment = require('moment');
 export default {
   name: 'demand',
-  props: {
-    demandlist: null,
-  },
+  props: {},
   components: {},
   data: () => ({
     src: require('@/assets/exchange.png'),
+    demandlist: [],
   }),
-  created() {},
+  created() {
+    this.search();
+  },
   computed: { ...mapState(['user']) },
-  methods: {},
+  methods: {
+    ...demand(['query']),
+    async search() {
+      const info = { status: '2', is_display: '0' };
+      const res = await this.query({ skip: 0, limit: 16, ...info });
+      this.$set(this, `demandlist`, res.data);
+    },
+  },
+  filters: {
+    getDate(meta) {
+      let createdAt = _.get(meta, `createdAt`);
+      let date = new Date(createdAt)
+        .toLocaleDateString()
+        .replace('/', '-')
+        .replace('/', '-');
+      return date;
+    },
+  },
 };
 </script>