Index.vue 16 KB

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