DatavAddDialog.vue 13.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
<template>
  <el-dialog
    class="datav-add-dialog"
    style="overflow: hidden;"
    fullscreen
    destroy-on-close
    ref="datavAddDialog"
    :close-on-click-modal="false"
    :visible.sync="dialogVisible"
  >
    <el-container class="container">
      <el-header ref="header" class="container__header" height="48px">

          <div class="navbar-default box-shadow flex">
            <el-page-header @back="close">
              <template v-slot:content>添加大屏</template>
            </el-page-header>
          </div>

      </el-header>
    <el-container class="container__body">
      <el-main>
          <div class="fullheight app_center_container">
            <div>
              <div>
                <el-input
                  placeholder="请输入模板名称"
                  v-model="searchForm.appName"
                  @keyup.enter.native="search(1)"
                  class="input-search"
                  :clearable="true">
                  <el-button slot="append" icon="el-icon-search" @click="search(1)"></el-button>
                </el-input>
              </div>
              <el-row class="content">
                <el-col :span="4">
                  <el-card
                          shadow="hover"
                          class="card"
                          @click.native="add"
                          v-if="apps.length<24">
                    <i class="el-icon-circle-plus-outline" style="font-size: 100px"></i>
                  </el-card>
                </el-col>
                <el-col
                    :span="4"
                    v-for="app in apps"
                    :key="app.id">
                  <div class="card-item" :class="{ checked: app.checked }">
                    <div class="sticky" @click="itemClick(app, $event)">
                      <label class="card-checkbox">
                        <input type="checkbox" />
                        <span></span>
                      </label>
                    </div>
                    <el-card
                            shadow="hover"
                            class="card"
                            :body-style="{ padding: '0px' }">
                      <div class="card-background" :style="{background:app.iconColor?app.iconColor:'#1339E0'}">
                        <el-image class="app-image" :src="app.icon" v-if="app.icon && app.icon.indexOf('icon')<0"></el-image>
                        <i :class="app.icon?app.icon:'icon-hotent-H'" style="color:#FFFFFF;padding-top: 10px" v-else></i>
                      </div>

                      <span class="card-title">{{app.name}}</span>
                      <div class="card-item-actions">
                        <el-button round   class="actions__btn">管理</el-button>
                        <el-button round   class="actions__btn">标签</el-button>
                        <el-button round   class="actions__btn">权限</el-button>
                        <el-popconfirm title="确定删除" @onConfirm="confirm(app.id)" class="actions__btn confirm__btn">
                          <el-button slot="reference" round type="danger">删除</el-button>
                        </el-popconfirm>
                      </div>
                    </el-card>
                  </div>
                </el-col>
              </el-row>
              <el-pagination
                  background
                  layout="prev, pager, next"
                  :total="pageResult.total"
                  :page-size="pageResult.pageSize"
                  :current-page="pageResult.page"
                  class="pagination"
                  @current-change="currentChange">
              </el-pagination>
            </div>
          </div>
      </el-main>
      </el-container>

      <el-dialog
        title="新建大屏"
        :visible.sync="newDialogVisible"
        class="datavAdd"
        append-to-body
        width="40%"
        top="25vh"
        :close-on-click-modal="false">
        <div style="height:300px;padding-left: 20px ;">
            <el-form v-model="newDatav" data-vv-scope="datavForm">
              <ht-form-item label="大屏名称" label-width="100px" prop="name">
                <ht-input
                  v-model="newDatav.name"
                  autocomplete="off"
                  :validate="{required:true}"
                  placeholder="请输入大屏名称"
                  :maxlength="50"
                  :showWordLimit="true"
                ></ht-input>
              </ht-form-item>
              <ht-form-item label="大屏别名" label-width="100px" prop="name">
                <ht-input
                  v-model="newDatav.alias"
                  autocomplete="off"
                  :validate="{
                    required: true,
                    isExist: '${portal}/portal/sysIndexLayoutManage/sysIndexLayoutManage/v1/checkKey?key=',
                    regex: {
                      exp: '^[a-zA-Z][a-zA-Z0-9_]*$',
                      message: '只能输入字母、数字、下划线,且以字母开头'
                    }
                  }"
                  :maxlength="50"
                  :showWordLimit="true"
                  placeholder="请输入别名"
                ></ht-input>
              </ht-form-item>
              <ht-form-item label="布局类型" label-width="100px" style="width:100%;">
                  <el-radio-group v-model="newDatav.layoutType">
                    <el-radio-button label="0">管理端</el-radio-button>
                    <el-radio-button label="2">应用端</el-radio-button>
                  </el-radio-group>
              </ht-form-item>
              <ht-form-item label="大屏尺寸" label-width="100px" prop="memo" >
                <el-input type="number" v-model="newDatav.width" style="width:220px;">
                  <template slot="prepend">宽</template>
                  <template slot="append">px</template>
                </el-input>
                <el-input type="number" v-model="newDatav.height" style="width:220px;margin-left:5px;">
                  <template slot="prepend">高</template>
                  <template slot="append">px</template>
                </el-input>
              </ht-form-item>
              <ht-form-item label="布局描述" label-width="100px" prop="memo" >
                <ht-input
                  type="textarea"
                  :rows="3"
                  v-model="newDatav.memo"
                  autocomplete="off"
                  placeholder="请输入描述信息"
                  :maxlength="200"
                  :showWordLimit="true"
                ></ht-input>
              </ht-form-item>
            </el-form>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="newDialogVisible = false">取 消</el-button>
          <el-button
            type="primary"
            @click="addNew()">确 定</el-button>
            </span>
      </el-dialog>
    </el-container>
  </el-dialog>
