index 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="名字" prop="name">
  6. <el-input v-model="queryParams.name" placeholder="请输入名字" clearable @keyup.enter.native="handleQuery"/>
  7. </el-form-item>
  8. <el-form-item label="出生日期" prop="birthday">
  9. <el-date-picker clearable v-model="queryParams.birthday" type="date" value-format="yyyy-MM-dd" placeholder="选择出生日期" />
  10. </el-form-item>
  11. <el-form-item label="性别" prop="sex">
  12. <el-select v-model="queryParams.sex" placeholder="请选择性别" clearable size="small">
  13. <el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_USER_SEX)"
  14. :key="dict.value" :label="dict.label" :value="dict.value"/>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="是否有效" prop="enabled">
  18. <el-select v-model="queryParams.enabled" placeholder="请选择是否有效" clearable size="small">
  19. <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INFRA_BOOLEAN_STRING)"
  20. :key="dict.value" :label="dict.label" :value="dict.value"/>
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="创建时间" prop="createTime">
  24. <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
  25. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  29. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  30. </el-form-item>
  31. </el-form>
  32. <!-- 操作工具栏 -->
  33. <el-row :gutter="10" class="mb8">
  34. <el-col :span="1.5">
  35. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
  36. v-hasPermi="['infra:student:create']">新增</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
  40. v-hasPermi="['infra:student:export']">导出</el-button>
  41. </el-col>
  42. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  43. </el-row>
  44. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  45. <el-table-column label="编号" align="center" prop="id">
  46. <template v-slot="scope">
  47. <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.id" />
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="名字" align="center" prop="name">
  51. <template v-slot="scope">
  52. <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.name" />
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="简介" align="center" prop="description">
  56. <template v-slot="scope">
  57. <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.description" />
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="出生日期" align="center" prop="birthday" width="180">
  61. <template v-slot="scope">
  62. <span>{{ parseTime(scope.row.birthday) }}</span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="性别" align="center" prop="sex">
  66. <template v-slot="scope">
  67. <dict-tag :type="DICT_TYPE.SYSTEM_USER_SEX" :value="scope.row.sex" />
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="是否有效" align="center" prop="enabled">
  71. <template v-slot="scope">
  72. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.enabled" />
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="头像" align="center" prop="avatar">
  76. <template v-slot="scope">
  77. <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.avatar" />
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="附件" align="center" prop="video">
  81. <template v-slot="scope">
  82. <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.video" />
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="备注" align="center" prop="memo">
  86. <template v-slot="scope">
  87. <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.memo" />
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  91. <template v-slot="scope">
  92. <span>{{ parseTime(scope.row.createTime) }}</span>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  96. <template v-slot="scope">
  97. <el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)"
  98. v-hasPermi="['infra:student:update']">修改</el-button>
  99. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  100. v-hasPermi="['infra:student:delete']">删除</el-button>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <!-- 分页组件 -->
  105. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  106. @pagination="getList"/>
  107. <!-- 对话框(添加 / 修改) -->
  108. <StudentForm ref="formRef" @success="getList" />
  109. </div>
  110. </template>
  111. <script>
  112. import * as StudentApi from '@/api/infra/demo';
  113. import StudentForm from './StudentForm.vue';
  114. export default {
  115. name: "Student",
  116. components: {
  117. StudentForm,
  118. },
  119. data() {
  120. return {
  121. // 遮罩层
  122. loading: true,
  123. // 导出遮罩层
  124. exportLoading: false,
  125. // 显示搜索条件
  126. showSearch: true,
  127. // 总条数
  128. total: 0,
  129. // 学生列表
  130. list: [],
  131. // 是否展开,默认全部展开
  132. isExpandAll: true,
  133. // 重新渲染表格状态
  134. refreshTable: true,
  135. // 选中行
  136. currentRow: {},
  137. // 查询参数
  138. queryParams: {
  139. pageNo: 1,
  140. pageSize: 10,
  141. name: null,
  142. birthday: null,
  143. sex: null,
  144. enabled: null,
  145. createTime: [],
  146. },
  147. };
  148. },
  149. created() {
  150. this.getList();
  151. },
  152. methods: {
  153. /** 查询列表 */
  154. async getList() {
  155. try {
  156. this.loading = true;
  157. const res = await StudentApi.getStudentPage(this.queryParams);
  158. this.list = res.data.list;
  159. this.total = res.data.total;
  160. } finally {
  161. this.loading = false;
  162. }
  163. },
  164. /** 搜索按钮操作 */
  165. handleQuery() {
  166. this.queryParams.pageNo = 1;
  167. this.getList();
  168. },
  169. /** 重置按钮操作 */
  170. resetQuery() {
  171. this.resetForm("queryForm");
  172. this.handleQuery();
  173. },
  174. /** 添加/修改操作 */
  175. openForm(id) {
  176. this.$refs["formRef"].open(id);
  177. },
  178. /** 删除按钮操作 */
  179. async handleDelete(row) {
  180. const id = row.id;
  181. await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
  182. try {
  183. await StudentApi.deleteStudent(id);
  184. await this.getList();
  185. this.$modal.msgSuccess("删除成功");
  186. } catch {}
  187. },
  188. /** 导出按钮操作 */
  189. async handleExport() {
  190. await this.$modal.confirm('是否确认导出所有学生数据项?');
  191. try {
  192. this.exportLoading = true;
  193. const res = await StudentApi.exportStudentExcel(this.queryParams);
  194. this.$download.excel(res.data, '学生.xls');
  195. } catch {
  196. } finally {
  197. this.exportLoading = false;
  198. }
  199. },
  200. }
  201. };
  202. </script>