Quellcode durchsuchen

修改资讯列表

修改资讯列表
dangyunlong vor 1 Monat
Ursprung
Commit
eaebab33a1
3 geänderte Dateien mit 220 neuen und 38 gelöschten Zeilen
  1. 178 26
      src/views/news/NewList.vue
  2. 23 8
      src/views/news/creatNews.vue
  3. 19 4
      src/views/news/examine.vue

+ 178 - 26
src/views/news/NewList.vue

@@ -35,15 +35,6 @@
               </el-select>
               </el-select>
             </div>
             </div>
           </el-col>
           </el-col>
-          <el-col :span="8">
-            <div class="searchBox">
-              <div class="searchTitle">资讯状态:</div>
-              <el-select v-model="getApiData.status" placeholder="请选择..">
-                <el-option label="待发布" value="0"></el-option>
-                <el-option label="已发布" value="1"></el-option>
-              </el-select>
-            </div>
-          </el-col>
         </el-row>
         </el-row>
       </div>
       </div>
     </div>
     </div>
@@ -65,7 +56,7 @@
       <el-row>
       <el-row>
         <template>
         <template>
           <el-table :data="tableData" style="width: 100%">
           <el-table :data="tableData" style="width: 100%">
-            <el-table-column fixed prop="id" label="编号" width="50"></el-table-column>
+            <el-table-column fixed prop="id" label="编号" width="80"></el-table-column>
             <el-table-column prop="title" label="资讯题目" width=""></el-table-column>
             <el-table-column prop="title" label="资讯题目" width=""></el-table-column>
             <el-table-column prop="category_name" label="展示名称" width=""></el-table-column>
             <el-table-column prop="category_name" label="展示名称" width=""></el-table-column>
             <el-table-column prop="islink" label="是否引用外链" width=""></el-table-column>
             <el-table-column prop="islink" label="是否引用外链" width=""></el-table-column>
@@ -82,26 +73,24 @@
             <el-table-column prop="author" label="作者" width=""></el-table-column>
             <el-table-column prop="author" label="作者" width=""></el-table-column>
             <el-table-column prop="created_at" label="创建时间" width=""></el-table-column>
             <el-table-column prop="created_at" label="创建时间" width=""></el-table-column>
             <el-table-column prop="updated_at" label="修改时间" width=""></el-table-column>
             <el-table-column prop="updated_at" label="修改时间" width=""></el-table-column>
-            <el-table-column prop="status" label="状态" width="" v-if="$store.state.user.usertype == 10000">
-              <template slot-scope="scope">
-                <span v-if="scope.row.status==404">404</span>
-                <el-switch
-                  v-else
-                  v-model="scope.row.status"
-                  :active-value="1"
-                  :inactive-value="0"
-                  @change="upRow(scope.row.id,scope.row.status)"
-                ></el-switch>
-              </template>
-            </el-table-column>
-            <el-table-column prop="status" label="状态" width="" v-else>
+            <el-table-column prop="status" label="状态" width="150">
               <template slot-scope="scope">
               <template slot-scope="scope">
                 <span v-if="scope.row.status==0">待审核</span>
                 <span v-if="scope.row.status==0">待审核</span>
                 <span v-if="scope.row.status==1">已通过</span>
                 <span v-if="scope.row.status==1">已通过</span>
                 <span v-if="scope.row.status==2">已拒绝</span>
                 <span v-if="scope.row.status==2">已拒绝</span>
               </template>
               </template>
             </el-table-column>
             </el-table-column>
-            <el-table-column fixed="right" label="操作" width="200" header-align="center">
+            <el-table-column fixed="right" label="操作" width="350" header-align="center" v-if="creatNews_user_type == 10000">
+              <template slot-scope="scope">
+                <div class="listBtnBox">
+                  <div class="listLinkBtn" @click="selectRow(scope.row.cat_arr_id, scope.row)"><i class="el-icon-full-screen"></i>站点选择</div>
+                  <div class="listUpBtn" @click="returnRow(scope.row.id, tableData)"><i class="el-icon-refresh-right"></i>撤回</div>
+                  <div class="listDeleteBtn" @click="deleteRow(scope.row.id, tableData)"><i class="el-icon-delete"></i>删除</div>
+                  <div class="listEditBtn" @click="goEdit(scope.row.id, tableData)"><i class="el-icon-edit-outline"></i>编辑</div>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column fixed="right" label="操作" width="180" header-align="center" v-if="creatNews_user_type != 10000">
               <template slot-scope="scope">
               <template slot-scope="scope">
                 <div class="listBtnBox">
                 <div class="listBtnBox">
                   <div class="listDeleteBtn" @click="deleteRow(scope.row.id, tableData)"><i class="el-icon-delete"></i>删除</div>
                   <div class="listDeleteBtn" @click="deleteRow(scope.row.id, tableData)"><i class="el-icon-delete"></i>删除</div>
