123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530 |
- <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="1" v-if="permissions.countHours">{{ $t('accordingtoworkinghours') }}</el-radio-button>
- <el-radio-button label="0" v-if="permissions.countCost">{{ $t('accordingtothecost') }}</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) && !user.dingdingUserid"></el-radio-button>
- <el-radio-button :label="$t('ren-yuan')" v-if="permissions.countPersonnel && !user.dingdingUserid"></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: '1',
- 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() {
- 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.permissions.countHours){
- 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;
- }
- if(this.$route.query && this.$route.query.endDate && this.$route.query.startDate) {
- const { endDate, startDate } = this.$route.query
- const lastDay = this.dayjs(`${endDate}-01`).endOf('month').format('YYYY-MM-DD');
- this.dateRange = [startDate+'-01', lastDay];
- }
- 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>
|