cost.vue 36 KB

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