cost.vue 69 KB

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