当前位置: 首页 > news >正文

element-ui表格el-table的使用

先给大家展示一下效果

Table 属性 

属性名说明类型可选值默认值
data显示的数据array
heightTable 的高度, 默认为自动高度。 如果 height 为 number 类型,单位 px;如果 height 为 string 类型,则这个高度会设置为 Table 的 style.height 的值,Table 的高度会受控于外部样式。string / number
max-heightTable 的最大高度。 合法的值为数字或者单位为 px 的高度。string / number
stripe是否为斑马纹 tablebooleanfalse
border是否带有纵向边框booleanfalse
sizeTable 的尺寸stringlarge / default /small
fit列的宽度是否自撑开booleantrue
show-header是否显示表头booleantrue
highlight-current-row是否要高亮当前行booleanfalse
current-row-key当前行的 key,只写属性string / number
row-class-name行的 className 的回调方法,也可以使用字符串为所有行设置一个固定的 className。function({ row, rowIndex }) / string
row-style行的 style 的回调方法,也可以使用一个固定的 Object 为所有行设置一样的 Style。function({ row, rowIndex }) / object
cell-class-name单元格的 className 的回调方法,也可以使用字符串为所有单元格设置一个固定的 className。function({ row, column, rowIndex, columnIndex }) / string
cell-style单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有单元格设置一样的 Style。function({ row, column, rowIndex, columnIndex }) / object
header-row-class-name表头行的 className 的回调方法,也可以使用字符串为所有表头行设置一个固定的 className。function({ row, rowIndex }) / string
header-row-style表头行的 style 的回调方法,也可以使用一个固定的 Object 为所有表头行设置一样的 Style。function({ row, rowIndex }) / object
header-cell-class-name表头单元格的 className 的回调方法,也可以使用字符串为所有表头单元格设置一个固定的 className。function({ row, column, rowIndex, columnIndex }) / string
header-cell-style表头单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有表头单元格设置一样的 Style。function({ row, column, rowIndex, columnIndex }) / object
row-key行数据的 Key,用来优化 Table 的渲染; 在使用reserve-selection功能与显示树形数据时,该属性是必填的。 类型为 String 时,支持多层访问:user.info.id,但不支持 user.info[0].id,此种情况请使用 Functionfunction(row) / string
empty-text空数据时显示的文本内容, 也可以通过 #empty 设置stringNo Data
default-expand-all是否默认展开所有行,当 Table 包含展开行存在或者为树形表格时有效booleanfalse
expand-row-keys可以通过该属性设置 Table 目前的展开行,需要设置 row-key 属性才能使用,该属性为展开行的 keys 数组。array
default-sort默认的排序列的 prop 和顺序。 它的 prop 属性指定默认的排序的列,order 指定默认排序的顺序object(order: 'ascending' 'descending')如果只指定了 prop, 没有指定 order, 则默认顺序是 ascending
tooltip-effect溢出的 tooltip 的 effectstringdark / lightdark
tooltip-options 2.2.28溢出 tooltip 的选项,参见下述 tooltip 组件object请参考 tooltipobject
show-summary是否在表尾显示合计行booleanfalse
sum-text显示摘要行第一列的文本stringSum
summary-method自定义的合计计算方法function({ columns, data })
span-method合并行或列的计算方法function({ row, column, rowIndex, columnIndex })
select-on-indeterminate在多选表格中,当仅有部分行被选中时,点击表头的多选框时的行为。 若为 true,则选中所有行;若为 false,则取消选择所有行booleantrue
indent展示树形数据时,树节点的缩进number16
lazy是否懒加载子节点数据boolean
load加载子节点数据的函数,lazy 为 true 时生效function(row, treeNode, resolve)
tree-props渲染嵌套数据的配置选项object{ hasChildren: 'hasChildren', children: 'children' }
table-layout设置表格单元、行和列的布局方式stringfixed / autofixed
scrollbar-always-on总是显示滚动条booleanfalse
flexible 2.2.1确保主轴的最小尺寸booleanfalse

Table 事件 

事件名说明回调参数
select当用户手动勾选数据行的 Checkbox 时触发的事件selection, row
select-all当用户手动勾选全选 Checkbox 时触发的事件selection
selection-change当选择项发生变化时会触发该事件selection
cell-mouse-enter当单元格 hover 进入时会触发该事件row, column, cell, event
cell-mouse-leave当单元格 hover 退出时会触发该事件row, column, cell, event
cell-click当某个单元格被点击时会触发该事件row, column, cell, event
cell-dblclick当某个单元格被双击击时会触发该事件row, column, cell, event
cell-contextmenu当某个单元格被鼠标右键点击时会触发该事件row, column, cell, event
row-click当某一行被点击时会触发该事件row, column, event
row-contextmenu当某一行被鼠标右键点击时会触发该事件row, column, event
row-dblclick当某一行被双击时会触发该事件row, column, event
header-click当某一列的表头被点击时会触发该事件column, event
header-contextmenu当某一列的表头被鼠标右键点击时触发该事件column, event
sort-change当表格的排序条件发生变化的时候会触发该事件{ column, prop, order }
filter-changecolumn 的 key, 如果需要使用 filter-change 事件,则需要此属性标识是哪个 column 的筛选条件filters
current-change当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性currentRow, oldCurrentRow
header-dragend当拖动表头改变了列的宽度的时候会触发该事件newWidth, oldWidth, column, event
expand-change当用户对某一行展开或者关闭的时候会触发该事件(展开行时,回调的第二个参数为 expandedRows;树形表格时第二参数为 expanded)row, (expandedRows | expanded)

