12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526 |
- <template>
- <section>
- <el-row style="padding-bottom: 0px;text-align:center;margin-top:20px;z-index: 999;">
- <el-col :span="6" >
- <div ><span style="color:#999;">{{ $t('chartY') }} </span>
- <el-radio-group v-model="yAxisValue" @change="onYAxisChange" size="small">
- <el-radio-button label="0" v-if="permissions.countCost">{{ $t('accordingtothecost') }}</el-radio-button>
- <el-radio-button label="1" v-if="permissions.countHours">{{ $t('accordingtoworkinghours') }}</el-radio-button>
- </el-radio-group></div>
- </el-col>
- <el-col :span="14" style="display: flex;flex-wrap: wrap;justify-content: flex-end;">
- <el-date-picker v-show="user.timeType.fixMonthcost==0" size="small"
- v-model="dateRange" :editable="false"
- format="yyyy-MM-dd" value-format="yyyy-MM-dd"
- @change="getEchart"
- :clearable="true"
- :range-separator="$t('other.to')"
- type="daterange"
- :start-placeholder="$t('time.startDate')"
- :end-placeholder="$t('time.endDate')"
- ></el-date-picker>
- <el-date-picker v-show="user.timeType.fixMonthcost==1"
- v-model="dateRange" :editable="false" size="small"
- format="yyyy-MM" value-format="yyyy-MM"
- @change="getEchart"
- :clearable="false"
- type="month"
- ></el-date-picker>
- <el-radio-group v-model="radio" @change="getEchart" style="margin-left:10px;" size="small" :disabled="radioLoading">
- <el-radio-button :label="$t('other.project')"></el-radio-button>
- <el-radio-button :label="$t('zhu-xiang-mu')" v-if="user.timeType.mainProjectState"></el-radio-button>
- <el-radio-button :label="$t('projectclassification')" v-if="user.companyId != '1071'"></el-radio-button>
- <el-radio-button :label="$t('lable.department')" v-if="permissions.viewAllSummary || permissions.viewMagDeptSummary"></el-radio-button>
- <el-radio-button :label="$t('ren-yuan')" v-if="permissions.countPersonnel"></el-radio-button>
- <el-radio-button :label="namess" v-if="jichu.customDegreeActive == 1 && !jichu.customDegreeMultiple"></el-radio-button>
- <el-radio-button v-for="item in theCustomList" :key="item.id" :label="item.name"></el-radio-button>
- </el-radio-group>
- <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">
- <el-option v-for="(item) in projectList" :key="item.id" :label="item.projectName + (item.projectCode ? item.projectCode : '')" :value="item.id">
- <span style="float: left;color: #8492a6;">{{ item.projectCode }}</span>
- <span style="float: right;font-size: 13px;margin-left: 20px">{{ item.projectName }}</span>
- </el-option>
- </el-select>
- <!--
- <el-select v-model="customName" filterable placeholder="请选择" style="margin-top: 10px;width: 350px" v-if="theCustomListFlg" @change="jieliu()">
- <el-option v-for="item in customList" :key="item.id" :label="item.name" :value="item.name"></el-option>
- </el-select> -->
- <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()"
- :disabled="hasReportUserList.length == 0 ? true : false">
- <el-option v-for="item in hasReportUserList" :key="item.id" :label="item.name" :value="item.name">
- <span style="float: left">{{ item.name }}</span>
- <span style="float: right; color: #8492a6; font-size: 13px;margin-left: 20px" v-if="item.jobNumber">{{ item.jobNumber }}</span>
- </el-option>
- </el-select>
- <span style="text-align: left">
- <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>
- </span>
- </el-col>
- <el-col :span="4">
- <el-button @click="exportProjectData" v-if="theCustomListFlg" size="small">{{ $t('reporderived') }}</el-button>
- <el-button @click="showExportDialog" v-else size="small">{{ $t('reporderived') }}</el-button>
- </el-col>
- </el-row>
- <!-- <div id="clearfix" :style="'width:'+widthHtval+'px;position: relative; height:'+containerHeight+'px;'">
- <div id="container" :style="'height:'+containerHeight+'px;width:100%'"></div>
- </div> -->
- <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">
- <div id="container" :style="'height:'+(containerHeight - 20)+'px;width:100%'"></div>
- <div class="poss">
- <el-pagination
- @size-change="echartsSizeChange"
- @current-change="echartsCurrentChange"
- :current-page="page"
- :page-sizes="[50]"
- :page-size="50"
- layout="total, sizes, prev, pager, next"
- :total="total">
- </el-pagination>
- </div>
- </div>
- <!-- <div>
- <div id="container" :style="'height:'+containerHeight+'px;width:100%'"></div>
- </div> -->
- <div style="position:fixed;top:170px;left:600px;" v-show="radio==$t('lable.department') && parentDeptId != null">
- <el-button @click="backToParentDept">{{ $t('returnsuperior') }}</el-button>
- </div>
- <!--导出报表条件选择 -->
- <el-dialog :title="$t('timeReportExport')" v-if="exportDialog" :visible.sync="exportDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
- <el-form ref="form3" :model="exportParam" >
- <el-form-item prop="projectCategoryId" :label="$t('projectclassification')" v-if="radio == $t('projectclassification')||radio==$t('other.project')">
- <el-select v-model="exportParam.projectCategoryId" :placeholder="$t('classificationitems')" clearable style="width:350px;" filterable="true">
- <el-option v-for="item in categoryList" :key="item.id" :label="item.name" :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- <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')">
- <el-select v-model="exportParam.projectId" :placeholder="$t('other.allProject')" clearable style="width:350px;" filterable="true" popper-class="projectSelectPopperClass">
- <el-option v-for="item in projectList" :key="item.id" :label="item.projectName + '/'+ item.projectCode" :value="item.id">
- <span style="float: left;color: #8492a6;">{{ item.projectCode }}</span>
- <span style="float: right;font-size: 13px;">{{ item.projectName }}</span>
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item prop="exportContent" label="导出内容" v-if="permissions.countCost && permissions.countHours && (radio == $t('other.project') || radio == $t('projectclassification'))">
- <el-select v-model="exportParam.exportContent" style="width:350px;" filterable="true" popper-class="projectSelectPopperClass">
- <el-option label="工时和成本" value="hoursAndCost"></el-option>
- <el-option label="仅工时" value="hours"></el-option>
- <el-option label="仅成本" value="cost"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item :label="$t('departmentchoice')" v-if="radio == $t('other.project')">
- <el-cascader v-if="user.userNameNeedTranslate != 1" v-model="exportParam.deptId" :options="departmentList" :placeholder="$t('defaultText.pleaseChoose')"
- :props="{ checkStrictly: true, expandTrigger: 'hover' }" clearable filterable style="width:350px;"
- ></el-cascader>
- <vueCascader :size="'medium'" :widthStr="'350'" :clearable="true" :subject="departmentList" :radios="true" :distinction="'1'" @vueCasader="vueCasader" v-if="user.userNameNeedTranslate == 1"></vueCascader>
- </el-form-item>
- <el-form-item prop="userIds" :label="$t('screening.selectPeople')" v-if="radio == $t('ren-yuan')">
- <el-select v-if="user.userNameNeedTranslate != '1'" v-model="exportParam.userIds" :placeholder="$t('lable.allStaff')" multiple="true" clearable style="width:350px;" filterable="true">
- <el-option v-for="item in hasReportUserList" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- <selectCat v-if="user.userNameNeedTranslate == '1'" :size="'medium'" :widthStr="'350'" :filterable="true" :subject="hasReportUserList" :clearable="true" :multiSelect="true" @selectCal="selectCal" :distinction="'1'"></selectCat>
- </el-form-item>
- <el-form-item prop="userIds" :label="$t('screening.selectPeople')" v-if="radio == $t('other.project') || radio == $t('projectclassification')">
- <el-select v-if="user.userNameNeedTranslate != '1'" v-model="exportParam.userIds" :placeholder="$t('lable.allStaff')" multiple="true" clearable style="width:350px;" filterable="true">
- <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- <selectCat v-if="user.userNameNeedTranslate == '1'" :size="'medium'" :widthStr="'350'" :filterable="true" :subject="users" :clearable="true" :multiSelect="true" @selectCal="selectCal" :distinction="'1'"></selectCat>
- </el-form-item>
- <el-form-item prop="projectId" :label="user.timeType.fixMonthcost==0?$t('time.dateRange'):$t('Selectmonth')">
- <el-date-picker v-show="user.timeType.fixMonthcost==0"
- v-model="exportParam.dateRange" :editable="false"
- format="yyyy-MM-dd" value-format="yyyy-MM-dd"
- :clearable="false"
- :range-separator="$t('other.to')"
- type="daterange"
- :start-placeholder="$t('time.startDate')"
- :end-placeholder="$t('time.endDate')"
- ></el-date-picker>
-
- <el-date-picker v-show="user.timeType.fixMonthcost==1"
- v-model="dateRange" :editable="false"
- format="yyyy-MM" value-format="yyyy-MM"
- @change="getEchart"
- :clearable="true"
- type="month"
- ></el-date-picker>
- </el-form-item>
-
- <el-form-item :label="$t('screening.selectPeople')" v-if="false">
- <el-select v-if="user.userNameNeedTranslate != '1'" v-model="exportParam.userId" :placeholder="$t('lable.allStaff')" style="width: 350px" filterable="true" clearable="true">
- <span v-for="(item, index) in users" :key="index">
- <el-option :label="item.name" :value="item.id"></el-option>
- </span>
- </el-select>
- <selectCat v-if="user.userNameNeedTranslate == '1'" :size="'medium'" :distinction="'4'" :widthStr="'350'" :subject="users" :clearable="true" @selectCal="selectCal"></selectCat>
- </el-form-item>
- <el-form-item prop="type" :label="$t('choosethestyle')" v-if="radio == $t('other.project') || radio == $t('projectclassification')">
- <el-select v-model="exportParam.type" :placeholder="$t('choosethestyle')" style="width:350px;" >
- <el-option :label="radio == $t('projectclassification') ? $t('classifiedontheline') : $t('Itemontheline')" value="0"></el-option>
- <el-option :label="radio == $t('projectclassification') ? $t('classifiedcolumns') : $t('itemisonthecolumn')" value="1"></el-option>
- </el-select>
- <div class="prompt">
- <el-popover placement="top" width="1200" trigger="hover">
- <img src="../../assets/image/hanglie.png" alt="" width="100%" v-if="this.radio != $t('projectclassification')">
- <img src="../../assets/image/hanglie_corp.png" alt="" width="100%" v-else>
- <i class="el-icon-question" slot="reference" />
- </el-popover>
- </div>
- </el-form-item>
- <el-form-item v-if="exportParam.type == 1 && permissions.countHours && (radio == $t('other.project'))">
- <el-checkbox v-model="exportParam.withPercent" >含项目工时占比</el-checkbox>
- </el-form-item>
- <el-form-item v-if="radio == $t('zhu-xiang-mu') || ((radio == $t('other.project') || radio == $t('projectclassification')) && exportParam.type == '0')">
- <el-checkbox v-model="exportParam.projectSum" >{{ $t('individualprojectdata') }}</el-checkbox>
- </el-form-item>
- <el-form-item v-if="radio == $t('ren-yuan') && user.timeType.mainProjectState == 1">
- <el-checkbox v-model="exportParam.mainProjectColumn" >含主项目</el-checkbox>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="exportProjectData" style="width:100%;" :loading="exporting">{{ $t('export.export') }}</el-button>
- </div>
- </el-dialog>
- </section>
- </template>
- <script>
- // 引入自定义组件
- import selectCat from "@/components/select.vue"
- //引入自定义级联组件
- import vueCascader from "@/components/cascader.vue"
- import util from "../../common/js/util";
- export default {
- components: {
- selectCat,
- vueCascader
- },
- data() {
- return {
- exporting: false,
- totalTime111: 0,
- allListData: [],
- page: 1,
- size: 50,
- total: 0,
- personnelValue: '',
- personnelAll: [],
- personnelAllPlly: [],
- yAxisValue: localStorage.yAxisValue?localStorage.yAxisValue:0,
- parentDeptStack:[],
- parentDeptId:null,
- hasReportUserList:[],
- projectList:[],
- categoryList: [],
- exportParam:{projectId:null,dateRange:[],userId: null,type: '0', withPercent: false},
- exportDialog:false,
- dateRange:[],
- user: JSON.parse(sessionStorage.getItem("user")),
- permissions: JSON.parse(sessionStorage.getItem("permissions")),
- radio: sessionStorage.radio!=null?sessionStorage.radio:this.$t('other.project'),
- containerHeight: 0,
- // myChart: null,
- params: null,
- widthHtval: document.body.clientWidth - 230,
- users: [],
- jichu: [],
- namess: '',
- timers: null, // 点击的时间
- zhishin: 0,
- theCustomList: [], // 自定义数据来源
- theCustomListFlg: false, // 判断是否点击的是自定义配置的数据来源
- theCustomListId: '',
- theCustomListPlantLIst: [],
- theCustomListPlant: '',
- customId: '',
- customName: '',
- customList: [],
- departmentList: [],
- radioLoading: false,
- proJuctId:'',
- };
- },
- methods: {
- echartsCurrentChange(val){
- this.page = val
- if(this.radio == this.$t('ren-yuan')){
- this.gtff()
- }else{
- this.jieliu_echarts()
- }
-
- },
- //Y轴点击改变显示的数据
- onYAxisChange() {
- localStorage.yAxisValue = this.yAxisValue;
- this.jieliu();
- },
- jutishez() {
- this.http.post('/time-type/getCompanyTimeSetting', {
- companyId: this.user.companyId,
- },
- res => {
- if (res.code == "ok") {
- this.jichu = res.data
- if(res.data.customDegreeActive == 1) {
- this.namess = res.data.customDegreeName
- }
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- getUsers() {
- this.http.post('/user/getSimpleActiveUserList', {},
- res => {
- if (res.code == "ok") {
- this.users = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
-
- showExportDialog() {
- // console.log(12345)
- // 清空选择的人
- if(this.radio == this.$t('ren-yuan')) {
- this.exportParam.userIds = new Array()
- }
- console.log(this.exportParam)
- this.exportDialog = true;
- this.exportParam.dateRange = this.dateRange;
- // console.log(this.hasReportUserList)
- if (this.radio == this.$t('ren-yuan')) {
- // this.exportParam.userIds = [];
- }
-
- if (this.radio == this.$t('other.project')) {
- this.exportParam.deptId = []
- }
- if(this.permissions.countCost && this.permissions.countHours && (this.radio == this.$t('other.project') || this.radio == this.$t('projectclassification'))){
- this.$set(this.exportParam, 'exportContent', 'hoursAndCost')
- }
- },
- //获取我的项目列表
- getMyProjectList() {
- this.http.post('/project/getProjectList', {
- },
- res => {
- if (res.code == "ok") {
- this.projectList = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- exportProjectData() {
- var param = {stateKey: 1};
- if (this.exportParam.dateRange != null) {
- param = {startDate:this.exportParam.dateRange[0], endDate: this.exportParam.dateRange[1],stateKey: 1};
- }
- var url = "/project/exportTimeCost";
- var fileName = this.$t('projectmanhourcoststatistics')+ '.xlsx';
- if (this.radio == this.$t('zhu-xiang-mu')) {
- param.withMainProject = 1;
- }
- if(this.radio == this.$t('other.project')){
- if (this.exportParam.userIds != null && this.exportParam.userIds.length > 0) {
- var ids = '';
- this.exportParam.userIds.forEach(u=>{
- ids += u+',';
- })
- param.userIds = ids.substring(0,ids.length-1);
- }
- if(this.exportParam.projectCategoryId){
- param.projectCategoryId = this.exportParam.projectCategoryId
- }
- //是否含工时占比显示
- if (this.exportParam.withPercent) {
- param.withPercent = 1;
- }
- }
- if (this.radio == this.$t('ren-yuan') ) {
- // console.log(this.exportParam.userIds);
- fileName = this.$t('labortimecoststatistics')+ '.xlsx';
- url = '/department/exportUserStatistic';
- if (this.exportParam.userIds != null && this.exportParam.userIds.length > 0) {
- var ids = '';
- this.exportParam.userIds.forEach(u=>{
- ids += u+',';
- })
- param.userIds = ids.substring(0,ids.length-1);
- }
- param.mainProjectColumn = this.exportParam.mainProjectColumn;
- }
- if(this.radio == this.$t('projectclassification')){
- fileName = this.$t('projectclassificationlaborosttatistics')+ '.xlsx';
- url = '/project/exportTimeCostByCategory'
- if(this.exportParam.projectCategoryId){
- param.projectCategoryId = this.exportParam.projectCategoryId
- }
- if (this.exportParam.userIds != null && this.exportParam.userIds.length > 0) {
- var ids = '';
- this.exportParam.userIds.forEach(u=>{
- ids += u+',';
- })
- param.userIds = ids.substring(0,ids.length-1);
- }
- }
- if(this.radio == this.$t('lable.department')){
- fileName = this.$t('departmenthourscoststatistics')+ '.xlsx'
- url = '/department/exportDeptStatistic'
- }
-
- if (this.exportParam.projectId && this.radio != this.$t('ren-yuan') && this.radio != this.$t('projectclassification')) {
- param.projectId = this.exportParam.projectId;
- }
- if (this.exportParam.userId) {
- if(this.radio == this.$t('lable.department') || this.radio == this.$t('ren-yuan')){
- param.userId = this.exportParam.userId;
- }
- }
- if (this.exportParam.type == 1) {
- this.exportParam.projectSum = null
- }
- if (this.exportParam.projectSum != null) {
- 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')){
- param.projectSum = this.exportParam.projectSum;
- }
- }
- if(!this.theCustomListFlg) {
- param.type = this.exportParam.type*1
- }
- console.log(this.radio)
- if(this.theCustomListFlg) {
- url = '/project/exportTimeCostByUserCustom'
- fileName = this.radio + this.$t('statistical') + '.xlsx'
- // param.subCustomName = this.customName
- param.customId = this.theCustomListId
- param.fieldName = this.theCustomListPlant
- }
- if(this.exportParam.deptId) {
- if(this.exportParam.deptId.length > 0) {
- param.deptId = this.exportParam.deptId[this.exportParam.deptId.length - 1]
- }
- }
- if(this.permissions.countCost && this.permissions.countHours && (this.radio == this.$t('other.project') || this.radio == this.$t('projectclassification'))){
- param.exportContent = this.exportParam.exportContent
- }
- if(this.radio == this.namess) {
- url = '/project/exportDegreeCost'
- param = {
- startDate:this.exportParam.dateRange[0],
- endDate: this.exportParam.dateRange[1],
- projectId: this.exportParam.projectId,
- }
- fileName = this.radio + '成本统计' + '.xlsx'
- }
- this.exporting = true;
- this.http.post(url, param,
- res => {
- this.exporting = false;
- if (res.code == "ok") {
- this.exportDialog = false;
- var aTag = document.createElement('a');
- aTag.download = fileName;
- aTag.href = res.data;
- aTag.click();
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.$message({
- message: error,
- type: "error"
- });
- this.exporting = false;
- });
- },
- // 人员筛选
- personnel() {
- this.page = 1
- if(this.personnelValue) {
- var arrlist = JSON.parse(JSON.stringify(this.personnelAllPlly))
- var arr = []
- for(var i in arrlist.list) {
- // console.log(arrlist.list[i].name, this.personnelValue)
- if(arrlist.list[i].name == this.personnelValue) {
- arr.push(arrlist.list[i])
- }
- }
- arrlist.list = arr
- this.allListData = arrlist
- // this.gtff()
- if(this.user.userNameNeedTranslate == '1') {
- if(arrlist.list.length > 0) {
- let list = arrlist.list
- let dealWithList = []
- for(var i in list) {
- let obj = {}
- obj.type = list[i].type
- obj.id = list[i].name
- dealWithList.push(obj)
- }
- this.dealWithTranslationPlone(dealWithList)
- } else {
- this.getUserCostList()
- }
- } else {
- this.allListData = arrlist
- this.gtff()
- }
- } else {
- this.allListData = this.personnelAllPlly
- this.gtff()
- }
- },
- //获取人员成本统计列表
- getUserCostList() {
- // console.log(this.port.project.userCost, '获取人员成本统计列表')
- // console.log(this.user.timeType.fixMonthcost)
- // console.log(Boolean(this.dateRange))
- let startDateNum = ''
- let endDateNum = ''
- if(this.dateRange) {
- startDateNum = this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange
- endDateNum = this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
- }
- // return
- this.http.post(this.port.project.userCost, {
- // startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange,
- // endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
- startDate: startDateNum,
- endDate: endDateNum
- },
- res => {
- this.radioLoading = false
- var _this = this;
- this.hasReportUserList = [];
- if (res.code == "ok") {
- let alltime = 0
- for(let i in res.data.list){
- for(let m in res.data.list[i].project){
- alltime += parseFloat(res.data.list[i].project[m].time)
- }
- }
- this.totalTime111 = alltime
- //
-
- //
- this.personnelAll = res.data
- this.allListData = res.data
- this.personnelAllPlly = JSON.parse(JSON.stringify(res.data))
- if(this.user.userNameNeedTranslate == '1') {
- let list = res.data.list
- let dealWithList = []
- for(var i in list) {
- let obj = {}
- obj.type = list[i].type
- obj.id = list[i].name
- dealWithList.push(obj)
- }
- this.dealWithTranslationPlone(dealWithList, res.data.list)
- } else {
- this.personnelAll = res.data
- this.allListData = res.data
- // console.log('人员返回', this.allListData);
- this.gtff()
- }
- } else {
- this.$message({
- message: res.msg + '里面',
- type: "error"
- });
- }
- },
- error => {
- this.radioLoading = false
- this.$message({
- message: error + '外面',
- type: "error"
- });
- });
- },
- // 共同方法
- gtff() {
- let data = this.allListData
- var _this = this;
- this.hasReportUserList = data.userList;
- this.total = data.list ? data.list.length : 0
- var totalHours = 0.0;
- var xList = [] , yList = [] , list = data.list.slice(0+50*(this.page-1),49+50*(this.page-1)), array = [] , series = [];
- var totalMoneyCost = data.totalCostMoney;
-
- for(var i in list) {
- if(i>20) {
- this.widthHtval = +this.widthHtval + 60
- } else {
- this.widthHtval = document.body.clientWidth - 230
- }
- }
- if (list.length > 0) {
- var num = list.length==0?0:list[0].project.length;
- // console.log('for 1');
- for(var i in list) {
- xList.push(list[i].name);
- var pro = list[i].project;
- for(var j in pro) {
- if(array.indexOf(pro[j].project) == -1) {
- array.push(pro[j].project)
- }
- }
- }
- // console.log('for 2');
- for(var i in array) {
- yList.push(array[i]);
- var dataList = [];
- let nameObj = {}
- list.forEach(item => {
- let moneyTol = 0;
- let timeTol = 0;
- item.project.forEach((project, index) => {
- moneyTol += +project.money;
- timeTol += +project.time;
- });
- // 假设每个 item.project 都至少有一个元素
- if (item.project.length > 0) {
- const lastProject = item.project[item.project.length - 1];
- nameObj[item.name] = {moneyTol: moneyTol, timeTol: timeTol}
- lastProject.moneyTol = moneyTol;
- lastProject.timeTol = timeTol;
- }
- });
- // console.log('==================>', list, nameObj);
- for(var j in list) {
- var project = list[j].project , num = 0;
- if(project.length != 0) {
- // console.log('for 2 1 1');
- for(var k in project) {
- if(project[k].project == array[i]) {
- let item = {
- "value": this.yAxisValue==0?project[k].money:project[k].time,
- }
- if(this.permissions.countCost){
- item.money = project[k].money
- }
- if(this.permissions.countHours){
- item.cost = project[k].time
- // totalHours += parseFloat(project[k].time);
- }
- if(project[k].moneyTol) {
- item.moneyTol = project[k].moneyTol
- item.timeTol = project[k].timeTol
- }
- dataList.push(item)
-
- } else {
- num++;
- }
- if(k == project.length-1 && num != project.length-1) {
- dataList.push({
- "value": 0,
- "cost": 0,
- "money":0,
- })
- }
- }
- } else {
- dataList.push({
- "value": 0,
- "cost": 0,
- "money":0,
- })
- }
- }
- // console.log(array[i], dataList, array, '《==============看看数据')
- let cerName = array[array.length - 1] // 最后一个项目
- let yAxisValue = this.yAxisValue
- series.push({
- name: array[i],
- type: 'bar',
- stack: '1',
- barMaxWidth: 30,
- data: dataList,
- label: {
- normal: {
- show: true,
- position: 'top',
- formatter: function(params) {
- const { seriesName, data, name} = params
- if(!name) {
- return ''
- }
- const unit = yAxisValue == 0 ? '元' : '小时';
- console.log(nameObj, name, nameObj[name], params)
- const totalValue = yAxisValue == 0 ? nameObj[name].moneyTol : nameObj[name].timeTol;
- return seriesName === cerName ? `${totalValue ? totalValue.toFixed(0) : 0} ${unit}` : '';
- }
- }
- }
- });
- }
- }
-
-
- var myChart = echarts.init(document.getElementById("container"));
- totalHours = this.totalTime111.toFixed(1);
- // 设置宽度
- myChart.resize({
- width: this.widthHtval
- })
- // console.log('设置宽度');
- // 设置宽度
- _this.myChart = myChart;
- var option = {
- //总成本
- title: {
- // text: '工时成本总计' + totalMoneyCost.toFixed(2) + '元, 时长'+totalHours+'小时',
- text: this.$t('otalhourscost')+ ':' +
- ((this.permissions.countCost) ? this.$t('costof') + ' ' + totalMoneyCost.toFixed(2) + ' ' + this.$t('yuan') + ',' : '') +
- ((this.permissions.countHours) ? this.$t('time.duration') + ' ' +totalHours + ' ' + this.$t('time.hour') : ''),
- left:'left',
- },
- // 工具箱
- legend: {
- x: 80,
- y: 10,
- data: yList,
- show: true,
- top:"5%",//与上方的距离 可百分比% 可像素px
- },
- grid : {
- top : 80, //距离容器上边界40像素
- // bottom: 100, //距离容器下边界30像素
- bottom: 35, //距离容器下边界30像素
- left: 150,
- right: 150
- },
- toolbox: {
- show: true,
- feature:{
- saveAsImage:{
- show: this.user.userNameNeedTranslate == 1 ? false : true
- },
- restore:{
- show:true
- },
- magicType:{
- type:['line','bar']
- }
- }
- },
- tooltip:{
- trigger:'axis',
- formatter: function (params,ticket,callback) {
- var totalTime = 0;
- var totalCost = 0;
- var res = "";
- for(var i in params) {
- if (params[i].data.value > 0) {
- res += "<div style='margin-top:3px;font-size:12px;'><font color='#ddd'>" + _this.$t('headerTop.projectName') + ":" + params[i].seriesName
- + "</font><br/>" +
- ((_this.permissions.countCost) ? _this.$t('workcost')+ ":" + params[i].data.money + _this.$t('yuan') + "</br>" : '') +
- ((_this.permissions.countHours) ? _this.$t('screening.workTime') + ":" + params[i].data.cost + _this.$t('time.hour') + "</br>" : '') + "</div>";
- totalTime += Number(params[i].data.cost);
- totalCost += Number(params[i].data.money);
- }
- }
- if(_this.user.userNameNeedTranslate != 1) {
- res = res +'<br/>'+ params[0].name+ '<br/>' + _this.$t('zong-ji') + ':' +
- ((_this.permissions.countHours) ? totalTime.toFixed(1) + _this.$t('time.hour') : '') +
- ((_this.permissions.countCost) ? totalCost.toFixed(2) + _this.$t('yuan') : '') +
- "<br/>";
- } else {
- res = res +'<br/>'+ '' + '<br/>' + _this.$t('zong-ji') + ':' +
- ((_this.permissions.countHours) ? totalTime.toFixed(1) + _this.$t('time.hour') : '') +
- ((_this.permissions.countCost) ? totalCost.toFixed(2) + _this.$t('yuan') : '') +
- "<br/>";
- }
-
- return res;
- }
- },
- xAxis: {
- data: xList,
- axisLabel: {
- interval:0,rotate:20
- }
- },
- yAxis: [{
- type : 'value',
- axisLabel: {
- formatter:this.yAxisValue==0?'{value} ('+this.$t('yuan')+')':'{value} ('+this.$t('time.hour')+')'
- // formatter:this.yAxisValue==0?'{value} (元)':'{value} (小时)'
- }
- }],
- series: series,
- };
- console.log('人员=======>', series)
- // console.log('setoption');
- myChart.setOption(option,{notMerge:true});
- },
- yanjiu() {
- // console.log('触发')
- },
- getEchart(e){
- var that = this
- // 更具选中的名字筛选出对应的自定义id
- that.theCustomListFlg = false
- let ints = null
- for(var i in that.theCustomList) {
- if(that.radio == that.theCustomList[i].name) {
- that.theCustomListId = that.theCustomList[i].id
- that.theCustomListPlant = that.theCustomListPlantLIst[i]
- that.theCustomListFlg = true
- ints = i
- }
- }
- if(that.theCustomListFlg) {
- that.customList = that.theCustomList[ints].subUserCustomList
- that.customName = that.theCustomList[ints].subUserCustomList[0].name
- // that.getCusTom()
- }
- that.jieliu()
- },
- getCusTom() {
- this.http.post('/sub-user-custom/list',{
- userCustomId: this.theCustomListId
- },res => {
- if(res.code == 'ok'){
- this.customList = res.data
- this.customName = res.data[0].name
- }else {
- this.$message({
- message: res.msg,
- type: 'error'
- })
- }
- },error => {
- this.$message({
- message: error,
- type: 'error'
- })
- })
- },
- getCategoryList(){
- this.http.post('/project-category/list',{},
- res => {
- if(res.code == 'ok'){
- this.categoryList = res.data
- }else {
- this.$message({
- message: res.msg,
- type: 'error'
- })
- }
- },err => {
- this.$message({
- message: err,
- type: 'error'
- })
- })
- },
- backToParentDept() {
- if (this.radio == this.$t('lable.department')) {
- if (this.parentDeptStack.length > 0) {
- this.parentDeptStack.pop();
- if (this.parentDeptStack.length > 0) {
- this.parentDeptId = this.parentDeptStack[this.parentDeptStack.length -1];
- } else {
- this.parentDeptId = null;
- }
- this.jieliu();
- }
- }
- },
- // 脱离出来的方法
- jieliu() {
- sessionStorage.radio = this.radio;
- this.radioLoading = true
- var param = {};
- if (this.dateRange != null) {
- param = {
- startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange,
- endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
- };
- // console.log(param);
- }
- var url = '';
- if (this.radio==this.$t('other.project')) {
- url = this.port.project.listCost;
- param.projectId=this.proJuctId
- param.type=this.yAxisValue
- }else if(this.radio == this.$t('zhu-xiang-mu')){
- url = '/project/getTimeCostByMainProject'
- // param.userId = this.user.id
- }else if (this.radio==this.$t('projectclassification')) {
- url = '/project/getTimeCostByCategory';
- // param.parentDeptId = this.parentDeptId;
- // param.userId = this.user.id
- } else if (this.radio==this.$t('lable.department')) {
- url = this.port.project.depCost;
- param.parentDeptId = this.parentDeptId;
- } else if (this.radio==this.$t('ren-yuan')) {
- this.getUserCostList();
- return;
- } else if (this.radio == this.namess) {
- url = '/project/getDegreeCost'
- param.projectId=this.proJuctId
- } else if (this.theCustomListFlg) {
- url = '/project/getTimeCostByUserCustom'
- // param.subCustomName = this.customName
- param.customId = this.theCustomListId
- param.fieldName = this.theCustomListPlant
- // console.log(param, '要传的数据')
- }
-
- this.http.post(url, param,
- res => {
- if (res.code == "ok") {
- this.radioLoading = false
- let alltime = 0
- if(this.radio==this.$t('other.project') || this.radio == this.$t('zhu-xiang-mu') || this.radio==this.$t('projectclassification')){
- for(let i in res.data.costList){
- alltime += parseFloat(res.data.costList[i].cost)
- }
- }else if(this.radio==this.$t('lable.department')){
- for(let i in res.data.costList){
- alltime += parseFloat(res.data.costList[i].costTime)
- }
- }else if(this.radio == this.namess){
- for(let i in res.data){
- alltime += parseFloat(res.data[i].cost)
- }
- }else if(this.theCustomListFlg){
- for(let i in res.data.list){
- alltime += parseFloat(res.data.list[i].cost)
- }
- }
- this.totalTime111 = alltime
- // additionName // 未转译的数据另外存储一份,用作 DOM 上渲染
- if(this.user.userNameNeedTranslate == '1') {
- for(var i in res.data.costList) {
- res.data.costList[i].additionName = res.data.costList[i].departmentName
- }
- }
- this.allListData = res.data
- this.page = 1
- if(this.user.userNameNeedTranslate == '1' && this.radio == this.$t('lable.department')) {
- let arr = []
- for(var i in this.allListData.costList) {
- let obj = {}
- obj.type = this.allListData.costList[i].type
- obj.id = this.allListData.costList[i].departmentName
- arr.push(obj)
- }
- this.dealWithTranslation(arr)
- } else {
- this.jieliu_echarts()
- }
- } else {
- this.radioLoading = false
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.radioLoading = false
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- dealWithTranslation(items) {
- if (WWOpenData.initCanvas) {
- WWOpenData.initCanvas()
- }
- const myFunOne = async () => {
- const result = await new Promise((resolve, reject) => {
- if(WWOpenData.prefetch) {
- WWOpenData.prefetch({ items }, (err, data) => {
- if (err) { return reject(err) }
- resolve(data)
- })
- }
-
- })
- for(var i in this.allListData.costList) {
- this.allListData.costList[i].departmentName = result.items[i].data
- }
- this.jieliu_echarts()
- }
-
- myFunOne()
- },
- dealWithTranslationPlone(items, dataList) {
- if (WWOpenData.initCanvas) {
- WWOpenData.initCanvas()
- }
- const myFunOne = async () => {
- const result = await new Promise((resolve, reject) => {
- if(WWOpenData.prefetch) {
- WWOpenData.prefetch({ items }, (err, data) => {
- if (err) { return reject(err) }
- resolve(data)
- })
- }
- })
- for(var i in this.allListData.list) {
- if(result.items[i]) {
- this.allListData.list[i].name = result.items[i].data
- }
- }
- this.gtff()
- }
- myFunOne()
- },
- jieliu_echarts(){
- var _this = this;
- // 更具数据的长度去加每个柱子的间距
- var xList = []
- var yList = []
- var list
- var totalMoneyCost;
- var totalHours = 0.0;
- 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')) {
- // this.allListData = res.data.costList
- this.total = this.allListData.costList ? this.allListData.costList.length : 0
-
- list = this.allListData.costList.slice(0+50*(this.page-1),49+50*(this.page-1))
- for(var i in list) {
- if(i>20) {
- this.widthHtval = +this.widthHtval + 60
- } else {
- this.widthHtval = document.body.clientWidth - 230
- }
- }
- // list = res.data.costList
- totalMoneyCost = ((this.radio==this.$t('other.project') || this.radio == this.$t('projectclassification'))?this.allListData.totalMoneyCost:this.allListData.totalCostMoney);
- for(var i in list) {
- if(this.radio==this.$t('other.project') || this.radio == this.$t('zhu-xiang-mu')) {
- if(this.radio == this.$t('other.project')){
- xList.push(list[i].project);
- }else{
- xList.push(list[i].mainProjectName);
- }
-
- let item = {
- "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),
- "id": list[i].id || i,
- }
- if(this.permissions.countCost){
- // item.money = list[i].costMoney.toFixed(2)
- item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
- }
- if(this.permissions.countHours){
- item.cost = list[i].cost
- totalHours += parseFloat(list[i].cost);
- }
- yList.push(item);
-
- } else if(this.radio == this.$t('lable.department')){
- xList.push(list[i].departmentName);
- let item = {
- // "value": this.yAxisValue==0 ? list[i].costMoney.toFixed(2) || list[i].costMoney: list[i].costTime.toFixed(1),
- "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),
- "id": list[i].departmentId,
- "hasSubDept": list[i].hasSubDept
- }
- if(this.permissions.countCost){
- // item.money = list[i].costMoney.toFixed(2)
- item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
- }
- if(this.permissions.countHours){
- item.cost = list[i].costTime
- totalHours += parseFloat(list[i].costTime);
- }
- yList.push(item);
-
- }else {
- xList.push(list[i].categoryName);
- let item = {
- // "value": this.yAxisValue==0?list[i].costMoney.toFixed(2) || list[i].costMoney:list[i].cost.toFixed(1),
- "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),
- "id": list[i].id || i,
- }
- if(this.permissions.countCost){
- // item.money = list[i].costMoney.toFixed(2)
- item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
- }
- if(this.permissions.countHours){
- item.cost = list[i].cost
- totalHours += parseFloat(list[i].cost);
- }
- yList.push(item);
- }
- }
- }
- else if(this.theCustomListFlg) {
- // this.allListData = res.data.list ? res.data.list : []
- this.total = this.allListData.list ? this.allListData.list.length : 0
- list = this.total ? this.allListData.list.slice(0+50*(this.page-1),49+50*(this.page-1)) : []
- // list = res.data.list
-
- for(var i in list) {
- xList.push(list[i].name);
- let item = {
- "value": this.yAxisValue==0?list[i].costMoney:list[i].cost,
- "id": list[i].id || i,
- }
- if(this.permissions.countCost){
- // item.money = list[i].costMoney.toFixed(2)
- item.money = list[i].costMoney ? list[i].costMoney.toFixed(2) : 0
- totalMoneyCost += parseFloat(list[i].costMoney);
- }
- if(this.permissions.countHours){
- item.cost = list[i].cost
- totalHours += parseFloat(list[i].cost);
- }
- yList.push(item);
-
- }
- }
- else {
- //自定义列表:data:{cost:3, costMoney:222}
- this.total = this.allListData ? this.allListData.length : 0
- // if(this.total){
- list = this.allListData.slice(0+50*(this.page-1),49+50*(this.page-1))
- // }else{
- // list =
- // }
- // list = this.total ? : []
-
- for(var i in list) {
- xList.push(list[i].name);
- let item = {
- "value": this.yAxisValue==0?list[i].costMoney:list[i].cost,
- "id": list[i].id || i,
- }
- if(this.permissions.countCost){
- // item.money = list[i].costMoney.toFixed(2)
- item.money = list[i].costMoney ? list[i].costMoney.toFixed(2) : 0
- totalMoneyCost += parseFloat(list[i].costMoney);
- }
- if(this.permissions.countHours){
- item.cost = list[i].cost
- totalHours += parseFloat(list[i].cost);
- }
- yList.push(item);
-
- }
- }
- totalHours = this.totalTime111.toFixed(1);
- var myChart = echarts.init(document.getElementById("container"));
- myChart.resize({
- width: this.widthHtval
- })
- _this.myChart = myChart;
- if(totalMoneyCost) {
- this.zhishin = totalMoneyCost.toFixed(2)
- } else {
- this.zhishin = 0
- }
- 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')) {
- var option = {
- title: {
- 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') : ''),
- left:'left',
- },
- // 工具箱
- toolbox: {
- show: true,
- feature:{
- saveAsImage:{show:this.user.userNameNeedTranslate == 1 ? false : true},restore:{show:true}, magicType:{ type:['line','bar']},
- }
- },
- tooltip:{
- trigger:'axis',
- formatter: function (params,ticket,callback) {
- _this.params = params;
- var res
- if(_this.user.userNameNeedTranslate != '1') {
- var res = params[0].name + "<br/>" +
- ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
- + _this.$t('yuan')+"<br/>" : '') +
- ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
- } else {
- var res = "<TranslationOpenDataText type='departmentName' :openid='"+ _this.allListData.costList[params[0].dataIndex].additionName +"'></TranslationOpenDataText>" + "<br/>" +
- ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
- + _this.$t('yuan')+"<br/>" : '') +
- ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
- }
-
- return res;
- }
- },
- xAxis: {
- data: xList,
- axisLabel: {
- interval:0,rotate:20
- }
- },
- yAxis: [{
- type : 'value',
- axisLabel: {
- formatter:this.yAxisValue==0?'{value} ('+this.$t('yuan')+')':'{value}'+this.$t('time.hour')
- }
- }],
- series: [{
- name: this.yAxisValue==0?this.$t('workcost')+'('+this.$t('yuan')+')':this.$t('screening.workTime')+'('+this.$t('time.hour')+')',
- type: 'bar',
- barMaxWidth: 30,
- data: yList,
- label: {
- normal: {
- show: true,
- position: 'top',
- formatter: `{c} ${this.yAxisValue==0 ? '元' : '小时'}`,
- }
- }
- }],
- grid: {
- left: '100px',
- }
- };
- } else {
- var option = {
- title: {
- // text: '工时成本总计' + this.zhishin + '元, 时长'+totalHours+'小时',
- 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') : ''),
- left:'left',
- },
- // 工具箱
- toolbox: {
- show: true,
- feature:{
- saveAsImage:{show:this.user.userNameNeedTranslate == 1 ? false : true},restore:{show:true}, magicType:{ type:['line','bar']},
- }
- },
- tooltip:{
- trigger:'axis',
- formatter: function (params,ticket,callback) {
- var res = params[0].name + "<br/>" +
- ((_this.permissions.countCost) ? _this.$t('workcost')+" : " + params[0].data.money
- + _this.$t('yuan')+"<br/>" : '') +
- ((_this.permissions.countHours) ? _this.$t('screening.workTime')+" : " + params[0].data.cost + _this.$t('time.hour') : '');
- _this.params = params;
- return res;
- }
- },
- xAxis: {
- data: xList,
- axisLabel: {
- interval:0,rotate:20
- }
- },
- yAxis: [{
- type : 'value',
- axisLabel: {
- formatter:this.yAxisValue==0?'{value} ('+this.$t('yuan')+')':'{value}'+this.$t('time.hour')
- }
- }],
- series: [{
- name: this.yAxisValue==0?this.$t('workcost')+'('+this.$t('yuan')+')':this.$t('screening.workTime')+'('+this.$t('time.hour')+')',
- type: 'bar',
- barMaxWidth: 30,
- data: yList,
- label: {
- normal: {
- show: true,
- position: 'top',
- formatter: `{c} ${this.yAxisValue==0 ? '元' : '小时'}`,
- }
- }
- }],
- grid: {
- left: '100px',
- }
- };
- }
-
- myChart.setOption(option,{notMerge: true});
- myChart.getZr().on('click', params => {
- const pointInPixel = [params.offsetX, params.offsetY];
- if (myChart.containPixel('grid', pointInPixel)) {
- if(_this.radio==this.$t('other.project')) {
- if (_this.dateRange != null) {
- if (this.user.timeType.fixMonthcost == 0) {
- _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
- +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
- } else {
- _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name
- +"?startDate="+_this.dateRange+"&endDate="+_this.dateRange);
- }
- } else {
- _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name);
- }
- } else if (_this.radio==this.$t('lable.department')) {
- if (_this.params[0].data.hasSubDept) {
- if (_this.parentDeptId != _this.params[0].data.id) {
- _this.parentDeptId = _this.params[0].data.id;
- _this.parentDeptStack.push(_this.parentDeptId);
- _this.jieliu();
- }
- // _this.jieliu();
- } else {
- if (_this.dateRange != null) {
- _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name
- +"?startDate="+_this.dateRange[0]+"&endDate="+_this.dateRange[1]);
- } else {
- _this.$router.push("/costDep/" + _this.params[0].data.id + "/" + _this.params[0].name);
- }
- }
- }
- }
- });
- },
- // 左右滚动
- scrollFunction () {
- this.domObj = document.getElementById('clearfix') // 通过id获取要设置的div
- if (this.domObj.attachEvent) { // IE
- this.domObj.attachEvent('onmousewheel', this.mouseScroll)
- } else if (this.domObj.addEventListener) {
- this.domObj.addEventListener('DOMMouseScroll', this.mouseScroll, false)
- }
- this.domObj.onmousewheel = this.domObj.onmousewheel = this.mouseScroll
- },
- mouseScroll(event) { // google 浏览器下
- let detail = event.wheelDelta || event.detail
- let moveForwardStep = -1
- let moveBackStep = 1
- let step = 0
- step = detail > 0 ? moveForwardStep * 100 : moveBackStep * 100
- event.preventDefault() // 阻止浏览器默认事件
- this.domObj.scrollLeft = this.domObj.scrollLeft + step
- },
- // 判断后端给的字段
- // 获取自定义
- getZDY() {
- this.http.post('/user-custom/getUserCustomTitle',{},res => {
- if(res.code == 'ok'){
- this.theCustomList = res.data.result
- this.theCustomListPlantLIst = res.data.field
- }else {
- this.$message({
- message: res.msg,
- type: 'error'
- })
- }
- },error => {
- this.$message({
- message: error,
- type: 'error'
- })
- })
- },
- // 获取部门
- getDepartmentList() {
- this.http.post( this.port.manage.depList, {},
- res => {
- if (res.code == "ok") {
- let dptlist = JSON.parse(JSON.stringify(res.data));
- this.departmentList = this.changeArr(dptlist);
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },error => {
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- changeArr(arr) {
- for (var i = 0; i < arr.length; i++) {
- if(arr[i].id != -1 && arr[i].id != 0) {
- if (arr[i].children != null && arr[i].children.length>0) {
- arr[i].children = this.changeArr(arr[i].children);
- }
- arr[i].id && (arr[i].value = arr[i].id);
- delete arr[i].id;
- }
- }
- for(var i in arr) {
- if(arr[i].id == -1 || arr[i].id == 0) {
- arr.splice(i,1)
- }
- }
- return arr;
- },
- // 自定义事件
- selectCal(obj) {
- if(obj.distinction == 1) {
- let arr = []
- for(var i in obj.arrUserList) {
- arr.push(obj.arrUserList[i].id)
- }
- this.exportParam.userIds = arr
- } else if(obj.distinction == 2) {
- this.personnelValue = obj.name
- this.personnel()
- } else if(obj.distinction == 4) {
- this.exportParam.userId = obj.id
- }
- },
- vueCasader(obj) {
- if(obj.distinction == 1) {
- let arr = []
- arr.push(obj.id)
- this.exportParam.deptId = arr
- }
- }
- },
- created() {
- this.myChart = null
- },
- mounted() {
- this.containerHeight = window.innerHeight - 200
- // this.containerHeight = window.innerHeight - 130
- const that = this;
- window.onresize = function temp() {
- this.containerHeight = window.innerHeight - 130
- // this.containerHeight = window.innerHeight - 200
- };
- if(this.permissions.countCost){
- this.yAxisValue = '0'
- }else{
- this.yAxisValue = '1'
- }
- if (this.user.timeType.fixMonthcost == 0) {
- if (this.$route.query.startDate != null) {
- this.dateRange = [this.$route.query.startDate, this.$route.query.endDate];
- } else {
- //默认查看本月
- var now = new Date();
- var t = util.formatDate.format(now, 'yyyy-MM-dd');
- var startStr = util.formatDate.format(new Date(), 'yyyy-MM') + "-01";
- this.dateRange = [startStr,t];
- }
- this.exportParam.dateRange = this.dateRange;
- } else if (this.user.timeType.fixMonthcost == 1) {
- if (this.$route.query.startDate != null) {
- this.dateRange = this.$route.query.startDate;
- } else {
- //默认查看本月
- var startStr = util.formatDate.format(new Date(), 'yyyy-MM');
- this.dateRange = startStr;
- }
- this.exportParam.dateRange = this.dateRange;
- }
- this.radio = this.$t('other.project')
- this.getEchart();
- var _this = this;
- window.addEventListener("resize", function() {
- _this.myChart.resize();
- });
- // this.getDepartment();
- this.getMyProjectList();
- this.getCategoryList();
- this.getUsers()
- this.jutishez()
- this.scrollFunction()
- // 判断
- if(this.user.timeType.userCustomStatic) {
- this.getZDY()
- }
- this.getDepartmentList()
- },
- beforeDestroy () {
- var myChart = echarts.init(document.getElementById("container"));
- myChart.clear()
- },
- };
- </script>
- <style lang="scss" scoped>
- #container {
- // display: inline-block;
- display: block;
- position: absolute;
- // width: 100% !important;
- margin-top: 60px;
- }
- .ryuans {
- top: -50px;
- }
- .prompt {
- position: absolute;
- right: 10px;
- top: 0;
- }
- .poss {
- position: fixed;
- bottom: 10px;
- right: 1%;
- box-sizing: border-box;
- }
- </style>
- <style lang="scss">
- </style>
|