From d20654ba067e5c0621d4d7d95915cbe47a10fe87 Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期四, 08 八月 2024 17:23:48 +0800
Subject: [PATCH] 1.正清和  增加页面缓存处理

---
 src/views/makeModel/InventoryList.vue |  376 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 227 insertions(+), 149 deletions(-)

diff --git a/src/views/makeModel/InventoryList.vue b/src/views/makeModel/InventoryList.vue
index 6edf62f..908d680 100644
--- a/src/views/makeModel/InventoryList.vue
+++ b/src/views/makeModel/InventoryList.vue
@@ -48,21 +48,28 @@
               <el-input v-model="form.partspec" placeholder="璇疯緭鍏�" style="width: 200px" />
             </el-form-item>
             <el-form-item label="瀛樿揣绫诲瀷" style=" display: flex;">
-              <el-select
-                v-model="form.stocktypecode"
+              <el-cascader
+                ref="cascader"
+                :options="stocktypeArr"
                 filterable
-                :popper-append-to-body="false"
-                style="width: 200px"
-                placeholder="璇烽�夋嫨"
-              >
-                <!--                @change="val=>stocktypecodeChange(val,'form')"-->
-                <el-option
-                  v-for="item in stocktypeArr"
-                  :key="item.code"
-                  :label="item.name"
-                  :value="item.code"
-                />
-              </el-select>
+                :props="defaultProps"
+                @change="val=>cascaderChange(val,'form')"
+              />
+              <!--              <el-select-->
+              <!--                v-model="form.stocktypecode"-->
+              <!--                filterable-->
+              <!--                :popper-append-to-body="false"-->
+              <!--                style="width: 200px"-->
+              <!--                placeholder="璇烽�夋嫨"-->
+              <!--              >-->
+              <!--                &lt;!&ndash;                @change="val=>stocktypecodeChange(val,'form')"&ndash;&gt;-->
+              <!--                <el-option-->
+              <!--                  v-for="item in stocktypeArr"-->
+              <!--                  :key="item.code"-->
+              <!--                  :label="item.name"-->
+              <!--                  :value="item.code"-->
+              <!--                />-->
+              <!--              </el-select>-->
             </el-form-item>
             <el-form-item v-if="false" label="鐗╂枡绫诲瀷" style=" display: flex;">
               <el-select
@@ -218,7 +225,7 @@
         :page.sync="form.page"
         :limit.sync="form.rows"
         align="right"
-        layout="total,prev, pager, next,sizes"
+        layout="total,prev, pager, next,sizes,jumper"
         popper-class="select_bottom"
         @pagination="getInventoryFileSelect"
       />
@@ -272,22 +279,31 @@
           </el-select>
         </el-form-item>
         <el-form-item label="瀛樿揣绫诲瀷" prop="stocktypecode">
-          <el-select
-            v-model="dialogForm.stocktypecode"
-            filterable
-            :popper-append-to-body="false"
-            style="width: 200px"
-            placeholder="璇烽�夋嫨"
-          >
-            <!--            @change="val=>stocktypecodeChange(val,'dialogForm')"-->
 
-            <el-option
-              v-for="item in stocktypeArr"
-              :key="item.code"
-              :label="item.name"
-              :value="item.code"
-            />
-          </el-select>
+          <el-cascader
+            ref="cascaderDialog"
+            :options="stocktypeArr"
+            filterable
+            :props="defaultPropsDialog"
+            @change="val=>cascaderChange(val,'dialogForm')"
+          />
+
+          <!--          <el-select-->
+          <!--            v-model="dialogForm.stocktypecode"-->
+          <!--            filterable-->
+          <!--            :popper-append-to-body="false"-->
+          <!--            style="width: 200px"-->
+          <!--            placeholder="璇烽�夋嫨"-->
+          <!--          >-->
+          <!--            &lt;!&ndash;            @change="val=>stocktypecodeChange(val,'dialogForm')"&ndash;&gt;-->
+
+          <!--            <el-option-->
+          <!--              v-for="item in stocktypeArr"-->
+          <!--              :key="item.code"-->
+          <!--              :label="item.name"-->
+          <!--              :value="item.code"-->
+          <!--            />-->
+          <!--          </el-select>-->
         </el-form-item>
         <el-form-item label="鎵�灞炰粨搴�" prop="warehousecode">
           <el-select
@@ -336,85 +352,85 @@
         </el-form-item>
       </el-form>
 
