From 44c2b0d615ac22c074920486a6bd9c991cd3ece3 Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期二, 13 八月 2024 17:16:48 +0800
Subject: [PATCH] 1.BOM页面  开发完成50%

---
 src/api/ProductModel.js                    |   27 +++
 src/views/materialManager/materialList.vue |  353 ++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 293 insertions(+), 87 deletions(-)

diff --git a/src/api/ProductModel.js b/src/api/ProductModel.js
index 96ff5d7..1b9b71f 100644
--- a/src/api/ProductModel.js
+++ b/src/api/ProductModel.js
@@ -159,3 +159,30 @@
     params: data
   })
 }
+
+// 鐗╂枡娓呭崟鏂板淇敼鑾峰彇瀛愪欢淇℃伅-T+鐣呮嵎閫氭ā寮�
+export function AddUpdateTBomDetailsData(data) {
+  return request({
+    url: 'ProductModel/AddUpdateTBomDetailsData',
+    method: 'get',
+    params: data
+  })
+}
+
+// 鐗╂枡娓呭崟鏂板淇敼鑾峰彇瀛愪欢Bom-T+鐣呮嵎閫氭ā寮�
+export function AddUpdateTBomDetailsBomData(data) {
+  return request({
+    url: 'ProductModel/AddUpdateTBomDetailsBomData',
+    method: 'get',
+    params: data
+  })
+}
+
+// 鐗╂枡娓呭崟鏂板淇敼鎻愪氦-T+鐣呮嵎閫氭ā寮�
+export function TBomAddUpdate(data, OperType) {
+  return request({
+    url: 'ProductModel/TBomAddUpdate?OperType=' + OperType,
+    method: 'post',
+    data
+  })
+}
diff --git a/src/views/materialManager/materialList.vue b/src/views/materialManager/materialList.vue
index 3eac471..2d3088f 100644
--- a/src/views/materialManager/materialList.vue
+++ b/src/views/materialManager/materialList.vue
@@ -24,17 +24,6 @@
             <el-form-item label="姣嶄欢瑙勬牸" style=" display: flex;">
               <el-input v-model="form.parentpartspec" placeholder="璇疯緭鍏�" style="width: 200px" />
             </el-form-item>
-            <!--            <el-form-item label="瀛樿揣绫诲瀷" style=" display: flex;">-->
-            <!--              <el-select v-model="form.parttype" style="width: 200px" placeholder="璇烽�夋嫨">-->
-            <!--                <el-option-->
-            <!--                  v-for="item in parttypeArr"-->
-            <!--                  :key="item.code"-->
-            <!--                  :label="item.name"-->
-            <!--                  :value="item.code"-->
-            <!--                />-->
-            <!--              </el-select>-->
-            <!--            </el-form-item>-->
-
             <el-form-item label="鐗堟湰缂栧彿" style=" display: flex;">
               <el-input v-model="form.version" placeholder="璇疯緭鍏�" style="width: 200px" />
             </el-form-item>
@@ -316,6 +305,7 @@
           label-width="80px"
           style="margin-left: 20px;"
         >
+
           <el-form-item label="姣嶄欢缂栫爜" prop="parentpartcode">
             <el-select
               v-model="dialogForm.parentpartcode"
@@ -399,6 +389,10 @@
           <el-form-item label="鐗堟湰鍙�" prop="version">
             <el-input v-model="dialogForm.version" disabled style="width: 200px" />
           </el-form-item>
+
+          <el-form-item label="榛樿BOM">
+            <el-checkbox v-model="dialogForm.isdefaultbom" />
+          </el-form-item>
         </el-form>
       </div>
 
@@ -448,7 +442,7 @@
               @change="val=>tableChange(val,row)"
             >
               <el-option
-                v-for="item in PartSelectArr"
+                v-for="item in PartDetailSelectArr"
                 :key="item.partcode"
                 :label="item.partcode+' / '+item.partname"
                 :value="item.partcode"
@@ -490,6 +484,50 @@
             </el-select>
           </template>
         </el-table-column>
+        <el-table-column
+          prop="idchildbom"
+          label="瀛愪欢BOM"
+          width="110"
+          show-tooltip-when-overflow
+        >
+          <template slot-scope="{row}">
+            <el-select
+              v-model="row.idchildbom"
+              style="width: 490px"
+              placeholder="璇烽�夋嫨"
+            >
+              <template slot="empty">
+                <el-table
+                  :data="row.tableData2"
+                  border
+                  stripe
+                  class="tableFixed"
+                  highlight-current-row
+                  :row-class-name="tableRowClassName"
+                  style="width: 100%"
+                  height="200"
+                  @row-click="rowClick"
+                >
+                  <el-table-column
+                    prop="partcode"
+                    label="浜у搧缂栫爜"
+                    width="180"
+                  />
+                  <el-table-column
+                    prop="partname"
+                    label="浜у搧鍚嶇О"
+                    width="180"
+                  />
+                  <el-table-column
+                    prop="unitcode"
+                    label="鍏跺畠"
+                  />
+                </el-table>
+              </template>
+            </el-select>
+          </template>
+        </el-table-column>
+
         <el-table-column
           prop="BASE_QUANTITY"
           label="鍩烘湰鐢ㄩ噺"
