From 3f386968d4b5cbb002ad93483f86a5443159e18a Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期六, 08 二月 2025 09:54:32 +0800
Subject: [PATCH] 1.递交

---
 src/views/materialManager/materialList.vue | 1346 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,341 insertions(+), 5 deletions(-)

diff --git a/src/views/materialManager/materialList.vue b/src/views/materialManager/materialList.vue
index 6daa823..83c3938 100644
--- a/src/views/materialManager/materialList.vue
+++ b/src/views/materialManager/materialList.vue
@@ -1,11 +1,1347 @@
-<template />
+<template>
+  <div>
+    <div class="body" :style="{height:mainHeight+'px'}">
+      <div class="bodyTopButtonGroup" style="justify-content: space-between">
+        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
+        <!--        <el-button v-waves icon="el-icon-download" @click="upload">瀵煎叆</el-button>-->
+      </div>
+
+      <div class="bodyTopFormGroup">
+        <el-form
+          ref="form"
+          :model="form"
+          label-width="100px"
+          inline
+          style="display: flex;"
+        >
+          <div class="elForm">
+            <el-form-item label="姣嶄欢缂栫爜" style=" display: flex;">
+              <el-input v-model="form.parentpartcode" placeholder="璇疯緭鍏�" style="width: 200px" />
+            </el-form-item>
+            <el-form-item label="姣嶄欢鍚嶇О" style=" display: flex;">
+              <el-input v-model="form.parentpartname" placeholder="璇疯緭鍏�" style="width: 200px" />
+            </el-form-item>
+            <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-input v-model="form.version" placeholder="璇疯緭鍏�" style="width: 200px" />
+            </el-form-item>
+            <el-form-item v-show="isExpandForm" label="鍒涘缓浜哄憳" style=" display: flex;">
+              <el-input v-model="form.createusername" style="width: 200px" placeholder="璇疯緭鍏�" />
+            </el-form-item>
+            <el-form-item v-show="isExpandForm" label="鍒涘缓鏃ユ湡" style=" display: flex;align-items: center">
+              <el-date-picker
+                v-model="form.createdate"
+                type="daterange"
+                :clearable="false"
+                class="timeMini"
+                range-separator="~"
+                start-placeholder="寮�濮嬫棩鏈�"
+                style="width: 200px;display: flex;line-height: 34px ;height: 34px ;"
+                end-placeholder="缁撴潫鏃ユ湡"
+                size="mini"
+              />
+            </el-form-item>
+            <el-form-item v-show="isExpandForm" label="鍚敤鐘舵��" style=" display: flex;">
+              <el-select v-model="form.status" style="width: 200px" placeholder="璇烽�夋嫨">
+                <el-option
+                  v-for="item in openTypeArr"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value"
+                />
+              </el-select>
+            </el-form-item>
+          </div>
+          <div
+            class="bodySearchReset"
+            :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
+          >
+            <el-button v-waves type="primary" icon="el-icon-search" @click="search">鏌ヨ</el-button>
+            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
+          </div>
+        </el-form>
+        <div
+          class="bodyTopFormExpand"
+        >
+          <svg-icon
+            v-show="mouseHoverType==='mouseout'"
+            style="cursor: pointer"
+            :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"
+            @mouseenter="mouseHoverType=$event.type"
+          />
+          <svg-icon
+            v-show="mouseHoverType==='mouseenter'"
+            style="cursor: pointer"
+            :icon-class="!isExpandForm?'doubleDown':'doubleUp'"
+            @click="isExpandForm=!isExpandForm"
+            @mouseout="mouseHoverType=$event.type"
+          />
+        </div>
+      </div>
+
+      <div class="elTableDiv">
+        <!--        <TableColumnSettings-->
+        <!--          :list1="tableColumnSettingsArray"-->
+        <!--          @tableColumnUpdate="tableColumnUpdate"-->
+        <!--        />-->
+        <el-table
+          ref="tableDataRef"
+          :key="tableTimeStampKey"
+          class="tableFixed"
+          :data="tableData"
+          :height="isExpandForm?tableHeight:(tableHeight+40)+'px'"
+          border
+          :row-class-name="tableRowClassName"
+          :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+40)+'px',}"
+          highlight-current-row
+          :header-cell-style="this.$headerCellStyle"
+          :cell-style="this.$cellStyle"
+          @sort-change="sortChange"
+        >
+
+          <el-table-column
+            v-for="item in tableColumnSettingsArray"
+            v-if="item.show"
+            :key="item.id"
+            :sortable="item.sortable"
+            :prop="item.prop"
+            :min-width="item.minWidth"
+            :label="item.label"
+            :width="item.width"
+            show-tooltip-when-overflow
+            :fixed="item.fixed?(item.fixed==='left'?'left':'right'):false"
+          >
+            <template slot-scope="{row}">
+              <div v-if="!row[item.prop]">/</div>
+
+              <!--              <div v-else-if="item.prop==='startdate'">{{ row.startdate.substring(0, 11) }}</div>-->
+              <div v-else-if="item.prop==='status'">
+                <div v-if="row[item.prop]==='Y'">
+                  <i class="el-icon-success" :style="{color:$store.state.settings.theme}" style="margin-right: 2px" />
+                  鏄�
+                </div>
+                <div v-if="row[item.prop]==='N'">
+                  <i class="el-icon-info" style="margin-right: 2px" />
+                  鍚�
+                </div>
+              </div>
+              <div v-else-if="item.prop==='isdefaultbom'">
+                <div v-if="row[item.prop]==='1'">
+                  <i class="el-icon-success" :style="{color:$store.state.settings.theme}" style="margin-right: 2px" />
+                  鏄�
+                </div>
+                <div v-if="row[item.prop]==='0'">
+                  <i class="el-icon-info" style="margin-right: 2px" />
+                  鍚�
+                </div>
+              </div>
+              <div v-else>{{ row[item.prop] }}</div>
+            </template>
+          </el-table-column>
+
+          <!--          <el-table-column-->
+          <!--            prop="RowNum"-->
+          <!--            width="50"-->
+          <!--            fixed-->
+          <!--            label="搴忓彿"-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="partcode"-->
+          <!--            label="姣嶄欢缂栫爜"-->
+          <!--            min-width="160"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="partname"-->
+          <!--            label="姣嶄欢鍚嶇О"-->
+          <!--            min-width="160"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="partspec"-->
+          <!--            label="姣嶄欢瑙勬牸"-->
+          <!--            min-width="160"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--          >-->
+          <!--            <template slot-scope="{row}">-->
+          <!--              <div v-if="row.partspec">{{ row.partspec }}</div>-->
+          <!--              <div v-else>/</div>-->
+          <!--            </template>-->
+          <!--          </el-table-column>-->
+          <!--          <el-table-column-->
+          <!--            prop="stocktype_name"-->
+          <!--            label="瀛樿揣绫诲瀷"-->
+          <!--            width="110"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="uom_name"-->
+          <!--            label="璁¢噺鍗曚綅"-->
+          <!--            width="110"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="quantity"-->
+          <!--            label="鍩虹鏁伴噺"-->
+          <!--            width="110"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="status"-->
+          <!--            width="110"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            label="鍚敤鐘舵��"-->
+          <!--            sortable="custom"-->
+          <!--          >-->
+          <!--            <template slot-scope="{row}">-->
+          <!--              <div v-if="row.status==='Y'">-->
+          <!--                <i class="el-icon-success" :style="{color:$store.state.settings.theme}" style="margin-right: 2px" />-->
+          <!--                鏄�-->
+          <!--              </div>-->
+          <!--              <div v-if="row.status==='N'">-->
+          <!--                <i class="el-icon-info" style="margin-right: 2px" />-->
+          <!--                鍚�-->
+          <!--              </div>-->
+          <!--            </template>-->
+          <!--          </el-table-column>-->
+          <!--          <el-table-column-->
+          <!--            prop="startdate"-->
+          <!--            label="鍚敤鏃ユ湡"-->
+          <!--            width="110"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--          >-->
+          <!--            <template slot-scope="{row}">-->
+          <!--              <div v-if="row.startdate">{{ row.startdate.substring(0, 11) }}</div>-->
+          <!--              <div v-else>/</div>-->
+          <!--            </template>-->
+          <!--          </el-table-column>-->
+          <!--          <el-table-column-->
+          <!--            prop="version"-->
+          <!--            label="鐗堟湰鍙�"-->
+          <!--            width="110"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="username"-->
+          <!--            label="鍒涘缓浜哄憳"-->
+          <!--            width="110"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="lm_date"-->
+          <!--            label="鍒涘缓鏃堕棿"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            width="110"-->
+          <!--            sortable="custom"-->
+          <!--          >-->
+          <!--            <template slot-scope="{row}">-->
+          <!--              <div v-if="row.lm_date">{{ row.lm_date.substring(0, 11) }}</div>-->
+          <!--              <div v-else>/</div>-->
+          <!--            </template>-->
+          <!--          </el-table-column>-->
+          <el-table-column
+            label="鎿嶄綔"
+            width="120"
+            fixed="right"
+          >
+            <template slot-scope="{row}">
+              <div class="operationClass">
+                <el-tooltip class="item" effect="dark" content="棰勮" placement="top">
+                  <i
+                    class="el-icon-view"
+                    :style="{color:$store.state.settings.theme}"
+                    style="margin-right:15px;cursor: pointer;"
+                    @click="edit('preview',row)"
+                  />
+                </el-tooltip>
+                <el-tooltip class="item" effect="dark" content="缂栬緫" placement="top">
+                  <i
+                    :style="{color:$store.state.settings.theme}"
+                    class="el-icon-edit-outline"
+                    @click="edit('edit',row)"
+                  />
+                </el-tooltip>
+                <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
+                  <i :style="{color:$store.state.settings.theme}" class="el-icon-delete" @click="del(row)" />
+                </el-tooltip>
+
+              </div>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+      <!--鍒嗛〉-->
+      <pagination
+        :total="total"
+        :page.sync="form.page"
+        :limit.sync="form.rows"
+        align="right"
+        layout="total,prev, pager, next,sizes"
+        popper-class="select_bottom"
+        @pagination="getBomMainData"
+      />
+    </div>
+
+    <el-dialog
+      v-el-drag-dialog
+      :title="operation==='add'?'鏂板':(operation==='edit'?'缂栬緫':'棰勮')"
+      :visible.sync="dialogVisible"
+      width="1100px"
+      :close-on-click-modal="false"
+      top="5vh"
+      @closed="handleClose"
+      @close="handleClose"
+    >
+      <div>
+        <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" style="margin: -20px 10px 20px 0" />姣嶄欢淇℃伅锛�
+      </div>
+      <div style="width: 800px;">
+        <el-form
+          ref="dialogForm"
+          inline
+          :rules="dialogFormRules"
+          :model="dialogForm"
+          label-width="80px"
+          style="margin-left: 20px;"
+        >
+
+          <el-form-item label="姣嶄欢缂栫爜" prop="parentpartcode">
+            <el-select
+              v-model="dialogForm.parentpartcode"
+              style="width: 490px"
+              placeholder="璇烽�夋嫨"
+              :popper-append-to-body="false"
+              filterable
+              @change="partSelectChange"
+            >
+              <el-option
+                v-for="item in PartSelectArr"
+                :key="item.partcode"
+                :label="item.partcode+' / '+item.partname"
+                :value="item.partcode"
+              />
+            </el-select>
+          </el-form-item>
+
+          <el-form-item label="姣嶄欢瑙勬牸" prop="parentpartspec">
+            <el-input v-model="dialogForm.parentpartspec" disabled style="width: 200px" />
+          </el-form-item>
+          <el-form-item label="璁¢噺鍗曚綅">
+            <!--            <el-input v-model="dialogForm.uomname"  style="width: 200px" />-->
+
+            <el-select
+              v-model="dialogForm.uomcode"
+              :disabled="UnitGroupArr.length<2"
+              style="width: 200px"
+              placeholder="璇烽�夋嫨"
+              :popper-append-to-body="false"
+            >
+              <el-option
+                v-for="item in UnitGroupArr"
+                :key="item.unitcode"
+                :label="item.unitname"
+                :value="item.unitcode"
+              />
+            </el-select>
+
+          </el-form-item>
+          <!--          <el-form-item label="瀛樿揣绫诲瀷">-->
+          <!--            <el-input v-model="dialogForm.chlx" readonly style="width: 200px" />-->
+          <!--          </el-form-item>-->
+          <el-form-item label="鍩虹鏁伴噺" prop="quantity">
+            <el-input
+              v-model="dialogForm.quantity"
+              :disabled="operation==='preview'"
+              oninput="value=value.replace(/[^0-9.]/g,'')"
+              style="width: 200px"
+            />
+          </el-form-item>
+          <el-form-item prop="status" label="鍚敤鐘舵��">
+            <el-select
+              v-model="dialogForm.status"
+              style="width: 200px"
+              filterable
+              placeholder="璇烽�夋嫨"
+              :disabled="operation==='preview'"
+              :popper-append-to-body="false"
+            >
+              <el-option
+                v-for="item in openTypeArr"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="鍚敤鏃ユ湡" prop="startdate">
+            <el-date-picker
+              v-model="dialogForm.startdate"
+              style="width: 200px"
+              type="date"
+              :disabled="operation!=='add'"
+              value-format="yyyy-MM-dd"
+              :clearable="false"
+              placeholder="閫夋嫨鏃ユ湡"
+            />
+          </el-form-item>
+          <el-form-item label="鐗堟湰鍙�" prop="version">
+            <el-input v-model="dialogForm.version" style="width: 200px" />
+          </el-form-item>
+          <el-form-item label="BOM灞傜骇">
+            <el-input v-model="dialogForm.bomdepth" disabled style="width: 200px" />
+          </el-form-item>
+
+          <el-form-item label="榛樿BOM">
+            <el-checkbox v-model="dialogForm.isdefaultbom" />
+          </el-form-item>
+        </el-form>
+      </div>
+
+      <div>
+        <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" style="margin: -20px 10px 10px 0" />瀛愪欢淇℃伅锛�
+      </div>
+      <el-button
+        v-if="operation!=='preview'"
+        v-waves
+        type="primary"
+        style="margin-left: 20px;margin-bottom: 10px;"
+        icon="el-icon-circle-plus-outline"
+        :disabled="dialogForm.parentpartcode===''"
+        @click="addDialog()"
+      >鏂板
+      </el-button>
+      <el-table
+        ref="dialogTableDataArrRef"
+        class="tableFixed"
+        :data="dialogTableDataArr"
+        :height="tableHeight-300"
+        :style="{width: 100+'%',height:tableHeight-300+'px',}"
+        border
+        :row-class-name="tableRowClassName"
+        highlight-current-row
+        :header-cell-style="this.$headerCellStyle"
+        :cell-style="this.$cellStyle"
+      >
+        <el-table-column
+          width="50"
+          label="琛屽彿"
+          prop="SEQ"
+          fixed
+        />
+        <el-table-column
+          prop="SMATERIRL_CODE"
+          label="瀛愪欢缂栫爜/鍚嶇О"
+          show-tooltip-when-overflow
+        >
+          <template slot-scope="{row}">
+            <el-select
+              v-model="row.SMATERIRL_CODE"
+              filterable
+              style="width: 100%;"
+              placeholder="璇烽�夋嫨"
+              @change="val=>tableChange(val,row)"
+            >
+              <el-option
+                v-for="item in PartDetailSelectArr"
+                :key="item.partcode"
+                :label="item.partcode+' / '+item.partname"
+                :value="item.partcode"
+              />
+            </el-select>
+          </template>
+        </el-table-column>
+
+        <el-table-column
+          prop="SMATERIRL_SPEC"
+          label="瀛愪欢瑙勬牸"
+          width="110"
+          show-tooltip-when-overflow
+        >
+          <!--          <template slot-scope="{row}">-->
+          <!--            <div v-if="row.SMATERIRL_SPEC">{{ row.SMATERIRL_SPEC }}</div>-->
+          <!--            <div v-else>/</div>-->
+          <!--          </template>-->
+        </el-table-column>
+        <el-table-column
+          prop="uomname"
+          label="璁¢噺鍗曚綅"
+          width="110"
+          show-tooltip-when-overflow
+        >
+          <template slot-scope="{row}">
+            <el-select
+              v-model="row.uomcode"
+              :disabled="row.UnitGroupArr.length<2"
+              placeholder="璇烽�夋嫨"
+            >
+              <el-option
+                v-for="item in row.UnitGroupArr"
+                :key="item.unitcode"
+                :label="item.unitname"
+                :value="item.unitcode"
+              />
+            </el-select>
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop="idchildbom"
+          label="瀛愪欢BOM"
+          width="110"
+          show-tooltip-when-overflow
+        >
+          <template slot-scope="{row}">
+            <!--            {{ row.idchildbom }}-->
+            <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: 400px"
+                  height="200"
+                  @row-click="r=>rowClick(r,row)"
+                >
+                  <el-table-column
+                    prop="materiel_code"
+                    label="浜у搧缂栫爜"
+                  />
+                  <el-table-column
+                    prop="materiel_name"
+                    label="浜у搧鍚嶇О"
+                  />
+                  <el-table-column
+                    prop="materiel_spec"
+                    label="瑙勬牸鍨嬪彿"
+                  />
+                  <el-table-column
+                    prop="version"
+                    label="鐗堟湰鍙�"
+                  />
+                </el-table>
+              </template>
+            </el-select>
+          </template>
+        </el-table-column>
+
+        <el-table-column
+          prop="BASE_QUANTITY"
+          label="鍩烘湰鐢ㄩ噺"
+          width="110"
+          show-tooltip-when-overflow
+        >
+          <template slot-scope="{row}">
+            <el-input
+              v-model="row.BASE_QUANTITY"
+              oninput="value=value.replace(/[^0-9.]/g,'')"
+              placeholder="璇疯緭鍏�"
+              @input="val=>inputChange(val,row)"
+            />
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop="LOSS_QUANTITY"
+          label="鎹熻�楃巼%"
+          show-tooltip-when-overflow
+          width="110"
+        >
+          <template slot-scope="{row}">
+            <el-input
+
+              v-model="row.LOSS_QUANTITY"
+              oninput="value=value.replace(/[^0-9.]/g,'')"
+              placeholder="璇疯緭鍏�"
+              @input="val=>inputChange(val,row)"
+            />
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop="TOTAL_QUANTITY"
+          label="瀹為檯鐢ㄩ噺"
+          show-tooltip-when-overflow
+          width="110"
+        />
+
+        <el-table-column
+          v-if="operation!=='preview'"
+          label="鎿嶄綔"
+          width="80"
+          fixed="right"
+        >
+          <template slot-scope="{row,$index}">
+            <div class="operationClass">
+              <el-button v-waves type="text" @click="delRow(row,$index)">鍒犻櫎</el-button>
+            </div>
+          </template>
+        </el-table-column>
+
+      </el-table>
+
+      <span slot="footer" class="dialog-footer">
+        <div class="footerButton">
+          <el-button v-if="operation==='preview'" v-waves @click="dialogVisibleCancel">杩� 鍥�</el-button>
+          <el-button v-if="operation!=='preview'" v-waves @click="dialogVisibleCancel">鍙� 娑�</el-button>
+          <el-button
+            v-if="operation!=='preview'"
+            v-waves
+            :loading="$store.state.app.buttonIsDisabled"
+            :disabled="$store.state.app.buttonIsDisabled"
+            type="primary"
+            @click="dialogVisibleConfirm"
+          >淇濆瓨</el-button>
+        </div>
+      </span>
+    </el-dialog>
+
+  </div>
+</template>
 
 <script>