-      <el-collapse>
-        <el-collapse-item title="涓�鑷存�� Consistency" name="1">
-          <template slot="title">
-            <div>
-              <i
-                class="el-icon-s-operation"
-                :style="{color:$store.state.settings.theme}"
-                style="margin: -20px 10px 20px 20px"
-              />楂樼骇璁剧疆锛�
-            </div>
-          </template>
-          <div
-            style="display: flex;flex-direction: column;height: 140px; align-content: center;justify-content: space-between"
-          >
-            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">
-              <div>
-                <el-tooltip
-                  class="item"
-                  effect="dark"
-                  content=""
-                  placement="top"
-                >
-                  <div slot="content" style="width: 300px">
-                    鍚敤绠$悊鍚庡簱瀛樻暟閲忎細鎸夋爣绛惧垎寮�鏄剧ず锛岄渶瑕佸仛閲囪喘鍒拌揣鎵嶈兘鍏ュ簱锛屼笖鐢熶骇鍙戞枡闇�瑕佹壂鐮佹爣绛捐繘琛屽彂鏂欙紝涓嶅惎鐢ㄦ壒娆$鐞嗙殑涓嶉渶瑕侀噰璐埌璐э紝鍙互鐩存帴閫夋嫨鐗╂枡閲囪喘鍏ュ簱锛屼笖鍏ュ簱鍚庝細鍚堝苟鏄剧ず璇ョ墿鏂欑殑搴撳瓨锛岀敓浜у彂鏂欏垯鎸夊簱浣嶈繘琛屽嚭搴撱��
-                  </div>
-                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />
-                </el-tooltip>
-              </div>
+      <!--      <el-collapse>-->
+      <!--        <el-collapse-item title="涓�鑷存�� Consistency" name="1">-->
+      <!--          <template slot="title">-->
+      <!--            <div>-->
+      <!--              <i-->
+      <!--                class="el-icon-s-operation"-->
+      <!--                :style="{color:$store.state.settings.theme}"-->
+      <!--                style="margin: -20px 10px 20px 20px"-->
+      <!--              />楂樼骇璁剧疆锛�-->
+      <!--            </div>-->
+      <!--          </template>-->
+      <!--          <div-->
+      <!--            style="display: flex;flex-direction: column;height: 140px; align-content: center;justify-content: space-between"-->
+      <!--          >-->
+      <!--            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">-->
+      <!--              <div>-->
+      <!--                <el-tooltip-->
+      <!--                  class="item"-->
+      <!--                  effect="dark"-->
+      <!--                  content=""-->
+      <!--                  placement="top"-->
+      <!--                >-->
+      <!--                  <div slot="content" style="width: 300px">-->
+      <!--                    鍚敤绠$悊鍚庡簱瀛樻暟閲忎細鎸夋爣绛惧垎寮�鏄剧ず锛岄渶瑕佸仛閲囪喘鍒拌揣鎵嶈兘鍏ュ簱锛屼笖鐢熶骇鍙戞枡闇�瑕佹壂鐮佹爣绛捐繘琛屽彂鏂欙紝涓嶅惎鐢ㄦ壒娆$鐞嗙殑涓嶉渶瑕侀噰璐埌璐э紝鍙互鐩存帴閫夋嫨鐗╂枡閲囪喘鍏ュ簱锛屼笖鍏ュ簱鍚庝細鍚堝苟鏄剧ず璇ョ墿鏂欑殑搴撳瓨锛岀敓浜у彂鏂欏垯鎸夊簱浣嶈繘琛屽嚭搴撱��-->
+      <!--                  </div>-->
+      <!--                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />-->
+      <!--                </el-tooltip>-->
+      <!--              </div>-->
 
