index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. :page-size="pageSize"
  15. @columns-change="handleColumnChange"
  16. :cache-key="cacheKeyUrl"
  17. @filter-change="selectType"
  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. >
  28. 添加
  29. </el-button>
  30. </template>
  31. <!-- <template v-slot:workshop="{ row }">
  32. {{ showWorkshop(row) }}
  33. </template> -->
  34. <template v-slot:meterTime="{ row }">
  35. <div v-if="row.extInfo.meterTime">
  36. {{ `${row.extInfo.meterTime} ${row.extInfo.meterTimeUnit}/次 ` }}
  37. </div>
  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. ></edit>
  70. </div>
  71. </template>
  72. <script>
  73. import tabMixins from '@/mixins/tableColumnsMixin';
  74. import search from './components/search.vue';
  75. import edit from './components/edit.vue';
  76. import {
  77. deleteFactoryworkstation,
  78. getFactoryworkstation,
  79. getFactoryarea
  80. } from '@/api/factoryModel';
  81. import { listOrganizations } from '@/api/system/organization';
  82. export default {
  83. mixins: [tabMixins],
  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: 'factoryName',
  117. },
  118. {
  119. label: '所属厂房',
  120. prop: 'workshopPlanName',
  121. },
  122. {
  123. label: '所属车间',
  124. prop: 'workshopName'
  125. },
  126. {
  127. label: '所属产线',
  128. prop: 'productionLineName'
  129. },
  130. {
  131. label: '节拍时间',
  132. prop: 'extInfo.meterTime',
  133. slot: 'meterTime'
  134. },
  135. {//修改此prop名称时,请同步修改columnKey属性和下方selectType方法
  136. label: '状态',
  137. prop: 'enabled',
  138. slot: 'enabled',
  139. filters: [
  140. { value: 1, text: '生效' },
  141. { value: 0, text: '未生效' },
  142. ],
  143. filterMultiple: false,
  144. columnKey: 'enabled'
  145. },
  146. {
  147. columnKey: 'action',
  148. label: '操作',
  149. width: 220,
  150. align: 'center',
  151. resizable: false,
  152. slot: 'action',
  153. showOverflowTooltip: true
  154. }
  155. ],
  156. dict: {
  157. groupId: [],
  158. factory: [],
  159. enabled: {
  160. 1: '生效',
  161. 0: '未生效'
  162. }
  163. },
  164. pageSize: this.$store.state.tablePageSize,
  165. cacheKeyUrl: 'ef00833a-factoryModel-station'
  166. };
  167. },
  168. created () {
  169. this.getGs();
  170. this.getFactoryarea();
  171. },
  172. methods: {
  173. selectType(value) {
  174. let where = {}
  175. if (value.enabled.length > 0) {
  176. where['enable'] = value.enabled[0]
  177. }
  178. this.search(where)
  179. },
  180. datasource ({ page, where, limit }) {
  181. return getFactoryworkstation({
  182. ...where,
  183. pageNum: page,
  184. size: limit
  185. });
  186. },
  187. search (where) {
  188. this.$refs.table.reload({
  189. where: where,
  190. page: 1
  191. });
  192. },
  193. openEdit (type, row) {
  194. this.$refs.edit.open(type, row);
  195. },
  196. // 获取公司数据
  197. getGs () {
  198. listOrganizations().then((list) => {
  199. this.dict.groupId = JSON.parse(JSON.stringify(list));
  200. });
  201. },
  202. // 回显车间
  203. showWorkshop (row) {
  204. let result = row.parent.find((n) => n.id == row.parentId);
  205. if (result) {
  206. return result.name;
  207. } else {
  208. return '';
  209. }
  210. },
  211. // 获取工厂数据
  212. getFactoryarea () {
  213. let par = {
  214. type: 1,
  215. size: 9999,
  216. type: 2,
  217. };
  218. getFactoryarea(par).then((res) => {
  219. this.dict.factory = res.list;
  220. });
  221. },
  222. remove (row) {
  223. deleteFactoryworkstation(row.id)
  224. .then((message) => {
  225. this.$message.success(message);
  226. this.done();
  227. })
  228. .catch((e) => {
  229. this.$message.error(e.message);
  230. });
  231. },
  232. done () {
  233. this.$refs.search.search();
  234. }
  235. }
  236. };
  237. </script>