Header.vue 16.4 KB
Newer Older
fukai committed
1
<template>
2
  <div class="self-header">
潘际乾 committed
3
    <div style="display: inline-block; height: 40px">
4
      <img src="../../assets/logo.png" alt="" style="height: 100%" />
潘际乾 committed
5
    </div>
6
    <div class="self_header_label">
潘际乾 committed
7
      <h2>国际结算系统</h2>
8
      <!--h2 style="margin-left: 15px;">International Settlement</h2-->
9 10
    </div>
    <div class="header-tool">
Wuyuqiu committed
11
      <div class="header-subInstName">  
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
        <!-- <marquee
          v-if="subInstName.length > 12"
          behavior="scroll"
          direction="left"
          scrollamount="3"
          >{{ this.subInstName }}</marquee
        > -->
        <span v-if="subInstName.length <= 12">{{ this.subInstName }}</span>
      </div>
      <el-popover
        class="header-tool-popover"
        placement="bottom"
        width="200"
        trigger="hover"
      >
        <div class="header-tool-userdetail">
          <div>{{ user.userName }}</div>
          <div class="long-text" :title="user.userId">
wangren committed
30 31
            <i class="el-icon-user" style="padding: 0px 5px"></i>
            <span style="letter-spacing: 1px">{{ user.userId }}</span>
32 33
          </div>
          <div class="long-text" :title="user.instName">
wangren committed
34
            <i class="el-icon-office-building" style="padding: 0px 5px"></i>
35 36 37
            {{ user.instName }}
          </div>
          <div class="long-text" :title="user.roleName">
wangren committed
38
            <i class="el-icon-collection-tag" style="padding: 0px 5px"></i>
39 40
            {{ user.roleName }}
          </div>
wangren committed
41

42
          <el-row class="header-tool-userdetail-action">
43
            <!-- <el-button
潘际乾 committed
44 45
              @click="showHomeCellSettingDialog"
              size="small"
wangren committed
46
              style="width: 100%; margin-left: 0px; margin-top: 5px"
潘际乾 committed
47
              >首页组件</el-button
48
            > -->
wangren committed
49 50 51 52 53 54
            <el-button
              @click="showChgPwdDialog"
              size="small"
              style="width: 100%; margin-left: 0px; margin-top: 5px"
              >修改密码</el-button
            >
55 56 57
            <el-button
              @click="showLogoutDialog(false)"
              size="small"
wangren committed
58
              style="width: 100%; margin-left: 0px; margin-top: 5px"
59 60
              >用户签退</el-button
            >
wangren committed
61
            <!-- <el-button
62 63 64 65
              @click="showLogoutDialog(true)"
              size="small"
              style="width:100%;margin-left:0px;margin-top:5px"
              >强制签退</el-button
wangren committed
66
            > -->
67 68 69 70 71 72
          </el-row>
        </div>
        <div class="header-tool-item" slot="reference">
          <div>
            <i class="el-icon-user"></i>
            <span class="header-tool-item-text">{{ user.userName }}</span>
wangren committed
73
            <i class="el-icon-arrow-down" style="font-size: 12px"></i>
74 75 76 77 78 79 80 81
          </div>
        </div>
      </el-popover>
      <el-popover
        class="header-tool-popover"
        placement="bottom"
        width="80"
        trigger="hover"
82
        v-model="langSelectVisible"
83 84
      >
        <ul class="header-tool-item-list">
85 86 87 88 89 90 91
          <li
            v-for="(item, idx) in languageOptions"
            :key="idx"
            @click="handleLang(item.lang)"
          >
            {{ item.fullName }}
          </li>
92 93
        </ul>
        <div class="header-tool-item header-tool-item-text" slot="reference">
wangren committed
94
          <i class="el-icon-setting" style="font-size: 14px"></i>
95
          {{ displayLangName }}
wangren committed
96
          <i class="el-icon-arrow-down" style="font-size: 12px"></i>
