Home.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. <template>
  2. <el-row class="container">
  3. <el-col :span="24" class="header">
  4. <el-col :span="10" class="logo" :class="collapsed?'logo-collapse-width':'logo-width'" :style="collapsed?'padding:0':''">
  5. <img v-if="collapsed" class="headImg" src="../assets/image/head_logo.png" />
  6. <div v-else class="logo-sys">
  7. <img class="headImg" src="../assets/image/head_logo.png" />
  8. <span>{{$t('workingHoursHousekeeper')}}</span>
  9. </div>
  10. </el-col>
  11. <el-col :span="6">
  12. <div class="tools" @click.prevent="collapse" style="position: relative;">
  13. <i class="fa fa-align-justify"></i>
  14. <div class="gongshimingz">
  15. {{user.companyName}}
  16. </div>
  17. </div>
  18. </el-col>
  19. <el-col :span="12" class="userinfo" style="display: flex;align-items: center;justify-content: flex-end;">
  20. <!-- 中英文切换入口 -->
  21. <!-- <el-dropdown trigger="click" @command="langChange" style="margin-right:30px;">
  22. <span class="el-dropdown-link userinfo-inner">
  23. {{language}} <i class="el-icon-caret-bottom"></i>
  24. </span>
  25. <el-dropdown-menu slot="dropdown">
  26. <el-dropdown-item divided command="zh">中文</el-dropdown-item>
  27. <el-dropdown-item divided command="en">English</el-dropdown-item>
  28. </el-dropdown-menu>
  29. </el-dropdown> -->
  30. <el-dropdown trigger="hover" style="margin-right:30px;">
  31. <span class="el-dropdown-link userinfo-inner">
  32. <i class="el-icon-user" style="font-size:18px" ></i>
  33. <!-- {{$t('other.customerService')}} -->
  34. 帮助中心
  35. </span>
  36. <el-dropdown-menu slot="dropdown">
  37. <el-dropdown-item >
  38. <div v-if="!isCorpWX">
  39. <!-- <div>{{$t('other.sweepWeChatYards')}}</div> -->
  40. <!-- <div>扫码添加企业微信客服</div> -->
  41. <div>{{ $t('ke-fu-wei-xin') }}</div>
  42. <img
  43. style="width: 120px; height: 120px"
  44. src="../assets/image/code.jpg" />
  45. </div>
  46. <div v-if="isCorpWX">
  47. <div>扫码添加企业微信客服</div>
  48. <img
  49. style="width: 153px; height: 153px"
  50. src="../assets/image/qwcode.png" />
  51. </div>
  52. <div>
  53. <div>
  54. <el-link type="primary" :underline="false" href="https://www.ttkuaiban.com/download/%E5%B7%A5%E6%97%B6%E7%AE%A1%E5%AE%B6%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E%E4%B9%A6.pdf">点击查看操作手册</el-link>
  55. </div>
  56. </div>
  57. </el-dropdown-item>
  58. </el-dropdown-menu>
  59. </el-dropdown>
  60. {{$t('time.dueDate')}}:{{remainingTime}}
  61. <el-badge class="itemNew" :value="num" :hidden="num == 0">
  62. <i class="el-icon-message-solid" style="font-size:24px" v-popover:popover1 @click="drawer = true"></i>
  63. </el-badge>
  64. <el-drawer :title="$t('other.messageCenter')" :visible.sync="drawer" direction="rtl" :with-header="false" size="35%">
  65. <el-table :data="popoverData" :height="tableHeight" size="small">
  66. <el-table-column property="type" :label="$t('other.messageContent')" align="left">
  67. <template slot-scope="scope">
  68. <el-link type="primary" :underline="false" @click="locationHerf(scope.row.id,scope.row.content, scope.row.type)">
  69. <span style="font-size:13px;">
  70. <span v-if="scope.row.msg == null">
  71. {{msgTypeTxt[scope.row.type]}}
  72. </span>
  73. <span v-else>
  74. <span v-if="user.userNameNeedTranslate != 1">
  75. {{scope.row.msg}}
  76. </span>
  77. <span v-if="user.userNameNeedTranslate == 1">
  78. {{scope.row.omg.textOne}}
  79. <ww-open-data type='userName' :openid='scope.row.omg.textTwo'></ww-open-data>
  80. {{scope.row.omg.textThree}}
  81. </span>
  82. </span>
  83. <!-- {{scope.row.msg==null?msgTypeTxt[scope.row.type]:scope.row.msg}} -->
  84. </span>
  85. </el-link>
  86. </template>
  87. </el-table-column>
  88. <el-table-column property="type" :label="$t('state.states')" align="center" width="60">
  89. <template slot-scope="scope">
  90. <span v-if="scope.row.checked == 0" style="color:red">{{$t('other.unread')}}</span>
  91. <span v-else style="color:green">{{$t('other.read')}}</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column property="time" :label="$t('time.times')" align="center" width="120"></el-table-column>
  95. </el-table>
  96. </el-drawer>
  97. <el-dropdown trigger="hover" style="margin-left:10px;">
  98. <span class="el-dropdown-link userinfo-inner">
  99. <img src="../assets/image/userHead.png" />
  100. <span v-if="user.userNameNeedTranslate == 1">
  101. <ww-open-data type='userName' :openid='sysUserName'></ww-open-data>
  102. </span>
  103. <span v-if="user.userNameNeedTranslate != 1">
  104. {{sysUserName}}
  105. </span>
  106. <!-- {{sysUserName}} -->
  107. </span>
  108. <el-dropdown-menu slot="dropdown">
  109. <!-- <el-dropdown-item disabled ><span style="font-size:12px;"><i class="el-icon-view" ></i>{{roleArray[user.role]}}</span></el-dropdown-item> -->
  110. <el-dropdown-item disabled ><span style="font-size:12px;"><i class="el-icon-view" ></i>{{user.roleName}}</span></el-dropdown-item>
  111. <el-dropdown-item disabled ><span style="font-size:12px;"><i class="el-icon-medal" v-if="user.jobNumber"></i>{{user.jobNumber}}</span></el-dropdown-item>
  112. <el-dropdown-item @click.native="reset" v-if="!isCorpWX">{{$t('other.changeThePassword')}}</el-dropdown-item>
  113. <!-- <el-dropdown-item @click.native="editInfoOpen">修改信息</el-dropdown-item> -->
  114. <el-dropdown-item divided @click.native="logout" v-if="!isCorpWX" >{{$t('other.launchTheLogin')}}</el-dropdown-item>
  115. </el-dropdown-menu>
  116. </el-dropdown>
  117. </el-col>
  118. </el-col>
  119. <el-col :span="24" class="main">
  120. <aside :class="collapsed?'menu-collapsed':'menu-expanded'">
  121. <el-scrollbar style="height:100%">
  122. <!--导航菜单-->
  123. <el-menu :default-active="$route.path" class="el-menu-vertical-demo" unique-opened router v-if="!collapsed">
  124. <template v-for="(item, index) in $router.options.routes" v-if="!item.hidden">
  125. <el-submenu :index="index+''" v-if="!item.leaf">
  126. <template slot="title">
  127. <i :class="item.iconCls"></i>
  128. <!-- <span class="itemName">{{item.name}}</span> -->
  129. <span class="itemName bosx" v-if="$t(item.meta.text).length < 16">{{$t(item.meta.text)}}</span>
  130. <el-tooltip class="itemName bosx" v-if="$t(item.meta.text).length > 16" effect="dark" :content="$t(item.meta.text)" placement="top">
  131. <span>{{$t(item.meta.text)}}</span>
  132. </el-tooltip>
  133. </template>
  134. <el-menu-item v-for="child in item.children" :index="child.path" :key="child.path" v-if="!child.hidden"><i :class="child.iconCls"></i>
  135. <!-- {{child.name}} -->
  136. <span class="bosx" v-if="$t(child.meta.text).length < 16">{{$t(child.meta.text)}}</span>
  137. <el-tooltip class="bosx" v-if="$t(child.meta.text).length > 16" effect="dark" :content="$t(child.meta.text)" placement="top">
  138. <span>{{$t(child.meta.text)}}</span>
  139. </el-tooltip>
  140. </el-menu-item>
  141. </el-submenu>
  142. <el-menu-item v-if="item.leaf && item.children.length > 0" :index="item.children[0].path">
  143. <i :class="item.iconCls"></i>
  144. <!-- {{item.children[0].name}} -->
  145. <span class="bosx" v-if="$t(item.meta.text).length < 16">{{$t(item.meta.text)}}</span>
  146. <el-tooltip class="itemName bosx" v-if="$t(item.meta.text).length > 16" effect="dark" :content="$t(item.meta.text)" placement="top">
  147. <span>{{$t(item.meta.text)}}</span>
  148. </el-tooltip>
  149. <!-- {{$t('navigation.reports')}} -->
  150. <!-- this.$t('navigation.reports')  // js-->
  151. </el-menu-item>
  152. </template>
  153. </el-menu>
  154. <!--导航菜单-折叠后-->
  155. <ul class="el-menu el-menu-vertical-demo collapsed" v-if="collapsed" ref="menuCollapsed">
  156. <li v-for="(item,index) in $router.options.routes" v-if="!item.hidden" class="el-submenu item" :style="{overflow:!item.leaf?'':'hidden'}">
  157. <template v-if="!item.leaf">
  158. <div class="el-submenu__title" style="padding-left: 20px;" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)">
  159. <i :class="item.iconCls"></i>
  160. </div>
  161. <ul class="el-menu submenu" :class="'submenu-hook-'+index" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)">
  162. <li v-for="child in item.children" v-if="!child.hidden" :key="child.path" class="el-menu-item" style="padding-left: 40px;" :class="$route.path==child.path?'is-active':''" @click="$router.push(child.path)">
  163. {{child.name}}
  164. </li>
  165. </ul>
  166. </template>
  167. <template v-else>
  168. <li class="el-submenu">
  169. <div class="el-submenu__title el-menu-item" :class="$route.path==item.children[0].path?'is-active':''" @click="$router.push(item.children[0].path)"
  170. style="padding-left: 20px;height: 56px;line-height: 56px;padding: 0 20px;">
  171. <i :class="item.iconCls"></i>
  172. </div>
  173. </li>
  174. </template>
  175. </li>
  176. </ul>
  177. </el-scrollbar>
  178. </aside>
  179. <section class="content-container">
  180. <div class="grid-content bg-purple-light">
  181. <el-col :span="24" class="content-wrapper">
  182. <transition name="fade" mode="out-in">
  183. <router-view></router-view>
  184. </transition>
  185. </el-col>
  186. </div>
  187. <!--修改密码-->
  188. <el-dialog :title="$t('other.changeThePassword')" width='450px' v-if="editPassWord" :visible.sync="editPassWord" :close-on-click-modal="false" customClass="customWidth">
  189. <el-form :model="addForm" label-width="auto" :rules="passRule" ref="addForm">
  190. <el-form-item :label="$t('lable.originalPassword')" prop="originPassword">
  191. <el-input v-model="addForm.originPassword" autocomplete="off" :placeholder="$t('defaultText.pleaseEnterTheOldPassword')" show-password></el-input>
  192. </el-form-item>
  193. <el-form-item :label="$t('lable.newPassword')" prop="newPassword">
  194. <el-input v-model="addForm.newPassword" autocomplete="off" :placeholder="$t('defaultText.pleaseEnterTheNewPassword')" show-password></el-input>
  195. </el-form-item>
  196. </el-form>
  197. <div slot="footer" class="dialog-footer">
  198. <el-button @click.native="editPassWord = false">{{$t('btn.cancel')}}</el-button>
  199. <el-button type="primary" @click.native="resetPwd" :loading="editLoading">{{$t('btn.submit')}}</el-button>
  200. </div>
  201. </el-dialog>
  202. <!--修改信息-->
  203. <el-dialog :title="$t('title.modifyTheInformation')" width='450px' v-if="editInformation" :visible.sync="editInformation" :close-on-click-modal="false" customClass="customWidth">
  204. <el-form :model="editInfoForm" label-width="auto" :rules="passRule" ref="editInfoForm">
  205. <el-form-item :label="$t('lable.name')" prop="username">
  206. <el-input v-model="editInfoForm.username" autocomplete="off" :placeholder="$t('defaultText.PleaseEnterYourName')"></el-input>
  207. </el-form-item>
  208. </el-form>
  209. <el-form :model="editInfoForm" label-width="auto" :rules="passRule" ref="editInfoForm">
  210. <el-form-item :label="$t('lable.phone')" prop="mobile">
  211. <el-input v-model="editInfoForm.mobile" autocomplete="off" :placeholder="$t('defaultText.PleaseEnterYourPhone')" :disabled="true"></el-input>
  212. </el-form-item>
  213. </el-form>
  214. <div slot="footer" class="dialog-footer">
  215. <el-button @click.native="editInformation = false">{{$t('btn.cancel')}}</el-button>
  216. <el-button type="primary" @click.native="editInfo" :loading="editLoading2">{{$t('btn.submit')}}</el-button>
  217. </div>
  218. </el-dialog>
  219. </section>
  220. </el-col>
  221. </el-row>
  222. </template>
  223. <script>
  224. import util from "../common/js/util";
  225. export default {
  226. // 引用 app.vue reloads 方法
  227. inject:['reloads'],
  228. data() {
  229. return {
  230. isCorpWX: false,
  231. // roleArray:["普通员工","超级管理员", "系统管理员", "公司高层","财务管理员", "项目管理员","公司领导"],
  232. roleArray:[this.$t('role.ordinaryEmployees'),this.$t('role.superAdministrator'),this.$t('role.systemAdministrator'),this.$t('role.companyTop'),this.$t('role.financialAdministrator'),this.$t('role.projectManager'),this.$t('role.companyLeadership')],
  233. helpImg: '../assets/image/userHead.png',
  234. user: sessionStorage.getItem("user"),
  235. collapsed: sessionStorage.collapsed!=null?(sessionStorage.collapsed=='true'?true:false):false,
  236. sysUserName: "",
  237. menu: [],
  238. // msgTypeTxt:["审批未通过","有新任务啦","任务有新进展","项目日报审核通过"],
  239. msgTypeTxt:[this.$t('state.notApproved'),this.$t('state.ThereIsAnewTask'),this.$t('state.TheresBeen'),this.$t('state.approvedProject')],
  240. editInformation: false,
  241. editPassWord: false,
  242. editLoading: false,
  243. editLoading2: false,
  244. addForm: {
  245. id: "",
  246. originPassword: "",
  247. newPassword: ""
  248. },
  249. editInfoForm: {
  250. id: "",
  251. username: "",
  252. mobile: "",
  253. companyName: ""
  254. },
  255. passRule: {
  256. originPassword: [{ required: true, message: this.$t('defaultText.pleaseEnterTheOldPassword'), trigger: "blur" }],
  257. newPassword: [{ required: true, message: this.$t('defaultText.pleaseEnterTheNewPassword'), trigger: "blur" }],
  258. username: [{ required: true, message: this.$t('defaultText.PleaseEnterYourName'), trigger: "blur" }]
  259. },
  260. //时间
  261. activeDate: new Date(),
  262. timer: null,
  263. remainingTime: '',
  264. drawer: false,
  265. tableHeight: 0,
  266. popoverData: [],
  267. num: 0,
  268. language: '',
  269. setTimeLoad: null
  270. };
  271. },
  272. methods: {
  273. // 中英文切换
  274. langChange(command) {
  275. let flg = this.language
  276. this.$i18n.locale = command
  277. localStorage.setItem("lang", command)
  278. if(command == 'en') {
  279. this.language = 'English'
  280. } else if (command == 'zh') {
  281. this.language = '中文'
  282. }
  283. if(flg != this.language) {
  284. this.reloads()
  285. }
  286. },
  287. //退出登录
  288. logout: function() {
  289. var _this = this;
  290. this.$confirm(this.$t('other.confirmExit') + '?', this.$t('other.prompts'), {
  291. //type: 'warning'
  292. confirmButtonText: this.$t('btn.submit'),
  293. cancelButtonText: this.$t('btn.cancel'),
  294. }).then(() => {
  295. sessionStorage.removeItem("user");
  296. location.reload();
  297. _this.$router.push("/login");
  298. });
  299. },
  300. //折叠导航栏
  301. collapse: function() {
  302. this.collapsed = !this.collapsed;
  303. sessionStorage.collapsed = this.collapsed;
  304. },
  305. showMenu(i, status) {
  306. this.$refs.menuCollapsed.getElementsByClassName(
  307. "submenu-hook-" + i
  308. )[0].style.display = status ? "block" : "none";
  309. },
  310. //打开编辑信息界面
  311. editInfoOpen() {
  312. this.editInformation = true;
  313. this.editInfoForm.id = JSON.parse(sessionStorage.getItem("user")).id;
  314. this.editInfoForm.username = JSON.parse(
  315. sessionStorage.getItem("user")
  316. ).username;
  317. this.editInfoForm.mobile = JSON.parse(
  318. sessionStorage.getItem("user")
  319. ).account;
  320. this.editInfoForm.companyName = JSON.parse(
  321. sessionStorage.getItem("user")
  322. ).companyName;
  323. },
  324. //编辑信息
  325. editInfo() {
  326. this.$refs.editInfoForm.validate(valid => {
  327. if (valid) {
  328. this.editLoading2 = true;
  329. this.http.post(
  330. this.port.pwd.resetPwd,
  331. { id: this.editInfoForm.id, username: this.editInfoForm.username },
  332. res => {
  333. this.editLoading2 = false;
  334. this.editInformation = false;
  335. if (res.code == "ok") {
  336. this.$message({
  337. message: this.$t('message.modifyTheSuccess'),
  338. type: "success"
  339. });
  340. //读取并覆盖session storage
  341. var userObject = JSON.parse(sessionStorage.getItem("user"));
  342. userObject.username = this.editInfoForm.username;
  343. sessionStorage.setItem("user", JSON.stringify(userObject));
  344. this.sysUserName = this.editInfoForm.username;
  345. } else {
  346. this.$message({
  347. message: res.msg,
  348. type: "error"
  349. });
  350. }
  351. },
  352. error => {
  353. this.editLoading2 = false;
  354. this.editInformation = false;
  355. this.$message({
  356. message: error,
  357. type: "error"
  358. });
  359. }
  360. );
  361. }
  362. });
  363. },
  364. reset() {
  365. this.editPassWord = true;
  366. this.addForm.id = JSON.parse(sessionStorage.getItem("user")).id;
  367. this.addForm.account = JSON.parse(sessionStorage.getItem("user")).account;
  368. },
  369. resetPwd() {
  370. this.$refs.addForm.validate(valid => {
  371. if (valid) {
  372. this.editLoading = true;
  373. this.http.post( this.port.manage.editPassword, this.addForm,
  374. res => {
  375. this.editLoading = false;
  376. this.editPassWord = false;
  377. if (res.code == "ok") {
  378. this.$message({
  379. // message: "修改成功,请重新登录",
  380. message: this.$t('message.logAganin'),
  381. type: "success"
  382. });
  383. this.$router.push("/login");
  384. } else {
  385. this.$message({
  386. message: res.msg,
  387. type: "error"
  388. });
  389. }
  390. },
  391. error => {
  392. this.editLoading = false;
  393. this.editPassWord = false;
  394. this.$message({
  395. message: error,
  396. type: "error"
  397. });
  398. });
  399. }
  400. });
  401. },
  402. setTime() {
  403. var d = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'd');
  404. var h = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'h');
  405. var m = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'm');
  406. var s = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 's');
  407. this.remainingTime = d+'天'+h+'时'+m+'分'+s+'秒';
  408. },
  409. // 加载消息
  410. loadNotice() {
  411. this.http.post( this.port.manage.msgList, {},
  412. res => {
  413. if (res.code == "ok") {
  414. var list = res.data;
  415. if(this.user.userNameNeedTranslate == 1) {
  416. let msgArr = res.data
  417. for(var i in msgArr) {
  418. if(msgArr[i].msg) {
  419. let caozuo = JSON.parse(JSON.stringify(msgArr[i].msg))
  420. if(caozuo.indexOf('$userName=') != '-1') {
  421. let textOne = caozuo.split('$userName=')[0]
  422. let textTwo = caozuo.split('$userName=')[1].split('$')[0]
  423. let textThree = caozuo.split('$userName=')[1].split('$')[1]
  424. msgArr[i].omg = {
  425. textOne: textOne,
  426. textTwo: textTwo,
  427. textThree: textThree
  428. }
  429. } else {
  430. msgArr[i].omg = {
  431. textOne: msgArr[i].msg,
  432. textTwo: '',
  433. textThree: ''
  434. }
  435. }
  436. } else {
  437. msgArr[i].omg = {
  438. textOne: '',
  439. textTwo: '',
  440. textThree: ''
  441. }
  442. }
  443. }
  444. }
  445. this.popoverData = res.data;
  446. var num = 0;
  447. for(var i in list) {
  448. if(list[i].checked != 1) {
  449. num ++;
  450. }
  451. }
  452. this.num = num;
  453. } else {
  454. this.$message({
  455. message: res.msg,
  456. type: "error"
  457. });
  458. }
  459. },
  460. error => {
  461. this.$message({
  462. message: error,
  463. type: "error"
  464. });
  465. });
  466. },
  467. //点击消息的跳转
  468. locationHerf(id, date, type) {
  469. this.http.post( this.port.manage.check, { id: id },
  470. res => {
  471. if (res.code == "ok") {
  472. this.loadNotice();
  473. if (type == 0 || type == 3) {
  474. //审批未通过的消息, 也包括审批通过的通知
  475. sessionStorage.msg = date;
  476. sessionStorage.from = 1;
  477. //本页面再点的话强制转移一下
  478. var currentRoute = this.$route.path.split("/");
  479. if (currentRoute[1] == "daily") {
  480. this.$router.go(0);
  481. this.drawer = false;
  482. return false;
  483. }
  484. this.$router.push("/daily");
  485. this.drawer = false;
  486. } else if (type == 1) {
  487. //1- 有新任务待执行
  488. this.$router.push("/projectInside/"+date);
  489. this.drawer = false;
  490. } else if (type == 2) {
  491. //2- 任务有新进展
  492. this.$router.push("/projectInside/"+date);
  493. this.drawer = false;
  494. } else if (type == 3) {
  495. //3- 费用报销
  496. this.$router.push("/expense");
  497. this.drawer = false;
  498. } else if (type == 4) {
  499. //4- 请假消息
  500. this.$router.push("/leave");
  501. this.drawer = false;
  502. } else if (type == 5) {
  503. //5- 出差消息
  504. this.$router.push("/awayOffice");
  505. this.drawer = false;
  506. }
  507. } else {
  508. this.$message({
  509. message: res.msg,
  510. type: "error"
  511. });
  512. }
  513. },
  514. error => {
  515. this.$message({
  516. message: error,
  517. type: "error"
  518. });
  519. });
  520. },
  521. // 获取企业微信的参数
  522. agentConfig() {
  523. var curUrl = location.href.split("#")[0];
  524. this.http.post("/wxcorp/getCorpWXConfig", {url: curUrl, token: this.user.id}, (res) => {
  525. if (res.code == "ok") {
  526. wx.config({
  527. beta: true,
  528. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  529. appId: res.data.appid, // 必填,公众号的唯一标识
  530. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  531. nonceStr: res.data.noncestr, // 必填,生成签名的随机串
  532. signature: res.data.sign, // 必填,签名,见附录1
  533. jsApiList: ['chooseImage','previewImage','uploadImage','downloadImage','previewFile','getLocation','agentConfig']
  534. });
  535. var that = this;
  536. wx.ready(function(){
  537. // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
  538. that.http.post("/wxcorp/getCorpWXAgentConfig", {url: curUrl, token: that.user.id}, (res) => {
  539. if (res.code == "ok") {
  540. console.log()
  541. wx.agentConfig({
  542. corpid: res.data.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
  543. agentid: res.data.agentid, // 必填,企业微信的应用id (e.g. 1000247)
  544. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  545. nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
  546. signature: res.data.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
  547. jsApiList: ['selectExternalContact', 'selectEnterpriseContact'], //必填,传入需要使用的接口名称
  548. success: function (result) {
  549. console.log(result, '请求微信成功')
  550. console.log(window, 'window')
  551. // wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
  552. if(window.WWOpenData) {
  553. window.WWOpenData.bind(document.querySelector('ww-open-data'))
  554. if (WWOpenData.initCanvas) {
  555. WWOpenData.initCanvas()
  556. console.log('我企业微信 canvas 应该执行了吧')
  557. }
  558. }
  559. },
  560. fail: function (res) {
  561. console.log('查看错误信息', res)
  562. if (res.errMsg.indexOf('function not exist') > -1) {
  563. alert('版本过低请升级')
  564. }
  565. },
  566. })
  567. }
  568. }, (error) => {
  569. console.log('查看错误信息' + res)
  570. if (error.errMsg.indexOf('function not exist') > -1) {
  571. alert('版本过低请升级')
  572. }
  573. })
  574. });
  575. }
  576. }, (error) => {
  577. console.log(error, '哦耶')
  578. })
  579. },
  580. },
  581. mounted() {
  582. // console.log(this.$router.options.routes, '看看')
  583. console.log(this.$router.options.routes, '路由')
  584. var ua = navigator.userAgent.toLowerCase();
  585. if (ua.indexOf("wxwork") > 0) {
  586. this.isCorpWX = true;
  587. }
  588. let langse = localStorage.getItem("lang") || 'zh'
  589. if(langse == 'en') {
  590. this.language = 'English'
  591. } else if (langse == 'zh') {
  592. this.language = '中文'
  593. }
  594. let height = window.innerHeight;
  595. this.tableHeight = height - 15;
  596. const that = this;
  597. window.onresize = function temp() {
  598. that.tableHeight = window.innerHeight - 15;
  599. };
  600. if (this.user) {
  601. var user = JSON.parse(this.user);
  602. this.user = user;
  603. this.sysUserName = user.name || "";
  604. this.loadNotice();
  605. if(this.user.remainingTime != "" && this.user.remainingTime != 0) {
  606. this.remainingTime = util.formatDate.format(new Date(new Date().getTime() + this.user.remainingTime), "yyyy-MM-dd")
  607. } else {
  608. this.remainingTime = this.$t('other.expired');
  609. clearInterval(this.timer);
  610. }
  611. } else {
  612. this.$router.push("/login");
  613. }
  614. // console.log('啊,我被触发了呀')
  615. // 获取企业微信参数
  616. if(this.user.userNameNeedTranslate == '1') {
  617. this.agentConfig()
  618. }
  619. },
  620. };
  621. </script>
  622. <style scoped lang="scss">
  623. .gongshimingz {
  624. width: 100%;
  625. position: absolute;
  626. left: 0px;
  627. display: inline-block;
  628. overflow: hidden;
  629. white-space: nowrap;
  630. text-overflow: ellipsis;
  631. box-sizing: border-box;
  632. padding-left: 60px;
  633. }
  634. .el-menu-vertical-demo i {
  635. margin-right: 10px;
  636. }
  637. .container {
  638. position: absolute;
  639. top: 0px;
  640. bottom: 0px;
  641. width: 100%;
  642. .header {
  643. height: 60px;
  644. line-height: 60px;
  645. background: #20a0ff;
  646. color: #fff;
  647. .userinfo {
  648. text-align: right;
  649. padding-right: 35px;
  650. float: right;
  651. .userinfo-inner {
  652. cursor: pointer;
  653. color: #fff;
  654. img {
  655. width: 40px;
  656. height: 40px;
  657. border-radius: 20px;
  658. margin: 10px 10px 10px 10px;
  659. float: left;
  660. }
  661. }
  662. .itemNew {
  663. height: 25px;
  664. margin: 0 0 0 10px;
  665. i {
  666. vertical-align: top;
  667. }
  668. }
  669. }
  670. .logo {
  671. height: 60px;
  672. font-size: 21px;
  673. padding-left: 20px;
  674. padding-right: 20px;
  675. border-color: rgba(238, 241, 146, 0.3);
  676. border-right-width: 1px;
  677. border-right-style: solid;
  678. img {
  679. width: 40px;
  680. float: left;
  681. margin: 10px 10px 10px 18px;
  682. }
  683. img.headImg {
  684. margin: 0;
  685. width: 40px;
  686. height: 40px;
  687. margin: 10px 0 0 10px;
  688. }
  689. .logo-sys {
  690. height: 100%;
  691. line-height: 100%;
  692. img.headImg {
  693. width: 40px;
  694. height: 40px;
  695. margin: 7.5px 0 0 10px;
  696. vertical-align: middle;
  697. }
  698. span {
  699. display: inline-block;
  700. height: 100%;
  701. line-height: 60px;
  702. margin-left: 15px;
  703. font-size: 18px;
  704. // margin: 20px 0 0 15px;
  705. vertical-align: middle;
  706. }
  707. }
  708. .txt {
  709. color: #fff;
  710. }
  711. }
  712. .logo-width {
  713. width: 200px;
  714. }
  715. .logo-collapse-width {
  716. width: 60px;
  717. }
  718. .tools {
  719. padding: 0px 23px;
  720. // width: 14px;
  721. height: 60px;
  722. line-height: 60px;
  723. cursor: pointer;
  724. }
  725. }
  726. .main {
  727. display: flex;
  728. position: absolute;
  729. top: 60px;
  730. bottom: 0px;
  731. overflow: hidden;
  732. aside {
  733. flex: 0 0 230px;
  734. width: 230px;
  735. .el-menu {
  736. height: 100%;
  737. }
  738. .collapsed {
  739. width: 60px;
  740. .item {
  741. position: relative;
  742. }
  743. .submenu {
  744. position: absolute;
  745. top: 0px;
  746. left: 60px;
  747. z-index: 99999;
  748. height: auto;
  749. display: none;
  750. box-shadow: 5px 5px 10px #ddd;
  751. }
  752. }
  753. }
  754. .menu-collapsed {
  755. flex: 0 0 60px;
  756. width: 60px;
  757. }
  758. .menu-expanded {
  759. flex: 0 0 200px;
  760. width: 200px;
  761. }
  762. .content-container {
  763. flex: 1;
  764. width: 80%;
  765. overflow-y: auto;
  766. overflow-x: hidden;
  767. .breadcrumb-container {
  768. .title {
  769. width: 200px;
  770. float: left;
  771. color: #475669;
  772. }
  773. .breadcrumb-inner {
  774. float: right;
  775. }
  776. }
  777. .content-wrapper {
  778. background-color: #fff;
  779. box-sizing: border-box;
  780. }
  781. }
  782. }
  783. }
  784. .popover-item {
  785. padding: 10px;
  786. border-bottom: 1px #eee solid;
  787. }
  788. .popover-item > div > p {
  789. margin: 0;
  790. line-height: 18px;
  791. }
  792. .popover-title {
  793. color: #409eff;
  794. padding-bottom: 8px;
  795. }
  796. .popover-type {
  797. color: #aaa;
  798. font-size: 8px;
  799. float: right;
  800. }
  801. .popover-button {
  802. font-weight: 900;
  803. padding: 10px;
  804. text-align: center;
  805. cursor: pointer;
  806. }
  807. .isRead {
  808. color: #999 !important;
  809. }
  810. .bosx {
  811. width: 110px;
  812. display: inline-block;
  813. overflow: hidden;
  814. white-space: nowrap;
  815. text-overflow: ellipsis;
  816. }
  817. </style>