index.vue 7.02 KB
Newer Older
乐宝呗666's avatar
乐宝呗666 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
<template>
  <div class="interactive-wrapper height100">
    <el-card class="height100 tree-box">
      <div class="tree-title">组织机构</div>
      <div class="tree-body">
        <el-input
          suffix-icon="el-icon-search"
          placeholder="请输入组织结构名称"
          v-model="filterText"
        ></el-input>
        <div class="tree-content">
          <el-tree
            class="org-tree"
            :data="treeData"
            :props="defaultProps"
            accordion
            :filter-node-method="filterNode"
            @node-click="handleNodeClick"
            ref="tree"
          >
            <div
              class="custom-tree-node"
              slot-scope="{ node, data }"
              :class="'tree-node-level' + data.level"
            >
              <i class="icon-org" v-if="data.level === 1"></i>
              <span>{{ node.label }}</span>
            </div>
          </el-tree>
        </div>
      </div>
    </el-card>
    <el-card class="height100 detail-box" ref="rightBox">
      <div class="content-title">
        <div class="title">“北京市政府”展板互动信息汇总</div>
        <div class="page-tip">
          <span class="page-tip-title">页面说明:</span>
乐宝呗666's avatar
乐宝呗666 committed
38
          <span class="page-tips">可查看某个组织机构的互动信息</span>
乐宝呗666's avatar
乐宝呗666 committed
39 40
        </div>
      </div>
乐宝呗666's avatar
乐宝呗666 committed
41
      <div class="scrollBox"  v-show="tableData.length">
乐宝呗666's avatar
乐宝呗666 committed
42 43 44 45 46 47 48
        <div
          class="content-item"
          v-for="(item, index) in tableData"
          :key="index"
        >
          <h5 class="title">{{ item.name }}</h5>
          <p>{{ item.content }}</p>
乐宝呗666's avatar
乐宝呗666 committed
49
          <div class="img-box" v-if="item.images.length">
乐宝呗666's avatar
乐宝呗666 committed
50 51
            <img v-for="(j, idx) in item.images" :src="j" :key="idx" alt="" />
          </div>
乐宝呗666's avatar
乐宝呗666 committed
52
          <div class="img-box" v-if="!item.images.length">暂无数据</div>
乐宝呗666's avatar
乐宝呗666 committed
53 54 55 56 57 58
          <div class="author">
            <div>{{ item.username }}</div>
            <div>{{ item.createTime }}</div>
          </div>
        </div>
      </div>
乐宝呗666's avatar
乐宝呗666 committed
59
      <div class="partyt-pagination" style="margin: 0 20px"  v-show="tableData.length">
