cost.vue 71 KB

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