earning.vue 15 KB

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