comparison.vue 4.76 KB
<!--
 * @Description:
 * @Autor: renchao
 * @LastEditTime: 2023-07-19 09:52:37
-->
<template>
  <div class="djxxTable">
    <div class="tableBox">
      <div class="title">
        {{ title }}
        <div class="checkbox">
          <el-radio-group v-model="radio" :change="checkChange()">
            <el-radio :label="1">所有数据</el-radio>
            <el-radio :label="2">只展示变化数据</el-radio>
          </el-radio-group>
        </div>
      </div>
      <div class="xxTableBox rollTable">
        <!-- 固定前三个 -->
        <table class="xxTable">
          <tr v-for="(item, colindex) in columnsall" :key="colindex" :class="item.bt">
            <td>
              {{ item.label }}
            </td>
            <td v-for="(row, index) in tableData" :key="index">
              <div class="setbut" v-if="item.prop == 'bhqk'">
                {{ index?"变化后": "变化前"}}
              </div>
              <div
                v-if="item.prop == 'cz' && row.sjlx != '系统数据'"></div>
              <span v-if="item.prop == 'qszt'" :class="item.co">
                {{ getQsztName(row[item.prop]) }}
              </span>
              <span v-else :class="item.co"> {{ row[item.prop] }}</span>
            </td>
          </tr>
        </table>
      </div>
    </div>
  </div>
</template>

<script>
  import { datas } from "./qlxxFormData.js";
  import { getSjlx } from "@/utils/dictionary.js";
  import { getDjbQlxxDiff } from "@/api/djbDetail.js";
  export default {
    props: {
      formData: {
        type: Object,
        default: {},
      },
    },
    data () {
      return {
        radio: 1,
        title: "变化情况对比",
        qsztList: datas.columns().qsztList,
        //列表数据
        tableData: [],
        //空列值个数
        emptycolNum: 1,
        //列名称对象
        columns: [],
        columnsall: [],
        columnsum: []
      };
    },
    created () {
      switch (this.formData.dqqllx) {
        case "JSYDSYQ":
          this.columns = datas.columns().JSYDSYQ;
          break;
        case "FDCQ2":
          this.columns = datas.columns().FDCQ2;
          break;
        case "NYDSYQ":
          this.columns = datas.columns().NYDSYQ;
          break;
        case "DYAQ":
          this.columns = datas.columns().DYAQ;
          break;
        case "DYIQ":
          this.columns = datas.columns().DYIQ;
          break;
        case "YGDJ":
          this.columns = datas.columns().YGDJ;
          break;
        case "CFDJ":
          this.columns = datas.columns().CFDJ;
          break;
        case "YYDJ":
          this.columns = datas.columns().YYDJ;
          break;
      }
      this.getdata();
    },
    methods: {
      getArrDifference: function (arr1, arr2) {
        return arr1.concat(arr2).filter(function (value, i, arr) {
          return arr.indexOf(value) === arr.lastIndexOf(value);
        })
      },
      /**
       * @description: checkChange
       * @author: renchao
       */
      getdata () {
        getDjbQlxxDiff(this.formData.bsmQlxx).then((res) => {
          if (res.code === 200) {
            this.tableData.push(res.result.ssQlxx)
            this.tableData.push(res.result.currentQlxx)

            this.tableData.map((item) => {
              item.sjlx = getSjlx(item.sjlx);
            });
            for (let key in this.tableData[0]) {
              this.columnsum = this.columns.filter((item, index) => {
                if (this.tableData[1][key] !== this.tableData[0][key] && this.columns[index].prop == key) {
                  this.columns[index].bt = "bgc"
                  this.columns[index].co = "red"
                }
                return this.columns[index].bt == "bgc"
              })
            }
            this.columns.unshift({
              prop: "bhqk",
              label: ""
            })
            this.columnsum.unshift({
              prop: "bhqk",
              label: ""
            })
            this.columnsall = this.columns



          }
        });
      }
    /**
     * @description: getQsztName
     * @param {*} code
     * @author: renchao
     */,
      getQsztName (code) {
        let name = "";
        for (let item of this.qsztList) {
          if (item.value == code) {
            name = item.label;
            break;
          }
        }
        return name;
      },

      checkChange () {
        if (this.radio == 2) {
          this.columnsall = this.columnsum

        } else {
          this.columnsall = this.columns

        }
      },
    },
  };
</script>

<style lang="scss" scoped>
  @import "./qlxxCommon.scss";
  .bgc {
    td {
      // background-color: rgb(182, 203, 207) !important;
    }
  }
  .xxTable tr td {
    min-width: 520px !important;
  }
  .red {
    color: red;
  }
  .setbut {
    font-size: 18px;
    font-weight: 700;
  }
</style>