index.vue 5.0 KB

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