zhaoke 1 жил өмнө
parent
commit
3135b468a0

+ 110 - 15
src/views/newQuery/components/table.vue

@@ -1,9 +1,9 @@
 <template>
   <div v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)" class="newQueryTable">
     <template v-if="istableChild">
-      <el-table ref="table" v-el-table-infinite-scroll="load" :data="dealedTableData" :summary-method="getSummaries" :span-method="tableSpanMethod" :show-summary="showSummary" :header-cell-class-name="headerCellClass" :cell-class-name="cellClass" height="100%" class="table infinite-list" stripe border @cell-click="cellClick">
+      <el-table ref="table" v-el-table-infinite-scroll="load" :data="dealedTableData" :summary-method="getSummaries" :span-method="tableSpanMethod" :show-summary="showSummary" :header-cell-class-name="headerCellClass" :row-class-name="rowClass" :cell-class-name="cellClass" height="100%" class="table infinite-list" stripe border @cell-click="cellClick">
         <el-table-column v-for="col in tableColsCopy" :key="col.columnName" :prop="col.columnName" :label="col.groupName" align="center">
-          <el-table-column v-for="childCol in col.children" :key="childCol.columnName" :prop="childCol.columnName" :label="childCol.columnLabel" :formatter="formatter">
+          <el-table-column v-for="childCol in col.children" :key="childCol.columnName" :width="childCol.nameLength ? Number(childCol.nameLength) : ''" :prop="childCol.columnName" :label="childCol.columnLabel" :formatter="formatter">
             <template #header>
               <el-tooltip :content="childCol.columnDescribe || childCol.columnLabel" placement="top">
                 <TableHeaderCell :label="childCol.columnLabel" :filter-options="tableDataFilters[childCol.columnName]" :filter-values.sync="filterValues[childCol.columnName]" :sortable="childCol.needSort" :sort-rule.sync="tableDataSortRules[childCol.columnName]" />
@@ -14,8 +14,8 @@
       </el-table>
     </template>
     <template v-else>
-      <el-table ref="table" v-el-table-infinite-scroll="load" :data="dealedTableData" :summary-method="getSummaries" :span-method="tableSpanMethod" :show-summary="showSummary" :header-cell-class-name="headerCellClass" :cell-class-name="cellClass" height="100%" class="table infinite-list" border stripe @cell-click="cellClick">
-        <el-table-column v-for="(item, index) in tableColsCopy" :key="index" :prop="item.columnName" :label="item.columnLabel" :show-overflow-tooltip="showOverflowTooltip" :formatter="formatter">
+      <el-table ref="table" v-el-table-infinite-scroll="load" :data="dealedTableData" :summary-method="getSummaries" :span-method="tableSpanMethod" :show-summary="showSummary" :header-cell-class-name="headerCellClass" :row-class-name="rowClass" :cell-class-name="cellClass" height="100%" class="table infinite-list" border stripe @cell-click="cellClick">
+        <el-table-column v-for="(item, index) in tableColsCopy" :key="index" :width="item.nameLength ? Number(item.nameLength) : ''" :prop="item.columnName" :label="item.columnLabel" :show-overflow-tooltip="showOverflowTooltip" :formatter="formatter">
           <template #header>
             <el-tooltip :content="item.columnDescribe || item.columnLabel" placement="top">
               <TableHeaderCell :label="item.columnLabel" :filter-options="tableDataFilters[item.columnName]" :filter-values.sync="filterValues[item.columnName]" :sortable="item.needSort" :sort-rule.sync="tableDataSortRules[item.columnName]" />