-              <div style="margin: 0 3px">鎵规绠$悊锛�</div>
-              <el-switch
-                v-model="isBatchNo"
-              />
-            </div>
-            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">
-              <div style="margin: 0 3px">鍏堣繘鍏堝嚭锛�</div>
-              <el-switch
-                v-model="isFifo"
-              />
-            </div>
-            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">
-              <div>
-                <el-tooltip
-                  class="item"
-                  effect="dark"
-                  content=""
-                  placement="top"
-                >
-                  <div slot="content" style="width: 300px">寮�鍚悗璇ョ墿鏂欏繀椤诲仛鍏ュ巶妫�楠屾垨璐ㄩ噺鍒ゆ柇鍚堟牸鍚庢墠鑳藉仛鍏ュ巶鍙嶅垯璇ョ墿鏂欒川閲忕姸鎬佷负寰呮鐘舵�佹槸涓嶅厑璁稿叆鍘傜殑銆�</div>
-                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />
-                </el-tooltip>
-              </div>
+      <!--              <div style="margin: 0 3px">鎵规绠$悊锛�</div>-->
+      <!--              <el-switch-->
+      <!--                v-model="isBatchNo"-->
+      <!--              />-->
+      <!--            </div>-->
+      <!--            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">-->
+      <!--              <div style="margin: 0 3px">鍏堣繘鍏堝嚭锛�</div>-->
+      <!--              <el-switch-->
+      <!--                v-model="isFifo"-->
+      <!--              />-->
+      <!--            </div>-->
+      <!--            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">-->
+      <!--              <div>-->
+      <!--                <el-tooltip-->
+      <!--                  class="item"-->
+      <!--                  effect="dark"-->
+      <!--                  content=""-->
+      <!--                  placement="top"-->
+      <!--                >-->
+      <!--                  <div slot="content" style="width: 300px">寮�鍚悗璇ョ墿鏂欏繀椤诲仛鍏ュ巶妫�楠屾垨璐ㄩ噺鍒ゆ柇鍚堟牸鍚庢墠鑳藉仛鍏ュ巶鍙嶅垯璇ョ墿鏂欒川閲忕姸鎬佷负寰呮鐘舵�佹槸涓嶅厑璁稿叆鍘傜殑銆�</div>-->
+      <!--                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />-->
+      <!--                </el-tooltip>-->
+      <!--              </div>-->
 
-              <div style="margin: 0 3px">鍏ュ巶妫�楠岋細</div>
-              <el-switch
-                v-model="isInCheck"
-              />
-            </div>
-            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">
-              <div>
-                <el-tooltip
-                  class="item"
-                  effect="dark"
-                  content=""
-                  placement="top"
-                >
-                  <div slot="content" style="width: 300px">寮�鍚悗璇ョ墿鏂欏繀椤诲仛鍑哄巶妫�楠屾垨璐ㄩ噺鍒ゆ柇鍚堟牸鍚庢墠鑳藉仛鍑哄巶锛屽弽鍒欒鐗╂枡璐ㄩ噺鐘舵�佷负寰呮鐘舵�佹槸涓嶅厑璁稿嚭鍘傜殑銆�</div>
-                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />
-                </el-tooltip>
-              </div>
+      <!--              <div style="margin: 0 3px">鍏ュ巶妫�楠岋細</div>-->
+      <!--              <el-switch-->
+      <!--                v-model="isInCheck"-->
+      <!--              />-->
+      <!--            </div>-->
+      <!--            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">-->
+      <!--              <div>-->
+      <!--                <el-tooltip-->
+      <!--                  class="item"-->
+      <!--                  effect="dark"-->
+      <!--                  content=""-->
+      <!--                  placement="top"-->
+      <!--                >-->
+      <!--                  <div slot="content" style="width: 300px">寮�鍚悗璇ョ墿鏂欏繀椤诲仛鍑哄巶妫�楠屾垨璐ㄩ噺鍒ゆ柇鍚堟牸鍚庢墠鑳藉仛鍑哄巶锛屽弽鍒欒鐗╂枡璐ㄩ噺鐘舵�佷负寰呮鐘舵�佹槸涓嶅厑璁稿嚭鍘傜殑銆�</div>-->
+      <!--                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />-->
+      <!--                </el-tooltip>-->
+      <!--              </div>-->
 
-              <div style="margin: 0 3px">鍑哄巶妫�楠岋細</div>
-              <el-switch
-                v-model="isOutCheck"
-              />
-            </div>
-          </div>
-        </el-collapse-item>
-      </el-collapse>
+      <!--              <div style="margin: 0 3px">鍑哄巶妫�楠岋細</div>-->
+      <!--              <el-switch-->
+      <!--                v-model="isOutCheck"-->
+      <!--              />-->
+      <!--            </div>-->
+      <!--          </div>-->
+      <!--        </el-collapse-item>-->
+      <!--      </el-collapse>-->
       <!--      </div>-->
       <span slot="footer" class="dialog-footer">
         <div class="footerButton">
@@ -615,26 +631,26 @@
         </div>
       </div>
 
