cost.vue 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307
  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" size="small">
  7. <el-radio-button label="0" v-if="permissions.countCost">显示成本</el-radio-button>
  8. <el-radio-button label="1" v-if="permissions.countHours">显示工时</el-radio-button>
  9. </el-radio-group></div>
  10. </el-col>
  11. <el-col :span="14" style="display: flex;flex-wrap: wrap;">
  12. <el-date-picker v-show="user.timeType.fixMonthcost==0" size="small"
  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" size="small"
  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;" size="small">
  30. <el-radio-button label="项目"></el-radio-button>
  31. <el-radio-button label="主项目" v-if="user.timeType.mainProjectState"></el-radio-button>
  32. <el-radio-button label="项目分类"></el-radio-button>
  33. <el-radio-button label="部门"></el-radio-button>
  34. <el-radio-button label="人员" v-if="permissions.countPersonnel"></el-radio-button>
  35. <el-radio-button :label="namess" v-if="jichu.customDegreeActive == 1"></el-radio-button>
  36. <el-radio-button v-for="item in theCustomList" :key="item.id" :label="item.name"></el-radio-button>
  37. </el-radio-group>
  38. <!--
  39. <el-select v-model="customName" filterable placeholder="请选择" style="margin-top: 10px;width: 350px" v-if="theCustomListFlg" @change="jieliu()">
  40. <el-option v-for="item in customList" :key="item.id" :label="item.name" :value="item.name"></el-option>
  41. </el-select> -->
  42. <el-select v-model="personnelValue" filterable clearable placeholder="请选择人员" size="small" style="margin-top: 10px;width: 350px" v-if="radio == '人员'" @change="personnel()">
  43. <el-option v-for="item in hasReportUserList" :key="item.id" :label="item.name" :value="item.name"></el-option>
  44. </el-select>
  45. </el-col>
  46. <el-col :span="4">
  47. <el-button @click="exportProjectData" v-if="theCustomListFlg" size="small">报表导出</el-button>
  48. <el-button @click="showExportDialog" v-else size="small">报表导出</el-button>
  49. </el-col>
  50. </el-row>
  51. <!-- <div id="clearfix" :style="'width:'+widthHtval+'px;position: relative; height:'+containerHeight+'px;'">
  52. <div id="container" :style="'height:'+containerHeight+'px;width:100%'"></div>
  53. </div> -->
  54. <div id="clearfix" :class="radio == '人员' ? 'ryuans' : ''" :style="'overflow-x: auto;width:100%;padding-bottom: 100px; position: relative; height:'+containerHeight+'px;'">
  55. <div id="container" :style="'height:'+containerHeight+'px;width:100%'"></div>
  56. </div>
  57. <!-- <div>
  58. <div id="container" :style="'height:'+containerHeight+'px;width:100%'"></div>
  59. </div> -->
  60. <div style="position:fixed;top:170px;left:600px;" v-show="radio=='部门' && parentDeptId != null">
  61. <el-button @click="backToParentDept">返回上级</el-button>
  62. </div>
  63. <!--导出报表条件选择 -->
  64. <el-dialog title="工时报表导出" v-if="exportDialog" :visible.sync="exportDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
  65. <el-form ref="form3" :model="exportParam" >
  66. <el-form-item prop="projectId" label="选择项目" v-if="radio != '人员' && radio != '项目分类'">
  67. <el-select v-model="exportParam.projectId" placeholder="全部项目" clearable style="width:350px;" filterable="true" popper-class="projectSelectPopperClass">
  68. <el-option v-for="item in projectList" :key="item.id" :label="item.projectName + item.projectCode" :value="item.id">
  69. <span style="float: left;color: #8492a6;">{{ item.projectCode }}</span>
  70. <span style="float: right;font-size: 13px;">{{ item.projectName }}</span>
  71. </el-option>
  72. </el-select>
  73. </el-form-item>
  74. <el-form-item label="部门选择" v-if="radio == '项目'">
  75. <el-cascader v-model="exportParam.deptId" :options="departmentList" placeholder="请选择部门"
  76. :props="{ checkStrictly: true, expandTrigger: 'hover' }" clearable filterable style="width:350px;"
  77. ></el-cascader>
  78. </el-form-item>
  79. <el-form-item prop="projectCategoryId" label="项目分类" v-if="radio == '项目分类'">
  80. <el-select v-model="exportParam.projectCategoryId" placeholder="全部项目分类" clearable style="width:350px;" filterable="true">
  81. <el-option v-for="item in categoryList" :key="item.id" :label="item.name" :value="item.id">
  82. </el-option>
  83. </el-select>
  84. </el-form-item>
  85. <el-form-item prop="userIds" label="选择人员" v-if="radio == '人员'">
  86. <el-select v-model="exportParam.userIds" placeholder="全部人员" multiple="true" clearable style="width:350px;" filterable="true">
  87. <el-option v-for="item in hasReportUserList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  88. </el-select>
  89. </el-form-item>
  90. <el-form-item prop="projectId" :label="user.timeType.fixMonthcost==0?'日期范围':'选择月份'">
  91. <el-date-picker v-show="user.timeType.fixMonthcost==0"
  92. v-model="exportParam.dateRange" :editable="false"
  93. format="yyyy-MM-dd" value-format="yyyy-MM-dd"
  94. :clearable="false"
  95. range-separator="至"
  96. type="daterange"
  97. start-placeholder="开始日期"
  98. end-placeholder="结束日期"
  99. ></el-date-picker>
  100. <el-date-picker v-show="user.timeType.fixMonthcost==1"
  101. v-model="dateRange" :editable="false"
  102. format="yyyy-MM" value-format="yyyy-MM"
  103. @change="getEchart"
  104. :clearable="true"
  105. type="month"
  106. ></el-date-picker>
  107. </el-form-item>
  108. <el-form-item label="选择人员" v-if="radio == '项目' || radio == '部门' || radio == '项目分类'">
  109. <el-select v-model="exportParam.userId" placeholder="全部人员" style="width: 350px" filterable="true" clearable="true">
  110. <span v-for="(item, index) in users" :key="index">
  111. <el-option :label="item.name" :value="item.id"></el-option>
  112. </span>
  113. </el-select>
  114. </el-form-item>
  115. <el-form-item prop="type" label="选择样式" v-if="radio == '项目' || radio == '部门' || radio == '项目分类'">
  116. <el-select v-model="exportParam.type" placeholder="选择样式" style="width:350px;" >
  117. <el-option :label="radio == '项目分类' ? '项目分类在行上' : '项目在行上'" value="0"></el-option>
  118. <el-option :label="radio == '项目分类' ? '项目分类在列上' : '项目在列上'" value="1"></el-option>
  119. </el-select>
  120. <div class="prompt">
  121. <el-popover placement="top" width="1200" trigger="hover">
  122. <img src="../../assets/image/hanglie.png" alt="" width="100%" v-if="this.radio != '项目分类'">
  123. <img src="../../assets/image/hanglie_corp.png" alt="" width="100%" v-else>
  124. <i class="el-icon-question" slot="reference" />
  125. </el-popover>
  126. </div>
  127. </el-form-item>
  128. <el-form-item v-if="(radio == '项目' || radio == '部门' || radio == '项目分类') && exportParam.type == '0'">
  129. <el-checkbox v-model="exportParam.projectSum" >含单个项目数据汇总</el-checkbox>
  130. </el-form-item>
  131. </el-form>
  132. <div slot="footer" class="dialog-footer">
  133. <el-button type="primary" @click="exportProjectData" style="width:100%;" >导出</el-button>
  134. </div>
  135. </el-dialog>
  136. </section>
  137. </template>
  138. <script>
  139. import util from "../../common/js/util";
  140. export default {
  141. data() {
  142. return {
  143. personnelValue: '',
  144. personnelAll: [],
  145. yAxisValue: localStorage.yAxisValue?localStorage.yAxisValue:0,
  146. parentDeptStack:[],
  147. parentDeptId:null,
  148. hasReportUserList:[],
  149. projectList:[],
  150. categoryList: [],
  151. exportParam:{projectId:null,dateRange:[],userId: null,type: '0'},
  152. exportDialog:false,
  153. dateRange:[],
  154. user: JSON.parse(sessionStorage.getItem("user")),
  155. permissions: JSON.parse(sessionStorage.getItem("permissions")),
  156. radio: sessionStorage.radio!=null?sessionStorage.radio:'项目',
  157. containerHeight: 0,
  158. // myChart: null,
  159. params: null,
  160. widthHtval: document.body.clientWidth - 230,
  161. users: [],
  162. jichu: [],
  163. namess: '',
  164. timers: null, // 点击的时间
  165. zhishin: 0,
  166. theCustomList: [], // 自定义数据来源
  167. theCustomListFlg: false, // 判断是否点击的是自定义配置的数据来源
  168. theCustomListId: '',
  169. theCustomListPlantLIst: [],
  170. theCustomListPlant: '',
  171. customId: '',
  172. customName: '',
  173. customList: [],
  174. departmentList: []
  175. };
  176. },
  177. methods: {
  178. //Y轴点击改变显示的数据
  179. onYAxisChange() {
  180. localStorage.yAxisValue = this.yAxisValue;
  181. this.jieliu();
  182. },
  183. jutishez() {
  184. this.http.post('/time-type/getCompanyTimeSetting', {
  185. companyId: this.user.companyId,
  186. },
  187. res => {
  188. if (res.code == "ok") {
  189. this.jichu = res.data
  190. if(res.data.customDegreeActive == 1) {
  191. this.namess = res.data.customDegreeName
  192. }
  193. } else {
  194. this.$message({
  195. message: res.msg,
  196. type: "error"
  197. });
  198. }
  199. },
  200. error => {
  201. this.$message({
  202. message: error,
  203. type: "error"
  204. });
  205. });
  206. },
  207. getUsers() {
  208. // console.log(this.port.manage.list)
  209. // this.http.post(this.port.manage.list, {
  210. // departmentId: -1,
  211. // pageIndex: 1,
  212. // // pageSize: 99999
  213. // pageSize: -1
  214. // },
  215. this.http.post('/user/getSimpleActiveUserList', {},
  216. res => {
  217. if (res.code == "ok") {
  218. this.users = res.data;
  219. } else {
  220. this.$message({
  221. message: res.msg,
  222. type: "error"
  223. });
  224. }
  225. },
  226. error => {
  227. this.$message({
  228. message: error,
  229. type: "error"
  230. });
  231. });
  232. },
  233. showExportDialog() {
  234. console.log(12345)
  235. this.exportDialog = true;
  236. this.exportParam.dateRange = this.dateRange;
  237. console.log(this.hasReportUserList)
  238. if (this.radio == '人员') {
  239. // this.exportParam.userIds = [];
  240. }
  241. if (this.radio == '项目') {
  242. this.exportParam.deptId = []
  243. }
  244. },
  245. //获取我的项目列表
  246. getMyProjectList() {
  247. this.http.post('/project/getProjectList', {
  248. },
  249. res => {
  250. if (res.code == "ok") {
  251. this.projectList = res.data;
  252. } else {
  253. this.$message({
  254. message: res.msg,
  255. type: "error"
  256. });
  257. }
  258. },
  259. error => {
  260. this.$message({
  261. message: error,
  262. type: "error"
  263. });
  264. });
  265. },
  266. exportProjectData() {
  267. var param = {stateKey: 1};
  268. if (this.exportParam.dateRange != null) {
  269. param = {startDate:this.exportParam.dateRange[0], endDate: this.exportParam.dateRange[1],stateKey: 1};
  270. }
  271. var url = "/project/exportTimeCost";
  272. var fileName = '项目工时成本统计.xls';
  273. if (this.radio == '人员' ) {
  274. console.log(this.exportParam.userIds);
  275. fileName = '人员工时成本统计.xls';
  276. url = '/department/exportUserStatistic';
  277. if (this.exportParam.userIds != null && this.exportParam.userIds.length > 0) {
  278. var ids = '';
  279. this.exportParam.userIds.forEach(u=>{
  280. ids += u+',';
  281. })
  282. param.userIds = ids;
  283. }
  284. }
  285. if(this.radio == '项目分类'){
  286. fileName = '项目分类工时成本统计.xls';
  287. url = '/project/exportTimeCostByCategory'
  288. if(this.exportParam.projectCategoryId){
  289. param.projectCategoryId = this.exportParam.projectCategoryId
  290. }
  291. }
  292. if(this.radio == '部门'){
  293. fileName = '部门工时成本统计.xls'
  294. url = '/department/exportDeptStatistic'
  295. }
  296. if (this.exportParam.projectId && this.radio != '人员' && this.radio != '项目分类') {
  297. param.projectId = this.exportParam.projectId;
  298. }
  299. if (this.exportParam.userId) {
  300. if(this.radio == '项目' || this.radio == '部门' || this.radio == '人员' || this.radio == '项目分类'){
  301. param.userId = this.exportParam.userId;
  302. }
  303. }
  304. if (this.exportParam.type == 1) {
  305. this.exportParam.projectSum = null
  306. }
  307. if (this.exportParam.projectSum != null) {
  308. if(this.radio == '项目' || this.radio == '部门' || this.radio == '项目分类'){
  309. param.projectSum = this.exportParam.projectSum;
  310. }
  311. }
  312. if(!this.theCustomListFlg) {
  313. param.type = this.exportParam.type*1
  314. }
  315. if(this.theCustomListFlg) {
  316. url = '/project/exportTimeCostByUserCustom'
  317. fileName = this.radio + '统计.xls'
  318. // param.subCustomName = this.customName
  319. param.customId = this.theCustomListId
  320. param.fieldName = this.theCustomListPlant
  321. }
  322. if(this.exportParam.deptId) {
  323. if(this.exportParam.deptId.length > 0) {
  324. param.deptId = this.exportParam.deptId[this.exportParam.deptId.length - 1]
  325. }
  326. }
  327. this.http.post(url, param,
  328. res => {
  329. this.listLoading = false;
  330. if (res.code == "ok") {
  331. this.exportDialog = false;
  332. var aTag = document.createElement('a');
  333. aTag.download = fileName;
  334. aTag.href = res.data;
  335. aTag.click();
  336. } else {
  337. this.$message({
  338. message: res.msg,
  339. type: "error"
  340. });
  341. }
  342. },
  343. error => {
  344. this.listLoading = false;
  345. this.$message({
  346. message: error,
  347. type: "error"
  348. });
  349. });
  350. },
  351. // 人员筛选
  352. personnel() {
  353. if(this.personnelValue) {
  354. var arrlist = JSON.parse(JSON.stringify(this.personnelAll))
  355. var arr = []
  356. for(var i in arrlist.list) {
  357. if(arrlist.list[i].name == this.personnelValue) {
  358. arr.push(arrlist.list[i])
  359. }
  360. }
  361. arrlist.list = arr
  362. this.gtff(arrlist)
  363. } else {
  364. this.gtff(this.personnelAll)
  365. }
  366. },
  367. //获取人员成本统计列表
  368. getUserCostList() {
  369. this.listLoading = true;
  370. console.log(this.port.project.userCost, '获取人员成本统计列表')
  371. console.log(this.user.timeType.fixMonthcost)
  372. console.log(Boolean(this.dateRange))
  373. let startDateNum = ''
  374. let endDateNum = ''
  375. if(this.dateRange) {
  376. startDateNum = this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange
  377. endDateNum = this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
  378. }
  379. // return
  380. this.http.post(this.port.project.userCost, {
  381. // startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange,
  382. // endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
  383. startDate: startDateNum,
  384. endDate: endDateNum
  385. },
  386. res => {
  387. this.listLoading = false;
  388. var _this = this;
  389. this.hasReportUserList = [];
  390. if (res.code == "ok") {
  391. //
  392. // var sss = []
  393. // var ddd = []
  394. // for(var i = 0; i < 120; i++) {
  395. // sss.push(res.data.list[0])
  396. // ddd.push(res.data.userList[0])
  397. // }
  398. // res.data.list = sss
  399. // res.data.userList = ddd
  400. for(var i in res.data.list) {
  401. if(i>20) {
  402. // this.widthHtval = +this.widthHtval + 2
  403. this.widthHtval = +this.widthHtval + 40
  404. } else {
  405. this.widthHtval = document.body.clientWidth - 230
  406. }
  407. }
  408. //
  409. this.personnelAll = res.data
  410. this.gtff(res.data)
  411. //工时总成本
  412. // this.hasReportUserList = res.data.userList;
  413. // var xList = [] yList = [] , list = res.data.list, array = [] , series = [];
  414. // var totalMoneyCost = res.data.totalCostMoney;
  415. // var totalHours = 0.0;
  416. // if (list.length > 0) {
  417. // var num = list.length==0?0:list[0].project.length;
  418. // for(var i in list) {
  419. // xList.push(list[i].name);
  420. // var pro = list[i].project;
  421. // for(var j in pro) {
  422. // if(array.indexOf(pro[j].project) == -1) {
  423. // array.push(pro[j].project)
  424. // }
  425. // }
  426. // }
  427. // for(var i in array) {
  428. // yList.push(array[i]);
  429. // var dataList = [];
  430. // for(var j in list) {
  431. // var project = list[j].project , num = 0;
  432. // if(project.length != 0) {
  433. // for(var k in project) {
  434. // if(project[k].project == array[i]) {
  435. // dataList.push({
  436. // "value": this.yAxisValue==0?project[k].money:project[k].time,
  437. // "cost": project[k].time,
  438. // "money":project[k].money
  439. // })
  440. // totalHours += parseFloat(project[k].time);
  441. // } else {
  442. // num++;
  443. // }
  444. // if(k == project.length-1 && num != project.length-1) {
  445. // dataList.push({
  446. // "value": 0,
  447. // "cost": 0,
  448. // "money":0,
  449. // })
  450. // }
  451. // }
  452. // } else {
  453. // dataList.push({
  454. // "value": 0,
  455. // "cost": 0,
  456. // "money":0,
  457. // })
  458. // }
  459. // }
  460. // series.push({
  461. // name: array[i],
  462. // type: 'bar',
  463. // stack:'1',
  464. // barMaxWidth: 30,
  465. // data: dataList,
  466. // })
  467. // }
  468. // }
  469. // var myChart = echarts.init(document.getElementById("container"));
  470. // totalHours = totalHours.toFixed(1);
  471. // // 设置宽度
  472. // myChart.resize({
  473. // width: this.widthHtval
  474. // })
  475. // // 设置宽度
  476. // _this.myChart = myChart;
  477. // var option = {
  478. // //总成本
  479. // title: {
  480. // text: '工时成本总计' + totalMoneyCost.toFixed(2) + '元, 时长'+totalHours+'小时',
  481. // left:'left',
  482. // },
  483. // // 工具箱
  484. // legend: {
  485. // x: 80,
  486. // y: 10,
  487. // data: yList,
  488. // show: true,
  489. //        top:"5%",//与上方的距离 可百分比% 可像素px
  490. // },
  491. // grid : {
  492. // top : 80, //距离容器上边界40像素
  493. // // bottom: 100, //距离容器下边界30像素
  494. // bottom: 35, //距离容器下边界30像素
  495. // left: 150,
  496. // right: 150
  497. // },
  498. // toolbox: {
  499. // show: true,
  500. // feature:{
  501. // saveAsImage:{
  502. // show:true
  503. // },
  504. // restore:{
  505. // show:true
  506. // },
  507. // // dataView:{
  508. // // show:true
  509. // // },
  510. // // dataZoom:{
  511. // // show:true
  512. // // },
  513. // magicType:{
  514. // type:['line','bar']
  515. // }
  516. // }
  517. // },
  518. // tooltip:{
  519. // trigger:'axis',
  520. // formatter: function (params,ticket,callback) {
  521. // var totalTime = 0;
  522. // var totalCost = 0;
  523. // var res = "";
  524. // for(var i in params) {
  525. // if (params[i].data.value > 0) {
  526. // res += "<div style='margin-top:3px;font-size:12px;'><font color='#ddd'>项目名称:" + params[i].seriesName
  527. // + "</font><br/>工作成本 : " + params[i].data.money
  528. // + "元 <br/>工作时长"+" : " + params[i].data.cost + "小时</br></div>";
  529. // totalTime += Number(params[i].data.cost);
  530. // totalCost += Number(params[i].data.money);
  531. // }
  532. // }
  533. // res = res +'<br/>'+ params[0].name+ '<br/>总计: ' + totalTime.toFixed(1)+'小时 '+totalCost.toFixed(2) + "元<br/>";
  534. // return res;
  535. // }
  536. // },
  537. // xAxis: {
  538. // data: xList,
  539. // axisLabel: {
  540. // interval:0,rotate:20
  541. // }
  542. // },
  543. // yAxis: [{
  544. // type : 'value',
  545. // axisLabel: {
  546. // formatter:this.yAxisValue==0?'{value} (元)':'{value} (小时)'
  547. // }
  548. // }],
  549. // series: series,
  550. // };
  551. // myChart.setOption(option,{notMerge:true});
  552. } else {
  553. this.$message({
  554. message: res.msg,
  555. type: "error"
  556. });
  557. }
  558. },
  559. error => {
  560. this.listLoading = false;
  561. this.$message({
  562. message: error,
  563. type: "error"
  564. });
  565. });
  566. },
  567. // 共同方法
  568. gtff(data) {
  569. var _this = this;
  570. this.hasReportUserList = data.userList;
  571. var xList = [] , yList = [] , list = data.list, array = [] , series = [];
  572. var totalMoneyCost = data.totalCostMoney;
  573. var totalHours = 0.0;
  574. if (list.length > 0) {
  575. var num = list.length==0?0:list[0].project.length;
  576. for(var i in list) {
  577. xList.push(list[i].name);
  578. var pro = list[i].project;
  579. for(var j in pro) {
  580. if(array.indexOf(pro[j].project) == -1) {
  581. array.push(pro[j].project)
  582. }
  583. }
  584. }
  585. for(var i in array) {
  586. yList.push(array[i]);
  587. var dataList = [];
  588. for(var j in list) {
  589. var project = list[j].project , num = 0;
  590. if(project.length != 0) {
  591. for(var k in project) {
  592. if(project[k].project == array[i]) {
  593. let item = {
  594. "value": this.yAxisValue==0?project[k].money:project[k].time,
  595. }
  596. if(this.permissions.countCost){
  597. item.money = project[k].money
  598. }
  599. if(this.permissions.countHours){
  600. item.cost = project[k].time
  601. totalHours += parseFloat(project[k].time);
  602. }
  603. dataList.push(item)
  604. } else {
  605. num++;
  606. }
  607. if(k == project.length-1 && num != project.length-1) {
  608. dataList.push({
  609. "value": 0,
  610. "cost": 0,
  611. "money":0,
  612. })
  613. }
  614. }
  615. } else {
  616. dataList.push({
  617. "value": 0,
  618. "cost": 0,
  619. "money":0,
  620. })
  621. }
  622. }
  623. series.push({
  624. name: array[i],
  625. type: 'bar',
  626. stack:'1',
  627. barMaxWidth: 30,
  628. data: dataList,
  629. })
  630. }
  631. }
  632. var myChart = echarts.init(document.getElementById("container"));
  633. totalHours = totalHours.toFixed(1);
  634. // 设置宽度
  635. myChart.resize({
  636. width: this.widthHtval
  637. })
  638. // 设置宽度
  639. _this.myChart = myChart;
  640. var option = {
  641. //总成本
  642. title: {
  643. // text: '工时成本总计' + totalMoneyCost.toFixed(2) + '元, 时长'+totalHours+'小时',
  644. text: '工时成本总计:' +
  645. ((this.permissions.countCost) ? '成本' + totalMoneyCost.toFixed(2) + '元,' : '') +
  646. ((this.permissions.countHours) ? '时长' + totalHours + '小时' : ''),
  647. left:'left',
  648. },
  649. // 工具箱
  650. legend: {
  651. x: 80,
  652. y: 10,
  653. data: yList,
  654. show: true,
  655.       top:"5%",//与上方的距离 可百分比% 可像素px
  656. },
  657. grid : {
  658. top : 80, //距离容器上边界40像素
  659. // bottom: 100, //距离容器下边界30像素
  660. bottom: 35, //距离容器下边界30像素
  661. left: 150,
  662. right: 150
  663. },
  664. toolbox: {
  665. show: true,
  666. feature:{
  667. saveAsImage:{
  668. show:true
  669. },
  670. restore:{
  671. show:true
  672. },
  673. // dataView:{
  674. // show:true
  675. // },
  676. // dataZoom:{
  677. // show:true
  678. // },
  679. magicType:{
  680. type:['line','bar']
  681. }
  682. }
  683. },
  684. tooltip:{
  685. trigger:'axis',
  686. formatter: function (params,ticket,callback) {
  687. var totalTime = 0;
  688. var totalCost = 0;
  689. var res = "";
  690. for(var i in params) {
  691. if (params[i].data.value > 0) {
  692. res += "<div style='margin-top:3px;font-size:12px;'><font color='#ddd'>项目名称:" + params[i].seriesName
  693. + "</font><br/>" +
  694. ((_this.permissions.countCost) ? "工作成本 : " + params[i].data.money + "元<br/>" : '') +
  695. ((_this.permissions.countHours) ? "工作时长 : " + params[i].data.cost + "小时</br>" : '') + "</div>";
  696. totalTime += Number(params[i].data.cost);
  697. totalCost += Number(params[i].data.money);
  698. }
  699. }
  700. res = res +'<br/>'+ params[0].name+ '<br/>总计: ' +
  701. ((_this.permissions.countHours) ? totalTime.toFixed(1) + '小时 ' : '') +
  702. ((_this.permissions.countCost) ? totalCost.toFixed(2) + "元" : '') +
  703. "<br/>";
  704. return res;
  705. }
  706. },
  707. xAxis: {
  708. data: xList,
  709. axisLabel: {
  710. interval:0,rotate:20
  711. }
  712. },
  713. yAxis: [{
  714. type : 'value',
  715. axisLabel: {
  716. formatter:this.yAxisValue==0?'{value} (元)':'{value} (小时)'
  717. }
  718. }],
  719. series: series,
  720. };
  721. myChart.setOption(option,{notMerge:true});
  722. },
  723. yanjiu() {
  724. console.log('触发')
  725. },
  726. getEchart(e){
  727. var that = this
  728. // 更具选中的名字筛选出对应的自定义id
  729. that.theCustomListFlg = false
  730. let ints = null
  731. for(var i in that.theCustomList) {
  732. if(that.radio == that.theCustomList[i].name) {
  733. that.theCustomListId = that.theCustomList[i].id
  734. that.theCustomListPlant = that.theCustomListPlantLIst[i]
  735. that.theCustomListFlg = true
  736. ints = i
  737. }
  738. }
  739. if(that.theCustomListFlg) {
  740. that.customList = that.theCustomList[ints].subUserCustomList
  741. that.customName = that.theCustomList[ints].subUserCustomList[0].name
  742. // that.getCusTom()
  743. }
  744. that.jieliu()
  745. },
  746. getCusTom() {
  747. this.http.post('/sub-user-custom/list',{
  748. userCustomId: this.theCustomListId
  749. },res => {
  750. if(res.code == 'ok'){
  751. this.customList = res.data
  752. this.customName = res.data[0].name
  753. }else {
  754. this.$message({
  755. message: res.msg,
  756. type: 'error'
  757. })
  758. }
  759. },error => {
  760. this.$message({
  761. message: error,
  762. type: 'error'
  763. })
  764. })
  765. },
  766. getCategoryList(){
  767. this.http.post('/project-category/list',{},
  768. res => {
  769. if(res.code == 'ok'){
  770. this.categoryList = res.data
  771. }else {
  772. this.$message({
  773. message: res.msg,
  774. type: 'error'
  775. })
  776. }
  777. },err => {
  778. this.$message({
  779. message: err,
  780. type: 'error'
  781. })
  782. })
  783. },
  784. backToParentDept() {
  785. if (this.radio == '部门') {
  786. if (this.parentDeptStack.length > 0) {
  787. this.parentDeptStack.pop();
  788. if (this.parentDeptStack.length > 0) {
  789. this.parentDeptId = this.parentDeptStack[this.parentDeptStack.length -1];
  790. } else {
  791. this.parentDeptId = null;
  792. }
  793. this.jieliu();
  794. }
  795. }
  796. },
  797. // 脱离出来的方法
  798. jieliu() {
  799. sessionStorage.radio = this.radio;
  800. var _this = this;
  801. var param = {};
  802. if (this.dateRange != null) {
  803. param = {
  804. startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange,
  805. endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
  806. };
  807. // console.log(param);
  808. }
  809. var url = '';
  810. if (this.radio=='项目') {
  811. url = this.port.project.listCost;
  812. }else if(this.radio == '主项目'){
  813. url = '/project/getTimeCostByMainProject'
  814. // param.userId = this.user.id
  815. }else if (this.radio=='项目分类') {
  816. url = '/project/getTimeCostByCategory';
  817. // param.parentDeptId = this.parentDeptId;
  818. // param.userId = this.user.id
  819. } else if (this.radio=='部门') {
  820. url = this.port.project.depCost;
  821. param.parentDeptId = this.parentDeptId;
  822. } else if (this.radio=='人员') {
  823. this.getUserCostList();
  824. return;
  825. } else if (this.radio == this.namess) {
  826. url = '/project/getDegreeCost'
  827. } else if (this.theCustomListFlg) {
  828. url = '/project/getTimeCostByUserCustom'
  829. // param.subCustomName = this.customName
  830. param.customId = this.theCustomListId
  831. param.fieldName = this.theCustomListPlant
  832. console.log(param, '要传的数据')
  833. }
  834. this.http.post(url, param,
  835. res => {
  836. if (res.code == "ok") {
  837. // 更具数据的长度去加每个柱子的间距
  838. for(var i in res.data.costList) {
  839. if(i>20) {
  840. this.widthHtval = +this.widthHtval + 40
  841. } else {
  842. this.widthHtval = document.body.clientWidth - 230
  843. }
  844. }
  845. // console.log(this.dayjs().add('0','day').format("YYYY-MM-DD HH:mm:ss"), '结束处理')
  846. // if(res.data.costList.length > 20) {
  847. // for(var i in res.data.costList) {
  848. // this.widthHtval = +this.widthHtval + 40
  849. // }
  850. // } else {
  851. // this.widthHtval = document.body.clientWidth - 230
  852. // }
  853. var xList = []
  854. var yList = []
  855. var list
  856. var totalMoneyCost;
  857. var totalHours = 0.0;
  858. if(this.radio == '项目' || this.radio == '项目分类' || this.radio=='部门' || this.radio == '主项目') {
  859. list = res.data.costList
  860. totalMoneyCost = ((this.radio=='项目' || this.radio == '项目分类')?res.data.totalMoneyCost:res.data.totalCostMoney);
  861. for(var i in list) {
  862. if(this.radio=='项目' || this.radio == '主项目') {
  863. if(this.radio == '项目'){
  864. xList.push(list[i].project);
  865. }else{
  866. xList.push(list[i].mainProjectName);
  867. }
  868. let item = {
  869. "value": this.yAxisValue==0?(list[i].costMoney ? list[i].costMoney.toFixed(2) : 0) || list[i].costMoney:(list[i].cost ? list[i].cost.toFixed(1) : 0),
  870. "id": list[i].id || i,
  871. }
  872. if(this.permissions.countCost){
  873. // item.money = list[i].costMoney.toFixed(2)
  874. item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
  875. }
  876. if(this.permissions.countHours){
  877. item.cost = list[i].cost
  878. totalHours += parseFloat(list[i].cost);
  879. }
  880. yList.push(item);
  881. } else if(this.radio == '部门'){
  882. xList.push(list[i].departmentName);
  883. let item = {
  884. // "value": this.yAxisValue==0 ? list[i].costMoney.toFixed(2) || list[i].costMoney: list[i].costTime.toFixed(1),
  885. "value": this.yAxisValue==0 ? (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0) || list[i].costMoney: (list[i].costTime ? list[i].costTime.toFixed(1) : 0),
  886. "id": list[i].departmentId,
  887. "hasSubDept": list[i].hasSubDept
  888. }
  889. if(this.permissions.countCost){
  890. // item.money = list[i].costMoney.toFixed(2)
  891. item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
  892. }
  893. if(this.permissions.countHours){
  894. item.cost = list[i].costTime
  895. totalHours += parseFloat(list[i].costTime);
  896. }
  897. yList.push(item);
  898. }else {
  899. xList.push(list[i].categoryName);
  900. let item = {
  901. // "value": this.yAxisValue==0?list[i].costMoney.toFixed(2) || list[i].costMoney:list[i].cost.toFixed(1),
  902. "value": this.yAxisValue==0?(list[i].costMoney ? list[i].costMoney.toFixed(2) : 0) || list[i].costMoney:(list[i].cost ? list[i].cost.toFixed(1) : 0),
  903. "id": list[i].id || i,
  904. }
  905. if(this.permissions.countCost){
  906. // item.money = list[i].costMoney.toFixed(2)
  907. item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
  908. }
  909. if(this.permissions.countHours){
  910. item.cost = list[i].cost
  911. totalHours += parseFloat(list[i].cost);
  912. }
  913. yList.push(item);
  914. }
  915. }
  916. }
  917. else if(this.theCustomListFlg) {
  918. list = res.data.list
  919. for(var i in list) {
  920. // console.log(list[i].name, list[i].costMoney, list[i].cost)
  921. xList.push(list[i].name);
  922. let item = {
  923. "value": this.yAxisValue==0?list[i].costMoney:list[i].cost,
  924. "id": list[i].id || i,
  925. }
  926. if(this.permissions.countCost){
  927. // item.money = list[i].costMoney.toFixed(2)
  928. item.money = list[i].costMoney ? list[i].costMoney.toFixed(2) : 0
  929. totalMoneyCost += parseFloat(list[i].costMoney);
  930. }
  931. if(this.permissions.countHours){
  932. item.cost = list[i].cost
  933. totalHours += parseFloat(list[i].cost);
  934. }
  935. yList.push(item);
  936. }
  937. }
  938. else {
  939. list = res.data
  940. for(var i in list) {
  941. // console.log(list[i].name, list[i].costMoney, list[i].cost)
  942. xList.push(list[i].name);
  943. let item = {
  944. "value": this.yAxisValue==0?list[i].costMoney:list[i].cost,
  945. "id": list[i].id || i,
  946. }
  947. if(this.permissions.countCost){
  948. // item.money = list[i].costMoney.toFixed(2)
  949. item.money = list[i].costMoney ? list[i].costMoney.toFixed(2) : 0
  950. totalMoneyCost += parseFloat(list[i].costMoney);
  951. }
  952. if(this.permissions.countHours){
  953. item.cost = list[i].cost
  954. totalHours += parseFloat(list[i].cost);
  955. }
  956. yList.push(item);
  957. }
  958. }
  959. totalHours = totalHours.toFixed(1);
  960. var myChart = echarts.init(document.getElementById("container"));
  961. myChart.resize({
  962. width: this.widthHtval
  963. })
  964. _this.myChart = myChart;
  965. // console.log(totalMoneyCost.toFixed(2), '看看', totalMoneyCost)
  966. // var chengbentongji = totalMoneyCost.toFixed(2) || totalMoneyCost
  967. if(totalMoneyCost) {
  968. this.zhishin = totalMoneyCost.toFixed(2)
  969. }
  970. if(this.radio == '项目' || this.radio == '主项目' || this.radio == '人员' || this.radio == '项目分类' || this.radio=='部门') {
  971. var option = {
  972. title: {
  973. text: '工时成本总计:' + ((this.permissions.countCost) ? '成本' + this.zhishin + '元,' : '') + ((this.permissions.countHours) ? '时长' + totalHours + '小时' : ''),
  974. left:'left',
  975. },
  976. // 工具箱
  977. toolbox: {
  978. show: true,
  979. feature:{
  980. saveAsImage:{show:true},restore:{show:true}, magicType:{ type:['line','bar']},
  981. }
  982. },
  983. tooltip:{
  984. trigger:'axis',
  985. formatter: function (params,ticket,callback) {
  986. // var res = params[0].name + "<br/>工作成本"+" : " + params[0].data.money
  987. // + "元 <br/>工作时长"+" : " + params[0].data.cost + "小时";
  988. _this.params = params;
  989. var res = params[0].name + "<br/>" +
  990. ((_this.permissions.countCost) ? "工作成本"+" : " + params[0].data.money
  991. + "元 <br/>" : '') +
  992. ((_this.permissions.countHours) ? "工作时长"+" : " + params[0].data.cost + "小时" : '');
  993. return res;
  994. }
  995. },
  996. xAxis: {
  997. data: xList,
  998. axisLabel: {
  999. interval:0,rotate:20
  1000. }
  1001. },
  1002. yAxis: [{
  1003. type : 'value',
  1004. axisLabel: {
  1005. formatter:this.yAxisValue==0?'{value} (元)':'{value}小时'
  1006. }
  1007. }],
  1008. series: [{
  1009. name: this.yAxisValue==0?'工作成本(元)':'工作时长(小时)',
  1010. type: 'bar',
  1011. barMaxWidth: 30,
  1012. data: yList,
  1013. }],
  1014. grid: {
  1015. left: '100px',
  1016. }
  1017. };
  1018. } else {
  1019. var option = {
  1020. title: {
  1021. // text: '工时成本总计' + this.zhishin + '元, 时长'+totalHours+'小时',
  1022. text: '工时成本总计:' + ((this.permissions.countCost) ? '成本' + this.zhishin + '元,' : '') + ((this.permissions.countHours) ? '时长' + totalHours + '小时' : ''),
  1023. left:'left',
  1024. },
  1025. // 工具箱
  1026. toolbox: {
  1027. show: true,
  1028. feature:{
  1029. saveAsImage:{show:true},restore:{show:true}, magicType:{ type:['line','bar']},
  1030. }
  1031. },
  1032. tooltip:{
  1033. trigger:'axis',
  1034. formatter: function (params,ticket,callback) {
  1035. var res = params[0].name + "<br/>" +
  1036. ((_this.permissions.countCost) ? "工作成本"+" : " + params[0].data.money
  1037. + "元 <br/>" : '') +
  1038. ((_this.permissions.countHours) ? "工作时长"+" : " + params[0].data.cost + "小时" : '');
  1039. _this.params = params;
  1040. return res;
  1041. }
  1042. },
  1043. xAxis: {
  1044. data: xList,
  1045. axisLabel: {
  1046. interval:0,rotate:20
  1047. }
  1048. },
  1049. yAxis: [{
  1050. type : 'value',
  1051. axisLabel: {
  1052. formatter:this.yAxisValue==0?'{value} (元)':'{value}小时'
  1053. }
  1054. }],
  1055. series: [{
  1056. name: this.yAxisValue==0?'工作成本(元)':'工作时长(小时)',
  1057. type: 'bar',
  1058. barMaxWidth: 30,
  1059. data: yList,
  1060. }],
  1061. grid: {
  1062. left: '100px',
  1063. }
  1064. };
  1065. }
  1066. myChart.setOption(option,{notMerge: true});
  1067. myChart.getZr().on('click', params => {
  1068. const pointInPixel = [params.offsetX, params.offsetY];
  1069. if (myChart.containPixel('grid', pointInPixel)) {
  1070. console.log(_this.params)
  1071. if(_this.radio=='项目') {
  1072. if (_this.dateRange != null) {
  1073. if (this.user.timeType.fixMonthcost == 0) {
  1074. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
  1075. +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
  1076. } else {
  1077. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
  1078. +"?startDate="+_this.dateRange+"&endDate="+_this.dateRange);
  1079. }
  1080. } else {
  1081. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name);
  1082. }
  1083. } else if (_this.radio=='部门') {
  1084. if (_this.params[0].data.hasSubDept) {
  1085. if (_this.parentDeptId != _this.params[0].data.id) {
  1086. _this.parentDeptId = _this.params[0].data.id;
  1087. _this.parentDeptStack.push(_this.parentDeptId);
  1088. _this.jieliu();
  1089. }
  1090. // _this.jieliu();
  1091. } else {
  1092. if (_this.dateRange != null) {
  1093. _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name
  1094. +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
  1095. } else {
  1096. _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name);
  1097. }
  1098. }
  1099. }
  1100. }
  1101. });
  1102. } else {
  1103. this.$message({
  1104. message: res.msg,
  1105. type: "error"
  1106. });
  1107. }
  1108. },
  1109. error => {
  1110. this.$message({
  1111. message: error,
  1112. type: "error"
  1113. });
  1114. });
  1115. },
  1116. // 左右滚动
  1117. scrollFunction () {
  1118. this.domObj = document.getElementById('clearfix') // 通过id获取要设置的div
  1119. if (this.domObj.attachEvent) { // IE
  1120. this.domObj.attachEvent('onmousewheel', this.mouseScroll)
  1121. } else if (this.domObj.addEventListener) {
  1122. this.domObj.addEventListener('DOMMouseScroll', this.mouseScroll, false)
  1123. }
  1124. this.domObj.onmousewheel = this.domObj.onmousewheel = this.mouseScroll
  1125. },
  1126. mouseScroll(event) { // google 浏览器下
  1127. let detail = event.wheelDelta || event.detail
  1128. let moveForwardStep = -1
  1129. let moveBackStep = 1
  1130. let step = 0
  1131. step = detail > 0 ? moveForwardStep * 100 : moveBackStep * 100
  1132. event.preventDefault() // 阻止浏览器默认事件
  1133. this.domObj.scrollLeft = this.domObj.scrollLeft + step
  1134. },
  1135. // 判断后端给的字段
  1136. // 获取自定义
  1137. getZDY() {
  1138. this.http.post('/user-custom/getUserCustomTitle',{},res => {
  1139. if(res.code == 'ok'){
  1140. console.log(res, '数据来源')
  1141. this.theCustomList = res.data.result
  1142. this.theCustomListPlantLIst = res.data.field
  1143. }else {
  1144. this.$message({
  1145. message: res.msg,
  1146. type: 'error'
  1147. })
  1148. }
  1149. },error => {
  1150. this.$message({
  1151. message: error,
  1152. type: 'error'
  1153. })
  1154. })
  1155. },
  1156. // 获取部门
  1157. getDepartmentList() {
  1158. this.http.post( this.port.manage.depList, {},
  1159. res => {
  1160. if (res.code == "ok") {
  1161. let dptlist = JSON.parse(JSON.stringify(res.data));
  1162. this.departmentList = this.changeArr(dptlist);
  1163. } else {
  1164. this.$message({
  1165. message: res.msg,
  1166. type: "error"
  1167. });
  1168. }
  1169. },error => {
  1170. this.$message({
  1171. message: error,
  1172. type: "error"
  1173. });
  1174. });
  1175. },
  1176. changeArr(arr) {
  1177. for (var i = 0; i < arr.length; i++) {
  1178. if(arr[i].id != -1 && arr[i].id != 0) {
  1179. if (arr[i].children != null && arr[i].children.length>0) {
  1180. arr[i].children = this.changeArr(arr[i].children);
  1181. }
  1182. arr[i].id && (arr[i].value = arr[i].id);
  1183. delete arr[i].id;
  1184. }
  1185. }
  1186. for(var i in arr) {
  1187. if(arr[i].id == -1 || arr[i].id == 0) {
  1188. arr.splice(i,1)
  1189. }
  1190. }
  1191. return arr;
  1192. },
  1193. },
  1194. created() {
  1195. this.myChart = null
  1196. },
  1197. mounted() {
  1198. this.containerHeight = window.innerHeight - 200
  1199. // this.containerHeight = window.innerHeight - 130
  1200. const that = this;
  1201. window.onresize = function temp() {
  1202. this.containerHeight = window.innerHeight - 130
  1203. // this.containerHeight = window.innerHeight - 200
  1204. };
  1205. if(this.permissions.countCost){
  1206. this.yAxisValue = '0'
  1207. }else{
  1208. this.yAxisValue = '1'
  1209. }
  1210. if (this.user.timeType.fixMonthcost == 0) {
  1211. if (this.$route.query.startDate != null) {
  1212. this.dateRange = [this.$route.query.startDate, this.$route.query.endDate];
  1213. } else {
  1214. //默认查看本月
  1215. var now = new Date();
  1216. var t = util.formatDate.format(now, 'yyyy-MM-dd');
  1217. var startStr = util.formatDate.format(new Date(), 'yyyy-MM') + "-01";
  1218. this.dateRange = [startStr,t];
  1219. }
  1220. this.exportParam.dateRange = this.dateRange;
  1221. } else if (this.user.timeType.fixMonthcost == 1) {
  1222. if (this.$route.query.startDate != null) {
  1223. this.dateRange = this.$route.query.startDate;
  1224. } else {
  1225. //默认查看本月
  1226. var startStr = util.formatDate.format(new Date(), 'yyyy-MM');
  1227. this.dateRange = startStr;
  1228. }
  1229. this.exportParam.dateRange = this.dateRange;
  1230. }
  1231. this.radio = '项目'
  1232. this.getEchart();
  1233. var _this = this;
  1234. window.addEventListener("resize", function() {
  1235. _this.myChart.resize();
  1236. });
  1237. // this.getDepartment();
  1238. this.getMyProjectList();
  1239. this.getUsers()
  1240. this.jutishez()
  1241. this.scrollFunction()
  1242. // 判断
  1243. if(this.user.timeType.userCustomStatic) {
  1244. this.getZDY()
  1245. }
  1246. this.getDepartmentList()
  1247. },
  1248. beforeDestroy () {
  1249. var myChart = echarts.init(document.getElementById("container"));
  1250. myChart.clear()
  1251. },
  1252. };
  1253. </script>
  1254. <style lang="scss" scoped>
  1255. #container {
  1256. // display: inline-block;
  1257. display: block;
  1258. position: absolute;
  1259. // width: 100% !important;
  1260. margin-top: 60px;
  1261. }
  1262. .ryuans {
  1263. top: -50px;
  1264. }
  1265. .prompt {
  1266. position: absolute;
  1267. right: 10px;
  1268. top: 0;
  1269. }
  1270. </style>
  1271. <style lang="scss">
  1272. </style>