Browse Source

feat():添加聊天记录

geek 4 years ago
parent
commit
28ed45c6c9

+ 7 - 0
src/api/article.js

@@ -63,3 +63,10 @@ export function deleteArticle(id) {
     method: 'get'
   })
 }
+
+export function commitArticle(id) {
+  return request({
+    url: '/article/commit?id=' + id,
+    method: 'get'
+  })
+}

+ 1 - 1
src/components/Tinymce/index.vue

@@ -139,7 +139,7 @@ export default {
         fontsize_formats: '0pt 8pt 10pt 12pt 14pt 18pt 24pt 36pt',
         link_title: false,
         image_dimensions: false,
-        content_style: "div {margin: 0px; border:0px ; padding: 0px}",
+        content_style: 'div {margin: 0px; border:0px ; padding: 0px}',
         nonbreaking_force_tab: true, // inserting nonbreaking space   need Nonbreaking Space Plugin
         init_instance_callback: editor => {
           if (_this.value) {

+ 9 - 3
src/views/article/components/ArticleDetail.vue

@@ -23,8 +23,11 @@
           <Tinymce ref="editor" v-model="postForm.content" :height="400" />
         </el-form-item>
         <el-row>
-          <el-button v-if="!isEdit" v-loading="loading" type="success" @click="submitForm">
-            提交
+          <el-button v-if="!isEdit" v-loading="loading" type="success" @click="submitForm('')">
+            直接发布
+          </el-button>
+          <el-button v-if="!isEdit" v-loading="loading" type="success" @click="submitForm('commit')">
+            暂存,以后发布
           </el-button>
           <el-button v-if="isEdit" v-loading="loading" type="success" @click="updateArticle">
             修改
@@ -136,7 +139,10 @@ export default {
       const title = 'Edit Article'
       document.title = `${title} - ${this.postForm.id}`
     },
-    submitForm() {
+    submitForm(type) {
+      if (type === 'commit') {
+        this.postForm.commit = true
+      }
       this.$refs.postForm.validate(valid => {
         if (valid) {
           this.loading = true

+ 23 - 3
src/views/article/list.vue

@@ -32,7 +32,7 @@
       <el-table-column class-name="status-col" label="Status" width="80ß">
         <template slot-scope="{row}">
           <el-tag :type="row.status | statusFilter">
-            {{ row.status == 'normal' ? "正常" : "删除" }}
+            {{ row.status == 'normal' ? "正常" : "待发布" }}
           </el-tag>
         </template>
       </el-table-column>
@@ -45,13 +45,16 @@
         </template>
       </el-table-column>
 
-      <el-table-column align="center" label="Actions" width="190" class-name="small-padding fixed-width">
+      <el-table-column align="center" label="Actions" width="320" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <router-link :to="'/article/edit/'+scope.row.id">
             <el-button type="primary" size="mini" icon="el-icon-edit">
               修改
             </el-button>
           </router-link>
+          <el-button type="success" size="mini" icon="el-icon-success" style="margin-left: 10px;" :disabled="scope.row.status == 'normal'" @click="handleUpdate(scope)">
+            {{ scope.row.status == 'normal' ? "已发布" : "发布" }}
+          </el-button>
           <el-button type="danger" size="mini" icon="el-icon-delete" style="margin-left: 10px;" @click="handleDelete(scope)">
             删除
           </el-button>
@@ -64,7 +67,7 @@
 </template>
 
 <script>
-import { fetchList, deleteArticle } from '@/api/article'
+import { fetchList, deleteArticle, commitArticle, fetchArticle } from '@/api/article'
 import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
 import waves from '@/directive/waves'
 
@@ -128,6 +131,23 @@ export default {
             message: '删除成功'
           })
         })
+    },
+    handleUpdate({ $index, row }) {
+      console.log(row.id)
+      this.$confirm('您确定要发布吗', '警告', {
+        confirmButtonText: '是的',
+        cancelButtonText: '取消',
+        type: 'warning'
+      })
+        .then(async() => {
+          await commitArticle(row.id)
+          const rs = await fetchArticle(row.id)
+          this.list.splice($index, 1, rs.data.info)
+          this.$message({
+            type: 'success',
+            message: '发布成功'
+          })
+        })
     }
   }
 }