-      <el-divider />
-      <div>
-        <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 榛樿宸ヨ壓璺嚎
-      </div>
-      <div style="margin-top: 20px">
-        <el-select
-          v-model="defaultroute_code"
-          filterable
-          style="width: 200px;"
-          placeholder="璇烽�夋嫨"
-          class="defaultroute_code"
-        >
-          <el-option
-            v-for="item in defaultroute_codeArr"
-            :key="item.code"
-            :label="item.name"
-            :value="item.code"
-          />
-        </el-select>
-      </div>
+      <!--      <el-divider   />-->
+      <!--      <div  >-->
+      <!--        <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 榛樿宸ヨ壓璺嚎-->
+      <!--      </div>-->
+      <!--      <div  style="margin-top: 20px">-->
+      <!--        <el-select-->
+      <!--          v-model="defaultroute_code"-->
+      <!--          filterable-->
+      <!--          style="width: 200px;"-->
+      <!--          placeholder="璇烽�夋嫨"-->
+      <!--          class="defaultroute_code"-->
+      <!--        >-->
+      <!--          <el-option-->
+      <!--            v-for="item in defaultroute_codeArr"-->
+      <!--            :key="item.code"-->
+      <!--            :label="item.name"-->
+      <!--            :value="item.code"-->
+      <!--          />-->
+      <!--        </el-select>-->
+      <!--      </div>-->
       <el-divider />
       <div style="margin-bottom: 10px">
         <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 宸ュ簭鍒楄〃
@@ -720,9 +736,10 @@
 import elDragDialog from '@/directive/el-drag-dialog'
 import waves from '@/directive/waves'
 import TableColumnSettings from '@/components/TableColumnSettings'
+import arrayToTree from 'array-to-tree'
 
 export default {
-  name: 'CHDA',
+  name: 'InventoryList',
   components: {
     Pagination, TableColumnSettings
   },
@@ -976,12 +993,25 @@
         // routeOperationSelectedArr: [] // 宸ヨ壓璺嚎閫変腑闆嗗悎鏁扮粍
       },
       defaultroute_code: '', // 榛樿宸ヨ壓璺嚎閫変腑鍊�
-      defaultroute_codeArr: '', // 榛樿宸ヨ壓璺嚎鏁扮粍
+      defaultroute_codeArr: [], // 榛樿宸ヨ壓璺嚎鏁扮粍
       projectTableData: [], // 璁惧鍒楄〃
       isBatchNo: false, // 鏄惁鎵规绠$悊
       isFifo: false, // 鏄惁鍏堣繘鍏堝嚭
       isInCheck: false, // 鏄惁鍏ュ簱妫�楠�
-      isOutCheck: false// 鏄惁鍑哄巶妫�楠�
+      isOutCheck: false, // 鏄惁鍑哄巶妫�楠�
+
+      defaultProps: {
+        checkStrictly: true,
+        expandTrigger: 'hover',
+        value: 'code',
+        label: 'name'
+      },
+      defaultPropsDialog: {
+        // checkStrictly: true,
+        expandTrigger: 'hover',
+        value: 'code',
+        label: 'name'
+      }
     }
   },
   created() {
@@ -1079,6 +1109,34 @@
         }, 10000)
       }
     },
+    cascaderChange(val, type) {
+      if (type === 'form') {
+        this.form.stocktypecode = val[val.length - 1]
+      }
+      if (type === 'dialogForm') {
+        this.dialogForm.stocktypecode = val[val.length - 1]
+      }
+    },
+    // parents:鐢ㄤ簬杩斿洖鐨勬暟缁勶紝childNode:瑕佹煡璇㈢殑鑺傜偣锛宼reeData锛歫son鏍戝舰鏁版嵁
+    findParent(parents, childNode, treeData) {
+      for (let i = 0; i < treeData.length; i++) {
+        // 鐖惰妭鐐规煡璇㈡潯浠�
+        if (treeData[i].code === childNode) {
+          // 濡傛灉鎵惧埌缁撴灉,淇濆瓨褰撳墠鑺傜偣
+          parents.push(treeData[i].code)
+          // 鐢ㄥ綋鍓嶈妭鐐瑰啀鍘诲師鏁版嵁鏌ユ壘褰撳墠鑺傜偣鐨勭埗鑺傜偣
+          this.findParent(parents, treeData[i].iparent_id, this.stocktypeArr)
+          break
+        } else {
+          if (treeData[i].children instanceof Array) {
+            //	娌℃壘鍒帮紝閬嶅巻璇ヨ妭鐐圭殑瀛愯妭鐐�
+            this.findParent(parents, childNode, treeData[i].children)
+          }
+        }
+      }
+      return parents
+    },
+
     async getInventoryFileSelect() {
       const res = await InventoryFileSelect(this.form)
       this.tableData = res.data
@@ -1087,7 +1145,13 @@
     },
     async getStockTypeSelect() {
       const { data: res } = await StockTypeSelect()
-      this.stocktypeArr = res
+      this.stocktypeArr = arrayToTree(res, {
+        parentProperty: 'iparent_id',
+        customID: 'code',
+        childrenProperty: 'children'
+      })
+
+      console.log(this.stocktypeArr, 2)
     },
     async getWareHouseSelect() {
       const { data: res } = await WareHouseSelect()
@@ -1139,6 +1203,7 @@
       this.form.stocktypecode = ''
       this.form.materialtypecode = ''
       this.form.storehousecode = ''
+      this.$refs.cascader.checkedValue = ''
       this.getInventoryFileSelect()
     },
     // 鏂板鎸夐挳
