index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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"
  24. v-permission="'export/teacherSalary'"></i>
  25. </el-tooltip>
  26. </div>
  27. <el-divider></el-divider>
  28. <div class="m-core">
  29. <div class="m-wrap">
  30. <div class="title">乐团招生汇总:
  31. </div>
  32. <el-select v-model.trim="organIdList"
  33. class="organSelect"
  34. style="width:100%"
  35. filterable
  36. multiple
  37. clearable>
  38. <el-option v-for="(item,index) in organList"
  39. :key="index"
  40. :label="item.name"
  41. :value="item.id"></el-option>
  42. </el-select>
  43. <div class="newBand"
  44. @click="exportMusicGroup"
  45. v-permission="'export/musicGroupRegister'">导出</div>
  46. <el-tooltip placement="top"
  47. popper-class="mTooltip">
  48. <div slot="content">
  49. 请选择分部后,导出招生情况汇总表,分部可多选
  50. </div>
  51. <i class="el-icon-question micon el-tooltip"
  52. v-permission="'export/musicGroupRegister'"
  53. style="font-size: 18px; color: #F56C6C"></i>
  54. </el-tooltip>
  55. </div>
  56. </div>
  57. <el-divider></el-divider>
  58. <div class="m-core">
  59. <div class="m-wrap">
  60. <div class="title">老师默认课酬:
  61. </div>
  62. <el-select v-model.trim="teacherDefaultSalaryOrganId"
  63. class="organSelect"
  64. style="width:100%"
  65. filterable
  66. clearable>
  67. <el-option v-for="(item,index) in organList"
  68. :key="index"
  69. :label="item.name"
  70. :value="item.id"></el-option>
  71. </el-select>
  72. <div class="newBand"
  73. @click="exportDefaultSalary"
  74. v-permission="'export/teacherDefaultSalary'">导出</div>
  75. <el-tooltip placement="top"
  76. popper-class="mTooltip">
  77. <div slot="content">
  78. 请选择分部后,导出老师列表及老师课酬信息
  79. </div>
  80. <i class="el-icon-question micon el-tooltip"
  81. style="font-size: 18px; color: #F56C6C"
  82. v-permission="'export/teacherDefaultSalary'"></i>
  83. </el-tooltip>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </template>
  89. <script>
  90. import { exportTeacherSalary } from '@/api/generalSettings'
  91. import { getEmployeeOrgan } from "@/api/buildTeam";
  92. import axios from 'axios'
  93. import {
  94. getToken
  95. } from '@/utils/auth'
  96. import load from '@/utils/loading'
  97. import qs from 'qs'
  98. export default {
  99. name: "reportForm",
  100. data () {
  101. return {
  102. mouth: "",
  103. organList: [],
  104. organIdList: [],
  105. teacherDefaultSalaryOrganId: ''
  106. // imageIcon: require("@/assets/images/base/warning.png")
  107. };
  108. },
  109. mounted () {
  110. getEmployeeOrgan().then(res => {
  111. if (res.code == 200) {
  112. this.organList = res.data;
  113. }
  114. });
  115. },
  116. methods: {
  117. exportSalar () {
  118. if (!this.mouth) {
  119. this.$message.error('请选择导出月份')
  120. return
  121. }
  122. let url = '/api-web/export/teacherSalary'
  123. let data = { date: this.mouth }
  124. const options = {
  125. method: 'POST',
  126. headers: {
  127. 'Authorization': getToken()
  128. },
  129. data: qs.stringify(data),
  130. url,
  131. responseType: 'blob'
  132. }
  133. this.$confirm('您确定导出课酬', '提示', {
  134. confirmButtonText: '确定',
  135. cancelButtonText: '取消',
  136. type: 'warning'
  137. }).then(() => {
  138. load.startLoading()
  139. axios(options).then(res => {
  140. let blob = new Blob([res.data], {
  141. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  142. type: 'application/vnd.ms-excel;charset=utf-8'
  143. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  144. })
  145. let text = (new Response(blob)).text()
  146. text.then(res => {
  147. // 判断是否报错
  148. if (res.indexOf('code') != -1) {
  149. let json = JSON.parse(res)
  150. this.$message.error(json.msg)
  151. } else {
  152. let objectUrl = URL.createObjectURL(blob)
  153. let link = document.createElement("a")
  154. let nowTime = new Date()
  155. let ymd = nowTime.getFullYear() + '' + (nowTime.getMonth() + 1) + '' + nowTime.getDate()
  156. let fname = ymd + '课酬' //下载文件的名字
  157. link.href = objectUrl
  158. link.setAttribute("download", fname)
  159. document.body.appendChild(link)
  160. link.click()
  161. }
  162. })
  163. load.endLoading();
  164. }).catch(error => {
  165. this.$message.error('导出数据失败,请联系管理员');
  166. load.endLoading();
  167. })
  168. }).catch(() => { })
  169. },
  170. exportMusicGroup () {
  171. if (this.organIdList.length < 1) {
  172. this.$message.error('请至少选择一个分部')
  173. return
  174. }
  175. let url = '/api-web/export/musicGroupRegister'
  176. let data = { organIds: this.organIdList.join(',') }
  177. const options = {
  178. method: 'POST',
  179. headers: {
  180. 'Authorization': getToken()
  181. },
  182. data: qs.stringify(data),
  183. url,
  184. responseType: 'blob'
  185. }
  186. this.$confirm('您确定导出招生情况汇总表', '提示', {
  187. confirmButtonText: '确定',
  188. cancelButtonText: '取消',
  189. type: 'warning'
  190. }).then(() => {
  191. load.startLoading()
  192. axios(options).then(res => {
  193. let blob = new Blob([res.data], {
  194. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  195. type: 'application/vnd.ms-excel;charset=utf-8'
  196. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  197. })
  198. let text = (new Response(blob)).text()
  199. text.then(res => {
  200. // 判断是否报错
  201. if (res.indexOf('code') != -1) {
  202. let json = JSON.parse(res)
  203. this.$message.error(json.msg)
  204. } else {
  205. let objectUrl = URL.createObjectURL(blob)
  206. let link = document.createElement("a")
  207. let nowTime = new Date()
  208. let ymd = nowTime.getFullYear() + '' + (nowTime.getMonth() + 1) + '' + nowTime.getDate()
  209. let fname = ymd + '招生情况汇总表' //下载文件的名字
  210. link.href = objectUrl
  211. link.setAttribute("download", fname)
  212. document.body.appendChild(link)
  213. link.click()
  214. }
  215. })
  216. load.endLoading();
  217. }).catch(error => {
  218. this.$message.error('导出数据失败,请联系管理员');
  219. load.endLoading();
  220. })
  221. }).catch(() => { })
  222. },
  223. exportDefaultSalary () {
  224. if (!this.teacherDefaultSalaryOrganId) {
  225. this.$message.error('请选择一个分部')
  226. return
  227. }
  228. let url = '/api-web/export/teacherDefaultSalary'
  229. let data = { organId: this.teacherDefaultSalaryOrganId }
  230. const options = {
  231. method: 'POST',
  232. headers: {
  233. 'Authorization': getToken()
  234. },
  235. data: qs.stringify(data),
  236. url,
  237. responseType: 'blob'
  238. }
  239. this.$confirm('您确定导出老师默认课酬表', '提示', {
  240. confirmButtonText: '确定',
  241. cancelButtonText: '取消',
  242. type: 'warning'
  243. }).then(() => {
  244. load.startLoading()
  245. axios(options).then(res => {
  246. let blob = new Blob([res.data], {
  247. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  248. type: 'application/vnd.ms-excel;charset=utf-8'
  249. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  250. })
  251. let text = (new Response(blob)).text()
  252. text.then(res => {
  253. // 判断是否报错
  254. if (res.indexOf('code') != -1) {
  255. let json = JSON.parse(res)
  256. this.$message.error(json.msg)
  257. } else {
  258. let objectUrl = URL.createObjectURL(blob)
  259. let link = document.createElement("a")
  260. let nowTime = new Date()
  261. let ymd = nowTime.getFullYear() + '' + (nowTime.getMonth() + 1) + '' + nowTime.getDate()
  262. let fname = ymd + '老师默认课酬表' //下载文件的名字
  263. link.href = objectUrl
  264. link.setAttribute("download", fname)
  265. document.body.appendChild(link)
  266. link.click()
  267. }
  268. })
  269. load.endLoading();
  270. }).catch(error => {
  271. this.$message.error('导出数据失败,请联系管理员');
  272. load.endLoading();
  273. })
  274. }).catch(() => { })
  275. }
  276. }
  277. };
  278. </script>
  279. <style lang="scss" scoped>
  280. .m-container {
  281. .m-core {
  282. margin-top: 20px;
  283. .m-wrap {
  284. display: flex;
  285. flex-direction: row;
  286. justify-content: flex-start;
  287. width: 100%;
  288. // align-items: center;
  289. .newBand {
  290. margin: 0 5px 0 10px;
  291. }
  292. .title {
  293. width: 120px;
  294. height: 40px;
  295. line-height: 40px;
  296. text-align: right;
  297. color: #606266;
  298. }
  299. .organSelect {
  300. width: 220px !important;
  301. }
  302. .el-tooltip.micon {
  303. width: 20px;
  304. height: 20px;
  305. position: relative;
  306. top: 12px;
  307. }
  308. }
  309. }
  310. }
  311. /deep/.el-input__icon.el-icon-date {
  312. height: 40px !important;
  313. }
  314. </style>