@@ -539,10 +577,6 @@
         >
           <template slot-scope="{row}">
             <div class="operationClass">
-              <!--                      <el-button v-if="row.isVisible===1" v-waves type="text" @click="saveRow(row)">纭畾</el-button>-->
-              <!--                      <el-button v-if="row.isVisible===1" v-waves type="text" @click="cancelRow(row)">鍙栨秷</el-button>-->
-              <!--                      <el-button v-if="row.isVisible===0" v-waves type="text" @click="editRow(row)">缂栬緫</el-button>-->
-              <!--                      <el-button v-if="row.isVisible===0" v-waves type="text" @click="delRow(row)">鍒犻櫎</el-button>-->
               <el-button v-waves type="text" @click="delRow(row)">鍒犻櫎</el-button>
             </div>
           </template>
@@ -579,7 +613,7 @@
   AddUpdateTBomUnitGroup,
   BomMainData,
   AddUpdateTBomParentData,
-  TMaterielClassTree, AddUpdateTBomMaxVsion
+  AddUpdateTBomDetailsData, AddUpdateTBomMaxVsion, AddUpdateTBomDetailsBomData, TBomAddUpdate
 } from '@/api/ProductModel'
 
 export default {
@@ -608,7 +642,7 @@
         page: 1, // 绗嚑椤�
         rows: 20 // 姣忛〉澶氬皯鏉�
       },
-      parttypeArr: [], // 瀛樿揣绫诲瀷
+
       openTypeArr: [// 鍚敤鐘舵��
         { label: '鏄�', value: 'Y' },
         { label: '鍚�', value: 'N' }
@@ -743,7 +777,8 @@
         quantity: '',
         status: 'Y',
         startdate: '',
-        version: ''
+        version: '',
+        isdefaultbom: false
       },
       operation: '',
       dialogFormRules: {
@@ -773,11 +808,8 @@
       PartSelectArr: [], // 浜у搧鍙�夊��
       PartSelectArrTemp: [], // 浜у搧宸查�夋殏瀛樺��
       dialogTableDataArr: [],
-      sxArr: [
-        { code: 'Z', name: '涓绘枡' },
-        { code: 'F', name: '杈呮枡' }
-      ],
-      UnitGroupArr: []// 璁¢噺鍗曚綅鏁扮粍
+      UnitGroupArr: [], // 璁¢噺鍗曚綅鏁扮粍
+      PartDetailSelectArr: []
 
     }
   },
@@ -785,7 +817,7 @@
   created() {
     this.getBomMainData()
     this.getAddUpdateTBomParentData()
-    // this.getStockTypeSelect()
+    this.getAddUpdateTBomDetailsData()
   },
   mounted() {
     window.addEventListener('resize', this.getHeight)
@@ -833,9 +865,9 @@
       this.PartSelectArrAll = res
     },
     // 鑾峰彇瀛樿揣绫诲瀷涓嬫媺鎺ュ彛
