cost.vue 68 KB

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