index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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="keyword">
  5. <el-input v-model="queryParams.keyword" placeholder="请输入关键词" clearable size="small"
  6. @keyup.enter.native="handleQuery" />
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  10. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  11. </el-form-item>
  12. </el-form>
  13. <el-row :gutter="10" class="mb8">
  14. <el-col :span="1.5">
  15. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  16. v-hasPermi="['course:courseAnswerLog:add']">新增</el-button>
  17. </el-col>
  18. <el-col :span="1.5">
  19. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
  20. @click="handleDelete" v-hasPermi="['course:courseAnswerLog:remove']">删除</el-button>
  21. </el-col>
  22. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  23. </el-row>
  24. <el-table border v-loading="loading" :data="list" @selection-change="handleSelectionChange">
  25. <el-table-column type="selection" width="55" align="center" />
  26. <el-table-column label="ID" align="center" prop="id" width="80" />
  27. <el-table-column label="名称" align="center" prop="name" :show-overflow-tooltip="true" />
  28. <el-table-column label="创建时间" align="center" prop="createTime" width="160">
  29. <template slot-scope="scope">
  30. <span>{{ parseTime(scope.row.createTime) }}</span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
  34. <template slot-scope="scope">
  35. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  36. v-hasPermi="['course:courseAnswerLog:edit']">修改</el-button>
  37. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  38. v-hasPermi="['course:courseAnswerLog:remove']">删除</el-button>
  39. </template>
  40. </el-table-column>
  41. </el-table>
  42. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum"
  43. :limit.sync="queryParams.pageSize" @pagination="getList" />
  44. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  45. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  46. <el-form-item label="名称" prop="name">
  47. <el-input v-model="form.name" placeholder="请输入名称" />
  48. </el-form-item>
  49. </el-form>
  50. <div slot="footer" class="dialog-footer">
  51. <el-button type="primary" @click="submitForm">确 定</el-button>
  52. <el-button @click="cancel">取 消</el-button>
  53. </div>
  54. </el-dialog>
  55. </div>
  56. </template>
  57. <script>
  58. import { getRequest, postRequest, putRequest, delRequest } from "@/api/common";
  59. export default {
  60. name: "CourseCourseanswerlog",
  61. data() {
  62. return {
  63. loading: true,
  64. ids: [],
  65. multiple: true,
  66. showSearch: true,
  67. total: 0,
  68. list: [],
  69. title: "",
  70. open: false,
  71. queryParams: {
  72. pageNum: 1,
  73. pageSize: 10,
  74. keyword: null
  75. },
  76. form: {},
  77. rules: {
  78. name: [{ required: true, message: "名称不能为空", trigger: "blur" }],
  79. },
  80. };
  81. },
  82. created() {
  83. this.getList();
  84. },
  85. methods: {
  86. getList() {
  87. this.loading = true;
  88. getRequest("/course/courseAnswerLog/list", this.queryParams).then(response => {
  89. this.list = response.rows || [];
  90. this.total = response.total || 0;
  91. this.loading = false;
  92. }).catch(() => {
  93. this.list = [];
  94. this.total = 0;
  95. this.loading = false;
  96. });
  97. },
  98. handleQuery() {
  99. this.queryParams.pageNum = 1;
  100. this.getList();
  101. },
  102. resetQuery() {
  103. this.resetForm("queryForm");
  104. this.handleQuery();
  105. },
  106. cancel() {
  107. this.open = false;
  108. this.reset();
  109. },
  110. reset() {
  111. this.form = { id: null, name: null };
  112. this.resetForm("form");
  113. },
  114. handleSelectionChange(selection) {
  115. this.ids = selection.map(item => item.id);
  116. this.multiple = !selection.length;
  117. },
  118. handleAdd() {
  119. this.reset();
  120. this.open = true;
  121. this.title = "新增";
  122. },
  123. handleUpdate(row) {
  124. this.reset();
  125. const id = row.id || this.ids;
  126. getRequest("/course/courseAnswerLog/" + id).then(response => {
  127. this.form = response.data;
  128. this.open = true;
  129. this.title = "修改";
  130. });
  131. },
  132. submitForm() {
  133. this.$refs["form"].validate(valid => {
  134. if (valid) {
  135. if (this.form.id != null) {
  136. putRequest("/course/courseAnswerLog", this.form).then(response => {
  137. this.$modal.msgSuccess("修改成功");
  138. this.open = false;
  139. this.getList();
  140. });
  141. } else {
  142. postRequest("/course/courseAnswerLog", this.form).then(response => {
  143. this.$modal.msgSuccess("新增成功");
  144. this.open = false;
  145. this.getList();
  146. });
  147. }
  148. }
  149. });
  150. },
  151. handleDelete(row) {
  152. const ids = row.id || this.ids;
  153. this.$modal.confirm('是否确认删除选中的数据项?', "警告", {
  154. confirmButtonText: "确定",
  155. cancelButtonText: "取消",
  156. type: "warning"
  157. }).then(() => {
  158. return delRequest("/course/courseAnswerLog/" + ids);
  159. }).then(() => {
  160. this.getList();
  161. this.$modal.msgSuccess("删除成功");
  162. }).catch(() => {});
  163. },
  164. },
  165. };
  166. </script>