cost.vue 68 KB

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