浏览代码

新闻咨询

gks 1 年之前
父节点
当前提交
3a77e78566
共有 2 个文件被更改,包括 77 次插入36 次删除
  1. 4 2
      src/views/COUNSELINGMESSAGE/edit.vue
  2. 73 34
      src/views/news/edit.vue

+ 4 - 2
src/views/COUNSELINGMESSAGE/edit.vue

@@ -30,8 +30,8 @@
     </el-form>
 
     <div slot="footer" class="mfooter">
-      <el-button type="info" @click="submitzc">暂 存</el-button>
-      <el-button type="primary" @click="submitForm">确 定</el-button>
+      <el-button type="info" @click="submitzc" v-if="checkPermi(['business:COUNSELINGMESSAGE:confirm'])">暂 存</el-button>
+      <el-button type="primary" @click="submitForm" v-if="checkPermi(['business:COUNSELINGMESSAGE:confirm'])">确 定</el-button>
       <el-button @click="$layer.close(layerid)">取 消</el-button>
     </div>
     <el-dialog :visible.sync="dialogVisible" :close-on-click-modal="false" fullscreen append-to-body @close="dialogVisible = false">
@@ -42,6 +42,7 @@
 
 <script>
 import { listCOUNSELINGMESSAGE, getCOUNSELINGMESSAGE, delCOUNSELINGMESSAGE, addCOUNSELINGMESSAGE, updateCOUNSELINGMESSAGE, upload, newCommit } from '@/api/portal/COUNSELINGMESSAGE/COUNSELINGMESSAGE';
+import { checkPermi } from "@/utils/permission";
 
 export default {
   name: 'edit.vue',
@@ -82,6 +83,7 @@ export default {
     }
   },
   methods:{
+    checkPermi,
     //旧的图片上传
     httprequest() {},
     /** 上传附件 */

+ 73 - 34
src/views/news/edit.vue

@@ -7,8 +7,17 @@
       <el-row>
         <el-col :span="12">
           <el-form-item label="新闻类型" prop="type">
-            <el-select v-model="form.type" placeholder="请选择" style="width: 100%">
-              <el-option v-for="item in typeList" :key="item.value + 'typeList'" :label="item.label" :value="item.value"></el-option>
+            <el-select
+              v-model="form.type"
+              placeholder="请选择"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in typeList"
+                :key="item.value + 'typeList'"
+                :label="item.label"
+                :value="item.value"
+              ></el-option>
             </el-select>
           </el-form-item>
         </el-col>
@@ -26,34 +35,56 @@
       </el-form-item>
     </el-form>
     <div class="mfooter">
-      <el-button type="primary" @click="submitForm">确 定</el-button>
+      <el-button v-if="checkPermi(['business:NEWS:confirm'])" type="primary" @click="submitForm('add')" >确 定</el-button>
+      <el-button v-if="checkPermi(['business:NEWS:confirm'])" type="warning" @click="submitForm('draft')">暂 存</el-button>
       <el-button @click="$layer.close(layerid)">取 消</el-button>
     </div>
   </div>
 </template>
 
 <script>
-import { listNEWS, getNEWS, delNEWS, addNEWS, updateNEWS, upload, setTop, newCommit, updateAndex, downloadpic } from '@/api/portal/news/NEWS.js';
+import { checkPermi } from "@/utils/permission";
+import {
+  listNEWS,
+  getNEWS,
+  delNEWS,
+  addNEWS,
+  updateNEWS,
+  upload,
+  setTop,
+  newCommit,
+  updateAndex,
+  downloadpic,
+} from "@/api/portal/news/NEWS.js";
 export default {
   data() {
     return {
       typeList: [
-        { label: '要闻动态', value: 1 },
-        { label: '政策文件', value: 2 },
-        { label: '通知公告', value: 3 },
-        { label: '政策解读', value: 4 },
-        { label: '投资导航', value: 5 }
+        { label: "要闻动态", value: 1 },
+        { label: "政策文件", value: 2 },
+        { label: "通知公告", value: 3 },
+        { label: "政策解读", value: 4 },
+        { label: "投资导航", value: 5 },
       ],
-      form: {type:2},
+      form: { type: 2 },
       rules: {
-        title: [{ required: true, message: '标题不能为空', trigger: 'blur' }],
-        content: [{ required: true, message: '内容不能为空', trigger: 'blur' }],
-        fileUrl: [{ required: true, message: '附件不能为空', trigger: 'blur' }],
-        type: [{ required: true, message: '类型不能为空', trigger: 'change' }],
-        typeName: [{ required: true, message: '字典类型名称不能为空', trigger: 'blur' }],
-        picture: [{ required: true, message: '图片不能为空', trigger: 'blur' }],
-        status: [{ required: true, message: '状态(0.草稿,1.下架,2.审核中,3.审核驳回,4.已发布,5.已上报)不能为空', trigger: 'blur' }]
-      }
+        title: [{ required: true, message: "标题不能为空", trigger: "blur" }],
+        content: [{ required: true, message: "内容不能为空", trigger: "blur" }],
+        fileUrl: [{ required: true, message: "附件不能为空", trigger: "blur" }],
+        type: [{ required: true, message: "类型不能为空", trigger: "change" }],
+        typeName: [
+          { required: true, message: "字典类型名称不能为空", trigger: "blur" },
+        ],
+        picture: [{ required: true, message: "图片不能为空", trigger: "blur" }],
+        status: [
+          {
+            required: true,
+            message:
+              "状态(0.草稿,1.下架,2.审核中,3.审核驳回,4.已发布,5.已上报)不能为空",
+            trigger: "blur",
+          },
+        ],
+      },
     };
   },
   props: {
@@ -61,46 +92,54 @@ export default {
       type: Object,
       default: () => {
         return {};
-      }
+      },
     },
     layerid: {
-      type: String
-    }
+      type: String,
+    },
   },
   mounted() {
     if (this.param.type) {
-      this.form.type =parseInt(this.param.type);
+      this.form.type = parseInt(this.param.type);
     }
     if (this.param.id) {
-      getNEWS(this.param.id).then(response => {
+      getNEWS(this.param.id).then((response) => {
         this.form = response.data;
-        this.form.type=parseInt(this.form.type);
-        this.form.content = response.data.content.replace(new RegExp('/profile/upload/', 'g'), this.baseUrl + '/profile/upload/');
+        this.form.type = parseInt(this.form.type);
+        this.form.content = response.data.content.replace(
+          new RegExp("/profile/upload/", "g"),
+          this.baseUrl + "/profile/upload/"
+        );
       });
     }
   },
   methods: {
+    checkPermi,
     /** 提交按钮 */
-    submitForm() {
-      this.$refs['form'].validate(valid => {
+    submitForm(type) {
+      this.$refs["form"].validate((valid) => {
         if (valid) {
           if (this.form.id != null) {
-            updateAndex(this.form).then(response => {
-              this.$modal.msgSuccess('修改成功');
+            updateAndex(this.form).then((response) => {
+              this.$modal.msgSuccess("修改成功");
               this.$layer.close(this.layerid);
               this.$parent.getList();
             });
           } else {
-            this.form.status = '1';
-            addNEWS(this.form).then(response => {
-              this.$modal.msgSuccess('新增成功');
+            if (type == "add") {
+              this.form.status = "1";
+            } else if (type == "draft") {
+              this.form.status = "0";
+            }
+            addNEWS(this.form).then((response) => {
+              this.$modal.msgSuccess("新增成功");
               this.$layer.close(this.layerid);
               this.$parent.getList();
             });
           }
         }
       });
-    }
-  }
+    },
+  },
 };
 </script>