Table 方法 

方法名说明参数
clearSelection用于多选表格,清空用户的选择
getSelectionRows返回当前选中的行
toggleRowSelection用于多选表格,切换某一行的选中状态, 如果使用了第二个参数,则可直接设置这一行选中与否row, selected
toggleAllSelection用于多选表格,切换全选和全不选
toggleRowExpansion用于可扩展的表格或树表格,如果某行被扩展,则切换。 使用第二个参数,您可以直接设置该行应该被扩展或折叠。row, expanded
setCurrentRow用于单选表格,设定某一行为选中行, 如果调用时不加参数,则会取消目前高亮行的选中状态。row
clearSort用于清空排序条件,数据会恢复成未排序的状态
clearFilter传入由columnKey 组成的数组以清除指定列的过滤条件。 如果没有参数,清除所有过滤器columnKeys
doLayout对 Table 进行重新布局。 当表格可见性变化时,您可能需要调用此方法以获得正确的布局
sort手动排序表格。 参数 prop 属性指定排序列,order 指定排序顺序。prop: string, order: string
scrollTo滚动到一组特定坐标(options: ScrollToOptions | number, yCoord?: number)
setScrollTop设置垂直滚动位置top
setScrollLeft设置水平滚动位置left

Table 插槽 

插槽名说明子标签
-自定义默认内容Table-column
append插入至表格最后一行之后的内容, 如果需要对表格的内容进行无限滚动操作,可能需要用到这个 slot。 若表格有合计行,该 slot 会位于合计行之上。
empty当数据为空时自定义的内容

Table-column 属性 

属性名说明类型可选值默认值
type对应列的类型。 如果设置了selection则显示多选框; 如果设置了 index 则显示该行的索引(从 1 开始计算); 如果设置了 expand 则显示为一个可展开的按钮stringselection / index / expand
index如果设置了 type=index,可以通过传递 index 属性来自定义索引number / function(index)
label显示的标题string
column-keycolumn 的 key, column 的 key, 如果需要使用 filter-change 事件,则需要此属性标识是哪个 column 的筛选条件string
prop字段名称 对应列内容的字段名, 也可以使用 property属性string
width对应列的宽度string / number
min-width对应列的最小宽度, 对应列的最小宽度, 与 width 的区别是 width 是固定的,min-width 会把剩余宽度按比例分配给设置了 min-width 的列string / number
fixed列是否固定在左侧或者右侧。 true 表示固定在左侧string / booleantrue / 'left' / 'right'
render-header列标题 Label 区域渲染使用的 Functionfunction({ column, $index })
sortable对应列是否可以排序, 如果设置为 'custom',则代表用户希望远程排序,需要监听 Table 的 sort-change 事件boolean / stringcustomfalse
sort-method指定数据按照哪个属性进行排序,仅当sortable设置为true的时候有效。 应该如同 Array.sort 那样返回一个 Numberfunction(a, b)
sort-by指定数据按照哪个属性进行排序,仅当 sortable 设置为 true 且没有设置 sort-method 的时候有效。 如果 sort-by 为数组,则先按照第 1 个属性排序,如果第 1 个相等,再按照第 2 个排序,以此类推function(row, index) / string / array
sort-orders数据在排序时所使用排序策略的轮转顺序,仅当 sortable 为 true 时有效。 需传入一个数组,随着用户点击表头,该列依次按照数组中元素的顺序进行排序array数组中的元素需为以下三者之一:ascending 表示升序,descending 表示降序,null 表示还原为原始顺序['ascending', 'descending', null]
resizable对应列是否可以通过拖动改变宽度(需要在 el-table 上设置 border 属性为真)booleantrue
formatter用来格式化内容function(row, column, cellValue, index)
show-overflow-tooltip当内容过长被隐藏时显示 tooltipboolean \object 2.2.28参考表格的 tooltip-options
align对齐方式stringleft / center / rightleft
header-align表头对齐方式, 若不设置该项,则使用表格的对齐方式stringleft / center / right
class-name列的 classNamestring
label-class-name当前列标题的自定义类名string
selectable仅对 type=selection 的列有效,类型为 Function,Function 的返回值用来决定这一行的 CheckBox 是否可以勾选function(row, index)
reserve-selection数据刷新后是否保留选项,仅对 type=selection 的列有效, 请注意, 需指定 row-key 来让这个功能生效。booleanfalse
filters数据过滤的选项, 数组格式,数组中的元素需要有 text 和 value 属性。 数组中的每个元素都需要有 text 和 value 属性。Array<{text: string, value: string}>
filter-placement过滤弹出框的定位string与 Tooltip 的 placement 属性相同
filter-multiple数据过滤的选项是否多选booleantrue
filter-method数据过滤使用的方法, 如果是多选的筛选项,对每一条数据会执行多次,任意一次返回 true 就会显示。function(value, row, column)
filtered-value选中的数据过滤项,如果需要自定义表头过滤的渲染方式,可能会需要此属性。array

