代码写的有点low,但能用。
使用场景
1.Status:后台传的数字转化成其他内容,类似过滤器
2.操作中点击修改按钮,表格span变成input,不过得这样加属性,类似双向绑定的原理,能立刻变
this.AbnormaOrderList = list.map(item => {
this.$set(item, ‘AbnormaOrderBoolean’, true)
return item
3.一个表格单元格有几行排齐的内容
4.再2的操作基础上,有时要按钮名字变,修改变成确定后,导致每行都变,也封装了只变操作那行的名字,不过会麻烦点,就是btn写成[[]]的形式,具体不说了
template:
<ElTables
v-loading=“listLoading”
:columns=“see_columns”
:data=“seeList”
@handleBtnClick=“handleBtnClick”
/>
data:
see_columns: [
{ name: ‘序号’, type: ‘index’, tooltip: true, width: ‘50’ },
{ name: ‘产品名称’, desc: ‘ItemName’, tooltip: true },
{ name: ‘单价’, desc: ‘OrderPrice’, tooltip: true },
{ name: ‘批次信息’, first: ‘LotCode’, second: ‘ManufactureDt’, third: ‘DisabledDatetime’, fourth: ‘ApprovalNum’, fifth: ‘SterilizationLotMaster’, sixth: ‘Serial’, many: true, tooltip: true },
{ name: ‘是否扫码’, desc: ‘barcodeflag’, tooltip: true, show: true, status: [‘主条码(否)批次条码(否)’, ‘主条码(是)批次条码(否)’, ‘主条码(是)批次条码(是)’] },
{ name: ‘操作’, desc: ‘operate’, width: ‘240’,
btns: [
{ name: ‘编辑’, btnType: ‘success’, clickType: ‘editProductLineUser’ },
{ name: ‘修改’, btnType: ‘success’, clickType: ‘addProductLineUser’ },
{ name: ‘删除’, btnType: ‘success’, clickType: ‘deleteProductLineUser’ }
]
}
],
script
import ElTable from '@/components/table’导入封装的组件
按钮事件
/** 表格内点击方法 */
handleBtnClick(scope) {
if (scope.type === ‘addProductLineUser’) {
} else if (scope.type === ‘editProductLineUser’) {
} else if (scope.type === ‘deleteProductLineUser’) {
}
<template>
<div>
<el-table
ref="multipleTable"
:data="formatData"
border
stripe
style="width: 100%"
@select="onTableSelect"
@selection-change="handleSelectionChange"
>
>
<!-- 表头 、表体-->
<template v-for="column in columns">
<!-- 循环父页面数据、对数据进行判断参数处理-->
<el-table-column
v-if="column.type"
:fixed="column.fixed"
:key="column.desc"
:label="column.name"
:sortable="column.sortable?'custom':false"
:type="column.type"
:width="column.width==undefined?'auto':column.width"
align="center"
/>
<el-table-column
v-if="!column.type"
:fixed="column.fixed"
:key="column.desc"
:label="column.name"
:prop="column.desc"
:show-overflow-tooltip="column.tooltip?true:false"
:sortable="column.sortable?'custom':false"
:width="column.width==undefined?'auto':column.width"
align="center"
>
<template slot-scope="scope">
<!-- column.link为true 显示可点击状态 -->