| | |
| | | v-loading="tableLoading" |
| | | :border="border" |
| | | :data="tableData" |
| | | :header-cell-style="{ background: '#0e3372', color: '#cccccc' }" |
| | | :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" |
| | | :height="height" |
| | | :highlight-current-row="highlightCurrentRow" |
| | | :row-class-name="rowClassName" |
| | |
| | | <template> |
| | | <el-table-column align="center" label="序号" type="index" width="60" /> |
| | | </template> |
| | | |
| | | |
| | | <template v-for="(item, index) in column"> |
| | | <el-table-column :column-key="item.columnKey" :filter-method="item.filterHandler" |
| | | :filter-multiple="item.filterMultiple" :filtered-value="item.filteredValue" |
| | | :filters="item.filters" :fixed="item.fixed" :label="item.label" |
| | | :min-width="item.minWidth" :prop="item.prop" |
| | | :show-overflow-tooltip="item.showOverflowTooltip" |
| | | show-overflow-tooltip |
| | | :sortable="item.sortable ? true : false" :type="item.type" :width="item.width" |
| | | align="center"> |
| | | <!-- <div class="123" v-if="item.type == ''"> --> |
| | |
| | | slot-scope="scope"> |
| | | <slot v-if="item.theadSlot" :index="index" :name="item.theadSlot" :row="scope.row" /> |
| | | </template> |
| | | |
| | | |
| | | <template slot-scope="scope"> |
| | | <!-- 插槽 --> |
| | | <div v-if="item.dataType == 'slot'"> |
| | |
| | | <div v-else-if="item.dataType == 'progress'"> |
| | | <el-progress :percentage="Number(scope.row[item.prop])" /> |
| | | </div> |
| | | |
| | | |
| | | <!-- tag --> |
| | | <div v-else-if="item.dataType == 'tag'"> |
| | | <el-tag v-if="typeof dataTypeFn(scope.row[item.prop], item.formatData) == 'string'" |
| | |
| | | <el-tag v-else :title="scope.row[item.prop] | formatters(item.formatData)" |
| | | :type="formatType(scope.row[item.prop], item.formatType)">{{ scope.row[item.prop] | formatters(item.formatData) }}</el-tag> |
| | | </div> |
| | | |
| | | |
| | | <!-- 按钮 --> |
| | | <div v-else-if="item.dataType == 'action'"> |
| | | <template v-for="(o, key) in item.operation"> |
| | | <el-button |
| | | v-if="o.type!='upload'" |
| | | size="mini" |
| | | v-show="o.showHide ? o.showHide(scope.row) : true" |
| | | :disabled="o.disabled ? o.disabled(scope.row) : false" |
| | | :icon="o.icon | iconFn(scope.row)" |
| | | :plain="o.plain" :size="o.size" |
| | | :style="{ 'color': o.color }" |
| | | :icon="iconFn(o)" |
| | | :plain="o.plain" |
| | | :style="{ 'color': o.name === '删除' ? '#f56c6c' : o.color }" |
| | | :type="o.type | typeFn(scope.row)" |
| | | @click="o.clickFun(scope.row)"> |
| | | {{ o.name }} |
| | | </el-button> |
| | | <el-upload |
| | | action="#" |
| | | size="mini" |
| | | :on-change="(file, fileList)=>o.clickFun(scope.row,file, fileList)" |
| | | :multiple="o.multiple?o.multiple:false" |
| | | :limit="o.limit?o.limit:1" |
| | |
| | | <pagination |
| | | v-show="page.total>0" |
| | | :total="page.total" |
| | | :page.sync="page.pageNum" |
| | | :limit.sync="page.pageSize" |
| | | :layout="page.layout" |
| | | :page.sync="page.current" |
| | | :limit.sync="page.size" |
| | | @pagination="pagination" |
| | | /> |
| | | </div> |
| | | </template> |
| | | |
| | | |
| | | <script> |
| | | // 注:以下是所有配置项,其中最常使用的就是label、width、prop、dataType、slot |
| | | // label :列名,就是表头上的标签叫什么些什么,类型 string |
| | |
| | | export default { |
| | | name: 'ZTTable', |
| | | filters: { |
| | | iconFn(val, row) { |
| | | if (typeof (val) === 'function') { |
| | | return val(row); |
| | | } else return val; |
| | | }, |
| | | typeFn(val, row) { |
| | | // console.log(val, row, '11111111'); |
| | | if (typeof (val) === 'function') { |
| | |
| | | }, |
| | | border: { |
| | | type: Boolean, |
| | | default: true |
| | | default: false |
| | | }, |
| | | highlightCurrentRow: { |
| | | type: Boolean, |
| | |
| | | rowClassName: { |
| | | type: Function, |
| | | default: () => { |
| | | |
| | | |
| | | } |
| | | }, |
| | | rowStyle: { |
| | |
| | | default: undefined |
| | | }, |
| | | page:{ |
| | | type:object, |
| | | type:Object, |
| | | default() { |
| | | return { |
| | | total:0, |
| | | pageNum:0, |
| | | pageSize:10 |
| | | current:0, |
| | | size:10, |
| | | layout: 'total, sizes, prev, pager, next, jumper' |
| | | }; |
| | | } |
| | | } |
| | | }, |
| | | |
| | | |
| | | methods: { |
| | | iconFn(row) { |
| | | if (row.name === '编辑') { |
| | | return 'el-icon-edit' |
| | | } else if (row.name === '删除') { |
| | | return 'el-icon-delete' |
| | | } else if (row.name === '查看') { |
| | | return 'el-icon-view' |
| | | } else { |
| | | return row.icon |
| | | } |
| | | // if (typeof (val) === 'function') { |
| | | // return val(row); |
| | | // } else return val; |
| | | }, |
| | | formatType(val, format) { |
| | | if (typeof (format) === 'function') { |
| | | return format(val); |
| | |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | |
| | | <style scoped> |
| | | .el-table >>> .el-table__empty-text { |
| | | text-align: center |
| | | } |
| | | </style> |
| | | |