@@ -1149,10 +1214,14 @@
     },
     // 淇敼鎸夐挳
     async edit(operation, row) {
+      const cascaderCheckedValue = this.findParent([], row.stocktypecode, this.stocktypeArr)
+
       this.operation = operation
       this.dialogVisible = true
       // await this.stocktypecodeChange(row.stocktypecode, 'dialogForm')
       this.$nextTick(() => {
+        this.$refs.cascaderDialog.checkedValue = cascaderCheckedValue.reverse()
+
         this.dialogForm.id = row.id
         this.dialogForm.materialcode = row.partcode
         this.dialogForm.materialname = row.partname
@@ -1205,6 +1274,7 @@
       this.isFifo = false
       this.isInCheck = false
       this.isOutCheck = false
+      this.$refs.cascaderDialog.checkedValue = ''
       this.$refs.dialogForm.clearValidate()
     },
     // 瀵硅瘽妗嗗彇娑�
@@ -1271,7 +1341,8 @@
         background: 'rgba(0, 0, 0, 0.7)'
       })
 
-      this.defaultroute_code = row.default_route
+      // this.defaultroute_code = row.default_route
+      // this.defaultroute_code = ''
       this.dialogFormRoute.projectCode = row.partcode
       this.dialogFormRoute.projectName = row.partname
 
@@ -1310,7 +1381,7 @@
               }
             })
 
-            this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.flag === 'Y')
+            // this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.flag === 'Y')
           }, 1000)
         } else {
           loading.close()
@@ -1320,7 +1391,7 @@
     // 瀵硅瘽妗嗗叧闂�
     handleCloseRoute() {
       this.dialogFormRoute.routeOperationArr = []
-      this.defaultroute_codeArr = []
+      // this.defaultroute_codeArr = []
     },
     // 鍙栨秷
     routeDialogVisibleCancel() {
@@ -1328,20 +1399,26 @@
     },
     // 纭畾
     async routeDialogVisibleConfirm() {
-      console.log(this.defaultroute_code)
-      if (this.defaultroute_code === null || this.defaultroute_code === 'null') {
-        return this.$message.info('榛樿宸ヨ壓璺嚎涓嶈兘涓虹┖锛�')
-      }
+      // console.log(this.defaultroute_code)
+      // if (this.defaultroute_code === null || this.defaultroute_code === 'null') {
+      //   return this.$message.info('榛樿宸ヨ壓璺嚎涓嶈兘涓虹┖锛�')
+      // }
 
       // 鎻愪氦鏍煎紡
       const data = []
       this.dialogFormRoute.routeOperationArr.forEach(item => {
         if (item.isSelected2) {
-          data.push({ code: item.code, name: item.name })
+          data.push({
+            code: item.code,
+            name: item.name,
+            wkshopcode: item.wkshopcode,
+            wkshopname: item.wkshopname
+          })
         }
       })
       this.$store.state.app.buttonIsDisabled = true
-      const res = await SaveInventoryFile(this.dialogFormRoute.projectCode, this.defaultroute_code, data)
+      // const res = await SaveInventoryFile(this.dialogFormRoute.projectCode, this.defaultroute_code, data)
+      const res = await SaveInventoryFile(this.dialogFormRoute.projectCode, '', data)
       if (res.code === '200') {
         this.dialogVisibleRoute = false
         this.$message.success('淇濆瓨鎴愬姛锛�')
@@ -1368,10 +1445,11 @@
           item.flag = !item.flag
         }
       })
-      if (val.code === this.defaultroute_code) {
-        this.defaultroute_code = ''
-      }
-      this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
+      // if (val.code === this.defaultroute_code) {
+      //   this.defaultroute_code = ''
+      // }
+      // this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
+      this.$forceUpdate()
     },
     /* 鍗曚綅妯″潡*/
     // 鍗曚綅鎸夐挳鐐瑰嚮浜嬩欢
@@ -1562,12 +1640,12 @@
   }
 }
 
-.defaultroute_code ::v-deep .el-input__suffix-inner {
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  margin-top: -3px;
-}
+//.defaultroute_code ::v-deep .el-input__suffix-inner {
+//  display: flex;
+//  align-items: center;
+//  justify-content: center;
+//  margin-top: -3px;
+//}
 </style>
 
 <!--鍏叡椤甸潰鏍峰紡-->

--
Gitblit v1.9.3