cost.vue 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341
  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. // list = res.data
  942. // this.allListData = res.data
  943. this.total = this.allListData.list.length
  944. list = this.allListData.list.slice(0+50*(this.page-1),49+50*(this.page-1))
  945. for(var i in list) {
  946. // console.log(list[i].name, list[i].costMoney, list[i].cost)
  947. xList.push(list[i].name);
  948. let item = {
  949. "value": this.yAxisValue==0?list[i].costMoney:list[i].cost,
  950. "id": list[i].id || i,
  951. }
  952. if(this.permissions.countCost){
  953. // item.money = list[i].costMoney.toFixed(2)
  954. item.money = list[i].costMoney ? list[i].costMoney.toFixed(2) : 0
  955. totalMoneyCost += parseFloat(list[i].costMoney);
  956. }
  957. if(this.permissions.countHours){
  958. item.cost = list[i].cost
  959. totalHours += parseFloat(list[i].cost);
  960. }
  961. yList.push(item);
  962. }
  963. }
  964. totalHours = totalHours.toFixed(1);
  965. var myChart = echarts.init(document.getElementById("container"));
  966. myChart.resize({
  967. width: this.widthHtval
  968. })
  969. _this.myChart = myChart;
  970. // console.log(totalMoneyCost.toFixed(2), '看看', totalMoneyCost)
  971. // var chengbentongji = totalMoneyCost.toFixed(2) || totalMoneyCost
  972. if(totalMoneyCost) {
  973. this.zhishin = totalMoneyCost.toFixed(2)
  974. }
  975. 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')) {
  976. var option = {
  977. title: {
  978. 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') : ''),
  979. left:'left',
  980. },
  981. // 工具箱
  982. toolbox: {
  983. show: true,
  984. feature:{
  985. saveAsImage:{show:true},restore:{show:true}, magicType:{ type:['line','bar']},
  986. }
  987. },
  988. tooltip:{
  989. trigger:'axis',
  990. formatter: function (params,ticket,callback) {
  991. _this.params = params;
  992. var res
  993. if(_this.user.userNameNeedTranslate != '1') {
  994. var res = params[0].name + "<br/>" +
  995. ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
  996. + _this.$t('yuan')+"<br/>" : '') +
  997. ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
  998. } else {
  999. var res = "<ww-open-data type='departmentName' :openid='"+ _this.allListData.costList[params[0].dataIndex].additionName +"'></ww-open-data>" + "<br/>" +
  1000. ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
  1001. + _this.$t('yuan')+"<br/>" : '') +
  1002. ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
  1003. }
  1004. return res;
  1005. }
  1006. },
  1007. xAxis: {
  1008. data: xList,
  1009. axisLabel: {
  1010. interval:0,rotate:20
  1011. }
  1012. },
  1013. yAxis: [{
  1014. type : 'value',
  1015. axisLabel: {
  1016. formatter:this.yAxisValue==0?'{value} ('+this.$t('yuan')+')':'{value}'+this.$t('time.hour')
  1017. }
  1018. }],
  1019. series: [{
  1020. name: this.yAxisValue==0?this.$t('workcost')+'('+this.$t('yuan')+')':this.$t('screening.workTime')+'('+this.$t('time.hour')+')',
  1021. type: 'bar',
  1022. barMaxWidth: 30,
  1023. data: yList,
  1024. }],
  1025. grid: {
  1026. left: '100px',
  1027. }
  1028. };
  1029. } else {
  1030. var option = {
  1031. title: {
  1032. // text: '工时成本总计' + this.zhishin + '元, 时长'+totalHours+'小时',
  1033. 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') : ''),
  1034. left:'left',
  1035. },
  1036. // 工具箱
  1037. toolbox: {
  1038. show: true,
  1039. feature:{
  1040. saveAsImage:{show:true},restore:{show:true}, magicType:{ type:['line','bar']},
  1041. }
  1042. },
  1043. tooltip:{
  1044. trigger:'axis',
  1045. formatter: function (params,ticket,callback) {
  1046. var res = params[0].name + "<br/>" +
  1047. ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
  1048. + _this.$t('yuan')+"<br/>" : '') +
  1049. ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
  1050. _this.params = params;
  1051. return res;
  1052. }
  1053. },
  1054. xAxis: {
  1055. data: xList,
  1056. axisLabel: {
  1057. interval:0,rotate:20
  1058. }
  1059. },
  1060. yAxis: [{
  1061. type : 'value',
  1062. axisLabel: {
  1063. formatter:this.yAxisValue==0?'{value} ('+this.$t('yuan')+')':'{value}'+this.$t('time.hour')
  1064. }
  1065. }],
  1066. series: [{
  1067. name: this.yAxisValue==0?this.$t('workcost')+'('+this.$t('yuan')+')':this.$t('screening.workTime')+'('+this.$t('time.hour')+')',
  1068. type: 'bar',
  1069. barMaxWidth: 30,
  1070. data: yList,
  1071. }],
  1072. grid: {
  1073. left: '100px',
  1074. }
  1075. };
  1076. }
  1077. myChart.setOption(option,{notMerge: true});
  1078. myChart.getZr().on('click', params => {
  1079. const pointInPixel = [params.offsetX, params.offsetY];
  1080. if (myChart.containPixel('grid', pointInPixel)) {
  1081. // console.log(_this.params)
  1082. if(_this.radio==this.$t('other.project')) {
  1083. if (_this.dateRange != null) {
  1084. if (this.user.timeType.fixMonthcost == 0) {
  1085. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
  1086. +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
  1087. } else {
  1088. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
  1089. +"?startDate="+_this.dateRange+"&endDate="+_this.dateRange);
  1090. }
  1091. } else {
  1092. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name);
  1093. }
  1094. } else if (_this.radio==this.$t('lable.department')) {
  1095. if (_this.params[0].data.hasSubDept) {
  1096. if (_this.parentDeptId != _this.params[0].data.id) {
  1097. _this.parentDeptId = _this.params[0].data.id;
  1098. _this.parentDeptStack.push(_this.parentDeptId);
  1099. _this.jieliu();
  1100. }
  1101. // _this.jieliu();
  1102. } else {
  1103. if (_this.dateRange != null) {
  1104. _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name
  1105. +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
  1106. } else {
  1107. _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name);
  1108. }
  1109. }
  1110. }
  1111. }
  1112. });
  1113. },
  1114. // 左右滚动
  1115. scrollFunction () {
  1116. this.domObj = document.getElementById('clearfix') // 通过id获取要设置的div
  1117. if (this.domObj.attachEvent) { // IE
  1118. this.domObj.attachEvent('onmousewheel', this.mouseScroll)
  1119. } else if (this.domObj.addEventListener) {
  1120. this.domObj.addEventListener('DOMMouseScroll', this.mouseScroll, false)
  1121. }
  1122. this.domObj.onmousewheel = this.domObj.onmousewheel = this.mouseScroll
  1123. },
  1124. mouseScroll(event) { // google 浏览器下
  1125. let detail = event.wheelDelta || event.detail
  1126. let moveForwardStep = -1
  1127. let moveBackStep = 1
  1128. let step = 0
  1129. step = detail > 0 ? moveForwardStep * 100 : moveBackStep * 100
  1130. event.preventDefault() // 阻止浏览器默认事件
  1131. this.domObj.scrollLeft = this.domObj.scrollLeft + step
  1132. },
  1133. // 判断后端给的字段
  1134. // 获取自定义
  1135. getZDY() {
  1136. this.http.post('/user-custom/getUserCustomTitle',{},res => {
  1137. if(res.code == 'ok'){
  1138. // console.log(res, '数据来源')
  1139. this.theCustomList = res.data.result
  1140. this.theCustomListPlantLIst = res.data.field
  1141. }else {
  1142. this.$message({
  1143. message: res.msg,
  1144. type: 'error'
  1145. })
  1146. }
  1147. },error => {
  1148. this.$message({
  1149. message: error,
  1150. type: 'error'
  1151. })
  1152. })
  1153. },
  1154. // 获取部门
  1155. getDepartmentList() {
  1156. this.http.post( this.port.manage.depList, {},
  1157. res => {
  1158. if (res.code == "ok") {
  1159. let dptlist = JSON.parse(JSON.stringify(res.data));
  1160. this.departmentList = this.changeArr(dptlist);
  1161. } else {
  1162. this.$message({
  1163. message: res.msg,
  1164. type: "error"
  1165. });
  1166. }
  1167. },error => {
  1168. this.$message({
  1169. message: error,
  1170. type: "error"
  1171. });
  1172. });
  1173. },
  1174. changeArr(arr) {
  1175. for (var i = 0; i < arr.length; i++) {
  1176. if(arr[i].id != -1 && arr[i].id != 0) {
  1177. if (arr[i].children != null && arr[i].children.length>0) {
  1178. arr[i].children = this.changeArr(arr[i].children);
  1179. }
  1180. arr[i].id && (arr[i].value = arr[i].id);
  1181. delete arr[i].id;
  1182. }
  1183. }
  1184. for(var i in arr) {
  1185. if(arr[i].id == -1 || arr[i].id == 0) {
  1186. arr.splice(i,1)
  1187. }
  1188. }
  1189. return arr;
  1190. },
  1191. // 自定义事件
  1192. selectCal(obj) {
  1193. console.log(obj)
  1194. if(obj.distinction == 1) {
  1195. let arr = []
  1196. for(var i in obj.arrUserList) {
  1197. arr.push(obj.arrUserList[i].id)
  1198. }
  1199. this.exportParam.userIds = arr
  1200. } else if(obj.distinction == 2) {
  1201. console.log(obj)
  1202. this.personnelValue = obj.name
  1203. this.personnel()
  1204. }
  1205. },
  1206. vueCasader(obj) {
  1207. if(obj.distinction == 1) {
  1208. console.log(obj, '数据')
  1209. let arr = []
  1210. arr.push(obj.id)
  1211. this.exportParam.deptId = arr
  1212. }
  1213. }
  1214. },
  1215. created() {
  1216. this.myChart = null
  1217. },
  1218. mounted() {
  1219. this.containerHeight = window.innerHeight - 200
  1220. // this.containerHeight = window.innerHeight - 130
  1221. const that = this;
  1222. window.onresize = function temp() {
  1223. this.containerHeight = window.innerHeight - 130
  1224. // this.containerHeight = window.innerHeight - 200
  1225. };
  1226. if(this.permissions.countCost){
  1227. this.yAxisValue = '0'
  1228. }else{
  1229. this.yAxisValue = '1'
  1230. }
  1231. if (this.user.timeType.fixMonthcost == 0) {
  1232. if (this.$route.query.startDate != null) {
  1233. this.dateRange = [this.$route.query.startDate, this.$route.query.endDate];
  1234. } else {
  1235. //默认查看本月
  1236. var now = new Date();
  1237. var t = util.formatDate.format(now, 'yyyy-MM-dd');
  1238. var startStr = util.formatDate.format(new Date(), 'yyyy-MM') + "-01";
  1239. this.dateRange = [startStr,t];
  1240. }
  1241. this.exportParam.dateRange = this.dateRange;
  1242. } else if (this.user.timeType.fixMonthcost == 1) {
  1243. if (this.$route.query.startDate != null) {
  1244. this.dateRange = this.$route.query.startDate;
  1245. } else {
  1246. //默认查看本月
  1247. var startStr = util.formatDate.format(new Date(), 'yyyy-MM');
  1248. this.dateRange = startStr;
  1249. }
  1250. this.exportParam.dateRange = this.dateRange;
  1251. }
  1252. this.radio = this.$t('other.project')
  1253. this.getEchart();
  1254. var _this = this;
  1255. window.addEventListener("resize", function() {
  1256. _this.myChart.resize();
  1257. });
  1258. // this.getDepartment();
  1259. this.getMyProjectList();
  1260. this.getUsers()
  1261. this.jutishez()
  1262. this.scrollFunction()
  1263. // 判断
  1264. if(this.user.timeType.userCustomStatic) {
  1265. this.getZDY()
  1266. }
  1267. this.getDepartmentList()
  1268. },
  1269. beforeDestroy () {
  1270. var myChart = echarts.init(document.getElementById("container"));
  1271. myChart.clear()
  1272. },
  1273. };
  1274. </script>
  1275. <style lang="scss" scoped>
  1276. #container {
  1277. // display: inline-block;
  1278. display: block;
  1279. position: absolute;
  1280. // width: 100% !important;
  1281. margin-top: 60px;
  1282. }
  1283. .ryuans {
  1284. top: -50px;
  1285. }
  1286. .prompt {
  1287. position: absolute;
  1288. right: 10px;
  1289. top: 0;
  1290. }
  1291. .poss {
  1292. position: fixed;
  1293. bottom: -10px;
  1294. right: 1%;
  1295. box-sizing: border-box;
  1296. }
  1297. </style>
  1298. <style lang="scss">
  1299. </style>