accompanyBuys.vue 10 KB

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