Table-column 插槽 

插槽名说明
自定义列的内容 作用域参数为 { row, column, $index }
header自定义表头的内容, 作用域参数为 { column, $index }

表格部分代码

  <!--表格数据展示 start--><el-table :data="dataList.list" style="width:1300px;"><el-table-column prop="bookImg" label="图片" width="150" align="center"><template #default="scope"><img :src="scope.row.bookImg" style="height:60px"/></template></el-table-column><el-table-column  prop="bookTypeId" label="类型" width="100px"><template #default="scope"><span v-for="item in typeList.list" :key="item.bookTypeId">{{ scope.row.bookTypeId == item.bookTypeId ? item.bookTypeName : '' }}</span></template></el-table-column><el-table-column  prop="bookName" label="名称" width="100" align="center"><template #default="scope"><div style="color: #6ca7ef;" v-html="scope.row.bookName"></div></template></el-table-column><el-table-column prop="bookPrice" label="价格" width="100" align="center"></el-table-column><el-table-column show-overflow-tooltip prop="bookWriter" label="作者" width="60" align="center"></el-table-column><el-table-column show-overflow-tooltip prop="bookPublishHouse" label="出版社" width="80" align="center"></el-table-column><el-table-column prop="bookPublishTime" label="出版时间" width="100" align="center"></el-table-column><el-table-column show-overflow-tooltip prop="bookISBN" label="ISBN号" width="100"align="center"></el-table-column><el-table-column prop="bookStock" label="库存" width="100" align="center"></el-table-column><el-table-column prop="bookSalvesVolume" label="销量" width="100" align="center"></el-table-column><el-table-column show-overflow-tooltip prop="bookCatalog" label="目录" width="60" align="center"></el-table-column><el-table-column show-overflow-tooltip prop="bookDesc" label="简介" width="60" align="center"></el-table-column><el-table-column label="操作" width="200" align="center"><template #default="scope"><el-button round size="small" type="primary"@click="handleEdit(scope.$index, scope.row)">修改</el-button><el-button round size="small" type="danger"@click="handleDelete(scope.$index, scope.row)">删除</el-button></template></el-table-column></el-table><!--表格数据展示 end-->

全部代码 

