complete.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div class='flex flex-justify-start flex-col'>
  3. <span class='font-16 bold full-width text-left'>项目投资完成情况总览</span>
  4. <div class='full-width flex-justify-end flex'>
  5. <el-select v-model="month" class="m-2" placeholder="请选择" ref='month' clearable @change='changeMonth'>
  6. <el-option
  7. v-for="item in selectOption"
  8. :key="item.value"
  9. :label="item.label"
  10. :value="item.value"
  11. />
  12. </el-select>
  13. </div>
  14. <avue-crud
  15. :option="option"
  16. :data="data"
  17. ref="crud"
  18. v-model="form">
  19. </avue-crud>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. name: 'complete',
  25. props: {
  26. type: {
  27. type: Number,
  28. default: 0
  29. },
  30. deptId: {
  31. type: String,
  32. default: ''
  33. }
  34. },
  35. watch: {
  36. type: {
  37. handler (val) {
  38. this.initOption(val)
  39. },
  40. immediate: false
  41. },
  42. deptId: {
  43. handler (val) {
  44. this.onLoad()
  45. },
  46. immediate: true
  47. }
  48. },
  49. data () {
  50. return {
  51. month: '',
  52. quarter: '',
  53. form: {},
  54. data: [],
  55. option: {
  56. height: '800',
  57. align: 'center',
  58. menuAlign: 'center',
  59. menu: false,
  60. size: 'mini',
  61. addBtn: false,
  62. refreshBtn: false,
  63. columnBtn: false,
  64. border: true,
  65. index: true,
  66. column: [
  67. {
  68. label: '项目名称',
  69. prop: 'projectName'
  70. },
  71. {
  72. label: '计划完成投资(万元)',
  73. prop: 'yearlyPlanCompleteAmount'
  74. },
  75. {
  76. label: '完成投资(万元)',
  77. prop: 'yearlyCompleteAmount'
  78. },
  79. {
  80. label: '完成率',
  81. prop: 'rate'
  82. }
  83. ]
  84. },
  85. selectOption: []
  86. }
  87. },
  88. methods: {
  89. onLoad () {
  90. const data = {
  91. deptId: this.deptId === null ? '' : this.deptId,
  92. month: this.month,
  93. quarter: this.quarter
  94. }
  95. this.$api.invest.list(data).then(res => {
  96. if (res.code === 200) {
  97. this.data = res.data
  98. }
  99. })
  100. },
  101. initOption (res) {
  102. console.log('initOption')
  103. this.month = ''
  104. this.selectOption.length = 0
  105. switch (res.value) {
  106. case 1:
  107. for (let i = 1; i <= 3; i++) {
  108. const item = { label: i + '月', value: i }
  109. this.selectOption.push(item)
  110. }
  111. this.quarter = 1
  112. break
  113. case 2:
  114. for (let i = 4; i <= 6; i++) {
  115. const item = { label: i + '月', value: i }
  116. this.selectOption.push(item)
  117. }
  118. this.quarter = 2
  119. break
  120. case 3:
  121. for (let i = 7; i <= 9; i++) {
  122. const item = { label: i + '月', value: i }
  123. this.selectOption.push(item)
  124. }
  125. this.quarter = 3
  126. break
  127. case 4:
  128. for (let i = 10; i <= 12; i++) {
  129. const item = { label: i + '月', value: i }
  130. this.selectOption.push(item)
  131. }
  132. this.quarter = 4
  133. break
  134. default:
  135. for (let i = 1; i <= 12; i++) {
  136. const item = { label: i + '月', value: i }
  137. this.selectOption.push(item)
  138. this.month = ''
  139. this.quarter = ''
  140. }
  141. break
  142. }
  143. this.onLoad()
  144. },
  145. changeMonth (res) {
  146. console.log('changeMonth')
  147. this.month = res
  148. this.onLoad()
  149. }
  150. }
  151. }
  152. </script>
  153. <style lang='scss' scoped>
  154. .m-2 {
  155. }
  156. </style>