VUE使用element Ui dialog组件实现最大最小化,拖拽功能

 最大化最小化在弹窗顶部使用按钮实现,提前下载icon图标

<template>
    <div class="app-container">
      <el-dialog
        v-dialogDrag
        class="ZDialog"
        :title="creditTitle"
        :modal="false"
        :fullscreen="isfullscreen"
        :visible="visible"
        :append-to-body="true"
        :show-close="false"
        width="86%"
        :close-on-click-modal="false"
        :class="isminimize ? 'isminimize' : ''"
        @close="closeDialog"
      >
        <div
          v-show="!isminimize"
          slot="title"
          class="medium"
          @dblclick="resetFull"
        >
          <div class="lefts">
            <span style="color: aliceblue;">{{ creditTitle }}</span>
          </div>
          <div class="icons">
            <i
              title="缩小"
              class="iconfont icon-zuixiaohua_huaban1"
              style="font-size: 24px"
              @click="minimize"
            ></i>&nbsp;
            <i
              title="关闭"
              class="iconfont icon-chahao"
              style="font-size: 24px"
              @click="closeDialog"
            ></i>
          </div>
        </div>
        <div v-show="isminimize" slot="title" class="horn" @dblclick="resetFull">
          <div class="lefts">
            <span style="color: aliceblue;">{{ creditTitle }}</span>
          </div>
          <div class="icons">
            <i
              title="还原"
              class="iconfont icon-huanyuan"
              style="font-size: 24px"
              @click="minimize"
            ></i>
          </div>&nbsp;
          <!-- <i
            title="关闭"
            class="iconfont icon-chahao"
            style="font-size: 24px"
            @click="closeDialog"
          ></i> -->
        </div>
        <div v-show="!isminimize" class="dialogBody">
          <slot name="body" solt="body">
            <el-tabs class="dialog-credit" v-model="activeName" type="card" @tab-click="handleClick">
              <el-tab-pane name="first">
                <span slot="label">
                  <span>信用承诺失信行为查询</span>
                </span>
                <div class="credit-title">
                  <div class="credit-left">
                    <el-input
                      size="small"
                      v-model="searchText"
                      placeholder="请输入投标单位名称"
                      class="search-area inputSearch"
                    >
                      <i class="el-icon-search" slot="suffix" @click="creditSearch"></i>
                    </el-input>&nbsp;
                    <span>提示:如果多次查询,系统显示最后一次查询结果;只查询投保金递交方式是投标保证金信用承诺函的投标人</span>
                  </div>
                  <div class="credit-reght">
                      <el-button type="primary" @click="queryBtn">查询</el-button>
                      <el-button type="primary" @click="PDFDownload">PDF下载</el-button>
                  </div>
                </div>
                <div class="credit-table">
                  <el-table
                    :data="tableData"
                    stripe
                    style="width: 100%; min-height: 520px; max-height: 520px; overflow: auto;">
                    <el-table-column
                        type="selection"
                        align = 'center'
                        header-align = 'center'
                        width="50">
                    </el-table-column>
                    <el-table-column
                        prop="creditId"
                        label="序号"
                        align = 'center'
                        header-align = 'center'
                        width="50">
                    </el-table-column>
                    <el-table-column
                        prop="unitName"
                        label="投标单位名称"
                        align = 'center'
                        header-align = 'center'
                        width="260">
                    </el-table-column>
                    <el-table-column
                        prop="marginSubmit"
                        width="300"
                        align = 'center'
                        header-align = 'center'
                        label="保证金递交方式">
                    </el-table-column>
                    <el-table-column
                        prop="dishonestyIs"
                        width="300"
                        align = 'center'
                        header-align = 'center'
                        label="是否存在信用承诺失信行为">
                    </el-table-column>
                    <el-table-column
                        prop="Inquirer"
                        width="200"
                        align = 'center'
                        header-align = 'center'
                        label="查询人">
                    </el-table-column>
                    <el-table-column
                        prop="queryTime"
                        width="263"
                        align = 'center'
                        header-align = 'center'
                        label="查询时间">
                    </el-table-column>
                    <el-table-column
                        align = 'center'
                        header-align = 'center'
                        label="查看">
                        <template slot-scope="scope">
                            <i class="el-icon-search" @click="querySearch(scope.row.unitName)"></i>
                        </template>
                    </el-table-column>
                  </el-table>
                </div>
                <div class="credit-pagination">
                  <el-pagination
                      @size-change="handleSizeChange"
                      @current-change="handleCurrentChange"
                      :current-page="currentPage4"
                      :page-sizes="[20, 30, 50, 100]"
                      :page-size="20"
                      layout="total, sizes, prev, pager, next, jumper"
                      :total="10">
                  </el-pagination>
                </div>
              </el-tab-pane>
              <el-tab-pane
                v-if="$store.state.bid.bidInfo.collectType !== 0"
                name="second"
              >
                <span slot="label">   
                  <span>信用信息查询</span>
                </span>
                <div class="credit-title">
                  <div class="credit-left">
                    <el-input
                      size="small"
                      v-model="searchText"
                      placeholder="请输入投标单位名称"
                      class="search-area inputSearch"
                    >
                      <i class="el-icon-search" slot="suffix" @click="creditSearch"></i>
                    </el-input>&nbsp;
                    <span>提示:如果多次查询,系统显示最后一次查询结果;只查询投保金递交方式是投标保证金信用承诺函的投标人</span>
                  </div>
                  <div class="credit-reght">
                      <el-button type="primary" @click="queryBtn">查询</el-button>
                      <el-button type="primary" @click="PDFDownload">PDF下载</el-button>
                  </div>
                </div>
                <div class="credit-table">
                  <el-table
                    :data="tableData"
                    stripe
                    style="width: 100%; min-height: 520px; max-height: 520px; overflow: auto;">
                    <el-table-column
                        type="selection"
                        align = 'center'
                        header-align = 'center'
                        width="50">
                    </el-table-column>
                    <el-table-column
                        prop="creditId"
                        label="序号"
                        align = 'center'
                        header-align = 'center'
                        width="50">
                    </el-table-column>
                    <el-table-column
                        prop="unitName"
                        label="投标单位名称"
                        align = 'center'
                        header-align = 'center'
                        width="260">
                    </el-table-column>
                    <el-table-column
                        prop="marginSubmit"
                        width="300"
                        align = 'center'
                        header-align = 'center'
                        label="保证金递交方式">
                    </el-table-column>
                    <el-table-column
                        prop="dishonestyIs"
                        width="300"
                        align = 'center'
                        header-align = 'center'
                        label="信用负面行为行为记录">
                    </el-table-column>
                    <el-table-column
                        prop="Inquirer"
                        width="200"
                        align = 'center'
                        header-align = 'center'
                        label="查询人">
                    </el-table-column>
                    <el-table-column
                        prop="queryTime"
                        width="263"
                        align = 'center'
                        header-align = 'center'
                        label="查询时间">
                    </el-table-column>
                    <el-table-column
                        align = 'center'
                        header-align = 'center'
                        label="查看">
                        <template slot-scope="scope">
                            <i class="el-icon-search" @click="querySearch(scope.row.unitName)"></i>
                        </template>
                    </el-table-column>
                  </el-table>
                </div>
                <div class="credit-pagination">
                  <el-pagination
                      @size-change="handleSizeChange"
                      @current-change="handleCurrentChange"
                      :current-page="currentPage4"
                      :page-sizes="[20, 30, 50, 100]"
                      :page-size="20"
                      layout="total, sizes, prev, pager, next, jumper"
                      :total="10">
                  </el-pagination>
                </div>
              </el-tab-pane>
            </el-tabs>
          </slot>
        </div>
        <!-- <div v-show="!isminimize" class="dialogFooter" v-if="isFooter">
            <slot name="footer" solt="footer">
            </slot>
        </div> -->
      </el-dialog>
    </div>
