index.vue 6.1 KB

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