index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>报表中心
  5. </h2>
  6. <div class="m-core">
  7. <div class="m-wrap">
  8. <div class="title">课酬导出:</div>
  9. <el-date-picker v-model="mouth"
  10. type="month"
  11. placeholder="选择月"
  12. value-format="yyyy-MM-dd"></el-date-picker>
  13. <div class="newBand"
  14. @click="exportSalar"
  15. v-permission="'export/teacherSalary'">导出</div>
  16. <el-tooltip placement="top"
  17. popper-class="mTooltip">
  18. <div slot="content">
  19. 将只导出当前选择月份已结算的课程课酬。
  20. </div>
  21. <!-- <img :src="imageIcon" class="micon el-tooltip" style="width:8px height:8px" alt /> -->
  22. <i class="el-icon-question micon el-tooltip"
  23. style="font-size: 18px; color: #F56C6C"></i>
  24. </el-tooltip>
  25. </div>
  26. <el-divider></el-divider>
  27. <div class="m-core">
  28. <div class="m-wrap">
  29. <div class="title">乐团招生汇总:
  30. </div>
  31. <el-select v-model.trim="organIdList"
  32. class="organSelect"
  33. style="width:100%"
  34. filterable
  35. multiple
  36. clearable>
  37. <el-option v-for="(item,index) in organList"
  38. :key="index"
  39. :label="item.name"
  40. :value="item.id"></el-option>
  41. </el-select>
  42. <div class="newBand"
  43. @click="exportMusicGroup"
  44. v-permission="'export/musicGroupRegister'">导出</div>
  45. <el-tooltip placement="top"
  46. popper-class="mTooltip">
  47. <div slot="content">
  48. 请选择分部后,导出招生情况汇总表,分部可多选
  49. </div>
  50. <i class="el-icon-question micon el-tooltip"
  51. style="font-size: 18px; color: #F56C6C"></i>
  52. </el-tooltip>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. import { exportTeacherSalary } from '@/api/generalSettings'
  60. import { getEmployeeOrgan } from "@/api/buildTeam";
  61. import axios from 'axios'
  62. import {
  63. getToken
  64. } from '@/utils/auth'
  65. import load from '@/utils/loading'
  66. import qs from 'qs'
  67. export default {
  68. name: "reportForm",
  69. data () {
  70. return {
  71. mouth: "",
  72. organList: [],
  73. organIdList: []
  74. // imageIcon: require("@/assets/images/base/warning.png")
  75. };
  76. },
  77. mounted () {
  78. getEmployeeOrgan().then(res => {
  79. if (res.code == 200) {
  80. this.organList = res.data;
  81. }
  82. });
  83. },
  84. methods: {
  85. exportSalar () {
  86. if (!this.mouth) {
  87. this.$message.error('请选择导出月份')
  88. return
  89. }
  90. let url = '/api-web/export/teacherSalary'
  91. let data = { date: this.mouth }
  92. const options = {
  93. method: 'POST',
  94. headers: {
  95. 'Authorization': getToken()
  96. },
  97. data: qs.stringify(data),
  98. url,
  99. responseType: 'blob'
  100. }
  101. this.$confirm('您确定导出课酬', '提示', {
  102. confirmButtonText: '确定',
  103. cancelButtonText: '取消',
  104. type: 'warning'
  105. }).then(() => {
  106. load.startLoading()
  107. axios(options).then(res => {
  108. let blob = new Blob([res.data], {
  109. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  110. type: 'application/vnd.ms-excel;charset=utf-8'
  111. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  112. })
  113. let text = (new Response(blob)).text()
  114. text.then(res => {
  115. // 判断是否报错
  116. if (res.indexOf('code') != -1) {
  117. let json = JSON.parse(res)
  118. this.$message.error(json.msg)
  119. } else {
  120. let objectUrl = URL.createObjectURL(blob)
  121. let link = document.createElement("a")
  122. let nowTime = new Date()
  123. let ymd = nowTime.getFullYear() + '' + (nowTime.getMonth() + 1) + '' + nowTime.getDate()
  124. let fname = ymd + '课酬' //下载文件的名字
  125. link.href = objectUrl
  126. link.setAttribute("download", fname)
  127. document.body.appendChild(link)
  128. link.click()
  129. }
  130. })
  131. load.endLoading();
  132. }).catch(error => {
  133. this.$message.error('导出数据失败,请联系管理员');
  134. load.endLoading();
  135. })
  136. }).catch(() => { })
  137. },
  138. exportMusicGroup () {
  139. if (this.organIdList.length < 1) {
  140. this.$message.error('请至少选择一个分部')
  141. return
  142. }
  143. let url = '/api-web/export/musicGroupRegister'
  144. let data = { date: this.organIdList.join(',') }
  145. const options = {
  146. method: 'POST',
  147. headers: {
  148. 'Authorization': getToken()
  149. },
  150. data: qs.stringify(data),
  151. url,
  152. responseType: 'blob'
  153. }
  154. this.$confirm('您确定导出招生情况汇总表', '提示', {
  155. confirmButtonText: '确定',
  156. cancelButtonText: '取消',
  157. type: 'warning'
  158. }).then(() => {
  159. load.startLoading()
  160. axios(options).then(res => {
  161. let blob = new Blob([res.data], {
  162. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  163. type: 'application/vnd.ms-excel;charset=utf-8'
  164. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  165. })
  166. let text = (new Response(blob)).text()
  167. text.then(res => {
  168. // 判断是否报错
  169. if (res.indexOf('code') != -1) {
  170. let json = JSON.parse(res)
  171. this.$message.error(json.msg)
  172. } else {
  173. let objectUrl = URL.createObjectURL(blob)
  174. let link = document.createElement("a")
  175. let nowTime = new Date()
  176. let ymd = nowTime.getFullYear() + '' + (nowTime.getMonth() + 1) + '' + nowTime.getDate()
  177. let fname = ymd + '招生情况汇总表' //下载文件的名字
  178. link.href = objectUrl
  179. link.setAttribute("download", fname)
  180. document.body.appendChild(link)
  181. link.click()
  182. }
  183. })
  184. load.endLoading();
  185. }).catch(error => {
  186. this.$message.error('导出数据失败,请联系管理员');
  187. load.endLoading();
  188. })
  189. }).catch(() => { })
  190. }
  191. }
  192. };
  193. </script>
  194. <style lang="scss" scoped>
  195. .m-container {
  196. .m-core {
  197. margin-top: 20px;
  198. .m-wrap {
  199. display: flex;
  200. flex-direction: row;
  201. justify-content: flex-start;
  202. width: 100%;
  203. // align-items: center;
  204. .newBand {
  205. margin: 0 5px 0 10px;
  206. }
  207. .title {
  208. width: 120px;
  209. height: 40px;
  210. line-height: 40px;
  211. text-align: right;
  212. color: #606266;
  213. }
  214. .organSelect {
  215. width: 220px !important;
  216. }
  217. .el-tooltip.micon {
  218. width: 20px;
  219. height: 20px;
  220. position: relative;
  221. top: 12px;
  222. }
  223. }
  224. }
  225. }
  226. /deep/.el-input__icon.el-icon-date {
  227. height: 40px !important;
  228. }
  229. </style>