index.vue 9.8 KB

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