index.vue 7.8 KB

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