<template><div class="data-container"><!--添加 start--><div class="data-header"><!--优化:@keyup.enter="searchHandle"回车时触发searchHandle事件--><el-input class="input" @keyup.enter="searchHandle" v-model="searchInfo" size="large"placeholder="请输入名称/作者/出版社"></el-input><el-button @click="searchHandle" class="button" size="large" type="primary" plain>搜索</el-button><el-button @click="addHander" style="margin-left: 40px;" size="large" class="button" type="primary"><el-icon><DocumentAdd/></el-icon>&nbsp;添加</el-button></div><!--添加 end--><div class="data-table"><!--表格数据展示 start--><el-table :data="dataList.list" style="width:1300px;"><el-table-column prop="bookImg" label="图片" width="150" align="center"><template #default="scope"><img :src="scope.row.bookImg" style="height:60px"/></template></el-table-column><el-table-column  prop="bookTypeId" label="类型" width="100px"><template #default="scope"><span v-for="item in typeList.list" :key="item.bookTypeId">{{ scope.row.bookTypeId == item.bookTypeId ? item.bookTypeName : '' }}</span></template></el-table-column><el-table-column  prop="bookName" label="名称" width="100" align="center"><template #default="scope"><div style="color: #6ca7ef;" v-html="scope.row.bookName"></div></template></el-table-column><el-table-column prop="bookPrice" label="价格" width="100" align="center"></el-table-column><el-table-column show-overflow-tooltip prop="bookWriter" label="作者" width="60" align="center"></el-table-column><el-table-column show-overflow-tooltip prop="bookPublishHouse" label="出版社" width="80" align="center"></el-table-column><el-table-column prop="bookPublishTime" label="出版时间" width="100" align="center"></el-table-column><el-table-column show-overflow-tooltip prop="bookISBN" label="ISBN号" width="100"align="center"></el-table-column><el-table-column prop="bookStock" label="库存" width="100" align="center"></el-table-column><el-table-column prop="bookSalvesVolume" label="销量" width="100" align="center"></el-table-column><el-table-column show-overflow-tooltip prop="bookCatalog" label="目录" width="60" align="center"></el-table-column><el-table-column show-overflow-tooltip prop="bookDesc" label="简介" width="60" align="center"></el-table-column><el-table-column label="操作" width="200" align="center"><template #default="scope"><el-button round size="small" type="primary"@click="handleEdit(scope.$index, scope.row)">修改</el-button><el-button round size="small" type="danger"@click="handleDelete(scope.$index, scope.row)">删除</el-button></template></el-table-column></el-table><!--表格数据展示 end--><!--分页 start--><div class="page"><el-pagination @current-change="currentChangeHaddler" background layout="prev,pager,next,jumper"default-page-size="defaultPageSize" :total="totalData"></el-pagination></div><!--分页 end--><!--添加对话框 start--><el-dialog draggable destroy-on-close v-model="dialogAddVisible" title="添加" width="70%" center><el-form :inline="true" :model="addFormInfo" status-icon label-width="120px"><el-form-item label="图片"><el-upload list-type="picture-card" action="http://localhost:8040/file/localhost/upload":on-success="onUploadAddSuccess" :on-remove="handleAddRemove"><el-icon><Plus/></el-icon></el-upload></el-form-item><el-form-item label="类型"><el-select v-model="addFormInfo.bookTypeId" class="m-2" placeholder="请选择书籍类型" size="large"><el-option v-for="item in typeList.list" :key="item.bookTypeId" :label="item.bookTypeName":value="item.bookTypeId"/></el-select></el-form-item><el-form-item label="名称"><el-input v-model="addFormInfo.bookName"></el-input></el-form-item><el-form-item label="价格"><el-input v-model="addFormInfo.bookPrice"></el-input></el-form-item><el-form-item label="作者"><el-input v-model="addFormInfo.bookWriter"></el-input></el-form-item><el-form-item label="出版社"><el-input v-model="addFormInfo.bookPublishHouse"></el-input></el-form-item><el-form-item label="出版时间"><el-input v-model="addFormInfo.bookPublishTime"></el-input></el-form-item><el-form-item label="ISBN号"><el-input v-model="addFormInfo.bookISBN"></el-input></el-form-item><el-form-item label="库存"><el-input v-model="addFormInfo.bookStock"></el-input></el-form-item><el-form-item label="销量"><el-input v-model="addFormInfo.bookSalvesVolume"></el-input></el-form-item><el-form-item label="目录"><el-input style="width: 800px" :rows="6" type="textarea" v-model="addFormInfo.bookCatalog"></el-input></el-form-item><el-form-item label="简介"><el-input style="width: 800px" :rows="6" type="textarea" v-model="addFormInfo.bookDesc"></el-input></el-form-item></el-form><template #footer><span class="dialog-footer"><el-button @click="dialogAddVisible = false">取消</el-button><el-button type="primary" @click="sureHandler">确定</el-button></span></template></el-dialog><!--添加对话框 end--><!--编辑对话框 start--><el-dialog draggable destroy-on-close v-model="dialogEditorVisible" title="修改" width="70%" center><el-form :inline="true" :model="editorFormInfo" label-width="120px"><el-form-item label="图片"><el-upload list-type="picture-card" action="http://localhost:8040/file/localhost/upload":show-file-list="false":on-success="onUploadEditorSuccess"><img v-if="fileEditorPath" :src="fileEditorPath" class="avatar" style="height:60px"/><el-icon v-else class="avatar-uploader-icon"><Plus/></el-icon></el-upload></el-form-item><el-form-item label="类型"><el-select v-model="editorFormInfo.bookTypeId" class="m-2" placeholder="Select" size="large"><el-option v-for="item in typeList.list" :key="item.bookTypeId" :label="item.bookTypeName":value="item.bookTypeId"/></el-select></el-form-item><el-form-item label="名称"><el-input v-model="editorFormInfo.bookName"></el-input></el-form-item><el-form-item label="价格"><el-input v-model="editorFormInfo.bookPrice"></el-input></el-form-item><el-form-item label="作者"><el-input v-model="editorFormInfo.bookWriter"></el-input></el-form-item><el-form-item label="出版社"><el-input v-model="editorFormInfo.bookPublishHouse"></el-input></el-form-item><el-form-item label="出版时间"><el-input v-model="editorFormInfo.bookPublishTime"></el-input></el-form-item><el-form-item label="ISBN号"><el-input v-model="editorFormInfo.bookISBN"></el-input></el-form-item><el-form-item label="库存"><el-input v-model="editorFormInfo.bookStock"></el-input></el-form-item><el-form-item label="销量"><el-input v-model="editorFormInfo.bookSalvesVolume"></el-input></el-form-item><el-form-item label="目录"><el-input style="width: 800px" :rows="6" type="textarea" v-model="editorFormInfo.bookCatalog"></el-input></el-form-item><el-form-item label="简介"><el-input style="width: 800px" :rows="6" type="textarea" v-model="editorFormInfo.bookDesc"></el-input></el-form-item></el-form><template #footer><span class="dialog-footer"><el-button @click="dialogEditorVisible = false">取消</el-button><el-button type="primary" @click="sureEditorHandler">确定</el-button></span></template></el-dialog><!--编辑对话框 end--></div></div>
</template>
<script setup>
import axios from "@/utils/request.js"
import {onMounted, reactive, ref} from "vue";
//初始化类型列表
const typeList = reactive({list: []
})
//数据列表
const dataList = reactive({list: []
})
//数据总条数
const totalData = ref(0)
//当前页
const currentPage = ref(1)
//初始化分页显示条数
const defaultPageSize = ref(5)
//搜索初始化状态
const searchInfo = ref("")
//添加-上传后图片地址
const fileAddPath = ref(0)
//编辑-上传后图片地址
const fileEditorPath = ref(0)
//添加添加对话框控制器
const dialogAddVisible = ref(false)
//初始化添加对话框状态
const addFormInfo = reactive({bookImg: "",bookName: "",bookPrice: "",bookWriter: "",bookPublishHouse: "",bookPublishTime: "",bookISBN: "",bookStock: "",bookSalvesVolume: "",bookCatalog: "",bookDesc: "",bookTypeId: "",})
//编辑对话框控制器
const dialogEditorVisible = ref(false)
//初始化编辑对话框状态
const editorFormInfo = reactive({bookId: "",bookImg: "",bookName: "",bookPrice: "",bookWriter: "",bookPublishHouse: "",bookPublishTime: "",bookISBN: "",bookStock: "",bookSalvesVolume: "",bookCatalog: "",bookDesc: "",bookTypeId: "",})
/*** 网路请求:分页查询*  */
const http = (search, page, size) => {axios.get('/book/book/search', {params: {search,page,size}}).then(res => {if (res.data.code == 200) {dataList.list = res.data.data.recordstotalData.value = res.data.data.total} else {ElMessage.error(res.data.message)}})
}
onMounted(() => {http(null, 1, 5)axios.get('/book/bookType/findAll').then(res => {typeList.list = res.data.dataconsole.log(typeList.list[0])})
})
/*** 添加时文件上传成功时的钩子*/
const onUploadAddSuccess = (response, uploadFile) => {console.log(response)//http://192.168.66.101/group1/M00/00/00/wKhCZWQZ2Y6AfdIDAADHg7AcneY285.jpgconsole.log(uploadFile.raw.name)//springboot.jpgfileAddPath.value = response.data
}
/*** 编辑时文件上传成功时的钩子*/
const onUploadEditorSuccess = (response, uploadFile) => {//console.log(response.data)//http://192.168.66.101/group1/M00/00/00/wKhCZWQZ2Y6AfdIDAADHg7AcneY285.jpg//console.log(uploadFile.raw.name)//springboot.jpgfileEditorPath.value = response.data
}
/*** 添加时文件移除时的操作*/
const handleAddRemove = (file, files) => {//console.log(file.url)//file.url---blob:http://127.0.0.1:81/87591d3e-43e3-4032-bd61-c26867d32f0e//console.log(fileAddPath.value)axios.post('/book/book/delete', {params: {filePath: fileAddPath.value}}).then(res => {if (res.data.code == 200) {fileAddPath.value = nullElMessage.success("上传时移除图片成功")}})
}
/*** 分页*/
const currentChangeHaddler = (val) => {http(searchInfo.value, val, 5)currentPage.value = val
}
/*** 搜索按钮*/
const searchHandle = () => {http(searchInfo.value, 1, 5)
}
/*** 添加对话框弹出事件*/
const addHander = () => {dialogAddVisible.value = true
}
/*** 添加对话框 确定事件*/
const sureHandler = () => {axios.post('/book/book/add', {bookName: addFormInfo.bookName,bookPrice: addFormInfo.bookPrice,bookImg: fileAddPath.value,bookWriter: addFormInfo.bookWriter,bookPublishHouse: addFormInfo.bookPublishHouse,bookPublishTime: addFormInfo.bookPublishTime,bookISBN: addFormInfo.bookISBN,bookStock: addFormInfo.bookStock,bookSalvesVolume: addFormInfo.bookSalvesVolume,bookCatalog: addFormInfo.bookCatalog,bookDesc: addFormInfo.bookDesc,bookTypeId: addFormInfo.bookTypeId,}).then(res => {if (res.data.code == 200) {dialogAddVisible.value = false//刷新页面http(null, currentPage.value, 5)fileAddPath.value = null} else {ElMessage.error(res.data.message)}})
}
/*** 编辑对话框 弹出事件*  */
const handleEdit = (index, row) => {dialogEditorVisible.value = trueaxios.get('/book/book/findById', {params: {bookId: row.bookId}}).then(res => {if (res.data.code == 200) {editorFormInfo.bookId = res.data.data.bookId;fileEditorPath.value = res.data.data.bookImg;editorFormInfo.bookPrice = res.data.data.bookPrice;editorFormInfo.bookWriter = res.data.data.bookWriter;editorFormInfo.bookPublishHouse = res.data.data.bookPublishHouse;editorFormInfo.bookPublishTime = res.data.data.bookPublishTime;editorFormInfo.bookISBN = res.data.data.bookISBN;editorFormInfo.bookStock = res.data.data.bookStock;editorFormInfo.bookSalvesVolume = res.data.data.bookSalvesVolume;editorFormInfo.bookCatalog = res.data.data.bookCatalog;editorFormInfo.bookDesc = res.data.data.bookDesc;editorFormInfo.bookTypeId = res.data.data.bookTypeId;} else {ElMessage.error(res.data.data.message)}})}
/*** 编辑对话框 确定事件*/
const sureEditorHandler = () => {axios.post('/book/book/update', {bookId: editorFormInfo.bookId,bookName: editorFormInfo.bookName,bookPrice: editorFormInfo.bookPrice,bookImg: fileEditorPath.value,bookWriter: editorFormInfo.bookWriter,bookPublishHouse: editorFormInfo.bookPublishHouse,bookPublishTime: editorFormInfo.bookPublishTime,bookISBN: editorFormInfo.bookISBN,bookStock: editorFormInfo.bookStock,bookSalvesVolume: editorFormInfo.bookSalvesVolume,bookCatalog: editorFormInfo.bookCatalog,bookDesc: editorFormInfo.bookDesc,bookTypeId: editorFormInfo.bookTypeId,}).then(res => {if (res.data.code == 200) {dialogEditorVisible.value = falsehttp(null, currentPage.value, 5)} else {ElMessage.error(res.data.message)}})
}/**删除 */
const handleDelete = (index, row) => {ElMessageBox.confirm('确定删除么','删除',{confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning',}).then(() => {//确认删除axios.delete("/book/book/delete", {params: {bookId: row.bookId}}).then(res => {if (res.data.code == 200) {ElMessage({type: 'success',message: "删除成功!!!",})//刷新http(null, currentPage.value, 5)} else {ElMessage({type: 'error',message: res.data.message,})}})}).catch(error => {ElMessage({type: 'info',message: "取消删除",})})}
</script>
<style scoped>
.el-carousel__item:nth-child(2n + 1) {background-color: #d3dce6;
}.data-header {background: linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);background: -o-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);background: -ms-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);background: -moz-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);background: -webkit-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);padding: 20px;width: 100%;background-attachment: #fff;box-sizing: border-box;
}.data-header span {color: #6ca7ef;font-weight: 700;
}.data-header .input {width: 300px;
}.data-table {background: linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);background: -o-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);background: -ms-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);background: -moz-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);background: -webkit-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);padding: 20px;display: flex;width: 100%;height: 700px;
}.page {/**分页模块*//**固定定位 元素的位置相对于浏览器窗口是固定位置。即使窗口是滚动的它也不会移动 */position: fixed;right: 10px;bottom: 100px;
}
</style>

