power-plan.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div class="power-plan">
  3. <!-- <tab @select="selectionItemClick" :data="currTabs" class="power-plan-tab" /> -->
  4. <row
  5. style="margin-top: 47px"
  6. @click="
  7. openDialog(
  8. '计划电量完成详情',
  9. 'genreset/findProjectPlanPower',
  10. 'doneLineChart'
  11. )
  12. "
  13. >
  14. <Col :span="12">
  15. <!-- <percent-card-2 :title="'月完成率' + parseInt((planData.yfdl / planData.yfdljh) * 100) + '%'" TotalText="实际" ActualText="计划" :TotalValue="planData.yfdl" :ActualValue="planData.yfdljh" :percent="planData.ywcl" /> -->
  16. <percent-card-2
  17. :title="''"
  18. TotalText="月实际"
  19. ActualText="月计划"
  20. :TotalValue="planData.yfdl"
  21. :ActualValue="planData.yfdljh"
  22. :percent="planData.ywcl"
  23. />
  24. </Col>
  25. <Col :span="12">
  26. <!-- <percent-card-2 :title="'年完成率' + parseInt((planData.nfdl / planData.nfdljh) * 100) + '%'" TotalText="实际" ActualText="计划" :TotalValue="planData.nfdl" :ActualValue="planData.nfdljh" :percent="planData.nwcl" /> -->
  27. <percent-card-2
  28. :title="''"
  29. TotalText="年实际"
  30. ActualText="年计划"
  31. :TotalValue="planData.nfdl"
  32. :ActualValue="planData.nfdljh"
  33. :percent="planData.nwcl"
  34. />
  35. </Col>
  36. </row>
  37. </div>
  38. </template>
  39. <script>
  40. import Col from "@/components/coms/grid/col.vue";
  41. import Row from "@/components/coms/grid/row.vue";
  42. import Tab from "@/components/coms/tabs/tab.vue";
  43. import PercentCard2 from "../../../components/coms/cards/percent-card-2.vue";
  44. export default {
  45. components: { Row, Col, Tab, PercentCard2 },
  46. data() {
  47. return {
  48. planData: {},
  49. wpId: "",
  50. showTitle: "",
  51. // tab项
  52. tabs: [
  53. {
  54. id: "1",
  55. text: "",
  56. },
  57. ],
  58. // 月计划完成率
  59. monthPlan: {
  60. plan: 100,
  61. actual: 40,
  62. },
  63. // 年计划完成率
  64. yearPlan: {
  65. plan: 100,
  66. actual: 25,
  67. },
  68. };
  69. },
  70. props: {
  71. showSingle: {
  72. type: Boolean,
  73. default: false,
  74. },
  75. data: {
  76. type: Object,
  77. default: () => {},
  78. },
  79. id: {
  80. type: String,
  81. default: "",
  82. },
  83. title: {
  84. type: String,
  85. default: "",
  86. },
  87. },
  88. computed: {
  89. currTabs() {
  90. if (this.showSingle) {
  91. return [
  92. {
  93. id: "1",
  94. text: "风电",
  95. },
  96. ];
  97. } else return this.tabs;
  98. },
  99. },
  100. mounted() {
  101. this.planData = this.data;
  102. this.wpId = this.id;
  103. this.tabs[0].text = this.title;
  104. },
  105. methods: {
  106. selectionItemClick(item) {
  107. // 点击tab选项 模拟数据变化
  108. // 动态改变子组件数据变化
  109. this.monthPlan = {
  110. plan: 100,
  111. actual: 25,
  112. };
  113. this.yearPlan = {
  114. plan: 100,
  115. actual: 45,
  116. };
  117. },
  118. openDialog(dialogTitle, subUrl, dialogType) {
  119. let that = this;
  120. that.API.requestData({
  121. method: "POST",
  122. subUrl,
  123. data: {
  124. id: that.wpId,
  125. },
  126. success(res) {
  127. let key = [
  128. {
  129. key: "value1",
  130. title: "月计划发电量",
  131. },
  132. {
  133. key: "value2",
  134. title: "年计划发电量",
  135. },
  136. {
  137. key: "value3",
  138. title: "月发电量",
  139. },
  140. {
  141. key: "value4",
  142. title: "年发电量",
  143. },
  144. ];
  145. let doneLineChartData = {
  146. // 图表所用单位
  147. units: [""],
  148. value: [],
  149. };
  150. key.forEach((keyEle, keyIndex) => {
  151. doneLineChartData.value.push({
  152. title: keyEle.title,
  153. yAxisIndex: 0, // 使用单位
  154. value: [],
  155. });
  156. res.data.forEach((ele) => {
  157. doneLineChartData.value[keyIndex].value.push({
  158. text: ele.name,
  159. value: ele[keyEle.key],
  160. });
  161. });
  162. });
  163. that.$emit("chartClick", {
  164. dialogTitle,
  165. dialogType,
  166. data: doneLineChartData,
  167. });
  168. },
  169. });
  170. },
  171. },
  172. watch: {
  173. data(res) {
  174. this.planData = res;
  175. },
  176. id(res) {
  177. this.wpId = res;
  178. },
  179. title(res) {
  180. this.tabs[0].text = res;
  181. },
  182. },
  183. };
  184. </script>
  185. <style lang="less">
  186. .power-plan {
  187. padding: 0 1.481vh;
  188. .power-plan-tab {
  189. margin-bottom: 2.222vh;
  190. }
  191. }
  192. </style>