Просмотр исходного кода

fix: 更新订单列表对话框以支持单选模式

xieyong 19 часов назад
Родитель
Сommit
2c04d38231

+ 2 - 1
src/views/warehouseManagement/inventoryAllocation/accountstatement/generateStatement.vue

@@ -53,6 +53,7 @@
       ref="orderListDialogRef"
       ref="orderListDialogRef"
       @changeParent="getOrderInfo"
       @changeParent="getOrderInfo"
       needProduces="4"
       needProduces="4"
+      :isSingle="true"
     ></orderListDialog>
     ></orderListDialog>
   </ele-modal>
   </ele-modal>
 </template>
 </template>
@@ -229,7 +230,7 @@
             let params = this.form.datasource.map(item => {
             let params = this.form.datasource.map(item => {
                 return {
                 return {
                     allotId: item.id,
                     allotId: item.id,
-                    saleOrderNos: item.saleOrderNos,
+                    saleOrderNo: item.saleOrderNos,
                 }
                 }
             });
             });
             console.log('params~~~', params);
             console.log('params~~~', params);

+ 51 - 15
src/views/warehouseManagement/inventoryAllocation/accountstatement/orderListDialog.vue

@@ -14,7 +14,7 @@
       <searchTable @search="reload"></searchTable>
       <searchTable @search="reload"></searchTable>
       <ele-pro-table
       <ele-pro-table
         ref="table"
         ref="table"
-        :columns="columns"
+        :columns="tableColumns"
         :datasource="datasource"
         :datasource="datasource"
         row-key="id"
         row-key="id"
         height="calc(100vh - 500px)"
         height="calc(100vh - 500px)"
@@ -25,7 +25,7 @@
       >
       >
         <!-- 表头工具栏 -->
         <!-- 表头工具栏 -->
         <template v-slot:action="{ row }">
         <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
             ><i></i
           ></el-radio>
           ></el-radio>
         </template>
         </template>
@@ -62,6 +62,10 @@ export default {
     needProduces: {
     needProduces: {
       type: String,
       type: String,
       default: ''
       default: ''
+    },
+    isSingle: {
+      type: Boolean,
+      default: false
     }
     }
   },
   },
   data() {
   data() {
@@ -69,6 +73,7 @@ export default {
       visible: false,
       visible: false,
       currentIndex: null,
       currentIndex: null,
       selection: [],
       selection: [],
+      selectedRow: null,
       columns: [
       columns: [
         {
         {
           width: 45,
           width: 45,
@@ -85,12 +90,6 @@ export default {
           showOverflowTooltip: true,
           showOverflowTooltip: true,
           fixed: 'left'
           fixed: 'left'
         },
         },
-        // {
-        //   action: 'action',
-        //   slot: 'action',
-        //   align: 'center',
-        //   label: '选择'
-        // },
         {
         {
           prop: 'orderNo',
           prop: 'orderNo',
           label: '订单编码',
           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: {
   methods: {
     open(item, currentIndex) {
     open(item, currentIndex) {
       this.currentIndex = currentIndex;
       this.currentIndex = currentIndex;
       this.selection = [];
       this.selection = [];
+      this.selectedRow = null;
+      this.radio = null;
       // if (item && item.id) {
       // if (item && item.id) {
       //   this.radio = item.id;
       //   this.radio = item.id;
       // }
       // }
@@ -246,22 +265,39 @@ export default {
       this.current = row;
       this.current = row;
       console.log(row);
       console.log(row);
       this.radio = row.id;
       this.radio = row.id;
+      if (this.isSingle) {
+        this.selectedRow = row;
+      }
+    },
+    // 单选模式下记录选中的整行数据
+    radioChange(row) {
+      if (this.isSingle) {
+        this.selectedRow = row;
+      }
     },
     },
     handleClose() {
     handleClose() {
       this.visible = false;
       this.visible = false;
       this.current = null;
       this.current = null;
       this.radio = '';
       this.radio = '';
+      this.selectedRow = null;
     },
     },
 
 
     selected() {
     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();
       this.handleClose();
     }
     }
   }
   }