index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <search ref="search" @search="search"></search>
  5. <ele-pro-table
  6. ref="table"
  7. :columns="columns"
  8. height="calc(100vh - 400px)"
  9. :datasource="datasource"
  10. cache-key="systemRoleTable1"
  11. >
  12. <!-- 表头工具栏 -->
  13. <template v-slot:toolbar>
  14. <el-button
  15. size="small"
  16. type="primary"
  17. icon="el-icon-plus"
  18. class="ele-btn-icon"
  19. @click="openEdit('add')"
  20. >
  21. 添加
  22. </el-button>
  23. </template>
  24. <template v-slot:enabled="{ row }">
  25. {{ dict.enabled[row.enabled] }}
  26. </template>
  27. <template v-slot:groupId="{ row }">
  28. {{ showgroupName(row.groupId) }}
  29. </template>
  30. <!-- 操作列 -->
  31. <template v-slot:action="{ row }">
  32. <el-link
  33. type="primary"
  34. :underline="false"
  35. icon="el-icon-edit"
  36. @click="openEdit('edit', row)"
  37. >
  38. 修改
  39. </el-link>
  40. <el-popconfirm
  41. class="ele-action"
  42. title="确定要删除此角色吗?"
  43. @confirm="remove(row)"
  44. >
  45. <template v-slot:reference>
  46. <el-link type="danger" :underline="false" icon="el-icon-delete">
  47. 删除
  48. </el-link>
  49. </template>
  50. </el-popconfirm>
  51. </template>
  52. </ele-pro-table>
  53. </el-card>
  54. <edit ref="edit" @done="done" :options_groupId="dict.groupId"></edit>
  55. </div>
  56. </template>
  57. <script>
  58. import search from './components/search.vue';
  59. import edit from './components/edit.vue';
  60. import { getFactoryarea, deletefactoryarea } from '@/api/factoryModel';
  61. import { listOrganizations } from '@/api/system/organization';
  62. export default {
  63. components: {
  64. search,
  65. edit
  66. },
  67. data() {
  68. return {
  69. columns: [
  70. {
  71. width: 45,
  72. type: 'index',
  73. columnKey: 'index',
  74. align: 'center'
  75. },
  76. {
  77. prop: 'code',
  78. label: '工厂编码'
  79. },
  80. {
  81. label: '工厂名称',
  82. prop: 'name'
  83. },
  84. {
  85. label: '所属公司',
  86. prop: 'groupId',
  87. slot: 'groupId'
  88. },
  89. {
  90. label: '区域名',
  91. prop: 'areaName',
  92. },
  93. {
  94. label: '省/市/区',
  95. prop: 'extInfo.location'
  96. },
  97. {
  98. label: '详细地址',
  99. prop: 'extInfo.locationDetail'
  100. },
  101. {
  102. label: '状态',
  103. prop: 'enabled',
  104. slot: 'enabled'
  105. },
  106. {
  107. columnKey: 'action',
  108. label: '操作',
  109. width: 220,
  110. align: 'center',
  111. resizable: false,
  112. slot: 'action',
  113. showOverflowTooltip: true
  114. }
  115. ],
  116. dict: {
  117. enabled: {
  118. 1: '生效',
  119. 0: '未生效'
  120. },
  121. groupId: []
  122. }
  123. };
  124. },
  125. created() {
  126. this.getGs();
  127. },
  128. methods: {
  129. datasource({ page, where, limit }) {
  130. return getFactoryarea({
  131. ...where,
  132. pageNum: page,
  133. size: limit,
  134. type: 1
  135. });
  136. },
  137. search(where) {
  138. this.$refs.table.reload({
  139. where: where,
  140. page: 1
  141. });
  142. },
  143. openEdit(type, row) {
  144. this.$refs.edit.open(type, row);
  145. },
  146. // 获取公司数据
  147. getGs() {
  148. listOrganizations().then((list) => {
  149. console.log(list);
  150. this.dict.groupId = list;
  151. });
  152. },
  153. // 回显公司名称
  154. showgroupName(id) {
  155. let result = this.dict.groupId.find((n) => n.id == id);
  156. if (result) {
  157. return result.name;
  158. } else {
  159. return '';
  160. }
  161. },
  162. remove(row) {
  163. deletefactoryarea(row.id)
  164. .then((message) => {
  165. this.$message.success(message);
  166. this.done();
  167. })
  168. .catch((e) => {
  169. this.$message.error(e.message);
  170. });
  171. },
  172. done() {
  173. this.$refs.search.search();
  174. }
  175. }
  176. };
  177. </script>