@@ -123,6 +112,26 @@
     </div>
     </div>
     <!--分页 end------------------------------------------------------------>
     <!--分页 end------------------------------------------------------------>
     <!--表格内容 end------------------------------------------------------------>
     <!--表格内容 end------------------------------------------------------------>
+
+    <!--弹出框:选择要发布的网站 start------------------------------------------------------------>
+    <el-dialog title="请选择不要发布的网站" :visible.sync="selectStatusWindow" :close-on-click-modal="false">
+      <el-form label-position="left" >
+        <div class="formDiv">
+          <el-table v-loading="loading" ref="multipleTable" :data="webSiteData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
+            <el-table-column type="selection" width="55"></el-table-column>
+            <el-table-column prop="website_id" label="网站id"></el-table-column>
+            <el-table-column prop="website_name" label="网站名称"></el-table-column>
+          </el-table>
+        </div>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <div>
+          <el-button type="info" @click="selectStatusWindow=false">取消</el-button>
+          <el-button type="primary" @click="selectWebSiteToServe">确定</el-button>
+        </div>
+      </div>
+    </el-dialog>
+    <!--弹出框:选择要发布的网站 end------------------------------------------------------------>
   </div>
   </div>
 </template>
 </template>
 
 
@@ -131,6 +140,8 @@
 import tableTitle from './components/tableTitle';
 import tableTitle from './components/tableTitle';
 //引入公用样式
 //引入公用样式
 import '@/styles/global.less';
 import '@/styles/global.less';
+//获得用户身份
+import { getUseType } from '@/utils/auth'
 
 
 export default {
 export default {
   components: {
   components: {
@@ -141,13 +152,22 @@ export default {
       //1.列表和分页相关 start ------------------------------------------------------------>
       //1.列表和分页相关 start ------------------------------------------------------------>
       tableDivTitle:"资讯列表",
       tableDivTitle:"资讯列表",
       tableData:[],//内容
       tableData:[],//内容
+      webSiteData: [],//可选网站列表
+      creatNews_user_type:0,//用户类型
+      //选择要发布的网站
+      webSiteForm:{
+        ignore_ids:[]
+      },
+      ids:[],//待选网站列表
+      loading:false,//loading
       editId:0,//要修改的网站id
       editId:0,//要修改的网站id
+      selectStatusWindow:false,//反选窗口
       getApiData:{
       getApiData:{
         title:"",//标题
         title:"",//标题
         category_name:"",//导航池id
         category_name:"",//导航池id
         author:"",//作者
         author:"",//作者
         islink:"",//是否使用外链
         islink:"",//是否使用外链
-        status:"",//资讯状态
+        status:1,//资讯状态
         page:1,//当前是第几页
         page:1,//当前是第几页
         pageSize:10,//一共多少条
         pageSize:10,//一共多少条
       },
       },
@@ -270,10 +290,142 @@ export default {
         path: '/creatNews',
         path: '/creatNews',
         query: data
         query: data
       });
       });
-    }
+    },
     //添加新闻 end ------------------------------------------------------------>
     //添加新闻 end ------------------------------------------------------------>