97 98 99 100 101 102
        </div>
      </el-popover>
      <el-popover placement="bottom" width="450" trigger="hover">
        <div>
          <el-col :span="24">
            <el-col :span="24">
103 104 105
              <c-page title="公告">
                <c-table :data="noticeboardData">
                  <el-table-column
wangren committed
106
                    label="通知内容"
107 108 109 110 111 112 113 114 115 116 117 118
                    prop="noticeContent"
                  ></el-table-column>
                  <el-table-column
                    label="发布人"
                    prop="publisher"
                  ></el-table-column>
                  <el-table-column
                    label="发布日期"
                    prop="publishDate"
                  ></el-table-column>
                </c-table>
              </c-page>
119 120
            </el-col>
          </el-col>
121
        </div>
122 123
        <div class="header-tool-item" slot="reference">
          <i class="el-icon-bell"></i>
wangren committed
124
          <span class="header-tool-item-text" style="padding-left: 7px"
125 126
            >通知</span
          >
127 128 129
        </div>
      </el-popover>
      <span class="header-tool-item-text">会计日期: {{ accDate }}</span>
fukai committed
130
    </div>
潘际乾 committed
131

wangren committed
132 133 134 135 136
    <el-dialog
      custom-class="homeSetting"
      :visible="homeSettingDialog"
      title="首页小组件设置"
      width="60%"
潘际乾 committed
137 138
      :before-close="handleCloseHomeSettingDialog"
    >
wangren committed
139
      <div style="padding: 0 20px">
潘际乾 committed
140
        <div class="clear">
wangren committed
141
          <c-col :span="24" style="margin-bottom: 10px">
潘际乾 committed
142
            选择行数:
wangren committed
143 144 145 146 147
            <c-select
              v-model="homeSetting.rows"
              :clearable="false"
              @change="updateDisplayArr"
            >
潘际乾 committed
148 149 150 151 152
              <el-option label="1" :value="1"></el-option>
              <el-option label="2" :value="2"></el-option>
              <el-option label="3" :value="3"></el-option>
            </c-select>
          </c-col>
wangren committed
153
          <c-col :span="24" style="margin-bottom: 10px">
潘际乾 committed
154
            选择列数:
wangren committed
155 156 157 158 159
            <c-select
              v-model="homeSetting.cols"
              :clearable="false"
              @change="updateDisplayArr"
            >
潘际乾 committed
160 161 162 163 164 165 166 167 168
              <el-option label="1" :value="1"></el-option>
              <el-option label="2" :value="2"></el-option>
              <el-option label="3" :value="3"></el-option>
              <el-option label="4" :value="4"></el-option>
            </c-select>
          </c-col>
        </div>
        <div>
          <div class="setting-grid-row" v-for="row in getCellRows()" :key="row">
wangren committed
169 170 171 172 173 174
            <div
              class="setting-grid-col"
              v-for="col in getCellCols()"
              :key="col"
              :style="{ width: 100 / getCellCols() + '%', height: '50px' }"
            >
潘际乾 committed
175
              <div class="cell-item">
wangren committed
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
                <div>
                  {{
                    homeSetting.displayArray[row - 1][col - 1].title
                      ? "标题:" +
                        homeSetting.displayArray[row - 1][col - 1].title
                      : ""
                  }}
                </div>
                <div>
                  {{
                    homeSetting.displayArray[row - 1][col - 1].description
                      ? "描述:" +
                        homeSetting.displayArray[row - 1][col - 1].description
                      : ""
                  }}
                </div>
潘际乾 committed
192 193 194 195 196 197 198
              </div>
              <div class="cell-operate">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">
                    设置&nbsp;&nbsp;<i class="el-icon-edit"></i>
                  </span>
                  <el-dropdown-menu slot="dropdown">
wangren committed
199 200 201
                    <el-dropdown-item
                      v-for="(item, idx) in $store.state.UserContext
                        .homeCellsSetting.defaultCells"
