accompanyBuys.vue 10.0 KB

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