Blame view

src/views/zhcx/djbcx/components/djxxTable.vue 7.58 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<template>
  <div class="djxxTable">
    <div class="tableBox">
      <div class="title">
        {{ title }}
        <div class="checkbox">
          <el-checkbox-group v-model="checkList" @change="checkChange">
            <el-checkbox label="临时"></el-checkbox>
            <el-checkbox label="现势"></el-checkbox>
            <el-checkbox label="历史"></el-checkbox>
          </el-checkbox-group>
        </div>
      </div>
      <div class="xxTableBox" v-if="showTableData.length">
        <table class="xxTable" :width="tableWidth">
          <tr>
            <th rowspan="3">业务类型</th>
          </tr>
          <!-- 第一行表头 -->
          <tr class="one">
任超 committed
21
            <th v-for="(item, index) in ths" :key="index" :class="[item.class, item.type == '临时' ? 'linshiIcon' : '']">
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
              <div class="icon" v-if="item.type == '临时'">{{ item.type }}</div>
              {{ item.type }}
            </th>
          </tr>
          <!-- 第二行表头 -->
          <tr class="two">
            <th v-for="(item, index) in ths" :key="index" :class="item.class">
              <p>{{ item.qllxmc }}</p>
              <p>{{ item.djlxmc }}</p>
            </th>
          </tr>
          <!-- 数据 -->
          <tr v-for="(item, index) in columns" :key="index">
            <td>
              {{ item.label }}
            </td>
任超 committed
38 39 40 41
            <td v-for="(item1, index1) in showTableData" :key="index1" :class="[
              item1.qszt == '2' ? 'lishi' : '',
              item1.qszt == '0' ? 'linshi' : '',
            ]">
42 43 44 45 46 47 48 49 50 51 52 53
              {{ item1[item.prop] }}
            </td>
          </tr>
        </table>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { datas } from "./djxxColumns";
54
import { getJsydsyqList } from "@/api/zhcx.js";
55 56 57 58 59
export default {
  name: "djxxTable",
  props: {
    showType: "",
  },
任超 committed
60
  data () {
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
    return {
      checkList: ["临时", "现势", "历史"],
      tableWidth: 810,
      type: datas.columns(),
      tableData: [],
      showTableData: [],
      ths: [],
      showThs: [],
      columns: [],
      title: "",
    };
  },
  computed: {
    ...mapGetters(["djbxx"]),
  },
  watch: {
    showType: {
任超 committed
78
      async handler (newVlue) {
79 80 81 82 83 84
        // 清空值
        this.tableData = [];
        this.ths = [];
        this.columns = this.type[newVlue].columns;
        this.title = this.type[newVlue].title;
        this.checkList = ["临时", "现势", "历史"];
85 86 87
        this.tableWidth = 810;
        let detail;
        if (newVlue === "JSYDSYQ") {
任超 committed
88
          let res = await getJsydsyqList({
89 90 91
            bdcdyid: "2b33851f4edfd468ceef4d68c370bd41",
            qllx: "A03",
            qszt: ["1"]
任超 committed
92 93
          })
          detail = res.result;
94 95 96
        } else {
          detail = this.djbxx.detail.qlxxs[newVlue];
        }
任超 committed
97 98
        console.log(detail, 'detail');
        detail.length > 0 && detail.forEach((item) => {
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
          this.tableData.push(item);
          if (item.qszt == "0") {
            this.ths.push({
              type: "临时",
              qllxmc: item.qllxmc,
              djlxmc: item.djlxmc,
              prop: "linshi",
              class: "linshi",
            });
          } else if (item.qszt == "1") {
            this.ths.push({
              type: "现势",
              qllxmc: item.qllxmc,
              djlxmc: item.djlxmc,
              prop: "xianshi",
              class: "xianshi",
            });
          } else if (item.qszt == "2") {
            this.ths.push({
              type: "历史",
              qllxmc: item.qllxmc,
              djlxmc: item.djlxmc,
              prop: "lishi",
              class: "lishi",
            });
          }
        });
        this.showTableData = this.tableData;
        this.showThs = this.ths;
        let width = (this.tableData.length - 3) * 223 + this.tableWidth;
        this.tableWidth = this.tableData.length > 3 ? width : 810;
      },
任超 committed
131
      deep: true
132 133 134
    },
  },
  methods: {
任超 committed
135
    checkChange () {
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
      var checkKey = [];
      this.ths = [];
      this.tableWidth = 810;
      this.checkList.forEach((item) => {
        if (item == "临时") {
          checkKey.push("0");
        }
        if (item == "现势") {
          checkKey.push("1");
        }
        if (item == "历史") {
          checkKey.push("2");
        }
      });
      this.showTableData = this.tableData.filter((item) =>
        checkKey.includes(item.qszt)
      );
      this.showTableData.forEach((item) => {
        if (item.qszt == "0") {
          this.ths.push({
            type: "临时",
            qllxmc: item.qllxmc,
            djlxmc: item.djlxmc,
            prop: "linshi",
            class: "linshi",
          });
        } else if (item.qszt == "1") {
          this.ths.push({
            type: "现势",
            qllxmc: item.qllxmc,
            djlxmc: item.djlxmc,
            prop: "xianshi",
            class: "xianshi",
          });
        } else if (item.qszt == "2") {
          this.ths.push({
            type: "历史",
            qllxmc: item.qllxmc,
            djlxmc: item.djlxmc,
            prop: "lishi",
            class: "lishi",
          });
        }
      });
      let width = (this.showTableData.length - 3) * 223 + this.tableWidth;
      this.tableWidth = this.showTableData.length > 3 ? width : 810;
    },
  },
};
</script>