+import Pagination from '@/components/Pagination'
+import { handleDatetime } from '@/utils/global'
+import elDragDialog from '@/directive/el-drag-dialog'
+import waves from '@/directive/waves'
+import TableColumnSettings from '@/components/TableColumnSettings'
+import {
+  AddUpdateTBomUnitGroup,
+  BomMainData,
+  AddUpdateTBomParentData,
+  AddUpdateTBomDetailsData, AddUpdateTBomMaxVsion, AddUpdateTBomDetailsBomData, TBomAddUpdate, TBomDelete
+} from '@/api/ProductModel'
+
 export default {
-  name: 'MaterialList'
+  name: 'Zzjg',
+  components: {
+    Pagination, TableColumnSettings
+  },
+  directives: { elDragDialog, waves },
+  data() {
+    return {
+      mouseHoverType: 'mouseout',
+      isExpandForm: false,
+      mainHeight: 0,
+      tableHeight: 0,
+      form: {
+        parentpartcode: '', // 姣嶄欢缂栫爜
+        parentpartname: '', // 姣嶄欢鍚嶇О
+        parentpartspec: '', // 姣嶄欢瑙勬牸
+        parttype: '', // 瀛樿揣绫诲瀷
+        status: '', // 鍚敤鐘舵��
+        version: '', // 鐗堟湰鍙�
+        createusername: '', // 鍒涘缓浜哄憳
+        createdate: '', // 鍒涘缓鏃ユ湡
+        prop: 'id', // 鎺掑簭瀛楁
+        order: 'desc', // 鎺掑簭瀛楁
+        page: 1, // 绗嚑椤�
+        rows: 20 // 姣忛〉澶氬皯鏉�
+      },
+
+      openTypeArr: [// 鍚敤鐘舵��
+        { label: '鏄�', value: 'Y' },
+        { label: '鍚�', value: 'N' }
+      ],
+
+      total: 10,
+      tableData: [],
+
+      tableColumnSettingsArray: [
+        { minWidth: 50, width: false, prop: 'id', label: 'id', id: 1, show: false, fixed: false, sortable: false }, // 闅愯棌鍒�  show: false闅愯棌锛宼rue鏄剧ず
+        { minWidth: 25, width: 50, prop: 'rowNum', label: '搴忓彿', id: 2, show: true, fixed: 'left', sortable: false }, // custom
+        {
+          minWidth: 110,
+          width: false,
+          prop: 'materiel_code',
+          label: '姣嶄欢缂栫爜',
+          id: 3,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: 110,
+          width: false,
+          prop: 'materiel_name',
+          label: '姣嶄欢鍚嶇О',
+          id: 4,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: 110,
+          width: false,
+          prop: 'materiel_spec',
+          label: '姣嶄欢瑙勬牸',
+          id: 5,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: 110,
+          width: false,
+          prop: 'materiel_typename',
+          label: '瀛樿揣绫诲瀷',
+          id: 6,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: 110,
+          width: false,
+          prop: 'unitname',
+          label: '璁¢噺鍗曚綅',
+          id: 7,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: 110,
+          width: false,
+          prop: 'quantity',
+          label: '鍩虹鏁伴噺',
+          id: 8,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: false,
+          width: 110,
+          prop: 'status',
+          label: '鍚敤鐘舵��',
+          id: 9,
+          show: true,
+          fixed: false,
+          sortable: true
+        }, {
+          minWidth: false,
+          width: 110,
+          prop: 'startdate',
+          label: '鍚敤鏃ユ湡',
+          id: 10,
+          show: true,
+          fixed: false,
+          sortable: true
+        }, {
+          minWidth: false,
+          width: 110,
+          prop: 'version',
+          label: '鐗堟湰鍙�',
+          id: 11,
+          show: true,
+          fixed: false,
+          sortable: true
+        }, {
+          minWidth: false,
+          width: 110,
+          prop: 'isdefaultbom',
+          label: '榛樿BOM',
+          id: 12,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: false,
+          width: 110,
+          prop: 'lm_user',
+          label: '鍒涘缓浜哄憳',
+          id: 13,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: false,
+          width: 160,
+          prop: 'lm_date',
+          label: '鍒涘缓鏃堕棿',
+          id: 14,
+          show: true,
+          fixed: false,
+          sortable: true
+        }
+      ],
+      tableTimeStampKey: new Date().getTime(), // 琛ㄦ牸key
+
+      dialogVisible: false,
+      dialogForm: {
+        bomid: '',
+        parentpartcode: '',
+        parentpartname: '',
+        parentpartspec: '',
+        uomcode: '',
+        uomname: '',
+        // chlx: '',
+        quantity: '',
+        status: 'Y',
+        startdate: '',
+        version: '',
+        isdefaultbom: false,
+        bomdepth: ''
+      },
+      operation: '',
+      dialogFormRules: {
+        parentpartcode: [
+          { required: true, message: '璇烽�夋嫨姣嶄欢缂栫爜', trigger: ['blur', 'change'] }
+        ],
+        parentpartname: [
+          { required: true, message: '璇烽�夋嫨姣嶄欢鍚嶇О', trigger: ['blur', 'change'] }
+        ],
+        // parentpartspec: [
+        //   { required: true, message: '璇烽�夋嫨姣嶄欢瑙勬牸', trigger: ['blur', 'change'] }
+        // ],
+        status: [
+          { required: true, message: '璇烽�夋嫨鍚敤鐘舵��', trigger: ['blur', 'change'] }
+        ],
+        quantity: [
+          { required: true, message: '璇疯緭鍏ュ熀纭�鏁伴噺', trigger: ['blur', 'change'] }
+        ],
+        // version: [
+        //   { required: true, message: '璇疯緭鍏ョ増鏈彿', trigger: ['blur', 'change'] }
+        // ],
+        startdate: [
+          { required: true, message: '璇烽�夋嫨鍚敤鏃ユ湡', trigger: ['blur', 'change'] }
+        ],
+        version: [
+          { required: true, message: '璇烽�夋嫨鐗堟湰鍙�', trigger: ['blur', 'change'] }
+        ]
+      },
+      PartSelectArr: [], // 浜у搧鍙�夊��
+      dialogTableDataArr: [],
+      UnitGroupArr: [], // 璁¢噺鍗曚綅鏁扮粍
+      PartDetailSelectArr: []
+
+    }
+  },
+
+  created() {
+    this.getBomMainData()
+    this.getAddUpdateTBomParentData()
+    this.getAddUpdateTBomDetailsData()
+  },
+  mounted() {
+    window.addEventListener('resize', this.getHeight)
+    this.getHeight()
+  },
+  methods: {
+    tableColumnUpdate(val, isCopyTrue) {
+      if (isCopyTrue) {
+        this.tableColumnSettingsArray = val
+      }
+      this.tableTimeStampKey = new Date().getTime()
+      this.$refs.tableDataRef.doLayout()
+    },
+    async getBomMainData() {
+      let tempDate = this.form.createdate
+      if (tempDate.length > 0) {
+        tempDate = handleDatetime(tempDate[0]) + '~' + handleDatetime(tempDate[1])
+      }
+
+      const data = {
+        parentpartcode: this.form.parentpartcode,
+        parentpartname: this.form.parentpartname,
+        parentpartspec: this.form.parentpartspec,
+        parttype: this.form.parttype,
+        status: this.form.status,
+        version: this.form.version,
+        createusername: this.form.createusername,
+        createdate: tempDate,
+
+        prop: this.form.prop, // 鎺掑簭瀛楁
+        order: this.form.order, // 鎺掑簭瀛楁
+        page: this.form.page, // 绗嚑椤�
+        rows: this.form.rows // 姣忛〉澶氬皯鏉�
+      }
+
+      const res = await BomMainData(data)
+      this.tableData = res.data
+      this.total = res.count
+      return { code: res.code }
+    },
+    // 鑾峰彇姣嶄欢缂栫爜鍚嶇О绛変笅鎷夋帴鍙�
+    async getAddUpdateTBomParentData() {
+      const { data: res } = await AddUpdateTBomParentData()
+      this.PartSelectArr = res
+    },
+    // 鑾峰彇瀛樿揣绫诲瀷涓嬫媺鎺ュ彛
+    async getAddUpdateTBomDetailsData() {
+      const { data: res } = await AddUpdateTBomDetailsData()
+      this.PartDetailSelectArr = res
+    },
+    async partSelectChange(val) {
+      const res = this.PartSelectArr.find(item => item.partcode === val)
+      // this.dialogForm.parentpartcode = res.partcode
+      this.dialogForm.parentpartname = res.partname
+      this.dialogForm.parentpartspec = res.partspec
+      this.dialogForm.uomcode = res.unitcode
+      this.dialogForm.uomname = res.unitname
+
+      this.UnitGroupArr = []
+      this.UnitGroupArr.push({
+        unitcode: res.unitcode,
+        unitname: res.unitname
+      })
+
+      if (res.idunitgroup) {
+        const { data: r } = await AddUpdateTBomUnitGroup({ idunitgroup: res.idunitgroup })
+        this.UnitGroupArr = r
+      }
+
+      // await this.getAddUpdateTBomMaxVsion(this.dialogForm.parentpartcode)
+    },
+    async getAddUpdateTBomMaxVsion(parentpartcode) {
+      const { data: res } = await AddUpdateTBomMaxVsion({ parentpartcode })
+      this.dialogForm.version = res
+    },
+    // 鎺掑簭鏀瑰彉鏃�
+    sortChange({ column, prop, order }) {
+      if (order === 'descending') {
+        order = 'desc'
+      } else if (order === 'ascending') {
+        order = 'asc'
+      } else {
+        order = 'desc'
+      }
+      this.form.order = order
+      this.form.prop = prop
+      this.getBomMainData()
+    },
+    // 鏌ヨ
+    search() {
+      this.getBomMainData()
+    },
+    // 瀵煎叆鎸夐挳
+    upload() {
+      this.shows = true
+    },
+
+    // 閲嶇疆
+    reset() {
+      this.form.parentpartcode = ''
+      this.form.parentpartname = ''
+      this.form.parentpartspec = ''
+      this.form.parttype = ''
+      this.form.status = ''
+      this.form.version = ''
+      this.form.createusername = ''
+      this.form.createdate = ''
+      this.getBomMainData()
+    },
+
+    // 鏂板鎸夐挳
+    add(operation) {
+      this.operation = operation
+      this.dialogVisible = true
+
+      this.dialogForm.startdate = handleDatetime(new Date())
+
+      // this.$refs.dialogTableDataArrRef.doLayout()
+    },
+    // 淇敼鎸夐挳
+    async edit(operation, row) {
+      this.operation = operation
+
+      this.UnitGroupArr = []
+      this.UnitGroupArr.push({
+        unitcode: row.unitcode,
+        unitname: row.unitname
+      })
+      const t = this.PartSelectArr.find(item => item.partcode === row.materiel_code).idunitgroup
+      if (t) {
+        const { data: r } = await AddUpdateTBomUnitGroup({ idunitgroup: t })
+        this.UnitGroupArr = r
+      }
+
+      this.dialogForm = {
+        bomid: row.id,
+        parentpartcode: row.materiel_code,
+        parentpartname: row.materiel_name,
+        parentpartspec: row.materiel_spec,
+        uomcode: row.unitcode,
+        uomname: row.unitname,
+        quantity: row.quantity,
+        status: row.status,
+        startdate: row.startdate,
+        version: row.version,
+        isdefaultbom: row.isdefaultbom === '1',
+        bomdepth: row.bomdepth
+      }
+
+      const children = []
+
+      row.children.forEach((i, index) => {
+        let number = Math.random() * Math.random() // 浣滀负鍒犻櫎鏃剁殑鏍囪瘑绗�
+        number = number === 0 ? (10 + Math.random()) : number
+        children.push({
+          SEQ: (index + 1) + '0',
+          number,
+          SMATERIRL_CODE: i.materiel_code,
+          SMATERIRL_NAME: i.materiel_name,
+          SMATERIRL_SPEC: i.materiel_spec,
+          uomcode: i.unitcode,
+          uomname: '',
+          UnitGroupArr: [],
+          tableData2: [],
+          BASE_QUANTITY: i.base_quantity,
+          LOSS_QUANTITY: i.loss_quantity,
+          TOTAL_QUANTITY: i.total_quantity,
+          idchildbom: i.idchildbom
+        })
+        this.tableChange(i.materiel_code, children[index])
+      })
+
+      this.dialogTableDataArr = children
+
+      this.dialogVisible = true
+
+      this.$refs.dialogTableDataArrRef.doLayout()
+    },
+    // 杈撳叆妗嗗�兼敼鍙樻椂瑙﹀彂
+    inputChange(val, row) {
+      row.TOTAL_QUANTITY = (parseFloat(row.BASE_QUANTITY) * (parseFloat(row.LOSS_QUANTITY) + 100)) / 100
+      if (!Number.isFinite(row.TOTAL_QUANTITY)) { // 妫�楠屾槸鍚︽槸鏁板瓧
+        row.TOTAL_QUANTITY = ''
+      }
+    },
+    // 瀵硅瘽妗嗚〃鏍间笅鎷夐�夋嫨鍊兼敼鍙樻椂
+    async  tableChange(val, row) {
+      const res = this.PartSelectArr.find(item => item.partcode === val)
+      row.SMATERIRL_CODE = res.partcode
+      row.SMATERIRL_NAME = res.partname
+      row.SMATERIRL_SPEC = res.partspec
+      row.uomcode = res.unitcode
+      row.uomname = res.unitname
+
+      row.UnitGroupArr = []
+      row.UnitGroupArr.push({
+        unitcode: res.unitcode,
+        unitname: res.unitname
+      })
+
+      if (res.idunitgroup) {
+        const { data: r } = await AddUpdateTBomUnitGroup({ idunitgroup: res.idunitgroup })
+        row.UnitGroupArr = r
+      }
+
+      const { data: r2 } = await AddUpdateTBomDetailsBomData({ materiel_code: val })
+      if (r2.length > 0) {
+        row.idchildbom = row.idchildbom ? row.idchildbom : r2[0].id
+        row.tableData2 = r2
+        row.idchildbom = row.tableData2.find(i => parseFloat(i.id) === parseFloat(row.idchildbom)).version
+      }
+    },
+
+    addDialog() {
+      let number = Math.random() * Math.random() // 浣滀负鍒犻櫎鏃剁殑鏍囪瘑绗�
+      number = number === 0 ? (10 + Math.random()) : number
+      this.dialogTableDataArr.push({
+        SEQ: (this.dialogTableDataArr.length + 1) + '0',
+        number,
+        SMATERIRL_CODE: '',
+        SMATERIRL_NAME: '',
+        SMATERIRL_SPEC: '',
+        uomcode: '',
+        uomname: '',
+        idchildbom: '',
+        UnitGroupArr: [],
+        tableData2: [],
+        BASE_QUANTITY: '1',
+        LOSS_QUANTITY: '0',
+        TOTAL_QUANTITY: '1'
+      })
+    },
+    delRow(row, index) {
+      this.dialogTableDataArr.splice(index, 1)
+      this.dialogTableDataArr.forEach((item, index) => {
+        item.SEQ = (index + 1) + '0'
+      })
+    },
+    // 鍒犻櫎鎸夐挳
+    async del(row) {
+      this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
+        confirmButtonText: '纭畾',
+        cancelButtonText: '鍙栨秷',
+        type: 'warning'
+      }).then(() => {
+        TBomDelete(row).then(res => {
+          if (res.code === '200') {
+            this.$message.success('鍒犻櫎鎴愬姛!')
+            if (this.form.page > 1 && this.tableData.length === 1) {
+              this.form.page--
+            }
+            this.getBomMainData()
+          }
+        })
+      }).catch(() => {
+        this.$message.info('宸插彇娑堝垹闄�')
+      })
+    },
+    // 瀵硅瘽妗嗗叧闂簨浠�
+    handleClose() {
+      this.dialogForm.parentpartcode = ''
+      this.dialogForm.parentpartname = ''
+      this.dialogForm.parentpartspec = ''
+      this.dialogForm.uomcode = ''
+      this.dialogForm.uomname = ''
+      // this.dialogForm.chlx = ''
+      this.dialogForm.quantity = ''
+      this.dialogForm.status = 'Y'
+      this.dialogForm.startdate = ''
+      this.dialogForm.version = ''
+      this.dialogForm.bomdepth = ''
+      this.dialogForm.isdefaultbom = false
+      this.dialogTableDataArr = []
+      this.$refs.dialogForm.clearValidate()
+    },
+    // 瀵硅瘽妗嗗彇娑�
+    dialogVisibleCancel() {
+      this.dialogVisible = false
+    },
+    // 瀵硅瘽妗嗙‘璁�
+    dialogVisibleConfirm() {
+      if (this.dialogTableDataArr.length === 0) {
+        return this.$message.info('瀛愪欢淇℃伅涓嶈兘涓虹┖锛�')
+      }
+
+      if (this.dialogTableDataArr.find(i => i.SMATERIRL_CODE === this.dialogForm.parentpartcode)) {
+        return this.$message.info('鐖朵欢涓嶈兘浣滀负鑷繁鐨勫瓙浠讹紒')
+      }
+
+      this.$refs.dialogForm.validate(valid => {
+        if (valid) {
+          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': i.idchildbom ? i.tableData2.find(j => j.version === i.idchildbom).id : ''
+            })
+          })
+
+          const data = {
+            rowNum: '',
+            'id': this.dialogForm.bomid,
+            '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': this.dialogForm.bomdepth === '' ? '1' : this.dialogForm.bomdepth,
+            'lm_user': '',
+            'lm_date': '',
+            children
+          }
+          console.log(JSON.parse(JSON.stringify(data)))
+
+          this.$store.state.app.buttonIsDisabled = true
+          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
+            }
+          })
+        }
+      })
+    },
+
+    // 鑾峰彇椤甸潰楂樺害
+    getHeight() {
+      this.$nextTick(() => {
+        this.mainHeight = window.innerHeight - 85
+        this.tableHeight = this.mainHeight - 255
+        this.$refs.tableDataRef.doLayout()
+      })
+    },
+    tableRowClassName({ row, rowIndex }) {
+      return 'custom-row'
+    },
+
+    rowClick(r, row) {
+      row.idchildbom = r.version
+    }
+
+  }
 }
 </script>
-
-<style scoped>
-
+<style scoped lang="scss">
+::v-deep .el-select__caret::before{
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  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