cost.vue 82 KB

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