Index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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. </el-row>
  34. <!-- 区域模块 -->
  35. <div style="text-align: left; margin-left: 5%">
  36. <!-- 搜索-部分 -->
  37. <div class="defaultRow noBorder">
  38. <span :span="2" style="margin-left: 2%; color:white;">
  39. 当前日期: {{currentDate}}
  40. </span>
  41. <span :span="2" style="margin-right: 5%; float: right">
  42. <el-button
  43. plain
  44. type="primary"
  45. icon="el-icon-view"
  46. size="medium"
  47. @click="navigator"
  48. >
  49. 我的任务
  50. </el-button>
  51. </span>
  52. </div>
  53. <el-tabs style="text-align: left; margin-top: 25px" @tab-click="tabClick">
  54. <el-tab-pane label="任务打卡">
  55. <span class="tabTitle" slot="label"
  56. ><el-badge :value="taskCount" class="badge"
  57. ><i class="el-icon-date"></i>任务打卡</el-badge
  58. >
  59. </span>
  60. <el-row :gutter="20" v-show="hasTask">
  61. <el-col :span="20">
  62. <div class="tag-group">
  63. <el-badge :value="assignTask.startTime?'完成':''" class="bItem">
  64. <el-tag
  65. size="medium"
  66. class="input-new-tag"
  67. effect="dark">
  68. 上班{{assignTask.planStartTime? assignTask.planStartTime.substring(0,5):''}}
  69. <span class="tagTip">{{assignTask.startTime? assignTask.startTime.substring(10)+'已打卡':''}}</span>
  70. </el-tag>
  71. </el-badge>
  72. <el-badge :value="assignTask.endTime?'完成':''" class="bItem">
  73. <el-tag
  74. size="medium"
  75. class="input-new-tag"
  76. :type = "assignTask.startTime?'':'info'"
  77. effect="dark">
  78. 下班{{assignTask.planEndTime? assignTask.planEndTime.substring(0,5):''}}
  79. <span class="tagTip">{{assignTask.endTime? assignTask.endTime.substring(10)+'已打卡':''}}</span>
  80. </el-tag>
  81. </el-badge>
  82. </div>
  83. </el-col>
  84. </el-row>
  85. <el-row :gutter="24" v-show="hasTask">
  86. <el-col :span="8" :offset="8">
  87. <div class="grid-content">
  88. <el-button type="success" class="large-round-button" circle @click="assign">
  89. {{assignTask.startTime?(assignTask.endTime?'':'下班打卡'):'上班打卡'}} {{currentTime}}
  90. </el-button>
  91. </div>
  92. </el-col>
  93. </el-row>
  94. </el-tab-pane>
  95. <el-tab-pane label="打卡记录">
  96. <span class="tabTitle" slot="label">
  97. <i class="el-icon-date"></i> 打卡记录
  98. </span>
  99. <div class="tableTransparent">
  100. <el-table
  101. style="height:100%;min-height:80px;"
  102. :header-cell-style="{ background: '#1890ff', color: '#fff' }"
  103. :key="tableKey"
  104. ref="table"
  105. v-loading="loading"
  106. :data="tableData.data"
  107. border
  108. fit
  109. row-key="id"
  110. >
  111. <el-table-column
  112. :label="$t('common.serialNo')"
  113. width="55px"
  114. align="center"
  115. >
  116. <template slot-scope="scope">
  117. <div>
  118. {{
  119. scope.$index +
  120. (queryParams.current - 1) * queryParams.size +
  121. 1
  122. }}
  123. </div>
  124. </template>
  125. </el-table-column>
  126. <el-table-column prop="date" label="打卡日期" align="center">
  127. </el-table-column>
  128. <el-table-column prop="planStartTime" label="计划上班时间" align="center">
  129. </el-table-column>
  130. <el-table-column prop="planEndTime" label="计划下班时间" align="center">
  131. </el-table-column>
  132. <el-table-column prop="startTime" label="上班开始时间" width="150" align="center">
  133. </el-table-column>
  134. <el-table-column prop="endTime" label="下班结束时间" width="150" align="center">
  135. </el-table-column>
  136. <el-table-column prop="overTime" label="打卡完成" width="100" align="center">
  137. <template slot-scope="{ row }">
  138. {{ row.startTime && row.endTime ? "是" : "否" }}
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. <pagination
  143. v-show="tableData.total > 0"
  144. :limit.sync="queryParams.size"
  145. :page.sync="queryParams.current"
  146. :total="Number(tableData.total)"
  147. @pagination="fetch"
  148. />
  149. </div>
  150. </el-tab-pane>
  151. </el-tabs>
  152. </div>
  153. </div>
  154. </template>
  155. <script>
  156. // 【查看】组件
  157. import { fullScreen, exitFullScreen, initQueryParams } from "@/utils/commons";
  158. import stationMgrApi from "@/api/machiningClient/stationMgr";
  159. import taskMgrApi from "@/api/runManageCenter/taskMgr";
  160. import machiningClientApi from "@/api/machiningClient/machiningClient"
  161. import Pagination from "@/components/Pagination"
  162. import moment from 'moment';
  163. export default {
  164. name: "TouchScreen",
  165. components: {Pagination},
  166. props: {},
  167. data() {
  168. return {
  169. tableKey: 0,
  170. queryParams: initQueryParams({}),
  171. elTags:[{"label":"上班", "type":""},{"label":"下班", "type":"info"}],
  172. currentTime: '',
  173. currentDate: '',
  174. hasTask: true,
  175. assignTask:{},
  176. options: [
  177. ],
  178. currentStationId: "",
  179. currentStationName: "",
  180. taskCount: "",
  181. taskData: [
  182. ],
  183. current: 1,
  184. timer: null,
  185. confirmDisabled: true,
  186. tenantViewVisible: false,
  187. isFullSreen: false, // 默认不全屏
  188. loading: false,
  189. uniqueCode: "",
  190. tableData: {
  191. total: 0
  192. }
  193. };
  194. },
  195. // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
  196. created() {
  197. this.currentDate = moment().format('YYYY-MM-DD');
  198. this.getCurrentSchedule();
  199. },
  200. watch: {
  201. 'taskData': {
  202. handler(val, oldVal) {
  203. // 加载列表数据
  204. //console.log(val[0])
  205. //console.log(oldVal[0])
  206. if(oldVal.length>0 && val.length>0 && val[0].id!=oldVal[0].id){
  207. window.location.reload()
  208. }
  209. },
  210. deep: true
  211. }
  212. },
  213. computed: {
  214. currentUser() {
  215. return this.$store.state.account.user;
  216. },
  217. },
  218. mounted() {
  219. //setInterval(this.getStation, 2000);
  220. this.timerTask()
  221. },
  222. methods: {
  223. tabClick(e){
  224. console.log("被选择的tab:", e.index)
  225. // 待执行-tab
  226. if(e.index == 0){
  227. //this.getStation()
  228. this.timerTask()
  229. }
  230. // 已完成-tab
  231. if(e.index == 1){
  232. this.clearTimer()
  233. this.fetch()
  234. }
  235. },
  236. // 全屏
  237. fullPing() {
  238. this.$nextTick(() => {
  239. // 显示【退出全屏】
  240. this.isFullSreen = true;
  241. // 如果是退出全屏
  242. let $playerMap = this.$refs.playerMap;
  243. if ($playerMap) {
  244. fullScreen($playerMap);
  245. }
  246. });
  247. },
  248. //定时器处理
  249. timerTask(){
  250. let that = this
  251. that.timer = setInterval(()=>{
  252. this.currentTime = new Date().toLocaleTimeString();
  253. }, 1000)
  254. },
  255. clearTimer(){
  256. if(this.timer){
  257. clearInterval(this.timer)
  258. this.timer = null
  259. }
  260. },
  261. // 退出全屏
  262. exitFullPing() {
  263. this.$nextTick(() => {
  264. // 显示【全屏】
  265. this.isFullSreen = false;
  266. // 如果是全屏
  267. exitFullScreen(document.getElementById("playerMap"));
  268. });
  269. },
  270. selectChange(value) {
  271. console.log(value);
  272. },
  273. assign(){
  274. let ret = this.assignTask.startTime && this.assignTask.endTime
  275. if(ret) {
  276. this.$message({
  277. message: "打卡已完成,请勿重复点击",
  278. type: 'warning'
  279. });
  280. return false
  281. }
  282. let onWork = this.assignTask.startTime? false:true
  283. stationMgrApi.updateSchedule({ id: this.assignTask.id, onWork: onWork })
  284. .then((res) => {
  285. res = res.data;
  286. if (res.isSuccess) {
  287. this.$message({
  288. message: "打卡成功",
  289. type: 'success'
  290. });
  291. this.getCurrentSchedule();
  292. }
  293. }).catch(()=>{ });
  294. },
  295. getCurrentSchedule() {
  296. stationMgrApi.getCurrentSchedule({ userId: this.$store.state.account.user.id, date: this.currentDate })
  297. .then((res) => {
  298. res = res.data;
  299. if (res.isSuccess) {
  300. console.log(res.data)
  301. this.assignTask = res.data
  302. }else{
  303. this.$message({
  304. message: "今天没有加工任务",
  305. type: 'warning'
  306. });
  307. this.hasTask = false
  308. this.clearTimer()
  309. }
  310. }).catch(()=>{ });
  311. },
  312. resolveLogo(logo) {
  313. return require(`@/assets/yunMap/${logo}`);
  314. },
  315. view (item) {
  316. // let that = this;
  317. // let current = that.options.filter(function (c, i, a) {
  318. // if (c.value == that.currentStationId) {
  319. // return c
  320. // }
  321. // })
  322. // item.procedurePosition = current[0].name;
  323. // 只有开始中的页面可以点击进入详情页面操作
  324. console.log("开始")
  325. item.currentStationName = this.currentStationName
  326. if(item.exeStatus === '2' && item.interfaceType === '04' && item.step=="1"){
  327. if(item.taskName == '上料' || item.nodeName == '上料' ){
  328. this.$refs.view1.setTenant(item)
  329. this.view1Visible = true
  330. }else if(item.taskName.indexOf('翻面')>-1){
  331. item.uniqueCode = this.uniqueCode
  332. this.$refs.view2.setTenant(item)
  333. this.view2Visible = true
  334. }else if(item.taskName.indexOf('下料')>-1){
  335. if(item.taskName.indexOf('OP')>-1 || item.taskName.indexOf('热处理')>-1){
  336. //工序下料
  337. item.uniqueCode = this.uniqueCode
  338. this.$refs.view6.setTenant(item)
  339. this.view6Visible = true
  340. }else{
  341. item.uniqueCode = this.uniqueCode
  342. this.$refs.view3.setTenant(item)
  343. this.view3Visible = true
  344. }
  345. }else if(item.taskName.indexOf('上料')>-1){
  346. //工序上料或热处理上料
  347. item.uniqueCode = this.uniqueCode
  348. this.$refs.view5.setTenant(item)
  349. this.view5Visible = true
  350. }
  351. }
  352. },
  353. viewClose() {
  354. this.view1Visible = false
  355. this.view2Visible = false
  356. this.view3Visible = false
  357. this.view4Visible = false
  358. this.view5Visible = false
  359. this.view6Visible = false
  360. this.view7Visible = false
  361. },
  362. editSuccess(){
  363. // this.getStation()
  364. // this.taskData.shift();
  365. console.log("init query task")
  366. this.$nextTick(() => {
  367. this.getStation()
  368. });
  369. },
  370. setPercentage(time, left) {
  371. return this.formatGap(time, left)[0] > 100
  372. ? 100
  373. : this.formatGap(time, left)[0];
  374. },
  375. // 设置进度文本内容
  376. setItemText(time, left) {
  377. return () => {
  378. return this.formatGap(time, left)[1];
  379. };
  380. },
  381. //时间差转换
  382. formatGap(time, left) {
  383. return [Number(parseInt((100 * left) / time)), "剩余" + left + "分钟"];
  384. },
  385. fetch(params = {}) {
  386. this.loading = true
  387. if (this.queryParams.timeRange) {
  388. this.queryParams.map.deliveryTime_st = this.queryParams.timeRange[0]
  389. this.queryParams.map.deliveryTime_ed = this.queryParams.timeRange[1]
  390. }
  391. this.queryParams.current = params.current ? params.current : this.queryParams.current
  392. this.queryParams.size = params.size ? params.size : this.queryParams.size
  393. console.log(this.$store.state.account.user.id)
  394. this.queryParams.model.userId = this.$store.state.account.user.id
  395. stationMgrApi.schedulePageList(this.queryParams).then(response => {
  396. const res = response.data
  397. if (res.isSuccess) {
  398. this.tableData = res.data
  399. console.log(this.tableData)
  400. // 给列表设置条数
  401. this.$emit('setTabNums', res.data.total, 'tab2')
  402. }
  403. // eslint-disable-next-line no-return-assign
  404. }).finally(() => this.loading = false)
  405. },
  406. getFullTime(date) {
  407. var yy = date.getFullYear(); //年
  408. var mm = date.getMonth() + 1; //月
  409. var dd = date.getDate(); //日
  410. var hh = date.getHours(); //时
  411. var ii = date.getMinutes(); //分
  412. var ss = date.getSeconds(); //秒
  413. var clock = yy + "-";
  414. if (mm < 10) clock += "0";
  415. clock += mm + "-";
  416. if (dd < 10) clock += "0";
  417. clock += dd + " ";
  418. if (hh < 10) clock += "0";
  419. clock += hh + ":";
  420. if (ii < 10) clock += "0";
  421. clock += ii + ":";
  422. if (ss < 10) clock += "0";
  423. clock += ss;
  424. return clock;
  425. },
  426. navigator() {
  427. this.$store.dispatch('tagsView/delView', this.$route).then(res => {
  428. this.$router.push({ path: '/machiningClient/touchScreen', query: {userId: this.$store.state.account.user.id}}) //带参跳转
  429. })
  430. },
  431. },
  432. };
  433. </script>
  434. <style lang="scss" scoped>
  435. .tabDiv {
  436. position: relative;
  437. overflow: hidden;
  438. width: 100%;
  439. height: 100%;
  440. .battonDiv {
  441. z-index: 9;
  442. }
  443. }
  444. .el-tag + .el-tag {
  445. margin-left: 20px;
  446. }
  447. .input-new-tag {
  448. width: 200px;
  449. margin-left: 10px;
  450. vertical-align: bottom;
  451. height: 50px;
  452. line-height: 50px;
  453. padding-top: 0;
  454. padding-bottom: 0;
  455. }
  456. .bItem {
  457. margin-top: 10px;
  458. margin-right: 40px;
  459. }
  460. .grid-content {
  461. margin-top:100px;
  462. }
  463. .large-round-button {
  464. width: 250px; /* 设置按钮的宽度 */
  465. height: 250px; /* 设置按钮的高度 */
  466. border-radius: 50%; /* 使按钮变成圆形 */
  467. background-color: #007BFF; /* 设置背景颜色 */
  468. color: white; /* 设置文字颜色 */
  469. border: none; /* 移除边框 */
  470. font-size: 24px; /* 设置文字大小 */
  471. cursor: pointer; /* 鼠标悬停时显示手指图标 */
  472. outline: none; /* 移除点击后的轮廓线 */
  473. }
  474. .tagTip{
  475. color:#444;
  476. font-size:8px;
  477. margin-left:15px;
  478. float:right;
  479. }
  480. .tabTitle {
  481. font-size: 24px;
  482. height: 24px;
  483. line-height: 24px;
  484. }
  485. .card_content {
  486. padding: 8px;
  487. width: 100%;
  488. text-align: left;
  489. color: #fff;
  490. }
  491. .card_header {
  492. position: relative;
  493. border-bottom: 1px solid #fff;
  494. margin: 10px 0;
  495. }
  496. .indexNo {
  497. position: absolute;
  498. top: 25%;
  499. left: 9%;
  500. font-size: 24px;
  501. line-height: 24px;
  502. height: 24px;
  503. color: #fff;
  504. z-index: 999;
  505. }
  506. .indexNo2 {
  507. position: absolute;
  508. top: 25%;
  509. left: 6%;
  510. font-size: 24px;
  511. line-height: 24px;
  512. height: 24px;
  513. color: #fff;
  514. z-index: 999;
  515. }
  516. .itemNo {
  517. font-size: 12px;
  518. line-height: 12px;
  519. height: 12px;
  520. text-align: right;
  521. color: #fff;
  522. margin-left: 20%;
  523. margin-bottom: 10px;
  524. }
  525. .timeprogress >>> .el-progress-bar__outer {
  526. background-color: #1890ff;
  527. }
  528. .timeprogress .el-progress-bar__inner {
  529. text-align: center;
  530. }
  531. .el-form-item >>> .el-form-item__label {
  532. color: #fff;
  533. }
  534. .el-form-item {
  535. margin-bottom: 0;
  536. }
  537. .tabTitle >>> .el-badge {
  538. position: relative;
  539. display: inline-block;
  540. vertical-align: baseline;
  541. }
  542. .badge {
  543. margin-top: 10px;
  544. margin-right: 20px;
  545. }
  546. .tableTransparent >>> .el-table,
  547. .el-table__expanded-cell {
  548. background-color: transparent;
  549. }
  550. </style>