潘际乾 committed
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
                      :key="idx"
                      @click.native="setCell(row, col, item)"
                    >
                      {{ item.title }}
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </div>
            </div>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <c-button @click="cancelHomeSetting">取消</c-button>
        <c-button type="primary" @click="saveHomeSetting">保存</c-button>
      </span>
    </el-dialog>
219
  </div>
fukai committed
220 221 222
</template>

<script>
223
import cPage from "../../components/c-page.vue";
liuxin committed
224
import Api from "~/service/Api";
fukai committed
225
import EventService, {LOGOUT} from "~/service/EventService";
liuxin committed
226 227
import { changeLang } from "~/service/business/lang";

fukai committed
228
export default {
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
  components: { cPage },
  data() {
    return {
      txName: "",
      user: {
        userName: this.$store.state.UserContext.userName || "Admin",
        roleName: window.sessionStorage.roleName || "超级管理员",
        instName: window.sessionStorage.instName || "北京分行",
        userId: this.$store.state.UserContext.userId || "2124221421214",
      },
      rules: {
        username: [{ type: "string", required: true, message: "请填写用户名" }],
        password: [{ type: "string", required: true, message: "请填写密码" }],
      },
      dialogOpen: false,
      loading: false,
      count: "",
246
      accDate: window.sessionStorage.accDate || new Date().toLocaleDateString(),
247 248 249 250 251
      noticeboardData: [],
      langSelectVisible: false,
      languageOptions: [
        { lang: "zh", shortName: "中文", fullName: "中文" },
        { lang: "en", shortName: "En", fullName: "English" },
liuxin committed
252 253
        { lang: "th", shortName: "ไทย", fullName: "ภาษาไทย" },
        { lang: "vi", shortName: "Tiếng Việt", fullName: "Tiếng Việt" },
254
      ],
潘际乾 committed
255 256 257 258
      homeSettingDialog: false,
      homeSetting: {
        rows: null,
        cols: null,
wangren committed
259 260
        displayArray: [],
      },
261 262 263 264 265 266 267 268 269
    };
  },
  computed: {
    subInstName() {
      // let subStrList = window.sessionStorage.instName.split("股份有限公司");
      // let length = subStrList.length;
      // return subStrList[length - 1];
      return "北京分行";
    },
270 271 272 273 274 275 276 277 278 279 280 281
    lang() {
      return this.$store.state.I18n.lang;
    },
    displayLangName() {
      for (let i = 0; i < this.languageOptions.length; i++) {
        const op = this.languageOptions[i];
        if (this.lang === op.lang) {
          return op.shortName;
        }
      }
      return "";
    },
282 283 284
  },
  methods: {
    logout() {
fukai committed
285
      EventService.emit(LOGOUT);
286 287
      this.$store.commit("UserContext/setLogout");
      this.$router.push("/login");
288
      // window.location.href = "/#/login"
289
    },
liuxin committed
290
    async handleLang(lang) {
wangren committed
291 292 293 294 295 296 297 298 299
      const data = {
        lang: lang,
      };
      let rtnmsg = await changeLang(data);
      if (rtnmsg.respCode == SUCCESS) {
        this.$i18n.locale = lang;
        this.$store.dispatch("I18n/setLang", lang);
        this.langSelectVisible = false;
      }
300 301
    },
    showLogoutDialog(flg) {
潘际乾 committed
302
      // this.$refs.logoutform.show(flg);
wangren committed
303 304 305
      this.$store
        .dispatch("TagsView/delAllViews")
        .then(() => this.$router.push("/login"));
306 307 308 309
    },
    showChgPwdDialog() {
      this.$refs["chgPwdForm"].dialogOpen = true;
    },
潘际乾 committed
310 311
    showHomeCellSettingDialog() {
      this.homeSettingDialog = true;
wangren committed
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
      this.homeSetting.rows =
        this.$store.state.UserContext.homeCellsSetting.cellRows;
      this.homeSetting.cols =
        this.$store.state.UserContext.homeCellsSetting.cellCols;
      this.homeSetting.displayArray =
        this.$store.state.UserContext.homeCellsSetting.cellNames.map(
          (cellNameRows) => {
            return cellNameRows.map((cellName) => {
              return Object.assign(
                {},
                this.$store.state.UserContext.homeCellsSetting.defaultCells.find(
                  (cell) => cell.name === cellName
                )
              );
            });
          }
        );
潘际乾 committed
329 330 331
    },
    saveHomeSetting() {
      if (!this.homeSetting.rows || !this.homeSetting.cols) {
wangren committed
332 333
        this.$message.warning("请选择正确的行列数!");
        return;
潘际乾 committed
334
      }
wangren committed
335 336 337 338 339 340
      const cellNames = this.homeSetting.displayArray.map((row) => {
        return row.map((col) => col.name);
      });
      if (cellNames.some((row) => row.some((cellName) => !cellName))) {
        this.$message.warning("请配置全部的格子组件!");
        return;
潘际乾 committed
341
      }
wangren committed
342
      this.$store.commit("UserContext/setHomeCellsSetting", {
潘际乾 committed
343 344
        cellRows: this.homeSetting.rows,
        cellCols: this.homeSetting.cols,
wangren committed
345 346
        cellNames: cellNames,
      });
潘际乾 committed
347 348 349 350 351 352 353 354 355 356
      this.homeSettingDialog = false;
    },
    cancelHomeSetting() {
      this.homeSettingDialog = false;
    },
    handleCloseHomeSettingDialog(done) {
      this.homeSettingDialog = false;
      done();
    },
    getCellRows() {
wangren committed
357 358 359 360 361
      return this.homeSetting.rows
        ? this.homeSetting.rows
        : this.homeSetting.cols
        ? 1
        : 0;
潘际乾 committed
362 363
    },
    getCellCols() {
wangren committed
364 365 366 367 368
      return this.homeSetting.cols
        ? this.homeSetting.cols
        : this.homeSetting.rows
        ? 1
        : 0;
潘际乾 committed
369 370
    },
    updateDisplayArr() {
wangren committed
371
      const rArr = [];
潘际乾 committed
372
      for (let i = 0; i < this.getCellRows(); i++) {
wangren committed
373
        const cArr = [];
潘际乾 committed
374
        for (let j = 0; j < this.getCellCols(); j++) {
wangren committed
375 376 377 378 379
          cArr.push({
            title: null,
            name: null,
            description: null,
          });
潘际乾 committed
380
        }
wangren committed
381
        rArr.push(cArr);
潘际乾 committed
382
      }
wangren committed
383
      this.homeSetting.displayArray = rArr;
潘际乾 committed
384 385
    },
    setCell(row, col, item) {
wangren committed
386 387 388 389 390
      this.homeSetting.displayArray[row - 1][col - 1].title = item.title;
      this.homeSetting.displayArray[row - 1][col - 1].name = item.name;
      this.homeSetting.displayArray[row - 1][col - 1].description =
        item.description;
    },
391 392
  },
};
fukai committed
393 394 395
</script>