</template>
<script>
import req from '@/request'
import {mapState} from 'vuex'
export default {
  name: "datav-add",
  components: {
  },
  data() {
    return {
      dialogVisible: false,
      newDialogVisible:false,
      apps:[],
      selectIdList: [],
      pageResult: {
        page: 1,
        pageSize: 15,
        total: 0
      },
      searchForm: {
        appName: "",
        isPublish: false,
        notPublish: false
      },
      tempDatav:{
        name:'',
        alias:'',
        layoutType:'2',
        width:1920,
        height:1080,
        memo:'',
      },
      newDatav:{}
    }
  },
  computed: mapState({
    uploadHeaders: function (mapState) {
      return {Authorization: 'Bearer ' + mapState.login.currentUser.token}
    },
  }),
  mounted() {
    this.$validator = this.$root.$validator
  },
  methods: {
    showDialog() {
      this.$set(this,'newDatav',JSON.parse(JSON.stringify(this.tempDatav)))
      this.dialogVisible = true;
    },
    close(){
      this.dialogVisible = false;
    },
    loadData(query){
      let loading = this.$loading({
        target: document.querySelector(".content")
      });
      let param = {
        pageBean: this.pageResult,
        querys: [],
        sorter:[{direction: 'ASC',property: 'sn_'}]
      }
      if (query) {
        param.querys = query;
      }
      portal.getSysAppList(param).then(data => {
        this.apps = data.rows;
        this.pageResult = {
          page: data.page,
          pageSize: data.pageSize,
          total: data.total
        }
      }).finally(() => {
        loading.close();
      })
    },
    add(){
      this.newDialogVisible = true;
    },
    addNew(){
      if(!this.newDatav.name){
        this.$message.warning("请输入大屏名称。");
        return ;
      }
      if(!this.newDatav.alias){
        this.$message.warning("请输入大屏别名。");
        return ;
      }
      this.newDialogVisible = false;
      this.dialogVisible = false;
      this.$emit('toDesignDatav',{type:'new',data:this.newDatav});
    },
    currentChange(page) {
      this.search(page);
    },
    itemClick(item,$event) {
      $event.preventDefault();
      if (this.selectIdList.includes(item.id)) {
        this.selectIdList.remove(item.id);
        this.$set(item,"checked",false);
      }else {
        this.selectIdList.push(item.id);
        this.$set(item,"checked",true);
      }
    },
  },
}
</script>

<style lang="scss" scoped>
@import '@/assets/css/element-variables.scss';
@import '@/assets/css/form-editor.scss';
.app_center_container{
    height: 100%;
    overflow: auto;
}
.container__body {
  position: relative;
  padding: 0 5px;
  margin-top: 1px;
  padding-left: 0;
}
.container >>> .el-header{
  padding: 0px;
}
.card {
  margin: 5px;
  min-height: 200px;
  text-align: center;
}
.card i {
  font-size: 60px;
  display: block;
  margin: 10px 0;
}
.card-item-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        background: #fafafa;
        justify-content: center;
        padding: 10px 10px 0 10px;
        margin-top: 22px;
        .actions__btn{
            margin-bottom: 10px;
        }
        .confirm__btn{
            margin-left: 10px;
        }
    }
    .pagination {
        // position: absolute;
        // bottom: 0;
        margin-top: 20px;
    }
