yusheng vor 11 Monaten
Ursprung
Commit
8f5d18b1ef

+ 13 - 3
src/components/timeDialog/index.vue

@@ -22,7 +22,7 @@
         v-if="!view"
         >新增
       </el-button>
-      <span style="margin-left: 10px"
+      <span style="margin-left: 10px" v-if="!isAll"
         >待分配数量:<span style="color: #1890ff">{{ count }}</span></span
       >
       <el-table
@@ -117,11 +117,18 @@
       },
       isBatch: {
         default: false
+      },
+      isAll: {
+        default: false
       }
     },
     computed: {
       getCountMax() {
+    
         return (row) => {
+          if (this.isAll) {
+          return 100000000;
+        }
           let maxCount = this.current.totalCount * 1 || 0;
           let usedCount = this.form.arrivalBatch.reduce((n, item) => {
             n += item.arriveCount * 1;
@@ -206,10 +213,13 @@
       },
 
       handleOk() {
-        if (this.count !== 0)
+        if (this.count !== 0&&!this.isAll)
           return this.$message.warning('分配数量有误,请检查!');
         let batchS = this.form.arrivalBatch.map((item) => item.batch);
-        if (new Set(batchS).size != this.form.arrivalBatch.length&&this.isBatch) {
+        if (
+          new Set(batchS).size != this.form.arrivalBatch.length &&
+          this.isBatch
+        ) {
           return this.$message.warning('批次号不能重复!');
         }
         this.$refs.tableForm.validate((valid) => {

+ 116 - 0
src/components/timeDialog/indexAll.vue

@@ -0,0 +1,116 @@
+<template>
+  <div>
+    <el-button
+      size="small"
+      type="primary"
+      class="ele-btn-icon"
+      style="margin-left: 5px"
+      @click="open"
+      :disabled="disabled"
+      >批量设置到货方式
+    </el-button>
+    <ele-modal
+      :visible.sync="batchVisible"
+      title="批量选择"
+      width="25vw"
+      append-to-body
+      @close="handleClose"
+      :maxable="true"
+    >
+      <el-form :model="form" label-width="100px">
+        <el-form-item label="到货方式" prop="deliveryMethod">
+          <el-select
+            clearable
+            v-model="form.deliveryMethod"
+            placeholder="请选择"
+          >
+            <el-option label="一次性到货" :value="1" />
+            <el-option label="分批到货" :value="2" />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="要求到货时间" prop="requireDeliveryTime">
+          <el-date-picker
+            clearable
+            v-model="form.requireDeliveryTime"
+            type="date"
+            v-show="form.deliveryMethod == 1"
+            value-format="yyyy-MM-dd"
+            placeholder="请选择日期"
+            :pickerOptions="{
+              disabledDate: (time) =>
+                time.getTime() <
+                new Date(new Date().setHours(0, 0, 0, 0)).getTime()
+            }"
+          >
+          </el-date-picker>
+          <el-link
+            type="primary"
+            :underline="false"
+            v-show="form.deliveryMethod == 2"
+            @click.native="handleMethod()"
+          >
+            设置分批时间
+          </el-link>
+        </el-form-item>
+      </el-form>
+      <template v-slot:footer>
+        <el-button @click="handleClose">取消</el-button>
+        <el-button type="primary" @click="handleConfirm">确认</el-button>
+      </template>
+      <timeDialog
+        @chooseTime="chooseTime"
+        ref="timeDialogRef"
+        :isAll="true"
+      ></timeDialog>
+    </ele-modal>
+  </div>
+</template>
+
+<script>
+  import { copyObj } from '@/utils/util';
+  import timeDialog from '@/components/timeDialog/index.vue';
+
+  const def = {
+    deliveryMethod: '',
+    requireDeliveryTime: '',
+    arrivalBatch: []
+  };
+  export default {
+    components: { timeDialog },
+    computed: {},
+    data() {
+      return {
+        batchVisible: false,
+        form: copyObj(def)
+      };
+    },
+    props:{
+      disabled:{
+        type:Boolean,
+        default:true
+      }
+    },
+    methods: {
+      open() {
+        this.batchVisible = true;
+        this.form = copyObj(def);
+      },
+      handleMethod() {
+        this.$refs.timeDialogRef.open({ arrivalBatch:this.form.arrivalBatch});
+      },
+      chooseTime({ arrivalBatch }) {
+        this.form.arrivalBatch = arrivalBatch;
+      },
+      handleConfirm() {
+        console.log(this.form, 'this.form');
+        this.$emit('chooseTime', this.form);
+        this.handleClose();
+      },
+      handleClose() {
+        this.batchVisible = false;
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped></style>

+ 47 - 5
src/views/purchasingManage/purchaseNeedManage/components/inventoryTable.vue

@@ -9,11 +9,12 @@
       @columns-change="handleColumnChange"
       :cache-key="cacheKeyUrl"
       class="time-form"
+      :selection.sync="selection"
     >
       <!-- 表头工具栏 -->
       <template v-slot:toolbar>
         <div class="headbox">
-          <div>
+          <div style="display: flex">
             <el-button
               size="small"
               type="primary"
@@ -32,6 +33,11 @@
             >
               新增临时产品
             </el-button>
+
+            <timeDialogAll
+              @chooseTime="chooseTimeALl"
+              :disabled="!selection.length"
+            ></timeDialogAll>
           </div>
         </div>
       </template>
@@ -368,6 +374,7 @@
   import fileUpload from '@/components/upload/fileUpload';
   import headList from '@/BIZComponents/user-select/user-select.vue';
   import timeDialog from '@/components/timeDialog/index.vue';
+  import timeDialogAll from '@/components/timeDialog/indexAll.vue';
   import { copyObj } from '@/utils/util';
   import { getInventoryTotalAPI } from '@/api/wms';
   // import fileMain from '@/components/addDoc/index.vue';
@@ -377,7 +384,7 @@
   import { levelList } from '@/enum/dict.js';
 
   export default {
-    mixins: [dictMixins,tabMixins],
+    mixins: [dictMixins, tabMixins],
     components: {
       // fileMain,
       productList,
@@ -385,7 +392,8 @@
       fileUpload,
       headList,
       timeDialog,
-      taskinstanceDialog
+      taskinstanceDialog,
+      timeDialogAll
     },
     data() {
       const defaultForm = {
@@ -396,7 +404,7 @@
       };
       return {
         levelList,
-        cacheKeyUrl:'eos-purchaseNeedManage-inventoryTable',
+        cacheKeyUrl: 'eos-purchaseNeedManage-inventoryTable',
         numberReg,
         defaultForm,
         arrivalWayList: [
@@ -406,6 +414,7 @@
         form: {
           datasource: []
         },
+        selection: [],
         rules: {},
         dictList: {},
         taskinstanceDialogFlag: false,
@@ -416,6 +425,14 @@
             columnKey: 'index',
             align: 'center'
           },
+          {
+            label: '选择',
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            fixed: 'left'
+          },
           {
             width: 120,
             prop: 'productCategoryName',
@@ -619,7 +636,10 @@
       //修改回显
       async putTableValue(data) {
         if (data && data?.length) {
-          this.form.datasource = data;
+          this.form.datasource = data.map((item, index) => {
+            item.key = index + 1;
+            return item;
+          });
           //获取仓库库存
           let codeList = this.form.datasource
             .filter((item) => item.productCode)
@@ -655,6 +675,28 @@
           copyObj(arrivalBatch)
         );
       },
+      chooseTimeALl(data) {
+        console.log(data, 'data');
+        let keyS = this.selection.map((item) => item.key - 1);
+        keyS.forEach((key) => {
+        this.$set(this.form.datasource[key], 'arrivalWay', data.deliveryMethod);
+
+          if (data.deliveryMethod == 1) {
+            this.$set(
+              this.form.datasource[key],
+              'expectReceiveDate',
+              data.requireDeliveryTime
+            );
+          } else {
+            this.$set(
+              this.form.datasource[key],
+              'arrivalBatch',
+              copyObj(data.arrivalBatch)
+            );
+            this.$set(this.form.datasource[key],'totalCount',data.arrivalBatch.map(item=>item.arriveCount).reduce((a,b)=>a+b,0))
+          }
+        });
+      },
       //cbom新增
       handCBom(row, index) {
         this.$refs.cBomRef.open(this.form.datasource, index);