99 lines
2.3 KiB
Vue
99 lines
2.3 KiB
Vue
<template>
|
|
<el-table
|
|
border
|
|
:header-cell-style="{
|
|
background: '#f5f7fa',
|
|
}"
|
|
:data="tableData"
|
|
style="width: 100%; margin-top: 20px"
|
|
height="650"
|
|
size="mini"
|
|
>
|
|
<el-table-column
|
|
v-if="column.label !== 'userId'"
|
|
v-for="(column, index) in tableColumns"
|
|
:key="index"
|
|
:prop="column.prop"
|
|
:label="column.label"
|
|
width="auto"
|
|
>
|
|
<template slot-scope="scope">
|
|
<span v-if="column.type === 'text'"> {{ scope.row[column.prop] }}</span>
|
|
<div v-else-if="column.type === 'image'">
|
|
<img style="width: 200px; height: 100px" :src="scope.row[column.prop]" />
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column fixed="right" label="操作" width="160">
|
|
<template slot-scope="scope">
|
|
<el-popconfirm
|
|
@confirm="handleDelete(scope.row)"
|
|
:title="'确定要取消' + scope.row.userName"
|
|
>
|
|
<el-button
|
|
slot="reference"
|
|
style="margin-left: 10px; color: red"
|
|
class="el-icon-delete"
|
|
type="text"
|
|
size="small"
|
|
>取消负责人</el-button
|
|
>
|
|
</el-popconfirm>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</template>
|
|
<script>
|
|
export default {
|
|
name: "PersonInCharge",
|
|
props: {
|
|
columns: {
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
data: {
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
deleteFunc: {
|
|
type: Function,
|
|
default: () => {},
|
|
},
|
|
},
|
|
data() {
|
|
return {};
|
|
},
|
|
methods: {
|
|
// 删除事件
|
|
handleDelete(row) {
|
|
this.deleteFunc(row);
|
|
},
|
|
},
|
|
|
|
computed: {
|
|
tableColumns() {
|
|
// 处理传进来的列配置,返回符合 Element UI 表格要求的配置
|
|
return this.columns.map((column) => {
|
|
return {
|
|
label: column.label,
|
|
prop: column.prop,
|
|
type: column.type,
|
|
};
|
|
});
|
|
},
|
|
tableData() {
|
|
// 处理传进来的数据,返回符合 Element UI 表格要求的数据
|
|
return this.data.map((rowData) => {
|
|
let row = {};
|
|
for (let column of this.columns) {
|
|
row[column.prop] = rowData[column.prop];
|
|
}
|
|
return row;
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
<style lang="scss" scoped></style>
|