index.vue 5.3 KB

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