|
|
@@ -14,7 +14,7 @@
|
|
|
<searchTable @search="reload"></searchTable>
|
|
|
<ele-pro-table
|
|
|
ref="table"
|
|
|
- :columns="columns"
|
|
|
+ :columns="tableColumns"
|
|
|
:datasource="datasource"
|
|
|
row-key="id"
|
|
|
height="calc(100vh - 500px)"
|
|
|
@@ -25,7 +25,7 @@
|
|
|
>
|
|
|
<!-- 表头工具栏 -->
|
|
|
<template v-slot:action="{ row }">
|
|
|
- <el-radio class="radio" v-model="radio" :label="row.id"
|
|
|
+ <el-radio class="radio" v-model="radio" :label="row.id" @change="radioChange(row)"
|
|
|
><i></i
|
|
|
></el-radio>
|
|
|
</template>
|
|
|
@@ -62,6 +62,10 @@ export default {
|
|
|
needProduces: {
|
|
|
type: String,
|
|
|
default: ''
|
|
|
+ },
|
|
|
+ isSingle: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
@@ -69,6 +73,7 @@ export default {
|
|
|
visible: false,
|
|
|
currentIndex: null,
|
|
|
selection: [],
|
|
|
+ selectedRow: null,
|
|
|
columns: [
|
|
|
{
|
|
|
width: 45,
|
|
|
@@ -85,12 +90,6 @@ export default {
|
|
|
showOverflowTooltip: true,
|
|
|
fixed: 'left'
|
|
|
},
|
|
|
- // {
|
|
|
- // action: 'action',
|
|
|
- // slot: 'action',
|
|
|
- // align: 'center',
|
|
|
- // label: '选择'
|
|
|
- // },
|
|
|
{
|
|
|
prop: 'orderNo',
|
|
|
label: '订单编码',
|
|
|
@@ -206,10 +205,30 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
|
|
|
+ computed: {
|
|
|
+ tableColumns() {
|
|
|
+ if (this.isSingle) {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ action: 'action',
|
|
|
+ slot: 'action',
|
|
|
+ align: 'center',
|
|
|
+ label: '选择',
|
|
|
+ width: 55
|
|
|
+ },
|
|
|
+ ...this.columns.filter(col => col.columnKey !== 'selection')
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return this.columns;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
methods: {
|
|
|
open(item, currentIndex) {
|
|
|
this.currentIndex = currentIndex;
|
|
|
this.selection = [];
|
|
|
+ this.selectedRow = null;
|
|
|
+ this.radio = null;
|
|
|
// if (item && item.id) {
|
|
|
// this.radio = item.id;
|
|
|
// }
|
|
|
@@ -246,22 +265,39 @@ export default {
|
|
|
this.current = row;
|
|
|
console.log(row);
|
|
|
this.radio = row.id;
|
|
|
+ if (this.isSingle) {
|
|
|
+ this.selectedRow = row;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 单选模式下记录选中的整行数据
|
|
|
+ radioChange(row) {
|
|
|
+ if (this.isSingle) {
|
|
|
+ this.selectedRow = row;
|
|
|
+ }
|
|
|
},
|
|
|
handleClose() {
|
|
|
this.visible = false;
|
|
|
this.current = null;
|
|
|
this.radio = '';
|
|
|
+ this.selectedRow = null;
|
|
|
},
|
|
|
|
|
|
selected() {
|
|
|
- if (!this.selection.length) {
|
|
|
- return this.$message.warning('请至少选择一条数据');
|
|
|
+ if (this.isSingle) {
|
|
|
+ if (!this.selectedRow) {
|
|
|
+ return this.$message.warning('请选择一条数据');
|
|
|
+ }
|
|
|
+ this.$emit('changeParent', [this.selectedRow], this.currentIndex);
|
|
|
+ } else {
|
|
|
+ if (!this.selection.length) {
|
|
|
+ return this.$message.warning('请至少选择一条数据');
|
|
|
+ }
|
|
|
+ // let partaIds = this.selection.map((item) => item.partaId);
|
|
|
+ // if (new Set(partaIds).size != 1) {
|
|
|
+ // return this.$message.warning('请选择相同客户的订单!');
|
|
|
+ // }
|
|
|
+ this.$emit('changeParent', this.selection, this.currentIndex);
|
|
|
}
|
|
|
- // let partaIds = this.selection.map((item) => item.partaId);
|
|
|
- // if (new Set(partaIds).size != 1) {
|
|
|
- // return this.$message.warning('请选择相同客户的订单!');
|
|
|
- // }
|
|
|
- this.$emit('changeParent', this.selection, this.currentIndex);
|
|
|
this.handleClose();
|
|
|
}
|
|
|
}
|