cost.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. <template>
  2. <section>
  3. <el-col :span="24" style="padding-bottom: 0px;text-align:center;margin-top:10px;position: fixed;top: 60px;left: 160px;z-index: 999;">
  4. <el-date-picker v-show="user.timeType.fixMonthcost==0"
  5. v-model="dateRange" :editable="false"
  6. format="yyyy-MM-dd" value-format="yyyy-MM-dd"
  7. @change="getEchart"
  8. :clearable="true"
  9. range-separator="至"
  10. type="daterange"
  11. start-placeholder="开始日期"
  12. end-placeholder="结束日期"
  13. ></el-date-picker>
  14. <el-date-picker v-show="user.timeType.fixMonthcost==1"
  15. v-model="dateRange" :editable="false"
  16. format="yyyy-MM" value-format="yyyy-MM"
  17. @change="getEchart"
  18. :clearable="false"
  19. type="month"
  20. ></el-date-picker>
  21. <el-radio-group v-model="radio" @change="getEchart" style="margin-left:10px;">
  22. <el-radio-button label="项目"></el-radio-button>
  23. <el-radio-button label="部门"></el-radio-button>
  24. <el-radio-button label="人员"></el-radio-button>
  25. <el-radio-button :label="namess" v-if="jichu.customDegreeActive == 1"></el-radio-button>
  26. </el-radio-group>
  27. </el-col>
  28. <!-- <div :style="'width:'+widthHtval+'rem;position: relative;'"> -->
  29. <div :style="'width:'+widthHtval+'px;position: relative; height:'+containerHeight+'px;'">
  30. <div id="container" :style="'height:'+containerHeight+'px;width:100%'"></div>
  31. </div>
  32. <div style="position:fixed;top:120px;right:150px;"><el-button @click="showExportDialog">报表导出</el-button></div>
  33. <!--导出报表条件选择 -->
  34. <el-dialog title="工时报表导出" v-if="exportDialog" :visible.sync="exportDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
  35. <el-form ref="form3" :model="exportParam" >
  36. <el-form-item prop="projectId" label="选择项目" v-if="radio != '人员'">
  37. <el-select v-model="exportParam.projectId" placeholder="全部项目" clearable style="width:350px;" filterable="true">
  38. <el-option v-for="item in projectList" :key="item.id" :label="item.projectName" :value="item.id"></el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item prop="userIds" label="选择人员" v-if="radio == '人员'">
  42. <el-select v-model="exportParam.userIds" placeholder="全部人员" multiple="true" clearable style="width:350px;" filterable="true">
  43. <el-option v-for="item in hasReportUserList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item prop="projectId" :label="user.timeType.fixMonthcost==0?'日期范围':'选择月份'">
  47. <el-date-picker v-show="user.timeType.fixMonthcost==0"
  48. v-model="exportParam.dateRange" :editable="false"
  49. format="yyyy-MM-dd" value-format="yyyy-MM-dd"
  50. :clearable="false"
  51. range-separator="至"
  52. type="daterange"
  53. start-placeholder="开始日期"
  54. end-placeholder="结束日期"
  55. ></el-date-picker>
  56. <el-date-picker v-show="user.timeType.fixMonthcost==1"
  57. v-model="dateRange" :editable="false"
  58. format="yyyy-MM" value-format="yyyy-MM"
  59. @change="getEchart"
  60. :clearable="true"
  61. type="month"
  62. ></el-date-picker>
  63. </el-form-item>
  64. <el-form-item label="选择人员" v-if="radio == '项目' || radio == '部门'">
  65. <el-select v-model="exportParam.userId" placeholder="请选择人员" style="width: 350px" filterable="true">
  66. <span v-for="(item, index) in users" :key="index">
  67. <el-option :label="item.name" :value="item.id"></el-option>
  68. </span>
  69. </el-select>
  70. </el-form-item>
  71. </el-form>
  72. <div slot="footer" class="dialog-footer">
  73. <el-button type="primary" @click="exportProjectData" style="width:100%;" >导出</el-button>
  74. </div>
  75. </el-dialog>
  76. </section>
  77. </template>
  78. <script>
  79. import util from "../../common/js/util";
  80. export default {
  81. data() {
  82. return {
  83. hasReportUserList:[],
  84. projectList:[],
  85. exportParam:{projectId:null,dateRange:[],userId: null},
  86. exportDialog:false,
  87. dateRange:[],
  88. user: JSON.parse(sessionStorage.getItem("user")),
  89. radio: sessionStorage.radio!=null?sessionStorage.radio:'项目',
  90. containerHeight: 0,
  91. myChart: null,
  92. params: null,
  93. widthHtval: document.body.clientWidth - 230,
  94. users: [],
  95. jichu: [],
  96. namess: '',
  97. timers: null, // 点击的时间
  98. zhishin: 0
  99. };
  100. },
  101. methods: {
  102. jutishez() {
  103. this.http.post('/time-type/getCompanyTimeSetting', {
  104. companyId: this.user.companyId,
  105. },
  106. res => {
  107. if (res.code == "ok") {
  108. this.jichu = res.data
  109. if(res.data.customDegreeActive == 1) {
  110. this.namess = res.data.customDegreeName
  111. }
  112. } else {
  113. this.$message({
  114. message: res.msg,
  115. type: "error"
  116. });
  117. }
  118. },
  119. error => {
  120. this.$message({
  121. message: error,
  122. type: "error"
  123. });
  124. });
  125. },
  126. getUsers() {
  127. console.log(this.port.manage.list)
  128. this.http.post(this.port.manage.list, {
  129. departmentId: -1,
  130. pageIndex: 1,
  131. pageSize: 99999
  132. },
  133. res => {
  134. if (res.code == "ok") {
  135. this.users = res.data.records;
  136. } else {
  137. this.$message({
  138. message: res.msg,
  139. type: "error"
  140. });
  141. }
  142. },
  143. error => {
  144. this.$message({
  145. message: error,
  146. type: "error"
  147. });
  148. });
  149. },
  150. showExportDialog() {
  151. this.exportDialog = true;
  152. this.exportParam.dateRange = this.dateRange;
  153. if (this.radio == '人员') {
  154. // this.exportParam.userIds = [];
  155. }
  156. },
  157. //获取我的项目列表
  158. getMyProjectList() {
  159. this.http.post('/project/getProjectList', {
  160. },
  161. res => {
  162. if (res.code == "ok") {
  163. this.projectList = res.data;
  164. } else {
  165. this.$message({
  166. message: res.msg,
  167. type: "error"
  168. });
  169. }
  170. },
  171. error => {
  172. this.$message({
  173. message: error,
  174. type: "error"
  175. });
  176. });
  177. },
  178. exportProjectData() {
  179. var param = {};
  180. if (this.exportParam.dateRange != null) {
  181. param = {startDate:this.exportParam.dateRange[0], endDate: this.exportParam.dateRange[1]};
  182. }
  183. var url = "/project/exportTimeCost";
  184. var fileName = '项目工时成本统计.xls';
  185. if (this.radio == '人员' ) {
  186. console.log(this.exportParam.userIds);
  187. fileName = '人员工时成本统计.xls';
  188. url = '/department/exportUserStatistic';
  189. if (this.exportParam.userIds != null && this.exportParam.userIds.length > 0) {
  190. var ids = '';
  191. this.exportParam.userIds.forEach(u=>{
  192. ids += u+',';
  193. })
  194. param.userIds = ids;
  195. }
  196. }
  197. if (this.exportParam.projectId != null) {
  198. param.projectId = this.exportParam.projectId;
  199. }
  200. if (this.exportParam.userId != null) {
  201. if(this.radio == '项目' || this.radio == '部门' || this.radio == '人员'){
  202. param.userId = this.exportParam.userId;
  203. }
  204. }
  205. this.http.post(url, param,
  206. res => {
  207. this.listLoading = false;
  208. if (res.code == "ok") {
  209. this.exportDialog = false;
  210. var aTag = document.createElement('a');
  211. aTag.download = fileName;
  212. aTag.href = res.data;
  213. aTag.click();
  214. } else {
  215. this.$message({
  216. message: res.msg,
  217. type: "error"
  218. });
  219. }
  220. },
  221. error => {
  222. this.listLoading = false;
  223. this.$message({
  224. message: error,
  225. type: "error"
  226. });
  227. });
  228. },
  229. //获取人员成本统计列表
  230. getUserCostList() {
  231. this.listLoading = true;
  232. this.http.post(this.port.project.userCost, {
  233. startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange,
  234. endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
  235. },
  236. res => {
  237. this.listLoading = false;
  238. var _this = this;
  239. this.hasReportUserList = [];
  240. if (res.code == "ok") {
  241. //工时总成本
  242. this.hasReportUserList = res.data.userList;
  243. var xList = [] , yList = [] , list = res.data.list, array = [] , series = [];
  244. var totalMoneyCost = res.data.totalCostMoney;
  245. if (list.length > 0) {
  246. var num = list.length==0?0:list[0].project.length;
  247. for(var i in list) {
  248. xList.push(list[i].name);
  249. var pro = list[i].project;
  250. for(var j in pro) {
  251. if(array.indexOf(pro[j].project) == -1) {
  252. array.push(pro[j].project)
  253. }
  254. }
  255. }
  256. for(var i in array) {
  257. yList.push(array[i]);
  258. var dataList = [];
  259. for(var j in list) {
  260. var project = list[j].project , num = 0;
  261. if(project.length != 0) {
  262. for(var k in project) {
  263. if(project[k].project == array[i]) {
  264. dataList.push({
  265. "value": project[k].money,
  266. "cost": project[k].time,
  267. })
  268. } else {
  269. num++;
  270. }
  271. if(k == project.length-1 && num != project.length-1) {
  272. dataList.push({
  273. "value": 0,
  274. "cost": 0,
  275. })
  276. }
  277. }
  278. } else {
  279. dataList.push({
  280. "value": 0,
  281. "cost": 0,
  282. })
  283. }
  284. }
  285. series.push({
  286. name: array[i],
  287. type: 'bar',
  288. stack:'1',
  289. barMaxWidth: 30,
  290. data: dataList,
  291. })
  292. }
  293. }
  294. var myChart = echarts.init(document.getElementById("container"));
  295. _this.myChart = myChart;
  296. var option = {
  297. //总成本
  298. title: {
  299. text: '工时成本总计' + totalMoneyCost.toFixed(2) + '元',
  300. left:'left',
  301. },
  302. // 工具箱
  303. legend: {
  304. x: 80,
  305. y: 10,
  306. data: yList,
  307. show: true,
  308.        top:"5%",//与上方的距离 可百分比% 可像素px
  309. },
  310. grid : {
  311. top : 80, //距离容器上边界40像素
  312. bottom: 35 //距离容器下边界30像素
  313. },
  314. toolbox: {
  315. show: true,
  316. feature:{
  317. saveAsImage:{
  318. show:true
  319. },
  320. restore:{
  321. show:true
  322. },
  323. // dataView:{
  324. // show:true
  325. // },
  326. // dataZoom:{
  327. // show:true
  328. // },
  329. magicType:{
  330. type:['line','bar']
  331. }
  332. }
  333. },
  334. tooltip:{
  335. trigger:'axis',
  336. formatter: function (params,ticket,callback) {
  337. var totalTime = 0;
  338. var totalCost = 0;
  339. var res = "";
  340. for(var i in params) {
  341. if (params[i].data.value > 0) {
  342. res += "<div style='margin-top:3px;font-size:12px;'><font color='#ddd'>项目名称:" + params[i].seriesName
  343. + "</font><br/>工作成本 : " + params[i].data.value
  344. + "元 <br/>工作时长"+" : " + params[i].data.cost + "小时</br></div>";
  345. totalTime += Number(params[i].data.cost);
  346. totalCost += Number(params[i].data.value);
  347. }
  348. }
  349. res = res +'<br/>'+ params[0].name+ '<br/>总计: ' + totalTime.toFixed(1)+'小时 '+totalCost.toFixed(2) + "元<br/>";
  350. return res;
  351. }
  352. },
  353. xAxis: {
  354. data: xList,
  355. axisLabel: {
  356. interval:0,rotate:20
  357. }
  358. },
  359. yAxis: [{
  360. type : 'value',
  361. axisLabel: {
  362. formatter:'{value} (元)'
  363. }
  364. }],
  365. series: series,
  366. };
  367. myChart.setOption(option,{notMerge:true});
  368. } else {
  369. this.$message({
  370. message: res.msg,
  371. type: "error"
  372. });
  373. }
  374. },
  375. error => {
  376. this.listLoading = false;
  377. this.$message({
  378. message: error,
  379. type: "error"
  380. });
  381. });
  382. },
  383. yanjiu() {
  384. console.log('触发')
  385. },
  386. getEchart(){
  387. var that = this
  388. that.timers = setTimeout(()=>{
  389. clearTimeout(that.timers)
  390. console.log(that.timers)
  391. that.jieliu()
  392. },800);
  393. // this.jieliu()
  394. },
  395. // 脱离出来的方法
  396. jieliu() {
  397. console.log('触发了')
  398. sessionStorage.radio = this.radio;
  399. var _this = this;
  400. var param = {};
  401. if (this.dateRange != null) {
  402. param = {startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange,
  403. endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange};
  404. console.log(param);
  405. }
  406. var url = '';
  407. if (this.radio=='项目') {
  408. url = this.port.project.listCost;
  409. } else if (this.radio=='部门') {
  410. url = this.port.project.depCost;
  411. } else if (this.radio=='人员') {
  412. this.getUserCostList();
  413. return;
  414. } else if (this.radio == this.namess) {
  415. url = '/project/getDegreeCost'
  416. }
  417. this.http.post(url, param,
  418. res => {
  419. if (res.code == "ok") {
  420. // 测试写的
  421. // var shujuy = res.data.costList
  422. // var arrsa = []
  423. // for(var i=0; i<30; i++) {
  424. // arrsa.push(shujuy[0])
  425. // }
  426. // console.log(arrsa)
  427. // res.data.costList = arrsa
  428. for(var i in res.data.costList) {
  429. if(i>20) {
  430. // this.widthHtval = +this.widthHtval + 2
  431. this.widthHtval = +this.widthHtval + 40
  432. } else {
  433. this.widthHtval = document.body.clientWidth - 230
  434. }
  435. }
  436. // 测试写的
  437. var xList = []
  438. var yList = []
  439. var list
  440. var totalMoneyCost
  441. if(this.radio == '项目' || this.radio == '人员' || this.radio=='部门') {
  442. list = res.data.costList
  443. totalMoneyCost = ((this.radio=='项目' || this.radio=='人员')?res.data.totalMoneyCost:res.data.totalCostMoney);
  444. for(var i in list) {
  445. if(this.radio=='项目' || this.radio == '人员') {
  446. xList.push(this.radio=='项目'?list[i].project:list[i].name);
  447. yList.push({
  448. "value": list[i].costMoney.toFixed(2) || list[i].costMoney,
  449. "id": list[i].id || i,
  450. "cost": list[i].cost
  451. });
  452. } else {
  453. xList.push(list[i].departmentName);
  454. yList.push({
  455. "value": list[i].costMoney.toFixed(2) || list[i].costMoney,
  456. "id": list[i].departmentId,
  457. "cost": list[i].costTime
  458. });
  459. }
  460. }
  461. } else {
  462. list = res.data
  463. var totalMoneyCost = 1
  464. for(var i in list) {
  465. console.log(list[i].name, list[i].costMoney, list[i].cost)
  466. xList.push(list[i].name);
  467. yList.push({
  468. "value": list[i].costMoney,
  469. "id": list[i].id || i,
  470. "cost": list[i].cost
  471. });
  472. }
  473. }
  474. // var xList = [], yList = [], list = res.data.costList,
  475. // totalMoneyCost = ((this.radio=='项目' || this.radio=='人员')?res.data.totalMoneyCost:res.data.totalCostMoney);
  476. // for(var i in list) {
  477. // if(this.radio=='项目' || this.radio == '人员') {
  478. // xList.push(this.radio=='项目'?list[i].project:list[i].name);
  479. // yList.push({
  480. // "value": list[i].costMoney.toFixed(2),
  481. // "id": list[i].id || i,
  482. // "cost": list[i].cost
  483. // });
  484. // }
  485. // // else if(this.radio=='研究'){
  486. // // xList.push(list[i].name)
  487. // // yList.push({
  488. // // "value": list[i].costMoney.toFixed(2),
  489. // // // "id": list[i].id,
  490. // // "id": i,
  491. // // "cost": list[i].cost
  492. // // })
  493. // // }
  494. // else {
  495. // xList.push(list[i].departmentName);
  496. // yList.push({
  497. // "value": list[i].costMoney.toFixed(2),
  498. // "id": list[i].departmentId,
  499. // "cost": list[i].costTime
  500. // });
  501. // }
  502. // }
  503. var myChart = echarts.init(document.getElementById("container"));
  504. myChart.resize({
  505. width: this.widthHtval
  506. })
  507. _this.myChart = myChart;
  508. // console.log(totalMoneyCost.toFixed(2), '看看', totalMoneyCost)
  509. // var chengbentongji = totalMoneyCost.toFixed(2) || totalMoneyCost
  510. if(totalMoneyCost) {
  511. this.zhishin = totalMoneyCost.toFixed(2)
  512. }
  513. if(this.radio == '项目' || this.radio == '人员' || this.radio=='部门') {
  514. var option = {
  515. title: {
  516. text: '工时成本总计' + this.zhishin + '元',
  517. left:'left',
  518. },
  519. // 工具箱
  520. toolbox: {
  521. show: true,
  522. feature:{
  523. saveAsImage:{
  524. show:true
  525. },
  526. restore:{
  527. show:true
  528. },
  529. // dataView:{
  530. // show:true
  531. // },
  532. // dataZoom:{
  533. // show:true
  534. // },
  535. magicType:{
  536. type:['line','bar']
  537. },
  538. }
  539. },
  540. tooltip:{
  541. trigger:'axis',
  542. formatter: function (params,ticket,callback) {
  543. var res = params[0].name + "<br/>工作成本"+" : " + params[0].data.value
  544. + "元 <br/>工作时长"+" : " + params[0].data.cost + "小时";
  545. _this.params = params;
  546. return res;
  547. }
  548. },
  549. xAxis: {
  550. data: xList,
  551. axisLabel: {
  552. interval:0,rotate:20
  553. }
  554. },
  555. yAxis: [{
  556. type : 'value',
  557. axisLabel: {
  558. formatter:'{value} (元)'
  559. }
  560. }],
  561. series: [{
  562. name: '工作成本(元)',
  563. type: 'bar',
  564. barMaxWidth: 30,
  565. data: yList,
  566. }]
  567. };
  568. } else {
  569. var option = {
  570. title: {
  571. text: '',
  572. left:'left',
  573. },
  574. // 工具箱
  575. toolbox: {
  576. show: true,
  577. feature:{
  578. saveAsImage:{
  579. show:true
  580. },
  581. restore:{
  582. show:true
  583. },
  584. // dataView:{
  585. // show:true
  586. // },
  587. // dataZoom:{
  588. // show:true
  589. // },
  590. magicType:{
  591. type:['line','bar']
  592. },
  593. }
  594. },
  595. tooltip:{
  596. trigger:'axis',
  597. formatter: function (params,ticket,callback) {
  598. var res = params[0].name + "<br/>工作成本"+" : " + params[0].data.value
  599. + "元 <br/>工作时长"+" : " + params[0].data.cost + "小时";
  600. _this.params = params;
  601. return res;
  602. }
  603. },
  604. xAxis: {
  605. data: xList,
  606. axisLabel: {
  607. interval:0,rotate:20
  608. }
  609. },
  610. yAxis: [{
  611. type : 'value',
  612. axisLabel: {
  613. formatter:'{value} (元)'
  614. }
  615. }],
  616. series: [{
  617. name: '工作成本(元)',
  618. type: 'bar',
  619. barMaxWidth: 30,
  620. data: yList,
  621. }]
  622. };
  623. }
  624. // var option = {
  625. // title: {
  626. // text: '工时成本总计' + totalMoneyCost.toFixed(2) + '元',
  627. // left:'left',
  628. // },
  629. // // 工具箱
  630. // toolbox: {
  631. // show: true,
  632. // feature:{
  633. // saveAsImage:{
  634. // show:true
  635. // },
  636. // restore:{
  637. // show:true
  638. // },
  639. // // dataView:{
  640. // // show:true
  641. // // },
  642. // // dataZoom:{
  643. // // show:true
  644. // // },
  645. // magicType:{
  646. // type:['line','bar']
  647. // },
  648. // }
  649. // },
  650. // tooltip:{
  651. // trigger:'axis',
  652. // formatter: function (params,ticket,callback) {
  653. // var res = params[0].name + "<br/>工作成本"+" : " + params[0].data.value
  654. // + "元 <br/>工作时长"+" : " + params[0].data.cost + "小时";
  655. // _this.params = params;
  656. // return res;
  657. // }
  658. // },
  659. // xAxis: {
  660. // data: xList,
  661. // axisLabel: {
  662. // interval:0,rotate:20
  663. // }
  664. // },
  665. // yAxis: [{
  666. // type : 'value',
  667. // axisLabel: {
  668. // formatter:'{value} (元)'
  669. // }
  670. // }],
  671. // series: [{
  672. // name: '工作成本(元)',
  673. // type: 'bar',
  674. // barMaxWidth: 30,
  675. // data: yList,
  676. // }]
  677. // };
  678. myChart.setOption(option,{notMerge: true});
  679. myChart.getZr().on('click', params => {
  680. const pointInPixel = [params.offsetX, params.offsetY];
  681. if (myChart.containPixel('grid', pointInPixel)) {
  682. console.log(_this.params)
  683. if(_this.radio=='项目') {
  684. if (_this.dateRange != null) {
  685. if (this.user.timeType.fixMonthcost == 0) {
  686. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
  687. +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
  688. } else {
  689. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
  690. +"?startDate="+_this.dateRange+"&endDate="+_this.dateRange);
  691. }
  692. } else {
  693. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name);
  694. }
  695. } else if (_this.radio=='部门') {
  696. if (_this.dateRange != null) {
  697. _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name
  698. +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
  699. } else {
  700. _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name);
  701. }
  702. }
  703. }
  704. });
  705. } else {
  706. this.$message({
  707. message: res.msg,
  708. type: "error"
  709. });
  710. }
  711. },
  712. error => {
  713. this.$message({
  714. message: error,
  715. type: "error"
  716. });
  717. });
  718. }
  719. },
  720. created() {
  721. },
  722. mounted() {
  723. this.containerHeight = window.innerHeight - 140
  724. const that = this;
  725. window.onresize = function temp() {
  726. this.containerHeight = window.innerHeight - 100
  727. };
  728. if (this.user.timeType.fixMonthcost == 0) {
  729. if (this.$route.query.startDate != null) {
  730. this.dateRange = [this.$route.query.startDate, this.$route.query.endDate];
  731. } else {
  732. //默认查看本月
  733. var now = new Date();
  734. var t = util.formatDate.format(now, 'yyyy-MM-dd');
  735. var startStr = util.formatDate.format(new Date(), 'yyyy-MM') + "-01";
  736. this.dateRange = [startStr,t];
  737. }
  738. this.exportParam.dateRange = this.dateRange;
  739. } else if (this.user.timeType.fixMonthcost == 1) {
  740. if (this.$route.query.startDate != null) {
  741. this.dateRange = this.$route.query.startDate;
  742. } else {
  743. //默认查看本月
  744. var startStr = util.formatDate.format(new Date(), 'yyyy-MM');
  745. this.dateRange = startStr;
  746. }
  747. this.exportParam.dateRange = this.dateRange;
  748. }
  749. this.radio = '项目'
  750. this.getEchart();
  751. var _this = this;
  752. window.addEventListener("resize", function() {
  753. _this.myChart.resize();
  754. });
  755. this.getMyProjectList();
  756. this.getUsers()
  757. this.jutishez()
  758. },
  759. };
  760. </script>
  761. <style lang="scss" scoped>
  762. #container {
  763. // display: inline-block;
  764. display: block;
  765. position: absolute;
  766. // width: 100% !important;
  767. margin-top: 60px;
  768. }
  769. </style>
  770. <style lang="scss">
  771. </style>