关于watch监听和页码序号的真实渲染

本文介绍了Vue中的watch监听机制,包括默认行为和deep选项的使用。同时,讨论了在分页场景下如何实现页码变化时表格序号的实时更新,并给出了具体的实现方法。此外,还分享了一些VSCode的快捷键和Vue的具名插槽与作用域插槽的使用技巧,以及树形数据的处理方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

watch监听

页码序号的真实渲染

附加其他的一些常用: 


watch监听

watch:默认侦听栈的变化,基本数据类型都能侦听,复杂数据类型,引用地址改变了它默认可以侦听到

使用deep的话

堆与栈都能侦听,默认值是false,默认只侦听栈的变化

immediate:初次绑定时就立马执行回调,默认是false

关于使用如下:

export default {
  data() {
    return {
      obj: {
        a: 10
      }
    }
  },
  watch: {
    // watch:默认侦听栈的变化,基本数据类型都能侦听,复杂数据类型,引用地址改变了它默认可以侦听到
    /*
    deep:堆与栈都能侦听,默认值是false,默认只侦听栈的变化
    immediate:初次绑定时就立马执行回调,默认是false
    */
    // obj(newVal) {
    //   console.log(newVal)
    // }
    obj: {
      // deep: true,
      immediate: true,
      handler(newVal, oldVal) {
        console.log(newVal, oldVal)
      }
    }
  },
  methods: {
    btnClick() {
      // this.obj.a = Math.random() * 999
      this.obj = {
        a: Math.random() * 999
      }
    }
  }
}

页码序号的真实渲染

在渲染表格数据的时候如下:

 

 这个序号我们希望下面的页码改变,它的序号值也发生改变,就是我点击几页第几条的时候,让它跟着我发生变化,而不是序号还是1

以下是算法和使用方法

 这个是使用elemen组件   ,$index是索引号

<el-table-column label="序号" type="index">
              <template v-slot="{ $index }">
                <div>
                  {{ (page.page - 1) * page.pagesize + $index + 1 }}
                </div>
              </template>
            </el-table-column>

附加其他的一些常用: 

还有一些vscode的快捷键用法如下:

  1. ctrl+d 选中相同的

  2. alt+鼠标左键, 出现多个光标,

  3. ctrl+x 裁切

  4. ctrl+shift+左/右 选中光标前面或者后面一个词

  5. alt+上、下 能移动代码上下

 具名插槽和作用域插槽如下:

    具名插槽
         定义
          组件内xxx:
            div
                 <slot name="abc" />
       使用
          直接写  
            <xxx>
                <template v-slot:abc>
                    内容
                 <template>
            </xxx>  
            
     作用域插槽
         默认插槽
            定义
               <div>
               <slot num='123' />
               </div>
             使用
               <div   slot-scope="{num}"> 不建议使用
                <xxx>
                <template v-slot='scope/{num}'>
                scope:{
                    num:123
                }
                </template>
                </xxx>
              如果整个组件只有一个插槽且是作用域的默认插槽              
               <xxx v-slot='scope/{num}'>
                div。。。
                </xxx>                
                
                
           具名插槽
              定义
               <div>
               <slot num='123' name="abc" />
               </div>
             使用
               <div  slot="abc"   slot-scope="{num}"> 不建议使用
                <xxx>
                <template v-slot:abc='scope/{num}' #abc='scope/{num}'>
                scope:{
                    num:123
                }
                </template>
                </xxx>

用递归的方式进行树形数据处理

如下:

let arr=[
    {id:1,pid:0},
    {id:2,pid:1}    
    ...
]

function changeArr(arr,str=0){
    return arr.filter(item=>{
        if(item.pid===str){
           item.children=changeArr(arr,item.id)
            return true
        }
    })
}
changeArr(arr,0)===>[{id:1,pid:0,children:[]}]
changeArr(arr,1)====>[{id:2,pid:1}]

有些时候我们得到的数据是这样的

 但是我们想转换成树形一层套一层这样的

 

 如下:

created() {

    this.getData()

  },

