Home.vue 40 KB

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