</template>
<script>
//   import "@/utils/dialogIndex"
  import "./icons/iconfont.css"
  export default {
    data() {
      return {
        isfullscreen: false, // 全屏
        isminimize: false, // 最小化
        creditTitle:'信用信息',
        queryState:false,
        activeName:'first',
        searchText:'',
        tableData:[
          {
              creditId: '1',
              unitName: 'XXXXXXXX投标人1',
              marginSubmit: '投标保证金信用承诺函',
              dishonestyIs: '否',
              Inquirer: '蝎子莱莱',
              queryTime: '2023-12-12 11:22:22',
          },{
              creditId: '2',
              unitName: 'XXXXXXXX投标人1',
              marginSubmit: '投标保证金信用承诺函',
              dishonestyIs: '否',
              Inquirer: '蝎子莱莱',
              queryTime: '2023-12-12 11:22:22',
          },{
              creditId: '3',
              unitName: 'XXXXXXXX投标人1',
              marginSubmit: '投标保证金信用承诺函',
              dishonestyIs: '否',
              Inquirer: '蝎子莱莱',
              queryTime: '2023-12-12 11:22:22',
          },{
              creditId: '4',
              unitName: 'XXXXXXXX投标人1',
              marginSubmit: '投标保证金信用承诺函',
              dishonestyIs: '否',
              Inquirer: '蝎子莱莱',
              queryTime: '2023-12-12 11:22:22',
          },
        ],
        currentPage4: 1,
      }
    },
    props:{
      isFooter:{ type: Boolean, default: false },
      visible:{ type: Boolean, default: false },
    },
    methods: {
      // 最小化
      minimize() {
        this.isminimize = !this.isminimize;
        if (this.isfullscreen) this.isfullscreen = !this.isfullscreen;
      },
      // 关闭弹窗
      closeDialog() {
        this.$emit('update:visible', false)
      },
      // 全屏
      IsFullscreen() {
        this.isfullscreen = !this.isfullscreen;
        if (this.isfullscreen) this.$emit("isfullscreen");
      },
      resetFull() {
      },
      handleClick(){
          
      },
      queryBtn(){},
      PDFDownload(){},
      handleSizeChange(val) {
          console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
          console.log(`当前页: ${val}`);
      },
      querySearch(val){
          window.open(`http://ggzy.yancheng.gov.cn/creditResult.html?wd=${val}`)
      },
      creditSearch(){
          console.log('qwqwq');
      },
    },
     watch: { 
    //   visible(val) {
    //     if (val) {
    //       const el = this.$refs[this.zDialogRef].$el.querySelector(".el-dialog");
    //       el.style.left = 0;
    //       el.style.top = 0;
    //     }
    //   },
    },
    directives: {
      dialogDrag: {
        bind(el, binding, vnode, oldVnode) {
          const dialogHeaderEl = el.querySelector(".el-dialog__header");
          const dragDom = el.querySelector(".el-dialog");

          dialogHeaderEl.style.cursor = "move";
          // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
          const sty =
            dragDom.currentStyle || window.getComputedStyle(dragDom, null);
          // const fixedX =
          // const fixedY =
          dialogHeaderEl.onmousedown = e => {
            // 判断当前是否为全屏状态
            const path =
              event.path || (event.composedPath && event.composedPath());
            const isFull = path.find(s => {
              if (s.className === undefined) {
                return false;
              } else {
                return s.className.indexOf("is-fullscreen") > -1;
              }
            });
            if (isFull !== undefined) {
              return;
            }
            const isMinix = path.find(s => {
              if (s.className === undefined) {
                return false;
              } else {
                return s.className.indexOf("isminimize") > -1;
              }
            });
            if (isMinix !== undefined) {
              return;
            }
            // 鼠标按下,计算当前元素距离可视区的距离
            const disX = e.clientX - dialogHeaderEl.offsetLeft;
            const disY = e.clientY - dialogHeaderEl.offsetTop;
  
            // 获取到的值带px 正则匹配替换
            let styL, styT;
  
            // 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
            if (sty.left.includes("%")) {
              styL =
                +document.body.clientWidth * (+sty.left.replace(/\%/g, "") / 100);
              styT =
                +document.body.clientHeight * (+sty.top.replace(/\%/g, "") / 100);
            } else {
              styL = +sty.left.replace("px", "");
              styT = +sty.top.replace("px", "");
            }
  
            document.onmousemove = function(e) {
              // 通过事件委托,计算移动的距离
              const l = e.clientX - disX;
              const t = e.clientY - disY;
              // 移动当前元素
              dragDom.style.left = `${l + styL}px`;
              dragDom.style.top = `${t + styT}px`;
            //   const dom = e.path.find(s => s.querySelector('.el-dialog')).children[0]
              
            //   if (dom.offsetTop < 0) {
            //     dragDom.style.top = `0px`
            //   }
            //   if (dom.offsetLeft < 0) {
            //     dragDom.style.left = `0px`
            //   }
  
            //   // 将此时的位置传出去
            //   binding.value({x:e.pageX,y:e.pageY})
            };
  
            document.onmouseup = function(e) {
              const dragDom = el.querySelector(".el-dialog");
              const offsetLeft = dragDom.offsetLeft;
              const offsetTop = dragDom.offsetTop;
              const left = Number(dragDom.style.left.replace("px", ""));
              const top = Number(dragDom.style.top.replace("px", ""));
              const windowWidth = window.innerWidth;
              const windowHeight = window.innerHeight - 50;
              const offsetRight = offsetLeft + dragDom.offsetWidth - windowWidth * 1.6;
              const offsetBottom =
                offsetTop + dragDom.offsetHeight - windowHeight * 1.6;
              if (offsetLeft < 0) {
                dragDom.style.left = left - offsetLeft + "px";
              }
              if (offsetTop < 0) {
                dragDom.style.top = top - offsetTop + "px";
              }
              if (offsetRight > 0) {
                dragDom.style.left = left - offsetRight + "px";
              }
              if (offsetBottom > 0) {
                dragDom.style.top = top - offsetBottom + "px";
              }
              document.onmousemove = null;
              document.onmouseup = null;
            };
          };
        }
      }
    },
  };
