summary_dialog.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <div>
  3. <!-- 汇总数据导出-->
  4. <el-dialog v-model='showSummary'
  5. append-to-body
  6. center
  7. @close="close"
  8. title="汇总数据导出"
  9. width="45%">
  10. <div class="flex flex-col flex-center">
  11. <span
  12. class="bold mb-10">共找到符合条件的项目 <span class="blue font-15">{{ selectNum }}</span> 个,请选择下面的字段信息,系统将对已选项自动进行汇总累加</span>
  13. <el-select
  14. v-model="year"
  15. clearable
  16. placeholder="年份筛选"
  17. prefix-icon="Search"
  18. >
  19. <el-option
  20. v-for="item in yearList"
  21. :key="item"
  22. :label="item"
  23. :value="item"
  24. />
  25. </el-select>
  26. </div>
  27. <div class="hide-scrollbar full-width mt-15" style="height: 20vh;overflow-x: scroll">
  28. <div class="flex flex-justify-between flex-center">
  29. <span class="bold font-15 grey ml-5 ">字段选择</span>
  30. </div>
  31. <div class="flex flex-wrap">
  32. <div v-for="(item,index) in fieldType" :key='item.id'
  33. class="flex flex-center padding pointer">
  34. <el-checkbox v-model=item.checked :label="item.code" size="large">
  35. {{ item.dictValue }}
  36. </el-checkbox>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="flex flex-center mt-20 mb-5">
  41. <base-button title="重置" type="0" icon="Refresh"/>
  42. <base-button class="ml-15" title="导出表格" icon="el-icon-download" @click='exportExcel'/>
  43. </div>
  44. </el-dialog>
  45. </div>
  46. </template>
  47. <script>
  48. import BaseButton from '@/components/base-button.vue'
  49. export default {
  50. name: 'summary_dialog',
  51. components: {BaseButton},
  52. props: {
  53. dialogType: {
  54. type: String,
  55. default: -1
  56. },
  57. selectNum: {
  58. type: Number,
  59. default: 0
  60. }
  61. },
  62. watch: {
  63. dialogType: {
  64. handler(val) {
  65. if (val === 2) {
  66. this.showSummary = true
  67. this.getDict('summary_field')
  68. } else if (val === -1) {
  69. this.showSummary = false
  70. }
  71. },
  72. immediate: true
  73. }
  74. },
  75. data() {
  76. return {
  77. year: '',
  78. loading: false,
  79. checked: true,
  80. showSummary: false,
  81. code: '',
  82. fieldType: [],
  83. yearList: []
  84. }
  85. },
  86. created() {
  87. this.init()
  88. },
  89. methods: {
  90. init() {
  91. const year = new Date().getFullYear()
  92. for (let i = year - 10; i <= year; i++) {
  93. this.yearList.push(i)
  94. }
  95. },
  96. getDict(code) {
  97. this.$api.common.dicList({code}).then(res => {
  98. if (res.code === 200) {
  99. this.fieldType = res.data.map(e => {
  100. e.checked = true
  101. return e
  102. })
  103. }
  104. })
  105. },
  106. close() {
  107. this.$emit('close')
  108. },
  109. exportExcel() {
  110. const tmp = this.fieldType.filter(e => e.checked).map(sub => sub.dictKey)
  111. if (this.year.length === 0) {
  112. this.$message.error('请选择年份')
  113. return
  114. }
  115. if (tmp.length === 0) {
  116. this.$message.error('请选择要导出的字段')
  117. return
  118. }
  119. const data = {columnName: tmp.join(','), year: this.year}
  120. this.$emit('export', data)
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .pic {
  127. width: 196px;
  128. height: 154px;
  129. margin-top: -20px;
  130. }
  131. .box-s {
  132. border: 1px solid #AC9A7C;
  133. width: 120px;
  134. height: 50px;
  135. color: #D1A55F;
  136. }
  137. .box {
  138. width: 120px;
  139. height: 50px;
  140. border: 1px solid transparent;
  141. background: #F1F2F7;
  142. color: #707070;
  143. }
  144. </style>