SelectTemplate.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <el-dialog
  3. :visible="dialogVisible"
  4. width="900px"
  5. :title="$t('Key288')"
  6. :close-on-click-modal="false"
  7. @close="dialogClose"
  8. >
  9. <!-- 查询条件 -->
  10. <div class="query-criteria">
  11. <el-form :inline="true" :model="searchForm" size="mini">
  12. <el-form-item :label="$t('Key339')">
  13. <el-input v-model.trim="searchForm.name" @keyup.enter.native="queryCourseList" />
  14. </el-form-item>
  15. <el-form-item class="search-button">
  16. <el-button type="primary" @click="queryCourseList">
  17. <i class="el-icon-search" /> {{ $t('Key131') }}
  18. </el-button>
  19. </el-form-item>
  20. </el-form>
  21. </div>
  22. <el-table
  23. ref="templateTable"
  24. :data="courseList"
  25. height="40vh"
  26. highlight-current-row
  27. @current-change="handleCurrentChange"
  28. >
  29. <el-table-column prop="name" :label="$t('Key191')" width="320" />
  30. <el-table-column :label="$t('Key250')">
  31. <template slot-scope="{ row }">
  32. <i class="el-icon-date" /> {{ row.begin_date }} - {{ row.end_date }}
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. <el-pagination
  37. background
  38. :page-sizes="[10, 20, 30, 40, 50]"
  39. :page-size="page_capacity"
  40. layout="prev, pager, next, total, sizes, jumper"
  41. :total="total_count"
  42. :current-page="cur_page"
  43. @prev-click="changePage"
  44. @next-click="changePage"
  45. @current-change="changePage"
  46. @size-change="changePageSize"
  47. />
  48. <div slot="footer">
  49. <el-button size="mini" @click="dialogClose">
  50. {{ $t('Key83') }}
  51. </el-button>
  52. <el-button type="primary" size="mini" @click="confirmTemplate">
  53. {{ $t('Key94') }}
  54. </el-button>
  55. </div>
  56. </el-dialog>
  57. </template>
  58. <script>
  59. import { PageQueryCourseList } from '@/api/table';
  60. export default {
  61. props: {
  62. dialogVisible: {
  63. default: false,
  64. type: Boolean
  65. }
  66. },
  67. data() {
  68. return {
  69. cur_page: 1,
  70. total_count: 0,
  71. page_capacity: 10,
  72. searchForm: {
  73. name: ''
  74. },
  75. courseList: [],
  76. currentRow: null
  77. };
  78. },
  79. created() {
  80. this.queryCourseList();
  81. this.updateWordPack({
  82. word_key_list: ['Key288', 'Key339', 'Key131', 'Key191', 'Key250', 'Key83', 'Key94', 'Key340']
  83. });
  84. },
  85. methods: {
  86. queryCourseList() {
  87. const queryCriteria = {
  88. is_template: true,
  89. name: this.searchForm.name,
  90. page_capacity: this.page_capacity,
  91. cur_page: this.cur_page,
  92. release_status: 1
  93. };
  94. PageQueryCourseList(queryCriteria).then(({ course_list, total_count }) => {
  95. this.courseList = course_list;
  96. this.total_count = total_count;
  97. });
  98. },
  99. changePage(newPage) {
  100. this.cur_page = newPage;
  101. this.queryCourseList();
  102. },
  103. changePageSize(pageSize) {
  104. this.page_capacity = pageSize;
  105. this.queryCourseList();
  106. },
  107. handleCurrentChange(val) {
  108. this.currentRow = val;
  109. },
  110. dialogClose() {
  111. this.$emit('dialogClose');
  112. this.$refs.templateTable.clearSelection();
  113. },
  114. confirmTemplate() {
  115. if (!this.currentRow) {
  116. return this.$message.warning(this.$i18n.t('Key340'));
  117. }
  118. this.$emit('confirmTemplate', this.currentRow.id);
  119. }
  120. }
  121. };
  122. </script>
  123. <style lang="scss">
  124. @import '~@/styles/mixin';
  125. @include dialog;
  126. @include pagination;
  127. .query-criteria .el-form {
  128. display: flex;
  129. justify-content: space-between;
  130. }
  131. </style>