Index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索模块 -->
  4. <div class="filter-container">
  5. <!--设备名称-->
  6. <span>
  7. <span>{{ $t("resource.table.repair.productionresourceName") }}:</span>
  8. <el-input
  9. v-model="queryParams.model.productionresourceName"
  10. :placeholder="$t(&quot;common.pleaseEnter&quot;)"
  11. style="width: 150px;"
  12. size="medium"
  13. />
  14. </span>
  15. <!--设备编号-->
  16. <span>
  17. <span>{{ $t("resource.table.repair.code") }}:</span>
  18. <el-input
  19. v-model="queryParams.model.code"
  20. :placeholder="$t(&quot;common.pleaseEnter&quot;)"
  21. style="width: 150px;"
  22. size="medium"
  23. />
  24. </span>
  25. <span style="margin-left: 15px;">
  26. <el-button
  27. plain
  28. type="primary"
  29. icon="el-icon-search"
  30. size="medium"
  31. @click="search"
  32. >
  33. {{ $t("table.search") }}
  34. </el-button>
  35. <el-button
  36. plain
  37. type="warning"
  38. icon="el-icon-refresh"
  39. size="medium"
  40. @click="reset"
  41. >
  42. {{ $t("table.reset") }}
  43. </el-button>
  44. </span>
  45. </div>
  46. <!-- 功能按钮 -->
  47. <el-row class="filter-container">
  48. <el-col>
  49. <!--添加按钮,调用add方法-->
  50. <el-button
  51. type="primary"
  52. icon="el-icon-plus"
  53. size="medium"
  54. @click="add"
  55. >
  56. {{ $t("common.add") }}
  57. </el-button>
  58. <!--修改按钮,调用edit-->
  59. <el-button
  60. type="success"
  61. icon="el-icon-edit"
  62. size="medium"
  63. @click="editOne"
  64. >
  65. {{ $t("common.edit") }}
  66. </el-button>
  67. <el-button
  68. type="danger"
  69. icon="el-icon-delete"
  70. size="medium"
  71. @click="batchDelete"
  72. >
  73. {{ $t("table.delete") }}
  74. </el-button>
  75. </el-col>
  76. </el-row>
  77. <!-- 列表数据 -->
  78. <el-table
  79. :key="tableKey"
  80. ref="table"
  81. v-loading="loading"
  82. :data="tableData.records"
  83. border
  84. fit
  85. row-key="id"
  86. style="width: 100%;"
  87. @selection-change="onSelectChange"
  88. @cell-click="cellClick"
  89. >
  90. <el-table-column
  91. :label="$t(&quot;common.serialNo&quot;)"
  92. width="55px"
  93. align="center"
  94. >
  95. <template slot-scope="scope">
  96. <div>
  97. {{ scope.$index+(queryParams.current - 1) * queryParams.size + 1 }}
  98. </div>
  99. </template>
  100. </el-table-column>
  101. <el-table-column
  102. align="center"
  103. type="selection"
  104. width="50"
  105. :reserve-selection="true"
  106. />
  107. <!--设备编号-->
  108. <el-table-column
  109. prop="code"
  110. :label="$t(&quot;resource.table.repair.code&quot;)"
  111. :show-overflow-tooltip="true"
  112. />
  113. <!--设备名称-->
  114. <el-table-column
  115. prop="productionresourceName"
  116. :label="$t(&quot;resource.table.repair.productionresourceName&quot;)"
  117. :show-overflow-tooltip="true"
  118. />
  119. <!--所在产线-->
  120. <el-table-column
  121. prop="lineDesc"
  122. :label="$t(&quot;resource.table.repair.lineDesc&quot;)"
  123. :show-overflow-tooltip="true"
  124. width="120"
  125. />
  126. <!--维修倒计时进度-->
  127. <el-table-column
  128. prop="downTime"
  129. :label="$t(&quot;resource.table.repair.countdown&quot;)"
  130. :show-overflow-tooltip="true"
  131. width="200"
  132. align="center"
  133. >
  134. <template slot-scope="{ row }" id="">
  135. <el-progress
  136. :text-inside="true"
  137. :stroke-width="24"
  138. :percentage="row.process"
  139. show-text="true"
  140. :format="setItemText(row)"
  141. :color="setItemColor(row)"
  142. />
  143. </template>
  144. </el-table-column>
  145. <!--维保结束时间-->
  146. <el-table-column
  147. prop="repairEndTime"
  148. :label="$t(&quot;resource.table.repair.repairEndTime&quot;)"
  149. :show-overflow-tooltip="true"
  150. width="120"
  151. />
  152. <!--维修状态-->
  153. <el-table-column
  154. prop="repairStatus"
  155. :label="$t(&quot;resource.table.repair.repairStatus&quot;)"
  156. align="center"
  157. width="90px"
  158. >
  159. <template slot-scope="{ row }">
  160. <el-tag :type="row.repairStatus=='1' ? 'success' : 'danger'">
  161. {{ row.repairStatus=='1' ? '正常' : '待维修' }}
  162. </el-tag>
  163. </template>
  164. </el-table-column>
  165. <!--状态-->
  166. <el-table-column
  167. prop="status"
  168. :label="$t(&quot;resource.table.repair.status&quot;)"
  169. align="center"
  170. width="90px"
  171. >
  172. <template slot-scope="{ row }">
  173. <el-tag :type="row.status=='1' ? 'success' : 'danger'">
  174. {{ row.status=='1' ? '启用' : '冻结' }}
  175. </el-tag>
  176. </template>
  177. </el-table-column>
  178. <!--创建时间-->
  179. <el-table-column
  180. prop="createTime"
  181. :label="$t(&quot;resource.table.repair.createTime&quot;)"
  182. width="180px"
  183. />
  184. <!--最新修改时间-->
  185. <el-table-column
  186. prop="updateTime"
  187. :label="$t(&quot;resource.table.repair.updateTime&quot;)"
  188. width="180px"
  189. />
  190. <!--操作人-->
  191. <el-table-column
  192. prop="operationName"
  193. :label="$t(&quot;resource.table.repair.createUserDesc&quot;)"
  194. width="180px"
  195. />
  196. <!--操作-->
  197. <el-table-column
  198. :label="$t('table.operation')"
  199. fixed="right"
  200. align="center"
  201. column-key="operation"
  202. width="260px"
  203. >
  204. <template slot-scope="{ row }">
  205. <a
  206. class="rowBtn"
  207. @click="equipment(row)"
  208. >登记维保</a>
  209. <a
  210. class="rowBtn"
  211. @click="eventRow(row)"
  212. >更新计划</a>
  213. <a
  214. class="rowBtn"
  215. @click="edit(row)"
  216. >修改</a>
  217. <a
  218. class="rowBtn"
  219. @click="singleDelete(row)"
  220. >删除</a>
  221. </template>
  222. </el-table-column>
  223. </el-table>
  224. <pagination
  225. v-show="tableData.total > 0"
  226. :limit.sync="queryParams.size"
  227. :page.sync="queryParams.current"
  228. :total="Number(tableData.total)"
  229. @pagination="fetch"
  230. />
  231. <tenant-edit
  232. ref="edit"
  233. :dialog-visible="dialog.isVisible"
  234. :title="dialog.title"
  235. @close="editClose"
  236. @success="editSuccess"
  237. />
  238. <tenant-event
  239. ref="event"
  240. :dialog-visible="tenantEvent.isVisible"
  241. :title="tenantEvent.title"
  242. @close="eventClose"
  243. @success="eventSuccess"
  244. />
  245. <tenant-view
  246. ref="view"
  247. :dialog-visible="tenantViewVisible"
  248. @close="viewClose"
  249. />
  250. <el-dialog
  251. v-el-drag-dialog
  252. :close-on-click-modal="false"
  253. :close-on-press-escape="true"
  254. title="预览"
  255. width="80%"
  256. top="50px"
  257. :visible.sync="preview.isVisible"
  258. >
  259. <el-scrollbar>
  260. <div v-html="preview.context" />
  261. </el-scrollbar>
  262. </el-dialog>
  263. <el-dialog
  264. :visible.sync="equipmentVisible"
  265. width="80%"
  266. custom-class="dialogNoTop"
  267. @close="editEquipmentClose"
  268. >
  269. <!--【 维保】 -->
  270. <maintenanceLog
  271. :row-data="rowData"
  272. :maintenance-id="maintenanceId"
  273. @close="editEquipmentClose"
  274. @success="editEquipmentSuccess"
  275. />
  276. </el-dialog>
  277. </div>
  278. </template>
  279. <script>
  280. // 【分页】组件
  281. import Pagination from "@/components/Pagination"
  282. // 【新增/修改】组件
  283. import TenantEdit from "./components/Edit"
  284. //【更新/计划】组件
  285. import TenantEvent from "./components/Event"
  286. // 【查看】组件
  287. import TenantView from "./components/View"
  288. // 【维保计划管理】-API
  289. import repairApi from "@/api/resourceProductMgr/repair"
  290. // 【工作位置管理】组件
  291. import maintenanceLog from "@/views/zuihou/repairManger/maintenanceLog/Index"
  292. // 【弹出框】elementui组件
  293. import elDragDialog from '@/directive/el-drag-dialog'
  294. import VueProgressBar from 'vue-progressbar'
  295. // 共通函数
  296. import {downloadFile, initEnums, initDicts, initQueryParams} from '@/utils/commons'
  297. export default {
  298. name: "Repair",
  299. directives: {elDragDialog},
  300. components: {Pagination, TenantEdit, TenantView,TenantEvent,maintenanceLog},
  301. props: {},
  302. data() {
  303. return {
  304. maintenanceId:'',
  305. audioStatus: [],
  306. equipmentVisible: false, // 设备维保记录管理
  307. rowData: {}, // row数据
  308. dialog: {
  309. isVisible: false,
  310. title: ""
  311. },
  312. tenantEvent:{
  313. isVisible: false,
  314. title: ""
  315. },
  316. preview: {
  317. isVisible: false,
  318. context: ''
  319. },
  320. tenantViewVisible: false,
  321. tableKey: 0,
  322. queryParams: initQueryParams({}),
  323. selection: [],
  324. loading: false,
  325. tableData: {
  326. total: 0
  327. },
  328. dicts: {
  329. NATION: {}
  330. },
  331. enums: {
  332. TenantTypeEnum: {},
  333. TenantStatusEnum: {}
  334. }
  335. }
  336. },
  337. computed: {
  338. currentUser() {
  339. return this.$store.state.account.user
  340. },
  341. nationList() {
  342. return convertEnum(this.dicts.NATION)
  343. }
  344. },
  345. // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
  346. created() {
  347. // 调用常量-审核状态
  348. this.audioStatus = this.$constWKS.SHOWHIDE
  349. // 加载【字典】
  350. initDicts(['NATION'], this.dicts);
  351. // 加载列表数据
  352. this.fetch()
  353. },
  354. mounted() {
  355. },
  356. methods: {
  357. //【设备维保记录】按钮-事件
  358. equipment(row){
  359. this.maintenanceId = row.id
  360. this.equipmentVisible = true
  361. },
  362. editEquipmentClose(){
  363. this.equipmentVisible = false
  364. this.search()
  365. },
  366. editEquipmentSuccess(){
  367. this.search()
  368. },
  369. setItemText(row) {
  370. return () => {
  371. return row.downTime
  372. }
  373. },
  374. setItemColor(row) {
  375. return () => {
  376. if(row.expireFlag == 1){
  377. return '#FF0000'
  378. }
  379. }
  380. },
  381. viewClose() {
  382. this.tenantViewVisible = false
  383. },
  384. editClose() {
  385. this.dialog.isVisible = false
  386. this.fetch()
  387. },
  388. eventClose() {
  389. this.tenantEvent.isVisible = false
  390. this.fetch()
  391. },
  392. editSuccess() {
  393. this.search()
  394. },
  395. eventSuccess(){
  396. this.search()
  397. },
  398. onSelectChange(selection) {
  399. this.selection = selection
  400. },
  401. search() {
  402. this.fetch({
  403. ...this.queryParams
  404. })
  405. },
  406. reset() {
  407. this.queryParams = initQueryParams({})
  408. this.$refs.table.clearSort()
  409. this.$refs.table.clearFilter()
  410. this.search()
  411. },
  412. add() {
  413. this.$refs.edit.type = "add"
  414. this.$refs.edit.setTenant(false, this.dicts)
  415. this.dialog.title = this.$t("common.add")
  416. this.dialog.isVisible = true
  417. },
  418. singleDelete(row) {
  419. this.$refs.table.clearSelection()
  420. this.$refs.table.toggleRowSelection(row, true)
  421. this.batchDelete()
  422. },
  423. batchDelete() {
  424. if (!this.selection.length) {
  425. this.$message({
  426. message: this.$t("tips.noDataSelected"),
  427. type: "warning"
  428. })
  429. return
  430. }
  431. this.$confirm(this.$t("wms.tips.delete"), this.$t("common.tips"), {
  432. distinguishCancelAndClose: true,
  433. confirmButtonText: this.$t("common.confirm"),
  434. cancelButtonText: this.$t("common.cancel"),
  435. type: "warning"
  436. }).then(() => {
  437. const ids = []
  438. this.selection.forEach(item => {
  439. ids.push(item.id)
  440. })
  441. this.delete(ids)
  442. }).catch(() => {
  443. })
  444. },
  445. clearSelections() {
  446. this.$refs.table.clearSelection()
  447. },
  448. delete(ids) {
  449. repairApi.remove({ids: ids}).then(response => {
  450. const res = response.data
  451. if (res.isSuccess) {
  452. this.$message({
  453. message: this.$t("tips.deleteSuccess"),
  454. type: "success"
  455. })
  456. this.search()
  457. // 清理已经删除的数据
  458. this.$refs.table.clearSelection()
  459. }
  460. })
  461. },
  462. view(row) {
  463. this.$refs.view.setTenant(row)
  464. this.tenantViewVisible = true
  465. },
  466. // 【修改】表头上Btn-事件
  467. editOne() {
  468. if (!this.selection.length) {
  469. this.$message({
  470. message: this.$t("tips.noDataSelected"),
  471. type: "warning"
  472. })
  473. return
  474. }
  475. if (this.selection.length > 1) {
  476. this.$message({
  477. message: this.$t("tips.mustOne"),
  478. type: "warning"
  479. })
  480. return
  481. }
  482. this.edit(this.selection[0]);
  483. },
  484. edit(row) {
  485. this.$refs.edit.setTenant(row, this.dicts)
  486. this.$refs.edit.type = "edit"
  487. this.dialog.title = this.$t("common.edit")
  488. this.dialog.isVisible = true
  489. },
  490. eventRow(row){
  491. this.$refs.event.setTenant(row, this.dicts)
  492. this.$refs.event.type = "event"
  493. this.tenantEvent.title = "更新计划"
  494. this.tenantEvent.isVisible = true
  495. },
  496. fetch(params = {}) {
  497. this.tableKey = !this.tableKey
  498. this.selection = []
  499. this.loading = true
  500. if (this.queryParams.timeRange) {
  501. this.queryParams.map.createTime_st = this.queryParams.timeRange[0]
  502. this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]
  503. }
  504. this.queryParams.current = params.current ? params.current : this.queryParams.current
  505. this.queryParams.size = params.size ? params.size : this.queryParams.size
  506. repairApi.page(this.queryParams).then(response => {
  507. const res = response.data
  508. if (res.isSuccess) {
  509. this.tableData = res.data
  510. }
  511. // eslint-disable-next-line no-return-assign
  512. }).finally(() => this.loading = false)
  513. },
  514. cellClick(row, column) {
  515. if (column['columnKey'] === "operation") {
  516. return
  517. }
  518. let flag = false
  519. this.selection.forEach((item) => {
  520. if (item.id === row.id) {
  521. flag = true
  522. this.$refs.table.toggleRowSelection(row)
  523. }
  524. })
  525. if (!flag) {
  526. this.$refs.table.toggleRowSelection(row, true)
  527. }
  528. }
  529. }
  530. }
  531. </script>
  532. <style lang="scss" scoped>
  533. .rowBtn {
  534. margin: 0 5px;
  535. color: #1890ff;
  536. }
  537. .rowBtn:hover {
  538. opacity: 0.7;
  539. }
  540. </style>