-    async getStockTypeSelect() {
-      const { data: res } = await TMaterielClassTree()
-      this.parttypeArr = res
+    async getAddUpdateTBomDetailsData() {
+      const { data: res } = await AddUpdateTBomDetailsData()
+      this.PartDetailSelectArr = res
     },
     async partSelectChange(val) {
       const res = this.PartSelectArr.find(item => item.partcode === val)
@@ -921,6 +953,7 @@
           // item.isVisible = 0
           // item.number = number
           this.dialogTableDataArr.push({
+            id: item.id,
             SEQ: item.seq,
             isVisible: 0,
             number,
@@ -979,6 +1012,9 @@
         const { data: r } = await AddUpdateTBomUnitGroup({ idunitgroup: res.idunitgroup })
         row.UnitGroupArr = r
       }
+
+      const { data: r2 } = await AddUpdateTBomDetailsBomData({ materiel_code: val })
+      row.tableData2 = r2
     },
 
     addDialog() {
@@ -986,7 +1022,7 @@
       //   return this.$message.info('璇峰厛淇濆瓨鏈潯璁板綍锛�')
       // }
 
-      let number = Math.random() * Math.random()// 浣滀负鍒犻櫎鏃剁殑鏍囪瘑绗�
+      let number = Math.random() * Math.random() // 浣滀负鍒犻櫎鏃剁殑鏍囪瘑绗�
       number = number === 0 ? (10 + Math.random()) : number
       this.dialogTableDataArr.push({
         SEQ: (this.dialogTableDataArr.length + 1) + '0',
@@ -998,47 +1034,13 @@
         uomcode: '',
         uomname: '',
         UnitGroupArr: [],
+        tableData2: [],
         BASE_QUANTITY: '',
         LOSS_QUANTITY: '',
         TOTAL_QUANTITY: ''
       })
     },
-    saveRow(row) {
-      if (row.SMATERIRL_CODE === '' || row.BASE_QUANTITY === '' || row.LOSS_QUANTITY === '') {
-        return this.$message.info('淇濆瓨澶辫触锛岃琛屽唴瀹规湭濉叏锛�')
-      }
-
-      row.isVisible = 0
-      this.PartSelectArr = this.PartSelectArr.filter(i => i.partcode !== row.SMATERIRL_CODE)
-    },
-    cancelRow(row) {
-      row.isVisible = 0
-      this.dialogTableDataArr = this.dialogTableDataArr.filter(i => i.number !== row.number)
-    },
-    editRow(row) {
-      if (this.dialogTableDataArr.find(item => item.isVisible === 1)) {
-        return this.$message.info('璇峰厛淇濆瓨鍏跺畠琛岃褰曪紒')
-      }
-
-      row.isVisible = 1
-
-      this.PartSelectArrAll.forEach(item => {
-        if (item.partcode === row.SMATERIRL_CODE) {
-          this.PartSelectArr.unshift(item)
-        }
-      })
-    },
     delRow(row) {
-      // this.PartSelectArrAll.forEach(item => {
-      //   if (item.partcode === row.SMATERIRL_CODE) {
-      //     this.PartSelectArr.unshift(item)
-      //   }
-      // })
-      this.dialogTableDataArr.forEach((item, index) => {
-        if (item.SMATERIRL_CODE === row.SMATERIRL_CODE) {
-          this.dialogTableDataArr.splice(index, 1)
-        }
-      })
       this.dialogTableDataArr.forEach((item, index) => {
         item.SEQ = (index + 1) + '0'
       })
@@ -1075,6 +1077,7 @@
       this.dialogForm.status = 'Y'
       this.dialogForm.startdate = ''
       this.dialogForm.version = ''
+      this.dialogForm.isdefaultbom = false
       this.PartSelectArr = []
       this.PartSelectArrAll = []
       this.PartSelectArrTemp = []
@@ -1093,33 +1096,72 @@
 
       this.$refs.dialogForm.validate(valid => {
         if (valid) {
+          // [
+          //   {
+          //     'id': 'string',
+          //     'm_id': 'string',
+          //     'seq': 'string',
+          //     'materiel_code': 'string',
+          //     'materiel_name': 'string',
+          //     'materiel_spec': 'string',
+          //     'unitcode': 'string',
+          //     'base_quantity': 'string',
+          //     'loss_quantity': 'string',
+          //     'total_quantity': 'string',
+          //     'idchildbom': 'string'
+          //   }
+          // ]
+          const children = []
+
+          this.dialogTableDataArr.forEach(i => {
+            children.push({
+              id: i.id,
+              m_id: this.dialogForm.bomid,
+              'seq': i.SEQ,
+              'materiel_code': i.SMATERIRL_CODE,
+              'materiel_name': i.SMATERIRL_NAME,
+              'materiel_spec': i.SMATERIRL_SPEC,
+              'unitcode': i.uomcode,
+              'base_quantity': i.BASE_QUANTITY,
+              'loss_quantity': i.LOSS_QUANTITY,
+              'total_quantity': i.TOTAL_QUANTITY,
+              'idchildbom': ''
+            })
+          })
+
           const data = {
-            bomid: this.dialogForm.bomid,
-            parentpartcode: this.dialogForm.parentpartcode,
-            parentpartname: this.dialogForm.parentpartname,
-            parentpartspec: this.dialogForm.parentpartspec,
-            uomcode: this.PartSelectArrTemp.length > 0 ? this.PartSelectArrTemp[0].uom_code : this.dialogForm.uomcode,
-            quantity: this.dialogForm.quantity,
-            status: this.dialogForm.status,
-            startdate: this.dialogForm.startdate,
-            version: this.dialogForm.version,
-            worklist: this.dialogTableDataArr,
-            opertype: this.operation === 'add' ? 'Add' : 'Update'
+            'id': '',
+            'materiel_code': this.dialogForm.parentpartcode,
+            'materiel_name': this.dialogForm.parentpartname,
+            'materiel_spec': this.dialogForm.parentpartspec,
+            'materiel_typecode': '',
+            'materiel_typename': '',
+            'unitcode': this.dialogForm.uomcode,
+            'unitname': this.UnitGroupArr.find(i => i.unitcode === this.dialogForm.uomcode).unitname,
+            'quantity': this.dialogForm.quantity,
+            'status': this.dialogForm.status,
+            'startdate': this.dialogForm.startdate,
+            'version': this.dialogForm.version,
+            'isdefaultbom': this.dialogForm.isdefaultbom ? '1' : '0',
+            'bomdepth': '',
+            'lm_user': '',
+            'lm_date': '',
+            children
           }
-          // console.log(data)
+          console.log(JSON.parse(JSON.stringify(data)))
 
           this.$store.state.app.buttonIsDisabled = true
-          // AddUpdateBoIventory(data).then(res => {
-          //   if (res.code === '200') {
-          //     this.dialogVisible = false
-          //     this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
-          //     this.getBomMainData()
-          //     this.$store.state.app.buttonIsDisabled = false
-          //   } else {
-          //     this.$message.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
-          //     this.$store.state.app.buttonIsDisabled = false
-          //   }
-          // })
+          TBomAddUpdate(data, this.operation === 'add' ? 'Add' : 'Update').then(res => {
+            if (res.code === '200') {
+              this.dialogVisible = false
+              this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
+              this.getBomMainData()
+              this.$store.state.app.buttonIsDisabled = false
+            } else {
+              this.$message.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
+              this.$store.state.app.buttonIsDisabled = false
+            }
+          })
         }
       })
     },
@@ -1134,7 +1176,12 @@
     },
     tableRowClassName({ row, rowIndex }) {
       return 'custom-row'
+    },
+
+    rowClick(row, column, event) {
+      // this.dialogForm.parentpartcode = row.partcode
     }
+
   }
 }
 </script>
