index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="营期名称" prop="periodName">
  5. <el-input
  6. v-model="queryParams.periodName"
  7. placeholder="请输入营期名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="营期线" prop="periodStartingTime">
  14. <el-date-picker clearable size="small"
  15. v-model="queryParams.periodStartingTime"
  16. type="date"
  17. value-format="yyyy-MM-dd"
  18. placeholder="选择营期线">
  19. </el-date-picker>
  20. </el-form-item>
  21. <el-form-item label="销售公司" prop="companyName">
  22. <el-input
  23. v-model="queryParams.companyName"
  24. placeholder="请输入销售公司名称"
  25. clearable
  26. size="small"
  27. @keyup.enter.native="handleQuery"
  28. />
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  32. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  33. </el-form-item>
  34. </el-form>
  35. <el-row :gutter="10" class="mb8">
  36. <el-col :span="1.5">
  37. <el-button
  38. type="warning"
  39. plain
  40. icon="el-icon-download"
  41. size="mini"
  42. :loading="exportLoading"
  43. @click="handleExport"
  44. v-hasPermi="['course:userWatchStatistics:export']"
  45. >导出</el-button>
  46. </el-col>
  47. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  48. </el-row>
  49. <el-table border v-loading="loading" :data="userWatchStatisticsList" @selection-change="handleSelectionChange">
  50. <el-table-column type="selection" width="55" align="center" />
  51. <el-table-column label="营期名称" align="center" prop="periodName" />
  52. <el-table-column label="营期线" align="center" prop="periodStartingTime" width="180">
  53. <template slot-scope="scope">
  54. <span>{{ parseTime(scope.row.periodStartingTime, '{y}-{m}-{d}') }}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="销售公司" align="center" prop="companyName" />
  58. <el-table-column label="新增会员" align="center" prop="newUserNum" />
  59. <el-table-column label="会员数量" align="center" prop="userNum" />
  60. <el-table-column label="观看人数" align="center" prop="watchNum" />
  61. <el-table-column label="上线率" align="center" prop="onlineRatePercent" />
  62. <el-table-column label="完播人数" align="center" prop="completeWatchNum" />
  63. <el-table-column label="完播率" align="center" prop="completeWatchRatePercent" />
  64. </el-table>
  65. <pagination
  66. v-show="total>0"
  67. :total="total"
  68. :page.sync="queryParams.pageNum"
  69. :limit.sync="queryParams.pageSize"
  70. @pagination="getList"
  71. />
  72. <!-- 添加或修改会员看课统计-按营期统计对话框 -->
  73. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  74. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  75. <el-form-item label="营期id" prop="periodId">
  76. <el-input v-model="form.periodId" placeholder="请输入营期id" />
  77. </el-form-item>
  78. <el-form-item label="营期名称" prop="periodName">
  79. <el-input v-model="form.periodName" placeholder="请输入营期名称" />
  80. </el-form-item>
  81. <el-form-item label="营期开始日期" prop="periodStartingTime">
  82. <el-date-picker clearable size="small"
  83. v-model="form.periodStartingTime"
  84. type="date"
  85. value-format="yyyy-MM-dd"
  86. placeholder="选择营期开始日期">
  87. </el-date-picker>
  88. </el-form-item>
  89. <el-form-item label="新增会员数量" prop="newUserNum">
  90. <el-input v-model="form.newUserNum" placeholder="请输入新增会员数量" />
  91. </el-form-item>
  92. <el-form-item label="会员数量" prop="userNum">
  93. <el-input v-model="form.userNum" placeholder="请输入会员数量" />
  94. </el-form-item>
  95. <el-form-item label="观看人数" prop="watchNum">
  96. <el-input v-model="form.watchNum" placeholder="请输入观看人数" />
  97. </el-form-item>
  98. <el-form-item label="完播人数" prop="completeWatchNum">
  99. <el-input v-model="form.completeWatchNum" placeholder="请输入完播人数" />
  100. </el-form-item>
  101. <el-form-item label="完播率" prop="completeWatchRate">
  102. <el-input v-model="form.completeWatchRate" placeholder="请输入完播率" />
  103. </el-form-item>
  104. </el-form>
  105. <div slot="footer" class="dialog-footer">
  106. <el-button type="primary" @click="submitForm">确 定</el-button>
  107. <el-button @click="cancel">取 消</el-button>
  108. </div>
  109. </el-dialog>
  110. </div>
  111. </template>
  112. <script>
  113. import { listUserWatchStatistics, getUserWatchStatistics, delUserWatchStatistics, addUserWatchStatistics, updateUserWatchStatistics, exportUserWatchStatistics } from "@/api/course/userWatchStatistics";
  114. export default {
  115. name: "UserWatchStatistics",
  116. data() {
  117. return {
  118. // 遮罩层
  119. loading: true,
  120. // 导出遮罩层
  121. exportLoading: false,
  122. // 选中数组
  123. ids: [],
  124. // 非单个禁用
  125. single: true,
  126. // 非多个禁用
  127. multiple: true,
  128. // 显示搜索条件
  129. showSearch: true,
  130. // 总条数
  131. total: 0,
  132. // 会员看课统计-按营期统计表格数据
  133. userWatchStatisticsList: [],
  134. // 弹出层标题
  135. title: "",
  136. // 是否显示弹出层
  137. open: false,
  138. // 查询参数
  139. queryParams: {
  140. pageNum: 1,
  141. pageSize: 10,
  142. periodId: null,
  143. periodName: null,
  144. periodStartingTime: null,
  145. companyName: null,
  146. newUserNum: null,
  147. userNum: null,
  148. watchNum: null,
  149. completeWatchNum: null,
  150. completeWatchRate: null
  151. },
  152. // 表单参数
  153. form: {},
  154. // 表单校验
  155. rules: {
  156. }
  157. };
  158. },
  159. created() {
  160. this.getList();
  161. },
  162. methods: {
  163. /** 查询会员看课统计-按营期统计列表 */
  164. getList() {
  165. this.loading = true;
  166. listUserWatchStatistics(this.queryParams).then(response => {
  167. this.userWatchStatisticsList = response.rows;
  168. this.total = response.total;
  169. this.loading = false;
  170. });
  171. },
  172. // 取消按钮
  173. cancel() {
  174. this.open = false;
  175. this.reset();
  176. },
  177. // 表单重置
  178. reset() {
  179. this.form = {
  180. id: null,
  181. periodId: null,
  182. periodName: null,
  183. periodStartingTime: null,
  184. newUserNum: null,
  185. userNum: null,
  186. watchNum: null,
  187. completeWatchNum: null,
  188. completeWatchRate: null
  189. };
  190. this.resetForm("form");
  191. },
  192. /** 搜索按钮操作 */
  193. handleQuery() {
  194. this.queryParams.pageNum = 1;
  195. this.getList();
  196. },
  197. /** 重置按钮操作 */
  198. resetQuery() {
  199. this.resetForm("queryForm");
  200. this.handleQuery();
  201. },
  202. // 多选框选中数据
  203. handleSelectionChange(selection) {
  204. this.ids = selection.map(item => item.id)
  205. this.single = selection.length!==1
  206. this.multiple = !selection.length
  207. },
  208. /** 新增按钮操作 */
  209. handleAdd() {
  210. this.reset();
  211. this.open = true;
  212. this.title = "添加会员看课统计-按营期统计";
  213. },
  214. /** 修改按钮操作 */
  215. handleUpdate(row) {
  216. this.reset();
  217. const id = row.id || this.ids
  218. getUserWatchStatistics(id).then(response => {
  219. this.form = response.data;
  220. this.open = true;
  221. this.title = "修改会员看课统计-按营期统计";
  222. });
  223. },
  224. /** 提交按钮 */
  225. submitForm() {
  226. this.$refs["form"].validate(valid => {
  227. if (valid) {
  228. if (this.form.id != null) {
  229. updateUserWatchStatistics(this.form).then(response => {
  230. this.msgSuccess("修改成功");
  231. this.open = false;
  232. this.getList();
  233. });
  234. } else {
  235. addUserWatchStatistics(this.form).then(response => {
  236. this.msgSuccess("新增成功");
  237. this.open = false;
  238. this.getList();
  239. });
  240. }
  241. }
  242. });
  243. },
  244. /** 删除按钮操作 */
  245. handleDelete(row) {
  246. const ids = row.id || this.ids;
  247. this.$confirm('是否确认删除会员看课统计-按营期统计编号为"' + ids + '"的数据项?', "警告", {
  248. confirmButtonText: "确定",
  249. cancelButtonText: "取消",
  250. type: "warning"
  251. }).then(function() {
  252. return delUserWatchStatistics(ids);
  253. }).then(() => {
  254. this.getList();
  255. this.msgSuccess("删除成功");
  256. }).catch(() => {});
  257. },
  258. /** 导出按钮操作 */
  259. handleExport() {
  260. const queryParams = this.queryParams;
  261. this.$confirm('是否确认导出当前数据项?', "警告", {
  262. confirmButtonText: "确定",
  263. cancelButtonText: "取消",
  264. type: "warning"
  265. }).then(() => {
  266. this.exportLoading = true;
  267. return exportUserWatchStatistics(queryParams);
  268. }).then(response => {
  269. this.download(response.msg);
  270. this.exportLoading = false;
  271. }).catch(() => {});
  272. }
  273. }
  274. };
  275. </script>