index.vue 12 KB

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