<style>
396 397 398 399 400 401
.header-subInstName {
  display: inline-block;
  margin-right: 12px;
  text-align: right;
  font-size: 12px;
  padding: 0px 15px 0px 0px;
潘际乾 committed
402
  border-right: 1px solid #707070;
403 404 405 406 407
}
.self-header {
  height: 100%;
  /* background-color: #eeeeee; */
  /* margin-bottom: 5px; */
潘际乾 committed
408 409 410 411 412 413 414 415 416
  /* background-image: url("../../assets/head_bg.png"); */
  /* position: relative; */
  padding: 0px 0px 0px 30px;
  /* background-size: cover; */
  background-image: linear-gradient(#ededed, #dbebfc);
  border-bottom: solid 5px #2346dd;
  box-sizing: border-box;
  display: flex;
  align-items: center;
417 418 419 420 421 422
}

.self-header h2 {
  margin: 0;
  padding: 0;
  display: inline;
潘际乾 committed
423 424
  font-weight: unset;
  font-size: 22px;
425 426 427 428
}

.self_header_label {
  /* color: antiquewhite; */
潘际乾 committed
429
  color: #1b54b8;
430
  /* margin-top: 10px !important; */
潘际乾 committed
431 432
  /* position: relative; */
  /* top: 12.778px; */
433 434
  /* left: 10px; */
  padding: 0px 15px;
潘际乾 committed
435
  margin-left: 15px;
436 437
  display: inline-table;
  vertical-align: top;
liushikai committed
438
  font-family: "黑体";
439 440
  /* border-left: 1px solid antiquewhite; */
  border-left: 1px solid #fff;
Wuyuqiu committed
441 442
  /* ui美化 */
  font-size: 30px;
潘际乾 committed
443
  border-image: radial-gradient(#2244d4,transparent) 1 20;
444 445 446 447 448 449 450 451 452 453 454
}
.self_header_label p {
  font-family: "Times New Roman", Times, serif;
  text-align: center;
  font-style: italic;
  margin: 0;
  padding: 0;
  font-size: 12px;
  display: inline;
}
.header-tool {
潘际乾 committed
455
  /* position: absolute; */
456
  text-align: right;
潘际乾 committed
457 458 459
  /* right: 35px; */
  /* top: 22px; */
  color: #707070;
460
  font-size: 14px;
潘际乾 committed
461 462
  margin-right: 35px;
  flex: 1;
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
}
.header-tool-item {
  display: inline-block;
  margin-right: 12px;
  cursor: pointer;
}
.header-tool-userdetail {
  text-align: center;
}
.header-tool-item-text {
  font-size: 12px;
}
.header-tool-item-list {
  padding: 0;
  margin: 0;
}
.header-tool-userdetail-action {
  margin-top: 10px;
}
.header-tool-item-list li {
  list-style: none;
  padding: 5px;
  text-align: center;
  color: #606266;
  cursor: pointer;
}
.header-tool-item-list li:hover {
  background: rgba(144, 146, 152, 0.3);
}
.logoutdialog .el-dialog .el-dialog__header {
  padding: 10px 20px 0px;
}
.logoutdialog .el-dialog .el-dialog__body {
  padding: 20px 30px 0px 20px;
}
.logoutdialog .el-dialog .el-dialog__footer {
  padding: 0px 20px 15px;
Wuyuqiu committed
500

501
}
Wuyuqiu committed
502

503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
/* .header-tool-item-badge {
		margin-top: 10px;
		margin-right: 40px;
	} */
.header-tool-item-badge .el-badge__content {
  background-color: #f56c6c;
  border-radius: 7px;
  /* color: #FFF; */
  display: inline-block;
  font-size: 12px;
  height: 14px;
  line-height: 14px;
  padding: 0 6px;
  text-align: center;
  white-space: nowrap;
  border: 0px;
}
.long-text {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  text-align: left;
  font-size: 12px;
}
.long-text:hover {
  background-color: #e8f0fe;
}
潘际乾 committed
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
/* 首页设置框 */
.homeSetting .setting-grid-row {
  width: 100%;
  display: flex;
  border-bottom: 1px solid #ebebeb;
}
.homeSetting .setting-grid-row:nth-of-type(1) {
  border-top: 1px solid #ebebeb;
}
.homeSetting .setting-grid-col {
  display: flex;
  border-right: 1px solid #ebebeb;
}
.homeSetting .setting-grid-row .setting-grid-col:nth-of-type(1) {
  border-left: 1px solid #ebebeb;
}
.homeSetting .setting-grid-col .cell-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-left: 15px;
}
.homeSetting .setting-grid-col .cell-operate {
  font-size: 24px;
  margin: 0 10px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.homeSetting .setting-grid-col .cell-operate .el-dropdown-link {
  cursor: pointer;
wangren committed
562
  color: #409eff;
潘际乾 committed
563
}
564
</style>