Authored by 鲁尚清

对比分析首页优化

1、有多个对比分析功能,展示列表
2、增加删除列表后增加删除按钮
@@ -3,6 +3,9 @@ @@ -3,6 +3,9 @@
3 justify-content: center; 3 justify-content: center;
4 margin-top: 30px; 4 margin-top: 30px;
5 } 5 }
  6 +body{
  7 + padding:0;
  8 +}
6 .iconAdd{ 9 .iconAdd{
7 width:50%; 10 width:50%;
8 height:240px; 11 height:240px;
@@ -16,7 +19,8 @@ @@ -16,7 +19,8 @@
16 /*add页面*/ 19 /*add页面*/
17 .analysis-add-container{ 20 .analysis-add-container{
18 height: 100%; 21 height: 100%;
19 - background-color: #f6f6f6; 22 + background-color: #FFFFFF;
  23 + overflow: auto;
20 } 24 }
21 .add-top{ 25 .add-top{
22 background-color: #FFFFFF; 26 background-color: #FFFFFF;
@@ -79,6 +83,87 @@ @@ -79,6 +83,87 @@
79 color: #337ab7; 83 color: #337ab7;
80 cursor: pointer; 84 cursor: pointer;
81 } 85 }
  86 +.text-left{
  87 + text-align: left;
  88 +}
  89 +.analysis-list{
  90 + padding:20px;
  91 +}
  92 +.analysis-list table{
  93 + margin-top:0;
  94 +}
  95 +.list-title{
  96 + margin-bottom:20px;
  97 +}
  98 +.analysis-list .el-table th.el-table__cell{
  99 + color: rgb(30,159,255);
  100 + font-weight: bold;
  101 + background-color: rgb(235,245,249);
  102 +}
  103 +.icon-bg{
  104 + display: flex;
  105 + justify-content: center;
  106 + align-items: center;
  107 + width: 20px;
  108 + height: 20px;
  109 + background:rgb(30,159,255);
  110 + border-radius: 2px;
  111 + cursor: pointer;
  112 +}
  113 +.icon-list{
  114 + display: inline-block;
  115 + background-size: 100%;
  116 + background-position: center;
  117 + width: 14px;
  118 + height: 14px;
  119 +}
  120 +.button-flex-div-center span{
  121 + display: flex;
  122 + justify-content: center;
  123 + align-items: center;
  124 +}
  125 +.button-flex-div-center .icon-list{
  126 + margin-right: 3px;
  127 +}
  128 +.list-search{
  129 + margin-bottom: 20px;
  130 +}
  131 +.icon-list-delete{
  132 + background-image: url("/vue3/src/assets/images/analysis/icon-list-delete.png");
  133 +}
  134 +.icon-list-group{
  135 + background-image: url("/vue3/src/assets/images/analysis/icon-list-group.png");
  136 +}
82 137
  138 +.icon-list-message{
  139 + background-image: url("/vue3/src/assets/images/analysis/icon-list-message.png");
  140 +}
  141 +.icon-list-safe{
  142 + background-image: url("/vue3/src/assets/images/analysis/icon-list-safe.png");
  143 +}
83 144
  145 +.icon-list-net{
  146 + background-image: url("/vue3/src/assets/images/analysis/icon-list-net.png");
  147 +}
  148 +.search-text{
  149 + cursor: pointer;
  150 +}
  151 +.alert-div{
  152 + position:absolute;
  153 + top:0;
  154 +}
84 155
  156 +.analysis-table-div{
  157 + margin-bottom: 34px;
  158 +}
  159 +.demo-pagination-block{
  160 + background: #FFFFFF;
  161 + position: fixed;
  162 + bottom: 0;
  163 + border: 1px solid #ccc;
  164 + width: 100%;
  165 + text-align: left;
  166 + left: 0;
  167 + padding: 5px 10px;
  168 + z-index: 1;
  169 +}
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <div class="add-top-title" style=" padding: 20px 20px 20px 20px;font-size: 16px;color:#337ab7"> 2 <div class="add-top-title" style=" padding: 20px 20px 20px 20px;font-size: 16px;color:#337ab7">
3 比对分析场景 3 比对分析场景
4 </div> 4 </div>
5 - <div class="analysis-drop"> 5 + <div class="analysis-drop" v-if="!isShowLIst">
6 <router-link :to="'/analysis/add'" class="analysis link-type"> 6 <router-link :to="'/analysis/add'" class="analysis link-type">
7 <div class="analysis-index-container" style="display: grid;"> 7 <div class="analysis-index-container" style="display: grid;">
8 <img src="/vue3/src/assets/images/analysis/icon-add.png" style="margin-left: 20px;"></img> 8 <img src="/vue3/src/assets/images/analysis/icon-add.png" style="margin-left: 20px;"></img>
@@ -11,4 +11,76 @@ @@ -11,4 +11,76 @@
11 </router-link> 11 </router-link>
12 12
13 </div> 13 </div>
  14 + <div class="analysis-list" v-if="isShowLIst">
  15 + <el-row class="list-search">
  16 + <el-col :span="6">
  17 + <div class="search-input flex-div-start">
  18 + <el-input v-model="inputSearch" placeholder="请输入创建人名称" />
  19 + <span class="search-text" @click="searchData">搜索</span>
  20 + </div>
  21 +
  22 + </el-col>
  23 + </el-row>
  24 + <!-- <el-row class="list-title">
  25 + <el-col :span="24" class="text-left">
  26 + <el-button type="primary" class="button-flex-div-center"><i class="icon-list icon-list-add"></i>新增</el-button>
  27 + <el-button type="primary" class="button-flex-div-center"><i class="icon-list icon-list-delete"></i>删除</el-button>
  28 + </el-col>
  29 + </el-row>-->
  30 + <el-row class="analysis-table-div">
  31 + <el-col :span="24">
  32 + <el-table border ref="multipleTable" @selection-change="handleSelectionChange" :data="tableData" stripe style="width: 100%">
  33 +<!-- <el-table-column align="center" type="selection" width="55" />-->
  34 + <el-table-column prop="configName" align="center" label="配置项名称" sortable width="180" />
  35 + <el-table-column prop="configDepict" label="配置项描述" sortable width="180" />
  36 + <el-table-column prop="timeScopeName" label="时间范围" sortable width="180" ></el-table-column>
  37 + <el-table-column align="center" prop="nickname" label="创建人名称" sortable width="180" />
  38 + <el-table-column align="center" prop="createTime" :formatter="dateFormat" label="创建时间" sortable width="210" />
  39 +
  40 + <el-table-column prop="address" label="操作" >
  41 + <template #default="scope">
  42 + <div class="list-handle">
  43 + <span class="icon-bg">
  44 + <i class="icon-list icon-list-delete" @click="handleDelete(scope.row)"></i>
  45 + </span>
  46 + <!--<i class="icon-list icon-list-group"></i>
  47 + <i class="icon-list icon-list-message"></i>
  48 + <i class="icon-list icon-list-safe"></i>
  49 + <i class="icon-list icon-list-net"></i>-->
  50 + </div>
  51 +
  52 + </template>
  53 + </el-table-column>
  54 + </el-table>
  55 + </el-col>
  56 + </el-row>
  57 + <el-row>
  58 + <div class="demo-pagination-block">
  59 + <el-pagination
  60 + v-model:currentPage="currentPage4"
  61 + :page-sizes="[10,20,30,40]"
  62 + :page-size="pageSize"
  63 + layout="total, prev, pager, next, sizes, jumper"
  64 + :total="totalCount"
  65 + @size-change="handleSizeChange"
  66 + @current-change="handleCurrentChange"
  67 + >
  68 + </el-pagination>
  69 + </div>
  70 + </el-row>
  71 + </div>
  72 + <div class="add-dialog">
  73 + <el-dialog v-model="addVisible" :title="添加配置" width="50%" @close="closeDialog" top="15vh">
  74 + <el-form ref="addHandleForm" :model="addHandleForm" label-width="120px">
  75 + <el-form-item label="名称">
  76 + <el-input v-model="addHandleForm.parentName"></el-input>
  77 + </el-form-item>
  78 +
  79 + <el-form-item label="描述">
  80 + <el-input v-model="addHandleForm.desc"></el-input>
  81 + </el-form-item>
  82 + </el-form>
  83 + </el-dialog>
  84 +
  85 + </div>
14 </div> 86 </div>
@@ -4,10 +4,128 @@ export default { @@ -4,10 +4,128 @@ export default {
4 components:{}, 4 components:{},
5 data () { 5 data () {
6 return { 6 return {
  7 + multipleSelection:[],
  8 + domainName:sessionStorage.getItem('domainName'),
  9 + apiUrl:'/api-web/ContrastAnalysis/getParentNodes',
  10 + apiUrl1:'/api-web/ContrastAnalysis/deleteScene',
  11 + addVisible:false,//新增弹框
  12 + inputSearch:'',//搜索内容
  13 + nickname:'',//
  14 + messageVisible:false,//消息提示
  15 + pageSize:10,//每页显示条数
  16 + // currentPage:1,//当前页
  17 + // totalCount:0,//总条数
7 18
8 } 19 }
9 }, 20 },
10 setup(){ 21 setup(){
  22 + const {proxy} = Vue.getCurrentInstance();
  23 + const isShowLIst=Vue.ref(false);
  24 + const tableData=Vue.ref([]);
  25 + const totalCount=Vue.ref(0);
  26 + const currentPage=Vue.ref(1);
11 27
  28 + // 挂载完
  29 + Vue.onMounted(() => {
  30 + proxy.getData();
  31 +
  32 + })
  33 + //获取对比分析列表
  34 + const getData=()=>{
  35 + let params={
  36 + nickname:proxy.nickname,
  37 + limit:proxy.pageSize,
  38 + page:proxy.currentPage
  39 + }
  40 + $.get(proxy.domainName +proxy.apiUrl+'?access_token='+localStorage.getItem('access_token'),params,function (res) {
  41 + if(res){
  42 + console.log("res",res)
  43 + proxy.totalCount=res.count;
  44 + proxy.tableData=res.data;
  45 + proxy.tableData.map((item,index)=>{
  46 + item.createTime= proxy.dateForma(item,item.createTime)
  47 + })
  48 + }
  49 +
  50 +
  51 + if(proxy.tableData && proxy.tableData.length>0){
  52 + proxy.isShowLIst=true
  53 + }else{
  54 + proxy.isShowLIst=false
  55 +
  56 + }
  57 +
  58 + })
  59 +
  60 + }
  61 +
  62 + const toggleSelection=(rows)=> {
  63 + if (rows) {
  64 + rows.forEach((row) => {
  65 + this.$refs.multipleTable.toggleRowSelection(row)
  66 + })
  67 + } else {
  68 + this.$refs.multipleTable.clearSelection()
  69 + }
  70 + }
  71 + const handleSelectionChange=(val)=> {
  72 + this.multipleSelection = val
  73 + }
  74 + //单个删除
  75 + const handleDelete=(item)=>{
  76 +
  77 + let params={
  78 + id:item.id
  79 + }
  80 + $.get(proxy.domainName +proxy.apiUrl1+'?access_token='+localStorage.getItem('access_token'),params,function (res) {
  81 + if(res){
  82 + proxy.$global.showMsg("删除成功","warning")
  83 + proxy.getData();
  84 + }
  85 + })
  86 + }
  87 + const searchData=()=>{
  88 + proxy.nickname=proxy.inputSearch;
  89 + proxy.getData();
  90 + }
  91 + //格式化时间格式
  92 + let dateForma=(row,column)=>{
  93 + const daterc = column
  94 + if(daterc!=null){
  95 + const dateMat= new Date(parseInt(daterc));
  96 + const year = dateMat.getFullYear();
  97 + const month = dateMat.getMonth() + 1;
  98 + const day = dateMat.getDate();
  99 + const hh = dateMat.getHours();
  100 + const mm = dateMat.getMinutes();
  101 + const ss = dateMat.getSeconds();
  102 + const timeFormat= year + "年" + month + "月" + day + "日 " + hh + ":" + mm + ":" + ss;
  103 + return timeFormat;
  104 + }
  105 +
  106 + }
  107 + const handleSizeChange = (val) => {
  108 + proxy.pageSize=val;
  109 + proxy.getData();
  110 + }
  111 + //切换当前页
  112 + const handleCurrentChange = (val) => {
  113 + proxy.currentPage=val;
  114 + proxy.getData();
  115 + }
  116 + return{
  117 + isShowLIst,
  118 + tableData,
  119 + toggleSelection,
  120 + handleSelectionChange,
  121 + getData,
  122 + handleDelete,
  123 + dateForma,
  124 + searchData,
  125 + handleSizeChange,
  126 + handleCurrentChange,
  127 + totalCount,
  128 + currentPage
  129 + }
12 } 130 }
13 } 131 }