</script>
<style lang="scss">
  .el-dialog {
    margin-top: 10vh !important;
  }  
  .no_select {
    -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Chrome/Safari/Opera */
    -khtml-user-select: none; /* Konqueror */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none; /* Non-prefixed version, currently */
  }
  // 覆盖层元素增加可穿透点击事件
  .el-dialog__wrapper{
      pointer-events:none !important;
    }
      
    // 弹窗层元素不可穿透点击事件(不影响弹窗层元素的点击事件)
    .el-dialog{
      pointer-events:auto !important;
    }
  .isminimize {
    left: 20px;
    bottom: 20px;
    top: auto;
    right: auto;
    overflow: hidden;
  
    .el-dialog {
      margin: 0 !important;
      width: 240px !important;
      height: 43px;
      top: 0 !important;
      left: 0 !important;
    }
    .el-dialog__header {
      cursor: auto !important;
  
      .el-dialog__headerbtn {
        display: none;
      }
    }
    .dialogFooter {
      position: absolute;
      bottom: 0;
    }
  }
  .ZDialog {
    overflow: hidden;
    .is-fullscreen {
      width: 100% !important;
      left: 0 !important;
      top: 0 !important;
      margin-top: 0 !important;
      overflow: hidden;
      position: relative;
      .el-dialog__header {
        cursor: auto !important;
      }
      .el-dialog__body {
        height: 100%;
        padding: 0px !important;
        .dialogBody {
            height: 100% !important;
            max-height: none !important;
            padding-bottom: 120px !important;
        }
      }
      .dialogFooter {
        position: absolute;
        bottom: 0;
        width: 100%;
        background: #fff;
      }
    }
    .el-dialog {
      .el-dialog__header {
        width: 100%;
        padding: 10px 10px 10px !important;
        display: flex;
        border-bottom: 1px solid #ccc;
        @extend .no_select;
        cursor: auto;
        .medium {
          width: 100%;
          height: 100%;
          display: flex;
          div {
            flex: 1;
          }
          .lefts {
            margin-top: 3px;
            span {
              text-align: left;
              font-size: 16px;
              color: #606266;
            }
          }
          .icons {
            display: flex;
            justify-content: flex-end;
            i {
              color: #5f6368;
              font-size: 18px !important;
              display: block;
              padding: 3px;
            }
            i:hover {
              background: #dcdfe6;
              cursor: pointer;
            }
            .el-icon-close:hover {
              background: #f00;
              color: #fff;
            }
          }
        }
        .horn {
          width: 100%;
          height: 100%;
          display: flex;
          justify-content: space-between;
          div {
            i {
              color: #5f6368;
              font-size: 20px !important;
            }
          }
          .lefts {
            flex: 4;
            margin-top: 3px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            span {
              font-size: 16px;
              color: #606266;
            }
          }
          .icons {
            display: flex;
            justify-content: flex-end;
            i {
              color: #5f6368;
              font-size: 18px !important;
              display: block;
              padding: 3px;
            }
            i:hover {
              background: #dcdfe6;
              cursor: pointer;
            }
            .el-icon-close:hover {
              background: #f00;
              color: #fff;
            }
          }
          // .centers {
          //   flex: 1;
          // }
          // .rights {
          //   flex: 1;
          // }
          i:hover {
            cursor: pointer;
            color: #000;
          }
        }
        .el-dialog__headerbtn {
          top: 0;
          font-size: 24px;
        }
      }
      .el-dialog__body {
        padding: 0px !important;
        .dialogBody {
            // max-height: calc(80vh - 50px);
            height: 670px;
            // box-shadow: inset 0px -2px 10px 1px #b0b3b2;
            overflow: auto;
            padding: 20px 25px 20px;
            &::-webkit-scrollbar {
              width: 4px;
              height: 8px;
            }
            &::-webkit-scrollbar-thumb {
              background: transparent;
              border-radius: 4px;
            }
            &:hover::-webkit-scrollbar-thumb {
              background: hsla(0, 0%, 53%, 0.4);
            }
            &:hover::-webkit-scrollbar-track {
              background: hsla(0, 0%, 53%, 0.1);
            }       
            .dialog-credit{
                line-height: normal;
                .credit-title{
                    display: flex;
                    justify-content: space-between;
                    .credit-left{
                        color: red;
                        .inputSearch{
                            width: 250px;
                            vertical-align: middle;
                        }
                        span{
                            line-height: 30px;
                        }
                    }
                }
                .credit-table{
                    margin-top: 10px;
                }
                .credit-pagination{
                    display: flex;
                    justify-content: center;
                    margin:10px auto;
                }
            }
        }
        .dialogFooter {
          padding: 5px 15px;
          border-top: 1px solid #ccc;
          text-align: right;
          .el-button {
            padding: 7px 15px;
          }
        }
      }
    }
    .ZDialog {
      display: flex;
      justify-content: center;
      .el-select {
        width: 100%;
      }
      .el-date-editor {
        width: 100%;
      }
    }
  }
