operateStudent.vue 10 KB

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