From b811e2fa4cdcb5949047faa78aa9299aec1d2f67 Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期三, 27 三月 2024 15:08:45 +0800
Subject: [PATCH] 确认采购单接口换位post请求,产品列表字段替换

---
 src/components/makepager/TableCommonView.vue |  249 +++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 209 insertions(+), 40 deletions(-)

diff --git a/src/components/makepager/TableCommonView.vue b/src/components/makepager/TableCommonView.vue
index ca6a5e6..50ac390 100644
--- a/src/components/makepager/TableCommonView.vue
+++ b/src/components/makepager/TableCommonView.vue
@@ -1,27 +1,27 @@
+<!-- eslint-disable vue/no-use-v-if-with-v-for -->
 <template>
-  <div class="table-view">
+  <div class="table-view" v-loading="loading">
     <el-table
       ref="table"
       border
       :data="tableList.tableInfomation"
       tooltip-effect="dark"
-      style="width: 100%"
       :height="'calc(100% - 0px)'"
       :max-height="tableList.maxHeight"
+      style="width: 100%"
       :lazy="tableList.lazy"
-      size="mini"
+      :show-summary="showSummary.show"
+      :summary-method="getSummaries"
+      :span-method="arraySpanMethod"
       @selection-change="handleSelectionChange"
-      :header-cell-style="{ background: '#f1f3f8', color: '#000009' , 'font-size': '14px'}"
-      :highlight-current-row="tableList.highlight"
-      :row-class-name="tableRowClassName"
+      :header-cell-style="{ background: '#f1f3f8', color: '#000009', 'font-size': '12px', 'font-family': 'PingFangSC' }"
+      size="mini"
       @row-click="tableRowClick"
-      :row-key="tableList.key"
-      :default-expand-all="tableList.isDefaultExpandAll"
-      :tree-props="{ children: 'child', hasChildren: 'hasChildren' }"
+      :row-class-name="tableRowClassName"
     >
-      <el-table-column align="center" v-if="tableList.selectBox" type="selection" width="40"> </el-table-column>
-      <el-table-column align="center" v-if="tableList.selectIndex" type="index" label="搴忓彿" width="50"> </el-table-column>
-      <el-table-column align="center"
+      <el-table-column v-if="selectBox" type="selection" width="40" :selectable="selectable"> </el-table-column>
+      <el-table-column v-if="tableList.selectIndex" type="index" label="搴忓彿" width="50"></el-table-column>
+      <el-table-column
         v-for="(item, i) in tableList.tableColumn"
         :key="i"
         :prop="item.prop"
@@ -30,6 +30,7 @@
         :min-width="item.min"
         show-overflow-tooltip
         :sortable="item.sortable"
+        v-if="item.isShowColumn"
       >
         <template slot-scope="scope">
           <span v-if="item.price">{{ "锟�" + number_format(scope.row[item.prop], 2, ".", ",") }}</span>
@@ -39,10 +40,40 @@
               ? "--"
               : dateFormat("YYYY-mm-dd HH:MM:SS", scope.row[item.prop])
           }}</span>