methods: { 

    async getData() {

      const res = await companyDepartment()   

      console.log(res, '获得的数据')

    },

 

 

 

 

<template> <!-- 表格容器,根据 dialogTable 的值动态添加 'dialog-table' 类名 --> <div :class="{'dialog-table': dialogTable}" class="table-box"> <!-- Element UI 表格组件 --> <!-- ref: 为表格组件添加引用,方便后续操作 --> <!-- border: 是否显示表格边框 --> <!-- data: 表格展示的数据 --> <!-- header-cell-style: 设置表格表头的背景颜色 --> <!-- height: 设置表格的高度 --> <!-- highlight-current-row: 是否高亮当前选中行 --> <!-- row-class-name: 自定义行的类名 --> <!-- row-style: 设置行的样式,此处设置行高为 24px --> <!-- stripe: 是否显示斑马纹 --> <!-- style: 设置表格的宽度边框颜色 --> <!-- @selection-change: 当表格的选中项发生变化时触发的事件 --> <div class="table-container"> <el-table ref="table" v-loading="loading" :border="border" :data="tableData" :header-cell-style="{ background: headerBgColor }" :height="tableHeight" :highlight-current-row="highlightCurrentRow" :row-class-name="rowClassName" :row-style="{ height: '24px' }" :stripe="stripe" :style="{ width: '100%', borderColor: tableBorderColor }" @selection-change="handleSelectionChange" @row-dblclick="handleRowClick" @row-click="handleRowClickSelect" > <!-- 多选列 --> <!-- v-if: 当 multipleSelection 为 true 时显示多选列 --> <!-- selectable: 当开启单选模式时,使用 checkSelectable 方法判断行是否可选 --> <!-- type: 列的类型,设置为 'selection' 表示多选列 --> <!-- width: 列的宽度 --> <el-table-column v-if="multipleSelection" :selectable="singleSelect ? checkSelectable : undefined" type="selection" width="40" ></el-table-column> <!-- 序号列 --> <!-- v-if: 当 showIndex 为 true 时显示序号列 --> <!-- align: 列内容的对齐方式,设置为居中对齐 --> <!-- label: 列的表头名称 --> <!-- width: 列的宽度 --> <el-table-column v-if="showIndex" align="center" label="序号" width="60" > <!-- 序号列的内容模板 --> <!-- 计算并显示当前行的序号,考虑分页因素 --> <template #default="scope"> {{ (currentPage - 1) * pageSize + scope.$index + 1 }} </template> </el-table-column> <!-- 动态列 --> <!-- v-for: 遍历 columns 数组,动态生成列 --> <!-- key: 为每个列设置唯一的 key 值 --> <!-- formatter: 列的格式化函数 --> <!-- label: 列的表头名称 --> <!-- min-width: 列的最小宽度 --> <!-- prop: 列对应的数据字段 --> <!-- width: 列的宽度 --> <!-- show-overflow-tooltip: 是否在内容溢出时显示 tooltip --> <el-table-column v-for="column in columns" :key="column.prop" :formatter="column.formatter" :label="column.label" :min-width="column.minWidth || '80'" :prop="column.prop" :width="column.width" v-if="!isColumnHidden(column)" :show-overflow-tooltip="true" :fixed="column.fixed" > <!-- 动态列的内容模板 --> <template #default="scope"> <!-- Element UI 提示框组件 --> <!-- disabled: 是否禁用提示框 --> <!-- effect: 提示框的样式效果 --> <!-- placement: 提示框的位置 --> <el-tooltip :disabled="!isTextOverflow(scope.row[column.prop], column.className)" :effect="effect" style="max-width: 600px" :placement="placement" > <!-- 提示框的内容模板 --> <template #content> <div style="max-width: 600px; word-break: break-all">{{ scope.row[column.prop] }}</div> </template> <!-- 显示单元格内容的容器 --> <!-- class: 根据 column.preview 的值动态添加 'text-ellipsis' 类名 --> <!-- style: 设置文本颜色鼠标指针样式 --> <!-- @click: 单元格点击事件 --> <div :class="{'text-ellipsis': typeof column.preview === 'function' ? column.preview(scope.row) : column.preview}" :style="{ color: getTextColor(scope.row, column), cursor: (typeof column.clickable === 'function' ? column.clickable(scope.row) : column.clickable) ? 'pointer' : 'default' // 新增样式 }" class="preview-text" @click="handleCellClick(column, scope.row)" > <!-- 显示单元格内容 --> <!-- v-html: 根据 column.formatter 的值动态显示内容 --> <div :class="column.className" v-html="column.formatter ? column.formatter(scope.row, column, scope.row[column.prop]) : scope.row[column.prop]" v-if="!column.isInlineViewing"></div> <!-- 内联查看图标 --> <!-- v-if: 当 column.isInlineViewing 为 true 时显示图标 --> <div v-if="column.isInlineViewing"> <el-button type="text" @click="handleAction(column.icon, scope.row)"> <!-- 操作按钮的内容 --> <div class="action-item"> <!-- 操作按钮的图标 --> <svg-icon :icon-class="column.icon"/> <!-- 操作按钮的文本 --> <div class="action-text" v-html="column.formatter ? column.formatter(scope.row, column, scope.row[column.prop]) : scope.row[column.prop]"></div> <!-- <span class="action-text">{{ scope.row[column.prop] }}</span>--> </div> </el-button> </div> <!-- 新增预览图标 --> <!-- v-if: 根据 column.preview 的值判断是否显示图标 --> <svg-icon v-if="typeof column.preview === 'function' ? column.preview(scope.row) : column.preview" class="preview-icon" icon-class="primary" /> </div> </el-tooltip> </template> </el-table-column> <!-- 操作列 --> <!-- v-if: 当 showActionColumn 为 true 时显示操作列 --> <!-- label: 操作列的表头名称 --> <!-- width: 操作列的宽度 :width="actionColumnWidth"--> <!-- fixed: 操作列固定在右侧 --> <el-table-column v-if="showActionColumn" :label="operation" :min-width="calculateActionColumnWidth()" fixed="right" > <!-- 操作列的内容模板 --> <template #default="scope"> <!-- 操作按钮容器 --> <div class="operation"> <!-- 遍历操作按钮数组,动态生成按钮 --> <!-- v-for: 遍历操作按钮数组 --> <!-- key: 为每个按钮设置唯一的 key 值 --> <!-- size: 按钮的大小 --> <!-- type: 按钮的类型 --> <!-- @click: 按钮点击事件 --> <el-button v-for="button in (scope.row.actionButtons || actionButtons)" :key="button.name" size="small" type="text" :loading="typeof button.loading === 'function' ? button.loading(scope.row) : button.loading" v-if="!button.hasPermission || $auth.hasPermi(button.hasPermission)" :disabled="button.disabled ? (typeof button.disabled === 'function' ? button.disabled(scope.row) : button.disabled) : false" @click.stop="handleAction(button.name, scope.row)" > <!-- 操作按钮的内容 --> <span class="action-item"> <!-- 操作按钮的图标 --> <svg-icon :icon-class="button.icon || button.name" class="action-icon" :class="{'disabled-text': button.disabled? (typeof button.disabled === 'function' ? button.disabled(scope.row) : button.disabled) : false}" /> <!-- 操作按钮的文本 --> <span class="action-text" :class="{'disabled-text': button.disabled? (typeof button.disabled === 'function' ? button.disabled(scope.row) : button.disabled) : false}">{{ button.label }}</span> </span> </el-button> </div> </template> </el-table-column> </el-table> </div> <!-- 分页组件容器 --> <div class="pagination-wrapper" v-if="paginationFlag"> <!-- Element UI 分页组件 --> <!-- background: 是否显示分页按钮的背景 --> <!-- current-page: 当前页码 --> <!-- layout: 分页组件的布局 --> <!-- page-size: 每页显示的记录数 --> <!-- page-sizes: 每页显示记录数的可选值 --> <!-- total: 总记录数 --> <!-- @size-change: 每页显示记录数变化时触发的事件 --> <!-- @current-change: 当前页码变化时触发的事件 --> <el-pagination :background="background" :current-page="currentPage" :layout="layout" :page-size="pageSize" :page-sizes="pageSizes" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" /> </div> </div> </template> <script> /** * ElementTableWrapper 组件 * 封装了 Element UI 的表格组件,提供了多选、序号、动态列、操作列分页等功能 */ export default { name: 'ElementTableWrapper', props: { // 表格数据 tableData: { type: Array, default: () => [] }, // 列配置 columns: { type: Array, default: () => [] }, // 列配置 operation: { type: String, default: '操作' }, // 是否开启多选功能 multipleSelection: { type: Boolean, default: false }, // 是否显示操作列 showActionColumn: { type: Boolean, default: true }, // 是否显示边框 border: { type: Boolean, default: true }, // 是否显示斑马纹 stripe: { type: Boolean, default: false }, // 是否高亮当前行 highlightCurrentRow: { type: Boolean, default: false }, // 是否高亮当前行 dialogTable: { type: Boolean, default: false }, // 是否显示分页功能 paginationFlag: { type: Boolean, default: true }, // 行样式类名回调函数 rowClassName: { type: Function, default: () => '' }, // 操作按钮配置 actionButtons: { type: Array, default: () => [ {name: 'add', label: '新增', icon: 'add'}, {name: 'edit', label: '编辑', icon: 'edit'}, {name: 'delete', label: '删除', icon: 'delete'} ] }, // 表格头背景颜色 headerBgColor: { type: String, default: '#F9FAFB' }, // 表格边框颜色 tableBorderColor: { type: String, default: 'rgb(234, 236, 240)' }, // 新增单选控制props singleSelect: { // 启用单选模式 type: Boolean, default: false }, // 默认选中首行 defaultSelect: { type: Boolean, default: false }, // 新增分页相关props currentPage: { type: Number, default: 1 }, // 每页显示的记录数 pageSize: { type: Number, default: 10 }, // 总记录数 total: { type: Number, default: 0 }, // 每页显示记录数的可选值 pageSizes: { type: Array, default: () => [10, 20, 50, 100] }, // 分页组件的布局 layout: { type: String, default: 'total, sizes, prev, pager, next, jumper' }, // 是否显示分页按钮的背景 background: { type: Boolean, default: true }, // 表格高度 tableHeight: { type: [String, Number], default: '100%' // 默认100%高度 }, // 是否显示序号列 showIndex: { type: Boolean, default: true }, // 是否启用行点击事件 rowClickEnable: { type: Boolean, default: false }, // 行点击事件处理器 rowClickHandler: { type: Function, default: null }, // 提示框的样式效果 effect: { type: String, default: 'dark' }, // 提示框的位置 placement: { type: String, default: 'top' }, enableRowClickSelect: { type: Boolean, default: false }, // 新增 loading 属性 loading: { type: Boolean, default: false } }, data() { return { currentSelection: null, // 当前选中行 crossPageSelection: [], // 跨页选择的数据 } }, watch: { /** * 监听表格数据变化 * 当表格数据变化且 defaultSelect 为 true 时,默认选中第一行 * @param {Array} newVal - 新的表格数据 */ tableData(newVal) { if (this.defaultSelect && newVal.length > 0) { this.$nextTick(() => { // 切换第一行的选中状态为选中 this.$refs.table.toggleRowSelection(newVal[0], true) }) } }, }, mounted() { this.$emit('rendered'); // 触发 rendered 事件 }, methods: { /** * 处理操作按钮点击事件 * 触发与按钮名称对应的自定义事件,并传递当前行数据 * @param {string} actionName - 操作按钮的名称 * @param {Object} row - 当前行的数据 */ handleAction(actionName, row) { this.$emit(actionName, row); }, // 处理行点击事件 handleRowClick(row) { if (this.rowClickEnable) { // 触发自定义行点击事件 this.$emit('row-click', row); // 如果有自定义处理函数则执行 if (this.rowClickHandler) { this.rowClickHandler(row); } } }, /** * 获取文本颜色 * 根据列的文本颜色规则,判断是否需要修改文本颜色 * @param {Object} row - 当前行的数据 * @param {Object} column - 当前列的配置 * @returns {string} - 文本颜色 */ getTextColor(row, column) { // 将参数名从prop改为column if (column.textColorRule) { const {condition, color} = column.textColorRule; if (condition(row)) { // 新增:如果 color 是函数则调用并传入当前行数据,否则直接使用字符串 return typeof color === 'function' ? color(row) : color; } } return 'rgb(38, 38, 38)'; }, /** * 处理单元格点击事件 * 当单元格可点击时,触发 'cell-click' 自定义事件 * @param {Object} column - 当前列的配置 * @param {Object} row - 当前行的数据 */ handleCellClick(column, row) { if (typeof column.clickable === 'function' ? column.clickable(row) : column.clickable) { this.$emit('cell-click', { column, row, prop: column.prop }) } }, /** * 判断文本是否溢出 * 通过比较元素的滚动宽度客户端宽度来判断文本是否溢出 * @param {string} text - 文本内容 * @param className * @returns {boolean} - 文本是否溢出 */ isTextOverflow(text, className) { if (!text || !className) return false; // 创建测量容器 const container = document.createElement('div'); container.className = className; container.style.cssText = ` position: absolute; visibility: hidden; white-space: nowrap; font-size: 14px; padding: 0 8px; max-width: 100%; `; // 创建文本测量元素 const textSpan = document.createElement('div'); textSpan.textContent = text; // 测量逻辑 document.body.appendChild(container); container.appendChild(textSpan); const containerWidth = container.offsetWidth; const textWidth = textSpan.offsetWidth; document.body.removeChild(container); // 双重判断:文本超过容器宽度且在表格最大宽度范围内 return textWidth > containerWidth; }, /** * 处理每页显示记录数变化事件 * 触发 'update:pageSize' 'pagination-change' 自定义事件 * @param {number} val - 新的每页显示记录数 */ handleSizeChange(val) { this.$emit('update:pageSize', val); this.$emit('pagination-change', { page: this.currentPage, size: val }); // 新增:滚动到表格顶部 this.$nextTick(() => { const tableWrapper = this.$refs.table.$el.querySelector('.el-table__body-wrapper'); if (tableWrapper) { tableWrapper.scrollTop = 0; } }); }, // 暴露给父组件的方法 toggleRowSelection(row, selected) { this.$refs.table.toggleRowSelection(row, selected) }, /** * 处理表格选中项变化事件 * 当开启单选模式时,确保只选中一行 * @param {Array} selection - 当前选中的行数据数组 */ handleSelectionChange(selection) { if (this.singleSelect) { if (selection.length > 1) { const last = selection[selection.length - 1] // 清空所有选中项 this.$refs.table.clearSelection() // 切换最后一项的选中状态为选中 this.$refs.table.toggleRowSelection(last) this.currentSelection = last } else { this.currentSelection = selection[0] || null } } // 触发 'selection-change' 自定义事件,传递跨页选择的数据 this.$emit('selection-change', selection) }, /** * 计算操作列的宽度 * 根据操作按钮的数量每个按钮的大致宽度计算操作列的宽度 * @returns {number} - 操作列的宽度 */ calculateActionColumnWidth() { const getButtonWidth = (text) => { if (text.length >= 4) return 80; else if (text.length >= 2) return 60; return 40; }; // 权限判断方法(与模板中的v-if逻辑保持一致) const hasPermission = (button) => { return !button.hasPermission || this.$auth.hasPermi(button.hasPermission); }; const maxButtonCountRow = this.tableData.reduce((prev, current) => { // 过滤无权限按钮后比较 const prevValid = (prev.actionButtons || this.actionButtons).filter(hasPermission); const currentValid = (current.actionButtons || this.actionButtons).filter(hasPermission); return prevValid.length > currentValid.length ? prev : current; }, {}); // 过滤有效按钮 const validButtons = (maxButtonCountRow.actionButtons || this.actionButtons).filter(hasPermission); return validButtons.reduce((sum, button) => { return sum + getButtonWidth(button.label); }, 0); // 增加安全边距 }, /** * 检查行是否可选 * 当开启单选模式时,判断行是否可以被选中 * @param {Object} row - 当前行的数据 * @param {number} index - 当前行的索引(未使用) * @returns {boolean} - 行是否可选 */ checkSelectable(row, index) { return !this.currentSelection || row === this.currentSelection }, /** * 处理当前页码变化事件 * 触发 'update:currentPage' 'pagination-change' 自定义事件 * @param {number} val - 新的当前页码 */ handleCurrentChange(val) { this.$emit('update:currentPage', val); this.$emit('pagination-change', { page: val, size: this.pageSize }); // 新增:滚动到表格顶部 this.$nextTick(() => { const tableWrapper = this.$refs.table.$el.querySelector('.el-table__body-wrapper'); if (tableWrapper) { tableWrapper.scrollTop = 0; } }); }, // 新增列隐藏判断方法 isColumnHidden(column) { if (typeof column.hidden === 'function') { return column.hidden(this.$parent) // 传入父组件上下文 } return !!column.hidden }, /** * 处理行点击选中事件 * 当 enableRowClickSelect 为 true 时,选中点击的行 * @param {Object} row - 当前点击行的数据 */ handleRowClickSelect(row) { if (this.enableRowClickSelect) { if (this.singleSelect) { // 单选模式,清空其他选中项,选中当前行 this.$refs.table.clearSelection(); this.$refs.table.toggleRowSelection(row, true); } else { // 多选模式,切换当前行的选中状态 this.$refs.table.toggleRowSelection(row); } this.$emit('selection-change', this.$refs.table.selection); } } } }; </script> <style lang="scss" scoped> .table-box { display: flex; flex-direction: column; flex: 1; overflow: hidden; } .table-container { flex: 1; overflow: auto; ::v-deep .el-table { .el-table__body-wrapper { overflow: auto; height: calc(100% - 44px) !important; } } } /** * 对话框中的表格样式 * 设置表格高度为 100% */ .dialog-table { height: 100%; } /** * 分页组件容器样式 * 绝对定位到底部右侧,宽度为表格宽度减去 33px,文本右对齐 */ .pagination-wrapper { position: relative; text-align: right; margin-bottom: 10px; margin-top: 15px; } /** * 表格容器样式 * 确保表格容器有相对定位,设置最小高度 */ div:first-child { position: relative; min-height: 30px; /* 可根据需要调整最小高度 */ } /** * 分页按钮样式 * 设置分页按钮的边框、圆角、内边距鼠标悬停样式 */ ::v-deep .el-pagination.is-background { .btn-prev, .btn-next { border: 1px solid #DCDFE6; border-radius: 4px; padding: 0 8px; margin: 0 5px; &:hover { color: #409EFF; border-color: #409EFF; } } } /** * 表格基础样式 * 设置表格字体大小,处理文本换行溢出情况,设置预览图标样式 */ ::v-deep .el-table { font-size: 14px; /** * 允许换行的列样式 * 允许文本换行,调整行高 */ .wrap-text-column { white-space: normal !important; /* 允许换行 */ word-break: break-all; /* 允许单词内换行 */ line-height: 1.5; /* 调整行高 */ } /** * 鼠标悬停在表格行上时的样式 * 显示预览图标 */ tr:hover { .preview-icon { display: inline-block !important; } } .cell-content { .content-wrapper { .el-icon-loading { display: inline-block !important; position: absolute; right: 8px; top: 25%; color: #1D9C9D; } } } /** * 非换行列的样式 * 文本不换行,溢出部分显示省略号 */ :not(.wrap-text-column) { .cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } } /** * 文本省略样式 * 文本不换行,溢出部分显示省略号,为图标留出空间 */ .text-ellipsis { position: relative; padding-right: 24px; // 为图标留出空间 display: inline-block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /** * 预览图标样式 * 默认隐藏,鼠标悬停在表格行上时显示 */ .preview-icon { display: none; position: absolute; right: 8px; top: 25%; cursor: pointer; color: #1D9C9D; } /** * 预览文本样式 * 文本不换行,溢出部分显示省略号,垂直居中 */ .preview-text { display: inline-block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; line-height: 2; /** * 标签列样式 * 允许标签换行,设置标签样式 */ .tags-column { white-space: normal !important; line-height: 1.5; /** * 标签项样式 * 设置标签的边框、圆角、颜色背景颜色 */ .tag-item { display: inline-block; padding: 2px 8px; margin: 2px; border: 1px solid rgba(255, 105, 41, 0.5); border-radius: 4px; color: #FF6929; background-color: transparent; font-size: 12px; word-break: keep-all; /* 防止单个标签换行 */ } } } /** * 表格表头单元格样式 * 调整内边距,设置文本不换行,不隐藏溢出内容,不显示省略号 */ th, td { padding: 2px 0; .cell { white-space: nowrap; overflow: visible; text-overflow: ellipsis; line-height: 1; } } td.el-table__cell div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } } /** * 操作项样式 * 设置操作按钮操作项的布局为水平居中对齐 */ .operation, .action-item { display: flex; white-space: nowrap; /* 防止操作按钮换行 */ align-items: center; } /** * 文本省略样式 * 文本不换行,溢出部分显示省略号 */ .text-ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .action-item { cursor: pointer; margin-right: 8px; &:last-child { margin-right: 0; } .action-text { margin-left: 4px; font-size: 12px; color: rgb(31, 198, 234); } .action-icon { width: 1em; height: 1em; color: #1FC6EA; transition: color 0.2s; &:hover { color: #1FC6EA; } } .disabled-text { color: #999; } } ::v-deep .el-button--text { padding: 2px 0; } .action-item { display: inline-flex; align-items: center; cursor: pointer; margin-right: 8px; &:last-child { margin-right: 0; } } .action-text { margin-left: 4px; font-size: 12px; color: #606266; } .action-icon { width: 1em; height: 1em; cursor: pointer; color: #606266; transition: color 0.2s; } .action-icon:hover { color: #1FC6EA; } /* 添加表格字体大小设置 */ ::v-deep .el-table { font-size: 14px; /* 可调整字体大小 */ } ::v-deep .el-table th, ::v-deep .el-table td { padding: 10px 0; /* 调整单元格内边距 */ } /* 表格内容单行显示 */ ::v-deep .el-table .cell { white-space: nowrap; /* 不换行 */ overflow: visible; /* 不隐藏溢出内容 */ text-overflow: ellipsis; /* 不显示省略号 */ line-height: 1; /* 行高 */ } </style> 数据内容{ "total": 77251, "rows": [ { "id": "3109226059753587717", "stationId": "10042", "stationName": "盘城变", "voltageLevel": "220kV", "voltageLevelCode": "33", "bayId": "10006395", "bayName": "2号主变", "areaId": "206", "areaName": "220北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "2号主变110kV侧中性点成套装置", "equipNo": "10MZ0108517959259", "equipModel": "SR-JXB-110", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户外式", "useEnvironmentCode": "2", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "江苏省如高高压电器有限公司", "startTime": "2022-09-30", "manufactureDate": "2021-05-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587718", "stationId": "10089", "stationName": "万寿变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "10004149", "bayName": "1号主变", "areaId": "213", "areaName": "城北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "1号主变中性点成套装置", "equipNo": "10MZ0108518228845", "equipModel": "CG-IXB-110/1600", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户外式", "useEnvironmentCode": "2", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "湖南长高高压开关有限公司", "startTime": "2023-01-01", "manufactureDate": "2021-11-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587719", "stationId": "64386cb90e3c11ee90179e25b59ef9e0", "stationName": "绿洲变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "64d4ac720e3c11ee90179e25b59ef9e0", "bayName": "1号主变", "areaId": "210", "areaName": "城南", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "1号主变中性点成套装置", "equipNo": "10MZ0108519189286", "equipModel": "XK-ZJB-110", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "西安西电高压开关有限责任公司", "startTime": "2023-06-26", "manufactureDate": "2023-05-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587720", "stationId": "64386cb90e3c11ee90179e25b59ef9e0", "stationName": "绿洲变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "64d4ac7c0e3c11ee90179e25b59ef9e0", "bayName": "2号主变", "areaId": "210", "areaName": "城南", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "2号主变中性点成套装置", "equipNo": "10MZ0108519190392", "equipModel": "XK-ZJB-110", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "西安西电高压开关有限责任公司", "startTime": "2023-06-26", "manufactureDate": "2023-05-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587721", "stationId": "10000002", "stationName": "徐庄变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "128246796", "bayName": "2号主变", "areaId": "213", "areaName": "城北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "2号主变中性点成套装置", "equipNo": "10MZ0108519046377", "equipModel": "GW13-72.5(W)", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "江苏如皋高压电器有限公司", "startTime": "2011-03-11", "manufactureDate": "2011-01-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587722", "stationId": "10000002", "stationName": "徐庄变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "10014690", "bayName": "1号主变", "areaId": "213", "areaName": "城北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "1号主变中性点成套装置", "equipNo": "10MZ0108519046388", "equipModel": "GW13-72.5(W)", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "江苏如皋高压电器有限公司", "startTime": "2011-03-11", "manufactureDate": "2011-01-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587723", "stationId": "a13ce0756f8a06deed5382a7950153a13cbdc630ab", "stationName": "诚实变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "c2b10909-afe1-47fa-af68-c268247d1a7d", "bayName": "2号主变", "areaId": "213", "areaName": "城北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "2号主变中性点成套装置", "equipNo": "10MZ0108521242648", "equipModel": "GW13-126W/1600", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "常州思源东芝变压器有限公司", "startTime": "2024-09-06", "manufactureDate": "2024-01-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587724", "stationId": "19b7e87c-70b3-4736-9126-066604cfe72f", "stationName": "小村变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "d22b61f9-4a32-4da2-b2d8-c10a447d1f51", "bayName": "2号主变", "areaId": "210", "areaName": "城南", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "2号主变中性点成套装置", "equipNo": "10MZ0108521256500", "equipModel": "ZJKK-320-15", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "江苏如高高压电器有限公司", "startTime": "2024-09-23", "manufactureDate": "2024-02-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587725", "stationId": "19b7e87c-70b3-4736-9126-066604cfe72f", "stationName": "小村变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "6acbf7ba-0563-4500-92af-07f80a9f0137", "bayName": "1号主变", "areaId": "210", "areaName": "城南", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "1号主变中性点成套装置", "equipNo": "10MZ0108521256499", "equipModel": "ZJKK-320-15", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "江苏如高高压电器有限公司", "startTime": "2024-09-23", "manufactureDate": "2024-02-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587726", "stationId": "10055", "stationName": "珠江路变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "4fcb2a97-9e97-4382-ad72-76fa14a0a900", "bayName": "3号主变", "areaId": "213", "areaName": "城北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "3号主变中性点成套装置", "equipNo": "10MZ0108521889218", "equipModel": "SR-JXB-110", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "3号主变中性点成套装置", "useEnvironment": "户外式", "useEnvironmentCode": "2", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "KH250066", "produceOrgId": "", "produceOrg": "江苏如高高压电气有限公司", "startTime": "2025-04-01", "manufactureDate": "2025-03-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587727", "stationId": "10054", "stationName": "云南路变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "10001660", "bayName": "1号主变", "areaId": "213", "areaName": "城北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "1号主变中性点成套装置", "equipNo": "10MZ0108521404169", "equipModel": "XK-ZJB-110", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "2801240138", "produceOrgId": "", "produceOrg": "西安西电高压开关有限责任公司", "startTime": "2024-10-23", "manufactureDate": "2024-08-30", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587728", "stationId": "0f1da7c8-e937-47a9-ae19-485c64ed19bd", "stationName": "骆家变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "09cf5ce2-3384-4b4c-920d-d782477a447f", "bayName": "2号主变", "areaId": "213", "areaName": "城北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "2号主变中性点成套装置", "equipNo": "10MZ0108521505000", "equipModel": "SR-JXB-110", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "江苏省如皋高压电器有限公司", "startTime": "2024-12-20", "manufactureDate": "2023-10-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587729", "stationId": "0f1da7c8-e937-47a9-ae19-485c64ed19bd", "stationName": "骆家变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "6ab30fc2-7c0f-4c53-8ee1-0e5b5745ec71", "bayName": "1号主变", "areaId": "213", "areaName": "城北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "1号主变中性点成套装置", "equipNo": "10MZ0108521504999", "equipModel": "SR-JXB-110", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "江苏省如皋高压电器有限公司", "startTime": "2024-12-20", "manufactureDate": "2023-10-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587730", "stationId": "10054", "stationName": "云南路变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "10001661", "bayName": "2号主变", "areaId": "213", "areaName": "城北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "2号主变中性点成套装置", "equipNo": "10MZ0108521500656", "equipModel": "XK-ZJB-110", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "60613", "produceOrgId": "", "produceOrg": "西安西电高压开关有限公司", "startTime": "2024-12-19", "manufactureDate": "2006-06-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587731", "stationId": "10100", "stationName": "上新河变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "10005161", "bayName": "2号主变", "areaId": "210", "areaName": "城南", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "2号主变中性点成套装置", "equipNo": "10MZ0108522469177", "equipModel": "SR-JXB-110", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户外式", "useEnvironmentCode": "2", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "KH250036828", "produceOrgId": "", "produceOrg": "江苏如高高压电器有限公司", "startTime": "2025-05-07", "manufactureDate": "2025-03-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587732", "stationId": "10055", "stationName": "珠江路变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "8bbba0e3-8214-4833-80c2-4fbb37cedd47", "bayName": "2号主变", "areaId": "213", "areaName": "城北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "2号主变中性点成套装置", "equipNo": "10MZ0108522399716", "equipModel": "SR-JXB-110", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "KH250064", "produceOrgId": "", "produceOrg": "江苏如高高压电器有限公司", "startTime": "2025-05-06", "manufactureDate": "2025-03-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109226059753587733", "stationId": "a13ce0756f8a06deed5382a7950153a13cbdc630ab", "stationName": "诚实变", "voltageLevel": "110kV", "voltageLevelCode": "32", "bayId": "9b15d344-3e5b-41f1-88fb-86f94ec6f5c3", "bayName": "1号主变", "areaId": "213", "areaName": "城北", "equipLevel": "32", "equipLevelName": "110kV", "equipName": "1号主变中性点成套装置", "equipNo": "10MZ0108522479005", "equipModel": "GW13-126W/1600", "equipTypeId": 141, "equipTypeName": "主变中性点成套装置", "transRunNo": "", "useEnvironment": "户内式", "useEnvironmentCode": "1", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": null, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "", "produceOrgId": "", "produceOrg": "江苏华鹏变压器有限公司", "startTime": "2025-05-12", "manufactureDate": "2025-02-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": "O", "phaseCode": "4", "psrStateName": "在运", "psrState": "20" }, { "id": "3109222058689561600", "stationId": "154178358", "stationName": "滨南变", "voltageLevel": "220kV", "voltageLevelCode": "33", "bayId": null, "bayName": null, "areaId": "203", "areaName": "220南", "equipLevel": "22", "equipLevelName": "10kV", "equipName": "1号主变102B4接地刀闸", "equipNo": "10MZ0108517740354", "equipModel": null, "equipTypeId": 138, "equipTypeName": "低压隔离开关", "transRunNo": "102B4", "useEnvironment": "", "useEnvironmentCode": "", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": 4000.0, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "C2113022", "produceOrgId": "", "produceOrg": "江苏如高高压电器有限公司", "startTime": "2022-06-30", "manufactureDate": "2022-07-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": null, "phaseCode": null, "psrStateName": "在运", "psrState": "20" }, { "id": "3109222058689561601", "stationId": "154178358", "stationName": "滨南变", "voltageLevel": "220kV", "voltageLevelCode": "33", "bayId": null, "bayName": null, "areaId": "203", "areaName": "220南", "equipLevel": "22", "equipLevelName": "10kV", "equipName": "1号主变102B5接地刀闸", "equipNo": "10MZ0108517740480", "equipModel": null, "equipTypeId": 138, "equipTypeName": "低压隔离开关", "transRunNo": "102B5", "useEnvironment": "", "useEnvironmentCode": "", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": 4000.0, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "C2113021", "produceOrgId": "", "produceOrg": "江苏如高高压电器有限公司", "startTime": "2022-06-30", "manufactureDate": "2022-07-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": null, "phaseCode": null, "psrStateName": "在运", "psrState": "20" }, { "id": "3109222058689561602", "stationId": "154178358", "stationName": "滨南变", "voltageLevel": "220kV", "voltageLevelCode": "33", "bayId": null, "bayName": null, "areaId": "203", "areaName": "220南", "equipLevel": "22", "equipLevelName": "10kV", "equipName": "2号主变102A4接地刀闸", "equipNo": "10MZ0108517740549", "equipModel": null, "equipTypeId": 138, "equipTypeName": "低压隔离开关", "transRunNo": "102A4", "useEnvironment": "", "useEnvironmentCode": "", "structType": "", "structTypeCode": "", "insulationMedium": "", "insulationMediumCode": "", "ratedCurrent": 4000.0, "ratedBreakCurrent": null, "ratedCapacity": null, "breakerStructType": "", "breakerStructTypeCode": "", "ownNo": "C2113023", "produceOrgId": "", "produceOrg": "江苏如高高压电器有限公司", "startTime": "2022-06-30", "manufactureDate": "2022-07-01", "lastUpdateTime": "", "nextUpdateTime": "", "cycle": "6", "cycleUnit": "1", "dispatchRecord": "", "regulatePressureMode": null, "regulatePressureModeCode": null, "equipmentType": null, "equipmentTypeCode": null, "phase": null, "phaseCode": null, "psrStateName": "在运", "psrState": "20" } ], "code": 200, "msg": "查询成功" } 在this.tableData = res.rows.map(row => { const deviceType = row.equipTypeName; const deviceColumns = this.configMap[deviceType] || []; const newRow = {...row}; // 遍历所有列,若不在设备类型对应列中,则添加斜线 this.columns.forEach(col => { const prop = col.prop; if (!deviceColumns.includes(col.label)) { newRow[prop] = '/'; } }); return newRow; });为什么渲染的时候需要2s左右
07-26
<template> <div> <header class="ant-layout-header header_sd-header_common"> <div class="left_sd-header_common"> <div class="logo_sd-webflow_webflow"> <h3>激励考核指下发</h3> </div> </div> <div class="right_sd-header_common"> <a-button v-if="!readonly" type="link" icon="save" class="button_sd-webflow-button_webflow" @click="save" > 保存 </a-button> <a-button v-if="!readonly" type="link" icon="save" class="button_sd-webflow-button_webflow" @click="xfClick" > 下发 </a-button> <a-button type="link" icon="close-circle" class="button_sd-webflow-button_webflow" @click="btnClose" > 退出 </a-button> </div> </header> <div class="budget-record"> <div class="budget-record-table"> <h2 class="budget-record-table-title">激励考核指下发</h2> <a-form-model ref="ruleForm" :rules="rules" :model="project" class="sitd-apply" layout="horizontal" > <table> <colgroup> <col width="170px" /> <col /> <col width="170px" /> <col /> </colgroup> <tr> <td class="ant-form-item-label cell_sd-form-item-td-label_common"> <label title="指标编号">指标编号</label> </td> <td class="ant-form-item-control-wrapper" :colspan="3"> <a-form-model-item prop="zbbh"> <template>{{ project['zbbh'] }}</template> </a-form-model-item> </td> </tr> <tr> <td class="ant-form-item-label cell_sd-form-item-td-label_common"> <label title="指标年度" class="ant-form-item-required">指标年度</label> </td> <td class="ant-form-item-control-wrapper"> <a-form-model-item prop="zbnd"> <!-- 修改为下拉选择框 --> <a-select v-if="!readonly" v-model="project['zbnd']" placeholder="请选择年份" style="width: 100%" > <!-- 生成年份选项 --> <a-select-option v-for="year in yearOptions" :key="year" :value="year"> {{ year }} </a-select-option> </a-select> <template v-else> {{ project['zbnd'] }} </template> </a-form-model-item> </td> <td class="ant-form-item-label cell_sd-form-item-td-label_common"> <label title="考核周期">考核周期</label> </td> <td class="ant-form-item-control-wrapper"> <a-form-model-item prop="khzq"> <a-input v-if="!readonly" v-model="project['khzq']" placeholder="考核周期" /> <template v-else>{{ project['khzq'] }}</template> </a-form-model-item> </td> </tr> <tr> <td class="ant-form-item-label cell_sd-form-item-td-label_common"> <label title="考核对象">考核对象</label> </td> <td class="ant-form-item-control-wrapper"> <a-form-model-item prop="khdx"> <a-select v-if="!readonly" v-model="selectedKhdxIds" mode="multiple" style="width: 100%" placeholder="请选择被考核对象" @change="handleKhdxChange" > <template v-for="(item, _i) in khdxList"> <a-select-option :key="item.code" :value="item.code">{{ item.value }}</a-select-option> </template> </a-select> <template v-else>{{ project['khdx'] }}</template> </a-form-model-item> </td> <td class="ant-form-item-label cell_sd-form-item-td-label_common"> <label title="创建日期" class="ant-form-item-required">创建日期</label> </td> <td class="ant-form-item-control-wrapper"> <a-form-model-item prop="cjrq"> <template>{{ project['cjrq'] ? refreshTime(project['cjrq']) : '' }}</template> </a-form-model-item> </td> </tr> <tr> <td class="ant-form-item-label cell_sd-form-item-td-label_common upload-td"> <label title="说明">说明</label> </td> <td class="ant-form-item-control-wrapper" colspan="3"> <a-form-model-item prop="sm"> <div v-if="!readonly" class="textarea-wrapper"> <a-textarea v-model="project['sm']" placeholder="请输入内容" :max-length="300" class="m-textarea" :auto-size="{ minRows: 3, maxRows: 5 }" /> <span class="m-count">{{ `${project['sm']?.length || 0}/300` }}</span> </div> <template v-else>{{ project['sm'] }}</template> </a-form-model-item> </td> </tr> </table> </a-form-model> <!-- 这里暂时去掉,根据客户描述,一年只进行一次年度考核激励考核,因此根据年度单位关联即可 --> <!-- <h3 class="budget-record-table-title">关联年度考核</h3> <a-button v-if="!readonly" type="primary" :style="{ marginLeft: '88px' }" class="button_sd-webflow-button_webflow" @click="openDialogGl" > 关联年度考核 </a-button> <a-button v-if="!readonly" :style="{ marginLeft: '8px' }" class="button_sd-webflow-button_webflow" :disabled="!ndkhSelectedRowKeys.length" @click="ndkhBeforDelete" > 删除 </a-button> <a-modal title="选择年度考核" :visible="dialogVisibleGl" width="80%" @ok="handleDialogConfirm" @cancel="dialogVisibleGl = false" > <div class="apply-search"> <a-form-model :form="searchForm" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"> <a-row :gutter="24"> <a-col :span="8" class="chd"> <a-form-model-item label="考核年度"> <a-input v-model="searchForm['khnd']" allow-clear placeholder="请输入指标年度" /> </a-form-model-item> </a-col> <a-col :span="8" class="chd"> <a-form-model-item label="考核周期"> <a-input v-model="searchForm['khzq']" allow-clear placeholder="请输入考核周期" /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="24" class="chd" :style="{ textAlign: 'right', lineHeight: '45px' }"> <a-button :style="{ marginRight: '8px' }" @click="reset"> 重置 </a-button> <a-button type="primary" html-type="submit" @click="btnSearchBusinessList"> 查询 </a-button> </a-col> </a-row> </a-form-model> </div> <a-divider style="margin: 12px 0" /> <SdTable ref="ndkh" row-key="id" :columns="ndkhColumns" :data-source.sync="dialogResult" :pagination="paginationOpt" :loading="dialogLoading" :scroll="{ x: 1500 }" :row-selection="{ selectedRowKeys: selectedRowKeysAdd, onChange: btnSelectProjectAdd, }" > </SdTable> </a-modal> <SdTable ref="ndkhTable" row-key="id" :columns="ndkhColumns" :data-source.sync="ndkhResult" :loading="ndkhLoading" :pagination="false" class="ant-table" :row-selection="{ selectedRowKeys: ndkhSelectedRowKeys, onChange: btnSelectProjectNdkh, }" > </SdTable> --> <h3 class="budget-record-table-title" style="margin-top: 18px">激励考核指标</h3> <a-button v-if="!readonly" type="primary" :style="{ marginLeft: '88px' }" class="button_sd-webflow-button_webflow" @click="openDialog" > 新增 </a-button> <a-button v-if="!readonly" :style="{ marginLeft: '8px' }" class="button_sd-webflow-button_webflow" :disabled="!selectedRowKeys.length" @click="btnBeforDelete" > 删除 </a-button> <SdTable ref="jlkhzbxf" row-key="id" :columns="jlkhzbxfColumns" :data-source.sync="jlkhzbxfResult" :loading="loading" :pagination="false" class="ant-table" bordered :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: btnSelectProject, }" > <!-- 指标内容列自定义渲染 --> <template slot="指标内容" slot-scope="text, record, index"> <div style="white-space: pre-line; text-align: left; padding: 8px 0"> {{ text }} </div> </template> <template slot="分值" slot-scope="text, record, index"> <div style="white-space: pre-line; text-align: left; padding: 8px 0"> {{ text }} </div> </template> <!-- 操作列 --> <template v-if="!readonly" slot="操作" slot-scope="text, record"> <a-button class="action-button" type="link" size="small" @click="btnOpenProjectDetails(record)" > 编辑 </a-button> </template> </SdTable> <a-modal title="激励考核指标" :visible="dialogVisible" width="35%" @ok="handleConfirm" @cancel="handleCancel" > <div class="apply-search"> <a-form-model ref="subFormRef" :rules="jlkhzbxfSubRules" :form="jlkhzbxfSubForm" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" > <a-row> <a-col :span="18"> <a-form-model-item label="指标类别"> <a-input v-model="jlkhzbxfSubForm['zblb']" allow-clear placeholder="请输入指标类别" /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="18"> <a-form-model-item label="指标内容"> <a-textarea v-model="jlkhzbxfSubForm['zbnr']" placeholder="请输入指标内容(按Enter换行)" :max-length="300" class="m-textarea" :auto-size="{ minRows: 3, maxRows: 6 }" /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="18"> <a-form-model-item label="分值"> <a-textarea v-model="jlkhzbxfSubForm['fz']" placeholder="请输入分值(按Enter换行)" :max-length="300" class="m-textarea" :auto-size="{ minRows: 2, maxRows: 4 }" /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="18"> <a-form-model-item label="分值上限"> <a-input v-model="jlkhzbxfSubForm['fzsx']" allow-clear placeholder='例如:"+1分"、"-1.5分"或"不设上限"' /> </a-form-model-item> </a-col> </a-row> </a-form-model> </div> </a-modal> </div> </div> </div> </template> <script> import { Message, Modal } from 'ant-design-vue' import moment from 'moment' import components from './_import-components/zk-jlkh-zbxf-import' import KhypjService from './khypj-service' import crossWindowWatcher from '@/common/services/cross-window-watcher' import SdTable from '@/common/components/sd-table.vue' export default { name: 'ZkJlkhZbxf', metaInfo: { title: '激励考核指标下发', }, components: { ...components, SdTable, }, props: { id: { type: String, default: undefined, }, }, data() { // 添加校验规则 const validateFzsx = (rule, value, callback) => { if (!value) { callback() return } // 允许"不设上限" if (value === '不设上限') { callback() return } // 验证格式: ±数字(可含小数) + 单位(非数字字符) const regex = /^[+-]\d+(\.\d+)?[^\d]+$/ if (!regex.test(value)) { callback(new Error('格式错误,请填写"不设上限"或类似"+1分"、"-1.5分"的格式')) } else { callback() } } return { loading: false, ndkhLoading: false, dialogLoading: false, readonly: true, yearOptions: this.generateYearOptions(), rules: { zbnd: [{ required: true, message: '请选择指标年度', trigger: 'blur' }], }, jlkhzbxfSubRules: { fzsx: [{ validator: validateFzsx, trigger: 'blur' }], }, // 新增搜索表单数据 searchForm: { khnd: undefined, // 考核年度 khzq: undefined, // 考核周期 }, project: { id: undefined, // 主键id zbbh: undefined, // 指标编号 cjrq: undefined, // 创建日期 zbnd: undefined, // 指标年度 khzq: undefined, // 考核周期 khdx: undefined, // 考核对象 khdxId: undefined, // 考核对象id sm: undefined, // 说明 status: undefined, // 指标状态:0暂存,1下发(不可修改) ndkhId: undefined, // 关联的年度考核id }, jlkhzbxfResult: [], jlkhzbxfSubForm: { id: undefined, // id mainId: undefined, // 主表id zblb: undefined, // 指标类别 zbnr: undefined, // 指标内容 fz: undefined, // 分值 fzsx: undefined, // 分值上限 }, ndkhResult: [], khdxList: [], selectedKhdxIds: [], // 用于多选绑定的临时ID数组 dialogVisible: false, dialogVisibleGl: false, selectedKeys: [], selectedRows: [], selectedRowKeys: [], ndkhSelectedRowKeys: [], // 年度考核表格的选中项 ndkhSelectedRows: [], // 年度考核表格选中的行数据 selectedKeysAdd: [], selectedRowKeysAdd: [], // 年度考核表格的选中项 selectedRowsAdd: [], // 年度考核表格选中的行数据 isUpdateJlkhzbxfSub: false, isXf: false, ndkhColumns: [ { title: '考核编号', dataIndex: 'khbh', scopedSlots: { customRender: '考核编号', }, width: '200px', align: 'center', }, { title: '考核年度', dataIndex: 'khnd', scopedSlots: { customRender: '指标年度', }, width: '70px', align: 'center', }, { title: '考核对象', dataIndex: 'khdx', scopedSlots: { customRender: '责任主体', }, width: '200px', align: 'center', }, { title: '考核周期', dataIndex: 'khzq', scopedSlots: { customRender: '考核周期', }, width: '100px', align: 'center', }, ], dialogResult: [], dialogColumns: [], paginationOpt: { current: 1, // 当前页码 pageSize: 10, // 当前每页大小 total: 0, // 总数 showSizeChanger: true, showQuickJumper: false, pageSizeOptions: ['10', '20', '40', '60', '80', '100'], showTotal: (total) => `共 ${total} 条`, onShowSizeChange: (current, pageSize) => { this.paginationOpt.current = 1 this.paginationOpt.pageSize = pageSize this.btnSearchBusinessList() }, onChange: (current, size) => { this.paginationOpt.current = current this.paginationOpt.pageSize = size this.btnSearchBusinessList() }, }, } }, computed: { // 动态计算列配置 jlkhzbxfColumns() { const baseColumns = [ { title: '序号', customRender: (text, record, index) => { return index + 1 }, align: 'center', width: '10%', }, { title: '指标类别', dataIndex: 'zblb', customRender: (text, record) => { // 只有显示行才渲染内容 if (record.rowSpan > 0) { return { children: text, attrs: { rowSpan: record.rowSpan }, } } return { attrs: { rowSpan: 0 } } }, align: 'center', width: '10%', }, { title: '指标内容', dataIndex: 'zbnr', scopedSlots: { customRender: '指标内容', }, align: 'center', width: '40%', }, { title: '分值', dataIndex: 'fz', scopedSlots: { customRender: '分值', }, align: 'center', width: '20%', }, { title: '分值上限', dataIndex: 'fzsx', scopedSlots: { customRender: '分值上限', }, align: 'center', width: '10%', }, ] // 非只读模式下添加操作列 if (!this.readonly) { baseColumns.push({ title: '操作', dataIndex: 'action', scopedSlots: { customRender: '操作' }, width: '10%', align: 'center', }) } return baseColumns }, }, watch: { jlkhzbxfResult: { handler(newVal) { this.calculateRowSpans(newVal) }, immediate: true, // 初始化时立即执行 deep: true, // 深度监听 }, }, created() { this.getKhdxList() this.jlkhzbxfResult = this.calculateRowSpans(this.jlkhzbxfResult) this.initJlkhzbxfInfo() }, mounted() { if (!this.$route.query.id) { this.project.zbbh = this.getZBbh() this.project.cjrq = moment(new Date()).format('YYYY-MM-DD') this.readonly = false } }, methods: { // 年度考核表格选中处理 btnSelectProjectNdkh(selectedRowKeys, selectedRows) { this.ndkhSelectedRowKeys = selectedRowKeys this.ndkhSelectedRows = [...selectedRows] }, btnSelectProjectAdd(selectedRowKeys, selectedRows) { this.selectedRowKeysAdd = selectedRowKeys this.selectedRowsAdd = [...selectedRows] }, // 重置搜索表单 reset() { this.searchForm = { khnd: undefined, // 考核年度 khzq: undefined, // 考核周期 } this.paginationOpt.current = 1 this.paginationOpt.pageSize = 10 this.btnSearchBusinessList() }, getKhzbxfInfo() { console.log('1111111----------', this.project) console.log('22222222----------', this.project.ndkhId) if (this.project.ndkhId) { KhypjService.getKhzbxfById(this.project.ndkhId).then((res) => { if (res.data.code === 200) { if (res.data.data) { this.ndkhResult.push(res.data.data) } else { this.ndkhResult = [] } } else { Message.error('获取考核指标下发信息失败!') } }) } }, ndkhBeforDelete() { const _this = this if (_this.ndkhSelectedRowKeys.length === 0) { Message.warning('请选择要删除的数据!') return } Modal.confirm({ content: '是否确认删除?', onOk() { _this.project.ndkhId = '-1' _this.saveJlkhzbxf() _this.ndkhResult = [] _this.ndkhSelectedRowKeys = [] // 清空选中状态 }, onCancel() {}, }) }, openDialogGl() { console.log('3333----------', this.ndkhResult) if (this.ndkhResult.length > 0) { Message.warning('只能关联一条年度考核!') return } this.dialogVisibleGl = true this.selectedKeysAdd = [] this.selectedRowsAdd = [] this.btnSearchBusinessList() }, handleDialogConfirm() { if (this.selectedRowsAdd.length === 0) { Message.warning('请选择一条年度考核!') return } if (this.selectedRowsAdd.length > 1) { Message.warning('只能关联一条年度考核!') return } this.project.ndkhId = this.selectedRowsAdd[0].id this.saveJlkhzbxf() this.getKhzbxfInfo() this.dialogVisibleGl = false }, btnSearchBusinessList() { this.dialogLoading = true const khzbxfSearchVo = { khnd: this.searchForm.khnd, khzq: this.searchForm.khzq, } const params = { current: this.paginationOpt.current, // 直接使用当前页码 pageSize: this.paginationOpt.pageSize, // 直接使用当前每页大小 searchVo: khzbxfSearchVo, } KhypjService.getNdkhList(params) .then((res) => { if (res.data.code === 200) { this.paginationOpt.total = res.data.data.total this.dialogResult = res.data.data.records } else { Message.error('查询失败!') } }) .catch((err) => { Message.error(err.message || err.data) this.paginationOpt.total = 0 this.dialogResult = [] }) .finally(() => { this.dialogLoading = false }) }, getKhdxList() { KhypjService.getCodeList('khdx').then((res) => { if (res.data.code === 200) { this.khdxList = res.data.data } else { Message.error('查询失败!') } }) }, // 处理考核对象选择变化 handleKhdxChange(selectedIds) { // 1. 拼接ID字符串 this.project.khdxId = selectedIds.join(';') // 2. 拼接名称字符串 const selectedNames = [] selectedIds.forEach((code) => { const item = this.khdxList.find((d) => d.code === code) if (item) { selectedNames.push(item.value) } }) this.project.khdx = selectedNames.join(';') }, btnBeforDelete() { const _this = this if (this.selectedRowKeys.length === 0) { Message.warning('请选择要删除的数据!') return } Modal.confirm({ content: '是否确认删除?', onOk() { _this.deleteJlkhzbxfSub() _this.selectedRowKeys = [] }, onCancel() {}, }) }, deleteJlkhzbxfSub() { KhypjService.removeJlkhzbxfSubByIds(this.selectedRowKeys).then((res) => { if (res.data.code === 200) { Message.success('删除成功!') this.getJlkhzbxfSubList() } else { Message.error('查询失败!') } }) }, btnSelectProject(selectedRowKeys, selectedRows) { this.selectedRowKeys = selectedRowKeys this.selectedRows = [...selectedRows] }, openDialog() { this.dialogVisible = true this.selectedKeys = [] this.selectedRows = [] this.jlkhzbxfSubForm = { id: undefined, // id mainId: this.$route.query.id, // 主表id zblb: undefined, // 指标类别 zbnr: undefined, // 指标内容 fz: undefined, // 分值 fzsx: undefined, // 分值上限 } // 新增子数据自动保存主数据 if (!this.$route.query.id) { this.saveJlkhzbxf() } }, btnOpenProjectDetails(record) { this.dialogVisible = true this.jlkhzbxfSubForm = { id: record.id, // id mainId: record.mainId, // 主表id zblb: record.zblb, // 指标类别 zbnr: record.zbnr, // 指标内容 fz: record.fz, // 分值 fzsx: record.fzsx, // 分值上限 } this.isUpdateJlkhzbxfSub = true console.log('121212------', record) console.log('33333222------', this.jlkhzbSubxfForm) }, handleCancel() { this.dialogVisible = false }, // 弹窗确认 handleConfirm() { // 添加表单校验 this.$refs.subFormRef.validate((valid) => { if (!valid) { return false } // 原有的保存逻辑... if (!this.isUpdateJlkhzbxfSub) { this.jlkhzbxfSubForm.mainId = this.$route.query.id // 保存子表数据 KhypjService.saveJlkhzbxfSub(this.jlkhzbxfSubForm).then((res) => { if (res.data.code === 200) { Message.success(`添加成功!`) this.getJlkhzbxfSubList() } else { Message.error('添加失败!') } }) } else { // 保存子表数据 KhypjService.updateJlkhzbxfSub(this.jlkhzbxfSubForm).then((res) => { if (res.data.code === 200) { Message.success(`修改成功!`) this.getJlkhzbxfSubList() } else { Message.error('修改失败!') } }) this.isUpdateJlkhzbxfSub = false } this.dialogVisible = false }) }, // handleConfirm() { // if (!this.isUpdateJlkhzbxfSub) { // this.jlkhzbxfSubForm.mainId = this.$route.query.id // // 保存子表数据 // KhypjService.saveJlkhzbxfSub(this.jlkhzbxfSubForm).then((res) => { // if (res.data.code === 200) { // Message.success(`添加成功!`) // this.getJlkhzbxfSubList() // } else { // Message.error('添加失败!') // } // }) // } else { // // 保存子表数据 // KhypjService.updateJlkhzbxfSub(this.jlkhzbxfSubForm).then((res) => { // if (res.data.code === 200) { // Message.success(`修改成功!`) // this.getJlkhzbxfSubList() // } else { // Message.error('修改失败!') // } // }) // this.isUpdateJlkhzbxfSub = false // } // this.dialogVisible = false // }, // 计算行合并 calculateRowSpans(data) { if (!data || data.length === 0) return data const categoryMap = {} // 第一步:统计每个类别的行数 data.forEach((item) => { categoryMap[item.zblb] = (categoryMap[item.zblb] || 0) + 1 }) // 第二步:设置行合并属性 let lastCategory = null return data.map((item) => { // 重置rowSpan属性 item.rowSpan = undefined if (item.zblb !== lastCategory) { lastCategory = item.zblb // 只有每个类别的第一行设置rowSpan item.rowSpan = categoryMap[item.zblb] return item } // 同类别的后续行设置rowSpan为0 item.rowSpan = 0 return item }) }, // 生成年份选项 generateYearOptions() { const currentYear = new Date().getFullYear() const years = [] // 添加年份:当前年后1年、本年、前1年、前2年 years.push(currentYear + 1) // 后1年 years.push(currentYear) // 本年 years.push(currentYear - 1) // 前1年 years.push(currentYear - 2) // 前2年 return years }, btnClose() { window.close() }, initJlkhzbxfInfo() { if (this.$route.query.id) { KhypjService.getJlkhzbxfById(this.$route.query.id).then((res) => { if (res.data.code === 200) { this.project = res.data.data this.project.cjrq = this.project.cjrq ? moment(new Date(this.project.cjrq)).format('YYYY-MM-DD') : null this.readonly = this.project.status === 1 // 初始化选中项 if (this.project.khdxId) { this.selectedKhdxIds = this.project.khdxId.split(';').filter(Boolean) } this.getJlkhzbxfSubList() this.getKhzbxfInfo() } else { Message.error('获取考核指标库信息失败!') } }) } }, save() { const _this = this this.$refs.ruleForm.validate((valid, obj) => { if (!valid) { Message.warning('请输入必填项!') return false } else { _this.saveJlkhzbxf() } }) }, xfClick() { this.readonly = true this.isXf = true this.save() KhypjService.jlkhzbzpXfStart(this.$route.query.id).then((res) => { if (res.data.code === 200) { Message.success('下发成功!') } else { Message.error('下发失败!') } }) }, // 修改 saveJlkhzbxf 方法返回 Promise saveJlkhzbxf() { const _this = this if (this.isXf) { this.project.status = 1 } else { this.project.status = 0 } // 创建数据副本,避免污染原始数据 const postData = { ...this.project } // 仅在值是字符串时才进行转换 if (postData.cjrq && typeof postData.cjrq === 'string') { postData.cjrq = this.strToTimestamp(postData.cjrq) } // 返回一个 Promise return new Promise((resolve, reject) => { // 判断是新增还是更新 const apiCall = !this.$route.query.id ? KhypjService.saveJlkhzbxf(postData) : KhypjService.updateJlkhzbxf(postData) apiCall .then((res) => { if (res.data.code === 200) { // 处理新增保存成功 if (!_this.$route.query.id) { Message.success('保存成功!') if (res.data.data) { const currentUrl = window.location.href const newUrl = currentUrl.replace('zbxf', `zbxf?id=${res.data.data}`) // 直接跳转页面,不需要等待初始化 window.location.href = newUrl } resolve() // 解析 Promise } // 处理更新保存成功 else { if (_this.project.status === 1) { Message.success('提交成功!') } else { Message.success('保存成功!') } resolve() // 解析 Promise } } else { // 处理失败情况 const errorMessage = !_this.project.id ? '保存失败!' : _this.project.status === 1 ? '提交失败!' : '保存失败!' Message.error(errorMessage) reject(new Error(res.data.message || errorMessage)) } }) .catch((error) => { // 处理 API 错误 const errorMessage = !_this.project.id ? '保存失败!' : _this.project.status === 1 ? '提交失败!' : '保存失败!' console.error('API 错误:', error) Message.error(errorMessage) reject(error) }) }) }, getJlkhzbxfSubList() { KhypjService.getJlkhzbxfSubList(this.$route.query.id).then((res) => { if (res.data.code === 200) { this.jlkhzbxfResult = res.data.data } else { Message.error('获取子表信息失败!') } }) }, // 获取唯一指标编号 getZBbh() { // 获取当前时间 const now = new Date() // 获取当前时间的年、月、日、时、分、秒、毫秒 const year = now.getFullYear() const month = String(now.getMonth() + 1).padStart(2, '0') const day = String(now.getDate()).padStart(2, '0') const hour = String(now.getHours()).padStart(2, '0') const minute = String(now.getMinutes()).padStart(2, '0') const second = String(now.getSeconds()).padStart(2, '0') const millisecond = String(now.getMilliseconds()).padStart(3, '0') // 生成唯一标识 const uniqueId = `${year}${month}${day}${hour}${minute}${second}${millisecond}` return 'JLKHZBXF-' + uniqueId }, strToTimestamp(dateStr) { const date = moment(dateStr, 'YYYY-MM-DD') return date.valueOf() }, refreshTime(item) { return moment(item).format('YYYY-MM-DD') }, }, } </script> <style lang="scss" scoped> /* 设置表格宽度 */ .ant-table { width: 90%; margin: auto; /* 居中显示 */ } .sitd-collapse-block { width: 90%; margin: auto; &::v-deep(.ant-collapse-content-box) { padding: unset !important; } } table { width: 90%; margin: auto; border-top: 1px solid #e8e8e8; margin-bottom: 16px; table-layout: fixed; tr td { border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; min-height: 100px; &:first-child { border-left: unset; } &:nth-child(2n + 1) { background: #fafafa; width: 170px; } &.upload-td { background: #fafafa; width: 170px !important; } &.upload-time-td { background: #fafafa; width: 200px !important; } &.ant-form-item-check { width: 194px !important; } .ant-form-item { margin-bottom: unset !important; padding: 5px; .ant-form-item-label { width: 170px; padding-bottom: 1px; text-align: center; background-color: #fafafa; } } &::v-deep(label) { display: block; margin: 0 auto; text-align: right; white-space: normal; line-height: 20px; padding: 0 5px; } .ant-form-item-prompt { display: block; margin: 0 auto; text-align: right; white-space: normal; line-height: 20px; padding: 0 14px 0 5px; font-size: 16px; color: rgba(0, 0, 0, 0.85); } .prompt-red { color: #f5222d !important; } .ant-form-item-radio { &::v-deep(label) { display: inline !important; } } &::v-deep(.ant-checkbox + span) { padding-right: 0 !important; } } ::v-deep(.ant-form-item-control-wrapper) { min-height: 40px; } } .ant-form-long-label { tr td { &:nth-child(2n + 1) { // width: 200px !important; } } } .ant-collapse { border-top: 1px solid #d9d9d9; border-bottom: unset; border-left: unset; border-right: unset; width: 90%; margin: auto; & > .ant-collapse-item { border-bottom: unset; /*& > .ant-collapse-content{*/ /* border-top: 1px solid #d9d9d9;*/ /* border-bottom: 1px solid #d9d9d9;*/ /* border-radius: 4px;*/ /*}*/ &::v-deep(.ant-collapse-content) { border-top: unset; } } } .textarea-wrapper { position: relative; display: block; .m-textarea { padding: 8px 12px; height: 100%; } .m-count { color: #808080; background: #fff; position: absolute; font-size: 12px; bottom: 12px; right: 12px; line-height: 16px; } } .ant-spin-loading { width: 100vw; height: 100vh; display: block; background-color: rgba(0, 0, 0, 0.5); position: fixed; top: 0; left: 0; z-index: 99; } .apply-block { display: flex; align-items: center; .dynamic-delete-button { cursor: pointer; position: relative; font-size: 24px; color: #999; transition: all 0.3s; } .dynamic-delete-button:hover { color: #777; } .dynamic-delete-button[disabled] { cursor: not-allowed; opacity: 0.5; } div { flex: 1; } } .btn-group { display: flex; align-items: center; justify-content: right; width: 90%; margin: 0 auto 20px; button { margin-left: 10px; } } .ant-form-budget-border { border-bottom: 1px solid #d9d9d9; margin-left: -1px; } .budget-box { height: 100%; overflow: hidden; display: flex; flex: 1; flex-direction: column; } .budget-record { width: 100%; height: 100%; overflow: auto; display: flex; justify-content: center; background: #fff; } .budget-record-table { width: 90%; //调整页面表格宽度 // min-width: 840px; padding: 16px; } .budget-record-table-title { margin-bottom: 20px; text-align: center; white-space: pre-wrap; } .header_sd-header_common.ant-layout-header { padding: 0 20px 0 20px; color: #fff; background-image: linear-gradient(90deg, #1890ff 0%, #0162eb 100%); height: 64px; line-height: 64px; } .header_sd-header_common { z-index: 1; } .ant-layout-header { background: #001529; } .ant-layout-header, .ant-layout-footer { flex: 0 0 auto; } header { display: block; } .ant-layout, .ant-layout * { box-sizing: border-box; } .left_sd-header_common { float: left; height: 100%; } .right_sd-header_common { float: right; height: 100%; } .logo_sd-webflow_webflow h3 { color: #fff; } .header_sd-header_common .ant-btn-link { color: #fff; } .button_sd-webflow-button_webflow { max-width: 100%; } </style> 检查代码,针对分值上限设置的校验规则并未生效,请检查代码并修改
最新发布
07-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值