Index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索模块 -->
  4. <div class="filter-container">
  5. <!--<span>
  6. <span>{{$t("lineSide.searchForm.name")}}:</span>
  7. <el-input v-model="queryParams.model.name" :placeholder='$t("common.pleaseEnter")' style="width: 150px;" size="medium"/>
  8. </span>-->
  9. <span>
  10. <span>{{$t("resource.searchForm.startEndTime")}}:</span>
  11. <el-date-picker
  12. v-model="queryParams.timeRange"
  13. type="daterange"
  14. :picker-options="pickerOptions"
  15. :range-separator='$t("common.separator")'
  16. :start-placeholder='$t("common.startTime")'
  17. :end-placeholder='$t("common.endTime")'
  18. format="yyyy-MM-dd"
  19. value-format="yyyy-MM-dd"
  20. align="right">
  21. </el-date-picker>
  22. </span>
  23. <!--<span style="margin-left: 15px;">
  24. <span>{{$t("lineSide.common.type")}}:</span>
  25. <el-select v-model="queryParams.model.optType" :placeholder='$t("common.pleaseSelect")' size="medium" style="width: 150px;">
  26. <el-option
  27. v-for="item in audioStatus"
  28. :key="item.value"
  29. :label="item.label"
  30. :value="item.value">
  31. </el-option>
  32. </el-select>
  33. </span>-->
  34. <span style="margin-left: 15px;">
  35. <el-button plain type="primary" icon="el-icon-search" size="medium" @click="search">
  36. {{ $t("table.search") }}
  37. </el-button>
  38. <el-button plain type="warning" icon="el-icon-refresh" size="medium" @click="reset">
  39. {{ $t("table.reset") }}
  40. </el-button>
  41. </span>
  42. </div>
  43. <!-- 功能按钮 -->
  44. <el-row class="filter-container">
  45. <el-col>
  46. <el-button v-has-permission="['warnLong:delete']" type="danger" icon="el-icon-delete" size="medium" @click="batchDelete">
  47. {{ $t("table.delete") }}
  48. </el-button>
  49. <el-button v-has-permission="['warnLong:tags']" type="primary" icon="el-icon-plus" size="medium" @click="marking">{{ $t("developer.buttons.marking") }}</el-button>
  50. <!--<el-button type="success" icon="el-icon-edit" size="medium" @click="editOne">
  51. {{ $t("common.edit") }}
  52. </el-button>-->
  53. </el-col>
  54. </el-row>
  55. <!-- 列表数据 -->
  56. <el-table
  57. :key="tableKey"
  58. ref="table"
  59. v-loading="loading"
  60. :data="tableData.records"
  61. border
  62. fit
  63. row-key="id"
  64. style="width: 100%;"
  65. @selection-change="onSelectChange"
  66. @cell-click="cellClick"
  67. >
  68. <!-- 序号 -->
  69. <el-table-column :label='$t("common.serialNo")' width="55px" align="center">
  70. <template slot-scope="scope">
  71. <div>
  72. {{scope.$index+(queryParams.current - 1) * queryParams.size + 1}}
  73. </div>
  74. </template>
  75. </el-table-column>
  76. <!-- CheckBox -->
  77. <el-table-column align="center" type="selection" width="50" :reserve-selection="true" />
  78. <!-- 编码 -->
  79. <el-table-column prop="nodeNo" :label='$t("developer.table.warnLong.no")' :show-overflow-tooltip="true" width="160">
  80. <template slot-scope="{ row }">
  81. <span v-if="row.nodeNo"> {{row.nodeNo}}</span>
  82. <span v-else-if="!row.taskNodeId">设备状态监控</span>
  83. </template>
  84. </el-table-column>
  85. <!-- 设备 -->
  86. <el-table-column prop="resourceName" :label='$t("developer.table.warnLong.name")' width="180">
  87. <template slot-scope="{ row }">
  88. <span v-if="row.category=='2'">AGV异常</span>
  89. <span v-else-if="row.resourceName"> {{row.resourceName}}</span>
  90. <span v-else-if="row.robotName"> {{row.robotName}}</span>
  91. <span v-else-if="!row.taskNodeId">{{row.feedback}}</span>
  92. </template>
  93. </el-table-column>
  94. <!-- 报警内容 -->
  95. <el-table-column prop="feedback" :label='$t("developer.table.warnLong.storgeId")' >
  96. <template slot-scope="{ row }">
  97. <span v-if="row.taskNodeId"> {{row.procedureName}}-{{row.instructionName}}-{{row.feedback}}</span>
  98. <span v-else>设备监控推送异常</span>
  99. </template>
  100. </el-table-column>
  101. <!-- 报警时间 -->
  102. <el-table-column prop="createTime" :label='$t("developer.table.warnLong.updateTime")' width="160px"></el-table-column>
  103. <!-- 是否需要人员处理 -->
  104. <el-table-column prop="manual" :label='$t("developer.table.warnLong.num")' align="center" width="150px">
  105. <template slot-scope="{ row }">
  106. <el-tag v-if="row.manual == '1'" type="success">{{$t("common.yes")}}</el-tag>
  107. <el-tag v-else type="failed">{{$t("common.no")}}</el-tag>
  108. </template>
  109. </el-table-column>
  110. <!-- 处理状态 -->
  111. <el-table-column prop="status" :label='$t("developer.table.warnLong.goodsType")' align="center" width="120px">
  112. <template slot-scope="{ row }">
  113. <el-tag v-if="row.status == '0'" type="failed">{{$t("developer.common.status.start")}}</el-tag>
  114. <el-tag v-if="row.status == '1'" type="success">{{$t("developer.common.status.end")}}</el-tag>
  115. </template>
  116. </el-table-column>
  117. <!-- 处理时间 -->
  118. <el-table-column prop="updateTime" :label='$t("developer.table.warnLong.chuliTime")' width="160px">
  119. <template slot-scope="{ row }">
  120. <span v-if="row.status == '1'">{{row.updateTime}}</span>
  121. </template>
  122. </el-table-column>
  123. <el-table-column
  124. :label="$t('table.operation')"
  125. fixed="right"
  126. align="center"
  127. column-key="operation"
  128. width="85px">
  129. <template slot-scope="{ row }">
  130. <el-tooltip class="item" content='分析处理' effect="dark" placement="top-start" v-if="row.taskNodeId || row.method!='GlobalException'">
  131. <i
  132. class="el-icon-bell table-operation"
  133. style="color: #87d068;"
  134. @click="view(row)"
  135. />
  136. </el-tooltip>
  137. </template>
  138. </el-table-column>
  139. </el-table>
  140. <pagination
  141. v-show="tableData.total > 0"
  142. :limit.sync="queryParams.size"
  143. :page.sync="queryParams.current"
  144. :total="Number(tableData.total)"
  145. @pagination="fetch"
  146. />
  147. <tenant-edit
  148. ref="edit"
  149. :dialog-visible="dialog.isVisible"
  150. :title="dialog.title"
  151. @close="editClose"
  152. @success="editSuccess"
  153. />
  154. <tenant-view
  155. ref="view"
  156. :dialog-visible="tenantViewVisible"
  157. @close="viewClose"
  158. />
  159. <el-dialog
  160. v-el-drag-dialog
  161. :close-on-click-modal="false"
  162. :close-on-press-escape="true"
  163. title="预览"
  164. width="100%"
  165. top="50px"
  166. customClass="customWidth"
  167. :visible.sync="preview.isVisible"
  168. >
  169. <el-scrollbar>
  170. <div v-html="preview.context" />
  171. </el-scrollbar>
  172. </el-dialog>
  173. </div>
  174. </template>
  175. <script>
  176. import Pagination from "@/components/Pagination"
  177. import TenantEdit from "./components/Edit"
  178. import TenantView from "./components/View"
  179. // 【锁定记录、出入库记录】-API
  180. //import lockingRecordApi from "@/api/lineSideLibrary/lockingRecord"
  181. import warnLogApi from "@/api/lineSideLibrary/warnLog"
  182. import elDragDialog from '@/directive/el-drag-dialog'
  183. import { convertEnum, initDicts, initQueryParams } from '@/utils/commons'
  184. export default {
  185. name: "InOutRecord",
  186. directives: { elDragDialog },
  187. components: { Pagination, TenantEdit, TenantView },
  188. props: {
  189. },
  190. data () {
  191. return {
  192. audioStatus: [],
  193. dialog: {
  194. isVisible: false,
  195. title: ""
  196. },
  197. preview: {
  198. isVisible: false,
  199. context: ''
  200. },
  201. tenantViewVisible: false,
  202. tableKey: 0,
  203. queryParams: initQueryParams({}),
  204. selection: [],
  205. loading: false,
  206. tableData: {
  207. total: 0
  208. },
  209. dicts: {
  210. NATION: {}
  211. },
  212. enums: {
  213. TenantTypeEnum: {},
  214. TenantStatusEnum: {}
  215. },
  216. pickerOptions: {
  217. shortcuts: [{
  218. text: '最近一周',
  219. onClick(picker) {
  220. const end = new Date();
  221. const start = new Date();
  222. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  223. picker.$emit('pick', [start, end]);
  224. }
  225. }, {
  226. text: '最近一个月',
  227. onClick(picker) {
  228. const end = new Date();
  229. const start = new Date();
  230. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  231. picker.$emit('pick', [start, end]);
  232. }
  233. }, {
  234. text: '最近三个月',
  235. onClick(picker) {
  236. const end = new Date();
  237. const start = new Date();
  238. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  239. picker.$emit('pick', [start, end]);
  240. }
  241. }]
  242. }
  243. }
  244. },
  245. // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
  246. created() {
  247. // 调用常量-审核状态
  248. this.audioStatus = this.$constWKS.OPTTYPE
  249. // 加载【字典】
  250. initDicts(['NATION'], this.dicts);
  251. // 加载列表数据
  252. this.fetch()
  253. },
  254. computed: {
  255. currentUser () {
  256. return this.$store.state.account.user
  257. },
  258. nationList() {
  259. return convertEnum(this.dicts.NATION)
  260. },
  261. websocketMsg() {
  262. return this.$store.getters.STAFF_UPDATE.msg
  263. },
  264. },
  265. watch: {
  266. websocketMsg(curVal, oldVal) {
  267. let obj = JSON.parse(curVal)
  268. this.openMessageTips(obj)
  269. }
  270. },
  271. mounted () {
  272. // 判断长连接,是否已经开启
  273. if(this.$store.state.websocket.websock == null){
  274. // 页面刚进入时开启长连接
  275. this.$store.dispatch('STAFF_WEBSOCKET')
  276. }
  277. },
  278. // 销毁
  279. destroyed() {
  280. this.websocketClose()
  281. },
  282. methods: {
  283. viewClose () {
  284. this.tenantViewVisible = false
  285. },
  286. editClose () {
  287. this.dialog.isVisible = false
  288. },
  289. editSuccess () {
  290. this.search()
  291. },
  292. onSelectChange (selection) {
  293. this.selection = selection
  294. },
  295. search () {
  296. this.fetch({
  297. ...this.queryParams
  298. })
  299. },
  300. reset () {
  301. this.queryParams = initQueryParams({})
  302. this.$refs.table.clearSort()
  303. this.$refs.table.clearFilter()
  304. this.search()
  305. },
  306. add () {
  307. this.$refs.edit.type = "add"
  308. this.$refs.edit.setTenant(false, this.dicts)
  309. this.dialog.title = this.$t("common.add")
  310. this.dialog.isVisible = true
  311. },
  312. singleDelete (row) {
  313. this.$refs.table.clearSelection()
  314. this.$refs.table.toggleRowSelection(row, true)
  315. this.batchDelete()
  316. },
  317. batchDelete () {
  318. if (!this.selection.length) {
  319. this.$message({
  320. message: this.$t("tips.noDataSelected"),
  321. type: "warning"
  322. })
  323. return
  324. }
  325. this.$confirm(this.$t("developer.tips.wareTips"), this.$t("common.tips"), {
  326. distinguishCancelAndClose: true,
  327. confirmButtonText: this.$t("common.confirm"),
  328. cancelButtonText: this.$t("common.cancel"),
  329. type: "warning"
  330. }).then(() => {
  331. const ids = []
  332. this.selection.forEach(item => {
  333. ids.push(item.id)
  334. })
  335. this.delete(ids)
  336. }).catch(() => {})
  337. },
  338. clearSelections () {
  339. this.$refs.table.clearSelection()
  340. },
  341. view(row){
  342. this.$refs.view.setTenant(row)
  343. this.tenantViewVisible = true
  344. },
  345. marking(){
  346. if (!this.selection.length) {
  347. this.$message({
  348. message: this.$t("tips.noDataSelected"),
  349. type: "warning"
  350. })
  351. return false
  352. }
  353. const ids = []
  354. this.selection.forEach(item => {
  355. ids.push(item.id)
  356. })
  357. this.updateStatus(ids)
  358. },
  359. updateStatus(ids){
  360. warnLogApi.updateStatus({ids: ids}).then(response => {
  361. const res = response.data
  362. if (res.isSuccess) {
  363. this.$message({
  364. message: '标注成功',
  365. type: "success"
  366. })
  367. this.search()
  368. }
  369. })
  370. },
  371. delete (ids) {
  372. warnLogApi.remove({ ids: ids }).then(response => {
  373. const res = response.data
  374. if (res.isSuccess) {
  375. this.$message({
  376. message: this.$t("tips.deleteSuccess"),
  377. type: "success"
  378. })
  379. this.search()
  380. // 清理已经删除的数据
  381. this.$refs.table.clearSelection()
  382. }
  383. })
  384. },
  385. // 【修改】表头上Btn-事件
  386. editOne() {
  387. if (!this.selection.length) {
  388. this.$message({
  389. message: this.$t("tips.noDataSelected"),
  390. type: "warning"
  391. })
  392. return
  393. }
  394. if (this.selection.length > 1) {
  395. this.$message({
  396. message: this.$t("tips.mustOne"),
  397. type: "warning"
  398. })
  399. return
  400. }
  401. this.edit(this.selection[0]);
  402. },
  403. edit (row) {
  404. this.$refs.edit.setTenant(row, this.dicts)
  405. this.$refs.edit.type = "edit"
  406. this.dialog.title = this.$t("common.edit")
  407. this.dialog.isVisible = true
  408. },
  409. fetch (params = {}) {
  410. this.loading = true
  411. if (this.queryParams.timeRange) {
  412. this.queryParams.map.createTime_st = this.queryParams.timeRange[0]
  413. this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]
  414. }
  415. let id = this.$route.query.id
  416. if(id!=null && id!=""){
  417. this.queryParams.model.id = id
  418. }
  419. this.queryParams.current = params.current ? params.current : this.queryParams.current
  420. this.queryParams.size = params.size ? params.size : this.queryParams.size
  421. // 固定参数:dataStatus = 1-入库/出库,2-解锁/锁定
  422. //this.queryParams.model.dataStatus = '1'
  423. warnLogApi.page(this.queryParams).then(response => {
  424. const res = response.data
  425. if (res.isSuccess) {
  426. this.tableData = res.data
  427. }
  428. // eslint-disable-next-line no-return-assign
  429. }).finally(() => this.loading = false)
  430. },
  431. cellClick (row, column) {
  432. if (column['columnKey'] === "operation") {
  433. return
  434. }
  435. let flag = false
  436. this.selection.forEach((item) => {
  437. if (item.id === row.id) {
  438. flag = true
  439. this.$refs.table.toggleRowSelection(row)
  440. }
  441. })
  442. if (!flag) {
  443. this.$refs.table.toggleRowSelection(row, true)
  444. }
  445. },
  446. openMessageTips(data){ //排除数字大屏
  447. if(this.$route.fullPath.indexOf("/largeScreen")<0){
  448. //console.log("接收websocket的推送信息 == ", data)
  449. if(data!=null && data.type == 'PUSH_TYPE_GLOBAL_EXCEPTION'){
  450. this.$nextTick(()=> {
  451. let datas = data.data.warnMap.warnData.records
  452. datas.forEach((data)=>{
  453. let msg = data.feedback ? data.feedback : " 响应超时 ";
  454. //let url = data.taskNodeId ? "#/dispatchMgr/exception":"#/developer/warnLong";
  455. let url = "#/developer/warnLong"
  456. let content = "<a href='"+url+"'>"+(data.resourceName? "["+ data.resourceName +"] " : "" )+(data.procedureName? data.procedureName : "")
  457. + (data.instructionName? "("+data.instructionName+")" : "") + msg+"</a>";
  458. this.$notification.error(content, { messageIsHTML: true, timer:10, title:"异常警报", showCloseIcn:true });
  459. })
  460. });
  461. }
  462. }
  463. },
  464. // 组件销毁的时候,关闭websocket连接
  465. websocketClose() {
  466. this.$store.getters.STAFF_UPDATE.lockReconnect = true
  467. this.$store.getters.STAFF_UPDATE.websock.close() // 离开路由之后断开websocket连接
  468. clearTimeout(this.$store.getters.STAFF_UPDATE.reconnectData) // 离开清除 timeout
  469. clearTimeout(this.$store.getters.STAFF_UPDATE.timeoutObj) // 离开清除 timeout
  470. clearTimeout(this.$store.getters.STAFF_UPDATE.serverTimeoutObj) // 离开清除 timeout
  471. },
  472. // websocket信息变更
  473. onmessage() {
  474. this.$store.getters.STAFF_UPDATE.websock.onmessage = function(evt) {
  475. console.log("websocket获取数据==="+evt)
  476. }
  477. }
  478. }
  479. }
  480. </script>
  481. <style lang="scss" scoped>
  482. </style>