cost.vue 67 KB

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