index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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: 'parentId',
  113. slot: 'pathName'
  114. },
  115. {
  116. label: '所属车间',
  117. prop: 'workshopName'
  118. },
  119. {
  120. label: '所属产线',
  121. prop: 'productionLineName'
  122. },
  123. {
  124. label: '节拍时间',
  125. prop: 'extInfo.meterTime',
  126. slot: 'meterTime'
  127. },
  128. {
  129. label: '状态',
  130. prop: 'enabled',
  131. slot: 'enabled'
  132. },
  133. {
  134. columnKey: 'action',
  135. label: '操作',
  136. width: 220,
  137. align: 'center',
  138. resizable: false,
  139. slot: 'action',
  140. showOverflowTooltip: true
  141. }
  142. ],
  143. dict: {
  144. groupId: [],
  145. factory: [],
  146. enabled: {
  147. 1: '生效',
  148. 0: '未生效'
  149. }
  150. }
  151. };
  152. },
  153. created () {
  154. this.getGs();
  155. this.getFactoryarea();
  156. },
  157. methods: {
  158. datasource ({ page, where, limit }) {
  159. return getFactoryworkstation({
  160. ...where,
  161. pageNum: page,
  162. size: limit
  163. });
  164. },
  165. search (where) {
  166. this.$refs.table.reload({
  167. where: where,
  168. page: 1
  169. });
  170. },
  171. openEdit (type, row) {
  172. this.$refs.edit.open(type, row);
  173. },
  174. // 获取公司数据
  175. getGs () {
  176. listOrganizations().then((list) => {
  177. console.log(list);
  178. this.dict.groupId = list;
  179. });
  180. },
  181. // 回显车间
  182. showWorkshop (row) {
  183. let result = row.parent.find((n) => n.id == row.parentId);
  184. if (result) {
  185. return result.name;
  186. } else {
  187. return '';
  188. }
  189. },
  190. // 获取工厂数据
  191. getFactoryarea () {
  192. let par = {
  193. type: 1,
  194. size: 9999,
  195. type: 2,
  196. };
  197. getFactoryarea(par).then((res) => {
  198. this.dict.factory = res.list;
  199. });
  200. },
  201. remove (row) {
  202. deleteFactoryworkstation(row.id)
  203. .then((message) => {
  204. this.$message.success(message);
  205. this.done();
  206. })
  207. .catch((e) => {
  208. this.$message.error(e.message);
  209. });
  210. },
  211. done () {
  212. this.$refs.search.search();
  213. }
  214. }
  215. };
  216. </script>