index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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="displayOrder">
  5. <el-input
  6. v-model="queryParams.displayOrder"
  7. placeholder="请输入显示顺序"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="状态 (0:禁用, 1:启用)" prop="status">
  14. <el-select v-model="queryParams.status" placeholder="请选择状态 (0:禁用, 1:启用)" clearable size="small">
  15. <el-option label="请选择字典生成" value="" />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="创建人ID" prop="createId">
  19. <el-input
  20. v-model="queryParams.createId"
  21. placeholder="请输入创建人ID"
  22. clearable
  23. size="small"
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item>
  27. <el-form-item label="创建人ID" prop="updateId">
  28. <el-input
  29. v-model="queryParams.updateId"
  30. placeholder="请输入创建人ID"
  31. clearable
  32. size="small"
  33. @keyup.enter.native="handleQuery"
  34. />
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  38. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  39. </el-form-item>
  40. </el-form>
  41. <el-row :gutter="10" class="mb8">
  42. <el-col :span="1.5">
  43. <el-button
  44. type="primary"
  45. plain
  46. icon="el-icon-plus"
  47. size="mini"
  48. @click="handleAdd"
  49. v-hasPermi="['course:relation:add']"
  50. >新增</el-button>
  51. </el-col>
  52. <el-col :span="1.5">
  53. <el-button
  54. type="success"
  55. plain
  56. icon="el-icon-edit"
  57. size="mini"
  58. :disabled="single"
  59. @click="handleUpdate"
  60. v-hasPermi="['course:relation:edit']"
  61. >修改</el-button>
  62. </el-col>
  63. <el-col :span="1.5">
  64. <el-button
  65. type="danger"
  66. plain
  67. icon="el-icon-delete"
  68. size="mini"
  69. :disabled="multiple"
  70. @click="handleDelete"
  71. v-hasPermi="['course:relation:remove']"
  72. >删除</el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button
  76. type="warning"
  77. plain
  78. icon="el-icon-download"
  79. size="mini"
  80. :loading="exportLoading"
  81. @click="handleExport"
  82. v-hasPermi="['course:relation:export']"
  83. >导出</el-button>
  84. </el-col>
  85. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  86. </el-row>
  87. <el-table border v-loading="loading" :data="relationList" @selection-change="handleSelectionChange">
  88. <el-table-column type="selection" width="55" align="center" />
  89. <el-table-column label="关联关系ID" align="center" prop="id" />
  90. <el-table-column label="关联reward_.id" align="center" prop="rewardId" />
  91. <el-table-column label="关联视频小节ID" align="center" prop="videoSectionId" />
  92. <el-table-column label="显示顺序" align="center" prop="displayOrder" />
  93. <el-table-column label="状态 (0:禁用, 1:启用)" align="center" prop="status" />
  94. <el-table-column label="创建人ID" align="center" prop="createId" />
  95. <el-table-column label="创建人ID" align="center" prop="updateId" />
  96. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  97. <template slot-scope="scope">
  98. <el-button
  99. size="mini"
  100. type="text"
  101. icon="el-icon-edit"
  102. @click="handleUpdate(scope.row)"
  103. v-hasPermi="['course:relation:edit']"
  104. >修改</el-button>
  105. <el-button
  106. size="mini"
  107. type="text"
  108. icon="el-icon-delete"
  109. @click="handleDelete(scope.row)"
  110. v-hasPermi="['course:relation:remove']"
  111. >删除</el-button>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <pagination
  116. v-show="total>0"
  117. :total="total"
  118. :page.sync="queryParams.pageNum"
  119. :limit.sync="queryParams.pageSize"
  120. @pagination="getList"
  121. />
  122. <!-- 添加或修改奖励与视频小节关联关系对话框 -->
  123. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  124. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  125. <el-form-item label="显示顺序" prop="displayOrder">
  126. <el-input v-model="form.displayOrder" placeholder="请输入显示顺序" />
  127. </el-form-item>
  128. <el-form-item label="状态 (0:禁用, 1:启用)">
  129. <el-radio-group v-model="form.status">
  130. <el-radio label="1">请选择字典生成</el-radio>
  131. </el-radio-group>
  132. </el-form-item>
  133. <el-form-item label="创建人ID" prop="createId">
  134. <el-input v-model="form.createId" placeholder="请输入创建人ID" />
  135. </el-form-item>
  136. <el-form-item label="创建人ID" prop="updateId">
  137. <el-input v-model="form.updateId" placeholder="请输入创建人ID" />
  138. </el-form-item>
  139. </el-form>
  140. <div slot="footer" class="dialog-footer">
  141. <el-button type="primary" @click="submitForm">确 定</el-button>
  142. <el-button @click="cancel">取 消</el-button>
  143. </div>
  144. </el-dialog>
  145. </div>
  146. </template>
  147. <script>
  148. import { listRelation, getRelation, delRelation, addRelation, updateRelation, exportRelation } from "@/api/course/relation";
  149. export default {
  150. name: "Relation",
  151. data() {
  152. return {
  153. // 遮罩层
  154. loading: true,
  155. // 导出遮罩层
  156. exportLoading: false,
  157. // 选中数组
  158. ids: [],
  159. // 非单个禁用
  160. single: true,
  161. // 非多个禁用
  162. multiple: true,
  163. // 显示搜索条件
  164. showSearch: true,
  165. // 总条数
  166. total: 0,
  167. // 奖励与视频小节关联关系表格数据
  168. relationList: [],
  169. // 弹出层标题
  170. title: "",
  171. // 是否显示弹出层
  172. open: false,
  173. // 查询参数
  174. queryParams: {
  175. pageNum: 1,
  176. pageSize: 10,
  177. rewardId: null,
  178. videoSectionId: null,
  179. displayOrder: null,
  180. status: null,
  181. createId: null,
  182. updateId: null,
  183. },
  184. // 表单参数
  185. form: {},
  186. // 表单校验
  187. rules: {
  188. rewardId: [
  189. { required: true, message: "关联reward_.id不能为空", trigger: "blur" }
  190. ],
  191. videoSectionId: [
  192. { required: true, message: "关联视频小节ID不能为空", trigger: "blur" }
  193. ],
  194. displayOrder: [
  195. { required: true, message: "显示顺序不能为空", trigger: "blur" }
  196. ],
  197. status: [
  198. { required: true, message: "状态 (0:禁用, 1:启用)不能为空", trigger: "blur" }
  199. ],
  200. createTime: [
  201. { required: true, message: "创建时间不能为空", trigger: "blur" }
  202. ],
  203. }
  204. };
  205. },
  206. created() {
  207. this.getList();
  208. },
  209. methods: {
  210. /** 查询奖励与视频小节关联关系列表 */
  211. getList() {
  212. this.loading = true;
  213. listRelation(this.queryParams).then(response => {
  214. this.relationList = response.rows;
  215. this.total = response.total;
  216. this.loading = false;
  217. });
  218. },
  219. // 取消按钮
  220. cancel() {
  221. this.open = false;
  222. this.reset();
  223. },
  224. // 表单重置
  225. reset() {
  226. this.form = {
  227. id: null,
  228. rewardId: null,
  229. videoSectionId: null,
  230. displayOrder: null,
  231. status: 0,
  232. createId: null,
  233. createTime: null,
  234. updateId: null,
  235. updateTime: null
  236. };
  237. this.resetForm("form");
  238. },
  239. /** 搜索按钮操作 */
  240. handleQuery() {
  241. this.queryParams.pageNum = 1;
  242. this.getList();
  243. },
  244. /** 重置按钮操作 */
  245. resetQuery() {
  246. this.resetForm("queryForm");
  247. this.handleQuery();
  248. },
  249. // 多选框选中数据
  250. handleSelectionChange(selection) {
  251. this.ids = selection.map(item => item.id)
  252. this.single = selection.length!==1
  253. this.multiple = !selection.length
  254. },
  255. /** 新增按钮操作 */
  256. handleAdd() {
  257. this.reset();
  258. this.open = true;
  259. this.title = "添加奖励与视频小节关联关系";
  260. },
  261. /** 修改按钮操作 */
  262. handleUpdate(row) {
  263. this.reset();
  264. const id = row.id || this.ids
  265. getRelation(id).then(response => {
  266. this.form = response.data;
  267. this.open = true;
  268. this.title = "修改奖励与视频小节关联关系";
  269. });
  270. },
  271. /** 提交按钮 */
  272. submitForm() {
  273. this.$refs["form"].validate(valid => {
  274. if (valid) {
  275. if (this.form.id != null) {
  276. updateRelation(this.form).then(response => {
  277. this.msgSuccess("修改成功");
  278. this.open = false;
  279. this.getList();
  280. });
  281. } else {
  282. addRelation(this.form).then(response => {
  283. this.msgSuccess("新增成功");
  284. this.open = false;
  285. this.getList();
  286. });
  287. }
  288. }
  289. });
  290. },
  291. /** 删除按钮操作 */
  292. handleDelete(row) {
  293. const ids = row.id || this.ids;
  294. this.$confirm('是否确认删除奖励与视频小节关联关系编号为"' + ids + '"的数据项?', "警告", {
  295. confirmButtonText: "确定",
  296. cancelButtonText: "取消",
  297. type: "warning"
  298. }).then(function() {
  299. return delRelation(ids);
  300. }).then(() => {
  301. this.getList();
  302. this.msgSuccess("删除成功");
  303. }).catch(() => {});
  304. },
  305. /** 导出按钮操作 */
  306. handleExport() {
  307. const queryParams = this.queryParams;
  308. this.$confirm('是否确认导出所有奖励与视频小节关联关系数据项?', "警告", {
  309. confirmButtonText: "确定",
  310. cancelButtonText: "取消",
  311. type: "warning"
  312. }).then(() => {
  313. this.exportLoading = true;
  314. return exportRelation(queryParams);
  315. }).then(response => {
  316. this.download(response.msg);
  317. this.exportLoading = false;
  318. }).catch(() => {});
  319. }
  320. }
  321. };
  322. </script>