ysy il y a 2 ans
Parent
commit
23802b2884

+ 15 - 1
src/api/materialPlan/index.js

@@ -82,4 +82,18 @@ export async function getMaterialList(data) {
     return res.data.data;
     return res.data.data;
   }
   }
   return Promise.reject(new Error(res.data.message));
   return Promise.reject(new Error(res.data.message));
-}
+}
+
+
+
+
+
+// 批量根据生产计划计算bom列表信息
+
+export async function listBomBySalesOrderIds(data) {
+  const res = await request.post(`/aps/batchingplandetail/listBomBySalesOrderIds`,data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 2 - 1
src/enum/dict.js

@@ -17,7 +17,8 @@ export default {
   订单计划类型: 'plan_type',
   订单计划类型: 'plan_type',
   交付要求: 'require_ments',
   交付要求: 'require_ments',
   交货状态: 'delivery_status',
   交货状态: 'delivery_status',
-  余量系数: 'margin_code'
+  余量系数: 'margin_code',
+  计量单位: 'measuring_uint',
 
 
 };
 };
 
 

+ 32 - 21
src/views/materialPlan/components/ProductModal.vue

@@ -5,7 +5,7 @@
     <el-card shadow="never">
     <el-card shadow="never">
       <ProductSearch @search="reload" ref="searchRef" />
       <ProductSearch @search="reload" ref="searchRef" />
 
 
-      <ele-split-layout width="244px" hight="500px" allow-collapse :right-style="{ overflow: 'hidden' }">
+      <ele-split-layout width="244px" allow-collapse :right-style="{ overflow: 'hidden' }">
         <div class="ele-border-lighter split-layout-right-content">
         <div class="ele-border-lighter split-layout-right-content">
           <el-tree :data="treeList" :props="defaultProps" ref="treeRef"
           <el-tree :data="treeList" :props="defaultProps" ref="treeRef"
             :default-expanded-keys="categoryId ? [categoryId] : []" :highlight-current="true" node-key="id"
             :default-expanded-keys="categoryId ? [categoryId] : []" :highlight-current="true" node-key="id"
@@ -15,9 +15,8 @@
 
 
         <!-- 数据表格 -->
         <!-- 数据表格 -->
         <template v-slot:content>
         <template v-slot:content>
-          <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :selection.sync="selection" row-key="id">
-
-
+          <ele-pro-table style="min-height: 400px;" ref="table" :columns="columns" :datasource="datasource"
+            :selection.sync="selection" row-key="id">
           </ele-pro-table>
           </ele-pro-table>
         </template>
         </template>
       </ele-split-layout>
       </ele-split-layout>
@@ -47,7 +46,7 @@ export default {
       title: '选择物料',
       title: '选择物料',
 
 
       categoryLevelId: null,
       categoryLevelId: null,
-      categoryId: null,
+      categoryId: 1,
       treeList: [],
       treeList: [],
       treeLoading: false,
       treeLoading: false,
 
 
@@ -72,14 +71,12 @@ export default {
 
 
         {
         {
           label: '物料名称',
           label: '物料名称',
-          prop: 'categoryName',
-
+          prop: 'name',
         },
         },
 
 
-
         {
         {
           label: '物料编码',
           label: '物料编码',
-          prop: 'categoryCode'
+          prop: 'code'
         },
         },
         {
         {
           label: '牌号',
           label: '牌号',
@@ -89,30 +86,47 @@ export default {
           label: '型号',
           label: '型号',
           prop: 'modelType'
           prop: 'modelType'
         },
         },
+
         {
         {
-          label: '数量',
-          prop: 'count'
+          prop: 'availableCountBase',
+          label: '包装库存',
+          sortable: 'custom',
+        },
+        {
+          label: '单位',
+          prop: 'weightUnit'
         },
         },
+
+        {
+          prop: 'packingCountBase',
+          label: '计量库存',
+          sortable: 'custom',
+        },
+
         {
         {
           label: '计量单位',
           label: '计量单位',
           prop: 'unit'
           prop: 'unit'
         },
         },
 
 
 
 
+
+
         {
         {
-          label: '单位',
-          prop: 'weightUnit'
+          label: '数量',
+          prop: 'count'
         },
         },
 
 
 
 
 
 
 
 
+
       ],
       ],
 
 
       // 表格选中数据
       // 表格选中数据
       selection: [],
       selection: [],
 
 
-      processData: []
+      processData: [],
+      current: null
 
 
     }
     }
   },
   },
