custom_data.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  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>&nbsp;</div>
  6. </el-col>
  7. <el-col :span="12" style="">
  8. <el-date-picker size="small"
  9. v-model="dateRange" :editable="false"
  10. format="yyyy-MM-dd" value-format="yyyy-MM-dd"
  11. @change="getEchart"
  12. :clearable="true"
  13. :range-separator="$t('other.to')"
  14. type="daterange"
  15. :start-placeholder="$t('time.startDate')"
  16. :end-placeholder="$t('time.endDate')"
  17. ></el-date-picker>
  18. <el-radio-group v-model="radio" @change="getEchart" style="margin-left:10px;" size="small">
  19. <el-radio-button :label="$t('other.project')" v-if="permissions.customDataAll"></el-radio-button>
  20. <!-- <el-radio-button :label="部门"></el-radio-button> -->
  21. <el-radio-button :label="$t('ren-yuan')"></el-radio-button>
  22. <el-radio-button :label="$t('lable.department')"></el-radio-button>
  23. <el-radio-button :label="'日期'"></el-radio-button>
  24. <!-- <el-radio-button :label="namess" v-if="jichu.customDegreeActive == 1"></el-radio-button> -->
  25. </el-radio-group>
  26. </el-col>
  27. <el-col :span="6">
  28. <el-button @click="showExportDialog" size="small">{{ $t('reporderived') }}</el-button>
  29. </el-col>
  30. </el-row>
  31. <div :style="'width:'+widthHtval+'px;position: relative; height:'+containerHeight+'px;'">
  32. <div id="container" :style="'height:'+containerHeight+'px;width:100%'"></div>
  33. </div>
  34. <div style="position:fixed;top:170px;left:600px;" v-show="radio==$t('lable.department') && parentDeptId != null">
  35. <el-button @click="backToParentDept" size="small">{{ $t('returnsuperior') }}</el-button>
  36. </div>
  37. <!--导出报表条件选择 -->
  38. <el-dialog :title="$t('Exportdata')" v-if="exportDialog" :visible.sync="exportDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
  39. <el-form ref="form3" :model="exportParam" >
  40. <el-form-item prop="projectId" :label="$t('defaultText.selectProject')" v-if="permissions.customDataAll">
  41. <el-select v-model="exportParam.projectId" :placeholder="$t('other.allProject')" clearable style="width:350px;" filterable="true">
  42. <el-option v-for="item in projectList" :key="item.id" :label="item.projectName + item.projectCode" :value="item.id">
  43. <span style="float: left;color: #8492a6; font-size: 13px">{{ item.projectCode }}</span>
  44. <span style="float: right;margin-left: 20px">{{ item.projectName }}</span>
  45. </el-option>
  46. </el-select>
  47. </el-form-item>
  48. <!-- <el-form-item prop="userIds" label="选择人员" >
  49. <el-select v-model="exportParam.userIds" placeholder="全部人员" multiple="true" clearable style="width:350px;" filterable="true">
  50. <el-option v-for="item in hasReportUserList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  51. </el-select>
  52. </el-form-item> -->
  53. <el-form-item prop="projectId" :label="user.timeType.fixMonthcost==0?$t('time.dateRange'):$t('Selectmonth')">
  54. <el-date-picker v-show="user.timeType.fixMonthcost==0"
  55. v-model="exportParam.dateRange" :editable="false"
  56. format="yyyy-MM-dd" value-format="yyyy-MM-dd"
  57. :clearable="false"
  58. :range-separator="$t('other.to')"
  59. type="daterange"
  60. :start-placeholder="$t('time.startDate')"
  61. :end-placeholder="$t('time.endDate')"
  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%;" >{{ $t('export.export') }}</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. yAxisValue: localStorage.yAxisValue?localStorage.yAxisValue:0,
  84. parentDeptStack:[],
  85. parentDeptId:null,
  86. hasReportUserList:[],
  87. projectList:[],
  88. exportParam:{projectId:null,dateRange:[],userId: null},
  89. exportDialog:false,
  90. dateRange:[],
  91. user: JSON.parse(sessionStorage.getItem("user")),
  92. permissions: JSON.parse(sessionStorage.getItem("permissions")),
  93. radio: sessionStorage.radio!=null?sessionStorage.radio:this.$t('other.project'),
  94. containerHeight: 0,
  95. myChart: null,
  96. params: null,
  97. widthHtval: document.body.clientWidth - 230,
  98. users: [],
  99. jichu: [],
  100. namess: '',
  101. timers: null, // 点击的时间
  102. zhishin: 0
  103. };
  104. },
  105. methods: {
  106. //Y轴点击改变显示的数据
  107. onYAxisChange() {
  108. localStorage.yAxisValue = this.yAxisValue;
  109. this.jieliu();
  110. },
  111. jutishez() {
  112. this.http.post('/time-type/getCompanyTimeSetting', {
  113. companyId: this.user.companyId,
  114. },
  115. res => {
  116. if (res.code == "ok") {
  117. this.jichu = res.data
  118. if(res.data.customDegreeActive == 1) {
  119. this.namess = res.data.customDegreeName
  120. }
  121. } else {
  122. this.$message({
  123. message: res.msg,
  124. type: "error"
  125. });
  126. }
  127. },
  128. error => {
  129. this.$message({
  130. message: error,
  131. type: "error"
  132. });
  133. });
  134. },
  135. getUsers() {
  136. // console.log(this.port.manage.list,'getusers')
  137. // this.http.post(this.port.manage.list, {
  138. // departmentId: -1,
  139. // pageIndex: 1,
  140. // // pageSize: 99999
  141. // pageSize: -1
  142. // },
  143. this.http.post('/user/getSimpleActiveUserList', {},
  144. res => {
  145. if (res.code == "ok") {
  146. this.users = res.data;
  147. } else {
  148. this.$message({
  149. message: res.msg,
  150. type: "error"
  151. });
  152. }
  153. },
  154. error => {
  155. this.$message({
  156. message: error,
  157. type: "error"
  158. });
  159. });
  160. },
  161. showExportDialog() {
  162. this.exportDialog = true;
  163. this.exportParam.dateRange = this.dateRange;
  164. },
  165. //获取我的项目列表
  166. getMyProjectList() {
  167. this.http.post('/project/getProjectList', {
  168. },
  169. res => {
  170. if (res.code == "ok") {
  171. this.projectList = res.data;
  172. } else {
  173. this.$message({
  174. message: res.msg,
  175. type: "error"
  176. });
  177. }
  178. },
  179. error => {
  180. this.$message({
  181. message: error,
  182. type: "error"
  183. });
  184. });
  185. },
  186. exportProjectData() {
  187. var param = {};
  188. if (this.exportParam.dateRange != null) {
  189. param = {startDate:this.exportParam.dateRange[0], endDate: this.exportParam.dateRange[1]};
  190. }
  191. var url = "/project/exportCustomDataSum";
  192. var fileName = this.user.timeType.customDataName + this.$t('statistical')+'.xlsx';
  193. if (this.exportParam.projectId != null) {
  194. param.projectId = this.exportParam.projectId;
  195. }
  196. this.http.post(url, param,
  197. res => {
  198. this.listLoading = false;
  199. if (res.code == "ok") {
  200. this.exportDialog = false;
  201. var aTag = document.createElement('a');
  202. aTag.download = fileName;
  203. aTag.href = res.data;
  204. aTag.click();
  205. } else {
  206. this.$message({
  207. message: res.msg,
  208. type: "error"
  209. });
  210. }
  211. },
  212. error => {
  213. this.listLoading = false;
  214. this.$message({
  215. message: error,
  216. type: "error"
  217. });
  218. });
  219. },
  220. //获取人员成本统计列表
  221. getUserCostList() {
  222. this.listLoading = true;
  223. let url = this.radio == this.$t('ren-yuan') ? '/department/getUserCustomDataStatistic' :this.radio == '日期'?'/report/getCustomDataWithDate': '/department/getDeptCustomDataStatistic'
  224. this.http.post(url, {
  225. startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange,
  226. endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
  227. },
  228. res => {
  229. this.listLoading = false;
  230. var _this = this;
  231. this.hasReportUserList = [];
  232. if (res.code == "ok") {
  233. if(this.user.userNameNeedTranslate == 1 && (this.radio == this.$t('ren-yuan') || this.radio == this.$t('lable.department'))) {
  234. let arr = []
  235. for(var i in res.data.list) {
  236. let obj = {}
  237. if(this.radio == this.$t('ren-yuan')) {
  238. obj.type = 'userName'
  239. } else {
  240. obj.type = 'departmentName'
  241. }
  242. obj.id = res.data.list[i].name
  243. arr.push(obj)
  244. }
  245. this.dealWithTranslationPlone(arr, res)
  246. } else {
  247. this.choli(res)
  248. }
  249. } else {
  250. this.$message({
  251. message: res.msg,
  252. type: "error"
  253. });
  254. }
  255. },
  256. error => {
  257. this.listLoading = false;
  258. this.$message({
  259. message: error,
  260. type: "error"
  261. });
  262. });
  263. },
  264. dealWithTranslationPlone(items, dataList) {
  265. console.log(items, '处理的值')
  266. if (WWOpenData.initCanvas) {
  267. WWOpenData.initCanvas()
  268. }
  269. const myFunOne = async () => {
  270. const result = await new Promise((resolve, reject) => {
  271. if(WWOpenData.prefetch) {
  272. WWOpenData.prefetch({ items }, (err, data) => {
  273. if (err) { return reject(err) }
  274. resolve(data)
  275. })
  276. }
  277. })
  278. for(var i in dataList.data.list) {
  279. dataList.data.list[i].name = result.items[i].data
  280. }
  281. this.choli(dataList)
  282. }
  283. myFunOne()
  284. },
  285. choli(data) {
  286. console.log('过来的值', data)
  287. var _this = this;
  288. //工时总成本
  289. // this.hasReportUserList = this.radio == '人员' ? res.data.userList : res.data.department;
  290. // var xList = [] , yList = [] , list = res.data.list, array = [] , series = [];
  291. this.hasReportUserList = this.radio == this.$t('ren-yuan') ? data.data.userList : data.data.department;
  292. var xList = [] , yList = [] , list = data.data.list, array = [] , series = [];
  293. var totalHours = 0.0;
  294. if (list.length > 0) {
  295. var num = list.length==0?0:list[0].project.length;
  296. for(var i in list) {
  297. xList.push(list[i].name);
  298. var pro = list[i].project;
  299. for(var j in pro) {
  300. if(array.indexOf(pro[j].project) == -1) {
  301. array.push(pro[j].project)
  302. }
  303. }
  304. }
  305. for(var i in array) {
  306. yList.push(array[i]);
  307. var dataList = [];
  308. for(var j in list) {
  309. var project = list[j].project , num = 0;
  310. if(project.length != 0) {
  311. for(var k in project) {
  312. if(project[k].project == array[i]) {
  313. dataList.push({
  314. "value": project[k].cost,
  315. "cost": project[k].cost
  316. })
  317. totalHours += parseFloat(project[k].cost);
  318. } else {
  319. num++;
  320. }
  321. if(k == project.length-1 && num != project.length-1) {
  322. dataList.push({
  323. "value": 0,
  324. "cost": 0
  325. })
  326. }
  327. }
  328. } else {
  329. dataList.push({
  330. "value": 0,
  331. "cost": 0,
  332. })
  333. }
  334. }
  335. series.push({
  336. name: array[i],
  337. type: 'bar',
  338. stack:'1',
  339. barMaxWidth: 30,
  340. data: dataList,
  341. })
  342. }
  343. }
  344. var myChart = echarts.init(document.getElementById("container"));
  345. totalHours = totalHours.toFixed(1);
  346. _this.myChart = myChart;
  347. var option = {
  348. //总成本
  349. title: {
  350. text: _this.user.timeType.customDataName + this.$t('zong-ji') + totalHours,
  351. left:'left',
  352. },
  353. // 工具箱
  354. legend: {
  355. x: 80,
  356. y: 10,
  357. data: yList,
  358. show: true,
  359.       top:"5%",//与上方的距离 可百分比% 可像素px
  360. },
  361. grid : {
  362. top : 80, //距离容器上边界40像素
  363. bottom: 35 //距离容器下边界30像素
  364. },
  365. toolbox: {
  366. show: true,
  367. feature:{
  368. saveAsImage:{
  369. show:true
  370. },
  371. restore:{
  372. show:true
  373. },
  374. // dataView:{
  375. // show:true
  376. // },
  377. // dataZoom:{
  378. // show:true
  379. // },
  380. magicType:{
  381. type:['line','bar']
  382. }
  383. }
  384. },
  385. tooltip:{
  386. trigger:'axis',
  387. formatter: function (params,ticket,callback) {
  388. var totalTime = 0;
  389. var res = "";
  390. for(var i in params) {
  391. if (params[i].data.value > 0) {
  392. res += "<div style='margin-top:3px;font-size:12px;'><font color='#ddd'>"+_this.$t('headerTop.projectName')+":" + params[i].seriesName
  393. + "</font><br/>"+_this.user.timeType.customDataName+" : " + params[i].data.cost+"</div>";
  394. totalTime += Number(params[i].data.cost);
  395. }
  396. }
  397. if(_this.user.userNameNeedTranslate != 1) {
  398. res = res +'<br/>'+ params[0].name+ '<br/>'+_this.$t('zong-ji')+': ' + totalTime.toFixed(1);
  399. } else {
  400. if(_this.radio == _this.$t('ren-yuan') || _this.radio == _this.$t('lable.department')) {
  401. res = res +'<br/>'+ '' + '<br/>'+_this.$t('zong-ji')+': ' + totalTime.toFixed(1);
  402. } else {
  403. res = res +'<br/>'+ params[0].name+ '<br/>'+_this.$t('zong-ji')+': ' + totalTime.toFixed(1);
  404. }
  405. }
  406. return res;
  407. }
  408. },
  409. xAxis: {
  410. data: xList,
  411. axisLabel: {
  412. interval:0,rotate:20
  413. }
  414. },
  415. yAxis: [{
  416. type : 'value',
  417. axisLabel: {
  418. formatter:'{value}'
  419. }
  420. }],
  421. series: series,
  422. };
  423. myChart.setOption(option,{notMerge:true});
  424. },
  425. yanjiu() {
  426. // console.log('触发')
  427. },
  428. getEchart(){
  429. var that = this
  430. // that.timers = setTimeout(()=>{
  431. // clearTimeout(that.timers)
  432. // console.log(that.timers)
  433. that.jieliu()
  434. // },100);
  435. // this.jieliu()
  436. },
  437. backToParentDept() {
  438. if (this.radio == this.$t('lable.department')) {
  439. if (this.parentDeptStack.length > 0) {
  440. this.parentDeptStack.pop();
  441. if (this.parentDeptStack.length > 0) {
  442. this.parentDeptId = this.parentDeptStack[this.parentDeptStack.length -1];
  443. } else {
  444. this.parentDeptId = null;
  445. }
  446. this.jieliu();
  447. }
  448. }
  449. },
  450. // 脱离出来的方法
  451. jieliu() {
  452. sessionStorage.radio = this.radio;
  453. var _this = this;
  454. var param = {};
  455. if (this.dateRange != null) {
  456. param = {startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange,
  457. endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange};
  458. // console.log(param);
  459. }
  460. var url = '';
  461. if (this.radio==this.$t('other.project')) {
  462. url = '/project/getCustomDataSum';
  463. // } else if (this.radio=='部门') {
  464. // url = '/department/getDeptCustomDataStatistic';
  465. } else if (this.radio==this.$t('ren-yuan') || this.radio == this.$t('lable.department')||this.radio == '日期') {
  466. this.getUserCostList();
  467. return;
  468. } else if (this.radio == this.namess) {
  469. url = '/project/getDegreeCost'
  470. }
  471. this.http.post(url, param,
  472. res => {
  473. if (res.code == "ok") {
  474. for(var i in res.data.costList) {
  475. if(i>20) {
  476. // this.widthHtval = +this.widthHtval + 2
  477. this.widthHtval = +this.widthHtval + 40
  478. } else {
  479. this.widthHtval = document.body.clientWidth - 230
  480. }
  481. }
  482. // 测试写的
  483. var xList = []
  484. var yList = []
  485. var list
  486. var totalMoneyCost;
  487. var totalHours = 0.0;
  488. if(this.radio == this.$t('other.project') || this.radio==this.$t('lable.department')) {
  489. list = res.data.costList
  490. totalMoneyCost = ((this.radio==this.$t('other.project'))?res.data.totalMoneyCost:res.data.totalCostMoney);
  491. for(var i in list) {
  492. if(this.radio==this.$t('other.project')) {
  493. xList.push(this.radio==this.$t('other.project')?list[i].project:list[i].name);
  494. yList.push({
  495. "value": list[i].cost.toFixed(1),
  496. "id": list[i].id || i,
  497. "cost": list[i].cost
  498. });
  499. totalHours += parseFloat(list[i].cost);
  500. } else {
  501. xList.push(list[i].departmentName);
  502. yList.push({
  503. "value": list[i].costTime.toFixed(1),
  504. "id": list[i].departmentId,
  505. "cost": list[i].costTime,
  506. "hasSubDept": list[i].hasSubDept
  507. });
  508. totalHours += parseFloat(list[i].costTime);
  509. }
  510. }
  511. } else if(this.radio == this.$t('ren-yuan') || this.radio=='日期') {
  512. list = res.data
  513. var totalMoneyCost = 0;
  514. for(var i in list) {
  515. // console.log(list[i].name, list[i].costMoney, list[i].cost)
  516. xList.push(list[i].name);
  517. yList.push({
  518. "value": this.yAxisValue==0?list[i].costMoney:list[i].cost,
  519. "id": list[i].id || i,
  520. "cost": list[i].cost,
  521. "money":list[i].costMoney.toFixed(2)
  522. });
  523. totalHours += parseFloat(list[i].cost);
  524. totalMoneyCost += parseFloat(list[i].costMoney);
  525. }
  526. }
  527. totalHours = totalHours.toFixed(1);
  528. var myChart = echarts.init(document.getElementById("container"));
  529. myChart.resize({
  530. width: this.widthHtval
  531. })
  532. _this.myChart = myChart;
  533. // console.log(totalMoneyCost.toFixed(2), '看看', totalMoneyCost)
  534. // var chengbentongji = totalMoneyCost.toFixed(2) || totalMoneyCost
  535. if(totalMoneyCost) {
  536. this.zhishin = totalMoneyCost.toFixed(2)
  537. }
  538. if(this.radio == this.$t('other.project') || this.radio == this.$t('ren-yuan') || this.radio==this.$t('lable.department')|| this.radio=='日期') {
  539. var option = {
  540. title: {
  541. text: _this.user.timeType.customDataName+_this.$t('zong-ji')+':' + totalHours,
  542. left:'left',
  543. },
  544. // 工具箱
  545. toolbox: {
  546. show: true,
  547. feature:{
  548. saveAsImage:{show:true},restore:{show:true}, magicType:{ type:['line','bar']},
  549. }
  550. },
  551. tooltip:{
  552. trigger:'axis',
  553. formatter: function (params,ticket,callback) {
  554. var res = params[0].name + "<br/>"+_this.user.timeType.customDataName+" : " + 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:'{value}'
  569. }
  570. }],
  571. series: [{
  572. name: _this.user.timeType.customDataName,
  573. type: 'bar',
  574. barMaxWidth: 30,
  575. data: yList,
  576. }]
  577. };
  578. } else {
  579. var option = {
  580. title: {
  581. text: _this.$t('otalhourscost') + _this.zhishin + _this.$t('yuan')+','+_this.$t('time.duration')+totalHours+_this.$t('time.hour'),
  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/>"+_this.$t('workcost')+" : " + params[0].data.money
  595. + _this.$t('yuan')+"<br/>"+_this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour');
  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} ('+this.$t('yuan')+')':'{value}'+this.$t('time.hour')
  610. }
  611. }],
  612. series: [{
  613. name: this.yAxisValue==0?this.$t('workcost')+'('+this.$t('yuan')+')':this.$t('screening.workTime')+'('+this.$t('time.hour')+')',
  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('sss',_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 = this.permissions.customDataAll?this.$t('other.project'):this.$t('ren-yuan');
  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>