ysy 2 years ago
parent
commit
5e5dc17cf8

+ 3 - 3
src/api/material/BOM.js

@@ -37,10 +37,10 @@ export async function getById (id) {
   return Promise.reject(new Error(res.data.message));
 }
 // 删除
-export async function bomDelete (pid) {
-  const res = await request.get(`/main/bom/delete`);
+export async function bomDelete (data) {
+  const res = await request.delete(`/main/bom/delete`, { data });
   if (res.data.code == 0) {
-    return res.data.data;
+    return res.data.message;
   }
   return Promise.reject(new Error(res.data.message));
 }

+ 10 - 10
src/api/material/list.js

@@ -1,7 +1,7 @@
 import request from '@/utils/request';
 
 // 获取列表
-export async function getGroupPage (data) {
+export async function getGroupPage(data) {
   const res = await request.get('/main/categorylevelgroup/page', {
     params: data
   });
@@ -16,7 +16,7 @@ export async function getGroupPage (data) {
 
 
 // 根据分类组编码查询分类树信息
-export async function getTreeByPid (pid) {
+export async function getTreeByPid(pid) {
   const res = await request.get(`/main/categoryLevel/getTreeByPid/${pid}`);
   if (res.data.code == 0) {
     return res.data.data;
@@ -25,7 +25,7 @@ export async function getTreeByPid (pid) {
 }
 
 // 新增物料
-export async function addMaterial (data) {
+export async function addMaterial(data) {
   const res = await request.post(`/main/category/add`, data);
   if (res.data.code == 0) {
     return res.data.message;
@@ -34,7 +34,7 @@ export async function addMaterial (data) {
 }
 
 // 编辑物料
-export async function editMaterial (data) {
+export async function editMaterial(data) {
   const res = await request.post(`/main/category/edit`, data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -43,9 +43,9 @@ export async function editMaterial (data) {
 }
 
 // 获取列表
-export async function getMaterialList (data) {
-  const res = await request.get(`/main/category/getList`, {
-    params: data
+export async function getMaterialList(data) {
+  const res = await request.post(`/main/category/getList`, {
+    data
   });
   if (res.data.code == 0) {
     return res.data.data;
@@ -54,7 +54,7 @@ export async function getMaterialList (data) {
 }
 
 // 获取详情
-export async function getDetailInfo (id) {
+export async function getDetailInfo(id) {
   const res = await request.get(`/main/category/info/${id}`);
   if (res.data.code == 0) {
     return res.data.data;
@@ -63,7 +63,7 @@ export async function getDetailInfo (id) {
 }
 
 //删除
-export async function removeMaterial (id) {
+export async function removeMaterial(id) {
   const res = await request.get(`/main/category/remove/${id}`);
   if (res.data.code == 0) {
     return res.data.data;
@@ -72,7 +72,7 @@ export async function removeMaterial (id) {
 }
 
 //根据产品ID获取bom列表、工艺路线列表【产品管理】
-export async function getBomRoutingList (categoryId) {
+export async function getBomRoutingList(categoryId) {
   const res = await request.get(`/main/category/getSourceList/${categoryId}`);
   if (res.data.code == 0) {
     return res.data.data;

+ 0 - 73
src/components/CommomSelect/category-group-select.vue

@@ -1,73 +0,0 @@
-<template>
-  <el-select
-    v-model="selectVal"
-    filterable
-    style="width: 100%"
-    v-bind="$attrs"
-    v-on="$listeners"
-    clearable
-  >
-    <el-option
-      v-for="item in dictList"
-      :key="item.id"
-      :value="item.id"
-      :label="item.name"
-    ></el-option>
-  </el-select>
-</template>
-
-<script>
-  import { getGroupPage } from '@/api/material/list';
-  export default {
-    model: {
-      prop: 'value',
-      event: 'updateVal'
-    },
-    props: {
-      value: {
-        type: [String, Number, Array],
-        default: ''
-      },
-      init: {
-        type: Boolean,
-        default: true
-      }
-    },
-    data () {
-      return {
-        dictList: []
-      };
-    },
-    computed: {
-      selectVal: {
-        set (val) {
-          this.$emit(
-            'selfChange',
-            val,
-            this.dictList.find((i) => i.id === val)
-          );
-          this.$emit('updateVal', val);
-        },
-        get () {
-          return this.value;
-        }
-      }
-    },
-    created () {
-      if (this.init) {
-        this.getList();
-      }
-    },
-    methods: {
-      async getList (params) {
-        let data = { pageNum: 1, size: -1 };
-        // 如果传了参数就是获取巡点检人员数据
-        if (params) {
-          data = Object.assign(data, params);
-        }
-        const res = await getGroupPage(data);
-        this.dictList = res.list;
-      }
-    }
-  };
-</script>

+ 0 - 229
src/components/SelectDialog/materialDialog.vue

@@ -1,229 +0,0 @@
-<template>
-  <el-dialog
-    title="选择物料"
-    :visible.sync="groupVisible"
-    :before-close="handleClose"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    append-to-body
-    width="60%"
-  >
-    <div>
-      <el-form label-width="80px">
-        <el-row>
-          <el-col :span="8">
-            <el-form-item label="分类" prop="categoryLevelGroupId">
-              <categoryGroupSelect v-model="searchForm.categoryLevelGroupId" />
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="编码" prop="code">
-              <el-input v-model="searchForm.code"></el-input
-            ></el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="名称" prop="name">
-              <el-input v-model="searchForm.name"></el-input
-            ></el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="牌号" prop="brandNum">
-              <el-input v-model="searchForm.brandNum"></el-input
-            ></el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="型号" prop="modelType">
-              <el-input v-model="searchForm.modelType"></el-input
-            ></el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <div class="ele-form-actions">
-              <el-button icon="icon-reset" @click="handleReset">重置</el-button>
-              <el-button
-                type="primary"
-                icon="el-icon-search"
-                @click="handleSearch"
-                >搜索</el-button
-              >
-            </div>
-          </el-col>
-        </el-row>
-      </el-form>
-      <div class="table_col">
-        <el-table
-          :data="tableData"
-          height="450"
-          ref="tableRef"
-          highlight-current-row
-          @row-click="single"
-        >
-          <el-table-column label="编码" prop="code"></el-table-column>
-          <el-table-column
-            label="名称"
-            prop="name"
-            width="200"
-          ></el-table-column>
-          <el-table-column
-            label="牌号"
-            prop="brandNum"
-            width="200"
-          ></el-table-column>
-          <el-table-column
-            label="型号"
-            prop="modelType"
-            width="200"
-          ></el-table-column>
-          <el-table-column label="分类树" prop="categoryLevelPath">
-            <template slot-scope="scope">
-              {{ scope.row.categoryLevelPath + '分类' }}
-            </template>
-          </el-table-column>
-          <el-table-column label="选择" align="center">
-            <template slot-scope="scope">
-              <el-radio class="radio" v-model="radio" :label="scope.row.id"
-                ><i></i
-              ></el-radio>
-            </template>
-          </el-table-column>
-        </el-table>
-        <div class="pagination">
-          <el-pagination
-            background
-            layout="total, sizes, prev, pager, next, jumper"
-            :total="total"
-            :page-sizes="[10, 20, 50, 100]"
-            :page-size="pagination.size"
-            :current-page.sync="pagination.pageNum"
-            @current-change="handleCurrent"
-            @size-change="handleSize"
-          >
-          </el-pagination> </div
-      ></div>
-    </div>
-    <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/material/list.js';
-  import categoryGroupSelect from '@/components/CommomSelect/category-group-select';
-  const defaultWhere = {
-    brandNum: null,
-    modelType: null,
-    name: null,
-    code: null,
-    categoryLevelGroupId: null
-  };
-  export default {
-    components: { categoryGroupSelect },
-    data () {
-      return {
-        groupVisible: false,
-        tableData: [],
-        searchForm: { ...defaultWhere },
-        pagination: {
-          pageNum: 1,
-          size: 10
-        },
-        total: 0,
-        radio: '',
-        current: null,
-        callBack: null
-      };
-    },
-
-    watch: {},
-    methods: {
-      open (item, callBack) {
-        this.callBack = callBack;
-        if (item) {
-          this.current = item;
-          this.radio = item.categoryId || item.id;
-        }
-        this.groupVisible = true;
-        this.getList();
-      },
-      handleSearch () {
-        this.pagination.pageNum = 1;
-        this.getList();
-      },
-      handleReset () {
-        this.searchForm = { ...defaultWhere };
-        this.handleSearch();
-      },
-
-      // 单击获取id
-      single (row) {
-        this.current = row;
-        this.radio = row.id;
-      },
-
-      handleClose () {
-        this.groupVisible = false;
-        this.current = null;
-        this.radio = '';
-      },
-      handleCurrent (page) {
-        this.pagination.pageNum = page;
-        this.getList();
-      },
-      handleSize (size) {
-        this.pagination.pageNum = 1;
-        this.pagination.size = size;
-        this.getList();
-      },
-      getList () {
-        let params = { ...this.pagination, ...this.searchForm };
-        getMaterialList(params).then((res) => {
-          this.tableData = res.list;
-          this.total = res.count;
-          this.$nextTick(() => {
-            this.tableData.find((i) => {
-              if (i.id === this.current?.categoryId) {
-                this.$refs.tableRef.setCurrentRow(i);
-              }
-            });
-          });
-        });
-      },
-      selected () {
-        if (!this.current) {
-          return this.$message.warning('请选择物料组');
-        }
-        this.callBack && this.callBack(this.current);
-        this.$emit('changeMaterial', this.current);
-        this.handleClose();
-      }
-    }
-  };
-</script>
-
-<style lang="scss" scoped>
-  .tree_col {
-    border: 1px solid #eee;
-    padding: 10px 0;
-    box-sizing: border-box;
-    height: 500px;
-    overflow: auto;
-  }
-  .table_col {
-    padding-left: 10px;
-    ::v-deep .el-table th.el-table__cell {
-      background: #f2f2f2;
-    }
-  }
-  .pagination {
-    text-align: right;
-    padding: 10px 0;
-  }
-  .btns {
-    text-align: center;
-    padding: 10px 0;
-  }
-  .topsearch {
-    margin-bottom: 15px;
-  }
-</style>

+ 0 - 225
src/components/SelectDialog/productDialog.vue

@@ -1,225 +0,0 @@
-<template>
-  <el-dialog
-    title="选择产品"
-    :visible.sync="groupVisible"
-    :before-close="handleClose"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    append-to-body
-    width="60%"
-  >
-    <div>
-      <el-form label-width="80px">
-        <el-row>
-          <el-col :span="8">
-            <el-form-item label="分类" prop="categoryLevelId">
-              <categorySelect v-model="searchForm.categoryLevelId" pid="9" />
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="编码" prop="code">
-              <el-input v-model="searchForm.code"></el-input
-            ></el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="名称" prop="name">
-              <el-input v-model="searchForm.name"></el-input
-            ></el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="牌号" prop="brandNum">
-              <el-input v-model="searchForm.brandNum"></el-input
-            ></el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="型号" prop="modelType">
-              <el-input v-model="searchForm.modelType"></el-input
-            ></el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <div class="ele-form-actions">
-              <el-button icon="icon-reset" @click="handleReset">重置</el-button>
-              <el-button
-                type="primary"
-                icon="el-icon-search"
-                @click="handleSearch"
-                >搜索</el-button
-              >
-            </div>
-          </el-col>
-        </el-row>
-      </el-form>
-      <div class="table_col">
-        <el-table
-          :data="tableData"
-          height="450"
-          ref="tableRef"
-          highlight-current-row
-          @row-click="single"
-        >
-          <el-table-column label="编码" prop="code"></el-table-column>
-          <el-table-column
-            label="名称"
-            prop="name"
-            width="200"
-          ></el-table-column>
-          <el-table-column
-            label="牌号"
-            prop="brandNum"
-            width="200"
-          ></el-table-column>
-          <el-table-column
-            label="型号"
-            prop="modelType"
-            width="200"
-          ></el-table-column>
-          <el-table-column label="选择" align="center">
-            <template slot-scope="scope">
-              <el-radio class="radio" v-model="radio" :label="scope.row.id"
-                ><i></i
-              ></el-radio>
-            </template>
-          </el-table-column>
-        </el-table>
-        <div class="pagination">
-          <el-pagination
-            background
-            layout="total, sizes, prev, pager, next, jumper"
-            :total="total"
-            :page-sizes="[10, 20, 50, 100]"
-            :page-size="pagination.size"
-            :current-page.sync="pagination.pageNum"
-            @current-change="handleCurrent"
-            @size-change="handleSize"
-          >
-          </el-pagination> </div
-      ></div>
-    </div>
-    <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 { getList } from '@/api/classifyManage/itemInformation';
-  import categorySelect from '@/components/CommomSelect/category-select';
-  const defaultWhere = {
-    brandNum: null,
-    modelType: null,
-    name: null,
-    code: null,
-    categoryLevelId: '9',
-    isProduct: true,
-  };
-  export default {
-    components: { categorySelect },
-    data () {
-      return {
-        groupVisible: false,
-        tableData: [],
-        searchForm: { ...defaultWhere },
-        pagination: {
-          pageNum: 1,
-          size: 10
-        },
-        total: 0,
-        radio: '',
-        current: null,
-        callBack: null
-      };
-    },
-
-    watch: {},
-    methods: {
-      open (item, callBack) {
-        this.callBack = callBack;
-        if (item) {
-          this.current = item;
-          this.radio = item.categoryId || item.id;
-        }
-        this.groupVisible = true;
-        this.getList();
-      },
-      handleSearch () {
-        this.pagination.pageNum = 1;
-        this.getList();
-      },
-      handleReset () {
-        this.searchForm = { ...defaultWhere };
-        this.handleSearch();
-      },
-
-      // 单击获取id
-      single (row) {
-        this.current = row;
-        this.radio = row.id;
-      },
-
-      handleClose () {
-        this.groupVisible = false;
-        this.current = null;
-        this.radio = '';
-      },
-      handleCurrent (page) {
-        this.pagination.pageNum = page;
-        this.getList();
-      },
-      handleSize (size) {
-        this.pagination.pageNum = 1;
-        this.pagination.size = size;
-        this.getList();
-      },
-      getList () {
-        let params = { ...this.pagination, ...this.searchForm };
-        getList(params).then((res) => {
-          this.tableData = res.list;
-          this.total = res.count;
-          this.$nextTick(() => {
-            this.tableData.find((i) => {
-              if (i.id === this.current?.categoryId) {
-                this.$refs.tableRef.setCurrentRow(i);
-              }
-            });
-          });
-        });
-      },
-      selected () {
-        if (!this.current) {
-          return this.$message.warning('请选择物料组');
-        }
-        this.callBack && this.callBack(this.current);
-        this.$emit('changeMaterial', this.current);
-        this.handleClose();
-      }
-    }
-  };
-</script>
-
-<style lang="scss" scoped>
-  .tree_col {
-    border: 1px solid #eee;
-    padding: 10px 0;
-    box-sizing: border-box;
-    height: 500px;
-    overflow: auto;
-  }
-  .table_col {
-    padding-left: 10px;
-    ::v-deep .el-table th.el-table__cell {
-      background: #f2f2f2;
-    }
-  }
-  .pagination {
-    text-align: right;
-    padding: 10px 0;
-  }
-  .btns {
-    text-align: center;
-    padding: 10px 0;
-  }
-  .topsearch {
-    margin-bottom: 15px;
-  }
-</style>

+ 50 - 37
src/views/material/materialBOM/components/edit-dialog.vue

@@ -36,7 +36,7 @@
           </el-form-item>
         </el-col>
 
-<!-- 
+        <!-- 
         <el-col :span="8">
           <el-form-item label="分类层级" prop="categoryType">
             <el-select v-model="form.categoryType" placeholder="请选择" class="w100">
@@ -85,8 +85,8 @@
       <template v-slot:toolbar>
         <el-button type="primary" @click="add">添加</el-button>
       </template>
-      <template v-slot:action="{row, $index }">
-        <el-link type="primary" @click="handleDel(row,$index)">删除</el-link>
+      <template v-slot:action="{ row, $index }">
+        <el-link type="primary" @click="handleDel(row, $index)">删除</el-link>
       </template>
       <template v-slot:subCode="{ row }">
         <el-input v-model="row.subCode" placeholder="请输入"></el-input>
@@ -102,8 +102,8 @@
         ))
           "></el-input>
       </template>
-      <template v-slot:categoryName="{ row }">
-        <el-input :value="row.categoryName" placeholder="请选择" @click.native="categorySelect(row)"></el-input>
+      <template v-slot:categoryName="{ row, $index }">
+        <el-input :value="row.categoryName" placeholder="请选择" @click.native="categorySelect(row, $index)"></el-input>
       </template>
     </ele-pro-table>
 
@@ -111,20 +111,21 @@
       <el-button type="primary" @click="save">保存</el-button>
       <el-button @click="cancel">返回</el-button>
     </div>
-    <materialDialog ref="materialDialogRef" />
-    <productDialog ref="productDialogRef" />
+
+    <ProductModal ref="productRefs" @changeProduct='determineChoose' />
+
   </ele-modal>
 </template>
 
 <script>
-import materialDialog from '@/components/SelectDialog/materialDialog';
-import productDialog from '@/components/SelectDialog/productDialog';
+import ProductModal from '@/views/technology/productParam/components/ProductModal.vue'
+
 import factorySelect from '@/components/CommomSelect/factory-select.vue';
 import { getCode } from '@/api/codeManagement/index.js';
-import { getVersionCode, bomSave, bomUpdate,  getById, detailPage } from '@/api/material/BOM';
+import { getVersionCode, bomSave, bomUpdate, getById, detailPage } from '@/api/material/BOM';
 import { pageList } from '@/api/technology/version/version.js';
 export default {
-  components: { materialDialog, factorySelect, productDialog },
+  components: { ProductModal, factorySelect },
   props: {
     statusOpt: Object
   },
@@ -198,7 +199,7 @@ export default {
         },
         {
           label: '物料编码',
-          prop: 'categoryId'
+          prop: 'categoryCode'
         },
         {
           label: '牌号',
@@ -247,7 +248,7 @@ export default {
     };
   },
   methods: {
-   async open(type, row) {
+    async open(type, row) {
       this.title = type;
       this.row = row;
       this.getVersionList()
@@ -259,11 +260,11 @@ export default {
         this._getById(row.id);
 
 
-      const res  = await  detailPage({pageNum: 1, size: -1,  bomId: row.id})
-      this.tableData = res.list
- 
- 
-    
+        const res = await detailPage({ pageNum: 1, size: -1, bomId: row.id })
+        this.tableData = res.list
+
+
+
       }
     },
     add() {
@@ -292,29 +293,41 @@ export default {
       this.form.code = code;
     },
     selectProd() {
-      this.$refs.productDialogRef.open(this.form, (res) => {
-        this.form.categoryCode = res.code;
-        this.form.categoryId = res.id;
-        this.form.categoryName = res.name;
+      this.$refs.productRefs.open(this.form, '选择产品', '9')
+      
+    },
 
 
-        this.getVersion() // 获取版本号
-      });
+    categorySelect(row, idx) {
+      this.$refs.productRefs.open(row, '选择物料', '1', idx)
     },
-    categorySelect(row) {
-      this.$refs.materialDialogRef.open(row, (res) => {
-        row.categoryName = res.name;
-        row.categoryId = res.id;
-        row.unit = res.measuringUnit;
-        row.modelType = res.modelType;
-        row.brandNum = res.brandNum;
-      });
+
+    determineChoose(title, row, idx) {
+      if (title == '选择产品') {
+        this.$set(this.form, 'categoryName', row.name)
+        this.$set(this.form, 'categoryId', row.id)
+        this.$set(this.form, 'categoryCode', row.code)
+        this.getVersion()
+       
+
+      }
+      else if (title == '选择物料') {
+        this.$set(this.tableData[idx], 'categoryName', row.name)
+        this.$set(this.tableData[idx], 'categoryId', row.id)
+        this.$set(this.tableData[idx], 'categoryCode', row.code)
+        this.$set(this.tableData[idx], 'unit', row.measuringUnit)
+        this.$set(this.tableData[idx], 'brandNum', row.brandNum)
+        this.$set(this.tableData[idx], 'modelType', row.modelType)
+
+      }
+
     },
 
 
+
+
     async getVersion() {
       const res = await getVersionCode(this.form.categoryId);
-
       this.form.version = res
     },
 
@@ -337,7 +350,7 @@ export default {
         if (!this.isUpdate) {
           delete this.form.id;
         } else {
-          this.form.removeSubBomIdList =  this.removeSubBomIdList
+          this.form.removeSubBomIdList = this.removeSubBomIdList
         }
 
         const data = {
@@ -363,9 +376,9 @@ export default {
 
 
 
-    handleDel(row,index) {
+    handleDel(row, index) {
       this.tableData.splice(index, 1);
-      if(row?.id) {
+      if (row?.id) {
         this.removeSubBomIdList.push(row.id)
       }
     },
@@ -376,7 +389,7 @@ export default {
     async _getById(id) {
       const data = await getById(id);
       this.form = data;
-      this.form.status =  this.form.status + ''
+      this.form.status = this.form.status + ''
     },
 
 

+ 122 - 74
src/views/material/product/components/MaterialAdd.vue

@@ -67,22 +67,32 @@
 
             <el-row>
                 <div class="ele-body">
-                    <ele-pro-table ref="table" :datasource="form.subDetailList" row-key="id" :columns="columns">
+                    <ele-pro-table ref="table" :columns="columns" :datasource="tableData" height="calc(100vh - 550px)"
+                        :need-page="false">
                         <!-- 表头工具栏 -->
                         <template v-slot:toolbar>
-                            <el-button size="small" icon="el-icon-plus" class="ele-btn-icon" type="primary"
-                                @click.native="openParam()">添加物料</el-button>
+                            <el-button type="primary" @click="add">添加</el-button>
                         </template>
-
-                        <!-- 操作列 -->
-                        <template v-slot:action="{ row }">
-                            <el-popconfirm class="ele-action" title="确定要删除当前物料吗?" @confirm="remove(row)">
-                                <template v-slot:reference>
-                                    <el-link type="danger" :underline="false" icon="el-icon-delete">
-                                        删除
-                                    </el-link>
-                                </template>
-                            </el-popconfirm>
+                        <template v-slot:action="{ row, $index }">
+                            <el-link type="primary" @click="handleDel(row, $index)">删除</el-link>
+                        </template>
+                        <template v-slot:subCode="{ row }">
+                            <el-input v-model="row.subCode" placeholder="请输入"></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>
+                        <template v-slot:categoryName="{ row, $index }">
+                            <el-input :value="row.categoryName" placeholder="请选择"
+                                @click.native="categorySelect(row, $index)"></el-input>
                         </template>
                     </ele-pro-table>
                 </div>
@@ -94,28 +104,28 @@
                 </el-button>
             </el-row>
         </el-form>
-
-        <!-- 选择物料弹窗 -->
-        <materialDialog ref="materiaRef" @chooseModal="chooseModal"></materialDialog>
+        <ProductModal ref="productRefs" @changeProduct='determineChoose' />
     </ele-modal>
 </template>
   
 <script>
-import materialDialog from '@/components/material';
+
 import factorySelect from '@/components/CommomSelect/factory-select.vue';
 import { pageList } from '@/api/technology/version/version.js';
 import { getCode } from '@/api/codeManagement/index.js';
 import { bomSave, bomUpdate } from '@/api/material/BOM';
+import ProductModal from '@/views/technology/productParam/components/ProductModal.vue'
 export default {
     components: {
-        materialDialog,
-        factorySelect
+        factorySelect,
+        ProductModal
     },
     props: {
         // 弹窗是否打开
         visible: Boolean,
         // 修改回显的数据
-        categoryId: [String, Number]
+        categoryId: [String, Number],
+        data: Object,
     },
     data() {
 
@@ -141,7 +151,8 @@ export default {
             produceVersionId: '',
             baseCount: '',
             baseCountUnit: '',
-            subDetailList: []
+          
+
         };
         return {
             defaultForm,
@@ -150,6 +161,7 @@ export default {
                 ...defaultForm
             },
 
+            removeSubBomIdList: [],
             versionList: [],
 
             // 表单验证规则
@@ -184,45 +196,54 @@ export default {
                 ]
 
             },
-
             columns: [
                 {
-                    prop: 'code',
-                    label: '编码'
+                    type: 'index',
+                    width: 55,
+                    align: 'center'
                 },
                 {
-                    prop: 'name',
-                    label: '名称',
-                    showOverflowTooltip: true
+                    label: '子项编号',
+                    prop: 'subCode',
+                    slot: 'subCode',
+                    action: 'subCode'
                 },
                 {
-                    prop: 'brandNum',
-                    label: '牌号'
+                    label: '物料名称',
+                    prop: 'categoryName',
+                    slot: 'categoryName',
+                    action: 'categoryName'
                 },
                 {
-                    prop: 'modelType',
-                    label: '型号'
+                    label: '物料编码',
+                    prop: 'categoryCode'
                 },
                 {
-                    prop: 'weightUnit',
-                    label: '重量单位'
+                    label: '牌号',
+                    prop: 'brandNum'
                 },
                 {
-                    prop: 'netWeight',
-                    label: '净重'
+                    label: '型号',
+                    prop: 'modelType'
                 },
-
                 {
-                    columnKey: 'action',
-                    label: '操作',
-
-                    align: 'center',
-                    resizable: false,
+                    label: '净重',
+                    slot: 'count',
+                    action: 'count'
+                },
+                {
+                    label: '重量单位',
+                    slot: 'unit',
+                    action: 'unit'
+                },
+                {
+                    action: 'action',
                     slot: 'action',
-                    showOverflowTooltip: true
+                    label: '操作'
                 }
             ],
 
+            tableData: [],
             statusList: [
                 { label: '草稿', value: -1 },
                 { label: '失效', value: 0 },
@@ -244,26 +265,39 @@ export default {
         }
     },
     methods: {
-        openParam() {
-            this.$refs.materiaRef.open(this.form.subDetailList, '选择物料', '1');
-        },
 
-        chooseModal(data) {
-            this.$set(this.form, 'subDetailList', data);
-        },
 
-        /* 删除 */
-        remove(row) {
-            this.form.subDetailList = this.form.subDetailList.filter(
-                (d) => d.id !== row.id
-            );
+        handleDel(row, index) {
+            this.tableData.splice(index, 1);
+            if (row?.id) {
+                this.removeSubBomIdList.push(row.id)
+            }
         },
 
-        /* 表格数据源 */
-        datasource({ page, limit, where }) {
-            return [];
+        add() {
+            let subCode = '0010';
+            if (this.tableData.length) {
+                let max = Math.max(...this.tableData.map((i) => i.subCode)) + 10 + '';
+
+                if (max.length < 4) {
+                    max = new Array(4 - max.length).fill('0').join('') + max;
+                }
+                subCode = max.substring(0, max.length - 1) + '0';
+            }
+
+            this.tableData.push({
+                subCode,
+                categoryId: '',
+                categoryName: '',
+                brandNum: '',
+                count: '',
+                modelType: '',
+                unit: ''
+            });
         },
 
+
+
         async _getCode() {
             const code = await getCode('bom_code');
             this.form.code = code;
@@ -285,21 +319,10 @@ export default {
                     return false;
                 }
 
-                
-                let _arr = []
-                _arr = this.form.subDetailList.map((m) => {
-                    return{
-                        bomId: '',
-                        categoryId: m.id,
-                        count: '',
-                        id: m.id,
-                        sortNum: '',
-                        subCode: m.code,
-                        unit:  m.measuringUnit
-                    }
-                })
-           
-                if (_arr.length == 0) {
+
+
+
+                if (this.tableData.length == 0) {
                     this.$message.info('请至少添加一条物料');
                     return;
                 }
@@ -310,7 +333,8 @@ export default {
 
                 const data = {
                     ...this.form,
-                    subDetailList: _arr,
+                    removeSubBomIdList: this.removeSubBomIdList,
+                    subDetailList: this.tableData,
                     categoryId: this.categoryId,
                 };
 
@@ -321,8 +345,8 @@ export default {
                     .then((msg) => {
                         this.loading = false;
                         this.$message.success(msg);
-                        this.visible = false
                         this.$emit('done');
+                        this.visible = false
                     })
                     .catch((e) => {
                         this.loading = false;
@@ -330,6 +354,28 @@ export default {
 
             });
         },
+
+
+        categorySelect(row, idx) {
+            this.$refs.productRefs.open(row, '选择物料', '1', idx)
+
+        },
+
+        determineChoose(title, row, idx) {
+            if (title == '选择物料') {
+                this.$set(this.tableData[idx], 'categoryName', row.name)
+                this.$set(this.tableData[idx], 'categoryId', row.id)
+                this.$set(this.tableData[idx], 'categoryCode', row.code)
+                this.$set(this.tableData[idx], 'unit', row.measuringUnit)
+                this.$set(this.tableData[idx], 'brandNum', row.brandNum)
+                this.$set(this.tableData[idx], 'modelType', row.modelType)
+
+            }
+
+        },
+
+
+
         /* 更新visible */
         updateVisible(value) {
             this.$emit('update:visible', value);
@@ -341,11 +387,13 @@ export default {
             if (visible) {
                 this._getCode()
                 this.getVersionList();
+                this.removeSubBomIdList = []
                 if (this.data) {
-                    this.isUpdate = true
+                    this.tableData = this.data.subDetailList
                     this.$util.assignObject(this.form, {
                         ...this.data
                     });
+                    this.isUpdate = true
                 } else {
                     this.isUpdate = false
                 }

+ 68 - 145
src/views/material/product/components/MaterialModal.vue

@@ -5,7 +5,6 @@
         <header-title title="基本信息"></header-title>
         <el-form ref="form" :model="form" :rules="rules" label-width="120px">
             <el-row>
-
                 <el-col :span="8">
                     <el-form-item label="产品名称:" prop="name">
                         <el-input disabled v-model="form.name" readonly />
@@ -18,9 +17,6 @@
                     </el-form-item>
                 </el-col>
 
-
-
-
                 <el-col :span="8">
                     <el-form-item label="型号:" prop="modelType">
                         <el-input disabled v-model="form.modelType" placeholder="自动带入" />
@@ -33,40 +29,28 @@
                     </el-form-item>
                 </el-col>
 
-
                 <el-col :span="8">
                     <el-form-item label="规格:" prop="specification">
                         <el-input disabled v-model="form.specification" placeholder="自动带入" />
                     </el-form-item>
                 </el-col>
 
-
                 <el-col :span="8">
                     <el-form-item label="计量单位:" prop="measuringUnit">
                         <el-input disabled v-model="form.measuringUnit" placeholder="自动带入" />
                     </el-form-item>
                 </el-col>
-
-
-
             </el-row>
 
-
             <header-title title="物料BOM">
                 <div>
                     <el-button size="small" icon="el-icon-plus" class="ele-btn-icon" type="primary"
                         @click="handleAdd">新增</el-button>
-
-
-
-
                 </div>
             </header-title>
 
-            <el-card v-for="(bomItem, index) in form.list" :key="index">
-
+            <el-card v-for="(bomItem, index) in form.bomList" :key="index">
                 <el-row>
-
                     <el-col :span="8">
                         <el-form-item label="BOM编码:">
                             {{ bomItem.code }}
@@ -95,7 +79,6 @@
                         </el-form-item>
                     </el-col>
 
-
                     <el-col :span="8">
                         <el-form-item label="生产版本:" prop="produceVersionId">
                             <el-select v-model="bomItem.produceVersionId" filterable placeholder="清选择" disabled
@@ -126,75 +109,46 @@
                             </el-row>
                         </el-form-item>
                     </el-col>
-
-
-
-
-
                 </el-row>
 
-
                 <el-row>
-
                     <div class="ele-body">
-                        <ele-pro-table ref="table" :datasource="bomItem.materialList" row-key="id" :columns="columns">
-                            <!-- 表头工具栏 -->
+                        <ele-pro-table ref="table" :columns="columns" :need-page="false" row-key="id"
+                            :datasource="bomItem.subDetailList" min-height="200px">
                             <template v-slot:toolbar>
-                                <el-button size="small" icon="el-icon-plus" class="ele-btn-icon" type="primary"
-                                    @click.native="openParam(index)">添加物料</el-button>
-
-                                <el-button size="small" type="danger" icon="el-icon-delete"
-                                    @click="removeBom(index)">删除</el-button>
-
-                            </template>
+                                <el-button type="primary" size="small" @click="openEdit(index)">编辑</el-button>
 
-                            <!-- 操作列 -->
-                            <template v-slot:action="{ row }">
-                                <el-popconfirm class="ele-action" title="确定要删除当前物料吗?" @confirm="remove(index, row)">
+                                <el-popconfirm class="ele-action" title="确定要删除此物料BOM?" @confirm="remove(bomItem)">
                                     <template v-slot:reference>
-                                        <el-link type="danger" :underline="false" icon="el-icon-delete">
+                                        <el-button type="danger" size="small" icon="el-icon-delete">
                                             删除
-                                        </el-link>
+                                        </el-button>
                                     </template>
                                 </el-popconfirm>
                             </template>
                         </ele-pro-table>
                     </div>
-
                 </el-row>
-
-
             </el-card>
-
-
         </el-form>
 
-
-
-
-
-
-        <!-- 选择物料弹窗 -->
-        <materialDialog ref="materiaRef" @chooseModal="chooseModal"></materialDialog>
-
         <!-- 物料Bom -->
-        <MaterialAdd :visible.sync="materialShow" :categoryId="categoryId" ref="materialAddRef"></MaterialAdd>
-
-
-
+        <MaterialAdd :visible.sync="materialShow" :data="current" :categoryId="categoryId" @done="done"
+            ref="materialAddRef">
+        </MaterialAdd>
     </ele-modal>
 </template>
   
 <script>
-import materialDialog from '@/components/material'
-import MaterialAdd from './MaterialAdd.vue'
-import { pageList } from '@/api/technology/version/version.js';
-import { getCategoryBom } from '@/api/material/product'
 
+import MaterialAdd from './MaterialAdd.vue';
+import { pageList } from '@/api/technology/version/version.js';
+import { getCategoryBom } from '@/api/material/product';
+import { bomDelete } from '@/api/material/BOM';
 import factorySelect from '@/components/CommomSelect/factory-select.vue';
+
 export default {
     components: {
-        materialDialog,
         MaterialAdd,
         factorySelect
     },
@@ -215,91 +169,76 @@ export default {
             specification: '',
             measuringUnit: '',
 
-            list: [
-            ]
-
+            bomList: []
         };
         return {
             defaultForm,
             // 表单数据
             form: {
-                ...defaultForm,
-
+                ...defaultForm
             },
 
             versionList: [],
 
-
-
             // 表单验证规则
             rules: {
                 categoryName: [
                     { required: true, message: '请输入产品名称', trigger: 'blur' }
-                ],
-
-
-
+                ]
             },
 
-
             columns: [
-
                 {
-                    prop: 'code',
-                    label: '编码'
+                    type: 'index',
+                    width: 55,
+                    align: 'center'
                 },
                 {
-                    prop: 'name',
-                    label: '名称',
-                    showOverflowTooltip: true
+                    label: '子项编号',
+                    prop: 'subCode',
+                    action: 'subCode'
                 },
                 {
-                    prop: 'brandNum',
-                    label: '牌号'
+                    label: '物料名称',
+                    prop: 'categoryName',
+                    action: 'categoryName'
                 },
                 {
-                    prop: 'modelType',
-                    label: '型号'
+                    label: '物料编码',
+                    prop: 'categoryCode'
                 },
                 {
-                    prop: 'weightUnit',
-                    label: '重量单位'
+                    label: '牌号',
+                    prop: 'brandNum'
                 },
                 {
-                    prop: 'netWeight',
-                    label: '净重'
+                    label: '型号',
+                    prop: 'modelType'
                 },
-
                 {
-                    columnKey: 'action',
-                    label: '操作',
-
-                    align: 'center',
-                    resizable: false,
-                    slot: 'action',
-                    showOverflowTooltip: true
+                    label: '净重',
+                    prop: 'count'
+                },
+                {
+                    label: '重量单位',
+                    prop: 'unit'
                 }
-
             ],
 
-
             statusList: [
                 { label: '草稿', value: -1 },
                 { label: '失效', value: 0 },
                 { label: '生效', value: 1 }
             ],
 
-
             // 提交状态
             loading: false,
 
-
             categoryId: null,
 
-            tableData: [],
+            current: null,
 
             materialShow: false
-
         };
     },
     computed: {
@@ -309,87 +248,71 @@ export default {
         }
     },
     methods: {
-
-
-
-
-        openParam(index) {
-            this.tableData = this.form.list[index].materialList
-            this.$refs.materiaRef.open(this.tableData, '选择物料', '1', index)
-        },
-
-        chooseModal(data, id, idx) {
-            this.$set(this.form.list[idx], 'materialList', data)
-
+        openEdit(index) {
+            this.current = this.form.bomList[index];
+            console.log(this.current);
+            this.materialShow = true;
         },
 
-
-
-
-        /* 删除 */
-        remove(index, row) {
-            console.log(row)
-            this.form.list[index].materialList = this.form.list[index].materialList.filter((d) => d.id !== row.id)
-
-        },
-
-
         /* 表格数据源 */
         datasource({ page, limit, where }) {
-            return []
+            return [];
         },
 
-
         async getVersionList() {
             const res = await pageList({
                 pageNum: 1,
                 size: 100
             });
 
-            this.versionList = res.list
+            this.versionList = res.list;
         },
 
         handleAdd() {
-            this.materialShow = true
-        },
-
-        removeBom(index) {
-            this.form.list.splice(index, 1)
+            this.current = null;
+            this.materialShow = true;
         },
 
-
-
         /* 更新visible */
         updateVisible(value) {
             this.$emit('update:visible', value);
         },
 
         async getCategoryBomFn() {
-            const res = await getCategoryBom(this.categoryId)
-            this.form.list = res.bomList
-            console.log(res)
+            const res = await getCategoryBom(this.categoryId);
+            this.form.bomList = res.bomList;
         },
 
+        remove(row) {
+            bomDelete([row.id])
+                .then((message) => {
+                    this.$message.success(message);
+                    this.getCategoryBomFn();
+                })
+                .catch((e) => {
+                    this.$message.error(e.message);
+                });
+        },
+
+        done() {
+            this.materialShow = false
+            this.getCategoryBomFn();
+        },
 
     },
 
     watch: {
         async visible(visible) {
             if (visible) {
-                this.getVersionList()
+                this.getVersionList();
                 if (this.data) {
-                    this.categoryId = this.data.id
-                    this.getCategoryBomFn()
+                    this.categoryId = this.data.id;
+                    this.getCategoryBomFn();
                     this.$util.assignObject(this.form, {
                         ...this.data
                     });
-
                 } else {
-
-
                 }
-
-
             } else {
                 this.$refs.form.clearValidate();
                 this.form = { ...this.defaultForm };

+ 3 - 3
src/views/material/product/components/index-data.vue

@@ -26,12 +26,12 @@
         </el-popconfirm>
 
 
-        <el-link type="primary" :underline="false" @click="openParam(row)">
+        <el-link type="primary" v-if="row.isProduct == 1" :underline="false" @click="openParam(row)">
           工艺参数
         </el-link>
-        <!-- v-if="row.isProduct == 1" -->
+  
 
-        <el-link  type="primary" :underline="false" @click="openMaterial(row)">
+        <el-link  type="primary" v-if="row.isProduct == 1" :underline="false" @click="openMaterial(row)">
           物料BOM
         </el-link>
 

+ 8 - 12
src/views/technology/productParam/components/ProductModal.vue

@@ -122,7 +122,8 @@ export default {
       ],
       title: null,
       categoryLevelId: null,
-      radio: null
+      radio: null,
+      idx: null
     }
   },
 
@@ -148,12 +149,13 @@ export default {
     reload(where) {
       this.$refs.table.reload({ pageNum: 1, where: where });
     },
-    open(item, title, categoryLevelId) {
+    open(item, title, categoryLevelId, idx) {
       if (item) {
         this.title = title
         this.categoryLevelId = categoryLevelId
+        this.idx = idx
 
-        if (title == '选择产品') {
+        if (title == '选择产品' || title == '选择舟皿' || title == '选择物料') {
           this.current = {
             id: item.categoryId,
             name: item.categoryName,
@@ -161,14 +163,8 @@ export default {
           }
           this.radio = item.categoryId
 
-        } else if (title == '选择舟皿') {
-          this.current = {
-            id: item.categoryId,
-            name: item.categoryName,
-            code: item.categoryCode
-          }
-          this.radio = item.categoryId
-        }
+        } 
+
 
       }
       this.visible = true
@@ -192,7 +188,7 @@ export default {
       if (!this.current) {
         return this.$message.warning('请选择工作中心')
       }
-      this.$emit('changeProduct', this.title, this.current)
+      this.$emit('changeProduct', this.title, this.current, this.idx)
       this.handleClose()
     },
   }

+ 1 - 1
src/views/technology/productParam/components/user-edit.vue

@@ -362,7 +362,7 @@ export default {
         this.$set(this.form, 'categoryName', row.name)
         this.$set(this.form, 'categoryId', row.id)
         this.$set(this.form, 'categoryCode', row.code)
-        this.$set(this.form, 'categoryModelType', row.name)
+        this.$set(this.form, 'categoryModelType', row.modelType)
         this.$set(this.form, 'categoryBrandNum', row.brandNum)
         this.$set(this.form, 'specification', row.specification)
       } else if (title == '选择舟皿') {

+ 1 - 1
src/views/workforceManagement/team/components/edit.vue

@@ -77,7 +77,7 @@
             </el-form-item>
           </el-col>
           <el-col :span="8" style="margin-bottom: 22px">
-            <el-form-item label="工站:" prop="workStationIds">
+            <el-form-item label="工作中心:" prop="workStationIds">
               <div class="location-warp">
                 <el-select
                   v-model="form.workStationIds"