Index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. <template>
  2. <div
  3. id="playerMap"
  4. ref="playerMap"
  5. class="app-container yunMapDiv"
  6. style="height: 200%"
  7. >
  8. <!-- 全屏 -->
  9. <el-row :gutter="20" class="rowCls">
  10. <div class="headerBg">
  11. <h2>现场工控端</h2>
  12. <div class="battonDiv">
  13. <el-tooltip
  14. v-if="!isFullSreen"
  15. class="item"
  16. effect="dark"
  17. :content="$t('largeScreen.common.screening')"
  18. placement="top-start"
  19. >
  20. <a @click="fullPing()"><i class="el-icon-full-screen"></i></a>
  21. </el-tooltip>
  22. <el-tooltip
  23. v-else
  24. class="item"
  25. effect="dark"
  26. :content="$t('largeScreen.common.cancel')"
  27. placement="top-start"
  28. >
  29. <a @click="exitFullPing()"><i class="el-icon-switch-button"></i></a>
  30. </el-tooltip>
  31. </div>
  32. </div>
  33. <!--
  34. <el-image
  35. style="width: 100%; height: 100%"
  36. :src="url"
  37. fit="fill"
  38. ></el-image> -->
  39. </el-row>
  40. <!-- 区域模块 -->
  41. <div style="text-align: left; margin-left: 5%">
  42. <!-- 搜索-部分 -->
  43. <div class="defaultRow noBorder">
  44. <el-select
  45. v-model="currentStationId"
  46. :span="2"
  47. @change="selectChange"
  48. :placeholder="$t('common.pleaseSelect')"
  49. >
  50. <el-option
  51. v-for="item in options"
  52. :key="item.id"
  53. :label="item.name"
  54. :value="item.id"
  55. >
  56. </el-option>
  57. </el-select>
  58. <span :span="2" style="margin-left: 2%">
  59. <el-button
  60. plain
  61. type="primary"
  62. icon="el-icon-view"
  63. size="medium"
  64. @click="readView"
  65. >
  66. 读RFID
  67. </el-button>
  68. </span>
  69. <span :span="2" style="margin-right: 5%; float: right">
  70. <el-button
  71. plain
  72. type="primary"
  73. icon="el-icon-view"
  74. size="medium"
  75. @click="navigator"
  76. >
  77. 我的班表
  78. </el-button>
  79. </span>
  80. </div>
  81. <el-tabs style="text-align: left; margin-top: 25px" @tab-click="tabClick">
  82. <el-tab-pane label="未完成">
  83. <span class="tabTitle" slot="label"
  84. ><el-badge :value="taskCount" class="badge"
  85. ><i class="el-icon-date"></i> 未完成</el-badge
  86. >
  87. </span>
  88. <el-col
  89. :span="index == 0 ? 12 : 8"
  90. :gutter="24"
  91. v-for="(item, index) in taskData.slice(0, 3)"
  92. :key="item.id"
  93. :offset="index == 0 ? 0 : 1"
  94. v-show="item.status < 3 ? true : false"
  95. :style="
  96. index == 0
  97. ? 'zoom:1;min-width:300px;'
  98. : 'zoom:0.6;min-width:180px;'
  99. "
  100. >
  101. <el-card :gutter="24" class="box-card" style="margin: 5px" >
  102. <div class="card_content" >
  103. <el-tag effect="dark" style="float:right;" v-if="item.deviceName" >{{ item.deviceName }}</el-tag>
  104. <div class="block card_header" @click="view(item)">
  105. <el-image
  106. style="
  107. width: 90px;
  108. height: 80px;
  109. max-width: 200%;
  110. max-height: 200%;
  111. "
  112. :src="resolveLogo('status' + (index + 1) + '.png')"
  113. fit="fill"
  114. >
  115. </el-image>
  116. <span style="text-align: center;"><h2>{{ item.name }}_{{ item.content }}</h2></span>
  117. <div class="itemNo" style="margin-top: 10px" >任务编号: {{ item.no }}</div>
  118. </div>
  119. <el-form style="margin-top: 10px">
  120. <el-form-item label="零件名称:">
  121. <span>{{ item.name }}</span>
  122. </el-form-item>
  123. <el-form-item label="零件系统码:" v-if="item.completeBatchNo">
  124. <span>{{ item.completeBatchNo }}</span>
  125. </el-form-item>
  126. <el-form-item label="工序号:">
  127. <span>{{ item.taskNo }}</span>
  128. </el-form-item>
  129. <el-form-item label="托盘编号:">
  130. <span>{{ item.clampNo }}</span>
  131. </el-form-item>
  132. <el-form-item label="额定时间:">
  133. <span>{{ item.time }}分钟</span>
  134. <!--<div class="timeprogress">
  135. <el-progress
  136. :text-inside="true"
  137. :stroke-width="15"
  138. :percentage="setPercentage(item.time, item.left)"
  139. color="#FF3366"
  140. :format="setItemText(item.time, item.left)"
  141. ></el-progress>
  142. </div>-->
  143. </el-form-item>
  144. <!-- <el-form-item>-->
  145. <!-- <span style="margin: 2% 0; float: right">-->
  146. <!-- <el-button-->
  147. <!-- plain-->
  148. <!-- type="primary"-->
  149. <!-- icon="el-icon-view"-->
  150. <!-- size="medium"-->
  151. <!-- :disabled="index == 0 ? false : true"-->
  152. <!-- @click.native="finishTask(item)"-->
  153. <!-- >-->
  154. <!-- 完成-->
  155. <!-- </el-button>-->
  156. <!-- </span>-->
  157. <!-- </el-form-item>-->
  158. </el-form>
  159. </div>
  160. </el-card>
  161. </el-col>
  162. </el-tab-pane>
  163. <el-tab-pane label="已完成">
  164. <span class="tabTitle" slot="label">
  165. <i class="el-icon-date"></i> 已完成
  166. </span>
  167. <div class="tableTransparent">
  168. <el-table
  169. style="height:100%;min-height:80px;"
  170. :header-cell-style="{ background: '#1890ff', color: '#fff' }"
  171. :key="tableKey"
  172. ref="table"
  173. v-loading="loading"
  174. :data="tableData.records"
  175. border
  176. fit
  177. row-key="id"
  178. >
  179. <el-table-column
  180. :label="$t('common.serialNo')"
  181. width="55px"
  182. align="center"
  183. >
  184. <template slot-scope="scope">
  185. <div>
  186. {{
  187. scope.$index +
  188. (queryParams.current - 1) * queryParams.size +
  189. 1
  190. }}
  191. </div>
  192. </template>
  193. </el-table-column>
  194. <el-table-column prop="name" label="零件名称" align="center">
  195. </el-table-column>
  196. <el-table-column prop="procedureNo" label="工序号" width="80" align="center">
  197. </el-table-column>
  198. <el-table-column prop="procedureName" label="工序名称" align="center">
  199. </el-table-column>
  200. <el-table-column prop="ratedWorkHours" label="额定时间" width="100" align="center">
  201. </el-table-column>
  202. <el-table-column prop="activeTime" label="实际时间" width="100" align="center">
  203. </el-table-column>
  204. <el-table-column prop="startTime" label="开始时间" width="150" align="center">
  205. </el-table-column>
  206. <el-table-column prop="endTime" label="结束时间" width="150" align="center">
  207. </el-table-column>
  208. <el-table-column prop="overTime" label="是否超时" width="100" align="center">
  209. <template slot-scope="{ row }">
  210. {{ row.overTime>0 ? "是" : "否" }}
  211. </template>
  212. </el-table-column>
  213. <el-table-column prop="preResourceName" label="前序加工设备" width="150" align="center">
  214. </el-table-column>
  215. </el-table>
  216. <pagination
  217. v-show="tableData.total > 0"
  218. :limit.sync="queryParams.size"
  219. :page.sync="queryParams.current"
  220. :total="Number(tableData.total)"
  221. @pagination="fetch"
  222. />
  223. </div>
  224. </el-tab-pane>
  225. </el-tabs>
  226. </div>
  227. <!-- 【查看】组件 -->
  228. <task-view
  229. ref="view"
  230. :dialog-visible="tenantViewVisible"
  231. @get-data="showRFID"
  232. @close="viewClose"
  233. />
  234. <!-- 【查看】组件 -->
  235. <task-view1
  236. ref="view1"
  237. :dialog-visible="view1Visible"
  238. @close="viewClose"
  239. @success="editSuccess"
  240. />
  241. <task-view2
  242. ref="view2"
  243. :dialog-visible="view2Visible"
  244. @close="viewClose"
  245. @success="editSuccess"
  246. />
  247. <!-- 【查看】组件 -->
  248. <task-view3
  249. ref="view3"
  250. :dialog-visible="view3Visible"
  251. @close="viewClose"
  252. @success="editSuccess"
  253. />
  254. <task-view4
  255. ref="view4"
  256. :dialog-visible="view4Visible"
  257. @close="viewClose"
  258. @success="editSuccess"
  259. />
  260. <task-view5
  261. ref="view5"
  262. :dialog-visible="view5Visible"
  263. @close="viewClose"
  264. @success="editSuccess"
  265. />
  266. <task-view6
  267. ref="view6"
  268. :dialog-visible="view6Visible"
  269. @close="viewClose"
  270. @success="editSuccess"
  271. />
  272. <task-view7
  273. ref="view7"
  274. :dialog-visible="view7Visible"
  275. @close="viewClose"
  276. @success="editSuccess"
  277. />
  278. </div>
  279. </template>
  280. <script>
  281. // 【查看】组件
  282. import TaskView from "./components/View";
  283. import TaskView1 from "./components/View1";
  284. import TaskView2 from "./components/View2";
  285. import TaskView3 from "./components/View3";
  286. import TaskView4 from "./components/View4";
  287. import TaskView5 from "./components/View5";
  288. import TaskView6 from "./components/View6";
  289. import TaskView7 from "./components/View7";
  290. import { fullScreen, exitFullScreen, initQueryParams } from "@/utils/commons";
  291. import stationMgrApi from "@/api/machiningClient/stationMgr";
  292. import taskMgrApi from "@/api/runManageCenter/taskMgr";
  293. import machiningClientApi from "@/api/machiningClient/machiningClient"
  294. import Pagination from "@/components/Pagination"
  295. export default {
  296. name: "TouchScreen",
  297. components: {Pagination, TaskView,TaskView1,TaskView2,TaskView3,TaskView4, TaskView5, TaskView6,TaskView7},
  298. props: {},
  299. data() {
  300. return {
  301. tableKey: 0,
  302. queryParams: initQueryParams({}),
  303. RFIDParams: {
  304. url: "192.168.11.130",
  305. port: "102",
  306. taskId: "",
  307. taskNodeId: "",
  308. data: {
  309. content: "",
  310. positionIndex: ""
  311. }
  312. },
  313. options: [
  314. ],
  315. currentStationId: "",
  316. currentStationName: "",
  317. taskCount: "",
  318. taskData: [
  319. ],
  320. current: 1,
  321. timer: null,
  322. confirmDisabled: true,
  323. tenantViewVisible: false,
  324. view1Visible: false,
  325. view2Visible: false,
  326. view3Visible: false,
  327. view4Visible: false,
  328. view5Visible: false,
  329. view6Visible: false,
  330. view7Visible: false,
  331. isFullSreen: false, // 默认不全屏
  332. loading: false,
  333. uniqueCode: "",
  334. tableData: {
  335. total: 0
  336. }
  337. };
  338. },
  339. // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
  340. created() {
  341. this.getStation();
  342. },
  343. watch: {
  344. 'taskData': {
  345. handler(val, oldVal) {
  346. // 加载列表数据
  347. //console.log(val[0])
  348. //console.log(oldVal[0])
  349. if(oldVal.length>0 && val.length>0 && val[0].id!=oldVal[0].id){
  350. window.location.reload()
  351. }
  352. },
  353. deep: true
  354. }
  355. },
  356. computed: {
  357. currentUser() {
  358. return this.$store.state.account.user;
  359. },
  360. },
  361. mounted() {
  362. //setInterval(this.getStation, 2000);
  363. this.timerTask()
  364. },
  365. methods: {
  366. tabClick(e){
  367. console.log("被选择的tab:", e.index)
  368. // 待执行-tab
  369. if(e.index == 0){
  370. //this.getStation()
  371. this.timerTask()
  372. }
  373. // 已完成-tab
  374. if(e.index == 1){
  375. this.clearTimer()
  376. this.fetch()
  377. }
  378. },
  379. // 全屏
  380. fullPing() {
  381. this.$nextTick(() => {
  382. // 显示【退出全屏】
  383. this.isFullSreen = true;
  384. // 如果是退出全屏
  385. let $playerMap = this.$refs.playerMap;
  386. if ($playerMap) {
  387. fullScreen($playerMap);
  388. }
  389. });
  390. },
  391. //定时器处理
  392. timerTask(){
  393. let that = this
  394. that.timer = setInterval(()=>{
  395. this.getStation();
  396. }, 10000)
  397. },
  398. clearTimer(){
  399. if(this.timer){
  400. clearInterval(this.timer)
  401. this.timer = null
  402. }
  403. },
  404. // 退出全屏
  405. exitFullPing() {
  406. this.$nextTick(() => {
  407. // 显示【全屏】
  408. this.isFullSreen = false;
  409. // 如果是全屏
  410. exitFullScreen(document.getElementById("playerMap"));
  411. });
  412. },
  413. selectChange(value) {
  414. console.log(value);
  415. },
  416. getStation() {
  417. stationMgrApi.getStation({ userId: this.$store.state.account.user.id })
  418. .then((res) => {
  419. res = res.data;
  420. if (res.isSuccess) {
  421. if (res.data.length > 0) {
  422. this.options = res.data;
  423. this.currentStationId = this.options[0].id
  424. this.currentStationName = this.options[0].name
  425. taskMgrApi.getStationTasks({ resourceId : this.currentStationId,type : "0" }).then((res) => {
  426. res = res.data;
  427. if (res.isSuccess) {
  428. // if (res.data.length > 0) {
  429. this.taskData = res.data;
  430. // }
  431. }
  432. });
  433. }
  434. }
  435. }).catch(()=>{ this.clearTimer()});
  436. },
  437. readView() {
  438. //this.tenantViewVisible = true
  439. //this.$refs.view2.read(null)
  440. let currentNode = this.taskData[0]
  441. this.RFIDParams.taskId = currentNode.id
  442. this.RFIDParams.taskNodeId = currentNode.taskNodeId
  443. this.RFIDParams.data.positionIndex = this.currentStationName.substr(-1)
  444. let that = this
  445. /*machiningClientApi.read(this.RFIDParams).then(res => {
  446. if(res.data.result!="false"){
  447. this.$message({
  448. message: "RFID: "+res.data.result,
  449. type: "success"
  450. })
  451. that.uniqueCode = res.data.result
  452. }else {
  453. this.$message({
  454. message: "获取RFID数据失败",
  455. type: "warning"
  456. })
  457. }
  458. });*/
  459. },
  460. showRFID(code) {
  461. console.log(code);
  462. },
  463. resolveLogo(logo) {
  464. return require(`@/assets/yunMap/${logo}`);
  465. },
  466. view (item) {
  467. // let that = this;
  468. // let current = that.options.filter(function (c, i, a) {
  469. // if (c.value == that.currentStationId) {
  470. // return c
  471. // }
  472. // })
  473. // item.procedurePosition = current[0].name;
  474. // 只有开始中的页面可以点击进入详情页面操作
  475. console.log("开始")
  476. item.currentStationName = this.currentStationName
  477. if(item.exeStatus === '2' && item.interfaceType === '04' && item.step=="1"){
  478. if(item.taskName == '上料' || item.nodeName == '上料' ){
  479. this.$refs.view1.setTenant(item)
  480. this.view1Visible = true
  481. }else if(item.taskName.indexOf('翻面')>-1){
  482. item.uniqueCode = this.uniqueCode
  483. this.$refs.view2.setTenant(item)
  484. this.view2Visible = true
  485. }else if(item.taskName.indexOf('下料')>-1){
  486. if(item.taskName.indexOf('OP')>-1 || item.taskName.indexOf('热处理')>-1){
  487. //工序下料
  488. item.uniqueCode = this.uniqueCode
  489. this.$refs.view6.setTenant(item)
  490. this.view6Visible = true
  491. }else{
  492. item.uniqueCode = this.uniqueCode
  493. this.$refs.view3.setTenant(item)
  494. this.view3Visible = true
  495. }
  496. }else if(item.taskName.indexOf('上料')>-1){
  497. //工序上料或热处理上料
  498. item.uniqueCode = this.uniqueCode
  499. this.$refs.view5.setTenant(item)
  500. this.view5Visible = true
  501. }
  502. }
  503. },
  504. viewClose() {
  505. this.view1Visible = false
  506. this.view2Visible = false
  507. this.view3Visible = false
  508. this.view4Visible = false
  509. this.view5Visible = false
  510. this.view6Visible = false
  511. this.view7Visible = false
  512. },
  513. editSuccess(){
  514. // this.getStation()
  515. // this.taskData.shift();
  516. console.log("init query task")
  517. this.$nextTick(() => {
  518. this.getStation()
  519. });
  520. },
  521. setPercentage(time, left) {
  522. return this.formatGap(time, left)[0] > 100
  523. ? 100
  524. : this.formatGap(time, left)[0];
  525. },
  526. // 设置进度文本内容
  527. setItemText(time, left) {
  528. return () => {
  529. return this.formatGap(time, left)[1];
  530. };
  531. },
  532. //时间差转换
  533. formatGap(time, left) {
  534. return [Number(parseInt((100 * left) / time)), "剩余" + left + "分钟"];
  535. },
  536. fetch(params = {}) {
  537. this.loading = true
  538. if (this.queryParams.timeRange) {
  539. this.queryParams.map.deliveryTime_st = this.queryParams.timeRange[0]
  540. this.queryParams.map.deliveryTime_ed = this.queryParams.timeRange[1]
  541. }
  542. this.queryParams.current = params.current ? params.current : this.queryParams.current
  543. this.queryParams.size = params.size ? params.size : this.queryParams.size
  544. console.log(this.$store.state.account.user.id)
  545. this.queryParams.model.updateUser = this.$store.state.account.user.id
  546. taskMgrApi.getFinishList(this.queryParams).then(response => {
  547. const res = response.data
  548. if (res.isSuccess) {
  549. this.tableData = res.data
  550. console.log(this.tableData)
  551. // 给列表设置条数
  552. this.$emit('setTabNums', res.data.total, 'tab2')
  553. }
  554. // eslint-disable-next-line no-return-assign
  555. }).finally(() => this.loading = false)
  556. },
  557. getFullTime(date) {
  558. var yy = date.getFullYear(); //年
  559. var mm = date.getMonth() + 1; //月
  560. var dd = date.getDate(); //日
  561. var hh = date.getHours(); //时
  562. var ii = date.getMinutes(); //分
  563. var ss = date.getSeconds(); //秒
  564. var clock = yy + "-";
  565. if (mm < 10) clock += "0";
  566. clock += mm + "-";
  567. if (dd < 10) clock += "0";
  568. clock += dd + " ";
  569. if (hh < 10) clock += "0";
  570. clock += hh + ":";
  571. if (ii < 10) clock += "0";
  572. clock += ii + ":";
  573. if (ss < 10) clock += "0";
  574. clock += ss;
  575. return clock;
  576. },
  577. navigator() {
  578. this.$store.dispatch('tagsView/delView', this.$route).then(res => {
  579. this.$router.push({ path: '/machiningClient/scheduleTask', query: {userId: this.$store.state.account.user.id}}) //带参跳转
  580. })
  581. },
  582. },
  583. };
  584. </script>
  585. <style lang="scss" scoped>
  586. .tabDiv {
  587. position: relative;
  588. overflow: hidden;
  589. width: 100%;
  590. height: 100%;
  591. .battonDiv {
  592. z-index: 9;
  593. }
  594. }
  595. .tabTitle {
  596. font-size: 24px;
  597. height: 24px;
  598. line-height: 24px;
  599. }
  600. .card_content {
  601. padding: 8px;
  602. width: 100%;
  603. text-align: left;
  604. color: #fff;
  605. }
  606. .card_header {
  607. position: relative;
  608. border-bottom: 1px solid #fff;
  609. margin: 10px 0;
  610. }
  611. .indexNo {
  612. position: absolute;
  613. top: 25%;
  614. left: 9%;
  615. font-size: 24px;
  616. line-height: 24px;
  617. height: 24px;
  618. color: #fff;
  619. z-index: 999;
  620. }
  621. .indexNo2 {
  622. position: absolute;
  623. top: 25%;
  624. left: 6%;
  625. font-size: 24px;
  626. line-height: 24px;
  627. height: 24px;
  628. color: #fff;
  629. z-index: 999;
  630. }
  631. .itemNo {
  632. font-size: 12px;
  633. line-height: 12px;
  634. height: 12px;
  635. text-align: right;
  636. color: #fff;
  637. margin-left: 20%;
  638. margin-bottom: 10px;
  639. }
  640. .timeprogress >>> .el-progress-bar__outer {
  641. background-color: #1890ff;
  642. }
  643. .timeprogress .el-progress-bar__inner {
  644. text-align: center;
  645. }
  646. .el-form-item >>> .el-form-item__label {
  647. color: #fff;
  648. }
  649. .el-form-item {
  650. margin-bottom: 0;
  651. }
  652. .tabTitle >>> .el-badge {
  653. position: relative;
  654. display: inline-block;
  655. vertical-align: baseline;
  656. }
  657. .badge {
  658. margin-top: 10px;
  659. margin-right: 20px;
  660. }
  661. .tableTransparent >>> .el-table,
  662. .el-table__expanded-cell {
  663. background-color: transparent;
  664. }
  665. </style>