cost.vue 74 KB

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