Home.vue 46 KB

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