summary_dialog.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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">8</span> 个,请选择下面的字段信息,系统将对已选项自动进行汇总累加</span>
  13. <el-select
  14. v-model="keyWords"
  15. clearable
  16. placeholder="年份筛选"
  17. prefix-icon="Search"
  18. />
  19. </div>
  20. <div class="hide-scrollbar full-width mt-15" style="height: 20vh;overflow-x: scroll">
  21. <!-- <div v-if='attaches.length === 0' class='full-width flex flex-center '>-->
  22. <!-- <el-empty image-size='100'/>-->
  23. <!-- </div>-->
  24. <div class="flex flex-justify-between flex-center">
  25. <span class="bold font-15 grey ml-5 ">字段选择</span>
  26. </div>
  27. <div class="flex flex-wrap" v-if='selectIndex !== -1'>
  28. <div v-for="(item,index) in fieldType[selectIndex].params" :key='item.id'
  29. class="flex flex-center padding pointer">
  30. <el-checkbox v-model=item.checked :label="item.code" size="large" @change='change(selectIndex,index)'>
  31. {{ item.dictValue }}
  32. </el-checkbox>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="flex flex-center mt-20 mb-5">
  37. <base-button title="重置" type="0" icon="Refresh"/>
  38. <base-button class="ml-15" title="导出表格" icon="el-icon-download" @click='exportExcel'/>
  39. </div>
  40. </el-dialog>
  41. </div>
  42. </template>
  43. <script>
  44. import BaseButton from "@/components/base-button.vue";
  45. import uploads from "@/components/uploads.vue";
  46. export default {
  47. name: "summary_dialog",
  48. components: {BaseButton, uploads},
  49. props: {
  50. dialogType: {
  51. type: String,
  52. default: -1
  53. }
  54. },
  55. watch: {
  56. dialogType: {
  57. handler(val) {
  58. if (val === 2) {
  59. this.showSummary = true
  60. this.getDict('params_type')
  61. }
  62. },
  63. immediate: true
  64. }
  65. },
  66. data() {
  67. return {
  68. loading: false,
  69. active: 0,
  70. checked: true,
  71. showSummary: false,
  72. showExport: false,
  73. attaches: [],
  74. keyWords: '',
  75. code: '',
  76. fieldType: [],
  77. paramsList: [],
  78. checkList: [],
  79. selectIndex: -1,
  80. resultParams: []
  81. }
  82. },
  83. methods: {
  84. getDict(code) {
  85. this.$api.common.dicList({code}).then(res => {
  86. if (res.code === 200) {
  87. this.fieldType = res.data.map(e => {
  88. e.isSelect = false
  89. e.count = 0
  90. e.parmas = []
  91. return e
  92. })
  93. }
  94. })
  95. },
  96. close() {
  97. this.$emit('close')
  98. },
  99. upload(res) {
  100. console.log(res)
  101. this.attaches = res.fileList
  102. this.$message.success('操作成功')
  103. this.showImport = false
  104. },
  105. before(files) {
  106. console.log(files)
  107. this.attaches = files
  108. },
  109. removeFile(item) {
  110. this.attaches = this.attaches.filter(sub => sub.uid !== item.uid)
  111. },
  112. switchTab(item, index) {
  113. this.fieldType[index].isSelect = !this.fieldType[index].isSelect
  114. this.selectIndex = index
  115. if (this.fieldType[index].params === undefined) {
  116. this.$api.params.getListByKey({type: this.fieldType[index].dictKey}).then(res => {
  117. if (res.code === 200) {
  118. this.fieldType[index].params = res.data.records.map(e => {
  119. e.checked = true
  120. return e
  121. })
  122. this.fieldType[index].count = res.data.total
  123. }
  124. })
  125. }
  126. },
  127. importExcel() {
  128. this.$refs.upload.submit()
  129. },
  130. change(parentIndex, index) {
  131. const tmp = this.fieldType[parentIndex].params.filter(e => e.checked)
  132. this.fieldType[parentIndex].count = tmp.length
  133. for (let i = 0; i < tmp.length; i++) {
  134. console.log(tmp[i])
  135. this.resultParams.push(tmp[i])
  136. }
  137. },
  138. exportExcel() {
  139. const params = this.fieldType.filter(sub => sub.params).map(sub => sub.params)
  140. const tmps = [].concat.apply([], params)
  141. const tmpsList = tmps.filter(sub => sub.checked)
  142. if (tmpsList && tmpsList.length > 0) {
  143. const result = tmpsList.map(sub => sub.code).join(',')
  144. this.$emit('export', result)
  145. } else {
  146. this.$message.error('未选择任何字段进行导出')
  147. }
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .pic {
  154. width: 196px;
  155. height: 154px;
  156. margin-top: -20px;
  157. }
  158. .box-s {
  159. border: 1px solid #AC9A7C;
  160. width: 120px;
  161. height: 50px;
  162. color: #D1A55F;
  163. }
  164. .box {
  165. width: 120px;
  166. height: 50px;
  167. border: 1px solid transparent;
  168. background: #F1F2F7;
  169. color: #707070;
  170. }
  171. </style>