@@ -136,13 +150,10 @@ export default {
       return res;
       return res;
     },
     },
 
 
-    open(item, row, categoryId) {
-
-      // if (item) {
-      //   this.processData = item
+    open(item, row) {
 
 
-      // }
-      this.categoryId = categoryId
+      this.processData = item || []
+      this.current = row;
       this.visible = true
       this.visible = true
 
 
       this.getTreeData();
       this.getTreeData();
@@ -203,7 +214,7 @@ export default {
         this.$message.error('请至少选择一条数据');
         this.$message.error('请至少选择一条数据');
         return;
         return;
       }
       }
-      this.$emit('chooseProcess', this.selection)
+      this.$emit('chooseModal', this.selection, this.current)
       this.handleClose()
       this.handleClose()
     },
     },
   }
   }

+ 151 - 33
src/views/materialPlan/components/plan-edit-dialog.vue

@@ -39,8 +39,8 @@
         </template>
         </template>
 
 
         <template v-slot:action="{ row, $index }">
         <template v-slot:action="{ row, $index }">
-          <template >
-            <el-link type="primary" :underline="false" @click="categorySelect">
+          <template>
+            <el-link type="primary" :underline="false" @click="categorySelect(row)">
               添加物料
               添加物料
             </el-link>
             </el-link>
             <el-popconfirm class="ele-action" title="确定要删除此销售订单吗?" @confirm="remove(row, $index)">
             <el-popconfirm class="ele-action" title="确定要删除此销售订单吗?" @confirm="remove(row, $index)">
@@ -56,30 +56,42 @@
 
 
         <!-- 展开内容 -->
         <!-- 展开内容 -->
         <template v-slot:expand="{ row }">
         <template v-slot:expand="{ row }">
-          <div style="width:100%; min-height: 60px" v-if="row.materialList">
+          <div style="width:100%; min-height: 60px" v-if="row.materialList.length > 0">
             <ele-pro-table :toolbar="false" toolsTheme="none" ref="table2" :need-page="false"
             <ele-pro-table :toolbar="false" toolsTheme="none" ref="table2" :need-page="false"
               :datasource="row.materialList" :columns="columns2" row-key="id">
               :datasource="row.materialList" :columns="columns2" row-key="id">
 
 
-              <template v-slot:categoryName="{ row, $index }">
-                <el-input :value="row.categoryName" placeholder="请选择"
-                  @click.native="categorySelect(row, $index)"></el-input>
-              </template>
 
 
 
 
-              <template v-slot:unit="{ row }">
-                <DictSelection dictName="计量单位" v-model="row.unit"></DictSelection>
+
+              <template v-slot:demandQuantity="{ row }">
+                <el-input v-model="row.demandQuantity" placeholder="请输入" @input="(value) =>
+                (row.demandQuantity = value.replace(
+                  /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
+                  '$1$2.$3'
+                ))
+                  "></el-input>
               </template>
               </template>
 
 
 
 
-              <template v-slot:count="{ row }">
-                <el-input v-model="row.count" placeholder="请输入" @input="(value) =>
-                (row.count = value.replace(
+              <template v-slot:purchaseQuantity="{ row }">
+                <el-input v-model="row.purchaseQuantity" placeholder="请输入" @input="(value) =>
+                (row.purchaseQuantity = value.replace(
                   /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
                   /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
                   '$1$2.$3'
                   '$1$2.$3'
                 ))
                 ))
                   "></el-input>
                   "></el-input>
               </template>
               </template>
 
 