@@ -74,7 +74,7 @@ export default {
     },
     tableTag: {
       type: Object,
-      default: () => { },
+      default: () => ({}),
     },
     tableName: {
       type: String,
@@ -108,6 +108,10 @@ export default {
       type: Number,
       default: 20,
     },
+    shouldReset: {
+      type: Boolean,
+      default: true
+    },
   },
   data () {
     return {
@@ -133,7 +137,9 @@ export default {
       tableOptions: {}, // 弹框-下来数据缓存
       showSummary: false, // 是否显示统计
       tableDataSortRules: {},
-      tableCath: []
+      tableCath: [],
+      leaveCount: 0,
+      checkPath: ['/newDeparture', '/newTransfer/in', '/newTransfer/out', '/newArrival']
     }
   },
   computed: {
@@ -174,9 +180,13 @@ export default {
   },
   watch: {
     tableTag: {
-      handler (val) {
+      async handler (val) {
         this.dataContent = val
         this.restTable()
+        if (val.shouldReset) {
+          this.$emit('update:shouldReset', true)
+          await this.$nextTick()
+        }
         this.load()
       },
       deep: true,
@@ -293,7 +303,11 @@ export default {
     // 获取表格数据
     async getQuery (id, dataContent = this.dataContent, page, pageSize) {
       try {
-        this.loading = true
+        if (this.shouldReset) {
+          this.loading = true
+        }
+        this.$emit('update:shouldReset', false)
+        await this.$nextTick()
         const { code, returnData } = await this.getQueryListAuth(
           id,
           dataContent,
@@ -305,28 +319,34 @@ export default {
             this.page--
             this.noMore = true
             this.loading = false
+            return
+          }
+          if (this.shouldReset) {
+            this.tableData.push(...returnData)
+          } else {
+            this.tableData = [...returnData]
           }
-          this.tableData.push(...returnData)
           this.$emit('tableLoad', [...this.tableData])
           setTimeout(() => {
             this.initTableData()
             this.loading = false
           }, 100)
         } else {
-          this.page--
-          this.loading = false
-          this.$message.error('获取表格数据失败')
+          throw new Error('获取表格数据失败')
         }
       } catch (error) {
         this.page--
         this.loading = false
+        this.$message.error(error.message)
       }
     },
     restTable () {
       this.loading = false
-      this.noMore = false
       this.page = 0
-      this.tableData = []
+      if (this.shouldReset) {
+        this.noMore = false
+        this.tableData = []
+      }
     },
     load () {
       if (this.tableTag && Object.keys(this.tableTag).length) {
@@ -335,6 +355,7 @@ export default {
         }
         if (this.AqueryParams && this.AqueryParams.queryparams) {
           const newData = _.cloneDeep(this.tableTag)
+          delete newData.shouldReset
           const paramsType = typeof this.AqueryParams.queryparams
           if (paramsType == 'string') {
             const dataObj = {}
@@ -402,6 +423,17 @@ export default {
         //   }
         // }
       })
+      if (this.$route.path == '/newDeparture') {
+        this.leaveCount = 0
+        const nTableData = [...this.tableData]
+        const cData = nTableData.filter(item => Number(item['NO_BSM_number']) + Number(item['check_in_baggage_number']) > 0)
+        cData.forEach(item => {
+          if (item.normalState == 'DEP' || item.normalState == 'ARR') {
+            this.leaveCount++
+          }
+        })
+        this.tableData = _.orderBy([...cData], ["scheduleTakeOffTime", "normalState"], ["asc", "desc"]);
+      }
       const dats = this.setTableFilters(this.tableData, this.tableDataFilters)
       this.tableDataFilters = _.cloneDeep(dats)
       this.tableGroup(this.tableData)
@@ -458,7 +490,6 @@ export default {
     async getSelectData (id) {
       // name ? [name] : name === null ? [null]: [],
       const { code, returnData } = await this.getQueryList(id, {})
-      console.log(returnData)
       if (code == 0) {
         return returnData
       } else {
@@ -534,6 +565,35 @@ export default {
       if (this.authBtnColName.includes(column.property)) {
         return 'is-click-btn'
       }
+      if (this.$route.path == '/newDeparture') {
+        if (column.property === 'NO_check_number' && Number(row['NO_check_number']) > 0) {
+          return 'cell-toUnload'
+        }
+      }
+    },
+    // 表格-设置行样式
+    rowClass ({ row, rowIndex }) {
+      const classes = []
+      if (this.checkPath.includes(this.$route.path)) {
+        const { abnormalState, normalState } = row
+        if (abnormalState) {
+          if (abnormalState == 'DLY') {
+            classes.push('bgl-delayed')
+          }
+          if (abnormalState == 'CAN') {
+            classes.push('bgl-canceled')
+          }
+        }
+        if (normalState) {
+          if (normalState == 'DEP' || normalState == 'ARR') {
+            classes.push('bgl-hui')
+          }
+        }
+        if (rowIndex === this.leaveCount - 1) {
+          classes.push("redBorder");
+        }
+      }
+      return classes
     },
     // 表格-单元格点击
     cellClick (row, column) {
@@ -603,6 +663,41 @@ export default {
         line-height: 34px;
       }
     }
+    tr.bgl-delayed td {
+      background: #fcf0b1;
+    }
+    tr.bgl-canceled td {
+      background: #f7babe;
+    }
+    tr.bgl-hui td {
+      background: #d2d6df;
+    }
+    .redBorder {
+      position: relative;
+      &::after {
+        content: "";
+        position: absolute;
+        left: 0;
+        bottom: 0;
+        width: 100%;
+        height: 2px;
+        background: #e83f82;
+      }
+    }
+    td.cell-toUnload {
+      background: lightcoral !important;
+      position: relative;
+      &::after {
+        content: "";
+        display: block;
+        width: 100%;
+        height: 100%;
+        position: absolute;
+        top: 0;
+        left: 0;
+        border: 2px dashed red;
+      }
+    }
   }
   .btns {
     position: absolute;

+ 6 - 0
src/views/systemSettings/views/newAuth/components/table.vue

@@ -147,6 +147,11 @@
                 <el-input size="small" clearable placeholder="请输入分组名称" v-model="tableForm.groupName"></el-input>
               </el-form-item>
             </el-col>
+            <el-col :span="6">
+              <el-form-item label-width="70px" class="flex1" label="名称长度">
+                <el-input size="small" clearable placeholder="请输入名称长度" v-model="tableForm.nameLength"></el-input>
+              </el-form-item>
+            </el-col>
           </el-row>
         </el-form>
       </div>
@@ -282,6 +287,7 @@ export default {
         is_search: '',
         default_query_parameters: '',
         groupName: '',
+        nameLength: ''
       },
       tableData: [],
       tableDataCopys: [],