index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <div>
  5. <!-- 搜索区域 -->
  6. <div class="search-area">
  7. <seek-page
  8. :seekList="seekList"
  9. @search="handleSearch"
  10. :formLength="4"
  11. />
  12. </div>
  13. <!-- 列表视图 -->
  14. <div class="list-view">
  15. <ele-pro-table
  16. ref="table"
  17. row-key="id"
  18. :columns="columns"
  19. :datasource="datasource"
  20. :cache-key="cacheKeyUrl"
  21. height="calc(100vh - 350px)"
  22. @columns-change="handleColumnChange"
  23. >
  24. <template v-slot:toolbar>
  25. <div class="toolbar-left">
  26. <el-button
  27. type="primary"
  28. size="small"
  29. icon="el-icon-plus"
  30. v-if="$hasPermission('ehs:offlineTraining:save')"
  31. @click="handleAdd"
  32. >添加记录</el-button
  33. >
  34. </div>
  35. </template>
  36. <template v-slot:action="{ row }">
  37. <div class="action-links">
  38. <el-link
  39. type="primary"
  40. :underline="false"
  41. @click="handleView(row)"
  42. >查看</el-link
  43. >
  44. <el-link
  45. type="primary"
  46. :underline="false"
  47. v-if="$hasPermission('ehs:offlineTraining:update')"
  48. @click="handleEdit(row)"
  49. >编辑</el-link
  50. >
  51. <el-link
  52. type="primary"
  53. :underline="false"
  54. v-if="$hasPermission('ehs:offlineTraining:update')"
  55. @click="handleSummary(row)"
  56. >培训总结</el-link
  57. >
  58. <el-link
  59. type="danger"
  60. :underline="false"
  61. v-if="$hasPermission('ehs:offlineTraining:delete')"
  62. @click="handleDelete(row)"
  63. >删除</el-link
  64. >
  65. </div>
  66. </template>
  67. </ele-pro-table>
  68. </div>
  69. <!-- 新增/编辑/查看弹窗 -->
  70. <add ref="dialogRef" @reload="handleReload" />
  71. <!-- 培训总结 -->
  72. <summary-dialog ref="summaryRef" @reload="handleReload" />
  73. </div>
  74. </el-card>
  75. </div>
  76. </template>
  77. <script>
  78. import add from './add.vue';
  79. import summaryDialog from './summary.vue';
  80. import tabMixins from '@/mixins/tableColumnsMixin';
  81. import { getPage, remove } from '@/api/offlineTraining/index.js';
  82. import { TRAINING_TYPE_OPTIONS, getOptionLabel } from '../constants';
  83. export default {
  84. components: {
  85. add,
  86. summaryDialog
  87. },
  88. mixins: [tabMixins],
  89. data() {
  90. return {
  91. // 表格列配置
  92. columns: [
  93. {
  94. columnKey: 'index',
  95. label: '序号',
  96. type: 'index',
  97. width: 60,
  98. align: 'center'
  99. },
  100. {
  101. prop: 'trainingProject',
  102. label: '培训项目',
  103. align: 'center',
  104. minWidth: 180,
  105. showOverflowTooltip: true
  106. },
  107. {
  108. prop: 'organizationName',
  109. label: '组织单位',
  110. align: 'center',
  111. minWidth: 140,
  112. showOverflowTooltip: true
  113. },
  114. {
  115. prop: 'trainingUnitName',
  116. label: '培训单位',
  117. align: 'center',
  118. minWidth: 140,
  119. showOverflowTooltip: true
  120. },
  121. {
  122. prop: 'trainingLecturer',
  123. label: '培训讲师',
  124. align: 'center',
  125. minWidth: 110
  126. },
  127. {
  128. prop: 'location',
  129. label: '地点',
  130. align: 'center',
  131. minWidth: 130,
  132. showOverflowTooltip: true
  133. },
  134. {
  135. prop: 'trainingType',
  136. label: '培训类型',
  137. align: 'center',
  138. minWidth: 110,
  139. formatter: (row) =>
  140. getOptionLabel(TRAINING_TYPE_OPTIONS, row.trainingType)
  141. },
  142. {
  143. prop: 'startTime',
  144. label: '开始时间',
  145. align: 'center',
  146. minWidth: 160
  147. },
  148. {
  149. prop: 'endTime',
  150. label: '结束时间',
  151. align: 'center',
  152. minWidth: 160
  153. },
  154. {
  155. prop: 'plannedCount',
  156. label: '计划人数',
  157. align: 'center',
  158. minWidth: 100
  159. },
  160. {
  161. prop: 'actualCount',
  162. label: '实到人数',
  163. align: 'center',
  164. minWidth: 100
  165. },
  166. {
  167. prop: 'createTime',
  168. label: '创建时间',
  169. align: 'center',
  170. minWidth: 160
  171. },
  172. {
  173. columnKey: 'action',
  174. label: '操作',
  175. width: 230,
  176. align: 'center',
  177. slot: 'action'
  178. }
  179. ],
  180. cacheKeyUrl: 'ehs-offlineTrainingRecords-list'
  181. };
  182. },
  183. computed: {
  184. seekList() {
  185. return [
  186. {
  187. label: '培训项目:',
  188. value: 'trainingProject',
  189. type: 'input',
  190. width: 220,
  191. placeholder: '请输入培训项目'
  192. },
  193. {
  194. label: '地点:',
  195. value: 'location',
  196. type: 'input',
  197. width: 220,
  198. placeholder: '请输入地点'
  199. },
  200. {
  201. label: '培训类型:',
  202. value: 'trainingType',
  203. type: 'select',
  204. width: 220,
  205. placeholder: '请选择培训类型',
  206. planList: TRAINING_TYPE_OPTIONS
  207. }
  208. ];
  209. }
  210. },
  211. methods: {
  212. // 新增
  213. handleAdd() {
  214. this.$refs.dialogRef.open();
  215. },
  216. // 编辑
  217. handleEdit(row) {
  218. this.$refs.dialogRef.open(row, 'edit');
  219. },
  220. // 查看
  221. handleView(row) {
  222. this.$refs.dialogRef.open(row, 'view');
  223. },
  224. // 培训总结
  225. handleSummary(row) {
  226. this.$refs.summaryRef.open(row);
  227. },
  228. // 删除
  229. handleDelete(row) {
  230. this.$confirm('确认删除该培训记录吗?', '提示', {
  231. confirmButtonText: '确定',
  232. cancelButtonText: '取消',
  233. type: 'warning'
  234. })
  235. .then(() => remove([row.id]))
  236. .then((message) => {
  237. this.$message.success(message || '删除成功');
  238. this.$refs.table.reload();
  239. })
  240. .catch(() => {});
  241. },
  242. // 搜索
  243. handleSearch(where) {
  244. this.$refs.table.reload({ page: 1, where });
  245. },
  246. handleReload() {
  247. this.$refs.table.reload();
  248. },
  249. // 表格数据源
  250. datasource({ page, limit, where }) {
  251. const body = {
  252. ...where,
  253. pageNum: page,
  254. size: limit
  255. };
  256. Object.keys(body).forEach((key) => {
  257. if (body[key] === '' || body[key] === null) {
  258. delete body[key];
  259. }
  260. });
  261. return getPage(body);
  262. }
  263. }
  264. };
  265. </script>
  266. <style lang="scss" scoped>
  267. .search-area {
  268. margin-bottom: 15px;
  269. padding-bottom: 15px;
  270. border-bottom: 1px solid #ebeef5;
  271. }
  272. .list-view {
  273. ::v-deep .ele-pro-table {
  274. .el-table {
  275. border: 1px solid #ebeef5;
  276. border-radius: 4px;
  277. }
  278. }
  279. }
  280. .action-links {
  281. display: flex;
  282. flex-wrap: wrap;
  283. justify-content: center;
  284. gap: 8px;
  285. .el-link {
  286. font-size: 12px;
  287. }
  288. }
  289. </style>