|
@@ -2,28 +2,53 @@
|
|
|
* @Author : yuanrunwei
|
|
|
* @Date : 2021-11-01 18:02:58
|
|
|
* @LastEditors : yuanrunwei
|
|
|
- * @LastEditTime : 2021-12-03 16:30:48
|
|
|
+ * @LastEditTime : 2021-12-03 18:26:56
|
|
|
* @FilePath : \spfm-market-front\src\pages\main\performance\components\table.vue
|
|
|
-->
|
|
|
<template>
|
|
|
- <el-table class="simple-table" :data="list" v-loading="loading">
|
|
|
+ <el-table class="simple-table" :data="computed_list" v-loading="loading">
|
|
|
<el-table-column
|
|
|
- v-for="({ props, label, width, children }, index) in config"
|
|
|
+ v-for="(
|
|
|
+ { props, label, type, width, align, children }, index
|
|
|
+ ) in config"
|
|
|
:key="index"
|
|
|
:prop="props"
|
|
|
:width="width"
|
|
|
:label="label"
|
|
|
- align="center"
|
|
|
+ :align="align || 'center'"
|
|
|
>
|
|
|
+ <template #default="scope">
|
|
|
+ <div v-if="type === 'edit'">
|
|
|
+ <el-input
|
|
|
+ v-if="scope.row[`${props}_${type}`]"
|
|
|
+ v-model="scope.row[props]"
|
|
|
+ autosize
|
|
|
+ type="textarea"
|
|
|
+ />
|
|
|
+ <div v-else v-html="scope.row[props]"></div>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ class="margin-top-10"
|
|
|
+ @click="handleEdit({ scope, type, props })"
|
|
|
+ >
|
|
|
+ {{ !scope.row[`${props}_${type}`] ? "编辑" : "完成" }}
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ <div v-else>{{ scope.row[props] }}</div>
|
|
|
+ </template>
|
|
|
<template v-if="children">
|
|
|
<el-table-column
|
|
|
- v-for="({ props, label, width }, index) in children"
|
|
|
+ v-for="({ props, label, width, align }, index) in children"
|
|
|
:key="index"
|
|
|
:prop="props"
|
|
|
:width="width"
|
|
|
:label="label"
|
|
|
- align="center"
|
|
|
- />
|
|
|
+ :align="align || 'center'"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <div>{{ scope.row[props] }}</div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
@@ -64,10 +89,28 @@ export default {
|
|
|
default: () => [],
|
|
|
},
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ computed_list() {
|
|
|
+ const object = {};
|
|
|
+ this.config
|
|
|
+ .filter(({ type }) => type === "edit")
|
|
|
+ .forEach(({ props, type }) => {
|
|
|
+ object[`${props}_${type}`] = false;
|
|
|
+ });
|
|
|
+ return this.list.map((element) => ({
|
|
|
+ ...element,
|
|
|
+ ...object,
|
|
|
+ }));
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
handleClick(props, row) {
|
|
|
this.$emit(props, row);
|
|
|
},
|
|
|
+ handleEdit({ scope, type, props }) {
|
|
|
+ scope.row[`${props}_${type}`] = !scope.row[`${props}_${type}`];
|
|
|
+ this.$emit(props, scope.row);
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|