+
+    //3.编辑新闻 start ------------------------------------------------------------>
+    //3.1 打开反选窗口
+    selectRow(cid,row){
+      console.log(row)
+      this.selectStatusWindow = true;
+      //给与编辑的id
+      this.editId = row.id;
+      //给与编辑的状态
+      this.editStatus = row.status;
+      //把cid转换成数组,然后取出最后一位
+      
+      let cidLast = "";
+      // 判断cid是否为数组
+      if (!Array.isArray(cid)) {
+        let cidArr = cid.replace(/[\[\]]/g, '').split(',');
+        cidLast = cidArr[cidArr.length - 1];
+      }else{
+        cidLast = cid[cid.length - 1];
+      }
+      this.getWebsiteNavPoolSite(cidLast,row)
+    },
+    //3.2 获取可选网站列表
+    getWebsiteNavPoolSite(cid,row){
+      this.loading = true;
+      let ignoreIds = JSON.parse(row.ignore_ids);
+      this.webSiteData = [];
+      this.$store.dispatch('news/getWebsiteNavPoolSite',{category_id:cid}).then(res=>{
+        //this.webSiteData = res.data;
+        for(let item of res.data){
+          if(item.website_name!=null){
+            this.webSiteData.push(item)
+          }
+        }
+
+        //延迟一会返显,否则可能显示不了
+        if(res.data.length>0&&ignoreIds!=null){
+          setTimeout(()=>{
+            for(let index in this.webSiteData){
+              if(ignoreIds.includes(this.webSiteData[index].website_id)){
+                //调用回显方法
+                this.toggleSelection([this.webSiteData[index]])
+              }
+            }
+            this.loading = false;
+          },500)
+        }else{
+          this.loading = false;
+        }
+      })
+    },
+    //3.3 回显 选中的方法 
+    toggleSelection(rows) {
+      console.log(rows)
+      if (rows) {
+        rows.forEach(row => {
+          this.$refs.multipleTable.toggleRowSelection(row);
+        });
+      } else {
+        this.$refs.multipleTable.clearSelection();
+      }
+    },
+    //3.4 把选择的网站保存到待选择的网站列表
+    handleSelectionChange(val) {
+      console.log(val)
+      this.ids = val;
+    },
+    //3.5 提交选择的网站列表
+    selectWebSiteToServe(id){
+      let ids = [];
+      for(let item of this.ids){
+        ids.push(item.website_id)
+      }
+      //把数组转换为字符串
+      //let idsStr = ids.join(',');
+      //把数组转换为字符串
+      let idsStr = JSON.stringify(ids);
+
+      if(idsStr.length==0){
+        this.$message.error("至少需要选择一个网站!")
+        return;
+      }else{
+        let data = {
+          id:this.editId,
+          ignore_ids:idsStr,
+          status:this.editStatus
+        }
+        this.$store.dispatch('news/upArticleStatus',data).then(res=>{
+          console.log(res)
+          if(res.code==200){
+            this.$message({
+              type: 'success',
+              message: '资讯绑定网站成功!'
+            });
+            this.selectStatusWindow = false;
+            this.getData();
+          }else{
+            this.$message.error(res.data.msg)
+          }
+        })
+      }
+    },
+    //3.6 撤回审核
+    returnRow(id){
+      this.$confirm('确定要撤回吗?', '提示', {
+        confirmButtonText: '撤回',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        //撤回,把文章状态修改为0,重新进行审核
+        this.upRow(id,0)
+      })
+    },
+    //3.5 修改文章状态
+    upRow(id,status){
+      let data = {
+        id:id,
+        status:status
+      }
+      this.$store.dispatch('news/upArticleStatus',data).then(res=> {
+        if(res.code==200){
+          this.$message({
+            type: 'success',
+            message: '操作成功!'
+          });
+          this.getData();
+        }
+      })
+    },
+    //3.编辑新闻 end ------------------------------------------------------------>
+
   },
   },
   mounted(){
   mounted(){
+    this.creatNews_user_type = getUseType()
     //1.获得初始数据
     //1.获得初始数据
     this.getData();
     this.getData();
   }
   }

+ 23 - 8
src/views/news/creatNews.vue

@@ -168,13 +168,12 @@
                     disabled="disabled"></el-input>
                     disabled="disabled"></el-input>
                 </el-form-item>
                 </el-form-item>
               </div>
               </div>
-              <el-form-item label="资讯状态:" class="custom-align-right" style="width: 100%;" v-if="creatNews_user_type == 10000">
+              <!-- <el-form-item label="资讯状态:" class="custom-align-right" style="width: 100%;" v-if="creatNews_user_type == 10000">
                 <el-select v-model="form.status" placeholder="请选择..">
                 <el-select v-model="form.status" placeholder="请选择..">
                   <el-option label="已发布" :value="1"></el-option>
                   <el-option label="已发布" :value="1"></el-option>
                   <el-option label="待发布" :value="0"></el-option>
                   <el-option label="待发布" :value="0"></el-option>
-                  <!-- <el-option label="已拒绝" :value="2"></el-option> -->
                 </el-select>
                 </el-select>
