You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

305 lines
8.1 KiB

<template>
<div class="container">
<div id="pwpg" class="pwpg" ref="pwpg"></div>
</div>
</template>
<script>
import container from "./comps/container";
import drawTitle from './comps/title'
import workers from "./comps/person";
import drawDw from './comps/dw'
import drawPgd from './comps/pgd'
import baifang from "./comps/baifang";
import {sljh} from "@/views/zyjhzx/lliaofkui/comps/sljh";
import {getPgd, getYcldw, shangLiao} from "@/api/zyjh";
10 months ago
import {getBzryList} from "@/api/sjzx/bzzGL";
export default {
name:'PWanFKui',
data(){
return {
title:'理 料 作 业 反 馈',
width:0,
height:0,
stage:null,
layer:null,
sljhItemList:[],
sljhGroup:null,
pgdGroup:null,
drawGd:null,
10 months ago
dw:[],
dwGroup:null,
10 months ago
pgd:[],
slGroup:null,
10 months ago
currentWorker:null,
setWorkers:null,
workers:null,
drawItem:null,
}
},
mounted() {
this.$socket.open()
this.wsSubscribe()
this.initKonvaStage();
},
created(){
window.addEventListener('resize', this.initKonvaStage)
},
sockets:{},
methods:{
wsSubscribe() {
this.sockets.subscribe('llComplete', data => {
if (this.currentDw && this.currentDw.id === data.dwId) {
if (this.slGroup) {
this.slGroup.destroyChildren()
}
this.dw[this.currentDwIndex].list.push(data)
this.drawBaiFang(this.dw[this.currentDwIndex].list)
} else {
this.dw[data.dwId].list.push(data)
}
this.initDw()
})
this.sockets.subscribe('zyjhzx', data => {
if (this.zt===data.zt){
const item=data.zyjh
let dwId=0
let dwCeng=0
for (const dw of this.dw) {
if(dw.tzbh===data.zyjh.kw){
dwId=dw.dwId
dwCeng=dw.list.length
}
}
const tmp={
ydjh:item,
dwId:dwId,
ceng:dwCeng+1,
czbh:item.dcCh,
pl:item.dcPl,
fd:item.dcFd,
kw:item.kw,
zl:item.zl,
tlth:item.tzbh,
wph:item.wpxh,
wpgg:item.wpgg,
sljhrq:item.sljhrq,
qgjhrq:item.qgjhrq,
bfr:data.zyjh.llry,
type:'LLJ'
}
shangLiao(tmp).then(res=>{})
}else{
this.$message.error(`工单号错误:${data.gdh}`)
}
})
},
initPgd(pgd={}){
const group=this.drawGd(pgd)
this.pgdGroup.add(group)
},
initDwInfo(index,dw){
if (this.slGroup){
this.slGroup.destroyChildren()
}
this.canSl=true
this.currentDw=dw
this.currentDwIndex=index
!!dw&&this.drawBaiFang(dw.list)
},
initBaiFang(){
const {slGroup,handler,bgGroup:slBgGroup}= baifang({width:this.width,height:this.height})
this.slGroup=slGroup
this.layer.add(slBgGroup)
this.drawBaiFang=handler
},
drawSljhItem(list){
if (this.sljhGroup){
this.sljhGroup.destroyChildren()
}
for (let i = 0; i < list.length; i++) {
const qyGroup=this.drawItem(i,list[i])
const _layer=this.layer
const _sljhGroup=this.sljhGroup;
let touchingFlag=false;
const that=this
qyGroup.on('click tap',function (){
that.initPgd(list[i])
})
qyGroup.on('mousedown touchstart',function ({evt}){
const worker=that.currentWorker;
if (!that.canSl||!worker){
return
}
const {clientX:x,clientY:y}=evt
touchingFlag=true;
const _that=this
setTimeout(()=>{
const movingFlag=_sljhGroup.isDragging()
if (!movingFlag){
if (touchingFlag){
_sljhGroup.draggable(false)
const tmpGroup=_that.clone();
tmpGroup.x(x-10)
tmpGroup.y(y-10)
_layer.add(tmpGroup)
tmpGroup.draggable(true)
tmpGroup.dragBoundFunc(function (pos){
return{...pos}
})
tmpGroup.startDrag()
_that.visible(false)
tmpGroup.on('dragend',function (){
const {x:thisX,y:thisY}=this.absolutePosition()
const {x,y}=that.slGroup.absolutePosition()
const maxX=x+that.width*0.4-20
const maxY=y+that.height*0.8-20
if(thisX>=x&&thisY>=y&&thisX<=maxX&&thisY<=maxY){
const item=this.getAttr('item')
const data={
ydjh:item,
dwId:that.currentDw.id,
ceng:that.dw[that.currentDwIndex].list.length+1,
czbh:item.dcCh,
pl:item.dcPl,
fd:item.dcFd,
kw:item.kw,
zl:item.zl,
tlth:item.tzbh,
wph:item.wpxh,
wpgg:item.wpgg,
sljhrq:item.sljhrq,
qgjhrq:item.qgjhrq,
bfr:that.currentWorker?.userCode,
type:'LLJ'
}
shangLiao(data).then(res=>{})
this.remove()
that.sljhItemList.splice(this.getAttr('index'),1)
that.sljhGroup.destroyChildren()
that.drawSljhItem(that.sljhItemList)
}else{
this.remove()
_that.visible(true)
}
_sljhGroup.draggable(true)
})
}
}
},500)
})
qyGroup.on('touchend',function (){
touchingFlag=false;
this.draggable(false)
_sljhGroup.draggable(true)
})
}
},
initDw(){
const that=this
getYcldw({type:'llj'}).then(res=>{
if(this.dwGroup){
this.dwGroup.destroyChildren()
}
const {container,dw}=drawDw(this.width,this.height,that.initDwInfo)
const {bgGroup,group}=container()
this.dwGroup=group
this.dw=res.data
this.layer.add(bgGroup)
10 months ago
for (let i=0;i<res.data.length;i++){
const item=res.data[i]
const dwGroup=dw(i,item)
group.add(dwGroup)
}
})
},
initWorkers(){
10 months ago
const that=this
getBzryList({resourcesCode:'4KB002'}).then(res=>{
const {container,person}=workers(this.width,this.height)
const {bgGroup,group}=container()
this.layer.add(bgGroup)
this.workers=res.data
that.setWorkers(res.data)
10 months ago
for (let i=0;i<res.data.length;i++){
const item=res.data[i]
const worker=person(i,item)
worker.on('click touchstart',function (){
that.currentWorker=item
getPgd({field:'llry',user:item.userCode,zt:'41'}).then(res=>{
that.sljhItemList=res.data
that.drawSljhItem(res.data)
})
})
group.add(worker)
worker.zIndex(1)
}
})
},
initKonvaStage(){
this.width=this.$refs.pwpg.clientWidth
this.height=this.$refs.pwpg.clientHeight
const {stage,layer}=container(this.width,this.height,'pwpg')
this.stage=stage
this.layer=layer
const titel=drawTitle(this.width,this.height,this.title)
this.layer.add(titel)
this.initWorkers()
this.initDw()
const {container:pgdContainer,drawGd,setWorkers}=drawPgd(this.width,this.height)
this.setWorkers=setWorkers
this.drawGd=drawGd
this.pgdGroup=pgdContainer()
this.layer.add(this.pgdGroup)
const {layer:sljhLayer,group:sljhGroup,drawItem}=sljh(this.width,this.height)
this.drawItem=drawItem
this.sljhGroup=sljhGroup
this.stage.add(sljhLayer)
this.initBaiFang()
},
}
}
</script>
<style>
#pwpgd {
width:55%;
height: auto;
position: absolute;
top:45px;
left:20px;
border: none;
margin: 0;
}
#pwpg {
overflow: hidden;
width: 100%;
height: 100vh;
aspect-ratio: 16/9;
}
.container{
background: #ddd;
}
</style>