|
|
@@ -10,10 +10,11 @@
|
|
|
>
|
|
|
<el-card shadow="never">
|
|
|
<searchTable @search="reload"></searchTable>
|
|
|
- <ele-pro-table ref="table" :columns="columns" :datasource="datasource" row-key="id"
|
|
|
- height="calc(100vh - 500px)" class="dict-table" @cell-click="cellClick">
|
|
|
+ <ele-pro-table ref="table" :columns="tableColumns" :datasource="datasource" row-key="id"
|
|
|
+ height="calc(100vh - 500px)" class="dict-table" @cell-click="cellClick"
|
|
|
+ :selection.sync="selection">
|
|
|
<!-- 表头工具栏 -->
|
|
|
- <template v-slot:action="{ row }">
|
|
|
+ <template v-slot:action="{ row }" v-if="!multiple">
|
|
|
<el-radio class="radio" v-model="radio" :label="row.id"><i></i></el-radio>
|
|
|
</template>
|
|
|
</ele-pro-table>
|
|
|
@@ -38,7 +39,13 @@ export default {
|
|
|
components: {
|
|
|
searchTable
|
|
|
},
|
|
|
- props: ['inventoryAllocationDialogFlag'],
|
|
|
+ props: {
|
|
|
+ inventoryAllocationDialogFlag: Boolean,
|
|
|
+ multiple: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
currentIndex: null,
|
|
|
@@ -156,6 +163,23 @@ export default {
|
|
|
},
|
|
|
],
|
|
|
radio: null,
|
|
|
+ current: null,
|
|
|
+ selection: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ tableColumns() {
|
|
|
+ if (!this.multiple) return this.columns;
|
|
|
+ return [
|
|
|
+ this.columns[0],
|
|
|
+ {
|
|
|
+ width: 45,
|
|
|
+ type: 'selection',
|
|
|
+ columnKey: 'selection',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ ...this.columns.slice(2)
|
|
|
+ ];
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -178,18 +202,24 @@ export default {
|
|
|
|
|
|
// 单击获取id
|
|
|
cellClick(row) {
|
|
|
- this.current = row
|
|
|
- this.radio = row.id
|
|
|
+ if (!this.multiple) {
|
|
|
+ this.current = row
|
|
|
+ this.radio = row.id
|
|
|
+ }
|
|
|
},
|
|
|
handleClose() {
|
|
|
this.$emit('update:inventoryAllocationDialogFlag', false)
|
|
|
+ this.current = null;
|
|
|
+ this.radio = null;
|
|
|
+ this.selection = [];
|
|
|
},
|
|
|
|
|
|
selected() {
|
|
|
- if (!this.current) {
|
|
|
+ const selectedRows = this.multiple ? this.selection : this.current ? [this.current] : [];
|
|
|
+ if (selectedRows.length === 0) {
|
|
|
return this.$message.warning('请至少选择一条数据')
|
|
|
}
|
|
|
- this.$emit('changeParent', this.current, this.currentIndex)
|
|
|
+ this.$emit('changeParent', this.multiple ? selectedRows : selectedRows[0], this.currentIndex)
|
|
|
this.handleClose()
|
|
|
},
|
|
|
|