earning.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <div :style="'padding:10px;background:#f7f7f7;min-height:'+tableHeight+'px;'">
  3. <div style="margin: 0 auto;width:1120px;">
  4. <el-row :gutter="10">
  5. <el-col :span="24">
  6. <div class="box" style="height:650px;">
  7. <div >
  8. <div class="lableTxt">项目利润快照<el-button type="default" size="small" style="float:right;margin-left:10px;" @click="cancelDelete" v-if="deleteTxt == '确认删除'">取消操作</el-button><el-button type="default" size="small" style="float:right;" @click="showDeleteBox">{{deleteTxt}}</el-button></div>
  9. <el-divider></el-divider>
  10. <!--利润率列表-->
  11. <el-table :data="list" highlight-current-row v-loading="listLoading" max-height="300" :height="300" style="width: 100%;" @selection-change="handleSelectionChange">
  12. <el-table-column prop="indate" label="校准日期" ></el-table-column>
  13. <el-table-column prop="profit" align="right" >
  14. <template slot="header">
  15. <span>利润</span>
  16. <el-popover placement="top" width="200" trigger="hover" content="利润 = (合同金额 - 总成本)">
  17. <i class="el-icon-question" slot="reference" />
  18. </el-popover>
  19. </template>
  20. <template slot-scope="scope" >
  21. ¥{{scope.row.profit | numberToCurrency}}
  22. </template>
  23. </el-table-column>
  24. <el-table-column prop="profitPercent" label="利润率B" align="right">
  25. <template slot="header">
  26. <span>利润率</span>
  27. <el-popover placement="top" width="350" trigger="hover" content="利润率 = (合同金额 - 总成本)/合同金额">
  28. <i class="el-icon-question" slot="reference" />
  29. </el-popover>
  30. </template>
  31. <template slot-scope="scope">
  32. {{scope.row.profitPercent| numberToCurrency}}%
  33. </template>
  34. </el-table-column>
  35. <el-table-column prop="contractAmount" label="合同金额" width="150" align="right">
  36. <template slot-scope="scope">
  37. <span >¥{{scope.row.contractAmount | numberToCurrency}}</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="基线成本" align="center">
  41. <el-table-column v-for="item in costFields" :prop="contractAmount" :label="item.baseName" :key="item.id" align="right">
  42. <template slot-scope="scope">
  43. <span v-if="scope.row.costList.filter(c=>c.baseId == item.baseId)[0]">
  44. ¥{{scope.row.costList.filter(c=>c.baseId == item.baseId)[0].baseAmount | numberToCurrency}}
  45. </span>
  46. <!-- ¥{{scope.row.costList.filter(c=>c.baseId == item.baseId)[0].baseAmount | numberToCurrency}} -->
  47. </template>
  48. </el-table-column>
  49. <!--
  50. <el-table-column prop="baseMan" label="人员成本">
  51. <template slot-scope="scope">
  52. ¥{{scope.row.baseMan | numberToCurrency}}
  53. </template>
  54. </el-table-column>
  55. <el-table-column prop="baseFee" label="费用">
  56. <template slot-scope="scope">
  57. ¥{{scope.row.baseFee | numberToCurrency}}
  58. </template>
  59. </el-table-column>
  60. <el-table-column prop="baseOutsourcing" label="外包费用">
  61. <template slot-scope="scope">
  62. ¥{{scope.row.baseOutsourcing | numberToCurrency}}
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="baseRisk1" label="风险预留金额1" width="150">
  66. <template slot-scope="scope">
  67. ¥{{scope.row.baseRisk1 | numberToCurrency}}
  68. </template>
  69. </el-table-column>
  70. <el-table-column prop="baseRisk2" label="风险预留金额2" width="150">
  71. <template slot-scope="scope">
  72. ¥{{scope.row.baseRisk2 | numberToCurrency}}
  73. </template>
  74. </el-table-column> -->
  75. </el-table-column>
  76. <el-table-column label="备注" prop="remark">
  77. <template slot-scope="scope">
  78. <div style="font-size:10px;overflow:hidden;width:100px;height:25px;">
  79. <el-tooltip class="item" effect="dark" :content="scope.row.remark" placement="top-start">
  80. <span>{{scope.row.remark}}</span>
  81. </el-tooltip>
  82. </div>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="选择" width="55" type="selection" v-if="deleteTxt == '确认删除'">
  86. </el-table-column>
  87. </el-table>
  88. <el-divider ></el-divider>
  89. <!--图形显示 -->
  90. <div id="chartPanel" style="height: 300px;width: 1100px;"></div>
  91. </div>
  92. </div>
  93. </el-col>
  94. </el-row>
  95. </div>
  96. </div>
  97. </template>
  98. <style scoped>
  99. #executorPanel {
  100. display: inline-block;
  101. width: 100%;
  102. }
  103. .el-divider--horizontal {
  104. margin: 10px 0;
  105. height: 0.5px;
  106. }
  107. .box {
  108. background:#fff;border: 1px solid #eeeeee;border-radius:5px;padding:10px;
  109. height:303.7px;margin-top:10px;
  110. }
  111. .info span {
  112. color:#303133;
  113. }
  114. .gray_label {
  115. color:#999 !important;
  116. }
  117. .el-row {
  118. margin-top:10px;
  119. }
  120. .lableTxt {
  121. color:#666;
  122. }
  123. </style>
  124. <script>
  125. import util from "../../common/js/util";
  126. export default {
  127. data() {
  128. return {
  129. costFields:[],
  130. selectionArray:[],
  131. deleteTxt:"删除记录",
  132. yList3:[],
  133. yList2:[],
  134. yList1:[],
  135. xList:[],
  136. list:[],
  137. profitChart:null,
  138. pVisible:false,
  139. taskSum:{},
  140. users:[],
  141. importanceList:[{id:1,label:'一般'},{id:2,label:'紧急'},{id:3,label:'重要'},{id:4,label:'重要且紧急'}],
  142. //1-一般,2-紧急,3-重要,4-重要且紧急
  143. levelTxt:["全部","一般","紧急","重要","重要且紧急"],
  144. //1-进行中,2-已完成,3-已撤销
  145. statusTxt: ["全部","进行中","已完成","已撤销"],
  146. addFolderDialog: false,
  147. upLoading:false,
  148. user: JSON.parse(sessionStorage.getItem("user")),
  149. addLoading: false,
  150. curProjectId:null,
  151. title: "",
  152. };
  153. },
  154. filters: {
  155. numberToCurrency(value) {
  156. console.log('earning numberToCurrency='+value);
  157. if (!value) return '0.00'
  158. value = value.toFixed(2)
  159. const intPart = Math.trunc(value)
  160. const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
  161. let floatPart = '.00'
  162. const valueArray = value.toString().split('.')
  163. if (valueArray.length === 2) { // 有小数部分
  164. floatPart = valueArray[1].toString() // 取得小数部分
  165. return intPartFormat + '.' + floatPart
  166. }
  167. return intPartFormat + floatPart
  168. }
  169. },
  170. methods: {
  171. handleSelectionChange(value) {
  172. this.selectionArray = value;
  173. console.log(this.selectionArray);
  174. },
  175. cancelDelete() {
  176. this.deleteTxt = "删除记录";
  177. },
  178. showDeleteBox() {
  179. if (this.deleteTxt == '删除记录') {
  180. this.deleteTxt = "确认删除";
  181. } else {
  182. if (this.selectionArray.length == 0) {
  183. this.$message({
  184. message: '请先选择要删除的记录',
  185. type: "error"
  186. });
  187. return;
  188. }
  189. this.$confirm("确定要删除该记录吗吗?","删除记录", {
  190. confirmButtonText: "确定",
  191. cancelButtonText: "取消",
  192. type: "warning"
  193. })
  194. .then(() => {
  195. //调接口删除
  196. this.listLoading = true;
  197. var ids = '';
  198. this.deleteTxt = "删除记录";
  199. for (var i=0;i<this.selectionArray.length; i++) {
  200. ids += this.selectionArray[i].id+',';
  201. }
  202. this.http.post('/earning-snapshot/delete',{
  203. ids: ids, projectId:this.curProjectId
  204. },
  205. res => {
  206. this.listLoading = false;
  207. if (res.code == "ok") {
  208. this.getProfitSnapshot();
  209. } else {
  210. this.$message({
  211. message: res.msg,
  212. type: "error"
  213. });
  214. }
  215. },
  216. error => {
  217. this.listLoading = false;
  218. this.$message({
  219. message: error,
  220. type: "error"
  221. });
  222. }
  223. );
  224. }
  225. );
  226. }
  227. },
  228. getProfitSnapshot() {
  229. let _this = this;
  230. this.xList = [];
  231. this.yList1 = [];
  232. this.http.post('/earning-snapshot/list', {projectId: this.curProjectId},
  233. res => {
  234. if (res.code == "ok") {
  235. var list = JSON.parse(JSON.stringify(res.data)).reverse();
  236. if (list.length > 0) {
  237. this.costFields = list[0].costList;
  238. }
  239. _this.list = res.data;
  240. for (var m=0;m<list.length; m++) {
  241. this.xList.push(list[m].indate);
  242. this.yList1.push(list[m].profitPercent);
  243. }
  244. //图表展示
  245. var myChart = echarts.init(document.getElementById("chartPanel"));
  246. this.profitChart = myChart;
  247. console.log("mychart",myChart);
  248. myChart.setOption({
  249. title: {
  250. textStyle: {
  251. color: "#666666",
  252.   fontSize: 18,
  253. fontWeight: 'normal',
  254.  },
  255.   text: list.length == 0?"暂无数据":"利润率趋势图",
  256.   left: list.length == 0?"center":"left",
  257.   top: list.length == 0?"center":"left"
  258. },
  259. toolbox: {
  260. show: true,
  261. feature:{
  262. saveAsImage:{
  263. show:true
  264. },
  265. }
  266. },
  267. tooltip:{
  268. trigger: 'axis'
  269. },
  270. legend: {
  271. data: ['利润率(%)']
  272. },
  273. grid: {
  274. left: '3%',
  275. right: '4%',
  276. bottom: '3%',
  277. containLabel: true
  278. },
  279. xAxis: {
  280. type: 'category',
  281. boundaryGap: false,
  282. data: this.xList
  283. },
  284. yAxis: {
  285. type: 'value'
  286. },
  287. series : [
  288. {
  289. name: '利润率(%)',
  290. type: 'line',
  291. stack: '百分比',
  292. data: this.yList1
  293. },
  294. ]
  295. },{notMerge: true})
  296. } else {
  297. this.$message({
  298. message: res.msg,
  299. type: "error"
  300. });
  301. }
  302. },
  303. error => {
  304. this.$message({
  305. message: error,
  306. type: "error"
  307. });
  308. });
  309. },
  310. refreshPage() {
  311. this.curProjectId = parseInt(this.$route.params.id);
  312. this.getProfitSnapshot();
  313. }
  314. },
  315. created() {
  316. let height = window.innerHeight;
  317. this.tableHeight = height - 160;
  318. const that = this;
  319. window.onresize = function temp() {
  320. that.tableHeight = window.innerHeight - 160;
  321. };
  322. },
  323. mounted() {
  324. this.curProjectId = parseInt(this.$route.params.id);
  325. // var _this = this;
  326. var that = this
  327. console.log("this",this)
  328. window.addEventListener("resize", function() {
  329. // _this.profitChart.resize();
  330. // that.profitChart.resize();
  331. });
  332. this.getProfitSnapshot(); // 调用图表方法
  333. }
  334. };
  335. </script>
  336. <style scoped>
  337. </style>