Преглед на файлове

物料列表添加安全库存数量...,批量修改到货方式选择到货时间

yijing преди 1 година
родител
ревизия
ebcbd46076

+ 9 - 9
src/views/aps/presalesorder/index.vue

@@ -36,20 +36,20 @@
       <ele-pro-table ref="tableRef" :columns="columns" :datasource="salesorderList" :pageSize="20"
         :pageSizes="[20, 30, 40, 50, 100]" row-key="id" @selection-change="handleSelectionChange" @reload="salesorderList">
         <template v-slot:toolbar>
-          <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
-          <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single"
+          <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
+          <el-button style="background-color: #4e6cef;color: white;border-color: #4e6cef" icon="el-icon-edit" size="mini" :disabled="single"
             @click="handleUpdate">修改</el-button>
-          <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
+          <el-button style="background-color: #dd2c00;color: white;border-color: #dd2c00" icon="el-icon-delete" size="mini" :disabled="multiple"
             @click="handleDelete">删除</el-button>
-          <el-button type="warning" plain icon="el-icon-download" size="mini" :disabled="single"
+          <el-button style="background-color: #ec407a;color: white;border-color: #ec407a" icon="el-icon-download" size="mini" :disabled="single"
             @click="handleExpect">交期预估</el-button>
-          <el-button type="warning" plain icon="el-icon-download" size="mini" :disabled="multiple"
+          <el-button style="background-color: #cddc39;color: white;border-color: #cddc39" icon="el-icon-download" size="mini" :disabled="multiple"
             @click="handleAllExpect">全部预估</el-button>
-          <el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport">导入</el-button>
-          <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
-          <el-button type="success" plain icon="el-icon-download" size="mini" :disabled="single"
+          <el-button type="info" icon="el-icon-upload2" size="mini" @click="handleImport">导入</el-button>
+          <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
+          <el-button style="background-color: #8bc34a;color: white;border-color: #8bc34a" icon="el-icon-download" size="mini" :disabled="single"
             @click="handleSaleorder">转销售订单</el-button>
-          <el-button type="success" plain icon="el-icon-download" size="mini"
+          <el-button type="success" icon="el-icon-download" size="mini"
             @click="handleAllSaleorder">一次性转销售订单</el-button>
         </template>
         <!-- <template v-slot:status="{ row }">

+ 233 - 239
src/views/cuttingPlan/index.vue

@@ -1,22 +1,12 @@
 <template>
   <div class="ele-body">
     <el-card shadow="never" v-loading="loading">
-      <cuttingPlanSearch
-        @search="reload"
-        :statusOpt="statusOpt"
-        :activeName="activeName"
-        ref="searchRef"
-      >
+      <cuttingPlanSearch @search="reload" :statusOpt="statusOpt" :activeName="activeName" ref="searchRef">
       </cuttingPlanSearch>
 
       <!-- 数据表格 -->
-      <ele-pro-table
-        ref="table11"
-        :initLoad="false"
-        :columns="columns"
-        :datasource="datasource"
-        cache-key="`materialPlanTable`"
-      >
+      <ele-pro-table ref="table11" :initLoad="false" :columns="columns" :datasource="datasource"
+        cache-key="`materialPlanTable`" :pageSize="20" :pageSizes="[20, 30, 40, 50, 100]">
         <template v-slot:toolbar>
           <el-dropdown trigger="click" @command="handleClick">
             <el-link type="primary" icon="el-icon-plus">创建计划</el-link>
@@ -48,47 +38,29 @@
               row.orderType == 1
                 ? '销售订单'
                 : row.orderType == 2
-                ? '生产计划'
-                : ''
+                  ? '生产计划'
+                  : ''
             }}
           </span>
         </template>
 
         <template v-slot:approvalStatus="{ row }">
-          <el-link
-            type="primary"
-            :underline="false"
-            @click="handleDetails(row)"
-          >
+          <el-link type="primary" :underline="false" @click="handleDetails(row)">
             {{ approvalStatusFormatter(row.approvalStatus) }}
           </el-link>
         </template>
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
-          <el-link
-            type="primary"
-            :underline="false"
-            @click="todo(row)"
-            v-if="row.approvalStatus == 0 || row.approvalStatus == 3"
-          >
+          <el-link type="primary" :underline="false" @click="todo(row)"
+            v-if="row.approvalStatus == 0 || row.approvalStatus == 3">
             提交
           </el-link>
-          <el-link
-            type="primary"
-            :underline="false"
-            icon="el-icon-edit"
-            @click="handleEdit('edit', row)"
-            v-if="row.approvalStatus != 2 && row.approvalStatus != 1"
-          >
+          <el-link type="primary" :underline="false" icon="el-icon-edit" @click="handleEdit('edit', row)"
+            v-if="row.approvalStatus != 2 && row.approvalStatus != 1">
             修改
           </el-link>
-          <el-link
-            @click="handleDel(row)"
-            type="danger"
-            :underline="false"
-            icon="el-icon-delete"
-            v-if="row.approvalStatus == 0 || row.approvalStatus == 3"
-          >
+          <el-link @click="handleDel(row)" type="danger" :underline="false" icon="el-icon-delete"
+            v-if="row.approvalStatus == 0 || row.approvalStatus == 3">
             删除
           </el-link>
         </template>
@@ -102,224 +74,246 @@
 </template>
 
 <script>
-  import cuttingPlanSearch from './components/cuttingPlan-search.vue';
+import cuttingPlanSearch from './components/cuttingPlan-search.vue';
 
-  import planEditDialog from './components/plan-edit-dialog.vue';
+import planEditDialog from './components/plan-edit-dialog.vue';
 
-  import producePlan from './components/producePlan.vue';
+import producePlan from './components/producePlan.vue';
 
-  import detail from '@/views/materialPlan/components/detail.vue';
+import detail from '@/views/materialPlan/components/detail.vue';
 
-  import { getList, del, submit } from '@/api/cuttingPlan/index.js';
+import { getList, del, submit } from '@/api/cuttingPlan/index.js';
 
