Home.vue 38 KB

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