-              </el-form-item>
+              </el-form-item> -->
               <el-form-item label="是否开启投票:" prop="is_survey" class="custom-align-right">
               <el-form-item label="是否开启投票:" prop="is_survey" class="custom-align-right">
                 <el-radio-group v-model="form.is_survey">
                 <el-radio-group v-model="form.is_survey">
                   <el-radio :label="1">是</el-radio>
                   <el-radio :label="1">是</el-radio>
@@ -605,6 +604,15 @@ export default {
       this.form.department_arr_id = JSON.stringify(this.form.department_arr_id);
       this.form.department_arr_id = JSON.stringify(this.form.department_arr_id);
       this.form.city_arr_id = JSON.stringify(this.form.city_arr_id);
       this.form.city_arr_id = JSON.stringify(this.form.city_arr_id);
 
 
+      //判断用户身份
+      if(this.creatNews_user_type==10000){
+        console.log("用户身份为管理员,无需审核直接发布!")
+        this.form.status = 1;
+      }else{
+        console.log("用户身份为其他用户,提交到审核!")
+        this.form.status = 0;
+      }
+
       //先进行验证
       //先进行验证
       this.$refs.form.validate(valid => {
       this.$refs.form.validate(valid => {
         if (valid) {
         if (valid) {
@@ -649,7 +657,7 @@ export default {
         this.form.is_original = "";
         this.form.is_original = "";
         this.form.copyfrom = "";
         this.form.copyfrom = "";
         this.form.fromurl = "";
         this.form.fromurl = "";
-        this.form.status = "";
+        this.form.status = 0;
       }
       }
       if (type == 2) {
       if (type == 2) {
         //完全清理表单
         //完全清理表单
@@ -667,7 +675,7 @@ export default {
         this.form.is_original = "";
         this.form.is_original = "";
         this.form.copyfrom = "";
         this.form.copyfrom = "";
         this.form.fromurl = "";
         this.form.fromurl = "";
-        this.form.status = "";
+        this.form.status = 0;
       }
       }
     },
     },
     //1.4更新详细地址
     //1.4更新详细地址
@@ -823,6 +831,16 @@ export default {
       this.form.city_arr_id = JSON.stringify(this.form.city_arr_id);
       this.form.city_arr_id = JSON.stringify(this.form.city_arr_id);
       //添加要修改的id
       //添加要修改的id
       this.form.id = this.editId;
       this.form.id = this.editId;
+
+      //判断用户身份
+      if(this.creatNews_user_type==10000){
+        console.log("用户身份为管理员,无需审核直接发布!")
+        this.form.status = 1;
+      }else{
+        console.log("用户身份为其他用户,提交到审核!")
+        this.form.status = 0;
+      }
+
       //先进行验证
       //先进行验证
       this.$refs.form.validate(valid => {
       this.$refs.form.validate(valid => {
         if (valid) {
         if (valid) {
@@ -1024,9 +1042,6 @@ export default {
     this.creatNews_user_type = getUseType()
     this.creatNews_user_type = getUseType()
     this.websiteid = getWebSiteId()
     this.websiteid = getWebSiteId()
 
 
-    console.log(123456)
-    console.log(this.websiteid)
-
     this.get_creatNews_form_id_fun()
     this.get_creatNews_form_id_fun()
     this.get_creatNews_nav_pool_arr_fun()
     this.get_creatNews_nav_pool_arr_fun()
 
 

+ 19 - 4
src/views/news/examine.vue

@@ -40,7 +40,7 @@
               <div class="searchTitle">资讯状态:</div>
               <div class="searchTitle">资讯状态:</div>
               <el-select v-model="getApiData.status" placeholder="请选择..">
               <el-select v-model="getApiData.status" placeholder="请选择..">
                 <el-option label="待审核" value="0"></el-option>
                 <el-option label="待审核" value="0"></el-option>
-                <el-option label="已审核" value="1"></el-option>
+                <el-option label="已拒绝" value="2"></el-option>
               </el-select>
               </el-select>
             </div>
             </div>
           </el-col>
           </el-col>
@@ -97,17 +97,27 @@
                 <span v-if="scope.row.status==2">已拒绝</span>
                 <span v-if="scope.row.status==2">已拒绝</span>
               </template>
               </template>
             </el-table-column>
             </el-table-column>
-            <el-table-column fixed="right" label="操作" width="360" header-align="center">
+            <el-table-column fixed="right" label="操作" width="360" header-align="center" v-if="creatNews_user_type == 10000">
               <template slot-scope="scope">
               <template slot-scope="scope">
                 <div class="listBtnBox">
                 <div class="listBtnBox">
-                  <div class="listLinkBtn" @click="selectRow(scope.row.cat_arr_id, scope.row)"><i class="el-icon-full-screen"></i>站点选择</div>
+                  <div class="listMainBtn" @click="getUpRow(scope.row.id, tableData)"><i class="el-icon-check"></i>审核</div>
+                  <div class="listDeleteBtn" @click="deleteRow(scope.row.id, tableData)"><i class="el-icon-delete"></i>删除</div>
+                  <div class="listEditBtn" @click="goEdit(scope.row.id, tableData)"><i class="el-icon-edit-outline"></i>编辑</div>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column fixed="right" label="操作" width="360" header-align="center" v-if="creatNews_user_type != 10000">
+              <template slot-scope="scope">
+                <div class="listBtnBox">
+                  <!-- <div class="listLinkBtn" @click="selectRow(scope.row.cat_arr_id, scope.row)"><i class="el-icon-full-screen"></i>站点选择</div>
                   <div class="listMainBtn" @click="getUpRow(scope.row.id, tableData)" v-if="scope.row.status==0"><i class="el-icon-check"></i>审核</div>
                   <div class="listMainBtn" @click="getUpRow(scope.row.id, tableData)" v-if="scope.row.status==0"><i class="el-icon-check"></i>审核</div>
-                  <div class="listUpBtn" @click="returnRow(scope.row.id, tableData)" v-else><i class="el-icon-refresh-right"></i>撤回</div>
+                  <div class="listUpBtn" @click="returnRow(scope.row.id, tableData)" v-else><i class="el-icon-refresh-right"></i>撤回</div> -->
                   <div class="listDeleteBtn" @click="deleteRow(scope.row.id, tableData)"><i class="el-icon-delete"></i>删除</div>
                   <div class="listDeleteBtn" @click="deleteRow(scope.row.id, tableData)"><i class="el-icon-delete"></i>删除</div>
                   <div class="listEditBtn" @click="goEdit(scope.row.id, tableData)"><i class="el-icon-edit-outline"></i>编辑</div>
                   <div class="listEditBtn" @click="goEdit(scope.row.id, tableData)"><i class="el-icon-edit-outline"></i>编辑</div>
                 </div>
                 </div>
               </template>
               </template>
             </el-table-column>
             </el-table-column>
+
           </el-table>
           </el-table>
         </template>
         </template>
       </el-row>
       </el-row>
@@ -169,6 +179,8 @@
 import tableTitle from './components/tableTitle';
 import tableTitle from './components/tableTitle';
 //引入公用样式
 //引入公用样式
 import '@/styles/global.less';
 import '@/styles/global.less';
+//获得用户身份
+import { getUseType } from '@/utils/auth'
 
 
 export default {
 export default {
   components: {
   components: {
@@ -189,6 +201,7 @@ export default {
     return {
     return {
       //1.列表和分页相关 start ------------------------------------------------------------>
       //1.列表和分页相关 start ------------------------------------------------------------>
       tableDivTitle:"资讯列表",
       tableDivTitle:"资讯列表",
+      creatNews_user_type:0,//用户类型
       tableData:[],//内容
       tableData:[],//内容
       webSiteData: [],//可选网站列表
       webSiteData: [],//可选网站列表
       editId:0,//要修改的网站id
       editId:0,//要修改的网站id
@@ -202,6 +215,7 @@ export default {
         author:"",//作者
         author:"",//作者
         islink:"",//是否使用外链
         islink:"",//是否使用外链
         status:"",//资讯状态
         status:"",//资讯状态
+        status1:"[0,2]", //默认传递 - 如果不为空,表示获取所有未审核与已拒绝的
         page:1,//当前是第几页
         page:1,//当前是第几页
         pageSize:10,//一共多少条
         pageSize:10,//一共多少条
       },
       },
@@ -477,6 +491,7 @@ export default {
     //添加新闻 end ------------------------------------------------------------>
     //添加新闻 end ------------------------------------------------------------>
   },
   },
   mounted(){
   mounted(){
+    this.creatNews_user_type = getUseType()
     //1.获得初始数据
     //1.获得初始数据
     this.getData();
     this.getData();
   }
   }