guhongwei 5 年之前
父節點
當前提交
13c429995f
共有 1 個文件被更改,包括 105 次插入36 次删除
  1. 105 36
      src/views/pcenter/parts/infoAdmin.vue

+ 105 - 36
src/views/pcenter/parts/infoAdmin.vue

@@ -13,19 +13,29 @@
               <el-table-column prop="publish_unit" label="发布单位" align="center"> </el-table-column>
               <el-table-column label="状态" align="center">
                 <template slot-scope="scope">
-                  <span>{{ scope.row.status == '0' ? '草稿' : scope.row.status == '1' ? '审核中' : scope.row.status == '2' ? '审核通过' : '未识别' }}</span>
+                  <span>{{
+                    scope.row.status == '0'
+                      ? '草稿'
+                      : scope.row.status == '1'
+                      ? '审核中'
+                      : scope.row.status == '2'
+                      ? '审核通过'
+                      : scope.row.status == '3'
+                      ? '审核拒绝'
+                      : '未识别'
+                  }}</span>
                 </template>
               </el-table-column>
               <el-table-column label="操作" align="center" width="220">
-                <template slot-scope="">
-                  <el-button size="mini" type="primary">编辑</el-button>
-                  <el-button size="mini" type="success">发布</el-button>
+                <template slot-scope="scope">
+                  <el-button size="mini" type="primary" @click="examineBtn(scope.row)" v-if="user.type == '0' || user.type == '1'">审核</el-button>
+                  <el-button size="mini" type="primary" v-if="scope.row.status == '0'" @click="examineBtn(scope.row)">编辑</el-button>
+                  <el-button size="mini" type="success" v-if="scope.row.status == '0'" @click="submitInfo(scope.row)">发布</el-button>
                   <el-button size="mini" type="danger">删除</el-button>
-                  <!-- <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
-                  <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button> -->
                 </template>
               </el-table-column>
             </el-table>
+            <page :total="total" position="right"></page>
           </el-col>
         </span>
         <span v-else>
@@ -83,13 +93,6 @@
                   <el-radio label="1">推荐</el-radio>
                 </el-radio-group>
               </el-form-item>
-              <el-form-item label="状态" prop="status" v-if="user.type == '0' || user.type == '1'">
-                <el-radio-group v-model="form.status">
-                  <el-radio label="0">草稿</el-radio>
-                  <el-radio label="1">审核中</el-radio>
-                  <el-radio label="2">审核通过</el-radio>
-                </el-radio-group>
-              </el-form-item>
               <el-col :span="24" style="text-align:center;">
                 <el-button type="success" v-if="user.type == '0' || user.type == '1'" @click="examineIn()">审核通过</el-button>
                 <el-button type="danger" v-if="user.type == '0' || user.type == '1'" @click="examineOut()">审核拒绝</el-button>
@@ -108,6 +111,7 @@
 <script>
 import upload from '@/components/upload.vue';
 import wangEditor from '@/components/wang-editor.vue';
+import page from '@/components/pagination.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: news } = createNamespacedHelpers('news');
 export default {
@@ -116,12 +120,14 @@ export default {
   components: {
     upload,
     wangEditor,
+    page,
   },
   data: function() {
     return {
       display: 'list',
       // 列表
       list: [],
+      total: 0,
       // 选择栏目
       column_list: [
         { value: '科技资讯', label: '科技资讯' },
@@ -167,11 +173,12 @@ export default {
     this.searchInfo();
   },
   methods: {
-    ...news({ newsQuery: 'query', newsCreate: 'create' }),
-    async searchInfo({ skip = 0, limit = 0, col_name = '工作动态', ...info } = {}) {
-      let res = await this.newsQuery({ skip, limit, col_name, ...info });
+    ...news({ newsQuery: 'query', newsCreate: 'create', newsUpdate: 'update' }),
+    async searchInfo({ skip = 0, limit = 10, ...info } = {}) {
+      let res = await this.newsQuery({ skip, limit, ...info });
       if (this.$checkRes(res)) {
         this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
       }
     },
     // 添加
@@ -182,32 +189,101 @@ export default {
     back() {
       this.display = 'list';
     },
+    // 列表发布信息
+    async submitInfo(data) {
+      data.status = '1';
+      let res = await this.newsUpdate(data);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '发布信息成功',
+          type: 'success',
+        });
+        this.searchInfo();
+      }
+    },
+    // 列表审核打开
+    examineBtn(data) {
+      this.display = 'detail';
+      this.$set(this, `form`, data);
+    },
+    // 详情审核通过
+    async examineIn() {
+      this.form.status = '2';
+      let res = await this.newsUpdate(this.form);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '审核通过',
+          type: 'success',
+        });
+      }
+    },
+    // 详情审核拒绝
+    async examineOut() {
+      this.form.status = '3';
+      let res = await this.newsUpdate(this.form);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '审核拒绝',
+          type: 'error',
+        });
+      }
+    },
     // 保存草稿
     submitDraft(formName) {
       this.$refs[formName].validate(async valid => {
         if (valid) {
-          this.form.uid = this.user.uid;
-          this.form.status = '0';
-          let res = await this.newsCreate(this.form);
-          if (this.$checkRes(res)) {
-            console.log(res);
+          if (this.form.publisher) {
+            let res = await this.newsUpdate(this.form);
+            if (this.$checkRes(res)) {
+              this.$message({
+                message: '保存修改成功',
+                type: 'success',
+              });
+              this.display = 'list';
+            }
+          } else {
+            this.form.publisher = this.user.uid;
+            this.form.status = '0';
+            let res = await this.newsCreate(this.form);
+            if (this.$checkRes(res)) {
+              this.$message({
+                message: '保存成功',
+                type: 'success',
+              });
+              this.display = 'list';
+            }
           }
-          console.log(this.form);
         } else {
           console.log('error submit!!');
           return false;
         }
       });
     },
-    // 提交
+    // 提交发布
     submitForm(formName) {
       this.$refs[formName].validate(async valid => {
         if (valid) {
-          this.form.publisher = this.user.uid;
-          this.form.status = '1';
-          let res = await this.newsCreate(this.form);
-          if (this.$checkRes(res)) {
-            console.log(res);
+          if (this.form.publisher) {
+            this.form.status = '1';
+            let res = await this.newsUpdate(this.form);
+            if (this.$checkRes(res)) {
+              this.$message({
+                message: '发布信息成功',
+                type: 'success',
+              });
+              this.display = 'list';
+            }
+          } else {
+            this.form.publisher = this.user.uid;
+            this.form.status = '1';
+            let res = await this.newsCreate(this.form);
+            if (this.$checkRes(res)) {
+              this.$message({
+                message: '创建信息成功',
+                type: 'success',
+              });
+              this.display = 'list';
+            }
           }
         } else {
           console.log('error submit!!');
@@ -218,14 +294,7 @@ export default {
     // 取消
     resetForm(formName) {
       this.$refs[formName].resetFields();
-    },
-    // 审核通过
-    examineIn() {
-      console.log('审核通过');
-    },
-    // 审核拒绝
-    examineOut() {
-      console.log('审核拒绝');
+      this.display = 'list';
     },
     // 图片
     uploadSuccess({ type, data }) {