相关文章:

element-ui表格el-table的使用

先给大家展示一下效果 Table 属性 属性名说明类型可选值默认值data显示的数据array——heightTable 的高度&#xff0c; 默认为自动高度。 如果 height 为 number 类型&#xff0c;单位 px&#xff1b;如果 height 为 string 类型&#xff0c;则这个高度会设置为 Table 的 sty…...

Backtrader官方中文文档:第八章Indicators指标

本文档参考backtrader官方文档,是官方文档的完整中文翻译,可作为backtrader中文教程、backtrader中文参考手册、backtrader中文开发手册、backtrader入门资料使用。 Indicators指标章节目录 指标(Indicator)指标的使用__init__ 对比 next指标在`__init__`阶段的执行过程指标在…...

CAP原则

CAP原则又称CAP定理&#xff0c;指的是在一个分布式系统中&#xff0c;存在Consistency&#xff08;一致性&#xff09;、Availability&#xff08;可用性&#xff09;、Partition tolerance&#xff08;分区容错性&#xff09;&#xff0c;三者不可同时保证&#xff0c;最多只…...

【PowerQuery】M语言的使用产品和使用场景

当然PowerQuery的M语言应用场景不只是引用在PowerBI和Excel中,它具有广泛的应用场景。目前我们可以在以下产品的使用场景中应用到M语言。 Excel PowerQuery应用Excel通过M语言可以实现整体数据的清洗和重构。  PowerBI 的PowerQuery应用 PowerBI也是通过M语言来实现数据…...