@@ -1146,3 +1193,135 @@
   height: 34px;
 }
 </style>
+<!--鍏叡椤甸潰鏍峰紡-->
+<style lang="scss" scoped>
+$main_color: #42b983;
+::v-deep .el-button--text {
+  font-size: 14px;
+  cursor: pointer;
+}
+
+.el-icon-share, .el-icon-delete, .el-icon-edit-outline {
+  color: $main_color;
+  cursor: pointer;
+}
+
+.el-icon-edit-outline {
+  margin-right: 15px;
+}
+
+::v-deep .el-button--primary, .el-button--default, .el-button--info {
+  height: 34px;
+  display: flex;
+  align-items: center;
+  padding: 0 15px;
+}
+
+::v-deep .el-button--primary {
+  //background-color: $main_color !important;
+}
+
+::v-deep .el-button--default {
+  background-color: #f8f8fa;
+  border: none;
+}
+
+::v-deep .el-input__inner {
+  height: 34px;
+  line-height: 34px;
+  //color: #a7a7a7;
+}
+
+::v-deep .el-dialog__body {
+  //padding: 20px 100px !important;
+  padding: 20px !important;
+}
+
+::v-deep .dialogVisibleRoles .el-dialog__body {
+  padding: 20px 20px !important;
+}
+
+::v-deep .importPickerClass .el-dialog__body {
+  padding: 20px 20px !important;
+}
+
+::v-deep .el-dialog__footer {
+  display: flex;
+  justify-content: flex-end;
+}
+
+::v-deep .el-table .caret-wrapper {
+  transform: scale(0.8);
+}
+
+::v-deep .cell {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+}
+
+::v-deep .el-table::before {
+  height: 0;
+}
+
+::v-deep .el-table__body-wrapper {
+  background-color: #f8f8fa;
+}
+
+::v-deep .el-table__body .el-table__row.hover-row td {
+  background-color: #eaecef;
+}
+
+::v-deep .el-form--inline .el-form-item__label {
+  color: #a7a7a7;
+}
+
+.body ::v-deep .el-divider {
+  border: 1px solid #eee;
+  width: 99%;
+  margin: 10px auto;
+}
+
+.body ::v-deep .el-form-item {
+  margin-bottom: 0;
+}
+
+.userDialogVisible ::v-deep .el-form-item {
+  margin-bottom: 0;
+}
+
+::v-deep .el-select__caret {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.tableFixed {
+  ::v-deep .el-table__fixed-right {
+    height: 100% !important;
+  }
+
+  ::v-deep .el-table__fixed {
+    height: 100% !important;
+  }
+}
+
+::v-deep .el-range__icon {
+  line-height: 28px !important;
+}
+
+::v-deep .el-range-separator {
+  line-height: 28px !important;
+}
+
+::v-deep .el-range-input {
+  font-size: 14px;
+}
+
+::v-deep .el-range-separator {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+</style>
+

--
Gitblit v1.9.3