cost.vue 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300
  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. if(this.user.userNameNeedTranslate == '1') {
  426. let list = res.data.list
  427. let dealWithList = []
  428. for(var i in list) {
  429. let obj = {}
  430. obj.type = list[i].type
  431. obj.id = list[i].name
  432. dealWithList.push(obj)
  433. }
  434. this.dealWithTranslationPlone(dealWithList, res.data.list)
  435. } else {
  436. this.personnelAll = res.data
  437. this.allListData = res.data
  438. this.gtff()
  439. }
  440. } else {
  441. this.$message({
  442. message: res.msg + '里面',
  443. type: "error"
  444. });
  445. }
  446. },
  447. error => {
  448. this.listLoading = false;
  449. this.$message({
  450. message: error + '外面',
  451. type: "error"
  452. });
  453. });
  454. },
  455. // 共同方法
  456. gtff() {
  457. let data = this.allListData
  458. var _this = this;
  459. this.hasReportUserList = data.userList;
  460. this.total = data.list.length
  461. var xList = [] , yList = [] , list = data.list.slice(0+50*(this.page-1),49+50*(this.page-1)), array = [] , series = [];
  462. var totalMoneyCost = data.totalCostMoney;
  463. var totalHours = 0.0;
  464. for(var i in list) {
  465. if(i>20) {
  466. this.widthHtval = +this.widthHtval + 60
  467. } else {
  468. this.widthHtval = document.body.clientWidth - 230
  469. }
  470. }
  471. if (list.length > 0) {
  472. var num = list.length==0?0:list[0].project.length;
  473. // console.log('for 1');
  474. for(var i in list) {
  475. xList.push(list[i].name);
  476. var pro = list[i].project;
  477. for(var j in pro) {
  478. if(array.indexOf(pro[j].project) == -1) {
  479. array.push(pro[j].project)
  480. }
  481. }
  482. }
  483. // console.log('for 2');
  484. for(var i in array) {
  485. yList.push(array[i]);
  486. var dataList = [];
  487. // console.log('for 2 1');
  488. for(var j in list) {
  489. var project = list[j].project , num = 0;
  490. if(project.length != 0) {
  491. // console.log('for 2 1 1');
  492. for(var k in project) {
  493. if(project[k].project == array[i]) {
  494. let item = {
  495. "value": this.yAxisValue==0?project[k].money:project[k].time,
  496. }
  497. if(this.permissions.countCost){
  498. item.money = project[k].money
  499. }
  500. if(this.permissions.countHours){
  501. item.cost = project[k].time
  502. totalHours += parseFloat(project[k].time);
  503. }
  504. dataList.push(item)
  505. } else {
  506. num++;
  507. }
  508. if(k == project.length-1 && num != project.length-1) {
  509. dataList.push({
  510. "value": 0,
  511. "cost": 0,
  512. "money":0,
  513. })
  514. }
  515. }
  516. } else {
  517. dataList.push({
  518. "value": 0,
  519. "cost": 0,
  520. "money":0,
  521. })
  522. }
  523. }
  524. series.push({
  525. name: array[i],
  526. type: 'bar',
  527. stack:'1',
  528. barMaxWidth: 30,
  529. data: dataList,
  530. })
  531. }
  532. }
  533. var myChart = echarts.init(document.getElementById("container"));
  534. totalHours = totalHours.toFixed(1);
  535. // 设置宽度
  536. myChart.resize({
  537. width: this.widthHtval
  538. })
  539. // console.log('设置宽度');
  540. // 设置宽度
  541. _this.myChart = myChart;
  542. var option = {
  543. //总成本
  544. title: {
  545. // text: '工时成本总计' + totalMoneyCost.toFixed(2) + '元, 时长'+totalHours+'小时',
  546. text: this.$t('otalhourscost')+ ':' +
  547. ((this.permissions.countCost) ? this.$t('costof') + ' ' + totalMoneyCost.toFixed(2) + ' ' + this.$t('yuan') + ',' : '') +
  548. ((this.permissions.countHours) ? this.$t('time.duration') + ' ' +totalHours + ' ' + this.$t('time.hour') : ''),
  549. left:'left',
  550. },
  551. // 工具箱
  552. legend: {
  553. x: 80,
  554. y: 10,
  555. data: yList,
  556. show: true,
  557.       top:"5%",//与上方的距离 可百分比% 可像素px
  558. },
  559. grid : {
  560. top : 80, //距离容器上边界40像素
  561. // bottom: 100, //距离容器下边界30像素
  562. bottom: 35, //距离容器下边界30像素
  563. left: 150,
  564. right: 150
  565. },
  566. toolbox: {
  567. show: true,
  568. feature:{
  569. saveAsImage:{
  570. show:true
  571. },
  572. restore:{
  573. show:true
  574. },
  575. // dataView:{
  576. // show:true
  577. // },
  578. // dataZoom:{
  579. // show:true
  580. // },
  581. magicType:{
  582. type:['line','bar']
  583. }
  584. }
  585. },
  586. tooltip:{
  587. trigger:'axis',
  588. formatter: function (params,ticket,callback) {
  589. var totalTime = 0;
  590. var totalCost = 0;
  591. var res = "";
  592. for(var i in params) {
  593. if (params[i].data.value > 0) {
  594. res += "<div style='margin-top:3px;font-size:12px;'><font color='#ddd'>" + _this.$t('headerTop.projectName') + ":" + params[i].seriesName
  595. + "</font><br/>" +
  596. ((_this.permissions.countCost) ? _this.$t('workcost')+ ":" + params[i].data.money + _this.$t('yuan') + "</br>" : '') +
  597. ((_this.permissions.countHours) ? _this.$t('screening.workTime') + ":" + params[i].data.cost + _this.$t('time.hour') + "</br>" : '') + "</div>";
  598. totalTime += Number(params[i].data.cost);
  599. totalCost += Number(params[i].data.money);
  600. }
  601. }
  602. if(_this.user.userNameNeedTranslate != 1) {
  603. res = res +'<br/>'+ params[0].name+ '<br/>' + _this.$t('zong-ji') + ':' +
  604. ((_this.permissions.countHours) ? totalTime.toFixed(1) + _this.$t('time.hour') : '') +
  605. ((_this.permissions.countCost) ? totalCost.toFixed(2) + _this.$t('yuan') : '') +
  606. "<br/>";
  607. } else {
  608. res = res +'<br/>'+ '' + '<br/>' + _this.$t('zong-ji') + ':' +
  609. ((_this.permissions.countHours) ? totalTime.toFixed(1) + _this.$t('time.hour') : '') +
  610. ((_this.permissions.countCost) ? totalCost.toFixed(2) + _this.$t('yuan') : '') +
  611. "<br/>";
  612. }
  613. return res;
  614. }
  615. },
  616. xAxis: {
  617. data: xList,
  618. axisLabel: {
  619. interval:0,rotate:20
  620. }
  621. },
  622. yAxis: [{
  623. type : 'value',
  624. axisLabel: {
  625. formatter:this.yAxisValue==0?'{value} ('+this.$t('yuan')+')':'{value} ('+this.$t('time.hour')+')'
  626. // formatter:this.yAxisValue==0?'{value} (元)':'{value} (小时)'
  627. }
  628. }],
  629. series: series,
  630. };
  631. // console.log('setoption');
  632. myChart.setOption(option,{notMerge:true});
  633. },
  634. yanjiu() {
  635. // console.log('触发')
  636. },
  637. getEchart(e){
  638. var that = this
  639. // 更具选中的名字筛选出对应的自定义id
  640. that.theCustomListFlg = false
  641. let ints = null
  642. for(var i in that.theCustomList) {
  643. if(that.radio == that.theCustomList[i].name) {
  644. that.theCustomListId = that.theCustomList[i].id
  645. that.theCustomListPlant = that.theCustomListPlantLIst[i]
  646. that.theCustomListFlg = true
  647. ints = i
  648. }
  649. }
  650. if(that.theCustomListFlg) {
  651. that.customList = that.theCustomList[ints].subUserCustomList
  652. that.customName = that.theCustomList[ints].subUserCustomList[0].name
  653. // that.getCusTom()
  654. }
  655. that.jieliu()
  656. },
  657. getCusTom() {
  658. this.http.post('/sub-user-custom/list',{
  659. userCustomId: this.theCustomListId
  660. },res => {
  661. if(res.code == 'ok'){
  662. this.customList = res.data
  663. this.customName = res.data[0].name
  664. }else {
  665. this.$message({
  666. message: res.msg,
  667. type: 'error'
  668. })
  669. }
  670. },error => {
  671. this.$message({
  672. message: error,
  673. type: 'error'
  674. })
  675. })
  676. },
  677. getCategoryList(){
  678. this.http.post('/project-category/list',{},
  679. res => {
  680. if(res.code == 'ok'){
  681. this.categoryList = res.data
  682. }else {
  683. this.$message({
  684. message: res.msg,
  685. type: 'error'
  686. })
  687. }
  688. },err => {
  689. this.$message({
  690. message: err,
  691. type: 'error'
  692. })
  693. })
  694. },
  695. backToParentDept() {
  696. if (this.radio == this.$t('lable.department')) {
  697. if (this.parentDeptStack.length > 0) {
  698. this.parentDeptStack.pop();
  699. if (this.parentDeptStack.length > 0) {
  700. this.parentDeptId = this.parentDeptStack[this.parentDeptStack.length -1];
  701. } else {
  702. this.parentDeptId = null;
  703. }
  704. this.jieliu();
  705. }
  706. }
  707. },
  708. // 脱离出来的方法
  709. jieliu() {
  710. sessionStorage.radio = this.radio;
  711. var param = {};
  712. if (this.dateRange != null) {
  713. param = {
  714. startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange,
  715. endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
  716. };
  717. // console.log(param);
  718. }
  719. var url = '';
  720. if (this.radio==this.$t('other.project')) {
  721. url = this.port.project.listCost;
  722. }else if(this.radio == this.$t('zhu-xiang-mu')){
  723. url = '/project/getTimeCostByMainProject'
  724. // param.userId = this.user.id
  725. }else if (this.radio==this.$t('projectclassification')) {
  726. url = '/project/getTimeCostByCategory';
  727. // param.parentDeptId = this.parentDeptId;
  728. // param.userId = this.user.id
  729. } else if (this.radio==this.$t('lable.department')) {
  730. url = this.port.project.depCost;
  731. param.parentDeptId = this.parentDeptId;
  732. } else if (this.radio==this.$t('ren-yuan')) {
  733. this.getUserCostList();
  734. return;
  735. } else if (this.radio == this.namess) {
  736. url = '/project/getDegreeCost'
  737. } else if (this.theCustomListFlg) {
  738. url = '/project/getTimeCostByUserCustom'
  739. // param.subCustomName = this.customName
  740. param.customId = this.theCustomListId
  741. param.fieldName = this.theCustomListPlant
  742. // console.log(param, '要传的数据')
  743. }
  744. this.http.post(url, param,
  745. res => {
  746. if (res.code == "ok") {
  747. // additionName // 未转译的数据另外存储一份,用作 DOM 上渲染
  748. if(this.user.userNameNeedTranslate == '1') {
  749. for(var i in res.data.costList) {
  750. res.data.costList[i].additionName = res.data.costList[i].departmentName
  751. }
  752. }
  753. this.allListData = res.data
  754. console.log(this.allListData, '部门数据')
  755. this.page = 1
  756. if(this.user.userNameNeedTranslate == '1' && this.radio == this.$t('lable.department')) {
  757. console.log('进入我处理的方法')
  758. let arr = []
  759. for(var i in this.allListData.costList) {
  760. let obj = {}
  761. obj.type = this.allListData.costList[i].type
  762. obj.id = this.allListData.costList[i].departmentName
  763. arr.push(obj)
  764. }
  765. this.dealWithTranslation(arr)
  766. } else {
  767. this.jieliu_echarts()
  768. }
  769. } else {
  770. this.$message({
  771. message: res.msg,
  772. type: "error"
  773. });
  774. }
  775. },
  776. error => {
  777. this.$message({
  778. message: error,
  779. type: "error"
  780. });
  781. });
  782. },
  783. dealWithTranslation(items) {
  784. if (WWOpenData.initCanvas) {
  785. WWOpenData.initCanvas()
  786. }
  787. const myFunOne = async () => {
  788. const result = await new Promise((resolve, reject) => {
  789. if(WWOpenData.prefetch) {
  790. WWOpenData.prefetch({ items }, (err, data) => {
  791. console.log(items)
  792. console.log(err)
  793. console.log(data)
  794. if (err) { return reject(err) }
  795. resolve(data)
  796. })
  797. }
  798. })
  799. for(var i in this.allListData.costList) {
  800. this.allListData.costList[i].departmentName = result.items[i].data
  801. }
  802. this.jieliu_echarts()
  803. }
  804. myFunOne()
  805. },
  806. dealWithTranslationPlone(items, dataList) {
  807. if (WWOpenData.initCanvas) {
  808. WWOpenData.initCanvas()
  809. }
  810. const myFunOne = async () => {
  811. const result = await new Promise((resolve, reject) => {
  812. if(WWOpenData.prefetch) {
  813. WWOpenData.prefetch({ items }, (err, data) => {
  814. if (err) { return reject(err) }
  815. resolve(data)
  816. })
  817. }
  818. })
  819. for(var i in this.allListData.list) {
  820. this.allListData.list[i].name = result.items[i].data
  821. }
  822. this.gtff()
  823. }
  824. myFunOne()
  825. },
  826. jieliu_echarts(){
  827. var _this = this;
  828. // 更具数据的长度去加每个柱子的间距
  829. var xList = []
  830. var yList = []
  831. var list
  832. var totalMoneyCost;
  833. var totalHours = 0.0;
  834. 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')) {
  835. // this.allListData = res.data.costList
  836. this.total = this.allListData.costList.length
  837. list = this.allListData.costList.slice(0+50*(this.page-1),49+50*(this.page-1))
  838. for(var i in list) {
  839. if(i>20) {
  840. this.widthHtval = +this.widthHtval + 60
  841. } else {
  842. this.widthHtval = document.body.clientWidth - 230
  843. }
  844. }
  845. // list = res.data.costList
  846. totalMoneyCost = ((this.radio==this.$t('other.project') || this.radio == this.$t('projectclassification'))?this.allListData.totalMoneyCost:this.allListData.totalCostMoney);
  847. for(var i in list) {
  848. if(this.radio==this.$t('other.project') || this.radio == this.$t('zhu-xiang-mu')) {
  849. if(this.radio == this.$t('other.project')){
  850. xList.push(list[i].project);
  851. }else{
  852. xList.push(list[i].mainProjectName);
  853. }
  854. let item = {
  855. "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),
  856. "id": list[i].id || i,
  857. }
  858. if(this.permissions.countCost){
  859. // item.money = list[i].costMoney.toFixed(2)
  860. item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
  861. }
  862. if(this.permissions.countHours){
  863. item.cost = list[i].cost
  864. totalHours += parseFloat(list[i].cost);
  865. }
  866. yList.push(item);
  867. } else if(this.radio == this.$t('lable.department')){
  868. xList.push(list[i].departmentName);
  869. let item = {
  870. // "value": this.yAxisValue==0 ? list[i].costMoney.toFixed(2) || list[i].costMoney: list[i].costTime.toFixed(1),
  871. "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),
  872. "id": list[i].departmentId,
  873. "hasSubDept": list[i].hasSubDept
  874. }
  875. if(this.permissions.countCost){
  876. // item.money = list[i].costMoney.toFixed(2)
  877. item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
  878. }
  879. if(this.permissions.countHours){
  880. item.cost = list[i].costTime
  881. totalHours += parseFloat(list[i].costTime);
  882. }
  883. yList.push(item);
  884. }else {
  885. xList.push(list[i].categoryName);
  886. let item = {
  887. // "value": this.yAxisValue==0?list[i].costMoney.toFixed(2) || list[i].costMoney:list[i].cost.toFixed(1),
  888. "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),
  889. "id": list[i].id || i,
  890. }
  891. if(this.permissions.countCost){
  892. // item.money = list[i].costMoney.toFixed(2)
  893. item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
  894. }
  895. if(this.permissions.countHours){
  896. item.cost = list[i].cost
  897. totalHours += parseFloat(list[i].cost);
  898. }
  899. yList.push(item);
  900. }
  901. }
  902. }
  903. else if(this.theCustomListFlg) {
  904. // this.allListData = res.data.list
  905. this.total = this.allListData.list.length
  906. list = this.allListData.list.slice(0+50*(this.page-1),49+50*(this.page-1))
  907. // list = res.data.list
  908. for(var i in list) {
  909. // console.log(list[i].name, list[i].costMoney, list[i].cost)
  910. xList.push(list[i].name);
  911. let item = {
  912. "value": this.yAxisValue==0?list[i].costMoney:list[i].cost,
  913. "id": list[i].id || i,
  914. }
  915. if(this.permissions.countCost){
  916. // item.money = list[i].costMoney.toFixed(2)
  917. item.money = list[i].costMoney ? list[i].costMoney.toFixed(2) : 0
  918. totalMoneyCost += parseFloat(list[i].costMoney);
  919. }
  920. if(this.permissions.countHours){
  921. item.cost = list[i].cost
  922. totalHours += parseFloat(list[i].cost);
  923. }
  924. yList.push(item);
  925. }
  926. }
  927. else {
  928. // list = res.data
  929. // this.allListData = res.data
  930. this.total = this.allListData.length
  931. list = this.allListData.slice(0+50*(this.page-1),49+50*(this.page-1))
  932. for(var i in list) {
  933. // console.log(list[i].name, list[i].costMoney, list[i].cost)
  934. xList.push(list[i].name);
  935. let item = {
  936. "value": this.yAxisValue==0?list[i].costMoney:list[i].cost,
  937. "id": list[i].id || i,
  938. }
  939. if(this.permissions.countCost){
  940. // item.money = list[i].costMoney.toFixed(2)
  941. item.money = list[i].costMoney ? list[i].costMoney.toFixed(2) : 0
  942. totalMoneyCost += parseFloat(list[i].costMoney);
  943. }
  944. if(this.permissions.countHours){
  945. item.cost = list[i].cost
  946. totalHours += parseFloat(list[i].cost);
  947. }
  948. yList.push(item);
  949. }
  950. }
  951. totalHours = totalHours.toFixed(1);
  952. var myChart = echarts.init(document.getElementById("container"));
  953. myChart.resize({
  954. width: this.widthHtval
  955. })
  956. _this.myChart = myChart;
  957. // console.log(totalMoneyCost.toFixed(2), '看看', totalMoneyCost)
  958. // var chengbentongji = totalMoneyCost.toFixed(2) || totalMoneyCost
  959. if(totalMoneyCost) {
  960. this.zhishin = totalMoneyCost.toFixed(2)
  961. }
  962. 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')) {
  963. var option = {
  964. title: {
  965. 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') : ''),
  966. left:'left',
  967. },
  968. // 工具箱
  969. toolbox: {
  970. show: true,
  971. feature:{
  972. saveAsImage:{show:true},restore:{show:true}, magicType:{ type:['line','bar']},
  973. }
  974. },
  975. tooltip:{
  976. trigger:'axis',
  977. formatter: function (params,ticket,callback) {
  978. _this.params = params;
  979. var res
  980. if(_this.user.userNameNeedTranslate != '1') {
  981. var res = params[0].name + "<br/>" +
  982. ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
  983. + _this.$t('yuan')+"<br/>" : '') +
  984. ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
  985. } else {
  986. var res = "<ww-open-data type='departmentName' :openid='"+ _this.allListData.costList[params[0].dataIndex].additionName +"'></ww-open-data>" + "<br/>" +
  987. ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
  988. + _this.$t('yuan')+"<br/>" : '') +
  989. ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
  990. }
  991. return res;
  992. }
  993. },
  994. xAxis: {
  995. data: xList,
  996. axisLabel: {
  997. interval:0,rotate:20
  998. }
  999. },
  1000. yAxis: [{
  1001. type : 'value',
  1002. axisLabel: {
  1003. formatter:this.yAxisValue==0?'{value} ('+this.$t('yuan')+')':'{value}'+this.$t('time.hour')
  1004. }
  1005. }],
  1006. series: [{
  1007. name: this.yAxisValue==0?this.$t('workcost')+'('+this.$t('yuan')+')':this.$t('screening.workTime')+'('+this.$t('time.hour')+')',
  1008. type: 'bar',
  1009. barMaxWidth: 30,
  1010. data: yList,
  1011. }],
  1012. grid: {
  1013. left: '100px',
  1014. }
  1015. };
  1016. } else {
  1017. var option = {
  1018. title: {
  1019. // text: '工时成本总计' + this.zhishin + '元, 时长'+totalHours+'小时',
  1020. 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') : ''),
  1021. left:'left',
  1022. },
  1023. // 工具箱
  1024. toolbox: {
  1025. show: true,
  1026. feature:{
  1027. saveAsImage:{show:true},restore:{show:true}, magicType:{ type:['line','bar']},
  1028. }
  1029. },
  1030. tooltip:{
  1031. trigger:'axis',
  1032. formatter: function (params,ticket,callback) {
  1033. var res = params[0].name + "<br/>" +
  1034. ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
  1035. + _this.$t('yuan')+"<br/>" : '') +
  1036. ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
  1037. _this.params = params;
  1038. return res;
  1039. }
  1040. },
  1041. xAxis: {
  1042. data: xList,
  1043. axisLabel: {
  1044. interval:0,rotate:20
  1045. }
  1046. },
  1047. yAxis: [{
  1048. type : 'value',
  1049. axisLabel: {
  1050. formatter:this.yAxisValue==0?'{value} ('+this.$t('yuan')+')':'{value}'+this.$t('time.hour')
  1051. }
  1052. }],
  1053. series: [{
  1054. name: this.yAxisValue==0?this.$t('workcost')+'('+this.$t('yuan')+')':this.$t('screening.workTime')+'('+this.$t('time.hour')+')',
  1055. type: 'bar',
  1056. barMaxWidth: 30,
  1057. data: yList,
  1058. }],
  1059. grid: {
  1060. left: '100px',
  1061. }
  1062. };
  1063. }
  1064. myChart.setOption(option,{notMerge: true});
  1065. myChart.getZr().on('click', params => {
  1066. const pointInPixel = [params.offsetX, params.offsetY];
  1067. if (myChart.containPixel('grid', pointInPixel)) {
  1068. // console.log(_this.params)
  1069. if(_this.radio==this.$t('other.project')) {
  1070. if (_this.dateRange != null) {
  1071. if (this.user.timeType.fixMonthcost == 0) {
  1072. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
  1073. +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
  1074. } else {
  1075. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
  1076. +"?startDate="+_this.dateRange+"&endDate="+_this.dateRange);
  1077. }
  1078. } else {
  1079. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name);
  1080. }
  1081. } else if (_this.radio==this.$t('lable.department')) {
  1082. if (_this.params[0].data.hasSubDept) {
  1083. if (_this.parentDeptId != _this.params[0].data.id) {
  1084. _this.parentDeptId = _this.params[0].data.id;
  1085. _this.parentDeptStack.push(_this.parentDeptId);
  1086. _this.jieliu();
  1087. }
  1088. // _this.jieliu();
  1089. } else {
  1090. if (_this.dateRange != null) {
  1091. _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name
  1092. +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
  1093. } else {
  1094. _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name);
  1095. }
  1096. }
  1097. }
  1098. }
  1099. });
  1100. },
  1101. // 左右滚动
  1102. scrollFunction () {
  1103. this.domObj = document.getElementById('clearfix') // 通过id获取要设置的div
  1104. if (this.domObj.attachEvent) { // IE
  1105. this.domObj.attachEvent('onmousewheel', this.mouseScroll)
  1106. } else if (this.domObj.addEventListener) {
  1107. this.domObj.addEventListener('DOMMouseScroll', this.mouseScroll, false)
  1108. }
  1109. this.domObj.onmousewheel = this.domObj.onmousewheel = this.mouseScroll
  1110. },
  1111. mouseScroll(event) { // google 浏览器下
  1112. let detail = event.wheelDelta || event.detail
  1113. let moveForwardStep = -1
  1114. let moveBackStep = 1
  1115. let step = 0
  1116. step = detail > 0 ? moveForwardStep * 100 : moveBackStep * 100
  1117. event.preventDefault() // 阻止浏览器默认事件
  1118. this.domObj.scrollLeft = this.domObj.scrollLeft + step
  1119. },
  1120. // 判断后端给的字段
  1121. // 获取自定义
  1122. getZDY() {
  1123. this.http.post('/user-custom/getUserCustomTitle',{},res => {
  1124. if(res.code == 'ok'){
  1125. // console.log(res, '数据来源')
  1126. this.theCustomList = res.data.result
  1127. this.theCustomListPlantLIst = res.data.field
  1128. }else {
  1129. this.$message({
  1130. message: res.msg,
  1131. type: 'error'
  1132. })
  1133. }
  1134. },error => {
  1135. this.$message({
  1136. message: error,
  1137. type: 'error'
  1138. })
  1139. })
  1140. },
  1141. // 获取部门
  1142. getDepartmentList() {
  1143. this.http.post( this.port.manage.depList, {},
  1144. res => {
  1145. if (res.code == "ok") {
  1146. let dptlist = JSON.parse(JSON.stringify(res.data));
  1147. this.departmentList = this.changeArr(dptlist);
  1148. } else {
  1149. this.$message({
  1150. message: res.msg,
  1151. type: "error"
  1152. });
  1153. }
  1154. },error => {
  1155. this.$message({
  1156. message: error,
  1157. type: "error"
  1158. });
  1159. });
  1160. },
  1161. changeArr(arr) {
  1162. for (var i = 0; i < arr.length; i++) {
  1163. if(arr[i].id != -1 && arr[i].id != 0) {
  1164. if (arr[i].children != null && arr[i].children.length>0) {
  1165. arr[i].children = this.changeArr(arr[i].children);
  1166. }
  1167. arr[i].id && (arr[i].value = arr[i].id);
  1168. delete arr[i].id;
  1169. }
  1170. }
  1171. for(var i in arr) {
  1172. if(arr[i].id == -1 || arr[i].id == 0) {
  1173. arr.splice(i,1)
  1174. }
  1175. }
  1176. return arr;
  1177. },
  1178. },
  1179. created() {
  1180. this.myChart = null
  1181. },
  1182. mounted() {
  1183. this.containerHeight = window.innerHeight - 200
  1184. // this.containerHeight = window.innerHeight - 130
  1185. const that = this;
  1186. window.onresize = function temp() {
  1187. this.containerHeight = window.innerHeight - 130
  1188. // this.containerHeight = window.innerHeight - 200
  1189. };
  1190. if(this.permissions.countCost){
  1191. this.yAxisValue = '0'
  1192. }else{
  1193. this.yAxisValue = '1'
  1194. }
  1195. if (this.user.timeType.fixMonthcost == 0) {
  1196. if (this.$route.query.startDate != null) {
  1197. this.dateRange = [this.$route.query.startDate, this.$route.query.endDate];
  1198. } else {
  1199. //默认查看本月
  1200. var now = new Date();
  1201. var t = util.formatDate.format(now, 'yyyy-MM-dd');
  1202. var startStr = util.formatDate.format(new Date(), 'yyyy-MM') + "-01";
  1203. this.dateRange = [startStr,t];
  1204. }
  1205. this.exportParam.dateRange = this.dateRange;
  1206. } else if (this.user.timeType.fixMonthcost == 1) {
  1207. if (this.$route.query.startDate != null) {
  1208. this.dateRange = this.$route.query.startDate;
  1209. } else {
  1210. //默认查看本月
  1211. var startStr = util.formatDate.format(new Date(), 'yyyy-MM');
  1212. this.dateRange = startStr;
  1213. }
  1214. this.exportParam.dateRange = this.dateRange;
  1215. }
  1216. this.radio = this.$t('other.project')
  1217. this.getEchart();
  1218. var _this = this;
  1219. window.addEventListener("resize", function() {
  1220. _this.myChart.resize();
  1221. });
  1222. // this.getDepartment();
  1223. this.getMyProjectList();
  1224. this.getUsers()
  1225. this.jutishez()
  1226. this.scrollFunction()
  1227. // 判断
  1228. if(this.user.timeType.userCustomStatic) {
  1229. this.getZDY()
  1230. }
  1231. this.getDepartmentList()
  1232. },
  1233. beforeDestroy () {
  1234. var myChart = echarts.init(document.getElementById("container"));
  1235. myChart.clear()
  1236. },
  1237. };
  1238. </script>
  1239. <style lang="scss" scoped>
  1240. #container {
  1241. // display: inline-block;
  1242. display: block;
  1243. position: absolute;
  1244. // width: 100% !important;
  1245. margin-top: 60px;
  1246. }
  1247. .ryuans {
  1248. top: -50px;
  1249. }
  1250. .prompt {
  1251. position: absolute;
  1252. right: 10px;
  1253. top: 0;
  1254. }
  1255. .poss {
  1256. position: fixed;
  1257. bottom: -10px;
  1258. right: 1%;
  1259. box-sizing: border-box;
  1260. }
  1261. </style>
  1262. <style lang="scss">
  1263. </style>