planImplementation.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div>
  3. <el-dialog
  4. :title="generalData.title || '计划进度'"
  5. :visible.sync="generalShow"
  6. width="80%"
  7. top="5vh"
  8. append-to-body
  9. :center="generalData.titleCenter || false"
  10. custom-class="customClass"
  11. @close="close"
  12. >
  13. <div class="stopCenter">
  14. <div v-if="generalData.alertShow" class="tableTop">
  15. <el-alert
  16. :title="generalData.alert.title || ''"
  17. type="success"
  18. :description="generalData.alert.description || ''"
  19. :closable="false"
  20. />
  21. </div>
  22. <el-row>
  23. <el-col :span="5">
  24. <div :style="{ height: height + 'px'}">
  25. <div ref="chart1" class="chart" />
  26. <div class="leftContent">
  27. {{ generalData.leftData.leftContent || '' }}
  28. </div>
  29. </div>
  30. </el-col>
  31. <el-col :span="19">
  32. <div id="chart2" ref="chart2" class="chart2" :style="{ height: height + 'px'}" />
  33. </el-col>
  34. </el-row>
  35. </div>
  36. </el-dialog>
  37. </div>
  38. </template>
  39. <script>
  40. import planImplementationJS from './planImplementationJS'
  41. export default {
  42. mixins: [planImplementationJS],
  43. props: {
  44. show: {
  45. type: Boolean,
  46. default: false
  47. },
  48. generalList: {
  49. type: Array,
  50. default: () => {
  51. return []
  52. }
  53. }
  54. },
  55. data () {
  56. return {
  57. generalShow: this.show,
  58. id: '',
  59. generalData: {
  60. title: '', // 弹出框标题
  61. titleCentr: false, // 弹出框标题是否区中
  62. alertShow: false, // 提示是否显示
  63. alert: {
  64. title: '', // 提示标题
  65. description: '' // 提示内容
  66. },
  67. leftData: {
  68. leftTotal: 0, // 左图数量
  69. title: '', // 左图标题,默认"完成率"
  70. leftContent: ''
  71. },
  72. rightCustomShow: false, // 右图自定义
  73. rightData: {
  74. direction: 'x',
  75. title: '人数', // 右图标题
  76. xAxisName: '', // 右图x轴标题
  77. yAxisName: '', // 右图y轴标题
  78. yAxisData: ['金源信通'], // 右图y轴项
  79. series: [{
  80. name: '总数', // 右图x轴项
  81. data: [''], // 右图x轴数量
  82. label: {
  83. show: true,
  84. position: 'right',
  85. textStyle: { // 数值样式
  86. color: 'black',
  87. fontSize: 12
  88. },
  89. formatter: (params) => {
  90. // 这个回调函数不起作用了
  91. return params.value === '0' ? '' : params.value
  92. }
  93. }
  94. }],
  95. color: ['rgb(55, 162, 218)', 'rgb(103, 224, 227)', 'rgb(253, 102, 109)'], // 颜色
  96. tooltip: { // 右图弹出框
  97. show: true,
  98. trigger: 'axis'
  99. }
  100. }
  101. },
  102. height: 300
  103. }
  104. },
  105. watch: {
  106. show: {
  107. handler () {
  108. // this.generalShow = this.show
  109. },
  110. deep: true,
  111. immediate: true
  112. }
  113. },
  114. created () {
  115. this.generalData = this.generalList[0]
  116. const height = this.generalData.rightData.yAxisData.length * 100
  117. this.height = this.generalData.rightData.direction === 'x' ? 400 : height > 300 ? height : 300
  118. setTimeout(() => {
  119. this.getOption(this.generalData.leftData)
  120. this.barDataPlan(this.generalData.rightData, this.generalData.rightCustomShow, this.generalData.rightData.direction)
  121. }, 100)
  122. },
  123. methods: {
  124. close () {
  125. this.$emit('generalClose', false)
  126. }
  127. }
  128. }
  129. </script>
  130. <style scoped>
  131. .stopCenter{
  132. min-height: 350px;
  133. max-height: 800px;
  134. margin: 20px 30px 20px 30px;
  135. }
  136. .tableTop{
  137. margin: 0 0 10px 0;
  138. }
  139. .chart{
  140. width: 100%;
  141. height: 250px;
  142. }
  143. .chart2{
  144. width: 100%;
  145. min-height: 300px;
  146. }
  147. .leftContent{
  148. font-size: 20px;
  149. line-height: 30px;
  150. padding: 10px;
  151. text-align: center;
  152. }
  153. </style>