accompanyBuys.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <!-- -->
  2. <template>
  3. <div class="m-core">
  4. <save-form :inline="true"
  5. class="searchForm"
  6. @submit="search"
  7. @reset="onReSet"
  8. :save-key="saveKey"
  9. :model.sync="searchForm">
  10. <!-- 状态 指导老师 活动方案-->
  11. <el-form-item>
  12. <el-input v-model.trim="searchForm.search"
  13. placeholder="学员编号 学员名称"></el-input>
  14. </el-form-item>
  15. <el-form-item>
  16. <el-select class="multiple"
  17. v-model.trim="searchForm.organIdList"
  18. filterable
  19. clearable
  20. placeholder="请选择分部">
  21. <el-option v-for="(item,index) in selects.branchs"
  22. :key="index"
  23. :label="item.name"
  24. :value="item.id"></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <!-- statusList -->
  28. <el-form-item prop="buy">
  29. <el-select class="multiple"
  30. v-model.trim="searchForm.buy"
  31. filterable
  32. clearable
  33. placeholder="购买网管课">
  34. <el-option label="是"
  35. value="true"></el-option>
  36. <el-option label="否"
  37. value="false"></el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button native-type="submit"
  42. type="danger">搜索</el-button>
  43. <el-button native-type="reset"
  44. type="primary">重置</el-button>
  45. </el-form-item>
  46. <el-form-item>
  47. <!-- <div class="newBand" @click="onExport">导出</div> -->
  48. <el-button @click="onExport"
  49. type="primary"
  50. v-permission="'export/studentBuyPractice'"
  51. style="background-color: #14928a; border: 1px solid #14928a;">导出</el-button>
  52. </el-form-item>
  53. </save-form>
  54. <div class="tableWrap">
  55. <el-table style="width: 100%"
  56. :header-cell-style="{background:'#EDEEF0',color:'#444'}"
  57. :data="tableData">
  58. <el-table-column align="center"
  59. prop="studentId"
  60. label="学员编号"></el-table-column>
  61. <el-table-column align="center"
  62. prop="studentName"
  63. label="学员名称"></el-table-column>
  64. <el-table-column align="center"
  65. prop="organName"
  66. label="所属分部"></el-table-column>
  67. <!-- educationalTeacherId -->
  68. <el-table-column align="center"
  69. prop="phone"
  70. label="手机号"></el-table-column>
  71. <el-table-column align="center"
  72. label="是否购买">
  73. <template slot-scope="scope">
  74. <div>
  75. <p>{{scope.row.buyPractice?'是':'否'}}</p>
  76. </div>
  77. </template>
  78. </el-table-column>
  79. <el-table-column align="center"
  80. prop="lastClassDate"
  81. label="结束日期">
  82. <template slot="header"
  83. slot-scope="scope">
  84. <p style="position: relative; "> 结束日期 <el-tooltip placement="top"
  85. popper-class="mTooltip">
  86. <div slot="content">
  87. 免费网管课最后一节课截止日期
  88. </div>
  89. <!-- <img :src="imageIcon"
  90. class="micon el-tooltip"
  91. style="width:8px height:8px"
  92. alt /> -->
  93. <i class="el-icon-question"
  94. style="font-size: 18px; color: #F56C6C"></i>
  95. </el-tooltip>
  96. </p>
  97. </template>
  98. <template slot-scope="scope">
  99. <div>
  100. <p>{{scope.row.lastClassDate | formatTimer}}</p>
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column align="center"
  105. prop="firstBuyTime"
  106. label="购买日期">
  107. <template slot="header"
  108. slot-scope="scope">
  109. <p style="position: relative; "> 购买日期 <el-tooltip placement="top"
  110. popper-class="mTooltip">
  111. <div slot="content">
  112. 付费网管课第一次购买时间
  113. </div>
  114. <!-- <img :src="imageIcon"
  115. class="micon el-tooltip"
  116. style="width:8px height:8px"
  117. alt /> -->
  118. <i class="el-icon-question"
  119. style="font-size: 18px; color: #F56C6C"></i>
  120. </el-tooltip>
  121. </p>
  122. </template>
  123. <template slot-scope="scope">
  124. <div>
  125. <p>{{scope.row.firstBuyTime | formatTimer}}</p>
  126. </div>
  127. </template>
  128. </el-table-column>
  129. <el-table-column align="center"
  130. prop="intervalDay"
  131. label="时间差">
  132. <template slot="header"
  133. slot-scope="scope">
  134. <p style="position: relative; "> 时间差 <el-tooltip placement="top"
  135. popper-class="mTooltip">
  136. <div slot="content">
  137. 付费网管课结束后与购买日期的时间差
  138. </div>
  139. <!-- <img :src="imageIcon"
  140. class="micon el-tooltip"
  141. style="width:8px height:8px"
  142. alt /> -->
  143. <i class="el-icon-question"
  144. style="font-size: 18px; color: #F56C6C"></i>
  145. </el-tooltip>
  146. </p>
  147. </template>
  148. <template slot-scope="scope">
  149. <div>
  150. <p>{{scope.row.intervalDay + '天'}}</p>
  151. </div>
  152. </template>
  153. </el-table-column>
  154. </el-table>
  155. <pagination :total="rules.total"
  156. :page.sync="rules.page"
  157. :limit.sync="rules.limit"
  158. :page-sizes="rules.page_size"
  159. @pagination="getList" />
  160. </div>
  161. </div>
  162. </template>
  163. <script>
  164. import {
  165. practiceGroupManageStudentBuys,
  166. getEmployeeOrgan
  167. } from "@/api/buildTeam";
  168. import pagination from "@/components/Pagination/index";
  169. import axios from 'axios'
  170. import { getToken } from '@/utils/auth'
  171. import load from '@/utils/loading'
  172. import qs from 'qs'
  173. export default {
  174. components: { pagination },
  175. data () {
  176. return {
  177. searchForm: {
  178. search: null,
  179. buy: null,
  180. organIdList: null
  181. },
  182. tableData: [],
  183. organList: [],
  184. rules: {
  185. // 分页规则
  186. limit: 10, // 限制显示条数
  187. page: 1, // 当前页
  188. total: 0, // 总条数
  189. page_size: [10, 20, 40, 50] // 选择限制显示条数
  190. }
  191. };
  192. },
  193. //生命周期 - 创建完成(可以访问当前this实例)
  194. created () { },
  195. //生命周期 - 挂载完成(可以访问DOM元素)
  196. mounted () {
  197. this.init();
  198. },
  199. activated () {
  200. this.init();
  201. },
  202. computed: {
  203. saveKey() {
  204. return this.$route.path + '/2'
  205. }
  206. },
  207. methods: {
  208. init () {
  209. // 获取分部
  210. this.$store.dispatch('setBranchs')
  211. // getEmployeeOrgan().then(res => {
  212. // if (res.code == 200) {
  213. // this.organList = res.data;
  214. // }
  215. // });
  216. this.getList()
  217. },
  218. getList () {
  219. let obj = {
  220. page: this.rules.page,
  221. rows: this.rules.limit
  222. };
  223. this.searchForm.search ? (obj.search = this.searchForm.search) : null;
  224. this.searchForm.buy
  225. ? (obj.buyPractice = this.searchForm.buy)
  226. : null;
  227. this.searchForm.organIdList
  228. ? (obj.organId = this.searchForm.organIdList)
  229. : null;
  230. practiceGroupManageStudentBuys(obj).then(res => {
  231. if (res.code == 200) {
  232. this.tableData = res.data.rows
  233. this.rules.total = res.data.total;
  234. }
  235. });
  236. },
  237. search () {
  238. this.rules.page = 1;
  239. this.getList();
  240. },
  241. onReSet () {
  242. this.searchForm = {
  243. search: null,
  244. buy: null,
  245. organIdList: null
  246. };
  247. this.search();
  248. },
  249. // 导出
  250. onExport () {
  251. let searchForm = this.searchForm;
  252. let data = {
  253. buyPractice: searchForm.buy || null,
  254. organId: searchForm.organIdList || null,
  255. search: searchForm.search || null
  256. };
  257. let url = "/api-web/export/studentBuyPractice";
  258. const options = {
  259. method: "POST",
  260. headers: {
  261. Authorization: getToken()
  262. },
  263. params: data,
  264. url,
  265. responseType: "blob"
  266. };
  267. this.$confirm("您确定导出报表", "提示", {
  268. confirmButtonText: "确定",
  269. cancelButtonText: "取消",
  270. type: "warning"
  271. })
  272. .then(() => {
  273. load.startLoading()
  274. axios(options).then(res => {
  275. let blob = new Blob([res.data], {
  276. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  277. type: "application/vnd.ms-excel;charset=utf-8"
  278. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  279. });
  280. let text = (new Response(blob)).text()
  281. text.then(res => {
  282. // 判断是否报错
  283. if (res.indexOf('code') != -1) {
  284. let json = JSON.parse(res)
  285. this.$message.error(json.msg)
  286. } else {
  287. let objectUrl = URL.createObjectURL(blob);
  288. let link = document.createElement("a");
  289. let fname = "网管课购买" + new Date().getTime(); //下载文件的名字
  290. link.href = objectUrl;
  291. link.setAttribute("download", fname);
  292. document.body.appendChild(link);
  293. link.click();
  294. }
  295. })
  296. load.endLoading();
  297. }).catch(error => {
  298. this.$message.error('导出数据失败,请联系管理员');
  299. load.endLoading();
  300. });
  301. }).catch(() => { });
  302. }
  303. }
  304. };
  305. </script>
  306. <style lang='scss' scoped>
  307. </style>