Explorar o código

修改bug

修改bug
Sean hai 5 meses
pai
achega
87fb575ac6

+ 11 - 0
src/store/modules/template.js

@@ -24,6 +24,7 @@ const state = {
     aloneArticle:[],//自定义详情页
   },
   editWindowStatus:false,//编辑弹出框是否显示
+  editWindowTitle:"",//编辑弹出框标题
   // layout: [
   //   // i = id 
   //   // w = 最大宽度是12
@@ -106,6 +107,16 @@ const mutations = {
   setPageStatus(state,num){
     state.pageStatus = num;
   },
+  //打开编辑弹出框
+  setEditWindowStatus(state,title){
+    state.editWindowStatus = true;
+    state.editWindowTitle = title;
+  },
+  //关闭编辑弹出框
+  closeEditWindowStatus(state){
+    state.editWindowStatus = false;
+    state.editWindowTitle = "";
+  },
   //0.全局配置 start------------------------------------------------------------>
   //1.配置模块 start------------------------------------------------------------>
   //添加首页板块

+ 22 - 18
src/views/news/creatNews.vue

@@ -132,8 +132,8 @@
               <el-form-item label="来源名称:" prop="copyfrom" class="custom-align-right">
                 <el-input v-model="form.copyfrom" autocomplete="off" placeholder="请输入来源名称"></el-input>
               </el-form-item>
-              <el-form-item label="来源链接:" prop="linkurl" class="custom-align-right">
-                <el-input v-model="form.linkurl" autocomplete="off" placeholder="请输入来源链接"></el-input>
+              <el-form-item label="来源链接:" prop="fromurl" class="custom-align-right">
+                <el-input v-model="form.fromurl" autocomplete="off" placeholder="请输入来源链接"></el-input>
               </el-form-item>
               <div class="disclaimerBox">
                 <div class="disclaimerTitle">
@@ -145,7 +145,7 @@
             </div>
             <div v-if="form.is_original==1">
               <el-form-item label="来源名称:" prop="linkurl" class="custom-align-right">
-                <el-input v-model="form.linkurl" autocomplete="off" placeholder="请输入来源名称" disabled="disabled"></el-input>
+                <el-input v-model="form.copyfrom" autocomplete="off" placeholder="请输入来源名称" disabled="disabled"></el-input>
               </el-form-item>
             </div>
 
@@ -471,15 +471,14 @@ export default {
         //不是原创的时候显示来源
         if(res.data.is_original==1){
           this.form.is_original = 1;
-          this.form.linkurl = "本网";
+          this.form.copyfrom = "本网";
         }else{
           this.form.is_original = 0;
           this.$nextTick(() => {
             this.form.is_original = 0;
             console.log('is_original:', this.form.is_original); // 确保值已更新
           });
-          // <el-radio v-model="form.is_original" label="1">是</el-radio>
-          // <el-radio v-model="form.is_original" label="0">不是</el-radio>
+          this.form.copyfrom = res.data.copyfrom;
           this.form.linkurl = res.data.linkurl;
         }
         
@@ -501,7 +500,7 @@ export default {
         this.form.author = res.data.author;
         this.form.hits = res.data.hits;
         this.form.is_original = res.data.is_original;
-        this.form.copyfrom = res.data.copyfrom;
+        //this.form.copyfrom = res.data.copyfrom;
         this.form.fromurl = res.data.fromurl;
         this.form.status = res.data.status;
       }).catch(() => {
@@ -536,6 +535,7 @@ export default {
     editToServe(){
       //提交之前先判断是否为外链
       //如果使用了外链,清理掉除了外链以外的内容
+      console.log(this.form)
       if(this.form.islink==1){
         this.cleatForm(1)
       }
@@ -546,14 +546,18 @@ export default {
         if (valid) {
           //console.log(this.form)
           this.$store.dispatch('news/updateArticle',this.form).then(res=> {
-            //汇报结果
-            this.$message({
-              type: 'success',
-              message: '已成功添加资讯!'
-            });
-            this.cleatForm(2);
-            //返回列表页
-            this.returnPage()
+            if(res.code!=200){
+              this.$message.error("修改失败,请稍后再试!");
+            }else{
+              //汇报结果
+              this.$message({
+                type: 'success',
+                message: '已成功编辑资讯!'
+              });
+              this.cleatForm(2);
+              //返回列表页
+              this.returnPage()
+            }
           }).catch(() => {
             this.$message({
               type: 'info',
@@ -566,10 +570,10 @@ export default {
     //1.4 修改是否原创
     changeIsOriginal(){
       if(this.form.is_original==1){
-        this.form.copyfrom = "";
-        this.form.linkurl = "本网";
+        this.form.copyfrom = "本网";
       }else{
-        this.form.linkurl = "";
+        this.form.copyfrom = "";
+        this.form.fromurl = "";
       }
     },
     //跳转操作 end ------------------------------------------------------------>

+ 4 - 2
src/views/template/public/editBtn.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="templateEditBtnBox">
+  <div class="templateEditBtnBox" @click="openEditWindow">
     <i class="el-icon-setting"></i>
   </div>
 </template>
@@ -18,7 +18,9 @@ export default {
     };
   },
   methods: {
-    
+    openEditWindow(){
+      this.$store.commit('template/setEditWindowStatus');
+    }
   },
   mounted() {
     

+ 43 - 0
src/views/template/public/editWindow.vue

@@ -0,0 +1,43 @@
+<template>
+  <div class="editWindowBox">
+    <div class="editWindowBoxContent">
+      
+    </div>
+    <div class="editWindowBoxFooter">
+      <el-button type="info" @click="closeEditWindow">取消</el-button>
+      <el-button type="primary">确定</el-button>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  props: {
+      
+  },
+  data() {
+    return {
+      
+    };
+  },
+  methods: {
+    closeEditWindow(){
+      this.$store.commit('template/closeEditWindowStatus');
+    }
+  },
+  mounted() {
+    
+  },
+};
+</script>
+
+<style scoped lang="less">
+  .editWindowBox {
+    .editWindowBoxContent {
+      padding: 20px;
+    }
+    .editWindowBoxFooter {
+      text-align: right;
+    }
+  }
+</style>

+ 7 - 3
src/views/template/style/1/components/mainTitle.vue

@@ -7,17 +7,21 @@
 </template>
 
 <script>
-import editBtn from '../../../public/editBtn.vue'
+import editBtn from '../../../public/editBtn.vue';
+
 export default {
   components: {
     editBtn
   },
   props: {
-    
+    name:{
+      type:String,
+      default:''
+    }
   },
   data() {
     return {
-      articleId:2509
+      componentId:1
     };
   },
   methods: {

+ 10 - 9
src/views/template/templateCreat.vue

@@ -28,14 +28,9 @@
     <!-- 画布 end ---------------------------------------->
 
     <!-- 弹出框 start ---------------------------------------->
-    <el-dialog title="编辑模块" :visible.sync="this.$store.state.template.editWindowStatus" :close-on-click-modal="false">
-      <div>123</div>
-      <div slot="footer" class="dialog-footer">
-        <div>
-          <el-button type="info">取消</el-button>
-          <el-button type="warning">编辑</el-button>
-        </div>
-      </div>
+    <!-- 这里我去掉了:visible.sync 因为弹出框的关闭事件需要手动触发 -->
+    <el-dialog title="编辑组件" :visible="this.$store.state.template.editWindowStatus" :close-on-click-modal="false" @close="closeEditWindow">
+      <editWindow />
     </el-dialog>
     <!-- 弹出框 start ---------------------------------------->
   </div>
@@ -44,6 +39,7 @@
 <script>
 //页面公用组件 start------------------------------------------------------------>
 import '@/styles/global.less';
+import editWindow from './public/editWindow.vue';
 //页面公用组件 end------------------------------------------------------------>
 
 //页面组件 start------------------------------------------------------------>
@@ -53,7 +49,8 @@ import pageIndex from './page/pageIndex.vue';
 export default {
   components: {
     //引入页面组件
-    pageIndex
+    pageIndex,
+    editWindow
   },
   data() {
     return {
@@ -105,6 +102,10 @@ export default {
     openPage(num){
       this.$store.commit('template/setPageStatus',num);
     },
+    //关闭编辑弹出框
+    closeEditWindow(){
+      this.$store.commit('template/closeEditWindowStatus');
+    },
     //0.全局操作 end ------------------------------------------------------------>
   },
   mounted(){