-  export default {
-    components: {
-      cuttingPlanSearch,
+export default {
+  components: {
+    cuttingPlanSearch,
 
-      detail,
-      planEditDialog,
-      producePlan
-    },
+    detail,
+    planEditDialog,
+    producePlan
+  },
 
-    data() {
-      return {
-        activeName: 'first',
+  data() {
+    return {
+      activeName: 'first',
 
-        // 加载状态
-        loading: false,
+      // 加载状态
+      loading: false,
 
-        statusOpt: {
-          first: [
-            { label: '所有状态', value: null },
-            { label: '待排产', value: '1' },
-            { label: '待发布', value: '2' },
-            { label: '发布失败', value: '3' },
-            { label: '已完成', value: '6' }
-          ]
-        },
+      statusOpt: {
+        first: [
+          { label: '所有状态', value: null },
+          { label: '待排产', value: '1' },
+          { label: '待发布', value: '2' },
+          { label: '发布失败', value: '3' },
+          { label: '已完成', value: '6' }
+        ]
+      },
 
-        approvalStatusOpt: {
-          first: [
-            { label: '未提交', value: '0' },
-            { label: '审核中', value: '1' },
-            { label: '审核通过', value: '2' },
-            { label: '审核未通过', value: '3' }
-          ]
-        }
-      };
-    },
-    computed: {
-      // 表格列配置
-      columns() {
-        return [
-          {
-            columnKey: 'index',
-            label: '序号',
-            type: 'index',
-            width: 55,
-            align: 'center',
-            fixed: 'left'
-          },
-          {
-            slot: 'demandType',
-            prop: 'demandType',
-            label: '需求类型',
-            align: 'center',
-            formatter: (row, column, cellValue) => {
-              return row.demandType == 1
-                ? '生产性物资采购'
-                : row.demandType == 6
+      approvalStatusOpt: {
+        first: [
+          { label: '未提交', value: '0' },
+          { label: '审核中', value: '1' },
+          { label: '审核通过', value: '2' },
+          { label: '审核未通过', value: '3' }
+        ]
+      }
+    };
+  },
+  computed: {
+    // 表格列配置
+    columns() {
+      return [
+        {
+          columnKey: 'index',
+          label: '序号',
+          type: 'index',
+          width: 55,
+          align: 'center',
+          fixed: 'left'
+        },
+        {
+          slot: 'demandType',
+          prop: 'demandType',
+          label: '需求类型',
+          align: 'center',
+          formatter: (row, column, cellValue) => {
+            return row.demandType == 1
+              ? '生产性物资采购'
+              : row.demandType == 6
                 ? '外协自供料采购'
                 : row.demandType == 7
-                ? '外协客供料采购'
-                : '';
-            }
-          },
-          {
-            slot: 'name',
-            prop: 'name',
-            label: '名称',
-            align: 'center'
-          },
-          {
-            slot: 'code',
-            prop: 'code',
-            label: '编号',
-            align: 'center'
-          },
-          {
-            prop: 'planStr',
-            label: '生产计划编码',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'orderStr',
-            label: '销售订单号',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'serialNoStr',
-            label: '客户代号',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            columnKey: 'status',
-            label: '状态',
-            align: 'center',
-            slot: 'status',
-            action: 'status'
-          },
-          {
-            prop: 'approvalStatus',
-            label: '审批状态',
-            align: 'center',
-            slot: 'approvalStatus',
-            action: 'approvalStatus'
+                  ? '外协客供料采购'
+                  : '';
           },
-          {
-            prop: 'orderType',
-            label: '来源类型',
-            align: 'center',
-            slot: 'orderType',
-            action: 'orderType'
-          },
-          {
-            prop: 'createUserName',
-            label: '创建人',
-            align: 'center'
-          },
-          {
-            prop: 'createTime',
-            label: '创建时间',
-            align: 'center'
-          },
-          {
-            columnKey: 'action',
-            label: '操作',
-            width: 250,
-            align: 'center',
-            resizable: false,
-            fixed: 'right',
-            slot: 'action'
-          }
-        ];
-      }
+          width: 130,
+          showOverflowTooltip: true,
+          fixed: 'left'
+        },
+        {
+          slot: 'name',
+          prop: 'name',
+          label: '名称',
+          align: 'center',
+          width: 130,
+          showOverflowTooltip: true,
+          fixed: 'left'
+        },
+        {
+          slot: 'code',
+          prop: 'code',
+          label: '编号',
+          align: 'center',
+          width: 160,
+          showOverflowTooltip: true,
+          fixed: 'left'
+        },
+        {
+          prop: 'planStr',
+          label: '生产计划编码',
+          align: 'center',
+          width: 160,
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'orderStr',
+          label: '销售订单号',
+          align: 'center',
+          width: 160,
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'serialNoStr',
+          label: '客户代号',
+          align: 'center',
+          width: 120,
+          showOverflowTooltip: true
+        },
+        {
+          columnKey: 'status',
+          label: '状态',
+          align: 'center',
+          slot: 'status',
+          action: 'status',
+          width: 120,
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'approvalStatus',
+          label: '审批状态',
+          align: 'center',
+          slot: 'approvalStatus',
+          action: 'approvalStatus',
+          width: 120,
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'orderType',
+          label: '来源类型',
+          align: 'center',
+          slot: 'orderType',
+          action: 'orderType',
+          width: 120,
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'createUserName',
+          label: '创建人',
+          align: 'center',
+          width: 120,
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'createTime',
+          label: '创建时间',
+          align: 'center',
+          width: 120,
+          showOverflowTooltip: true
+        },
+        {
+          columnKey: 'action',
+          label: '操作',
+          width: 250,
+          align: 'center',
+          resizable: false,
+          fixed: 'right',
+          slot: 'action'
+        }
+      ];
+    }
+  },
+  methods: {
+    statusFormatter(status) {
+      const obj = this.statusOpt[this.activeName].find(
+        (i) => i.value == status
+      );
+
+      return obj && obj.label;
     },
-    methods: {
-      statusFormatter(status) {
-        const obj = this.statusOpt[this.activeName].find(
-          (i) => i.value == status
-        );
 
-        return obj && obj.label;
-      },
+    approvalStatusFormatter(status) {
+      const obj = this.approvalStatusOpt[this.activeName].find(
+        (i) => i.value == status
+      );
 
-      approvalStatusFormatter(status) {
-        const obj = this.approvalStatusOpt[this.activeName].find(
-          (i) => i.value == status
-        );
+      return obj && obj.label;
+    },
+    reload(where = {}) {
+      if (where.statusList) {
+        where.statusList = where.statusList.split(',');
+      }
+      this.$nextTick(() => {
+        this.$refs.table11.reload({ page: 1, where });
+      });
+    },
+    /* 表格数据源 */
+    datasource({ page, limit, where }) {
+      where.type = 1;
+      return getList({
+        pageNum: page,
+        size: limit,
+        ...where
+      });
+    },
+    handleClick(tab) {
+      if (tab == 1) {
+        this.$refs.planEditDialogRef.open('add');
+      } else if (tab == 2) {
+        this.$refs.produceRef.open('add');
+      }
+    },
+    handleDetails(row) {
+      if (row.status == 0) {
+        this.$message.info('未提交没有审核流程');
+      } else {
+        this.$refs.detailRef.open(row.processInstanceId);
+      }
+    },
+    handleEdit(type, row) {
+      if (row.orderType == 1) {
+        this.$refs.planEditDialogRef.open(type, row);
+      } else if (row.orderType == 2) {
+        this.$refs.produceRef.open(type, row);
+      }
+    },
+    handleDel({ id }) {
+      this.$confirm('确认删除当前数据!', '提示').then(async () => {
+        await del([id]);
+        this.$message.success('删除成功!');
+        this.reload();
+      });
+    },
 
-        return obj && obj.label;
-      },
-      reload(where = {}) {
-        if (where.statusList) {
-          where.statusList = where.statusList.split(',');
-        }
-        this.$nextTick(() => {
-          this.$refs.table11.reload({ page: 1, where });
-        });
-      },
-      /* 表格数据源 */
-      datasource({ page, limit, where }) {
-        where.type = 1;
-        return getList({
-          pageNum: page,
-          size: limit,
-          ...where
-        });
-      },
-      handleClick(tab) {
-        if (tab == 1) {
-          this.$refs.planEditDialogRef.open('add');
-        } else if (tab == 2) {
-          this.$refs.produceRef.open('add');
-        }
-      },
-      handleDetails(row) {
-        if (row.status == 0) {
-          this.$message.info('未提交没有审核流程');
-        } else {
-          this.$refs.detailRef.open(row.processInstanceId);
-        }
-      },
-      handleEdit(type, row) {
-        if (row.orderType == 1) {
-          this.$refs.planEditDialogRef.open(type, row);
-        } else if (row.orderType == 2) {
-          this.$refs.produceRef.open(type, row);
-        }
-      },
-      handleDel({ id }) {
-        this.$confirm('确认删除当前数据!', '提示').then(async () => {
-          await del([id]);
-          this.$message.success('删除成功!');
+    todo(row) {
+      submit({ businessId: row.id }).then((res) => {
+        if (res) {
+          this.$message.success('提交成功!');
           this.reload();
-        });
-      },
-
-      todo(row) {
-        submit({ businessId: row.id }).then((res) => {
-          if (res) {
-            this.$message.success('提交成功!');
-            this.reload();
-          }
-        });
-      }
+        }
+      });
     }
-  };
+  }
+};
 </script>
 
 <style lang="scss" scoped></style>

+ 162 - 160
src/views/materialPlan/components/plan-edit-dialog.vue

@@ -41,12 +41,11 @@
           <el-input placeholder="请输入" readonly :value="row.code || row.salesOrderCode"></el-input>
         </template>
 
-        <template v-slot:versions="{ row }">
-          <!-- <el-link type="primary" v-if="!row.productionPlanId" :underline="false" @click.native="openVersion(row)"
-            :disabled="type == 'detail'">选择</el-link> -->
-          <el-select v-model="row.versions" placeholder="请选择" style="width: 100%" :disabled="type == 'detail'"
+        <template v-slot:bomId="{ row }">
+          <el-select v-model="row.bomId" placeholder="请选择" style="width: 100%" :disabled="type == 'detail'"
             @change="changeVersions(row)">
-            <el-option v-for="item in row.bomCategoryList" :key="item.id" :label="item.versions" :value="item.id">
+            <el-option v-for="item in row.bomCategoryList" :key="item.id" :label="'V' + item.versions + '.0'"
+              :value="item.id">
             </el-option>
           </el-select>
 
@@ -70,7 +69,7 @@
         <!-- 展开内容 -->
         <template v-slot:expand="{ row, $index }">
           <div class="batch-actions" v-if="row.materialList.length > 0">
-            <!-- <el-button @click="batchUpdateDeliveryMethod">批量修改到货方式</el-button> -->
+            <el-button @click="batchUpdateDeliveryMethod">批量修改到货方式</el-button>
           </div>
           <div style="
               width: calc(100% - 95px);
@@ -181,7 +180,6 @@
         <el-form-item label="到货方式" prop="deliveryMethod">
           <el-select clearable v-model="formData2.deliveryMethod" placeholder="请选择">
             <el-option label="一次性到货" :value="1" />
-            <!-- <el-option label="分批到货" :value="2"   /> -->
             <el-option label="分批到货" :value="2" @click.native="
               handleMethod();
 
@@ -237,7 +235,8 @@ export default {
     return {
       formData2: {
         deliveryMethod: 1,
-        requireDeliveryTime: ''
+        requireDeliveryTime: '',
+        timeList: []
       },
       batchVisible: false,
       multipleSelection: [],
@@ -386,9 +385,9 @@ export default {
         },
 
         {
-          prop: 'versions',
+          prop: 'bomId',
           label: '选择BOM版本',
-          slot: 'versions',
+          slot: 'bomId',
           align: 'center',
           minWidth: 110
         },
@@ -406,6 +405,7 @@ export default {
       ].filter(Boolean);
       return list;
     },
+
     columns2() {
       const list = [
         {
@@ -462,7 +462,31 @@ export default {
           label: '库存',
           showOverflowTooltip: true
         },
-
+        {
+          prop: 'secureInventory',
+          label: '安全库存',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'lockQuantity',
+          label: '锁库数量',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'inTransitNum',
+          label: '在途数量',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'inTransitOrdersNum',
+          label: '在途已关联数量',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'availableQuantity',
+          label: '可用数量',
+          showOverflowTooltip: true
+        },
         {
           prop: 'unit',
           label: '计量单位',
@@ -529,7 +553,7 @@ export default {
           ? {
             columnKey: 'action',
             label: '操作',
-            width: 70,
+            width: 80,
             align: 'center',
             resizable: false,
             slot: 'action',
@@ -544,49 +568,6 @@ export default {
   created() { },
 
   methods: {
-    // 处理表格选中行的变化
-    handleSelectionChange(selection) {
-      console.log(selection, 'sssssssselectionsssssss');
-      this.multipleSelection = selection;
-    },
-    handleCancel() {
-      this.batchVisible = false
-    },
-    handleConfirm() {
-      const { deliveryMethod, requireDeliveryTime } = this.formData2;
-      const tableData = this.$refs.table.getData();
-      tableData.forEach((item) => {
-        item.materialList.forEach((m) => {
-          if (this.multipleSelection.some((selected) => selected.categoryId === m.categoryId)) {
-            this.$set(m, 'deliveryMethod', deliveryMethod)
-            if (deliveryMethod === 1) {
-              this.$set(m, 'requireDeliveryTime', requireDeliveryTime)
-              this.$set(m, 'timeList', null)
-            } else if (deliveryMethod === 2) {
-              this.$set(m, 'requireDeliveryTime', null)
-              console.log(m, 'm')
-              // this.handleMethod(m);
-            }
-          }
-        });
-      });
-      this.$refs.table.setData([...tableData]);
-      this.$forceUpdate();
-      this.batchVisible = false;
-
-    },
-    // 批量修改到货方式
-    batchUpdateDeliveryMethod() {
-      if (this.multipleSelection.length === 0) {
-        this.$message.warning('请选择要修改的行');
-        return;
-      }
-      this.formData2 = {
-        deliveryMethod: 1,
-        requireDeliveryTime: ''
-      };
-      this.batchVisible = true;
-    },
     async open(type, row) {
       this.type = type;
       if (type == 'add') {
@@ -606,7 +587,6 @@ export default {
         });
       }
     },
-
     getDetail(id) {
       getById(id).then((res) => {
         this.$set(this.formData, 'demandType', res.demandType);
@@ -629,82 +609,10 @@ export default {
       });
     },
 
-    confirm() {
-      this.$refs.formRef.validate(async (value) => {
-        if (value) {
-          let _arr = this.$refs.table.getData() ?? [];
-
-          if (_arr.length == 0) {
-            this.$message.info('请添加销售订单');
-            return false;
-          }
-          let _arr2 = [];
-
-          _arr2 = _arr.map((m) => {
-            if (
-              Object.prototype.hasOwnProperty.call(m, 'salesOrderId') &&
-              m.salesOrderId
-            ) {
-            } else {
-              m.salesOrderId = m.id;
-              m.salesOrderCode = m.code;
-              delete m.id;
-              delete m.code;
-            }
-
-            return {
-              ...m
-            };
-          });
-
-          this.formData['type'] = 1;
-          this.formData['salesOrderList'] = _arr2;
-          this.formData.baitingType = 2;
-          await save(this.formData);
-          this.$message.success('保存成功!');
-          this.$emit('success');
-          this.cancel();
-        }
-      });
-    },
-    cancel() {
-      this.visible = false;
-      this.formData = {};
-      this.formData.detailRemoveIds = [];
-      this.formData.materialRemoveIds = [];
-      this.$refs.table.setData([]);
-      this.$refs.formRef.resetFields();
-    },
-
-    datasource({ }) {
-      return [];
-    },
-
-    reload() {
-      this.$refs.table.reload();
-    },
-
     saleAdd() {
       this.tableData = this.$refs.table.getData();
       this.$refs.saleOrderRef.open(this.tableData);
     },
-
-    produceAdd() { },
-    changeVersions(row) {
-      console.log(row, 'row')
-      listBomByBomVersionId({ bomId: row.bomId, contractNum: row.contractNum, demandType: this.formData.demandType }).then(
-        (res) => {
-
-          console.log(res, 'res')
-
-          row.materialList = res;
-          // this.$nextTick(() => {
-          //   this.$refs.table.toggleRowExpansionAll();
-          //   this.$forceUpdate();
-          // });
-        }
-      );
-    },
     chooseOrder(list) {
       let salesOrderIds = [];
       list.map((m) => {
@@ -737,17 +645,15 @@ export default {
       }
     },
 
+    categorySelect(row) {
+      this.$refs.productRefs.open(row.materialList, row, this.type);
+    },
     remove(row, index) {
       this.formData.detailRemoveIds.push(row.id);
       let _arr = this.$refs.table.getData() || [];
       _arr.splice(index, 1);
       this.$refs.table.setData([..._arr]);
     },
-
-    categorySelect(row) {
-      this.$refs.productRefs.open(row.materialList, row, this.type);
-    },
-
     chooseModal(data, current) {
       data.map((m) => {
         m.detailId = current.id;
@@ -789,7 +695,21 @@ export default {
       this.$refs.table.setData([...data]);
       this.$forceUpdate();
     },
+    changeVersions(row) {
+      console.log(row, 'row')
+      listBomByBomVersionId({ bomId: row.bomId, contractNum: row.contractNum, demandType: this.formData.demandType }).then(
+        (res) => {
+          console.log(res, 'res')
 
+          row.materialList = res || [];
+          // this.$nextTick(() => {
+          //   this.$refs.table.toggleRowExpansionAll();
+          //   this.$forceUpdate();
+          // });
+        }
+      );
+    },
+    //选择工艺路线
     openVersion(row) {
       this.xsId = row.id;
       this.$refs.versionRefs.open();
@@ -826,7 +746,55 @@ export default {
           });
       });
     },
+    // ---------------------------
 
+    // 批量修改到货方式
+    batchUpdateDeliveryMethod() {
+      if (this.multipleSelection.length === 0) {
+        this.$message.warning('请选择要修改的行');
+        return;
+      }
+      this.formData2 = {
+        deliveryMethod: 1,
+        requireDeliveryTime: '',
+        timeList: []
+      };
+      this.batchVisible = true;
+    },
+    // 处理表格选中行的变化
+    handleSelectionChange(selection) {
+      console.log(selection, 'sssssssselectionsssssss');
+      this.multipleSelection = selection;
+    },
+    handleCancel() {
+      this.batchVisible = false
+    },
+
+    handleConfirm() {
+      const { deliveryMethod, requireDeliveryTime } = this.formData2;
+      const tableData = this.$refs.table.getData();
+
+      // 创建深拷贝的 timeList 模板(假设当前表单中已填写了分批时间)
+      const timeListTemplate = JSON.parse(JSON.stringify(this.formData2.timeList));
+
+      tableData.forEach((item) => {
+        item.materialList.forEach((m) => {
+          if (this.multipleSelection.some((selected) => selected.categoryId === m.categoryId)) {
+            this.$set(m, 'deliveryMethod', deliveryMethod);
+            if (deliveryMethod === 1) {
+              //一次性到货逻辑
+              this.$set(m, 'requireDeliveryTime', requireDeliveryTime)
+              this.$set(m, 'timeList', null)
+            } else if (deliveryMethod === 2) {
+              this.$set(m, 'timeList', JSON.parse(JSON.stringify(timeListTemplate)));
+            }
+          }
+        });
+      });
+
+      this.$refs.table.setData([...tableData]);
+      this.batchVisible = false;
+    },
     handleMethod(row, index) {
       console.log(index, 'index')
       if (row) {
@@ -835,47 +803,81 @@ export default {
       this.$refs.timeDialogRef.open(row || {}, index);
 
     },
+
     chooseTime(current, timeList, currentIndex) {
       const tableList = this.$refs.table.getData();
 
-      // 单条
       if (current && current.categoryId) {
-        console.log(current, 'rrrrrrrrrrrr22222222', currentIndex)
-        console.log(timeList, 'rrrrrrrrrrrr3333333')
-
-        this.$set(current, 'deliveryMethod', this.formData2.deliveryMethod)
-
-        for (const item of tableList) {
+        // 单独修改逻辑:直接操作当前物料的 timeList
+        tableList.forEach(item => {
           if (item.id === current.detailId) {
-            this.$set(item.materialList[currentIndex], 'timeList', timeList)
-
-            // const material = item.materialList.find(m => m.categoryId === current.categoryId);
-            // console.log(material, 'rrrrrrrrrrrr11111111')
-            // if (material && currentIndex) {
-            //   // this.$set(tableList, 'timeList', timeList);
-            //   break;
-            // }
+            const material = item.materialList[currentIndex];
+
+            this.$set(material, 'timeList', JSON.parse(JSON.stringify(timeList)));
           }
-        }
-      }
-      // 批量
-      else if (this.multipleSelection.length > 0) {
-        for (const item of tableList) {
+        });
+      } else if (this.multipleSelection.length > 0) {
+        // 批量修改逻辑
+        tableList.forEach(item => {
           item.materialList.forEach(material => {
             if (this.multipleSelection.some(selected => selected.categoryId === material.categoryId)) {
-              console.log('找到了匹配的元素', material)
               this.$set(material, 'deliveryMethod', this.formData2.deliveryMethod)
-              this.$set(material, 'timeList', timeList);
+              this.$set(material, 'timeList', JSON.parse(JSON.stringify(timeList)));
             }
           });
-        }
+        });
         this.$refs.timeDialogRef.handleClose()
         this.batchVisible = false;
       }
-      this.$refs.table.setData([...tableList]); // 强制更新表格
-      this.$forceUpdate();
-      console.log(this.$refs.table.getData()); // 打印更新后的表格数据
-    }
+
+      this.$refs.table.setData([...tableList]);
+    },
+    confirm() {
+      this.$refs.formRef.validate(async (value) => {
+        if (value) {
+          let _arr = this.$refs.table.getData() ?? [];
+
+          if (_arr.length == 0) {
+            this.$message.info('请添加销售订单');
+            return false;
+          }
+          let _arr2 = [];
+
+          _arr2 = _arr.map((m) => {
+            if (
+              Object.prototype.hasOwnProperty.call(m, 'salesOrderId') &&
+              m.salesOrderId
+            ) {
+            } else {
+              m.salesOrderId = m.id;
+              m.salesOrderCode = m.code;
+              delete m.id;
+              delete m.code;
+            }
+
+            return {
+              ...m
+            };
+          });
+
+          this.formData['type'] = 1;
+          this.formData['salesOrderList'] = _arr2;
+          this.formData.baitingType = 2;
+          await save(this.formData);
+          this.$message.success('保存成功!');
+          this.$emit('success');
+          this.cancel();
+        }
+      });
+    },
+    cancel() {
+      this.visible = false;
+      this.formData = {};
+      this.formData.detailRemoveIds = [];
+      this.formData.materialRemoveIds = [];
+      this.$refs.table.setData([]);
+      this.$refs.formRef.resetFields();
+    },
   }
 };
 </script>

+ 703 - 699
src/views/materialPlan/components/producePlan.vue

@@ -1,36 +1,14 @@
 <template>
-  <ele-modal
-    :visible.sync="visible"
-    :closed="cancel"
-    :title="`${type == 'add' ? '创建' : '编辑'}采购计划`"
-    custom-class="ele-dialog-form"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    width="80%"
-    :maxable="true"
-  >
-    <el-form
-      :model="formData"
-      ref="formRef"
-      label-width="120px"
-      class="ele-body"
-      :rules="rules"
-    >
+  <ele-modal :visible.sync="visible" :closed="cancel" :title="`${type == 'add' ? '创建' : '编辑'}采购计划`"
+    custom-class="ele-dialog-form" :close-on-click-modal="false" :close-on-press-escape="false" width="80%"
+    :maxable="true">
+    <el-form :model="formData" ref="formRef" label-width="120px" class="ele-body" :rules="rules">
       <el-row :gutter="24">
         <el-col :span="8">
           <el-form-item label="需求类型" prop="demandType">
-            <el-select
-              v-model="formData.demandType"
-              placeholder="请选择"
-              style="width: 100%"
-              :disabled="type == 'detail'"
-            >
-              <el-option
-                v-for="item in demandTypeList"
-                :key="item.dictCode"
-                :label="item.dictValue"
-                :value="item.dictCode"
-              >
+            <el-select v-model="formData.demandType" placeholder="请选择" style="width: 100%" :disabled="type == 'detail'">
+              <el-option v-for="item in demandTypeList" :key="item.dictCode" :label="item.dictValue"
+                :value="item.dictCode">
               </el-option>
             </el-select>
           </el-form-item>
@@ -38,79 +16,47 @@
 
         <el-col :span="8">
           <el-form-item label="计划名称" prop="name">
-            <el-input
-              placeholder="请选择"
-              v-model="formData.name"
-              :readonly="type == 'detail'"
-            ></el-input>
+            <el-input placeholder="请选择" v-model="formData.name" :readonly="type == 'detail'"></el-input>
           </el-form-item>
         </el-col>
 
         <el-col :span="8">
           <el-form-item label="备注" prop="remark">
-            <el-input
-              placeholder="备注"
-              v-model="formData.remark"
-              :readonly="type == 'detail'"
-            ></el-input>
+            <el-input placeholder="备注" v-model="formData.remark" :readonly="type == 'detail'"></el-input>
           </el-form-item>
         </el-col>
       </el-row>
     </el-form>
 
     <el-form :model="formData" ref="tableForm">
-      <ele-pro-table
-        ref="table"
-        :needPage="false"
-        :columns="columns"
-        row-key="id"
-      >
+      <ele-pro-table ref="table" :needPage="false" :columns="columns" row-key="id">
         <template v-slot:toolbar>
-          <el-button
-            size="small"
-            type="primary"
-            icon="el-icon-plus"
-            class="ele-btn-icon"
-            @click="produceAdd"
-            v-if="type != 'detail'"
-          >
+          <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="produceAdd"
+            v-if="type != 'detail'">
             添加生产计划
           </el-button>
         </template>
 
         <template v-slot:code="{ row }">
-          <el-input
-            placeholder="请输入"
-            readonly
-            :value="row.code || row.salesOrderCode"
-          ></el-input>
+          <el-input placeholder="请输入" readonly :value="row.code || row.salesOrderCode"></el-input>
         </template>
 
-        <template v-slot:productionPlanId="{ row }">
-          <el-link
-            type="primary"
-            v-if="!row.productionPlanId"
-            :underline="false"
-            @click.native="openVersion(row)"
-            :disabled="type == 'detail'"
-            >选择</el-link
-          >
+        <template v-slot:bomId="{ row }">
+          <el-select v-model="row.bomId" placeholder="请选择" style="width: 100%" :disabled="type == 'detail'"
+            @change="changeVersions(row)">
+            <el-option v-for="item in row.bomCategoryList" :key="item.id" :label="'V' + item.versions + '.0'"
+              :value="item.id">
+            </el-option>
+          </el-select>
+
         </template>
 
         <template v-slot:action="{ row, $index }" v-if="type != 'detail'">
           <template>
-            <el-link
-              type="primary"
-              :underline="false"
-              @click="categorySelect(row)"
-            >
+            <el-link type="primary" :underline="false" @click="categorySelect(row)">
               添加物料
             </el-link>
-            <el-popconfirm
-              class="ele-action"
-              title="确定要删除此销售订单吗?"
-              @confirm="remove(row, $index)"
-            >
+            <el-popconfirm class="ele-action" title="确定要删除此生产计划吗?" @confirm="remove(row, $index)">
               <template v-slot:reference>
                 <el-link type="danger" :underline="false" icon="el-icon-delete">
                   删除
@@ -122,25 +68,20 @@
 
         <!-- 展开内容 -->
         <template v-slot:expand="{ row, $index }">
-          <div
-            style="
+          <div class="batch-actions" v-if="row.materialList.length > 0">
+            <el-button @click="batchUpdateDeliveryMethod">批量修改到货方式</el-button>
+          </div>
+
+          <div style="
               width: calc(100% - 95px);
               min-height: 60px;
               margin-left: 95px;
-            "
-            v-if="row.materialList.length > 0"
-          >
-            <ele-pro-table
-              :toolbar="false"
-              toolsTheme="none"
-              ref="table2"
-              :need-page="false"
-              :datasource="row.materialList"
-              :columns="columns2"
-              :key="row.categoryId + '-' + $index"
-            >
+            " v-if="row.materialList.length > 0">
+            <ele-pro-table :toolbar="false" toolsTheme="none" ref="table2" :need-page="false"
+              :datasource="row.materialList" :columns="columns2" :key="row.categoryId + '-' + $index"
+              @selection-change="handleSelectionChange">
               <template v-slot:sort="{ $index }">
-                {{ $index }}
+                {{ $index + 1 }}
               </template>
 
               <template v-slot:unit="{ row }">
@@ -150,141 +91,70 @@
               <template v-slot:demandQuantity="{ row }">
                 <div>
                   <!-- 需求数量 -->
-                <el-input
-                  v-model="row.demandQuantity"
-                  placeholder="请输入"
-                  :readonly="type == 'detail'"
-                  @input="
+                  <el-input v-model="row.demandQuantity" placeholder="请输入" :readonly="type == 'detail'" @input="
                     (value) =>
-                      (row.demandQuantity = value.replace(
-                        /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
-                        '$1$2.$3'
-                      ))
-                  "
-                ></el-input>
+                    (row.demandQuantity = value.replace(
+                      /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
+                      '$1$2.$3'
+                    ))
+                  "></el-input>
                 </div>
-               
               </template>
-              <!-- <template v-slot:purchasingCycle="{ row }">
-                 <el-input
-                  v-model="row.purchasingCycle"
-                  placeholder="请输入"
-                  :readonly="type == 'detail'"
-                  @input="
-                    (value) =>
-                      (row.purchasingCycle = value.replace(
-                        /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
-                        '$1$2.$3'
-                      ))
-                  "
-                >
-                  <template slot="append" v-if="row.purchasingCycle">
-                    {{ row.purchasingCycleUnit }}
-                  </template>
-                </el-input>
-              </template> -->
+
               <template v-slot:purchasingCycle="{ row }">
                 {{ row.purchasingCycle }}{{ row.purchasingCycleUnit }}
               </template>
               <template v-slot:purchaseQuantity="{ row }">
-                <el-input
-                  v-model="row.purchaseQuantity"
-                  placeholder="请输入"
-                  :readonly="type == 'detail'"
-                  @input="
-                    (value) =>
-                      (row.purchaseQuantity = value.replace(
-                        /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
-                        '$1$2.$3'
-                      ))
-                  "
-                ></el-input>
+                <el-input v-model="row.purchaseQuantity" placeholder="请输入" :readonly="type == 'detail'" @input="
+                  (value) =>
+                  (row.purchaseQuantity = value.replace(
+                    /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
+                    '$1$2.$3'
+                  ))
+                "></el-input>
               </template>
 
-              <template v-slot:deliveryMethod="{ row }">
-                <el-select
-                  clearable
-                  class="ele-block"
-                  v-model="row.deliveryMethod"
-                  placeholder="请选择"
-                  :disabled="type == 'detail'"
-                >
-                  <el-option
-                    label="一次性到货"
-                    :value="1"
-                    @click.native="row.timeList = null"
-                  />
-                  <el-option
-                    label="分批到货"
-                    :value="2"
-                    @click.native="
-                      handleMethod(row);
-                      row.requireDeliveryTime = null;
-                    "
-                  />
+              <template v-slot:deliveryMethod="{ row, $index }">
+                <el-select clearable class="ele-block" v-model="row.deliveryMethod" placeholder="请选择"
+                  :disabled="type == 'detail'">
+                  <el-option label="一次性到货" :value="1" @click.native="row.timeList = null" />
+                  <el-option label="分批到货" :value="2" @click.native="
+                    handleMethod(row, $index);
+                  row.requireDeliveryTime = null;
+                  " />
                 </el-select>
               </template>
 
-              <template v-slot:requireDeliveryTime="{ row }">
-                <el-date-picker
-                  style="width: 100%"
-                  clearable
-                  v-model="row.requireDeliveryTime"
-                  type="date"
-                  v-if="row.deliveryMethod == 1"
-                  value-format="yyyy-MM-dd"
-                  placeholder="请选择日期"
-                  :readonly="type == 'detail'"
-                  :pickerOptions="{
+              <template v-slot:requireDeliveryTime="{ row, $index }">
+                <el-date-picker style="width: 100%" clearable v-model="row.requireDeliveryTime" type="date"
+                  v-if="row.deliveryMethod == 1" value-format="yyyy-MM-dd" placeholder="请选择日期"
+                  :readonly="type == 'detail'" :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-if="row.deliveryMethod == 2"
-                  @click.native="handleMethod(row)"
-                >
+                <el-link type="primary" :underline="false" v-if="row.deliveryMethod == 2"
+                  @click.native="handleMethod(row, $index)">
                   设置分批时间
                 </el-link>
               </template>
 
               <template v-slot:imgUrl="{ row }">
-                <fileUpload
-                  v-model="row.imgUrl"
-                  module="main"
-                  :showLib="false"
-                  :limit="1"
-                  :disabled="type == 'detail'"
-                />
+                <fileUpload v-model="row.imgUrl" module="main" :showLib="false" :limit="1"
+                  :disabled="type == 'detail'" />
               </template>
 
               <template v-slot:files="{ row }">
-                <fileUpload
-                  v-model="row.files"
-                  module="main"
-                  :showLib="false"
-                  :limit="1"
-                  :disabled="type == 'detail'"
-                />
+                <fileUpload v-model="row.files" module="main" :showLib="false" :limit="1"
+                  :disabled="type == 'detail'" />
               </template>
 
               <template v-slot:action="{ row }" v-if="type != 'detail'">
-                <el-popconfirm
-                  class="ele-action"
-                  title="确定要删除当前物料吗?"
-                  @confirm="remove2(row)"
-                >
+                <el-popconfirm class="ele-action" title="确定要删除当前物料吗?" @confirm="remove2(row)">
                   <template v-slot:reference>
-                    <el-link
-                      type="danger"
-                      :underline="false"
-                      icon="el-icon-delete"
-                    >
+                    <el-link type="danger" :underline="false" icon="el-icon-delete">
                       删除
                     </el-link>
                   </template>
@@ -301,574 +171,708 @@
       <el-button type="primary" @click="confirm">保存</el-button>
     </div>
 
-    <produceOrder
-      ref="produceOrderRef"
-      @chooseOrder="chooseOrder"
-    ></produceOrder>
+    <produceOrder ref="produceOrderRef" @chooseOrder="chooseOrder"></produceOrder>
 
     <ProductModal ref="productRefs" @chooseModal="chooseModal" />
 
-    <ProductionVersion
-      ref="versionRefs"
-      @changeProduct="changeProduct"
-    ></ProductionVersion>
+    <ProductionVersion ref="versionRefs" @changeProduct="changeProduct"></ProductionVersion>
 
     <timeDialog ref="timeDialogRef" @chooseTime="chooseTime"></timeDialog>
+
+    <ele-modal :visible.sync="batchVisible" title="批量选择" width="25vw" append-to-body @close="handleCancel"
+      :maxable="true">
+      <el-form :model="formData2" label-width="100px">
+        <el-form-item label="到货方式" prop="deliveryMethod">
+          <el-select clearable v-model="formData2.deliveryMethod" placeholder="请选择">
+            <el-option label="一次性到货" :value="1" />
+            <el-option label="分批到货" :value="2" @click.native="
+              handleMethod();
+            " />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="要求到货时间" prop="requireDeliveryTime">
+          <el-date-picker clearable v-model="formData2.requireDeliveryTime" type="date"
+            v-show="formData2.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="formData2.deliveryMethod == 2"
+            @click.native="handleMethod()">
+            设置分批时间
+          </el-link>
+        </el-form-item>
+      </el-form>
+      <template v-slot:footer>
+        <el-button @click="handleCancel">取消</el-button>
+        <el-button type="primary" @click="handleConfirm">确认</el-button>
+      </template>
+    </ele-modal>
+
   </ele-modal>
 </template>
 
 <script>
-  import produceOrder from './produceOrder.vue';
-  import ProductModal from './ProductModal.vue';
-  import {
-    listBomByPlanIdsOverride,
-    listBomBySalesOrderId,
-    save,
-    getById
-  } from '@/api/materialPlan/index';
-  import ProductionVersion from '@/components/CreatePlan/ProductionVersion2.vue';
-  import fileUpload from '@/components/upload/fileUpload';
-  import timeDialog from './timeDialog';
-  import dictMixins from '@/mixins/dictMixins';
-  export default {
-    components: {
-      produceOrder,
-      ProductModal,
-      ProductionVersion,
-      fileUpload,
-      timeDialog
-    },
-    mixins: [dictMixins],
-    data() {
-      return {
-        visible: false,
-        type: 'add',
-
-        tableData: [],
-
-        xsId: null,
-        rules: {
-          demandType: [
-            {
-              required: true,
-              message: '请选择需求类型',
-              trigger: ['blur', 'change']
-            }
-          ],
-          name: [
-            {
-              required: true,
-              message: '请输入配料计划名称',
-              trigger: ['blur', 'change']
-            }
-          ]
+import produceOrder from './produceOrder.vue';
+import ProductModal from './ProductModal.vue';
+import {
+  listBomByPlanIdsOverride,
+  listBomBySalesOrderId,
+  listBomByBomVersionId,
+  save,
+  getById
+} from '@/api/materialPlan/index';
+import ProductionVersion from '@/components/CreatePlan/ProductionVersion2.vue';
+import fileUpload from '@/components/upload/fileUpload';
+import timeDialog from './timeDialog';
+import dictMixins from '@/mixins/dictMixins';
+export default {
+  components: {
+    produceOrder,
+    ProductModal,
+    ProductionVersion,
+    fileUpload,
+    timeDialog
+  },
+  mixins: [dictMixins],
+  data() {
+    return {
+      formData2: {
+        deliveryMethod: 1,
+        requireDeliveryTime: '',
+        timeList: []
+      },
+      batchVisible: false,
+      multipleSelection: [],
+      visible: false,
+      type: 'add',
+
+      tableData: [],
+
+      xsId: null,
+      formData: {
+        demandType: '1',
+        name: '',
+        remark: '',
+        detailRemoveIds: [],
+        materialRemoveIds: [],
+        orderType: 2
+      },
+      demandTypeList: [
+        {
+          dictCode: '1',
+          dictValue: '生产性物资采购'
         },
-        formData: {
-          demandType: '1',
-          name: '',
-          remark: '',
-          detailRemoveIds: [],
-          materialRemoveIds: [],
-          orderType: 2
+        {
+          dictCode: '6',
+          dictValue: '外协自供料采购'
         },
-
-        demandTypeList: [
-          {
-            dictCode: '1',
-            dictValue: '生产性物资采购'
-          },
+        {
+          dictCode: '7',
+          dictValue: '外协客供料采购'
+        }
+      ],
+      expandedRowKeys: [],
+      rules: {
+        demandType: [
           {
-            dictCode: '6',
-            dictValue: '外协自供料采购'
-          },
+            required: true,
+            message: '请选择需求类型',
+            trigger: ['blur', 'change']
+          }
+        ],
+        name: [
           {
-            dictCode: '7',
-            dictValue: '外协客供料采购'
+            required: true,
+            message: '请输入配料计划名称',
+            trigger: ['blur', 'change']
           }
         ]
-      };
-    },
-    computed: {
-      // 表格列配置
-      columns() {
-        const list = [
-          {
-            width: 45,
-            type: 'expand',
-            columnKey: 'materialList',
-            align: 'center',
-            slot: 'expand'
-          },
-
-          {
-            width: 50,
-            label: '序号',
-            type: 'index',
-            align: 'center',
-            slot: 'index'
-          },
+      },
+    };
+  },
+  computed: {
+    // 表格列配置
+    columns() {
+      const list = [
+        {
+          width: 45,
+          type: 'expand',
+          columnKey: 'materialList',
+          align: 'center',
+          slot: 'expand'
+        },
 
-          {
-            prop: 'code',
-            label: '销售订单号',
-            slot: 'code',
-            showOverflowTooltip: true,
-            align: 'center',
-            minWidth: 170,
-            sortable: true
-          },
-          {
-            prop: 'customerName',
-            label: '客户名称',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'deliveryNum',
-            label: '客户代号',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'productCode',
-            label: '编码',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 140
-          },
+        {
+          width: 50,
+          label: '序号',
+          type: 'index',
+          align: 'center',
+          slot: 'index'
+        },
+        // {
+        //   prop: 'purchaseType',
+        //   label: '采购类型',
+        //   align: 'center',
+        //   showOverflowTooltip: true,
+        //   minWidth: 120,
+        //   sortable: true,
+        //   formatter: (row) => {
+        //     return row.purchaseType == '1' ? '未采购' : '已采购';
+        //   }
+        // },
+        {
+          prop: 'code',
+          label: '销售订单号',
+          slot: 'code',
+          showOverflowTooltip: true,
+          align: 'center',
+          minWidth: 170,
+          sortable: true
+        },
+        {
+          prop: 'customerName',
+          label: '客户名称',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'deliveryNum',
+          label: '客户代号',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'productCode',
+          label: '编码',
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 140
+        },
 
-          {
-            prop: 'productName',
-            label: '名称',
-            align: 'center',
-            minWidth: 120
-          },
+        {
+          prop: 'productName',
+          label: '名称',
+          align: 'center',
+          minWidth: 120
+        },
 
-          {
-            prop: 'model',
-            label: '型号',
-            align: 'center',
-            minWidth: 120
-          },
+        {
+          prop: 'model',
+          label: '型号',
+          align: 'center',
+          minWidth: 120
+        },
 
-          {
-            prop: 'brandNo',
-            label: '牌号',
-            align: 'center'
-          },
+        {
+          prop: 'brandNo',
+          label: '牌号',
+          align: 'center'
+        },
 
-          {
-            prop: 'deliveryTime',
-            label: '交付日期',
+        {
+          prop: 'deliveryTime',
+          label: '交付日期',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'contractNum',
+          label: '订单数量',
+          align: 'center'
+        },
+        {
+          prop: 'lackNum',
+          label: '欠交数量',
+          align: 'center'
+        },
+        {
+          prop: 'bomId',
+          label: '选择BOM版本',
+          slot: 'bomId',
+          align: 'center',
+          minWidth: 110
+        },
+        this.type != 'detail'
+          ? {
+            columnKey: 'action',
+            label: '操作',
+            width: 150,
             align: 'center',
+            resizable: false,
+            slot: 'action',
             showOverflowTooltip: true
-          },
-          {
-            prop: 'contractNum',
-            label: '订单数量',
-            align: 'center'
-          },
-          {
-            prop: 'lackNum',
-            label: '欠交数量',
-            align: 'center'
-          },
-
-          {
-            prop: 'productionPlanId',
-            label: '工艺路线',
-            slot: 'productionPlanId',
-            align: 'center',
-            minWidth: 110
-          },
-          this.type != 'detail'
-            ? {
-                columnKey: 'action',
-                label: '操作',
-                width: 150,
-                align: 'center',
-                resizable: false,
-                slot: 'action',
-                showOverflowTooltip: true
-              }
-            : ''
-        ].filter(Boolean);
-        return list;
-      },
-      columns2() {
-        const list = [
-          {
-            width: 50,
-            label: '序号',
-            prop: 'sort',
-            slot: 'sort',
-            align: 'center'
-          },
-
-          {
-            label: '物料名称',
-            prop: 'name',
-            align: 'center',
-            minWidth: 120
-          },
+          }
+          : ''
+      ].filter(Boolean);
+      return list;
+    },
+    columns2() {
+      const list = [
+        {
+          columnKey: 'selection',
+          type: 'selection',
+          width: 50,
+          align: 'center',
+          fixed: 'left'
+        },
+        {
+          width: 50,
+          label: '序号',
+          prop: 'sort',
+          slot: 'sort',
+          align: 'center'
+        },
 
-          {
-            label: '物料编码',
-            prop: 'code',
-            align: 'center',
-            minWidth: 120
-          },
-          {
-            label: '牌号',
-            prop: 'brandNum',
-            align: 'center'
-          },
-          {
-            prop: 'specification',
-            label: '规格',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          {
-            label: '型号',
-            prop: 'modelType',
-            align: 'center'
-          },
+        {
+          label: '物料名称',
+          prop: 'name',
+          align: 'center',
+          minWidth: 120,
+          fixed: 'left'
+        },
 
-          {
-            prop: 'inventoryQuantity',
-            label: '库存',
-            showOverflowTooltip: true
-          },
+        {
+          label: '物料编码',
+          prop: 'code',
+          align: 'center',
+          minWidth: 120,
+          fixed: 'left'
+        },
+        {
+          label: '牌号',
+          prop: 'brandNum',
+          align: 'center'
+        },
+        {
+          prop: 'specification',
+          label: '规格',
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+        {
+          label: '型号',
+          prop: 'modelType',
+          align: 'center'
+        },
+        {
+          prop: 'inventoryQuantity',
+          label: '库存',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'secureInventory',
+          label: '安全库存',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'lockQuantity',
+          label: '锁库数量',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'inTransitNum',
+          label: '在途数量',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'inTransitOrdersNum',
+          label: '在途已关联数量',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'availableQuantity',
+          label: '可用数量',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'unit',
+          label: '计量单位',
+          showOverflowTooltip: true,
+          action: 'unit',
+          slot: 'unit'
+        },
 
-          {
-            prop: 'unit',
-            label: '计量单位',
-            showOverflowTooltip: true,
-            action: 'unit',
-            slot: 'unit'
-          },
+        {
+          label: '需求数量',
+          slot: 'demandQuantity',
+          action: 'demandQuantity',
+          align: 'center',
+          minWidth: 120
+        },
 
-          {
-            label: '需求数量',
-            slot: 'demandQuantity',
-            action: 'demandQuantity',
-            align: 'center',
-            minWidth: 120
-          },
+        {
+          label: '采购数量',
+          slot: 'purchaseQuantity',
+          action: 'purchaseQuantity',
+          align: 'center',
+          minWidth: 120
+        },
 
-          {
-            label: '采购数量',
-            slot: 'purchaseQuantity',
-            action: 'purchaseQuantity',
-            align: 'center',
-            minWidth: 120
-          },
+        {
+          label: '到货方式',
+          slot: 'deliveryMethod',
+          action: 'deliveryMethod',
+          align: 'center',
+          minWidth: 140
+        },
+        {
+          label: '采购周期',
+          slot: 'purchasingCycle',
+          action: 'purchasingCycle',
+          align: 'center',
+          minWidth: 160
+        },
+        {
+          label: '要求到货时间',
+          slot: 'requireDeliveryTime',
+          action: 'requireDeliveryTime',
+          align: 'center',
+          minWidth: 180
+        },
 
-          {
-            label: '到货方式',
-            slot: 'deliveryMethod',
-            action: 'deliveryMethod',
-            align: 'center',
-            minWidth: 140
-          },
-          {
-            label: '采购周期',
-            slot: 'purchasingCycle',
-            action: 'purchasingCycle',
-            align: 'center',
-            minWidth: 160
-          },
-          {
-            label: '要求到货时间',
-            slot: 'requireDeliveryTime',
-            action: 'requireDeliveryTime',
-            align: 'center',
-            minWidth: 180
-          },
+        {
+          label: '图纸',
+          slot: 'imgUrl',
+          action: ' imgUrl',
+          align: 'center',
+          minWidth: 140
+        },
 
-          {
-            label: '图纸',
-            slot: 'imgUrl',
-            action: ' imgUrl',
-            align: 'center',
-            minWidth: 140
-          },
+        {
+          label: '附件',
+          slot: 'files',
+          action: ' files',
+          align: 'center',
+          minWidth: 140
+        },
 
-          {
-            label: '附件',
-            slot: 'files',
-            action: ' files',
+        this.type != 'detail'
+          ? {
+            columnKey: 'action',
+            label: '操作',
+            width: 70,
             align: 'center',
-            minWidth: 140
-          },
-
-          this.type != 'detail'
-            ? {
-                columnKey: 'action',
-                label: '操作',
-                width: 70,
-                align: 'center',
-                resizable: false,
-                slot: 'action',
-                showOverflowTooltip: true
-              }
-            : ''
-        ].filter(Boolean);
-        return list;
+            resizable: false,
+            slot: 'action',
+            showOverflowTooltip: true
+          }
+          : ''
+      ].filter(Boolean);
+      return list;
+    }
+  },
+  methods: {
+    async open(type, row) {
+      this.type = type;
+      if (type == 'add') {
+        // this.formData.demandType = '';
+        this.formData.name = '';
+        this.formData.remark = '';
+      }
+      this.formData.orderType = 2;
+      this.visible = true;
+
+      if (row) {
+        this.getDetail(row.id);
+      } else {
+        this.$nextTick(() => {
+          this.$refs.table.setData([]);
+        });
       }
     },
-    methods: {
-      async open(type, row) {
-        this.type = type;
-        if (type == 'add') {
-          // this.formData.demandType = '';
-          this.formData.name = '';
-          this.formData.remark = '';
+
+    getDetail(id) {
+      getById(id).then((res) => {
+        this.$set(this.formData, 'demandType', res.demandType);
+        this.$set(this.formData, 'name', res.name);
+        this.$set(this.formData, 'remark', res.remark);
+        this.formData['id'] = res.id;
+        if (res.salesOrderList) {
+          this.$refs.table.setData([...res.salesOrderList]);
+          // 展开所有行
+          this.expandedRowKeys = this.$refs.table
+            .getData()
+            ?.map((item) => item.id);
         }
-        this.formData.orderType = 2;
-        this.visible = true;
 
-        if (row) {
-          this.getDetail(row.id);
-        } else {
-          this.$nextTick(() => {
-            this.$refs.table.setData([]);
+        this.$nextTick(() => {
+          this.$refs.table.toggleRowExpansionAll();
+          this.$forceUpdate();
+        });
+      });
+    },
+    produceAdd() {
+      this.tableData = this.$refs.table.getData();
+      this.$refs.produceOrderRef.open(this.tableData);
+    },
+    chooseOrder(list) {
+      let planIds = [];
+      list.map((m) => {
+        planIds.push(m.id);
+        delete m.id;
+        return {
+          ...m
+        };
+      });
+
+      if (planIds.length > 0) {
+        listBomByPlanIdsOverride({ planIds: planIds }).then((res) => {
+          res.forEach((m) => {
+            if (m.materialList.length > 0) {
+              m.materialList.forEach((p) => {
+                p.detailId = m.id;
+              });
+            }
           });
-        }
-      },
 
-      getDetail(id) {
-        getById(id).then((res) => {
-          this.$set(this.formData, 'demandType', res.demandType);
-          this.$set(this.formData, 'name', res.name);
-          this.$set(this.formData, 'remark', res.remark);
-          this.formData['id'] = res.id;
-          if (res.salesOrderList) {
-            this.$refs.table.setData([...res.salesOrderList]);
-            // 展开所有行
-            this.expandedRowKeys = this.$refs.table
-              .getData()
-              ?.map((item) => item.id);
-          }
+          this.$refs.table.setData([...this.tableData, ...res]);
 
           this.$nextTick(() => {
             this.$refs.table.toggleRowExpansionAll();
             this.$forceUpdate();
           });
         });
-      },
+      }
+    },
+    categorySelect(row) {
+      this.$refs.productRefs.open(row.materialList, row, this.type);
+    },
+    remove(row, index) {
+      this.formData.detailRemoveIds.push(row.id);
+      let _arr = this.$refs.table.getData() || [];
+      _arr.splice(index, 1);
+      this.$refs.table.setData([..._arr]);
+    },
+    chooseModal(data, current) {
+      data.map((m) => {
+        m.detailId = current.id;
+        delete m.id;
+        return {
+          ...m
+        };
+      });
 
-      confirm() {
-        this.$refs.formRef.validate(async (value) => {
-          if (value) {
-            let _arr = this.$refs.table.getData() ?? [];
+      let tableList = [];
+      tableList = this.$refs.table.getData();
 
-            if (_arr.length == 0) {
-              this.$message.info('请添加销售订单');
-              return false;
-            }
-            let _arr2 = [];
-
-            _arr2 = _arr.map((m) => {
-              if (
-                Object.prototype.hasOwnProperty.call(m, 'salesOrderId') &&
-                m.salesOrderId
-              ) {
-              } else {
-                m.salesOrderId = m.id;
-                m.salesOrderCode = m.code;
-                delete m.id;
-                delete m.code;
-              }
-
-              return {
-                ...m
-              };
-            });
-
-            this.formData['type'] = 1;
-            this.formData['salesOrderList'] = _arr2;
-            this.formData.baitingType = 2;
-
-            await save(this.formData);
-            this.$message.success('保存成功!');
-            this.$emit('success');
-            this.cancel();
+      tableList.forEach((e) => {
+        if (e.id == current.id) {
+          if (e.materialList.length == 0) {
+            e.materialList = data;
+          } else {
+            e.materialList = [...e.materialList, ...data];
           }
-        });
-      },
-      cancel() {
-        this.visible = false;
-        this.formData = {};
-        this.formData.detailRemoveIds = [];
-        this.formData.materialRemoveIds = [];
-        this.$refs.table.setData([]);
-        this.$refs.formRef.resetFields();
-      },
+        }
+      });
 
-      datasource({}) {
-        return [];
-      },
+      console.log(tableList);
+      this.$refs.table.setData([...tableList]);
+      this.$forceUpdate();
+    },
+    remove2(row) {
+      const data = this.$refs.table.getData() ?? [];
+      this.formData.materialRemoveIds.push(row.categoryId);
+      data.forEach((e) => {
+        if (row.detailId == e.id) {
+          e.materialList = e.materialList.filter(
+            (d) => d.categoryId !== row.categoryId
+          );
+        }
+      });
 
-      reload() {
-        this.$refs.table.reload();
-      },
+      this.$refs.table.setData([...data]);
+      this.$forceUpdate();
+    },
 
-      produceAdd() {
-        this.tableData = this.$refs.table.getData();
-        this.$refs.produceOrderRef.open(this.tableData);
-      },
+    changeVersions(row) {
+      console.log(row, 'row')
+      listBomByBomVersionId({ bomId: row.bomId, contractNum: row.contractNum, demandType: this.formData.demandType }).then(
+        (res) => {
+          row.materialList = res || [];
+        }
+      );
+    },
 
-      chooseOrder(list) {
-        let planIds = [];
-        list.map((m) => {
-          planIds.push(m.id);
-          delete m.id;
-          return {
-            ...m
-          };
-        });
+    //选择-------------------
+    openVersion(row) {
+      this.xsId = row.id;
+      this.$refs.versionRefs.open();
+    },
+    changeProduct(data) {
+      let param = {
+        salesOrderIds: [this.xsId],
+        produceRoutingId: data.id
+      };
 
-        if (planIds.length > 0) {
-          listBomByPlanIdsOverride({ planIds: planIds }).then((res) => {
-            res.forEach((m) => {
-              if (m.materialList.length > 0) {
-                m.materialList.forEach((p) => {
-                  p.detailId = m.id;
-                });
-              }
-            });
-
-            this.$refs.table.setData([...this.tableData, ...res]);
-
-            this.$nextTick(() => {
-              this.$refs.table.toggleRowExpansionAll();
-              this.$forceUpdate();
-            });
+      listBomBySalesOrderId(param).then((res) => {
+        if (!res) return;
+        const tableList = this.$refs.table.getData();
+
+        tableList
+          .forEach((e) => {
+            if (e.id == this.xsId) {
+              res.map((m) => {
+                m.detailId = this.xsId;
+                return {
+                  ...m
+                };
+              });
+
+              e.materialList = res;
+
+              this.$nextTick(() => {
+                this.$refs.table.setData([...tableList]);
+                this.$refs.table.toggleRowExpansionAll();
+              });
+            }
+          })
+          .catch((error) => {
+            console.error('Failed to change product:', error);
           });
-        }
-      },
+      });
+    },
 
-      remove(row, index) {
-        this.formData.detailRemoveIds.push(row.id);
-        let _arr = this.$refs.table.getData() || [];
-        _arr.splice(index, 1);
-        this.$refs.table.setData([..._arr]);
-      },
+    // 处理表格选中行的变化
+    handleSelectionChange(selection) {
+      this.multipleSelection = selection;
+    },
+    handleCancel() {
+      this.batchVisible = false
+    },
+    batchUpdateDeliveryMethod() {
+      if (this.multipleSelection.length === 0) {
+        this.$message.warning('请选择要修改的行');
+        return;
+      }
+      this.formData2 = {
+        deliveryMethod: 1,
+        requireDeliveryTime: '',
+        timeList: []
+      };
+      this.batchVisible = true;
+    },
+    handleMethod(row, index) {
+      console.log(index, 'index')
+      if (row) {
+        this.multipleSelection = [];
+      }
+      this.$refs.timeDialogRef.open(row || {}, index);
+    },
+    chooseTime(current, timeList, currentIndex) {
+      const tableList = this.$refs.table.getData();
 
-      categorySelect(row) {
-        this.$refs.productRefs.open(row.materialList, row, this.type);
-      },
+      if (current && current.categoryId) {
+        // 单独修改逻辑:直接操作当前物料的 timeList
+        tableList.forEach(item => {
+          if (item.id === current.detailId) {
+            const material = item.materialList[currentIndex];
 
-      chooseModal(data, current) {
-        data.map((m) => {
-          m.detailId = current.id;
-          delete m.id;
-          return {
-            ...m
-          };
+            this.$set(material, 'timeList', JSON.parse(JSON.stringify(timeList)));
+          }
         });
-
-        let tableList = [];
-        tableList = this.$refs.table.getData();
-
-        tableList.forEach((e) => {
-          if (e.id == current.id) {
-            if (e.materialList.length == 0) {
-              e.materialList = data;
-            } else {
-              e.materialList = [...e.materialList, ...data];
+      } else if (this.multipleSelection.length > 0) {
+        // 批量修改逻辑
+        tableList.forEach(item => {
+          item.materialList.forEach(material => {
+            if (this.multipleSelection.some(selected => selected.categoryId === material.categoryId)) {
+              this.$set(material, 'deliveryMethod', this.formData2.deliveryMethod)
+              this.$set(material, 'timeList', JSON.parse(JSON.stringify(timeList)));
             }
-          }
+          });
         });
+        this.$refs.timeDialogRef.handleClose()
+        this.batchVisible = false;
+      }
 
-        console.log(tableList);
-        this.$refs.table.setData([...tableList]);
-        this.$forceUpdate();
-      },
-
-      remove2(row) {
-        const data = this.$refs.table.getData() ?? [];
-        this.formData.materialRemoveIds.push(row.categoryId);
-        data.forEach((e) => {
-          if (row.detailId == e.id) {
-            e.materialList = e.materialList.filter(
-              (d) => d.categoryId !== row.categoryId
-            );
+      this.$refs.table.setData([...tableList]);
+    },
+    handleConfirm() {
+      const { deliveryMethod, requireDeliveryTime } = this.formData2;
+      const tableData = this.$refs.table.getData();
+
+      // 创建深拷贝的 timeList 模板(假设当前表单中已填写了分批时间)
+      const timeListTemplate = JSON.parse(JSON.stringify(this.formData2.timeList));
+
+      tableData.forEach((item) => {
+        item.materialList.forEach((m) => {
+          if (this.multipleSelection.some((selected) => selected.categoryId === m.categoryId)) {
+            this.$set(m, 'deliveryMethod', deliveryMethod);
+            if (deliveryMethod === 1) {
+              //一次性到货逻辑
+              this.$set(m, 'requireDeliveryTime', requireDeliveryTime)
+              this.$set(m, 'timeList', null)
+            } else if (deliveryMethod === 2) {
+              this.$set(m, 'timeList', JSON.parse(JSON.stringify(timeListTemplate)));
+            }
           }
         });
+      });
 
-        this.$refs.table.setData([...data]);
-        this.$forceUpdate();
-      },
+      this.$refs.table.setData([...tableData]);
+      this.batchVisible = false;
+    },
+    confirm() {
+      this.$refs.formRef.validate(async (value) => {
+        if (value) {
+          let _arr = this.$refs.table.getData() ?? [];
+
+          if (_arr.length == 0) {
+            this.$message.info('请添加生产计划');
+            return false;
+          }
+          let _arr2 = [];
 
-      openVersion(row) {
-        this.xsId = row.id;
-        this.$refs.versionRefs.open();
-      },
-      changeProduct(data) {
-        let param = {
-          salesOrderIds: [this.xsId],
-          produceRoutingId: data.id
-        };
+          _arr2 = _arr.map((m) => {
+            if (
+              Object.prototype.hasOwnProperty.call(m, 'salesOrderId') &&
+              m.salesOrderId
+            ) {
+            } else {
+              m.salesOrderId = m.id;
+              m.salesOrderCode = m.code;
+              delete m.id;
+              delete m.code;
+            }
 
-        listBomBySalesOrderId(param).then((res) => {
-          if (!res) return;
-          const tableList = this.$refs.table.getData();
-
-          tableList
-            .forEach((e) => {
-              if (e.id == this.xsId) {
-                res.map((m) => {
-                  m.detailId = this.xsId;
-                  return {
-                    ...m
-                  };
-                });
-
-                e.materialList = res;
-
-                this.$nextTick(() => {
-                  this.$refs.table.setData([...tableList]);
-                  this.$refs.table.toggleRowExpansionAll();
-                });
-              }
-            })
-            .catch((error) => {
-              console.error('Failed to change product:', error);
-            });
-        });
-      },
+            return {
+              ...m
+            };
+          });
 
-      handleMethod(row) {
-        this.$refs.timeDialogRef.open(row);
-      },
-      chooseTime(current, timeList) {
-        let tableList = [];
-        tableList = this.$refs.table.getData();
-
-        tableList.forEach((e) => {
-          if (e.id == current.detailId) {
-            e.materialList.forEach((m) => {
-              if (m.categoryId == current.categoryId) {
-                m.timeList = timeList || [];
-              }
-            });
-          }
-        });
+          this.formData['type'] = 1;
+          this.formData['salesOrderList'] = _arr2;
+          this.formData.baitingType = 2;
 
-        this.$refs.table.setData([...tableList]);
-        this.$forceUpdate();
-      }
-    }
-  };
+          await save(this.formData);
+          this.$message.success('保存成功!');
+          this.$emit('success');
+          this.cancel();
+        }
+      });
+    },
+    cancel() {
+      this.visible = false;
+      this.formData = {};
+      this.formData.detailRemoveIds = [];
+      this.formData.materialRemoveIds = [];
+      this.$refs.table.setData([]);
+      this.$refs.formRef.resetFields();
+    },
+  }
+};
 </script>
 
 <style lang="scss" scoped>
-  :deep(.el-table__expanded-cell) {
-    padding-bottom: 30px !important;
-    border-bottom: 12px solid #ccffcc !important;
-  }
+:deep(.el-table__expanded-cell) {
+  padding-bottom: 30px !important;
+  border-bottom: 12px solid #ccffcc !important;
+}
+
+.batch-actions {
+  text-align: right;
+  margin: 10px;
+}
 </style>

+ 5 - 5
src/views/materialPlan/components/timeDialog.vue

@@ -1,5 +1,5 @@
 <template>
-    <el-dialog :title="title" :visible.sync="visible" :before-close="handleClose" :close-on-click-modal="true"
+    <el-dialog :title="title" :visible.sync="visible" :before-close="handleClose" :close-on-click-modal="false"
         :close-on-press-escape="false" append-to-body width="35%">
 
         <el-form :model="form" ref="tableForm" class="tableForm" :rules="tableFormRules">
@@ -128,14 +128,14 @@ export default {
         },
 
 
-
         handleOk() {
             this.$refs.tableForm.validate((valid) => {
                 if (valid) {
-                    this.$emit('chooseTime', this.current, this.form.timeList, this.currentIndex)
-                    this.handleClose()
+                    const clonedTimeList = JSON.parse(JSON.stringify(this.form.timeList));
+                    this.$emit('chooseTime', this.current, clonedTimeList, this.currentIndex);
+                    this.handleClose();
                 }
-            })
+            });
         },
 
 

+ 42 - 18
src/views/materialPlan/index.vue

@@ -6,7 +6,7 @@
 
       <!-- 数据表格 -->
       <ele-pro-table ref="table" :initLoad="false" :columns="columns" :datasource="datasource"
-        cache-key="`materialPlanTable`">
+        cache-key="`materialPlanTable`" :pageSize="20" :pageSizes="[20, 30, 40, 50, 100]">
         <template v-slot:toolbar>
           <el-dropdown trigger="click" @command="handleClick">
             <el-link type="primary" icon="el-icon-plus">创建采购计划</el-link>
@@ -18,18 +18,18 @@
         </template>
         <template v-slot:demandType="{ row }">
           <template v-if="row.flagTry">
-            <el-tooltip placement="top" >
+            <el-tooltip placement="top">
               <div slot="content">采购需求数量与采购实际采购入库数量不同!</div>
               <i class="el-icon-info" style="color:red;"></i>
-              </el-tooltip>
+            </el-tooltip>
           </template>
           {{ row.demandType == 1
-              ? '生产性物资采购'
-              : row.demandType == 6
-                ? '外协自供料采购'
-                : row.demandType == 7
-                  ? '外协客供料采购'
-                  : '' }}
+            ? '生产性物资采购'
+            : row.demandType == 6
+              ? '外协自供料采购'
+              : row.demandType == 7
+                ? '外协客供料采购'
+                : '' }}
         </template>
         <template v-slot:name="{ row }">
           <el-link type="primary" @click="handleEdit('detail', row)">{{
@@ -159,35 +159,47 @@ export default {
           prop: 'demandType',
           label: '需求类型',
           align: 'center',
+          width: 130,
+          showOverflowTooltip: true,
+          fixed: 'left'
         },
         {
           slot: 'name',
           prop: 'name',
           label: '名称',
-          align: 'center'
+          align: 'center',
+          width: 160,
+          showOverflowTooltip: true,
+          fixed: 'left'
         },
         {
           slot: 'code',
           prop: 'code',
           label: '编号',
-          align: 'center'
+          align: 'center',
+          width: 160,
+          showOverflowTooltip: true,
+          fixed: 'left'
         },
         {
           prop: 'planStr',
           label: '生产计划编码',
           align: 'center',
+          width: 160,
           showOverflowTooltip: true
         },
         {
           prop: 'orderStr',
           label: '销售订单号',
           align: 'center',
+          width: 160,
           showOverflowTooltip: true
         },
         {
           prop: 'serialNoStr',
           label: '客户代号',
           align: 'center',
+          width: 120,
           showOverflowTooltip: true
         },
         {
@@ -195,21 +207,27 @@ export default {
           label: '状态',
           align: 'center',
           slot: 'status',
-          action: 'status'
+          action: 'status',
+          width: 120,
+          showOverflowTooltip: true
         },
         {
           columnKey: 'progress',
           label: '订单整体进度',
           align: 'center',
           slot: 'progress',
-          action: 'progress'
+          action: 'progress',
+          width: 120,
+          showOverflowTooltip: true
         },
         {
           prop: 'approvalStatus',
           label: '审批状态',
           align: 'center',
           slot: 'approvalStatus',
-          action: 'approvalStatus'
+          action: 'approvalStatus',
+          width: 120,
+          showOverflowTooltip: true
         },
 
         {
@@ -217,23 +235,29 @@ export default {
           label: '来源类型',
           align: 'center',
           slot: 'orderType',
-          action: 'orderType'
+          action: 'orderType',
+          width: 120,
+          showOverflowTooltip: true
         },
 
         {
           prop: 'createUserName',
           label: '创建人',
-          align: 'center'
+          align: 'center',
+          width: 120,
+          showOverflowTooltip: true
         },
         {
           prop: 'createTime',
           label: '创建时间',
-          align: 'center'
+          align: 'center',
+          width: 120,
+          showOverflowTooltip: true
         },
         {
           columnKey: 'action',
           label: '操作',
-          width: 250,
+          width: 180,
           align: 'center',
           resizable: false,
           fixed: 'right',

+ 182 - 189
src/views/materialPlan/pickPlan.vue

@@ -1,197 +1,190 @@
 <template>
-    <div class="ele-body">
-      <el-card shadow="never" v-loading="loading">
-        <materialPlan-search @search="reload" :statusOpt="statusOpt" :activeName="activeName" ref="searchRef">
-        </materialPlan-search>
-  
-
-        <!-- 数据表格 -->
-        <ele-pro-table ref="table" :initLoad="false" :columns="columns" :datasource="datasource"
-          cache-key="pickPlanTable">
-          <template v-slot:toolbar>
-            <el-button type="primary" @click="handleEdit('add')">创建计划</el-button>
-          </template>
-  
-          <template v-slot:status="{ row }">
-            <span :class="{ 'ele-text-danger': row.status == 3 }">
-              {{ statusFormatter(row.status) }}
-            </span>
-          </template>
-
-
-          
-          <!-- 操作列 -->
-          <template v-slot:action="{ row }">
-  
-  
-            <el-link type="primary" :underline="false" icon="el-icon-edit" @click="handleEdit('edit', row)">
-              修改计划
-            </el-link>
-            <el-link @click="handleDel(row)" type="danger" :underline="false" icon="el-icon-delete">
-              删除
-            </el-link>
-
-          </template>
-        </ele-pro-table>
-      </el-card>
-      <produceEditDialog ref="produceEditDialogRef" @success="reload"></produceEditDialog>
-
-    </div>
-  </template>
-  
-  <script>
-  import materialPlanSearch from './components/materialPlan-search.vue';
-
-  import produceEditDialog from './components/produce-edit-dialog'
-  import { getList, del,  } from '@/api/materialPlan/index';
-  export default {
-    components: {
-
-      produceEditDialog,
-      materialPlanSearch,
-    
-    },
-  
-    data() {
-      return {
-        activeName: 'second',
-  
-        // 加载状态
-        loading: false,
-   
-  
-  
-        statusOpt: {
-    
-          second: [
-            { label: '所有状态', value: null },
-            { label: '待排产', value: '1' },
-            { label: '待发布', value: '2' },
-            { label: '发布失败', value: '3' },
-            { label: '已完成', value: '6' },
-          ]
+  <div class="ele-body">
+    <el-card shadow="never" v-loading="loading">
+      <materialPlan-search @search="reload" :statusOpt="statusOpt" :activeName="activeName" ref="searchRef">
+      </materialPlan-search>
+
+
+      <!-- 数据表格 -->
+      <ele-pro-table ref="table" :initLoad="false" :columns="columns" :datasource="datasource"
+        cache-key="pickPlanTable">
+        <template v-slot:toolbar>
+          <el-button type="primary" @click="handleEdit('add')">创建计划</el-button>
+        </template>
+
+        <template v-slot:status="{ row }">
+          <span :class="{ 'ele-text-danger': row.status == 3 }">
+            {{ statusFormatter(row.status) }}
+          </span>
+        </template>
+
+
+
+        <!-- 操作列 -->
+        <template v-slot:action="{ row }">
+
+
+          <el-link type="primary" :underline="false" icon="el-icon-edit" @click="handleEdit('edit', row)">
+            修改计划
+          </el-link>
+          <el-link @click="handleDel(row)" type="danger" :underline="false" icon="el-icon-delete">
+            删除
+          </el-link>
+
+        </template>
+      </ele-pro-table>
+    </el-card>
+    <produceEditDialog ref="produceEditDialogRef" @success="reload"></produceEditDialog>
+
+  </div>
+</template>
+
+<script>
+import materialPlanSearch from './components/materialPlan-search.vue';
+
+import produceEditDialog from './components/produce-edit-dialog'
+import { getList, del, } from '@/api/materialPlan/index';
+export default {
+  components: {
+
+    produceEditDialog,
+    materialPlanSearch,
+
+  },
+
+  data() {
+    return {
+      activeName: 'second',
+
+      // 加载状态
+      loading: false,
+
+
+
+      statusOpt: {
+
+        second: [
+          { label: '所有状态', value: null },
+          { label: '待排产', value: '1' },
+          { label: '待发布', value: '2' },
+          { label: '发布失败', value: '3' },
+          { label: '已完成', value: '6' },
+        ]
+      },
+
+
+    };
+  },
+  computed: {
+    // 表格列配置
+    columns() {
+      return [
+        {
+          columnKey: 'index',
+          label: '序号',
+          type: 'index',
+          width: 55,
+          align: 'center',
+          fixed: 'left'
+        },
+        {
+          slot: 'name',
+          prop: 'name',
+          label: '计划名称',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'code',
+          label: '计划编号',
+          align: 'center',
+          showOverflowTooltip: true
         },
-  
-    
-      };
+        {
+          columnKey: 'status',
+          label: '状态',
+          align: 'center',
+          slot: 'status',
+          action: 'status',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'createUserName',
+          label: '创建人',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'createTime',
+          label: '创建时间',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          columnKey: 'action',
+          label: '操作',
+          width: 250,
+          align: 'center',
+          resizable: false,
+          fixed: 'right',
+          slot: 'action'
+        }
+      ];
+    }
+  },
+  methods: {
+    statusFormatter(status) {
+      const obj = this.statusOpt[this.activeName].find(
+        (i) => i.value == status
+      );
+
+      return obj && obj.label;
     },
-    computed: {
-      // 表格列配置
-      columns() {
-        return [
-          {
-            columnKey: 'index',
-            label: '序号',
-            type: 'index',
-            width: 55,
-            align: 'center',
-            fixed: 'left'
-          },
-          {
-            slot: 'name',
-            prop: 'name',
-            label: '计划名称',
-            align: 'center',
-  
-          },
-          {
-            prop: 'code',
-            label: '计划编号',
-            align: 'center',
-  
-          },
-  
-  
-  
-  
-          {
-            columnKey: 'status',
-            label: '状态',
-            align: 'center',
-            slot: 'status',
-            action: 'status'
-          },
-  
-  
-  
-  
-          {
-            prop: 'createUserName',
-            label: '创建人',
-            align: 'center'
-          },
-          {
-            prop: 'createTime',
-            label: '创建时间',
-            align: 'center',
-  
-          },
-          {
-            columnKey: 'action',
-            label: '操作',
-            width: 250,
-            align: 'center',
-            resizable: false,
-            fixed: 'right',
-            slot: 'action'
-          }
-        ];
+
+
+    /* 表格数据源 */
+    datasource({ page, limit, where }) {
+      where.type = 2
+      delete where.statusList
+      return getList({
+        pageNum: page,
+        size: limit,
+        ...where
+      });
+    },
+    handleEdit(type, row) {
+      this.$refs.produceEditDialogRef.open(type, row);
+    },
+
+    handleDel({ id }) {
+      this.$confirm('确认删除当前数据!', '提示').then(async () => {
+        await del([id]);
+        this.$message.success('删除成功!');
+        this.reload();
+      });
+    },
+
+
+
+    handleTabChange() {
+      this.$refs.searchRef.reset();
+    },
+
+    /* 刷新表格 */
+    reload(where = {}) {
+      if (where.statusList) {
+        where.statusList = where.statusList.split(',')
       }
+      this.$nextTick(() => {
+        this.$refs.table.reload({ page: 1, where });
+      });
     },
-    methods: {
-      statusFormatter(status) {
-        const obj = this.statusOpt[this.activeName].find(
-          (i) => i.value == status
-        );
-  
-        return obj && obj.label;
-      },
-  
-
-      /* 表格数据源 */
-      datasource({ page, limit, where }) {
-        where.type = 2
-        delete where.statusList
-        return getList({
-          pageNum: page,
-          size: limit,
-          ...where
-        });
-      },
-      handleEdit(type, row) {
-        this.$refs.produceEditDialogRef.open(type, row);
-      },
 
-      handleDel({ id }) {
-        this.$confirm('确认删除当前数据!', '提示').then(async () => {
-          await del([id]);
-          this.$message.success('删除成功!');
-          this.reload();
-        });
-      },
-  
 
-  
-      handleTabChange() {
-        this.$refs.searchRef.reset();
-      },
-  
-      /* 刷新表格 */
-      reload(where = {}) {
-         if(where.statusList) {
-          where.statusList =  where.statusList.split(',')
-         }
-        this.$nextTick(() => {
-          this.$refs.table.reload({ page: 1, where });
-        });
-      },
-  
 
-  
-  
-    }
-  };
-  </script>
-  
-  <style lang="scss" scoped></style>
-  
+
+  }
+};
+</script>
+
+<style lang="scss" scoped></style>