<style lang="scss" scoped>
.djxxTable {
  width: 100%;
  height: 100%;
  background: #fff;
  overflow-y: scroll;
  color: #333;

  .tableBox {
    width: 810px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;

    .title {
      width: 100%;
      font-family: "Arial Negreta", "Arial Normal", "Arial", sans-serif;
      font-weight: 700;
      font-size: 16px;
      text-align: center;
      background: #e9e9e9;
      height: 62px;
      line-height: 62px;
      position: relative;
      margin: 1px 0;
任超 committed
212

213 214 215 216 217 218 219 220 221 222 223 224 225
      .checkbox {
        position: absolute;
        right: 20px;
        bottom: -16px;
        height: 62px;
      }
    }

    .xxTableBox {
      width: 810px;
      overflow-x: scroll;
    }

吴蕾 committed
226 227 228
    // .xxTable > tr th:not(:first-child) {
    //   width: 223px;
    // }
任超 committed
229
    .xxTable>tr:first-child th {
230 231
      width: 140px;
    }
吴蕾 committed
232

233 234
    .xxTable {
      border-spacing: 1px;
任超 committed
235 236

      tr>th {
237 238 239 240
        background: #464c5b;
        color: #fff;
        font-size: 16px;
      }
任超 committed
241

242 243 244 245
      th.linshi,
      th.xianshi {
        background: #464c5b;
      }
任超 committed
246

247 248 249
      th.lishi {
        background: rgba(70, 76, 91, 0.8);
      }
任超 committed
250

251 252 253 254 255 256 257 258
      .one th {
        height: 25px;
        font-size: 14px;
      }

      th.linshi {
        color: #fe9400;
      }
任超 committed
259

260 261 262 263 264 265 266
      .two th {
        height: 45px;

        p:nth-child(2) {
          font-size: 14px;
        }
      }
任超 committed
267

268 269 270
      .linshiIcon {
        position: relative;
      }
任超 committed
271

272 273 274 275 276 277 278 279 280 281 282 283 284
      .linshiIcon::after {
        content: "";
        display: block;
        width: 0;
        height: 0;
        border-width: 0px 0px 45px 45px;
        border-style: none solid solid;
        border-color: transparent transparent #fe9400;
        position: absolute;
        top: 0px;
        right: 3px;
        transform: rotate(-90deg);
      }
任超 committed
285

286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
      .icon {
        position: absolute;
        top: 8px;
        right: 6px;
        transform: rotate(45deg);
        color: #fff;
        font-size: 12px;
        z-index: 10;
      }

      tr td {
        text-align: center;
        height: 40px;
        padding: 4px;
        font-size: 13px;
301
        width: 140px;
302
      }
任超 committed
303 304

      >tr:nth-child(odd) td {
305 306
        background: #f2f2f2;
      }
任超 committed
307 308

      >tr:nth-child(even) td {
309 310
        background: #f9f9f9;
      }
任超 committed
311

312 313 314
      td.linshi {
        color: #fe9400;
      }
任超 committed
315 316

      tr>td.lishi {
317 318 319 320 321 322
        color: #7f7f7f;
      }
    }
  }
}
</style>