cost.vue 64 KB

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