From 2e2fe994aa53c7c2f389bc32d0933995389963be Mon Sep 17 00:00:00 2001
From: zzq <a13193816592@163.com>
Date: 星期三, 27 九月 2023 11:32:20 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/web/WMS

---
 src/views/operate/inventoryAdjustment/index.vue |  246 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 168 insertions(+), 78 deletions(-)

diff --git a/src/views/operate/inventoryAdjustment/index.vue b/src/views/operate/inventoryAdjustment/index.vue
index 7d52d43..9f6346e 100644
--- a/src/views/operate/inventoryAdjustment/index.vue
+++ b/src/views/operate/inventoryAdjustment/index.vue
@@ -2,57 +2,90 @@
   <div class="rightContent">
     <div class="top">
       <SearchCommonView
-        :add-title="'鏂板缓'"
-        :placeholder="'璇疯緭鍏ュ崟鍙�'"
+        :add-title="addTitle"
+        :show-discard="showDiscard"
+        :show-apply="true"
+        :placeholder="'璇疯緭鍏ヤ綅缃�/浜у搧'"
         :amount-view="false"
-        @addCommonClick="addBtnClick"
+        @addCommonClick="addProductClick"
         @searchClick="getList"
+        @discardBtnClick="discardBtnClick"
+        @applyBtnClick="applyBtnClick"
       />
     </div>
     <div class="list-view">
       <div class="table">
-        <TableCommonView
-          ref="tableListRef"
-          :table-list="tableList"
-          :show-checkcol="false"
+        <CommonFormTableView
+          :isinventory="true"
+          :product-table-list="tableList"
+          @inputContent="inputContent"
           @tableRowClick="tableRowClick"
-        ></TableCommonView>
+        >
+          <template slot="tableButton">
+            <el-table-column label="鎿嶄綔" width="180" fixed="right" align="center">
+              <template slot-scope="scope">
+                <span @click="handleHistoryClick(scope.row)">
+                  <i class="el-icon-refresh-left"></i>
+                  <span>鍘嗗彶</span>
+                </span>
+                <span v-if="scope.row.isSet" @click="handleSetClick(scope)" class="margin_left_5px">
+                  <i class="el-icon-setting"></i>
+                  <span>璁剧疆</span>
+                </span>
+                <template v-else>
+                  <span @click="handleUseClick(scope)" class="margin_left_5px">
+                    <i class="el-icon-document"></i>
+                    <span>搴旂敤</span>
+                  </span>
+                  <span @click="handleCleanupClick(scope)" class="margin_left_5px">
+                    <i class="el-icon-delete"></i>
+                    <span>娓呴櫎</span>
+                  </span>
+                </template>
+              </template>
+            </el-table-column>
+          </template>
+        </CommonFormTableView>
       </div>
       <div class="btn-pager">
         <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
       </div>
     </div>
-    <!-- 鏂板缓/缂栬緫 -->
-    <AddDialog
-      v-if="editConfig.visible"
-      @refresh="refresh"
-      :positionList="tableList.tableInfomation"
-      :edit-common-config="editConfig"
-    />
   </div>
 </template>
 
 <script>
+import CommonFormTableView from "@/components/makepager/CommonFormTableView"
 import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
 import { getLocationList } from "@/api/warehouseManage/warehouse"