【Linux】遇事不决,可先点灯,LED驱动的进化之路---1

【Linux】遇事不决&#xff0c;可先点灯&#xff0c;LED驱动的进化之路---1 前言&#xff1a; 一、最简单的LED驱动程序 1.1 字符设备驱动程序框架 1.2 程序实战 1.2.1 驱动程序&#xff08;led_drive_simple.c&#xff09; 1.2.2 应用程序&#xff08;led_test_simple.c…...

hive任务reduce步骤卡在99%原因及解决

我们在写sql的时候经常发现读取数据不多&#xff0c;但是代码运行时间异常长的情况&#xff0c;这通常是发生了数据倾斜现象。数据倾斜现象本质上是因为数据中的key分布不均匀&#xff0c;大量的数据集中到了一台或者几台机器上计算&#xff0c;这些数据的计算速度远远低于平均…...

C++11 -- lambda表达式

文章目录 lamaba表达式的引入lambda表达式语法lamabda达式各部分说明捕获列表说明 lamaba表达式底层原理探索 lamaba表达式的引入 在C11之前,如果我们想对自定义类型Goods排序,可以根据姓名,价格,学号按照从大到小或者从小到大的方式排序,可是,这样我们要写额外写6个相关的仿函…...

【开源项目】银行查询服务的设计和实现