+              <template v-slot:action="{ 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>
+                  </template>
+                </el-popconfirm>
+              </template>
+
             </ele-pro-table>
             </ele-pro-table>
           </div>
           </div>
 
 
@@ -100,7 +112,7 @@
 
 
 
 
 
 
-    <ProductModal ref="productRefs"  />
+    <ProductModal ref="productRefs" @chooseModal="chooseModal" />
 
 
   </ele-modal>
   </ele-modal>
 </template>
 </template>
@@ -108,10 +120,8 @@
 <script>
 <script>
 
 
 import saleOrderPop from './saleOrderPop.vue'
 import saleOrderPop from './saleOrderPop.vue'
-
-
 import ProductModal from './ProductModal.vue'
 import ProductModal from './ProductModal.vue'
-
+import { listBomBySalesOrderIds, save } from '@/api/materialPlan/index';
 
 
 export default {
 export default {
   components: {
   components: {
@@ -145,7 +155,7 @@ export default {
           slot: 'code',
           slot: 'code',
           showOverflowTooltip: true,
           showOverflowTooltip: true,
           align: 'center',
           align: 'center',
-          minWidth: 120
+          minWidth: 150
         },
         },
         {
         {
           prop: 'customerName',
           prop: 'customerName',
@@ -159,6 +169,13 @@ export default {
           align: 'center',
           align: 'center',
           showOverflowTooltip: true
           showOverflowTooltip: true
         },
         },
+        {
+          prop: 'productCode',
+          label: '产品编码',
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 140
+        },
 
 
         {
         {
           prop: 'productName',
           prop: 'productName',
@@ -186,7 +203,16 @@ export default {
           align: 'center',
           align: 'center',
           showOverflowTooltip: true
           showOverflowTooltip: true
         },
         },
-
+        {
+          prop: 'contractNum',
+          label: '合同数量',
+          align: 'center'
+        },
+        {
+          prop: 'lackNum',
+          label: '欠交数量',
+          align: 'center'
+        },
         {
         {
           prop: 'remark',
           prop: 'remark',
           label: '备注',
           label: '备注',
@@ -212,14 +238,12 @@ export default {
 
 
         {
         {
           label: '物料名称',
           label: '物料名称',
-          prop: 'categoryName',
-          slot: 'categoryName',
-          action: 'categoryName'
+          prop: 'name',
         },
         },
 
 
         {
         {
           label: '物料编码',
           label: '物料编码',
-          prop: 'categoryCode'
+          prop: 'code'
         },
         },
         {
         {
           label: '牌号',
           label: '牌号',
@@ -229,17 +253,50 @@ export default {
           label: '型号',
           label: '型号',
           prop: 'modelType'
           prop: 'modelType'
         },
         },
+
         {
         {
-          label: '数量',
-          slot: 'count',
-          action: 'count'
+          prop: 'availableCountBase',
+          label: '包装库存',
+          sortable: 'custom',
         },
         },
         {
         {
           label: '单位',
           label: '单位',
-          slot: 'unit',
-          action: 'unit'
+          prop: 'weightUnit'
+        },
+
+        {
+          prop: 'packingCountBase',
+          label: '计量库存',
+          sortable: 'custom',
+        },
+
+        {
+          label: '计量单位',
+          prop: 'unit'
+        },
+
+        {
+          label: '需求数量',
+          slot: 'demandQuantity',
+          action: 'demandQuantity'
+        },
+
+        {
+          label: '采购数量',
+          slot: 'purchaseQuantity',
+          action: 'purchaseQuantity'
         },
         },
 
 
+        {
+          columnKey: 'action',
+          label: '操作',
+
+          align: 'center',
+          resizable: false,
+          slot: 'action',
+          showOverflowTooltip: true
+        }
+
       ],
       ],
       rules: {
       rules: {
         materialName: [
         materialName: [
@@ -254,7 +311,7 @@ export default {
       },
       },
       formData: {
       formData: {
         materialName: '',
         materialName: '',
-        salesOrderPOList: []
+
       },
       },
 
 
 
 
@@ -263,7 +320,6 @@ export default {
   methods: {
   methods: {
     async open(type, row = {}) {
     async open(type, row = {}) {
       this.type = type;
       this.type = type;
-      // this.formData = Object.assign({}, this.formData, row);
       this.visible = true;
       this.visible = true;
     },
     },
 
 
@@ -271,10 +327,16 @@ export default {
     confirm() {
     confirm() {
       this.$refs.formRef.validate(async (value) => {
       this.$refs.formRef.validate(async (value) => {
         if (value) {
         if (value) {
-          const request = this.type == 'add' ? save : update;
 
 
+          let _arr = this.$refs.table.getData() ?? []
 
 
-          // await request(this.formData);
+          if (_arr.length == 0) {
+            this.$message.info('请添加销售订单');
+            return false
+          }
+          this.formData['salesOrderPOList'] = _arr
+          const request = this.type == 'add' ? save : update;
+          await request(this.formData);
           this.$message.success('保存成功!');
           this.$message.success('保存成功!');
           this.$emit('success');
           this.$emit('success');
           this.cancel();
           this.cancel();
@@ -301,7 +363,22 @@ export default {
     },
     },
 
 
     chooseOrder(list) {
     chooseOrder(list) {
+      let salesOrderIds = []
+      list.map((m => {
+        m.materialList = []
+        salesOrderIds.push(m.id)
+        return {
+          ...m,
+        }
+      }))
       this.$refs.table.setData([...this.tableData, ...list]);
       this.$refs.table.setData([...this.tableData, ...list]);
+
+
+      if (salesOrderIds.length > 0) {
+        listBomBySalesOrderIds({ salesOrderIds: salesOrderIds }).then((res) => {
+          this.$refs.table.setData([...this.tableData, ...res]);
+        })
+      }
     },
     },
 
 
     remove(row, index) {
     remove(row, index) {
@@ -311,8 +388,49 @@ export default {
     },
     },
 
 
     categorySelect(row) {
     categorySelect(row) {
-      this.current = row;
-      this.$refs.productRefs.open(row.materialList, this.current, 1)
+      this.$refs.productRefs.open(row.materialList, row)
+    },
+
+    chooseModal(data, current) {
+      data.map((m => {
+        m.parentId = current.id
+        return {
+          ...m,
+        }
+      }))
+
+      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]
+
+          }
+
+
+        }
+      })
+
+      this.$refs.table.setData([...tableList]);
+
+    },
+
+    remove2(row) {
+      const data = this.$refs.table.getData() ?? [];
+      data.forEach((e) => {
+        if (row.parentId == e.id) {
+          e.materialList = e.materialList.filter((d) => d.id !== row.id);
+        }
+      })
+
+      this.$refs.table.setData([...data])
+      this.$forceUpdate()
     },
     },
 
 
 
 

+ 2 - 1
src/views/materialPlan/components/saleOrderPop.vue

@@ -73,6 +73,7 @@ export default {
                     align: 'center',
                     align: 'center',
                     minWidth: 120
                     minWidth: 120
                 },
                 },
+            
                 {
                 {
                     prop: 'brandNo',
                     prop: 'brandNo',
                     label: '牌号',
                     label: '牌号',
@@ -139,7 +140,7 @@ export default {
 
 
         /* 表格数据源 */
         /* 表格数据源 */
         async datasource({ page, limit, where }) {
         async datasource({ page, limit, where }) {
-            where.status = [1]
+            where.status = [1, 2,  3, 4, 7,8]
             const data = await getPageList({
             const data = await getPageList({
                 ...where,
                 ...where,
                 pageNum: page,
                 pageNum: page,