</style>
<style lang="scss" scoped>
  .el-dialog {
    // 覆盖层元素增加可穿透点击事件
    ::v-deep.el-dialog__wrapper{
      pointer-events:none;
    }
      
    // 弹窗层元素不可穿透点击事件(不影响弹窗层元素的点击事件)
    ::v-deep.el-dialog{
      pointer-events:auto;
    }
  }
</style>
  

你可以使用Vue框架结合Element UI组件实现查询表单。Vue是一个用于构建用户界面的渐进式JavaScript框架,而Element UI是一个基于Vue组件库,提供了丰富的UI组件和样式。 首先,你需要安装VueElement UI。可以通过npm或者yarn来进行安装。 ```shell npm install vue npm install element-ui ``` 接下来,在你的Vue项目中,你需要在入口文件中引入VueElement UI,并注册Element UI组件。 ```javascript import Vue from 'vue' import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' Vue.use(ElementUI) ``` 然后,你可以在你的组件使用Element UI组件来构建查询表单。例如,你可以使用`el-form`和`el-input`组件来创建一个简单的查询表单。 ```html <template> <div> <el-form :model="form" label-width="80px"> <el-form-item label="关键词"> <el-input v-model="form.keyword"></el-input> </el-form-item> <el-form-item> <el-button type="primary" @click="submitForm">查询</el-button> </el-form-item> </el-form> </div> </template> <script> export default { data() { return { form: { keyword: '' } } }, methods: { submitForm() { // 在这里处理表单提交逻辑 } } } </script> ``` 以上代码展示了一个简单的查询表单,包含一个输入框和一个查询按钮。你可以根据自己的需求进行组件的选择和配置,以实现更复杂的查询功能。 希望这个例子能帮助你开始使用Vue框架结合Element UI组件实现查询表单。如果你有任何其他问题,请随时提问!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值