lrf402788946 4 years ago
parent
commit
092f858924

+ 17 - 5
src/views/adminCenter/adminRefute.vue

@@ -10,8 +10,12 @@
           </van-nav-bar>
         </el-col>
         <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }" ref="list">
-          <item></item>
-          <page :total="total" :limit="limit"></page>
+          <template v-for="(i, index) in list">
+            <item :key="`list${index}`" :data="i"></item>
+          </template>
+          <van-sticky container="list" :offset-top="clientHeight">
+            <page :total="total" :limit="limit"></page>
+          </van-sticky>
         </el-col>
         <el-col :span="24" class="foot">
           <foot></foot>
@@ -39,18 +43,26 @@ export default {
   data: function() {
     return {
       clientHeight: '',
+      list: [],
       total: 0,
-      limit: 5,
+      limit: '5',
     };
   },
-  created() {},
+  created() {
+    this.search();
+  },
   mounted() {
     let clientHeight = (document.documentElement.clientHeight || document.body.clientHeight) - 90;
     this.$set(this, `clientHeight`, clientHeight);
   },
   methods: {
     ...refute(['query']),
-    async search() {},
+    async search({ skip = 0 } = {}) {
+      const res = await this.query({ skip, limit: this.limit });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+      }
+    },
     toAdd() {
       this.$router.push('/adminRefute/edit');
     },

+ 5 - 2
src/views/adminCenter/refute/edit.vue

@@ -3,7 +3,7 @@
     <el-row>
       <el-col :span="24" class="main">
         <el-col :span="24" class="top">
-          <van-nav-bar :title="pageTitle" left-text="取消" @click-left="toCancel" right-text="发表" @click-right="toSubmit" />
+          <van-nav-bar :title="pageTitle" left-text="取消" @click-left="toCancel" :right-text="id ? '修改' : '发表'" @click-right="toSubmit" />
         </el-col>
         <el-col :span="24">
           <van-form ref="form" style="margin-top:30px">
@@ -55,7 +55,10 @@ export default {
     async search() {
       const res = await this.fetch(this.id);
       if (this.$checkRes(res, null, res.errmsg || '未找到指定数据')) {
-        this.$set(this, `form`, res.data);
+        let dup = _.cloneDeep(res.data);
+        if (_.get(dup, 'imgUrl')) dup.imgUrl = [{ url: dup.imgUrl }];
+        if (_.get(dup, 'fileUrl')) dup.fileUrl = [{ url: dup.fileUrl }];
+        this.$set(this, `form`, dup);
       }
     },
     async toSubmit() {

+ 61 - 5
src/views/adminCenter/refute/item.vue

@@ -1,6 +1,25 @@
 <template>
   <div id="item">
-    <p>item</p>
+    <el-row type="flex" class="list__row" @click.native="toEdit">
+      <el-col :span="9">
+        <van-image :src="data.imgUrl" :width="imgpx" :height="imghpx" fit="scale-down">
+          <template #error>
+            <van-image :src="noImg" :width="imgpx" :height="imghpx" fit="scale-down" />
+          </template>
+        </van-image>
+      </el-col>
+      <el-col :span="14">
+        <el-row>
+          <el-col :span="24" class="dl2">{{ data.title }}</el-col>
+          <el-col :span="24">
+            <el-row type="flex" align="middle" class="last__row">
+              <el-col :span="18"> {{ data.create_time }} </el-col>
+              <el-col :span="6">阅读: {{ data.read }} </el-col>
+            </el-row>
+          </el-col>
+        </el-row>
+      </el-col>
+    </el-row>
   </div>
 </template>
 
@@ -8,18 +27,30 @@
 import { mapState, createNamespacedHelpers } from 'vuex';
 export default {
   name: 'item',
-  props: {},
+  props: { data: { type: Object, default: () => {} } },
   components: {},
   data: function() {
-    return {};
+    return {
+      noImg: require('@a/noImg.jpg'),
+    };
   },
   created() {},
-  methods: {},
+  methods: {
+    toEdit() {
+      this.$router.push({ path: '/adminRefute/edit', query: { id: this.data._id } });
+    },
+  },
   computed: {
     ...mapState(['user', 'menuParams']),
     pageTitle() {
       return `${this.$route.meta.title}`;
     },
+    imgpx() {
+      return 120;
+    },
+    imghpx() {
+      return this.imgpx * 0.8;
+    },
   },
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -27,4 +58,29 @@ export default {
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+@wordHeight: 1rem;
+@subWord: #666666;
+.list__row {
+  padding: 0.3125rem;
+  border-bottom: 1px solid #ccc;
+  min-height: 6.375rem;
+}
+.s__row {
+  position: relative;
+}
+.last__row {
+  position: absolute;
+  bottom: 15px;
+  font-size: 0.875rem;
+  color: @subWord;
+}
+.dl2 {
+  overflow: hidden;
+  text-overflow: ellipsis;
+  -webkit-line-clamp: 2;
+  word-break: break-all;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+}
+</style>