index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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: 'factoryName'
  145. },
  146. {
  147. label: '所属厂房',
  148. prop: 'workshopPlanName'
  149. },
  150. {
  151. label: '所属车间',
  152. prop: 'workshopName'
  153. },
  154. {
  155. label: '所属产线',
  156. prop: 'productionLineName'
  157. },
  158. {
  159. label: '设备名称',
  160. prop: 'extInfo.assetName',
  161. formatter: (_row, _column, cellValue) => {
  162. return typeof cellValue === 'string' ? cellValue : '';
  163. }
  164. },
  165. {
  166. label: '设备编码',
  167. prop: 'extInfo.assetCode',
  168. formatter: (_row, _column, cellValue) => {
  169. return typeof cellValue === 'string' ? cellValue : '';
  170. }
  171. },
  172. {
  173. label: '节拍时间',
  174. prop: 'extInfo.meterTime',
  175. slot: 'meterTime'
  176. },
  177. {
  178. //修改此prop名称时,请同步修改columnKey属性和下方selectType方法
  179. label: '状态',
  180. prop: 'enabled',
  181. slot: 'enabled',
  182. filters: [
  183. { value: 1, text: '生效' },
  184. { value: 0, text: '未生效' }
  185. ],
  186. filterMultiple: false,
  187. columnKey: 'enabled'
  188. },
  189. {
  190. columnKey: 'action',
  191. label: '操作',
  192. width: 220,
  193. align: 'center',
  194. resizable: false,
  195. slot: 'action',
  196. showOverflowTooltip: true
  197. }
  198. ],
  199. dict: {
  200. groupId: [],
  201. factory: [],
  202. enabled: {
  203. 1: '生效',
  204. 0: '未生效'
  205. }
  206. },
  207. pageSize: this.$store.state.tablePageSize,
  208. cacheKeyUrl: 'ef00833a-factoryModel-station'
  209. };
  210. },
  211. created() {
  212. this.getGs();
  213. this.getFactoryarea();
  214. },
  215. methods: {
  216. selectType(value) {
  217. let where = {};
  218. if (value.enabled.length > 0) {
  219. where['enable'] = value.enabled[0];
  220. }
  221. this.search(where);
  222. },
  223. datasource({ page, where, limit }) {
  224. return getFactoryworkstation({
  225. ...where,
  226. pageNum: page,
  227. size: limit
  228. });
  229. },
  230. search(where) {
  231. this.$refs.table.reload({
  232. where: where,
  233. page: 1
  234. });
  235. },
  236. openEdit(type, row) {
  237. this.$refs.edit.open(type, row);
  238. },
  239. // 获取公司数据
  240. getGs() {
  241. listOrganizations().then((list) => {
  242. this.dict.groupId = JSON.parse(JSON.stringify(list));
  243. });
  244. },
  245. // 回显车间
  246. showWorkshop(row) {
  247. let result = row.parent.find((n) => n.id == row.parentId);
  248. if (result) {
  249. return result.name;
  250. } else {
  251. return '';
  252. }
  253. },
  254. // 获取工厂数据
  255. getFactoryarea() {
  256. let par = {
  257. type: 1,
  258. size: 9999,
  259. type: 2
  260. };
  261. getFactoryarea(par).then((res) => {
  262. this.dict.factory = res.list;
  263. });
  264. },
  265. importProfession() {
  266. this.$refs.importDialogRef.open();
  267. },
  268. remove(row) {
  269. deleteFactoryworkstation(row.id)
  270. .then((message) => {
  271. this.$message.success(message);
  272. this.done();
  273. })
  274. .catch((e) => {
  275. this.$message.error(e.message);
  276. });
  277. },
  278. done() {
  279. this.$refs.search.search();
  280. }
  281. }
  282. };
  283. </script>