el-table 设置固定宽度弹框

java 复制代码
  <template #default="scope">
          <el-tooltip effect="dark" placement="top">
            <template #content>
              <div class="set-popper">{{scope.row.content}}</div>
            </template>
            <div class="set-content">{{ scope.row.content }}</div>
          </el-tooltip>
        </template>
<style lang="scss" scoped>
.set-popper {
  max-width: 500px;
}
.set-content {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
</style>

案例:

<template>
  <div class="app-container">

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            plain
            size="mini"
            @click="handleAdd"
            v-hasPermi="['business:servermsg:add']"
        >
          <el-icon>
            <plus/>
          </el-icon>
          新增
        </el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="servermsgList" @selection-change="handleSelectionChange">
      <el-table-column label="序号" align="center" width="60" :show-overflow-tooltip="true">
        <template v-slot="scope">
          <span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="ID" align="center" prop="id"/>-->
      <el-table-column label="文案标题" align="center" prop="text"/>
      <el-table-column label="内容介绍" :align="center" prop="content">
        <template #default="scope">
          <el-tooltip effect="dark" placement="top">
            <template #content>
              <div class="set-popper">{{scope.row.content}}</div>
            </template>
            <div class="set-content">{{ scope.row.content }}</div>
          </el-tooltip>
        </template>

      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template v-slot="scope">
          <el-button
              size="mini"
              type="text"
              @click="handleUpdate(scope.row)"
          >
            <el-icon>
              <edit/>
            </el-icon>
            修改
          </el-button>
          <el-button
              size="mini"
              type="text"
              @click="handleDelete(scope.row)"
          >
            <el-icon>
              <delete/>
            </el-icon>
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />

    <!-- 添加或修改服务器管理对话框 -->
    <el-dialog :title="title" v-model="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">

        <el-form-item  label-position="right" label="文案标题" prop="text">
          <el-input    maxlength="200" show-word-limit v-model="form.text" placeholder="请输入文案标题"/>
        </el-form-item>
        <el-form-item  label="内容介绍" prop="content" label-width="100" >
          <editor v-model="form.content"  show-word-limit  :min-height="192"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<style lang="scss" scoped>
.set-popper {
  max-width: 500px;
}
.set-content {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
</style>

<script>
import {getGiraffeManorInstro, addGiraffeManorInstro, listGiraffeManorInstro, delGiraffeManorInstro, updateGiraffeManorInstro} from "@/api/business/giraffemanorInstro";
import Pagination from '@/components/Pagination'
export default {
  name: "Servermsg",
  data() {
    return {
      isDisable:false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 服务器管理表格数据
      servermsgList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        // serverId: [{ required: true, message: "服务器Id不能为空", trigger: "blur" }],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询服务器管理列表 */
    getList() {
      this.loading = true;
      listGiraffeManorInstro(this.queryParams).then(response => {
        this.servermsgList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加宣传配置";
      this.isDisable=false;
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      debugger
      const id = row.id || this.ids
      getGiraffeManorInstro(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.isDisable=true;
        this.title = "修改宣传配置";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          debugger
          if (this.form.id != null) {

            updateGiraffeManorInstro(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            debugger
            addGiraffeManorInstro(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除标题为"' + row.text + '"的数据项?').then(function () {
        return delGiraffeManorInstro(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    }
  }
};
</script>
相关推荐
Json_181790144804 分钟前
电商拍立淘按图搜索API接口系列,文档说明参考
前端·数据库
风尚云网27 分钟前
风尚云网前端学习:一个简易前端新手友好的HTML5页面布局与样式设计
前端·css·学习·html·html5·风尚云网
木子020430 分钟前
前端VUE项目启动方式
前端·javascript·vue.js
GISer_Jing32 分钟前
React核心功能详解(一)
前端·react.js·前端框架
捂月35 分钟前
Spring Boot 深度解析:快速构建高效、现代化的 Web 应用程序
前端·spring boot·后端
深度混淆42 分钟前
实用功能,觊觎(Edge)浏览器的内置截(长)图功能
前端·edge
Smartdaili China43 分钟前
如何在 Microsoft Edge 中设置代理: 快速而简单的方法
前端·爬虫·安全·microsoft·edge·社交·动态住宅代理
秦老师Q44 分钟前
「Chromeg谷歌浏览器/Edge浏览器」篡改猴Tempermongkey插件的安装与使用
前端·chrome·edge
滴水可藏海1 小时前
Chrome离线安装包下载
前端·chrome
endingCode1 小时前
45.坑王驾到第九期:Mac安装typescript后tsc命令无效的问题
javascript·macos·typescript