-import AddDialog from "@/views/warehouseManage/position/AddDialog"
-import { getDataByType } from "@/api/data"
 export default {
   name: "InventoryAdjustment",
   props: {},
-  components: { AddDialog },
+  components: { CommonFormTableView },
   mixins: [pageMixin],
   computed: {},
   data() {
     return {
+      addTitle: "鏂板缓",
+      showDiscard: false,
       tableList: {},
+      tableData: [
+        {
+          location: "HC/閿�鍞尯",
+          productName: "澶忓鐪熶笣鍚婂甫瑁�",
+          amount: "0.00",
+          unit: "浠�",
+          count: "0.00",
+          date: "2023-12-31",
+          user: "绠$悊鍛�",
+          isSet: true,
+          isEdit: true
+        }
+      ],
       searchOptions: [],
-      editConfig: {
-        visible: false,
-        title: "鏂板缓",
-        infomation: {}
-      },
-      positionTypeList: getDataByType("positionType")
+      countId: 0,
+      isNoProduct: true, // 娣诲姞鏄庣粏琛屾椂鏄惁鏈変骇鍝佹湭閫夋嫨
+      isRowClick: false
     }
   },
   created() {
@@ -62,55 +95,124 @@
   methods: {
     setTable() {
       this.tableList = {
-        tableInfomation: [],
+        tableData: this.tableData,
         selectBox: true,
-        showcol: this.showcol,
-        allcol: [],
-        tableColumn: this.setTableColumn(this.showcol)
+        tableColumn: [
+          { label: "浣嶇疆", prop: "location", location: true },
+          { label: "浜у搧", prop: "productName", product: true },
+          { label: "鍦ㄥ簱鏁伴噺", prop: "amount" },
+          { label: "璁¢噺鍗曚綅", prop: "unit" },
+          { label: "璁℃暟鐨勬暟閲�", prop: "count", inputFloat: true },
+          { label: "宸紓", prop: "difference" },
+          { label: "鏃ユ湡", prop: "date", date: true },
+          { label: "鐢ㄦ埛", prop: "user", user: true }
+        ]
       }
-      let allcol = []
-      for (let i = 0; i < this.tableList.tableColumn.length; i++) {
-        if (!this.tableList.tableColumn[i].default) {
-          const label = this.tableList.tableColumn[i].label
-          allcol.push(label)
+    },
+    // 鎿嶄綔杈撳叆
+    inputContent(val, prop, row) {
+      this.countId = row.countId
+      this.tableData.map((item) => {
+        if (item.countId === row.countId) {
+          item[prop] = val
+        }
+      })
+    },
+    // 鏂板
+    addProductClick() {
+      console.log(this.tableData)
+      this.isSel()
+      if (this.isNoProduct && this.addTitle === "鏂板缓") {
+        this.addTitle = "淇濆瓨"
+        this.showDiscard = true
+        this.isRowClick = false
+        this.countId++
+        this.tableData.push({
+          countId: this.countId,
+          productId: "",
+          amount: 0,
+          unit: "",
+          productName: "",
+          count: "0.00",
+          isSet: true,
+          isEdit: false
+        })
+      } else if (this.isNoProduct && this.addTitle === "淇濆瓨") {
+        this.addTitle = "鏂板缓"
+        this.showDiscard = false
+      }
+    },
+    // 鏄惁閫夋嫨浜у搧
+    isSel() {
+      for (let i = 0; i < this.tableData.length; i++) {
+        if (this.tableData[i].productName.length === 0) {
+          this.isNoProduct = false
+          break
+        } else {
+          this.isNoProduct = true
         }
       }
-      this.tableList.allcol = allcol
     },
-    setTableColumn(showcol) {
-      console.log(showcol)
-      let tableColumn = [
-        {
-          label: "浣嶇疆",
-          prop: "jointName",
-          isShowColumn: true,
-          default: true
-        },
-        {
-          label: "浣嶇疆绫诲瀷",
-          prop: "type",
-          isShowColumn: true,
-          default: true,
-          conversion: true,
-          getStatus: this.getTypesList
-        }
-      ]
-      return tableColumn
-    },
-    getTypesList(val) {
-      let string = "--"
-      if (val) {
-        for (let i in this.positionTypeList) {
-          if (this.positionTypeList[i].id == val) {
-            return this.positionTypeList[i].name
-          }
-        }
+    // 鍙栨秷
+    discardBtnClick() {
+      if (this.isRowClick) {
+        this.tableData.map((item) => {
+          item.isEdit = true
+        })
+      } else {
+        this.tableData.splice(this.tableData.length - 1, 1)
       }
-      return string
+      this.addTitle = "鏂板缓"
+      this.showDiscard = false
     },
-    selTableCol(val) {
-      this.showcol = val
-      this.tableList.tableColumn = this.setTableColumn(val)
+    // 搴旂敤鍏ㄩ儴
+    applyBtnClick() {
+      console.log("搴旂敤鍏ㄩ儴")
+    },
+    // 鍘嗗彶
+    handleHistoryClick(row) {
+      this.isSel()
+      console.log(row)
+      if (this.isNoProduct) {
+        console.log("鍘嗗彶")
+        this.$router.push({
+          name: "inventoryAdjustmentHistory",
+          params: { id: row.id }
+        })
+      }
+    },
+    // 璁剧疆
+    handleSetClick(scope) {
+      this.isSel()
+      if (this.isNoProduct) {
+        scope.row.isSet = !scope.row.isSet
+      }
+    },
+    // 搴旂敤
+    handleUseClick(scope) {
+      scope.row.isSet = !scope.row.isSet
+    },
+    // 娓呴櫎
+    handleCleanupClick(scope) {
+      scope.row.isSet = !scope.row.isSet
+    },
+    // 琛岀偣鍑�
+    tableRowClick(row, rowIndex) {
+      console.log(row, rowIndex)
+      this.addTitle = "淇濆瓨"
+      this.showDiscard = true
+      this.isRowClick = true
+      this.isSel()
+      if (!this.isNoProduct) {
+        this.tableData.splice(this.tableData.length - 1, 1)
+      }
+      this.tableData.map((item, index) => {
+        if (index === rowIndex) {
+          item.isEdit = false
+        } else {
+          item.isEdit = true
+        }
+      })
     },
     // 璇锋眰鏁版嵁
     async getData() {
@@ -126,23 +228,11 @@
         }
       })
     },
-    refresh() {
-      this.pagerOptions.currPage = 1
-      this.getData()
-    },
     // 鎼滅储
     getList(val) {
       this.keyword = val
       this.pagerOptions.currPage = 1
       this.getData()
-    },
-    // 琛岀偣鍑�
-    tableRowClick(row) {
-      console.log(row)
-      this.editConfig.title = "缂栬緫"
-      this.editConfig.infomation = { ...row }
-      this.editConfig.infomation.parentId = Number(this.editConfig.infomation.parentId)
-      this.editConfig.visible = true
     },
     // 鏂板缓
     addBtnClick() {

--
Gitblit v1.8.0