cost.vue 80 KB

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