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>
相关推荐
2501_9444480033 分钟前
Flutter for OpenHarmony衣橱管家App实战:支持我们功能实现
android·javascript·flutter
人工智能训练6 小时前
【极速部署】Ubuntu24.04+CUDA13.0 玩转 VLLM 0.15.0:预编译 Wheel 包 GPU 版安装全攻略
运维·前端·人工智能·python·ai编程·cuda·vllm
会跑的葫芦怪7 小时前
若依Vue 项目多子路径配置
前端·javascript·vue.js
xiaoqi9227 小时前
React Native鸿蒙跨平台如何进行狗狗领养中心,实现基于唯一标识的事件透传方式是移动端列表开发的通用规范
javascript·react native·react.js·ecmascript·harmonyos
jin1233228 小时前
React Native鸿蒙跨平台剧本杀组队消息与快捷入口组件,包含消息列表展示、快捷入口管理、快捷操作触发和消息详情预览四大核心功能
javascript·react native·react.js·ecmascript·harmonyos
烬头88219 小时前
React Native鸿蒙跨平台实现二维码联系人APP(QRCodeContactApp)
javascript·react native·react.js·ecmascript·harmonyos
pas1369 小时前
40-mini-vue 实现三种联合类型
前端·javascript·vue.js
摇滚侠10 小时前
2 小时快速入门 ES6 基础视频教程
前端·ecmascript·es6
2601_9498333910 小时前
flutter_for_openharmony口腔护理app实战+预约管理实现
android·javascript·flutter
珑墨10 小时前
【Turbo】使用介绍
前端