|
|
@@ -17,17 +17,19 @@
|
|
|
</el-row>
|
|
|
<el-row type="flex">
|
|
|
<el-col>
|
|
|
- <el-table :data="tableData">
|
|
|
- <el-table-column label="性能指标名称" prop="target_">
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <el-input v-model="row.target_" size="mini" placeholder="请输入性能指标名称" />
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
+ <el-table :data="tableData" @selection-change="handleSelectionChange" ref="table">
|
|
|
+ <el-table-column type="selection" width="55"></el-table-column>
|
|
|
<el-table-column label="性能指标代码" prop="target_key_">
|
|
|
<template slot-scope="{ row }">
|
|
|
<el-input v-model="row.target_key_" size="mini" placeholder="请输入性能指标代码" />
|
|
|
</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="性能指标名称" prop="target_">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-input v-model="row.target_" size="mini" placeholder="请输入性能指标名称" />
|
|
|
+ </template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column prop="id_" v-if="false"></el-table-column>
|
|
|
</el-table>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
@@ -38,6 +40,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { batchSaveZhiBiao } from '@/api/business/pv';
|
|
|
+
|
|
|
export default {
|
|
|
props: {
|
|
|
visible: {
|
|
|
@@ -47,7 +51,8 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- tableData: []
|
|
|
+ tableData: [],
|
|
|
+ selectedRows: []
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
@@ -55,21 +60,41 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
loadData() {
|
|
|
- const sql = 'select * from t_xnyzpzxx';
|
|
|
- this.$common.request('sql', sql).then((response) => {
|
|
|
+ this.$common.request('query', {
|
|
|
+ key: 'xnyzcxxnzb',
|
|
|
+ params: [null]
|
|
|
+ }).then((response) => {
|
|
|
this.tableData = response.variables.data || [];
|
|
|
});
|
|
|
},
|
|
|
addRow() {
|
|
|
- this.tableData.push({ target_: '', target_key_: '' });
|
|
|
+ this.tableData.push({ id_: '', target_: '', target_key_: '' });
|
|
|
},
|
|
|
deleteRow() {
|
|
|
- if (this.tableData.length > 0) {
|
|
|
- this.tableData.pop();
|
|
|
+ if (this.selectedRows.length > 0) {
|
|
|
+ this.tableData = this.tableData.filter(row => !this.selectedRows.includes(row));
|
|
|
+ this.selectedRows = [];
|
|
|
+ } else {
|
|
|
+ this.$message.warning('请先选择要删除的行');
|
|
|
}
|
|
|
},
|
|
|
+ handleSelectionChange(selection) {
|
|
|
+ this.selectedRows = selection;
|
|
|
+ },
|
|
|
save() {
|
|
|
- console.log('Save clicked', this.tableData);
|
|
|
+ const payload = this.tableData.map(item => ({
|
|
|
+ id: item.id_ || '',
|
|
|
+ target: item.target_,
|
|
|
+ targetKey: item.target_key_
|
|
|
+ }));
|
|
|
+ batchSaveZhiBiao(payload)
|
|
|
+ .then(() => {
|
|
|
+ this.$message.success('保存成功');
|
|
|
+ this.close();
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$message.error('保存失败');
|
|
|
+ });
|
|
|
},
|
|
|
close() {
|
|
|
this.$emit('update:visible', false);
|