-          <span v-else-if="item.isClick && scope.row[item.prop]" class="sel-name" @click="selCommonClick(scope.row)">{{
+          <span v-else-if="item.isClick && scope.row[item.prop]" class="sel-name" @click="selNameClick(scope.row)">{{
             scope.row[item.prop]
           }}</span>
           <span v-else-if="item.isFirst">{{ scope.row[item.prop] ? "鏄�" : "鍚�" }}</span>
+          <span
+            v-else-if="item.isSalesLeadClick && scope.row[item.prop]"
+            class="sel-name"
+            @click="selSalesLeadClick(scope.row)"
+            >{{ scope.row[item.prop] }}</span
+          >
+          <span
+            v-else-if="item.isClientClick && scope.row[item.prop]"
+            class="sel-name"
+            @click="selClientClick(scope.row)"
+            >{{ scope.row[item.prop] ? scope.row[item.prop] : "--" }}</span
+          >
+          <span
+            v-else-if="item.isContactClick && scope.row[item.prop]"
+            class="sel-name"
+            @click="selContactsClick(scope.row)"
+            >{{ scope.row[item.prop] }}</span
+          >
+          <span
+            v-else-if="item.isMasterClick && scope.row[item.prop]"
+            class="sel-name"
+            @click="selMasterClick(scope.row)"
+            >{{ scope.row[item.prop] }}</span
+          >
+          <span
+            v-else-if="item.isServiceOrder && scope.row[item.prop]"
+            class="sel-name"
+            @click="selServiceOrderClick(scope.row)"
+            >{{ scope.row[item.prop] }}</span
+          >
           <span
             v-else-if="item.isCommonClick && scope.row[item.prop]"
             class="sel-name"
@@ -52,7 +83,7 @@
           <div v-else-if="item.isProductName" class="product-view">
             <ul v-if="scope.row.products && scope.row.products.length > 0">
               <li v-for="(item, index) in scope.row.products" :key="index">
-                <div :class="scope.row.products.length === 1 ? 'name-view no-bottom' : 'name-view'">
+                <div class="name-view">
                   {{ item.name }}
                 </div>
               </li>
@@ -62,7 +93,7 @@
           <div v-else-if="item.isProductAmount" class="product-view">
             <ul v-if="scope.row.products && scope.row.products.length > 0">
               <li v-for="(item, index) in scope.row.products" :key="index">
-                <div :class="scope.row.products.length === 1 ? 'name-view no-bottom' : 'name-view'">
+                <div class="name-view">
                   {{ item.amount }}
                 </div>
               </li>
@@ -72,7 +103,7 @@
           <div v-else-if="item.isProductPrice" class="product-view">
             <ul v-if="scope.row.products && scope.row.products.length > 0">
               <li v-for="(item, index) in scope.row.products" :key="index">
-                <div :class="scope.row.products.length === 1 ? 'name-view no-bottom' : 'name-view'">
+                <div class="name-view">
                   {{ item.price }}
                 </div>
               </li>
@@ -82,12 +113,18 @@
           <div v-else-if="item.isProductTotal" class="product-view">
             <ul v-if="scope.row.products && scope.row.products.length > 0">
               <li v-for="(item, index) in scope.row.products" :key="index">
-                <div :class="scope.row.products.length === 1 ? 'name-view no-bottom' : 'name-view'">
+                <div class="name-view">
                   {{ item.total }}
                 </div>
               </li>
             </ul>
             <div v-else class="no-product">{{ "--" }}</div>
+          </div>
+          <!-- 璋冪敤鏂规硶鏄剧ず鏂囧瓧 -->
+          <div v-else-if="item.isCallMethod">
+            <span :class="item.isClass ? item.getClassName(scope.row[item.prop], scope.row) : ''">{{
+              item.getCallMethod(scope.row[item.prop], scope.row)
+            }}</span>
           </div>
           <span v-else>{{ scope.row[item.prop] ? scope.row[item.prop] : "--" }}</span>
         </template>
@@ -97,6 +134,14 @@
         <el-empty description="鏆傛棤鏁版嵁"></el-empty>
       </div>
     </el-table>
+
+    <div class="overSpread1" v-show="iscolopen" @click="onMaskClick"></div>
+    <div class="styleBtn">
+      <i @click="checkCol()" class="label">...</i>
+      <el-checkbox-group v-model="showcol" v-show="iscolopen" class="checkbox-group" @change="selectCheckBoxList">
+        <el-checkbox v-for="item in tableList.allcol" :label="item" :key="item">{{ item }} </el-checkbox>
+      </el-checkbox-group>
+    </div>
   </div>
 </template>
 
@@ -104,13 +149,18 @@
 export default {
   name: "TableCommonView",
   props: {
+    selectBox: {
+      type: Boolean,
+      default: false
+    },
     tableList: {
       type: Object,
       default: () => {
         return {
-          selectBox: false,
-          selectIndex: false,
+          selectIndex: true,
           tableInfomation: [], // 鎺ュ彛杩斿洖鏁版嵁
+          showcol: [],
+          allcol: [],
           tableColumn: [
             // table琛ㄥ崟
             { label: "", prop: "", min: 200, tooltip: true }
@@ -124,8 +174,7 @@
         return {
           show: false,
           sumProp: [],
-          mergeNumber: 1,
-          totalName: "鏈〉鎬昏"
+          mergeNumber: 1
         }
       }
     },
@@ -135,14 +184,42 @@
       default: () => {
         return {}
       }
+    },
+    loading: {
+      type: Boolean,
+      default: false
+    },
+    selectBoxList: {
+      type: Array,
+      default: () => []
     }
   },
+
   data() {
-    return {}
+    return {
+      iscolopen: false,
+      showcol: []
+    }
   },
   computed: {},
-  mounted() {},
+  watch: {
+    "tableList.showcol": {
+      handler(newVal) {
+        this.showcol = newVal
+      },
+      immediate: true
+    }
+  },
   methods: {
+    onMaskClick() {
+      this.iscolopen = false
+    },
+    checkCol() {
+      this.iscolopen = !this.iscolopen
+    },
+    selectCheckBoxList(val) {
+      this.$emit("selTableCol", val)
+    },
     handleReserve(row) {
       return row._id ? row._id : row.id
     },
@@ -159,10 +236,16 @@
               .querySelector(".el-table__footer")
             var cell = current.rows[0].cells
             for (let i = 0; i < this.showSummary.mergeNumber; i++) {
-              cell[i].style.display = "none"
+              cell[i] && cell[i].style && (cell[i].style.display = "none")
             }
-            cell[this.showSummary.mergeNumber].classList.remove("is-left")
-            cell[this.showSummary.mergeNumber].colSpan = this.showSummary.mergeNumber.toString()
+            if (cell[this.showSummary.mergeNumber]) {
+              if (cell[this.showSummary.mergeNumber].classList) {
+                cell[this.showSummary.mergeNumber].classList.remove("is-left")
+              }
+              if (cell[this.showSummary.mergeNumber].colSpan) {
+                cell[this.showSummary.mergeNumber].colSpan = this.showSummary.mergeNumber.toString()
+              }
+            }
           }
         })
       }
@@ -174,7 +257,7 @@
         const sums = []
         columns.forEach((column, index) => {
           if (index === this.showSummary.mergeNumber) {
-            sums[index] = this.showSummary.totalName
+            sums[index] = "鏈〉鎬昏"
           }
           const values = data.map((item) => Number(item[column.property]))
           if (this.showSummary.sumProp.includes(column.property)) {
@@ -273,9 +356,37 @@
       }
       return fmt
     },
-    // 鍏叡璇︽儏
+    // 鏂板缓缂栬緫閫夋嫨寮圭獥
+    selNameClick(row) {
+      this.$emit("selCommonClick", row)
+    },
+    // 閿�鍞嚎绱�
+    selSalesLeadClick(row) {
+      this.$emit("selSalesLeadClick", row)
+    },
+    // 瀹㈡埛鍚嶇О
+    selClientClick(row) {
+      this.$emit("selClientClick", row)
+    },
+    // 鑱旂郴浜哄鍚�
+    selContactsClick(row) {
+      this.$emit("selContactsClick", row)
+    },
+    // 閿�鍞�诲崟
+    selMasterClick(row) {
+      this.$emit("selMasterClick", row)
+    },
+    // 瀹㈡埛鏈嶅姟鍗�
+    selServiceOrderClick(row) {
+      this.$emit("selServiceOrderClick", row)
+    },
+    // 鍏叡锛堥攢鍞満浼氥�佹姤浠峰崟銆侀攢鍞�诲崟銆侀攢鍞瓙鍗曘�傘�傘�傦級
     selCommonClick(row) {
       this.$emit("selCommonClick", row)
+    },
+    // 琛岀偣鍑�
+    tableRowClick(row, column, event) {
+      this.$emit("tableRowClick", row, column, event)
     },
     // 鍗曢�夎鐩稿叧
     tableRowClassName({ row }) {
@@ -286,8 +397,13 @@
       }
       this.$emit("tableRowClassName", row)
     },
-    tableRowClick(row) {
-      this.$emit("tableRowClick", row)
+    selectable(row) {
+      let list = this.selectBoxList.map((item) => item.number)
+      if (list.findIndex((v) => v == row.number) == -1) {
+        return true
+      } else {
+        return false
+      }
     }
   }
 }