乐宝呗666's avatar
乐宝呗666 committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
        <el-pagination
          background
          @current-change="handleCurrentChange"
          :current-page="page.currentPage"
          :page-size="page.pageSize"
          layout="prev, pager, next, jumper"
          :total="page.total"
        ></el-pagination>
      </div>
    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return {
      filterText: "",
乐宝呗666's avatar
乐宝呗666 committed
77 78 79 80
      page: {
        currentPage: 1,
        pageSize: 10,
        total: 0,
乐宝呗666's avatar
乐宝呗666 committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
      },
      treeData: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
      selectAreaId: "",
      tableData: [],
    };
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val);
    },
  },
  mounted() {
    // 获取全部组织机构数据
乐宝呗666's avatar
乐宝呗666 committed
98 99
    this.getOrgData();
    // this.onSearch()
乐宝呗666's avatar
乐宝呗666 committed
100 101 102 103
  },
  methods: {
    // 查询
    onSearch() {
乐宝呗666's avatar
乐宝呗666 committed
104 105
      this.page.currentPage = 1;
      this.getTableData();
乐宝呗666's avatar
乐宝呗666 committed
106 107 108
    },
    // 获得数据接口
    getTableData() {
乐宝呗666's avatar
乐宝呗666 committed
109 110
      let vm = this;
      vm.tableData = [];
乐宝呗666's avatar
乐宝呗666 committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
      let param = {
        _index: this.page.currentPage,
        _size: this.page.pageSize,
        orgId: this.selectAreaId,
      };
      vm.$https(
        {
          url: "interaction/getList",
          method: "post",
          authType: this.backToken,
        },
        vm.$qs.stringify(param)
      )
        .then((res) => {
          if (res.data.resultCode === "200") {
乐宝呗666's avatar
乐宝呗666 committed
126 127 128 129 130 131 132
            let data = res.data.data;
            vm.page.total = data.total;
            vm.tableData = data.records;
            if(!vm.tableData.length){
              this.$message('暂无数据')
              return false
            }
乐宝呗666's avatar
乐宝呗666 committed
133
            vm.tableData.forEach((item) => {
乐宝呗666's avatar
乐宝呗666 committed
134
              item.images = item.images ? item.images.split(",") : [];
乐宝呗666's avatar
乐宝呗666 committed
135 136
              item.images.forEach((result, index) => {
                if (/\.(MP4|mp4)/.test(result)) {
乐宝呗666's avatar
乐宝呗666 committed
137
                  item.images[index] = require("@/assets/video-icon.png");
乐宝呗666's avatar
乐宝呗666 committed
138
                } else if (/\.(MP3|mp3)/.test(result)) {
乐宝呗666's avatar
乐宝呗666 committed
139
                  item.images[index] = require("@/assets/audio-icon.png");
乐宝呗666's avatar
乐宝呗666 committed
140
                }
乐宝呗666's avatar
乐宝呗666 committed
141 142
              });
            });
乐宝呗666's avatar
乐宝呗666 committed
143

乐宝呗666's avatar
乐宝呗666 committed
144
            vm.tableData = [...vm.tableData];
乐宝呗666's avatar
乐宝呗666 committed
145
          } else {
乐宝呗666's avatar
乐宝呗666 committed
146
            this.$message.error(res.data.message);
乐宝呗666's avatar
乐宝呗666 committed
147 148 149
          }
        })
        .catch(function (err) {
乐宝呗666's avatar
乐宝呗666 committed
150
          console.log(err);
乐宝呗666's avatar
乐宝呗666 committed
151 152 153 154 155 156 157 158 159 160 161
        });
    },
    // 获取组织机构数据
    getOrgData() {
      this.$https({
        method: "get",
        url: "organ/getTree",
        authType: this.backToken,
      }).then(
        (res) => {
          if (res.data.resultCode === "200") {
乐宝呗666's avatar
乐宝呗666 committed
162
            this.treeData = res.data.data;
乐宝呗666's avatar
乐宝呗666 committed
163
          } else {
乐宝呗666's avatar
乐宝呗666 committed
164
            this.$message.error(res.data.message);
乐宝呗666's avatar
乐宝呗666 committed
165 166 167
          }
        },
        (error) => {
乐宝呗666's avatar
乐宝呗666 committed
168
          console.log(error);
乐宝呗666's avatar
乐宝呗666 committed
169 170 171 172 173 174 175 176 177 178 179
        }
      );
    },
    // 过滤树结构数据
    filterNode(value, data) {
      if (!value) return true;
      return data.name.indexOf(value) !== -1;
    },
    // 点击节点事件
    handleNodeClick(data) {
      this.selectAreaId = data.id;
乐宝呗666's avatar
乐宝呗666 committed
180
      this.onSearch();
乐宝呗666's avatar
乐宝呗666 committed
181 182 183
    },
    // 分页
    handleCurrentChange(val) {
乐宝呗666's avatar
乐宝呗666 committed
184 185
      this.page.currentPage = val;
      this.getTableData();
乐宝呗666's avatar
乐宝呗666 committed
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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
    },
  },
};
</script>
<style lang="less">
@import "~@/style/pagination.less";
.interactive-wrapper {
  display: flex;
  .tree-box {
    width: 420px;
    .tree-body {
      padding: 20px;
      height: calc(100% - 56px);
      .tree-content {
        overflow-y: auto;
        height: calc(100% - 50px);
      }
      .el-input {
        margin-bottom: 10px;
        .el-input__inner {
          background: #f8f8f8;
          border-radius: 22px;
        }
        .el-input__icon {
          font-size: 18px;
          color: #ac9374;
        }
      }
    }
  }
  .detail-box {
    width: calc(100% - 440px);
    margin-left: 20px;
  }
  .scrollBox {
    height: calc(100% - 160px);
    overflow-y: auto;
  }
  .page-tip {
    display: flex;
    font-size: 14px;
    color: #333333;
228
    line-height: 30px;
乐宝呗666's avatar
乐宝呗666 committed
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
    .page-tip-title {
      font-weight: bold;
      padding-right: 10px;
    }
  }

  .el-card__body {
    padding: 0;
    height: 100%;
  }
  .tree-title {
    font-size: 16px;
    color: #fff;
    text-align: center;
    height: 56px;
    line-height: 56px;
    background: #9b1e23;
    border-radius: 8px 8px 0 0;
  }

  .content-title {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #eee;
    .title {
      font-size: 20px;
      color: #333;
    }
    .page-tips {
259
      width: 220px;
乐宝呗666's avatar
乐宝呗666 committed
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
    }
  }
  .content-item {
    font-size: 16px;
    margin: 20px;
    padding: 40px;
    background: #f8f8f8;
    .title {
      padding-bottom: 20px;
    }
    p {
      padding-bottom: 20px;
      border-bottom: 1px solid #bbb;
    }
    .img-box {
      padding: 20px;
      border-bottom: 1px solid #bbb;
      img {
        width: 90px;
        height: 90px;
        margin-right: 20px;
      }
    }
    .author {
      display: flex;
      justify-content: space-between;
      padding-top: 16px;
      font-size: 14px;
    }
  }
}
</style>