市北互联平台前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

301 lines
8.8 KiB

4 years ago
<template>
<main :class="['aui-content', { 'aui-content--tabs': $route.meta.isTab }]">
<!-- tab展示内容 -->
4 years ago
<template v-if="$route.meta.isTab && !$store.state.inIframe">
4 years ago
<el-dropdown class="aui-content--tabs-tools">
<i class="el-icon-arrow-down"></i>
4 years ago
<el-dropdown-menu slot="dropdown" :show-timeout="0">
<el-dropdown-item
@click.native="tabRemoveHandle($store.state.contentTabsActiveName)"
>{{ $t("contentTabs.closeCurrent") }}</el-dropdown-item
>
<el-dropdown-item @click.native="tabsCloseOtherHandle()">{{
$t("contentTabs.closeOther")
}}</el-dropdown-item>
<el-dropdown-item @click.native="tabsCloseAllHandle()">{{
$t("contentTabs.closeAll")
}}</el-dropdown-item>
4 years ago
</el-dropdown-menu>
</el-dropdown>
4 years ago
<el-tabs
v-model="$store.state.contentTabsActiveName"
@tab-click="tabSelectedHandle"
@tab-remove="tabRemoveHandle"
>
<el-tab-pane
v-for="item in $store.state.contentTabs"
:key="item.name"
:name="item.name"
:label="item.title"
:closable="item.name !== 'indexWork'"
:class="{ 'is-iframe': tabIsIframe(item.iframeURL) }"
>
<template v-if="item.name === 'indexWork'">
<svg
slot="label"
class="icon-svg aui-content--tabs-icon-nav"
aria-hidden="true"
>
4 years ago
<use xlink:href="#icon-home"></use>
</svg>
</template>
<template v-if="tabIsIframe(item.iframeURL)">
4 years ago
<iframe
:src="
item.iframeURL + '?token=' + token + '&customerId=' + customerId
"
ref="iframes"
class="iframes"
id="iframes"
width="100%"
height="100%"
frameborder="0"
scrolling="yes"
></iframe>
<!-- <div v-if="tabIsIframe(item.iframeURL)" id="addend-iframe" style="height: 100%;"> </div> -->
4 years ago
</template>
<keep-alive v-else>
4 years ago
<router-view
v-if="item.name === $store.state.contentTabsActiveName"
@changeCustomerName="changeCustomerName"
/>
4 years ago
</keep-alive>
</el-tab-pane>
</el-tabs>
</template>
<!-- 其他方式, 展示内容 -->
<template v-else>
<keep-alive>
<router-view />
</keep-alive>
</template>
3 years ago
3 years ago
<template v-for="(item, index) in msgList">
3 years ago
<Tips :key="item.memoId"
3 years ago
:info="item"
:show="msgList.length > 0 ? true : false"
@look="handleLook(item, index)" @close="handleClose(item, index)" />
3 years ago
</template>
3 years ago
3 years ago
<el-dialog :title="dialogTitle"
:visible.sync="dialogFormVisible"
:close-on-click-modal="false"
top="5vh"
3 years ago
width="950px"
3 years ago
class="dialog-h"
append-to-body>
<work-form v-if="formType == 'work_diary'" ref="ref_form"
@dialogCancle="dialogFormVisible = false; formType=''" />
<h-form v-if="formType == 'concern'" ref="concern_form"
@dialogCancle="dialogFormVisible = false; formType=''" />
<d-form v-if="formType == 'difficulty'" ref="difficulty_form"
@dialogCancle="dialogFormVisible = false; formType=''" />
3 years ago
</el-dialog>
4 years ago
</main>
</template>
<script>
4 years ago
import { isURL } from "@/utils/validate";
import Cookie from "js-cookie";
3 years ago
import Tips from './tips.vue'
3 years ago
import { requestPost } from "@/js/dai/request";
3 years ago
import workForm from './modules/secretaryLog/workLog/form.vue'
import dForm from './modules/secretaryLog/difficulty/difficultyForm.vue'
import hForm from './modules/secretaryLog/humanisticCare/careForm.vue'
4 years ago
export default {
3 years ago
components: {
3 years ago
Tips,
workForm,
dForm,
hForm
3 years ago
},
4 years ago
data() {
4 years ago
return {
3 years ago
dialogTitle: '',
3 years ago
dialogFormVisible: false,
4 years ago
iframeUrl: "",
token: "",
customerId: "",
3 years ago
form: {},
formType: '',
3 years ago
formLabelWidth: '120px',
tipsList: []
4 years ago
};
4 years ago
},
4 years ago
created() {
4 years ago
// this.$nextTick(() => {
// this.sendMessage()
// })
this.token = localStorage.getItem("token");
4 years ago
this.customerId = localStorage.getItem("customerId");
3 years ago
3 years ago
this.loopTips()
4 years ago
},
3 years ago
destroyed() {
this.$store.dispatch('clearInter')
},
3 years ago
computed: {
msgList() {
return this.$store.state.tipsList
}
},
4 years ago
methods: {
4 years ago
changeCustomerName(customerName) {
this.$emit("changeCustomerName", customerName);
4 years ago
},
// tabs, 是否通过iframe展示
4 years ago
tabIsIframe(url) {
4 years ago
// this.appendIframe(url)
4 years ago
this.iframeUrl =
url +
"?token=" +
localStorage.getItem("token") +
4 years ago
"&customerId=" +
localStorage.getItem("customerId");
return isURL(url);
4 years ago
},
// tabs, 选中tab
4 years ago
tabSelectedHandle(tab) {
tab = this.$store.state.contentTabs.filter(
(item) => item.name === tab.name
)[0];
4 years ago
if (tab) {
this.$router.push({
4 years ago
name: tab.name,
params: { ...tab.params },
query: { ...tab.query },
});
4 years ago
}
},
// tabs, 删除tab
4 years ago
tabRemoveHandle(tabName) {
if (tabName === "home") {
return false;
4 years ago
}
4 years ago
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(
(item) => item.name !== tabName
);
4 years ago
if (this.$store.state.contentTabs.length <= 0) {
4 years ago
this.$store.state.sidebarMenuActiveName =
this.$store.state.contentTabsActiveName = "home";
return false;
4 years ago
}
// 当前选中tab被删除
if (tabName === this.$store.state.contentTabsActiveName) {
4 years ago
let tab =
this.$store.state.contentTabs[
this.$store.state.contentTabs.length - 1
];
4 years ago
this.$router.push({
name: tab.name,
params: { ...tab.params },
4 years ago
query: { ...tab.query },
});
4 years ago
}
},
// tabs, 关闭其它
4 years ago
tabsCloseOtherHandle() {
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(
(item) => {
return (
item.name === "home" ||
item.name === this.$store.state.contentTabsActiveName
);
}
);
4 years ago
},
// tabs, 关闭全部
4 years ago
tabsCloseAllHandle() {
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(
(item) => item.name === "home"
);
this.$router.push({ name: "home" });
4 years ago
},
4 years ago
sendMessage() {
4 years ago
// const iframe = this.$refs.iframes.contentWindow
4 years ago
const iframe =
document.getElementsByClassName("iframes")[0].contentWindow;
4 years ago
4 years ago
console.log("iframe", iframe);
4 years ago
// iframe.postMessage({
// token: localStorage.getItem('token'),
4 years ago
// customerId: localStorage.getItem('customerId')
// }, '*')
4 years ago
iframe.postMessage({ name: "lalalal" }, "*");
4 years ago
},
3 years ago
loopTips() {
3 years ago
this.$store.dispatch('setTipsList')
this.$store.dispatch('setTipsTime')
// let id = 1
// this.timer = setInterval(() => {
// id = id + 1
// if (id == 5) clearInterval(this.timer)
// this.tipsList.push(id)
// console.log('id------0', id)
// }, 1000)
},
async closeTips(memoId) {
const url = '/gov/project/memoAttr/setReaded'
const params = {
memoId
}
const { data, code, msg } = await requestPost(url, params)
if (code != 0) this.$message.error(msg)
},
async getInfo(item) {
const urls = {
work_diary: '/gov/project/memoWorkDiary',
concern: '/gov/project/memoConcern',
difficulty: '/gov/project/memoDifficulty/detail'
}
const params = {
id: item.memoId,
readFlag: 0
}
const { data, code, msg } = await requestPost(urls[item.type], params)
if (code == 0) {
this.form = { ...data }
} else this.$message.error(msg)
},
handleClose(item, index) {
console.log('close-----', item)
this.$store.state.tipsList.splice(index, 1)
this.closeTips(item.memoId)
3 years ago
},
3 years ago
async handleLook(item, index) {
3 years ago
console.log('look-----', item)
3 years ago
const formType = {
work_diary: 'ref_form',
concern: 'concern_form',
difficulty: 'difficulty_form'
}
this.dialogTitle = item.typeName
// await this.getInfo(item)
this.formType = item.type
3 years ago
this.dialogFormVisible = true
3 years ago
3 years ago
console.log('ref0-----', this.formType)
this.$nextTick(() => {
console.log('this.$refs-----', this.$refs)
this.$refs[formType[item.type]].initForm('look', item.memoId)
this.$store.state.tipsList.splice(index, 1)
this.closeTips(item.memoId)
})
3 years ago
}
4 years ago
},
};
4 years ago
</script>
3 years ago
<style lang="scss" scoped>
.aui-content {
position: relative;
// height: calc(100vh -50px) !important;
overflow: hidden;
}
</style>