银行查询服务的设计和实现 项目地址github&#xff1a;https://github.com/xl-echo/bankInquiryService项目地址gitee&#xff1a;https://gitee.com/xl-echo/bank-inquiry-service 银行查询服务的设计初衷是&#xff1a;为提供更加便利的查询服务&#xff0c;我们在分布式系…...

Linux服务器禁止密码登录,设置秘钥登录

生成SSH密钥 (客户机端) 执行ssh-keygen -t rsa命令创建RSA密钥对&#xff0c;执行结果如下(键入3次回车)&#xff1a; [rootnode01 .ssh]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): [回车] En…...

第十八章 开发Productions - ObjectScript Productions - 通过引用或作为输出传递值

文章目录 第十八章 开发Productions - ObjectScript Productions - 通过引用或作为输出传递值典型的回调方法典型的辅助方法 第十八章 开发Productions - ObjectScript Productions - 通过引用或作为输出传递值典型的回调方法典型的辅助方法 第十八章 开发Productions - Object…...

【云原生|Kubernetes】07-Pod健康检查和服务可用性检查

【云原生|Kubernetes】07-Pod健康检查和服务可用性检查 文章目录 【云原生|Kubernetes】07-Pod健康检查和服务可用性检查前言Pod探针Liveness(Pod存活探针)Readiness(Pod服务就绪探针)Startup(启动探针) 定义Liveness存活探针EXec探针HTTP探针TCP探针gRPC探针使用命名端口 定义…...

jeecgboot使用的问题记录

最近使用jeecgboot些项目&#xff0c;总结使用过程中的问题。 form表单 1.下拉框 — 使用字典方式 {label: 工单状态,field: orderStatus,component: JDictSelectTag,componentProps: {dictCode: emergency_order_status,}, } 2.下拉框—使用接口获取数据方式 配置项 { l…...

【C++】数组 - 一维数组,二维数组

文章目录 1. 一维数组1.1 一维数组定义方式1.2 数组名1.3 冒泡排序 2. 二维数组2.1 二维数组定义方式2.2 数组名 所谓数组&#xff0c;就是一个集合&#xff0c;里边存放了相同类型的数据元素。 特点1&#xff1a;数组中的每个数据元素都是相同的数据类型 特点2&#xff1a;数…...

前端:使用rollup的简单记录

目录 rollup安装 简单使用 1、命令行打包 2、配置文件打包 问题 1、报错提示&#xff1a;(node:23744) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.(Use node --trace-warnings ... to sho…...

基于flask的web应用开发——接受post请求

目录 0. 前言1. 了解post方法2. 在flask中实现3. 具体讲解 0. 前言 操作系统&#xff1a;Windows10 家庭版 开发环境&#xff1a;Pycahrm Comunity 2022.3 Python解释器版本&#xff1a;Python3.8 第三方库&#xff1a;flask 1. 了解post方法 POST是HTTP协议定义的一种请…...

Linux源码包的安装与升级

文章目录 Linux源码包的安装与升级什么是源代码、编译器与可执行文件什么是函数库什么是make与configure什么是Tarball的软件如何安装与升级软件 Linux源码包的安装与升级 如果你想在自己的Linux服务器上运行网站&#xff0c;就需要安装一个Web服务器软件&#xff0c;否则无法…...

电子合同签署协议开源版系统开发

电子合同签署协议开源版系统开发 H5TP6mysqlphp 源码开源不加密 以下是电子合同系统可能包含的功能列表&#xff1a; 用户注册和登录&#xff1a;用户可以注册并登录系统&#xff0c;以便创建、签署和管理合同。合同创建&#xff1a;用户可以创建新合同&#xff0c;包括填写合…...

【每日一题Day221】LC2455可被三整除的偶数的平均值 | 模拟

