ysy 2 лет назад
Родитель
Сommit
3666da1114

+ 11 - 0
src/api/classifyManage/index.js

@@ -50,3 +50,14 @@ export async function getInfoById (id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 根据type查分类树组
+export async function getTreeByGroup(data) {
+  const res = await request.get(`/main/categoryLevel/getProduceTreeByPid`, {
+    params: data
+  });
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 12 - 0
src/api/materialPlan/index.js

@@ -71,3 +71,15 @@ export async function getReleaseInfoById (id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+
+// 获取列表
+export async function getMaterialList(data) {
+  const res = await request.get(`/wms/outin/getRealTimeInventory`, {
+    params: data
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 218 - 0
src/views/materialPlan/components/ProductModal.vue

@@ -0,0 +1,218 @@
+<template>
+  <el-dialog :title="title" :visible.sync="visible" :before-close="handleClose" :close-on-click-modal="false"
+    :close-on-press-escape="false" append-to-body width="70%">
+
+    <el-card shadow="never">
+      <ProductSearch @search="reload" ref="searchRef" />
+
+      <ele-split-layout width="244px" hight="500px" allow-collapse :right-style="{ overflow: 'hidden' }">
+        <div class="ele-border-lighter split-layout-right-content">
+          <el-tree :data="treeList" :props="defaultProps" ref="treeRef"
+            :default-expanded-keys="categoryId ? [categoryId] : []" :highlight-current="true" node-key="id"
+            @node-click="handleNodeClick"></el-tree>
+        </div>
+
+
+        <!-- 数据表格 -->
+        <template v-slot:content>
+          <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :selection.sync="selection" row-key="id">
+
+
+          </ele-pro-table>
+        </template>
+      </ele-split-layout>
+
+    </el-card>
+
+    <div class="btns">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+
+
+import { getMaterialList } from '@/api/materialPlan/index';
+import ProductSearch from './product-search.vue'
+import { getTreeByPid } from '@/api/classifyManage';
+export default {
+  components: {
+    ProductSearch
+  },
+  data() {
+    return {
+      visible: false,
+      title: '选择物料',
+
+      categoryLevelId: null,
+      categoryId: null,
+      treeList: [],
+      treeLoading: false,
+
+      defaultProps: {
+        children: 'children',
+        label: 'name'
+      },
+
+      // 表格列配置
+      columns: [
+        {
+          columnKey: 'selection',
+          type: 'selection',
+          width: 45,
+          align: 'center',
+          selectable: (row, index) => {
+            return !this.processData.some((it) => it.id == row.id);
+          },
+          reserveSelection: true,
+          fixed: 'left'
+        },
+
+        {
+          label: '物料名称',
+          prop: 'categoryName',
+
+        },
+
+
+        {
+          label: '物料编码',
+          prop: 'categoryCode'
+        },
+        {
+          label: '牌号',
+          prop: 'brandNum'
+        },
+        {
+          label: '型号',
+          prop: 'modelType'
+        },
+        {
+          label: '数量',
+          prop: 'count'
+        },
+        {
+          label: '计量单位',
+          prop: 'unit'
+        },
+
+
+        {
+          label: '单位',
+          prop: 'weightUnit'
+        },
+
+
+
+
+      ],
+
+      // 表格选中数据
+      selection: [],
+
+      processData: []
+
+    }
+  },
+
+  watch: {
+
+  },
+  methods: {
+
+
+    /* 表格数据源 */
+    async datasource({ page, limit, where }) {
+      const res = await getMaterialList({
+        ...where,
+
+        pageNum: page,
+        size: limit,
+        categoryLevelId: 1,
+        dimension: 1
+      });
+      return res;
+    },
+
+    open(item, row, categoryId) {
+
+      // if (item) {
+      //   this.processData = item
+
+      // }
+      this.categoryId = categoryId
+      this.visible = true
+
+      this.getTreeData();
+    },
+
+
+
+    async getTreeData() {
+      try {
+        this.treeLoading = true;
+
+        const res = await getTreeByPid(1);
+        this.treeLoading = false;
+        if (res?.code === '0') {
+          this.treeList = res.data;
+
+          this.$nextTick(() => {
+            // 默认高亮第一级树节点
+            if (this.treeList[0]) {
+              this.rootTreeId = this.treeList[0].id
+              this.$nextTick(() => {
+                this.$refs.treeRef.setCurrentKey(this.treeList[0].id);
+              });
+
+            }
+          });
+          return this.treeList;
+        }
+      } catch (error) { }
+      this.treeLoading = false;
+    },
+
+
+    handleNodeClick(data) {
+      this.categoryLevelId = data.id;
+      this.$refs.table.reload({ pageNum: 1, where: {} });
+
+
+
+    },
+
+
+    /* 刷新表格 */
+    reload(where) {
+      this.$refs.table.reload({ page: 1, where: where });
+    },
+
+
+
+    handleClose() {
+      this.visible = false
+      this.$refs.table.setSelectedRows([]);
+      this.selection = []
+
+    },
+    selected() {
+      if (!this.selection.length) {
+        this.$message.error('请至少选择一条数据');
+        return;
+      }
+      this.$emit('chooseProcess', this.selection)
+      this.handleClose()
+    },
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.btns {
+  text-align: center;
+  padding: 10px 0;
+}
+</style>

+ 100 - 28
src/views/materialPlan/components/plan-edit-dialog.vue

@@ -35,24 +35,15 @@
         </template>
 
         <template v-slot:remark="{ row }">
-          <el-input placeholder="备注"  v-model="row.remark"></el-input>
+          <el-input placeholder="备注" v-model="row.remark"></el-input>
         </template>
 
         <template v-slot:action="{ row, $index }">
-          <template v-if="row.orderSource != 1">
-            <el-link
-              type="primary"
-              :underline="false"
-           
-            
-            >
-              设置物料
+          <template >
+            <el-link type="primary" :underline="false" @click="categorySelect">
+              添加物料
             </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">
                   删除
@@ -63,6 +54,38 @@
         </template>
 
 
+        <!-- 展开内容 -->
+        <template v-slot:expand="{ row }">
+          <div style="width:100%; min-height: 60px" v-if="row.materialList">
+            <ele-pro-table :toolbar="false" toolsTheme="none" ref="table2" :need-page="false"
+              :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>
+
+
+              <template v-slot:count="{ row }">
+                <el-input v-model="row.count" placeholder="请输入" @input="(value) =>
+                (row.count = value.replace(
+                  /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
+                  '$1$2.$3'
+                ))
+                  "></el-input>
+              </template>
+
+            </ele-pro-table>
+          </div>
+
+        </template>
+
+
       </ele-pro-table>
 
     </el-form>
@@ -75,8 +98,9 @@
 
     <saleOrderPop ref="saleOrderRef" @chooseOrder="chooseOrder"></saleOrderPop>
 
-    <!-- 选择物料 -->
-    <ChooseMaterial ref="chooseRef" @success="handleChooseMaterial"></ChooseMaterial>
+
+
+    <ProductModal ref="productRefs"  />
 
   </ele-modal>
 </template>
@@ -85,14 +109,14 @@
 
 import saleOrderPop from './saleOrderPop.vue'
 
-import ChooseMaterial from '@/components/CreatePlan/ChooseMaterial.vue';
 
+import ProductModal from './ProductModal.vue'
 
 
 export default {
   components: {
     saleOrderPop,
-    ChooseMaterial,
+    ProductModal
 
 
   },
@@ -107,7 +131,13 @@ export default {
 
       // 表格列配置
       columns: [
-
+        {
+          width: 45,
+          type: 'expand',
+          columnKey: 'materialList',
+          align: 'center',
+          slot: 'expand'
+        },
 
         {
           prop: 'code',
@@ -115,7 +145,7 @@ export default {
           slot: 'code',
           showOverflowTooltip: true,
           align: 'center',
-          minWidth: 110
+          minWidth: 120
         },
         {
           prop: 'customerName',
@@ -165,7 +195,7 @@ export default {
           align: 'center',
           minWidth: 110
         },
-        
+
 
         {
           columnKey: 'action',
@@ -177,6 +207,40 @@ export default {
           showOverflowTooltip: true
         }
       ],
+
+      columns2: [
+
+        {
+          label: '物料名称',
+          prop: 'categoryName',
+          slot: 'categoryName',
+          action: 'categoryName'
+        },
+
+        {
+          label: '物料编码',
+          prop: 'categoryCode'
+        },
+        {
+          label: '牌号',
+          prop: 'brandNum'
+        },
+        {
+          label: '型号',
+          prop: 'modelType'
+        },
+        {
+          label: '数量',
+          slot: 'count',
+          action: 'count'
+        },
+        {
+          label: '单位',
+          slot: 'unit',
+          action: 'unit'
+        },
+
+      ],
       rules: {
         materialName: [
           {
@@ -237,16 +301,24 @@ export default {
     },
 
     chooseOrder(list) {
-      this.$refs.table.setData([...list]);
+      this.$refs.table.setData([...this.tableData, ...list]);
     },
 
-    remove (row, index) {
-       let _arr = this.$refs.table.getData() || [];
-       _arr.splice(index, 1);
-       this.$refs.table.setData([..._arr]);
-      },
+    remove(row, index) {
+      let _arr = this.$refs.table.getData() || [];
+      _arr.splice(index, 1);
+      this.$refs.table.setData([..._arr]);
+    },
+
+    categorySelect(row) {
+      this.current = row;
+      this.$refs.productRefs.open(row.materialList, this.current, 1)
+    },
+
+
+
+
 
-    handleChooseMaterial() { },
 
 
     chooseVersion() {

+ 102 - 0
src/views/materialPlan/components/product-search.vue

@@ -0,0 +1,102 @@
+<!-- 搜索表单 -->
+<template>
+  <el-form
+    label-width="77px"
+    class="ele-form-search"
+    @keyup.enter.native="search"
+    @submit.native.prevent
+  >
+    <el-row :gutter="10">
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="编码">
+          <el-input clearable v-model="where.code" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="名称">
+          <el-input clearable v-model="where.name" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="型号">
+          <el-input clearable v-model="where.modelType" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 4 } : { md: 4 }">
+        <div class="ele-form-actions">
+          <el-button
+            type="primary"
+            icon="el-icon-search"
+            class="ele-btn-icon"
+            @click="search"
+          >
+            查询
+          </el-button>
+
+          <el-button
+            @click="reset"
+            icon="el-icon-refresh"
+            class="ele-btn-icon"
+            size="medium"
+            >重置</el-button
+          >
+        </div>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+
+<script>
+  export default {
+    data () {
+      // 默认表单数据
+      const defaultWhere = {
+        name: '',
+        code: '',
+        modelType: ''
+      };
+      return {
+        defaultWhere,
+        // 表单数据
+        where: { ...defaultWhere },
+        treeData:[]
+      };
+    },
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive () {
+        return this.$store.state.theme.styleResponsive;
+      }
+    },
+    created() {
+    },
+    methods: {
+
+      /* 搜索 */
+      search () {
+        if (this.where.appType === 0) {
+          this.where.appType = '';
+        }
+        this.$emit('search', this.where);
+      },
+      /*  重置 */
+      reset () {
+        this.where = { ...this.defaultWhere };
+        this.search();
+      },
+      reset2 () {
+        this.where = { ...this.defaultWhere };
+
+      }
+    }
+  };
+</script>
+
+<style>
+  .ele-form-actions {
+    display: inline-block;
+    transform: translate(0);
+    transition: all;
+  }
+</style>