index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <search @search="reload" />
  5. <ele-pro-table
  6. ref="table"
  7. :columns="columns"
  8. :datasource="datasource"
  9. :page-size="pageSize"
  10. @columns-change="handleColumnChange"
  11. :cache-key="cacheKeyUrl"
  12. >
  13. <!-- 表头工具栏 -->
  14. <template v-slot:toolbar>
  15. <el-button
  16. size="small"
  17. type="primary"
  18. icon="el-icon-plus"
  19. class="ele-btn-icon"
  20. @click="openEdit('add')"
  21. v-if="$hasPermission('main:teamtime:save')"
  22. >
  23. 新建
  24. </el-button>
  25. </template>
  26. <!-- 操作列 -->
  27. <template v-slot:action="{ row }">
  28. <el-link
  29. type="primary"
  30. :underline="false"
  31. icon="el-icon-edit"
  32. @click="openEdit('edit', row)"
  33. v-if="$hasPermission('main:teamtime:update')"
  34. >
  35. 修改
  36. </el-link>
  37. <el-popconfirm
  38. class="ele-action"
  39. title="确定要删除此班次吗?"
  40. @confirm="remove(row)"
  41. v-if="$hasPermission('main:teamtime:delete')"
  42. >
  43. <template v-slot:reference>
  44. <el-link type="danger" :underline="false" icon="el-icon-delete">
  45. 删除
  46. </el-link>
  47. </template>
  48. </el-popconfirm>
  49. </template>
  50. </ele-pro-table>
  51. </el-card>
  52. <edit ref="edit" @done="done"></edit>
  53. </div>
  54. </template>
  55. <script>
  56. import tabMixins from '@/mixins/tableColumnsMixin';
  57. import edit from './components/edit.vue';
  58. import {
  59. getteamtime,
  60. deleteteamtime
  61. } from '@/api/workforceManagement/classes';
  62. import search from './components/search.vue';
  63. export default {
  64. mixins: [tabMixins],
  65. components: {
  66. edit,
  67. search
  68. },
  69. data () {
  70. return {
  71. columns: [
  72. {
  73. width: 45,
  74. type: 'index',
  75. columnKey: 'index',
  76. align: 'center',
  77. fixed:'left'
  78. },
  79. {
  80. prop: 'code',
  81. label: '班次编号'
  82. },
  83. {
  84. label: '班次名称',
  85. prop: 'name'
  86. },
  87. {
  88. label: '所属工厂',
  89. prop: 'factoryName'
  90. },
  91. {
  92. label: '创建人',
  93. prop: 'createUserName'
  94. },
  95. {
  96. label: '创建时间',
  97. prop: 'createTime'
  98. },
  99. {
  100. columnKey: 'action',
  101. label: '操作',
  102. width: 220,
  103. align: 'center',
  104. resizable: false,
  105. slot: 'action',
  106. showOverflowTooltip: true,
  107. fixed:'right'
  108. }
  109. ],
  110. dict: {
  111. enabled: {
  112. 1: '生效',
  113. 0: '未生效'
  114. },
  115. groupId: []
  116. },
  117. pageSize: this.$store.state.tablePageSize,
  118. cacheKeyUrl: 'bd54dd9f-workforceManagement-classes'
  119. };
  120. },
  121. methods: {
  122. datasource ({ page, where, limit }) {
  123. let data = getteamtime({
  124. ...where,
  125. pageNum: page,
  126. size: limit
  127. });
  128. console.log(data);
  129. return data;
  130. },
  131. openEdit (type, row) {
  132. this.$refs.edit.open(type, row);
  133. },
  134. remove (row) {
  135. let par = [row.id];
  136. deleteteamtime(par)
  137. .then((message) => {
  138. this.$message.success(message);
  139. this.done();
  140. })
  141. .catch((e) => {
  142. this.$message.error(e.message);
  143. });
  144. },
  145. done () {
  146. this.$refs.table.reload({
  147. page: 1
  148. });
  149. },
  150. /* 刷新表格 */
  151. reload(where) {
  152. this.$refs.table.reload({ page: 1, where: where });
  153. },
  154. openclass () {
  155. this.$refs.setclasses.open();
  156. }
  157. }
  158. };
  159. </script>