index.vue 4.9 KB

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