@@ -296,9 +412,7 @@
 <!-- Add "scoped" attribute to limit CSS to this component only -->
 <style lang="scss" scoped>
 .table-view {
-  // margin-top: 20px;
-  // margin-right: 10px;
-  // margin-bottom: 40px;
+  position: relative;
   height: 100%;
   .blue {
     width: 70px;
@@ -316,19 +430,22 @@
     margin-left: -10px;
     margin-right: -11px;
     li {
-      height: 57px;
-      line-height: 57px;
+      height: 22px;
+      line-height: 22px;
       .name-view {
         padding-left: 10px;
         border-bottom: 1px solid #ebeef5;
       }
       .no-bottom {
-        border-bottom: 0px;
+        border-bottom: 0;
       }
     }
+    li:last-child .name-view {
+      border-bottom: none;
+    }
     .no-product {
-      height: 57px;
-      line-height: 57px;
+      height: 22px;
+      line-height: 22px;
     }
   }
 }
@@ -358,9 +475,61 @@
   text-align: center;
 }
 
-::v-deep{
-  .el-table .cell .el-button--text.el-button--small{
+::v-deep {
+  .el-table .cell .el-button--text.el-button--small {
     padding: 4px 0;
   }
 }
+
+::v-deep .el-table .el-table__cell {
+  padding: 6px 0 !important;
+  height: 35px;
+  text-align: center;
+}
+
+.overSpread1 {
+  width: 100%;
+  height: 100%;
+  position: fixed;
+  top: 0;
+  left: 0;
+  background: rgba(0, 0, 0, 0);
+  z-index: 10;
+}
+
+.styleBtn {
+  position: absolute;
+  width: 30px;
+  height: 36px;
+  // line-height: 26px;
+  // background: #06c062;
+  top: 0;
+  right: -6px;
+  z-index: 11;
+  .label {
+    position: absolute;
+    top: 6px;
+    font-size: 20px;
+    // line-height: 5px;
+    cursor: pointer;
+    color: #000;
+    transform: rotate(-90deg);
+  }
+  .checkbox-group {
+    width: 160px;
+    height: 300px;
+    overflow: auto;
+    display: flex;
+    flex-direction: column;
+    line-height: 25px;
+    background: #ffffff;
+    border-radius: 16px;
+    padding: 12px;
+    position: absolute;
+    right: 0;
+    top: 30px;
+    z-index: 99;
+    box-shadow: 0 0 2px 2px #f8f8f8;
+  }
+}
 </style>

--
Gitblit v1.8.0