可被三整除的偶数的平均值【LC2455】 给你一个由正整数组成的整数数组 nums &#xff0c;返回其中可被 3 整除的所有偶数的平均值。 注意&#xff1a;n 个元素的平均值等于 n 个元素 求和 再除以 n &#xff0c;结果 向下取整 到最接近的整数。 思路 遍历数组&#xff0c;如果某…...

NCI架构-1

1、NFCC和DH通过物理连线相连&#xff0c;物理连线对应为Transport Layer&#xff08;传输层&#xff09;&#xff0c;支持SPI、I2C、UART、USB等&#xff1b; 2、DH中所有和NFC相关的应用程序都可视为DH-NFCEE(EE:Execution Enviroment)&#xff0c;图左的NFCEE模块可运行一些…...

lambda使用场景

字符串转换为数组: [rootmaster pyflink]# cat t300.py f(lambda i: (i, 1)) x11 22 33 print(f(x)) [rootmaster pyflink]# python t300.py (11 22 33, 1) [rootmaster pyflink]# cat t301.py f(lambda i: i[0]) x(aa,11, 22, 33) print(f(x)) [rootmaster pyflink]# pyth…...

Python模拟Postgres数据库连接

psycopg2 psycopg2是一个Python库&#xff0c;用于在Python应用程序中连接和操作PostgreSQL数据库。它是PostgreSQL数据库的官方驱动程序之一&#xff0c;具有广泛的应用和支持。 以下是一些psycopg2的特点和功能&#xff1a; 连接到PostgreSQL数据库&#xff1a;psycopg2提供…...

(转载)基于粒子群算法的多目标搜索算法(matlab实现)

1 理论基础 在实际工程优化问题中&#xff0c;多数问题是多目标优化问题。相对于单目标优化问题&#xff0c;多目标优化问题的显著特点是优化各个目标使其同时达到综合的最优值。然而&#xff0c;由于多目标优化问题的各个目标之间往往是相互冲突的&#xff0c;在满足其中一个…...

皮卡丘存储型xss、DOM型xss、DOM型xss-x

1.存储型xss 看题目&#xff0c;我们先留言&#xff0c;看它的过滤机制 发现可以永久存储并输出我们的留言 之后插入payload: <script>alert(xss)</script> 成功弹窗&#xff01; 2.DOM型xss Dom型xss&#xff0c;简单的说&#xff0c;就是向文档对象传入xss参…...

ThreadLocal源码

介绍 ThreadLocal是一个线程的本地变量&#xff0c;也就意味着这个变量是线程独有的&#xff0c;是不能与其他线程共享的。这样就可以避免资源竞争带来的多线程的问题。 但是&#xff0c;这种解决多线程安全问题的方式和加锁方式&#xff08;synchronized、Lock) 是有本质的区…...

Hive学习---3、DML(Data Manipulation Language)数据操作、查询

1、DML&#xff08;Data Manipulation Language&#xff09;数据操作 1.1 Load load语句可将文件导入到Hive表中 1、语法 load data [local] inpath filepath [overwrite] into table tablename [partition(partcol1val1,partcol2val2...)]2、关键字说明 &#xff08;1&…...

chatgpt赋能python:Python去除重复元素的几种方法

Python去除重复元素的几种方法 在Python编程中&#xff0c;去除列表、集合、字典等数据结构中的重复元素是一个常见的操作。本文将介绍Python中去除重复元素的几种方法&#xff0c;并分析它们的优缺点。 方法一&#xff1a;使用set去重 Set是Python中的一种集合类数据结构&a…...

2年测试我迷茫了,软件测试大佬都会哪些技能?我的测试进阶之路...

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 Python自动化测试&…...

21天学会C++:Day7----auto关键字

CSDN的uu们&#xff0c;大家好。这里是C入门的第七讲。 座右铭&#xff1a;前路坎坷&#xff0c;披荆斩棘&#xff0c;扶摇直上。 博客主页&#xff1a; 姬如祎 收录专栏&#xff1a;C专题 目录 1. 知识引入 2. auto的使用 2.1 auto与指针和引用结合起来使用 2.2 在同一…...

Vue3 + ElementPlus实战学习——模拟简单的联系人列表管理后台

文章目录 &#x1f4cb;前言&#x1f3af;demo 介绍&#x1f3af;功能分析&#x1f9e9;数据的展示与分页功能&#x1f9e9;编辑功能&#x1f9e9;删除功能 &#x1f3af;部分代码分析&#x1f3af;完整代码&#x1f4dd;最后 &#x1f4cb;前言 这篇文章介绍一下基于 Vue3 和…...

【Go语言从入门到实战】并发篇

Go语言从入门到实战 — 并发篇 协程 Thread vs Groutine 相比之下&#xff0c;协程的栈大小就小很多了&#xff0c;创建起来也会更快&#xff0c;也更节省系统资源。 一个 goroutine 的栈&#xff0c;和操作系统线程一样&#xff0c;会保存其活跃或挂起的函数调用的本地变量…...