cost.vue 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415
  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. if(arrlist.list.length > 0) {
  422. let list = arrlist.list
  423. let dealWithList = []
  424. for(var i in list) {
  425. let obj = {}
  426. obj.type = list[i].type
  427. obj.id = list[i].name
  428. dealWithList.push(obj)
  429. }
  430. this.dealWithTranslationPlone(dealWithList)
  431. } else {
  432. this.getUserCostList()
  433. }
  434. } else {
  435. this.allListData = arrlist
  436. this.gtff()
  437. }
  438. } else {
  439. this.allListData = this.personnelAllPlly
  440. this.gtff()
  441. }
  442. },
  443. //获取人员成本统计列表
  444. getUserCostList() {
  445. this.listLoading = true;
  446. // console.log(this.port.project.userCost, '获取人员成本统计列表')
  447. // console.log(this.user.timeType.fixMonthcost)
  448. // console.log(Boolean(this.dateRange))
  449. let startDateNum = ''
  450. let endDateNum = ''
  451. if(this.dateRange) {
  452. startDateNum = this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange
  453. endDateNum = this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
  454. }
  455. // return
  456. this.http.post(this.port.project.userCost, {
  457. // startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange,
  458. // endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
  459. startDate: startDateNum,
  460. endDate: endDateNum
  461. },
  462. res => {
  463. this.listLoading = false;
  464. var _this = this;
  465. this.hasReportUserList = [];
  466. if (res.code == "ok") {
  467. let alltime = 0
  468. for(let i in res.data.list){
  469. for(let m in res.data.list[i].project){
  470. alltime += parseFloat(res.data.list[i].project[m].time)
  471. }
  472. }
  473. this.totalTime111 = alltime
  474. //
  475. //
  476. this.personnelAll = res.data
  477. this.allListData = res.data
  478. this.personnelAllPlly = JSON.parse(JSON.stringify(res.data))
  479. if(this.user.userNameNeedTranslate == '1') {
  480. let list = res.data.list
  481. let dealWithList = []
  482. for(var i in list) {
  483. let obj = {}
  484. obj.type = list[i].type
  485. obj.id = list[i].name
  486. dealWithList.push(obj)
  487. }
  488. this.dealWithTranslationPlone(dealWithList, res.data.list)
  489. } else {
  490. this.personnelAll = res.data
  491. this.allListData = res.data
  492. console.log('人员返回', this.allListData);
  493. this.gtff()
  494. }
  495. } else {
  496. this.$message({
  497. message: res.msg + '里面',
  498. type: "error"
  499. });
  500. }
  501. },
  502. error => {
  503. this.listLoading = false;
  504. this.$message({
  505. message: error + '外面',
  506. type: "error"
  507. });
  508. });
  509. },
  510. // 共同方法
  511. gtff() {
  512. let data = this.allListData
  513. var _this = this;
  514. this.hasReportUserList = data.userList;
  515. this.total = data.list ? data.list.length : 0
  516. var totalHours = 0.0;
  517. var xList = [] , yList = [] , list = data.list.slice(0+50*(this.page-1),49+50*(this.page-1)), array = [] , series = [];
  518. var totalMoneyCost = data.totalCostMoney;
  519. for(var i in list) {
  520. if(i>20) {
  521. this.widthHtval = +this.widthHtval + 60
  522. } else {
  523. this.widthHtval = document.body.clientWidth - 230
  524. }
  525. }
  526. if (list.length > 0) {
  527. var num = list.length==0?0:list[0].project.length;
  528. // console.log('for 1');
  529. for(var i in list) {
  530. xList.push(list[i].name);
  531. var pro = list[i].project;
  532. for(var j in pro) {
  533. if(array.indexOf(pro[j].project) == -1) {
  534. array.push(pro[j].project)
  535. }
  536. }
  537. }
  538. // console.log('for 2');
  539. for(var i in array) {
  540. yList.push(array[i]);
  541. var dataList = [];
  542. // console.log('for 2 1');
  543. for(var j in list) {
  544. var project = list[j].project , num = 0;
  545. if(project.length != 0) {
  546. // console.log('for 2 1 1');
  547. for(var k in project) {
  548. if(project[k].project == array[i]) {
  549. let item = {
  550. "value": this.yAxisValue==0?project[k].money:project[k].time,
  551. }
  552. if(this.permissions.countCost){
  553. item.money = project[k].money
  554. }
  555. if(this.permissions.countHours){
  556. item.cost = project[k].time
  557. // totalHours += parseFloat(project[k].time);
  558. }
  559. dataList.push(item)
  560. } else {
  561. num++;
  562. }
  563. if(k == project.length-1 && num != project.length-1) {
  564. dataList.push({
  565. "value": 0,
  566. "cost": 0,
  567. "money":0,
  568. })
  569. }
  570. }
  571. } else {
  572. dataList.push({
  573. "value": 0,
  574. "cost": 0,
  575. "money":0,
  576. })
  577. }
  578. }
  579. series.push({
  580. name: array[i],
  581. type: 'bar',
  582. stack:'1',
  583. barMaxWidth: 30,
  584. data: dataList,
  585. })
  586. }
  587. }
  588. var myChart = echarts.init(document.getElementById("container"));
  589. totalHours = this.totalTime111.toFixed(1);
  590. // 设置宽度
  591. myChart.resize({
  592. width: this.widthHtval
  593. })
  594. // console.log('设置宽度');
  595. // 设置宽度
  596. _this.myChart = myChart;
  597. var option = {
  598. //总成本
  599. title: {
  600. // text: '工时成本总计' + totalMoneyCost.toFixed(2) + '元, 时长'+totalHours+'小时',
  601. text: this.$t('otalhourscost')+ ':' +
  602. ((this.permissions.countCost) ? this.$t('costof') + ' ' + totalMoneyCost.toFixed(2) + ' ' + this.$t('yuan') + ',' : '') +
  603. ((this.permissions.countHours) ? this.$t('time.duration') + ' ' +totalHours + ' ' + this.$t('time.hour') : ''),
  604. left:'left',
  605. },
  606. // 工具箱
  607. legend: {
  608. x: 80,
  609. y: 10,
  610. data: yList,
  611. show: true,
  612.       top:"5%",//与上方的距离 可百分比% 可像素px
  613. },
  614. grid : {
  615. top : 80, //距离容器上边界40像素
  616. // bottom: 100, //距离容器下边界30像素
  617. bottom: 35, //距离容器下边界30像素
  618. left: 150,
  619. right: 150
  620. },
  621. toolbox: {
  622. show: true,
  623. feature:{
  624. saveAsImage:{
  625. show:true
  626. },
  627. restore:{
  628. show:true
  629. },
  630. // dataView:{
  631. // show:true
  632. // },
  633. // dataZoom:{
  634. // show:true
  635. // },
  636. magicType:{
  637. type:['line','bar']
  638. }
  639. }
  640. },
  641. tooltip:{
  642. trigger:'axis',
  643. formatter: function (params,ticket,callback) {
  644. var totalTime = 0;
  645. var totalCost = 0;
  646. var res = "";
  647. for(var i in params) {
  648. if (params[i].data.value > 0) {
  649. res += "<div style='margin-top:3px;font-size:12px;'><font color='#ddd'>" + _this.$t('headerTop.projectName') + ":" + params[i].seriesName
  650. + "</font><br/>" +
  651. ((_this.permissions.countCost) ? _this.$t('workcost')+ ":" + params[i].data.money + _this.$t('yuan') + "</br>" : '') +
  652. ((_this.permissions.countHours) ? _this.$t('screening.workTime') + ":" + params[i].data.cost + _this.$t('time.hour') + "</br>" : '') + "</div>";
  653. totalTime += Number(params[i].data.cost);
  654. totalCost += Number(params[i].data.money);
  655. }
  656. }
  657. if(_this.user.userNameNeedTranslate != 1) {
  658. res = res +'<br/>'+ params[0].name+ '<br/>' + _this.$t('zong-ji') + ':' +
  659. ((_this.permissions.countHours) ? totalTime.toFixed(1) + _this.$t('time.hour') : '') +
  660. ((_this.permissions.countCost) ? totalCost.toFixed(2) + _this.$t('yuan') : '') +
  661. "<br/>";
  662. } else {
  663. res = res +'<br/>'+ '' + '<br/>' + _this.$t('zong-ji') + ':' +
  664. ((_this.permissions.countHours) ? totalTime.toFixed(1) + _this.$t('time.hour') : '') +
  665. ((_this.permissions.countCost) ? totalCost.toFixed(2) + _this.$t('yuan') : '') +
  666. "<br/>";
  667. }
  668. return res;
  669. }
  670. },
  671. xAxis: {
  672. data: xList,
  673. axisLabel: {
  674. interval:0,rotate:20
  675. }
  676. },
  677. yAxis: [{
  678. type : 'value',
  679. axisLabel: {
  680. formatter:this.yAxisValue==0?'{value} ('+this.$t('yuan')+')':'{value} ('+this.$t('time.hour')+')'
  681. // formatter:this.yAxisValue==0?'{value} (元)':'{value} (小时)'
  682. }
  683. }],
  684. series: series,
  685. };
  686. // console.log('setoption');
  687. myChart.setOption(option,{notMerge:true});
  688. },
  689. yanjiu() {
  690. // console.log('触发')
  691. },
  692. getEchart(e){
  693. var that = this
  694. // 更具选中的名字筛选出对应的自定义id
  695. that.theCustomListFlg = false
  696. let ints = null
  697. for(var i in that.theCustomList) {
  698. if(that.radio == that.theCustomList[i].name) {
  699. that.theCustomListId = that.theCustomList[i].id
  700. that.theCustomListPlant = that.theCustomListPlantLIst[i]
  701. that.theCustomListFlg = true
  702. ints = i
  703. }
  704. }
  705. if(that.theCustomListFlg) {
  706. that.customList = that.theCustomList[ints].subUserCustomList
  707. that.customName = that.theCustomList[ints].subUserCustomList[0].name
  708. // that.getCusTom()
  709. }
  710. that.jieliu()
  711. },
  712. getCusTom() {
  713. this.http.post('/sub-user-custom/list',{
  714. userCustomId: this.theCustomListId
  715. },res => {
  716. if(res.code == 'ok'){
  717. this.customList = res.data
  718. this.customName = res.data[0].name
  719. }else {
  720. this.$message({
  721. message: res.msg,
  722. type: 'error'
  723. })
  724. }
  725. },error => {
  726. this.$message({
  727. message: error,
  728. type: 'error'
  729. })
  730. })
  731. },
  732. getCategoryList(){
  733. this.http.post('/project-category/list',{},
  734. res => {
  735. if(res.code == 'ok'){
  736. this.categoryList = res.data
  737. }else {
  738. this.$message({
  739. message: res.msg,
  740. type: 'error'
  741. })
  742. }
  743. },err => {
  744. this.$message({
  745. message: err,
  746. type: 'error'
  747. })
  748. })
  749. },
  750. backToParentDept() {
  751. if (this.radio == this.$t('lable.department')) {
  752. if (this.parentDeptStack.length > 0) {
  753. this.parentDeptStack.pop();
  754. if (this.parentDeptStack.length > 0) {
  755. this.parentDeptId = this.parentDeptStack[this.parentDeptStack.length -1];
  756. } else {
  757. this.parentDeptId = null;
  758. }
  759. this.jieliu();
  760. }
  761. }
  762. },
  763. // 脱离出来的方法
  764. jieliu() {
  765. sessionStorage.radio = this.radio;
  766. var param = {};
  767. if (this.dateRange != null) {
  768. param = {
  769. startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange,
  770. endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
  771. };
  772. // console.log(param);
  773. }
  774. var url = '';
  775. if (this.radio==this.$t('other.project')) {
  776. url = this.port.project.listCost;
  777. }else if(this.radio == this.$t('zhu-xiang-mu')){
  778. url = '/project/getTimeCostByMainProject'
  779. // param.userId = this.user.id
  780. }else if (this.radio==this.$t('projectclassification')) {
  781. url = '/project/getTimeCostByCategory';
  782. // param.parentDeptId = this.parentDeptId;
  783. // param.userId = this.user.id
  784. } else if (this.radio==this.$t('lable.department')) {
  785. url = this.port.project.depCost;
  786. param.parentDeptId = this.parentDeptId;
  787. } else if (this.radio==this.$t('ren-yuan')) {
  788. this.getUserCostList();
  789. return;
  790. } else if (this.radio == this.namess) {
  791. url = '/project/getDegreeCost'
  792. } else if (this.theCustomListFlg) {
  793. url = '/project/getTimeCostByUserCustom'
  794. // param.subCustomName = this.customName
  795. param.customId = this.theCustomListId
  796. param.fieldName = this.theCustomListPlant
  797. // console.log(param, '要传的数据')
  798. }
  799. this.http.post(url, param,
  800. res => {
  801. if (res.code == "ok") {
  802. let alltime = 0
  803. if(this.radio==this.$t('other.project') || this.radio == this.$t('zhu-xiang-mu') || this.radio==this.$t('projectclassification')){
  804. for(let i in res.data.costList){
  805. alltime += parseFloat(res.data.costList[i].cost)
  806. }
  807. }else if(this.radio==this.$t('lable.department')){
  808. for(let i in res.data.costList){
  809. alltime += parseFloat(res.data.costList[i].costTime)
  810. }
  811. }else if(this.radio == this.namess){
  812. for(let i in res.data){
  813. alltime += parseFloat(res.data[i].cost)
  814. }
  815. }else if(this.theCustomListFlg){
  816. for(let i in res.data.list){
  817. alltime += parseFloat(res.data.list[i].cost)
  818. }
  819. }
  820. this.totalTime111 = alltime
  821. // additionName // 未转译的数据另外存储一份,用作 DOM 上渲染
  822. if(this.user.userNameNeedTranslate == '1') {
  823. for(var i in res.data.costList) {
  824. res.data.costList[i].additionName = res.data.costList[i].departmentName
  825. }
  826. }
  827. this.allListData = res.data
  828. console.log(this.allListData, '部门数据')
  829. this.page = 1
  830. if(this.user.userNameNeedTranslate == '1' && this.radio == this.$t('lable.department')) {
  831. console.log('进入我处理的方法')
  832. let arr = []
  833. for(var i in this.allListData.costList) {
  834. let obj = {}
  835. obj.type = this.allListData.costList[i].type
  836. obj.id = this.allListData.costList[i].departmentName
  837. arr.push(obj)
  838. }
  839. this.dealWithTranslation(arr)
  840. } else {
  841. this.jieliu_echarts()
  842. }
  843. } else {
  844. this.$message({
  845. message: res.msg,
  846. type: "error"
  847. });
  848. }
  849. },
  850. error => {
  851. this.$message({
  852. message: error,
  853. type: "error"
  854. });
  855. });
  856. },
  857. dealWithTranslation(items) {
  858. if (WWOpenData.initCanvas) {
  859. WWOpenData.initCanvas()
  860. }
  861. const myFunOne = async () => {
  862. const result = await new Promise((resolve, reject) => {
  863. if(WWOpenData.prefetch) {
  864. WWOpenData.prefetch({ items }, (err, data) => {
  865. console.log(items)
  866. console.log(err)
  867. console.log(data)
  868. if (err) { return reject(err) }
  869. resolve(data)
  870. })
  871. }
  872. })
  873. for(var i in this.allListData.costList) {
  874. this.allListData.costList[i].departmentName = result.items[i].data
  875. }
  876. this.jieliu_echarts()
  877. }
  878. myFunOne()
  879. },
  880. dealWithTranslationPlone(items, dataList) {
  881. console.log(items, '过来道德值')
  882. if (WWOpenData.initCanvas) {
  883. WWOpenData.initCanvas()
  884. }
  885. const myFunOne = async () => {
  886. const result = await new Promise((resolve, reject) => {
  887. if(WWOpenData.prefetch) {
  888. WWOpenData.prefetch({ items }, (err, data) => {
  889. if (err) { return reject(err) }
  890. resolve(data)
  891. })
  892. }
  893. })
  894. console.log('取到的值', result)
  895. for(var i in this.allListData.list) {
  896. if(result.items[i]) {
  897. this.allListData.list[i].name = result.items[i].data
  898. }
  899. }
  900. this.gtff()
  901. }
  902. myFunOne()
  903. },
  904. jieliu_echarts(){
  905. var _this = this;
  906. // 更具数据的长度去加每个柱子的间距
  907. var xList = []
  908. var yList = []
  909. var list
  910. var totalMoneyCost;
  911. var totalHours = 0.0;
  912. 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')) {
  913. // this.allListData = res.data.costList
  914. this.total = this.allListData.costList ? this.allListData.costList.length : 0
  915. list = this.allListData.costList.slice(0+50*(this.page-1),49+50*(this.page-1))
  916. for(var i in list) {
  917. if(i>20) {
  918. this.widthHtval = +this.widthHtval + 60
  919. } else {
  920. this.widthHtval = document.body.clientWidth - 230
  921. }
  922. }
  923. // list = res.data.costList
  924. totalMoneyCost = ((this.radio==this.$t('other.project') || this.radio == this.$t('projectclassification'))?this.allListData.totalMoneyCost:this.allListData.totalCostMoney);
  925. for(var i in list) {
  926. if(this.radio==this.$t('other.project') || this.radio == this.$t('zhu-xiang-mu')) {
  927. if(this.radio == this.$t('other.project')){
  928. xList.push(list[i].project);
  929. }else{
  930. xList.push(list[i].mainProjectName);
  931. }
  932. let item = {
  933. "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),
  934. "id": list[i].id || i,
  935. }
  936. if(this.permissions.countCost){
  937. // item.money = list[i].costMoney.toFixed(2)
  938. item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
  939. }
  940. if(this.permissions.countHours){
  941. item.cost = list[i].cost
  942. totalHours += parseFloat(list[i].cost);
  943. }
  944. yList.push(item);
  945. } else if(this.radio == this.$t('lable.department')){
  946. xList.push(list[i].departmentName);
  947. let item = {
  948. // "value": this.yAxisValue==0 ? list[i].costMoney.toFixed(2) || list[i].costMoney: list[i].costTime.toFixed(1),
  949. "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),
  950. "id": list[i].departmentId,
  951. "hasSubDept": list[i].hasSubDept
  952. }
  953. if(this.permissions.countCost){
  954. // item.money = list[i].costMoney.toFixed(2)
  955. item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
  956. }
  957. if(this.permissions.countHours){
  958. item.cost = list[i].costTime
  959. totalHours += parseFloat(list[i].costTime);
  960. }
  961. yList.push(item);
  962. }else {
  963. xList.push(list[i].categoryName);
  964. let item = {
  965. // "value": this.yAxisValue==0?list[i].costMoney.toFixed(2) || list[i].costMoney:list[i].cost.toFixed(1),
  966. "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),
  967. "id": list[i].id || i,
  968. }
  969. if(this.permissions.countCost){
  970. // item.money = list[i].costMoney.toFixed(2)
  971. item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
  972. }
  973. if(this.permissions.countHours){
  974. item.cost = list[i].cost
  975. totalHours += parseFloat(list[i].cost);
  976. }
  977. yList.push(item);
  978. }
  979. }
  980. }
  981. else if(this.theCustomListFlg) {
  982. // this.allListData = res.data.list ? res.data.list : []
  983. this.total = this.allListData.list ? this.allListData.list.length : 0
  984. list = this.total ? this.allListData.list.slice(0+50*(this.page-1),49+50*(this.page-1)) : []
  985. // list = res.data.list
  986. for(var i in list) {
  987. // console.log(list[i].name, list[i].costMoney, list[i].cost)
  988. xList.push(list[i].name);
  989. let item = {
  990. "value": this.yAxisValue==0?list[i].costMoney:list[i].cost,
  991. "id": list[i].id || i,
  992. }
  993. if(this.permissions.countCost){
  994. // item.money = list[i].costMoney.toFixed(2)
  995. item.money = list[i].costMoney ? list[i].costMoney.toFixed(2) : 0
  996. totalMoneyCost += parseFloat(list[i].costMoney);
  997. }
  998. if(this.permissions.countHours){
  999. item.cost = list[i].cost
  1000. totalHours += parseFloat(list[i].cost);
  1001. }
  1002. yList.push(item);
  1003. }
  1004. }
  1005. else {
  1006. //自定义列表:data:{cost:3, costMoney:222}
  1007. this.total = this.allListData.costList ? this.allListData.costList.length : 0
  1008. console.log('slice',this.allListData);
  1009. // if(this.total){
  1010. list = this.allListData.costList.slice(0+50*(this.page-1),49+50*(this.page-1))
  1011. // }else{
  1012. // list =
  1013. // }
  1014. // list = this.total ? : []
  1015. for(var i in list) {
  1016. xList.push(list[i].name);
  1017. let item = {
  1018. "value": this.yAxisValue==0?list[i].costMoney:list[i].cost,
  1019. "id": list[i].id || i,
  1020. }
  1021. if(this.permissions.countCost){
  1022. // item.money = list[i].costMoney.toFixed(2)
  1023. item.money = list[i].costMoney ? list[i].costMoney.toFixed(2) : 0
  1024. totalMoneyCost += parseFloat(list[i].costMoney);
  1025. }
  1026. if(this.permissions.countHours){
  1027. item.cost = list[i].cost
  1028. totalHours += parseFloat(list[i].cost);
  1029. }
  1030. yList.push(item);
  1031. }
  1032. }
  1033. totalHours = this.totalTime111.toFixed(1);
  1034. var myChart = echarts.init(document.getElementById("container"));
  1035. myChart.resize({
  1036. width: this.widthHtval
  1037. })
  1038. _this.myChart = myChart;
  1039. // console.log(totalMoneyCost.toFixed(2), '看看', totalMoneyCost)
  1040. // var chengbentongji = totalMoneyCost.toFixed(2) || totalMoneyCost
  1041. if(totalMoneyCost) {
  1042. this.zhishin = totalMoneyCost.toFixed(2)
  1043. }
  1044. 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')) {
  1045. var option = {
  1046. title: {
  1047. 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') : ''),
  1048. left:'left',
  1049. },
  1050. // 工具箱
  1051. toolbox: {
  1052. show: true,
  1053. feature:{
  1054. saveAsImage:{show:true},restore:{show:true}, magicType:{ type:['line','bar']},
  1055. }
  1056. },
  1057. tooltip:{
  1058. trigger:'axis',
  1059. formatter: function (params,ticket,callback) {
  1060. _this.params = params;
  1061. var res
  1062. if(_this.user.userNameNeedTranslate != '1') {
  1063. var res = params[0].name + "<br/>" +
  1064. ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
  1065. + _this.$t('yuan')+"<br/>" : '') +
  1066. ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
  1067. } else {
  1068. var res = "<ww-open-data type='departmentName' :openid='"+ _this.allListData.costList[params[0].dataIndex].additionName +"'></ww-open-data>" + "<br/>" +
  1069. ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
  1070. + _this.$t('yuan')+"<br/>" : '') +
  1071. ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
  1072. }
  1073. return res;
  1074. }
  1075. },
  1076. xAxis: {
  1077. data: xList,
  1078. axisLabel: {
  1079. interval:0,rotate:20
  1080. }
  1081. },
  1082. yAxis: [{
  1083. type : 'value',
  1084. axisLabel: {
  1085. formatter:this.yAxisValue==0?'{value} ('+this.$t('yuan')+')':'{value}'+this.$t('time.hour')
  1086. }
  1087. }],
  1088. series: [{
  1089. name: this.yAxisValue==0?this.$t('workcost')+'('+this.$t('yuan')+')':this.$t('screening.workTime')+'('+this.$t('time.hour')+')',
  1090. type: 'bar',
  1091. barMaxWidth: 30,
  1092. data: yList,
  1093. }],
  1094. grid: {
  1095. left: '100px',
  1096. }
  1097. };
  1098. } else {
  1099. var option = {
  1100. title: {
  1101. // text: '工时成本总计' + this.zhishin + '元, 时长'+totalHours+'小时',
  1102. 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') : ''),
  1103. left:'left',
  1104. },
  1105. // 工具箱
  1106. toolbox: {
  1107. show: true,
  1108. feature:{
  1109. saveAsImage:{show:true},restore:{show:true}, magicType:{ type:['line','bar']},
  1110. }
  1111. },
  1112. tooltip:{
  1113. trigger:'axis',
  1114. formatter: function (params,ticket,callback) {
  1115. var res = params[0].name + "<br/>" +
  1116. ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
  1117. + _this.$t('yuan')+"<br/>" : '') +
  1118. ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
  1119. _this.params = params;
  1120. return res;
  1121. }
  1122. },
  1123. xAxis: {
  1124. data: xList,
  1125. axisLabel: {
  1126. interval:0,rotate:20
  1127. }
  1128. },
  1129. yAxis: [{
  1130. type : 'value',
  1131. axisLabel: {
  1132. formatter:this.yAxisValue==0?'{value} ('+this.$t('yuan')+')':'{value}'+this.$t('time.hour')
  1133. }
  1134. }],
  1135. series: [{
  1136. name: this.yAxisValue==0?this.$t('workcost')+'('+this.$t('yuan')+')':this.$t('screening.workTime')+'('+this.$t('time.hour')+')',
  1137. type: 'bar',
  1138. barMaxWidth: 30,
  1139. data: yList,
  1140. }],
  1141. grid: {
  1142. left: '100px',
  1143. }
  1144. };
  1145. }
  1146. myChart.setOption(option,{notMerge: true});
  1147. myChart.getZr().on('click', params => {
  1148. const pointInPixel = [params.offsetX, params.offsetY];
  1149. if (myChart.containPixel('grid', pointInPixel)) {
  1150. // console.log(_this.params)
  1151. if(_this.radio==this.$t('other.project')) {
  1152. if (_this.dateRange != null) {
  1153. if (this.user.timeType.fixMonthcost == 0) {
  1154. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
  1155. +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
  1156. } else {
  1157. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
  1158. +"?startDate="+_this.dateRange+"&endDate="+_this.dateRange);
  1159. }
  1160. } else {
  1161. _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name);
  1162. }
  1163. } else if (_this.radio==this.$t('lable.department')) {
  1164. if (_this.params[0].data.hasSubDept) {
  1165. if (_this.parentDeptId != _this.params[0].data.id) {
  1166. _this.parentDeptId = _this.params[0].data.id;
  1167. _this.parentDeptStack.push(_this.parentDeptId);
  1168. _this.jieliu();
  1169. }
  1170. // _this.jieliu();
  1171. } else {
  1172. if (_this.dateRange != null) {
  1173. _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name
  1174. +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
  1175. } else {
  1176. _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name);
  1177. }
  1178. }
  1179. }
  1180. }
  1181. });
  1182. },
  1183. // 左右滚动
  1184. scrollFunction () {
  1185. this.domObj = document.getElementById('clearfix') // 通过id获取要设置的div
  1186. if (this.domObj.attachEvent) { // IE
  1187. this.domObj.attachEvent('onmousewheel', this.mouseScroll)
  1188. } else if (this.domObj.addEventListener) {
  1189. this.domObj.addEventListener('DOMMouseScroll', this.mouseScroll, false)
  1190. }
  1191. this.domObj.onmousewheel = this.domObj.onmousewheel = this.mouseScroll
  1192. },
  1193. mouseScroll(event) { // google 浏览器下
  1194. let detail = event.wheelDelta || event.detail
  1195. let moveForwardStep = -1
  1196. let moveBackStep = 1
  1197. let step = 0
  1198. step = detail > 0 ? moveForwardStep * 100 : moveBackStep * 100
  1199. event.preventDefault() // 阻止浏览器默认事件
  1200. this.domObj.scrollLeft = this.domObj.scrollLeft + step
  1201. },
  1202. // 判断后端给的字段
  1203. // 获取自定义
  1204. getZDY() {
  1205. this.http.post('/user-custom/getUserCustomTitle',{},res => {
  1206. if(res.code == 'ok'){
  1207. // console.log(res, '数据来源')
  1208. this.theCustomList = res.data.result
  1209. this.theCustomListPlantLIst = res.data.field
  1210. }else {
  1211. this.$message({
  1212. message: res.msg,
  1213. type: 'error'
  1214. })
  1215. }
  1216. },error => {
  1217. this.$message({
  1218. message: error,
  1219. type: 'error'
  1220. })
  1221. })
  1222. },
  1223. // 获取部门
  1224. getDepartmentList() {
  1225. this.http.post( this.port.manage.depList, {},
  1226. res => {
  1227. if (res.code == "ok") {
  1228. let dptlist = JSON.parse(JSON.stringify(res.data));
  1229. this.departmentList = this.changeArr(dptlist);
  1230. } else {
  1231. this.$message({
  1232. message: res.msg,
  1233. type: "error"
  1234. });
  1235. }
  1236. },error => {
  1237. this.$message({
  1238. message: error,
  1239. type: "error"
  1240. });
  1241. });
  1242. },
  1243. changeArr(arr) {
  1244. for (var i = 0; i < arr.length; i++) {
  1245. if(arr[i].id != -1 && arr[i].id != 0) {
  1246. if (arr[i].children != null && arr[i].children.length>0) {
  1247. arr[i].children = this.changeArr(arr[i].children);
  1248. }
  1249. arr[i].id && (arr[i].value = arr[i].id);
  1250. delete arr[i].id;
  1251. }
  1252. }
  1253. for(var i in arr) {
  1254. if(arr[i].id == -1 || arr[i].id == 0) {
  1255. arr.splice(i,1)
  1256. }
  1257. }
  1258. return arr;
  1259. },
  1260. // 自定义事件
  1261. selectCal(obj) {
  1262. console.log(obj)
  1263. if(obj.distinction == 1) {
  1264. let arr = []
  1265. for(var i in obj.arrUserList) {
  1266. arr.push(obj.arrUserList[i].id)
  1267. }
  1268. this.exportParam.userIds = arr
  1269. } else if(obj.distinction == 2) {
  1270. console.log(obj)
  1271. this.personnelValue = obj.name
  1272. this.personnel()
  1273. }
  1274. },
  1275. vueCasader(obj) {
  1276. if(obj.distinction == 1) {
  1277. console.log(obj, '数据')
  1278. let arr = []
  1279. arr.push(obj.id)
  1280. this.exportParam.deptId = arr
  1281. }
  1282. }
  1283. },
  1284. created() {
  1285. this.myChart = null
  1286. },
  1287. mounted() {
  1288. this.containerHeight = window.innerHeight - 200
  1289. // this.containerHeight = window.innerHeight - 130
  1290. const that = this;
  1291. window.onresize = function temp() {
  1292. this.containerHeight = window.innerHeight - 130
  1293. // this.containerHeight = window.innerHeight - 200
  1294. };
  1295. if(this.permissions.countCost){
  1296. this.yAxisValue = '0'
  1297. }else{
  1298. this.yAxisValue = '1'
  1299. }
  1300. if (this.user.timeType.fixMonthcost == 0) {
  1301. if (this.$route.query.startDate != null) {
  1302. this.dateRange = [this.$route.query.startDate, this.$route.query.endDate];
  1303. } else {
  1304. //默认查看本月
  1305. var now = new Date();
  1306. var t = util.formatDate.format(now, 'yyyy-MM-dd');
  1307. var startStr = util.formatDate.format(new Date(), 'yyyy-MM') + "-01";
  1308. this.dateRange = [startStr,t];
  1309. }
  1310. this.exportParam.dateRange = this.dateRange;
  1311. } else if (this.user.timeType.fixMonthcost == 1) {
  1312. if (this.$route.query.startDate != null) {
  1313. this.dateRange = this.$route.query.startDate;
  1314. } else {
  1315. //默认查看本月
  1316. var startStr = util.formatDate.format(new Date(), 'yyyy-MM');
  1317. this.dateRange = startStr;
  1318. }
  1319. this.exportParam.dateRange = this.dateRange;
  1320. }
  1321. this.radio = this.$t('other.project')
  1322. this.getEchart();
  1323. var _this = this;
  1324. window.addEventListener("resize", function() {
  1325. _this.myChart.resize();
  1326. });
  1327. // this.getDepartment();
  1328. this.getMyProjectList();
  1329. this.getUsers()
  1330. this.jutishez()
  1331. this.scrollFunction()
  1332. // 判断
  1333. if(this.user.timeType.userCustomStatic) {
  1334. this.getZDY()
  1335. }
  1336. this.getDepartmentList()
  1337. },
  1338. beforeDestroy () {
  1339. var myChart = echarts.init(document.getElementById("container"));
  1340. myChart.clear()
  1341. },
  1342. };
  1343. </script>
  1344. <style lang="scss" scoped>
  1345. #container {
  1346. // display: inline-block;
  1347. display: block;
  1348. position: absolute;
  1349. // width: 100% !important;
  1350. margin-top: 60px;
  1351. }
  1352. .ryuans {
  1353. top: -50px;
  1354. }
  1355. .prompt {
  1356. position: absolute;
  1357. right: 10px;
  1358. top: 0;
  1359. }
  1360. .poss {
  1361. position: fixed;
  1362. bottom: 10px;
  1363. right: 1%;
  1364. box-sizing: border-box;
  1365. }
  1366. </style>
  1367. <style lang="scss">
  1368. </style>