index.vue 5.2 KB

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