index.vue 5.6 KB

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