index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <workorder-search @search="reload"> </workorder-search>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. cache-key="systemRoleTable"
  11. >
  12. <!-- 表头工具栏 -->
  13. <!-- <template v-slot:toolbar>
  14. <el-button
  15. size="small"
  16. type="primary"
  17. class="ele-btn-icon"
  18. @click="goDetail({ id: 1 })"
  19. >
  20. 详情
  21. </el-button>
  22. </template> -->
  23. <template v-slot:code="{ row }"
  24. ><el-link type="primary" :underline="false" @click="goDetail(row)">
  25. {{ row.code }}
  26. </el-link></template
  27. >
  28. <!-- 操作列 -->
  29. <template v-slot:action="{ row }">
  30. <el-link
  31. v-if="row.orderStatus !== 3 && row.orderStatus !== 4"
  32. type="primary"
  33. :underline="false"
  34. icon="el-icon-truck"
  35. @click="addSpareItems(row)"
  36. >
  37. 申请备品备件
  38. </el-link>
  39. <el-link
  40. v-if="row.orderStatus !== 3 && row.orderStatus !== 4"
  41. type="primary"
  42. :underline="false"
  43. icon="el-icon-edit"
  44. @click="toReport(row)"
  45. >
  46. 报工
  47. </el-link>
  48. <el-link
  49. v-if="row.orderStatus !== 3 && row.orderStatus !== 4"
  50. type="primary"
  51. :underline="false"
  52. icon="el-icon-edit"
  53. @click="toRedeploy(row)"
  54. >
  55. 转派
  56. </el-link>
  57. <el-link
  58. v-if="row.orderStatus == 3"
  59. type="primary"
  60. :underline="false"
  61. icon="el-icon-edit"
  62. @click="downLoadOrder(row)"
  63. >
  64. 下载
  65. </el-link>
  66. <!-- <el-link
  67. type="primary"
  68. :underline="false"
  69. icon="el-icon-edit"
  70. @click="goDetail(row)"
  71. >
  72. 详情
  73. </el-link> -->
  74. </template>
  75. </ele-pro-table>
  76. </el-card>
  77. <!-- <el-dialog :visible.sync="visible" width="20vw">
  78. <el-form label-width="100px">
  79. ></el-form>
  80. <div slot="footer">
  81. <el-button type="primary" @click="spareItems">确定</el-button>
  82. <el-button @click="visible = false">关闭</el-button>
  83. </div>
  84. </el-dialog> -->
  85. <RepairDetailsDialog ref="detailsDialogRef" />
  86. <!-- 报工弹窗 -->
  87. <RepairReportingWork ref="repairReportingWorkRef" @refresh="reload" />
  88. <!-- 转派弹窗 -->
  89. <redeployOther ref="redeployOtherRef" @refresh="reload" />
  90. <!-- 备件弹窗 -->
  91. <edit @refresh="reload" ref="edit" />
  92. <!-- <AddSpareDialog
  93. ref="addSpareDialogRef"
  94. :selectedSpare="selectedSpare"
  95. @submit="spareItemSelectSubmit"
  96. /> -->
  97. </div>
  98. </template>
  99. <script>
  100. import { workorderStatus, resultStatus } from '@/utils/dict/operationManage';
  101. import WorkorderSearch from './components/workorder-search.vue';
  102. import AddSpareDialog from '@/components/addSpareDialog';
  103. import edit from '@/views/sparePartsApply/components/edit';
  104. import RepairReportingWork from '../components/repairReportingWork.vue';
  105. import RepairDetailsDialog from '../components/RepairDetailsDialog.vue';
  106. import redeployOther from '@/views/maintenance/components/redeployOther.vue';
  107. import {
  108. getWorkOrderList,
  109. applySpareParts,
  110. save
  111. } from '@/api/maintenance/repair';
  112. import outin from '@/api/maintenance/outin';
  113. import { getToken } from '@/utils/token-util';
  114. import { download } from '@/utils/file';
  115. import { API_BASE_URL } from '@/config/setting';
  116. import axios from 'axios';
  117. export default {
  118. components: {
  119. WorkorderSearch,
  120. RepairDetailsDialog,
  121. redeployOther,
  122. AddSpareDialog,
  123. RepairReportingWork,
  124. edit
  125. },
  126. data() {
  127. return {
  128. workorderStatus,
  129. resultStatus,
  130. currentRow: {},
  131. warehousingMaterialList: [],
  132. batchDetailsVOList: [],
  133. materialCodeReqList: [],
  134. selectionList: [],
  135. wlParams: {},
  136. visible: false,
  137. materialObj: {},
  138. // 表格列配置
  139. columns: [
  140. {
  141. columnKey: 'index',
  142. label: '序号',
  143. type: 'index',
  144. width: 55,
  145. align: 'center',
  146. showOverflowTooltip: true,
  147. fixed: 'left'
  148. },
  149. {
  150. prop: 'code',
  151. slot: 'code',
  152. label: '工单编号',
  153. align: 'center',
  154. showOverflowTooltip: true,
  155. minWidth: 150
  156. },
  157. {
  158. prop: 'planCode',
  159. // label: '关联单号',
  160. label: '计划单号',
  161. align: 'center',
  162. showOverflowTooltip: true,
  163. minWidth: 110
  164. },
  165. {
  166. prop: 'planName',
  167. label: '维修名称',
  168. align: 'center',
  169. showOverflowTooltip: true,
  170. minWidth: 110
  171. },
  172. {
  173. prop: 'substanceDetailVO.name',
  174. label: '设备名称',
  175. align: 'center',
  176. showOverflowTooltip: true,
  177. minWidth: 110
  178. },
  179. {
  180. prop: 'substanceDetailVO.fixCode',
  181. label: '固资编码',
  182. align: 'center',
  183. showOverflowTooltip: true,
  184. minWidth: 110
  185. },
  186. {
  187. prop: 'substanceDetailVO.codeNumber',
  188. label: '设备编号',
  189. align: 'center',
  190. showOverflowTooltip: true,
  191. minWidth: 110
  192. },
  193. {
  194. prop: 'executeUserName',
  195. label: '执行人',
  196. align: 'center',
  197. showOverflowTooltip: true,
  198. minWidth: 110
  199. },
  200. {
  201. prop: 'assistsName',
  202. label: '辅助人',
  203. align: 'center',
  204. showOverflowTooltip: true,
  205. minWidth: 110
  206. },
  207. {
  208. prop: 'acceptTime',
  209. label: '开始时间',
  210. align: 'center',
  211. showOverflowTooltip: true,
  212. minWidth: 110
  213. },
  214. {
  215. prop: 'finishTime',
  216. label: '结束时间',
  217. align: 'center',
  218. showOverflowTooltip: true,
  219. minWidth: 110
  220. },
  221. {
  222. prop: 'planFinishTime',
  223. label: '计划完成时间',
  224. align: 'center',
  225. showOverflowTooltip: true,
  226. minWidth: 110
  227. },
  228. {
  229. columnKey: 'orderHour',
  230. label: '实际工时(分钟)',
  231. align: 'center',
  232. resizable: false,
  233. showOverflowTooltip: true,
  234. minWidth: 120,
  235. formatter: (row) => {
  236. if (row.finishTime && row.acceptTime) {
  237. return parseInt(
  238. (new Date(row.finishTime).getTime() -
  239. new Date(row.acceptTime).getTime()) /
  240. 60000
  241. );
  242. }
  243. }
  244. },
  245. {
  246. prop: 'orderStatus',
  247. label: '状态',
  248. align: 'center',
  249. showOverflowTooltip: true,
  250. formatter: (row) => {
  251. return workorderStatus.filter(
  252. (item) => item.code == row.orderStatus
  253. )[0].label;
  254. }
  255. },
  256. {
  257. prop: 'acceptanceStatus',
  258. label: '执行结果',
  259. align: 'center',
  260. showOverflowTooltip: true,
  261. formatter: (row) => {
  262. return row.acceptanceStatus
  263. ? resultStatus.filter(
  264. (item) => item.code == row.acceptanceStatus
  265. )[0].label
  266. : '';
  267. }
  268. },
  269. {
  270. columnKey: 'action',
  271. fixed: 'right',
  272. label: '操作',
  273. width: 300,
  274. align: 'center',
  275. resizable: false,
  276. slot: 'action',
  277. showOverflowTooltip: true
  278. }
  279. ],
  280. // 加载状态
  281. loading: false,
  282. pageType: 'add',
  283. dialogTitle: '',
  284. isBindPlan: false,
  285. warehouseList: [],
  286. warehouseId: ''
  287. };
  288. },
  289. created() {},
  290. methods: {
  291. downLoadOrder(row) {
  292. let params = {
  293. id: row.id
  294. };
  295. // downloadAsset(params, '设备台账导出数据');
  296. axios({
  297. url: `${API_BASE_URL}/eam/workorder/excel?id=${row.id}`,
  298. method: 'get',
  299. responseType: 'blob',
  300. headers: {
  301. Authorization: getToken()
  302. }
  303. }).then((res) => {
  304. download(res.data, '维修工单');
  305. });
  306. },
  307. async handleNewSave() {
  308. let { user } = JSON.parse(sessionStorage.getItem('vuex-eam'));
  309. console.log(user);
  310. let userInfo = user.info;
  311. let obj = {
  312. fromUser: userInfo.userId,
  313. bizType: '4', // 领用出库
  314. extInfo: {
  315. assetType: 6,
  316. verifyDeptCode: userInfo.deptId[0],
  317. verifyDeptName: userInfo.deptName
  318. },
  319. type: 2,
  320. fromType: 2
  321. };
  322. obj = { ...obj, ...this.wlParams };
  323. if (this.dimension == 4) {
  324. obj.num = this.materialObj.wlList.length;
  325. } else {
  326. obj.num = this.materialCodeReqList.length;
  327. }
  328. obj.storageSource = 1;
  329. try {
  330. const res = await outin.saveNew(obj);
  331. if (res.code == 0) {
  332. let arr = obj.realTimeInventoryNewPOList.map((item) => {
  333. return {
  334. sparePartsId: item.id,
  335. sparePartsList: JSON.stringify({
  336. ...item,
  337. inventoryDetailsNewPOList: [],
  338. inventoryDetailsVOList: [],
  339. outInIds: res.data
  340. })
  341. };
  342. });
  343. applySpareParts({
  344. workOrderId: this.currentRow.id,
  345. infoList: arr
  346. }).then((res) => {
  347. this.$message.success('申请成功!');
  348. });
  349. }
  350. } catch (error) {
  351. console.log(error);
  352. }
  353. },
  354. detailData(data) {
  355. applySpareParts({
  356. workOrderId: this.currentRow.id,
  357. listId: data.map((item) => item.id),
  358. listNumber: data.map((item) => item.measureQuantity)
  359. }).then((res) => {
  360. this.$message.success('申请成功!');
  361. });
  362. },
  363. // 添加备品备件
  364. addSpareItems(row) {
  365. let data = JSON.parse(JSON.stringify(row));
  366. console.log(data, 'data1');
  367. data['deviceList'] = [data.substanceDetailVO];
  368. this.$refs.edit.open(data, 'add');
  369. console.log(data, 'data2');
  370. },
  371. /* 表格数据源 */
  372. datasource({ page, limit, where, order }) {
  373. return getWorkOrderList({
  374. pageNum: page,
  375. size: limit,
  376. ...where,
  377. type: 3
  378. });
  379. },
  380. async changeEnable(row) {
  381. const res = await putRoles(row);
  382. if (res.code == 0) {
  383. this.$message({
  384. type: 'success',
  385. message: '修改成功',
  386. customClass: 'ele-message-border'
  387. });
  388. this.reload();
  389. }
  390. },
  391. /* 刷新表格 */
  392. reload(where) {
  393. this.$refs.table.reload({ page: 1, where });
  394. },
  395. goDetail(row) {
  396. row.title = '工单详情';
  397. row.tabLabel = '工单信息';
  398. this.$refs.detailsDialogRef.init(row);
  399. },
  400. // 转派
  401. toRedeploy(row) {
  402. console.log(row, 'd');
  403. this.$refs.redeployOtherRef.open(row);
  404. },
  405. // 报工
  406. toReport(row) {
  407. this.$refs.repairReportingWorkRef.open(row, true);
  408. }
  409. }
  410. };
  411. </script>
  412. <style lang="scss" scoped></style>