.datav-add-dialog >>> .el-dialog__header {
  display: none;
}
.datav-add-dialog >>> .el-dialog__body {
  padding: 0;
  height: 100%;
}
.navbar-default {
  height: 100%;
  background-image: none;
  background: #fff;
  border-radius: 0px;
  box-shadow: 0px 2px 5px rgba(86, 96, 117, 0.15);
  border-bottom: 1px solid #ededed;
  justify-content: space-between;
}
.navbar-default span {
  color: #666;
  font-size: 14px;
  line-height: 48px;
  font-weight: bold;
  margin-left: 20px;
}
.header {
  padding: 0;
  background: #fff;
  z-index: 7;
}
.card-title {
  font-weight: bold;
  font-size: 20px;
}
.card-background {
  width: 80px;
  height: 80px;
  margin: 10px auto;
  border-radius: 15px;
}
.image {
  width: 30px;
  height: 30px;
}
.app-image {
  width: 60px;
  height: 60px;
  margin: 10px;
}
.input-search {
  width: 400px;
  margin: 0px 12px 0 6px;
}
  .card-item {
    cursor: default;
    display: block;
    position: relative;
  }
  .sticky {
    width: 1px;
    height: 0px;
    position: absolute;
    top: 0;
    right: 5px;
    border-left: 40px solid #fff;
    border-top: 40px solid #ededed;
  }
  .card-checkbox {
    position: absolute;
    top: -35px;
    right: 0;
  }
.card-checkbox input[type="checkbox"] {
  opacity: 0;
}
.card-checkbox input[type="checkbox"] + span::after {
  opacity: 1;
  content: "";
  position: absolute;
  width: 6px;
  height: 11px;
  background: transparent;
  right: 7px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  -webkit-transform: rotate(35deg);
  -moz-transform: rotate(35deg);
  -o-transform: rotate(35deg);
  -ms-transform: rotate(35deg);
  transform: rotate(35deg);
}
.card-item.checked .el-card {
  outline: 1px solid #5492f5;
}
.card-item.checked .sticky {
  border-top-color: #5492f5;
}
.datavAdd >>> .el-dialog__body{
  padding: 5px 10px;
}
.form {
  padding: 0px 3px;
  height: 100%;
  overflow: hidden;
  .field__tabs {
    height: 100%;
    overflow: hidden;
    min-width: 300px;
    /deep/ .el-tabs__nav-scroll {
      padding: 10px 0 0 10px;
    }
    /deep/ .el-tabs__content {
      height: 100%;
      overflow-x: hidden;
      overflow-y: auto;
    }
    /deep/ .el-collapse-item__header {
      font-weight: bold;
      color: #999;
      padding-left: 10px;
    }
    /deep/ .el-tab-pane {
      height: 100%;
    }
    /deep/ .el-collapse-item__header:hover {
      color: $--color-primary;
    }
    /deep/ .el-collapse-item__content {
      padding: 0 10px 10px;
    }
    /deep/ .el-form-item--small.el-form-item {
      margin-bottom: 5px;
    }
    /deep/ .el-form-item {
      display: inline-block;
      margin-right: 10px;
      vertical-align: top;
    }
    /deep/ .el-form-item--small .el-form-item__label {
        line-height: 32px;
    }
    /deep/ .el-form-item__label {
        float: none;
        display: inline-block;
        width: 100px;
    }
    /deep/ .el-form--label-left .el-form-item__label {
        text-align: left;
    }
  }

  /deep/ .el-form-item__content {
    margin-left: 0px !important;
  }
  /deep/ .el-dialog__body {
    padding: 5px !important;
    color: #606266;
    font-size: 14px;
    word-break: break-all;
  }
  /deep/ .el-dialog__footer {
    padding: 10px !important;
    text-align: right;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }
  .form-editor-dialog >>> .el-dialog__body {
    padding: 0;
    height: 100%;
  }
  .el-collapse-item__header {
    background: #fcfcfc;
  } 
  .form-table {
    width: 320px;
  }
  >>> .el-input-group__prepend{
    padding: 0 10px;
  }
  >>> .el-input-group__append{
    padding: 0 10px;
  }
  >>> .el-collapse-item{
    max-height: 650px;
    overflow-y: auto;
    overflow-x: hidden;
  }

}
</style>