Prechádzať zdrojové kódy

资讯crud与图片上传

qinhouyu 1 rok pred
rodič
commit
7a092ef99d
1 zmenil súbory, kde vykonal 75 pridanie a 19 odobranie
  1. 75 19
      src/views/information/index.vue

+ 75 - 19
src/views/information/index.vue

@@ -9,6 +9,26 @@
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
+      <el-form-item label="是否置顶" prop="isTop">
+        <el-select v-model="queryParams.isTop" placeholder="是否置顶" clearable>
+          <el-option
+            v-for="dict in isTops"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="是否政策推荐" prop="isGovernment">
+        <el-select v-model="queryParams.isGovernment" placeholder="是否政策推荐" clearable>
+          <el-option
+            v-for="dict in isGovernments"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -68,8 +88,19 @@
     <el-table v-loading="loading" :data="serverList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center"/>
       <el-table-column label="序号" align="center" type="index"/>
-      <el-table-column label="标题" align="center" prop="titleName"/>
-      <el-table-column label="正文" align="center" prop="textDetails" show-overflow-tooltip/>
+      <el-table-column label="标题" align="center" prop="titleName" show-overflow-tooltip/>
+      <el-table-column label="是否政策推荐" align="center" prop="isGovernment">
+        <template slot-scope="scope">
+          {{scope.row.isGovernment=='1'?'是':'否'}}
+        </template>
+      </el-table-column>
+      <el-table-column label="是否置顶" align="center" prop="isTop">
+        <template slot-scope="scope">
+          {{scope.row.isTop=='1'?'是':'否'}}
+        </template>
+      </el-table-column>
+      <el-table-column label="点赞数" align="center" prop="likeNum" show-overflow-tooltip/>
+      <el-table-column label="浏览数" align="center" prop="watchNum" show-overflow-tooltip/>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -101,14 +132,34 @@
     />
 
     <!-- 添加或修改资讯对话框 -->
-    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
+    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-form-item label="标题" prop="titleName">
-          <el-input v-model="form.titleName" placeholder="请输入标题"/>
+          <el-input v-model="form.titleName" placeholder="请输入标题" maxlength="50"/>
         </el-form-item>
         <el-form-item label="正文" prop="textDetails">
           <editor v-model="form.textDetails" :min-height="192"/>
         </el-form-item>
+        <el-form-item label="是否政策推荐" prop="isGovernment">
+          <el-switch
+            v-model="form.isGovernment"
+            active-value="0"
+            inactive-value="1">
+          </el-switch>
+        </el-form-item>
+        <el-form-item label="是否置顶" prop="isTop">
+          <el-switch
+            v-model="form.isTop"
+            active-value="0"
+            inactive-value="1">
+          </el-switch>
+        </el-form-item>
+        <el-form-item label="点赞数" prop="likeNum">
+          <el-input-number v-model="form.likeNum" :min="1" :max="999999999" label="点赞数"></el-input-number>
+        </el-form-item>
+        <el-form-item label="浏览数" prop="watchNum">
+          <el-input-number v-model="form.watchNum" :min="1" :max="999999999" label="浏览数"></el-input-number>
+        </el-form-item>
         <el-form-item label="图片" prop="imgUrlList">
           <image-upload v-model="form.imgUrlList"/>
         </el-form-item>
@@ -133,6 +184,8 @@ export default {
       loading: true,
       // 选中数组
       ids: [],
+      isGovernments: [{label:'是',value:'1'},{label: '否',value: '0'}],
+      isTops: [{label:'是',value:'1'},{label: '否',value: '0'}],
       // 非单个禁用
       single: true,
       // 非多个禁用
@@ -152,15 +205,15 @@ export default {
         pageNum: 1,
         pageSize: 10,
         titleName: null,
-        textDetails: null,
-        type: null,
+        isGovernment: null,
+        isTop: null,
+        type: this.$route.query.type,
+        delFlag: 0,
       },
       // 表单参数
       form: {},
       // 表单校验
-      rules: {
-
-      }
+      rules: {}
     };
   },
   created() {
@@ -189,11 +242,14 @@ export default {
         titleName: null,
         textDetails: null,
         type: this.$route.query.type,
-        createBy: null,
         createTime: null,
+        watchNum: 0,
+        likeNum: 0,
+        isTop: null,
+        isGovernment: null,
         updateBy: null,
         updateTime: null,
-        imgUrlList: null,
+        imgUrlList: '',
         delFlag: 0,
       };
       this.resetForm("form");
@@ -219,14 +275,14 @@ export default {
       this.reset();
       this.open = true;
       let str = ''
-      if (this.$route.query.type==10){
+      if (this.$route.query.type == 10) {
         str = '惠民通'
-      }else if(this.$route.query.type==11){
+      } else if (this.$route.query.type == 11) {
         str = '法律下乡'
-      }else if(this.$route.query.type==12){
+      } else if (this.$route.query.type == 12) {
         str = '资讯'
       }
-      this.title = "修改"+str;
+      this.title = "修改" + str;
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
@@ -236,14 +292,14 @@ export default {
         this.form = response.data;
         this.open = true;
         let str = ''
-        if (this.$route.query.type==10){
+        if (this.$route.query.type == 10) {
           str = '惠民通'
-        }else if(this.$route.query.type==11){
+        } else if (this.$route.query.type == 11) {
           str = '法律下乡'
-        }else if(this.$route.query.type==12){
+        } else if (this.$route.query.type == 12) {
           str = '资讯'
         }
-        this.title = "修改"+str;
+        this.title = "修改" + str;
       });
     },
     /** 提交按钮 */