|
|
@ -47,19 +47,16 @@ |
|
|
|
<!-- 示例插件2 id=100--> |
|
|
|
<button class="bg-blue-500 py-2 px-5 rounded text-white" onclick="p100.show()">测试组建2</button> |
|
|
|
|
|
|
|
<div data-tname="分诊" data-pid="1402932548627206144" data-uid="1323567842540523520" data-rid="rid333" data-tid="tid444" data-did="did555" style="height:50px;width:100%"> |
|
|
|
<div data-tname="分诊" data-pid="1402932548627206144" data-uid="1323567842540523520" data-rid="rid333" data-tid="tid444" data-did="did555" data-pstart="1627560659000" data-rstart="1627564259000" style="height:50px;width:100%"> |
|
|
|
<!-- 任务开始插件 --> |
|
|
|
<div data-root="p1419895659787722752" class="flex flex-row items-center" style="height:100%;width:100%;"> |
|
|
|
<div class="flex-1 title"></div> |
|
|
|
<div class="flex flex-nowrap startBtn mr-2"> |
|
|
|
<button class="bg-green-500 text-xs rounded-full py-1 px-5 text-white" onclick="p1419895659787722752.chooseTime(this)">开始</button> |
|
|
|
<button class="bg-blue-500 text-xs rounded-full py-1 px-5 text-white" onclick="p1419895659787722752.show(this)">开始</button> |
|
|
|
</div> |
|
|
|
<div class="flex flex-nowrap statusBtn mr-2 font-bold" style="display:none" onclick="p1419895659787722752.jumpDetails(this)"> |
|
|
|
<span class="mr-3 startTime">10:02</span> |
|
|
|
<span class="text-red-500 disparity">+0min</span> |
|
|
|
</div> |
|
|
|
<div class="flex flex-row-reverse items-center" onclick="p1419895659787722752.jumpDetails(this)"> |
|
|
|
<img style="height:16px" src="https://www.tall.wiki/staticrec/photos/right.png"> |
|
|
|
<div class="flex flex-nowrap statusBtn mr-2 font-bold" style="display:none"> |
|
|
|
<span class="mr-3 startTime"></span> |
|
|
|
<span class="text-red-500 disparity"></span> |
|
|
|
</div> |
|
|
|
<div class="time-box w-screen h-screen fixed z-10" style="background: rgba(0,0,0,0.65);top:0;left:0;display:none"> |
|
|
|
<div class="flex flex-col h-2/6 absolute w-full" style="background:#fff;bottom: 0;"> |
|
|
@ -117,115 +114,25 @@ |
|
|
|
</div> |
|
|
|
|
|
|
|
<script> |
|
|
|
;(function() { |
|
|
|
const hourDom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.hour-box'); |
|
|
|
const minDom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.min-box'); |
|
|
|
const yearDom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.year-box'); |
|
|
|
const monthDom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.month-box'); |
|
|
|
const dateDom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.day-box'); |
|
|
|
/* 生成小时数组 */ |
|
|
|
for(let i=0;i<24;i++) { |
|
|
|
var div = document.createElement('div'); |
|
|
|
div.style.height = '26px'; |
|
|
|
div.innerHTML = i; |
|
|
|
hourDom.appendChild(div); |
|
|
|
} |
|
|
|
/* 生成分钟数组 */ |
|
|
|
for(let i=0;i<60;i++) { |
|
|
|
var div = document.createElement('div'); |
|
|
|
div.style.height = '26px'; |
|
|
|
div.innerHTML = i; |
|
|
|
minDom.appendChild(div); |
|
|
|
} |
|
|
|
|
|
|
|
/* 生成年数组 */ |
|
|
|
var my = new Date(); |
|
|
|
var endYear = my.getFullYear();// 获取当前年份 |
|
|
|
for (var i = endYear; i > 1899; i--) { |
|
|
|
var div = document.createElement('div'); |
|
|
|
div.style.height = '26px'; |
|
|
|
div.innerHTML = i; |
|
|
|
yearDom.appendChild(div); |
|
|
|
} |
|
|
|
/* 生成月数组 */ |
|
|
|
for (var i = 1; i < 13; i++) { |
|
|
|
var div = document.createElement('div'); |
|
|
|
div.style.height = '26px'; |
|
|
|
div.innerHTML = i; |
|
|
|
monthDom.appendChild(div); |
|
|
|
} |
|
|
|
/* 生成日数组 */ |
|
|
|
for (var i = 1; i < 32; i++) { |
|
|
|
var div = document.createElement('div'); |
|
|
|
div.style.height = '26px'; |
|
|
|
div.innerHTML = i; |
|
|
|
dateDom.appendChild(div); |
|
|
|
} |
|
|
|
})() |
|
|
|
|
|
|
|
const p1419895659787722752 = { |
|
|
|
token: '', |
|
|
|
dom: '', |
|
|
|
cancelTime() { |
|
|
|
var dom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.time-box'); |
|
|
|
dom.style.display = 'none' |
|
|
|
}, |
|
|
|
changeTime() { |
|
|
|
const hourDom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.hour-box'); |
|
|
|
const minDom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.min-box'); |
|
|
|
const yearDom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.year-box'); |
|
|
|
const monthDom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.month-box'); |
|
|
|
const dayDom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.day-box'); |
|
|
|
const year = 2021 - Math.round(yearDom.scrollTop / 26) |
|
|
|
let month = Math.round(monthDom.scrollTop / 26) + 1 |
|
|
|
let day = Math.round(dayDom.scrollTop / 26) + 1 |
|
|
|
if (month === 2) { |
|
|
|
if ( (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0 && year % 4000 !== 0) ) { |
|
|
|
if(day > 29) { |
|
|
|
day = 29 |
|
|
|
} |
|
|
|
} else { |
|
|
|
if(day > 28) { |
|
|
|
day = 28 |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (month === 2 || month === 4 || month === 6 || month === 9 || month === 11) { |
|
|
|
if(day > 30) { |
|
|
|
day = 30 |
|
|
|
} |
|
|
|
} else { |
|
|
|
if(day > 31) { |
|
|
|
day = 31 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
let hour = Math.round(hourDom.scrollTop / 26) |
|
|
|
let min = Math.round(minDom.scrollTop / 26) |
|
|
|
if(month<10) { |
|
|
|
month = '0' + month |
|
|
|
} |
|
|
|
if(day<10) { |
|
|
|
day = '0' + day |
|
|
|
} |
|
|
|
if(hour<10) { |
|
|
|
hour = '0' + hour |
|
|
|
} |
|
|
|
if(min<10) { |
|
|
|
min = '0' + min |
|
|
|
} |
|
|
|
console.log(`${year}年-${month}月-${day}日 ${hour}时:${min}分`) |
|
|
|
this.cancelTime() |
|
|
|
}, |
|
|
|
projectId: '', |
|
|
|
planStart: '', |
|
|
|
realStart: '', |
|
|
|
|
|
|
|
init() { |
|
|
|
this.dom = document.querySelector("div[data-root=p1419895659787722752]"); |
|
|
|
var domBox = this.dom.parentNode; |
|
|
|
var title = this.dom.querySelector('.title'); |
|
|
|
title.innerHTML = domBox.getAttribute('data-tname') |
|
|
|
this.planStart = domBox.getAttribute('data-pstart') |
|
|
|
this.realStart = domBox.getAttribute('data-rstart') |
|
|
|
this.setTimeData() |
|
|
|
|
|
|
|
console.log('初始化'); |
|
|
|
// 获取父元素携带的参数 |
|
|
|
var userId = domBox.getAttribute("data-uid"); |
|
|
|
this.projectId = domBox.getAttribute("data-pid"); |
|
|
|
// 初始化的时候 获取token |
|
|
|
this.getTokenByUserId(userId); |
|
|
|
}, |
|
|
@ -241,24 +148,39 @@ |
|
|
|
const { success, code, data, msg } = res; |
|
|
|
if (success && code === 200) { |
|
|
|
that.token = data.token; |
|
|
|
// 查询当前项目的最新消息 |
|
|
|
that.getFirstAidRecord() |
|
|
|
} else { |
|
|
|
alert(msg || '获取失败') |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 选择时间 添加 |
|
|
|
async show(){ |
|
|
|
var timeBox = this.dom.querySelector('.time-box'); |
|
|
|
timeBox.style.display = 'block' |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询到场人员信息 |
|
|
|
* 确定 批量提交急救信息 |
|
|
|
* @param { Array } codeAndAnswerList code和答案 |
|
|
|
* @param { String } projectId 项目ID |
|
|
|
* @param { Number } codeAndAnswerList 提交人类型(0平车 1人) |
|
|
|
*/ |
|
|
|
getFirstAidRecord() { |
|
|
|
var that = this |
|
|
|
choose(time){ |
|
|
|
const that = this; |
|
|
|
const params = JSON.stringify({ |
|
|
|
param: {} |
|
|
|
param: { |
|
|
|
codeAndAnswerList: [ |
|
|
|
{ |
|
|
|
answer: time, |
|
|
|
questionCode: 'FZSJ' |
|
|
|
} |
|
|
|
], |
|
|
|
projectId: that.projectId, |
|
|
|
userType: 0 |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
fetch('/getDate', { |
|
|
|
fetch('http://www.tall.wiki/gateway/qcp/v3.0/patient/aidRecord', { |
|
|
|
method: 'POST', |
|
|
|
body: params, |
|
|
|
headers: new Headers({ |
|
|
@ -268,38 +190,34 @@ |
|
|
|
return response.json(); |
|
|
|
}).catch(function(error){ |
|
|
|
console.error('Error:', error) |
|
|
|
// TODO: 测试数据 |
|
|
|
that.setDate() |
|
|
|
// TODO: |
|
|
|
}).then(function(res){ |
|
|
|
const { success, code, data, msg } = res; |
|
|
|
if (success && code === 200) { |
|
|
|
that.setDate(data) |
|
|
|
that.setDate() |
|
|
|
} else { |
|
|
|
alert(msg || '查询失败') |
|
|
|
alert(msg || '添加失败') |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 界面渲染 |
|
|
|
setDate(res) { |
|
|
|
setDate() { |
|
|
|
const { dom } = this; |
|
|
|
var startBtn = dom.querySelector('.startBtn'); |
|
|
|
var statusBtn = dom.querySelector('.statusBtn'); |
|
|
|
var startTime = dom.querySelector('.startTime'); |
|
|
|
var disparity = dom.querySelector('.disparity'); |
|
|
|
if(res.status === 0){ |
|
|
|
startBtn.style.display='block'; |
|
|
|
statusBtn.style.display='none'; |
|
|
|
}else if(res.status === 1){ |
|
|
|
startBtn.style.display='none'; |
|
|
|
statusBtn.style.display='block'; |
|
|
|
}else{ |
|
|
|
|
|
|
|
startBtn.style.display='none'; |
|
|
|
statusBtn.style.display='block'; |
|
|
|
} |
|
|
|
|
|
|
|
var ms = (+res.startTime) - (+res.planStartTime); //时间差的毫秒数 |
|
|
|
var ms = (+this.planStart) - (+this.realStart); //时间差的毫秒数 |
|
|
|
var morbidityTime = Math.ceil(ms/1000/60); |
|
|
|
disparity.innerHTML = morbidityTime + "min" |
|
|
|
startTime.innerHTML = this.setTime(res.startTime) |
|
|
|
startTime.innerHTML = this.setTime(this.realStart) |
|
|
|
if(morbidityTime >= 0){ |
|
|
|
disparity.className="text-red-500 disparity" |
|
|
|
}else{ |
|
|
@ -317,43 +235,114 @@ |
|
|
|
const minute = (time.getMinutes()).toString().padStart(2, '0') |
|
|
|
const second = (time.getSeconds()).toString().padStart(2, '0') |
|
|
|
|
|
|
|
return minute + ':' + second |
|
|
|
return hours + ':' + minute |
|
|
|
}, |
|
|
|
|
|
|
|
// 选择时间 添加 |
|
|
|
chooseTime(){ |
|
|
|
var dom = document.querySelector("div[data-root=p1419895659787722752]").querySelector('.time-box'); |
|
|
|
dom.style.display = 'block' |
|
|
|
var that = this |
|
|
|
const params = JSON.stringify({ |
|
|
|
param: {} |
|
|
|
}); |
|
|
|
fetch('/chooseTime', { |
|
|
|
method: 'POST', |
|
|
|
body: params, |
|
|
|
headers: new Headers({ |
|
|
|
'Authorization': 'Bearer ' + that.token ,'Content-Type': 'application/json;charset=utf-8' |
|
|
|
}) |
|
|
|
}).then(function(response) { |
|
|
|
return response.json(); |
|
|
|
}).catch(function(error){ |
|
|
|
console.error('Error:', error) |
|
|
|
}).then(function(res){ |
|
|
|
const { success, code, data, msg } = res; |
|
|
|
if (success && code === 200) { |
|
|
|
alert('添加成功') |
|
|
|
that.setDate(data) |
|
|
|
// 取消时间 |
|
|
|
cancelTime() { |
|
|
|
var timeBox = this.dom.querySelector('.time-box'); |
|
|
|
timeBox.style.display = 'none' |
|
|
|
}, |
|
|
|
|
|
|
|
// 确定时间 |
|
|
|
async changeTime() { |
|
|
|
const hourDom = this.dom.querySelector('.hour-box'); |
|
|
|
const minDom = this.dom.querySelector('.min-box'); |
|
|
|
const yearDom = this.dom.querySelector('.year-box'); |
|
|
|
const monthDom = this.dom.querySelector('.month-box'); |
|
|
|
const dayDom = this.dom.querySelector('.day-box'); |
|
|
|
const year = 2021 - Math.round(yearDom.scrollTop / 26) |
|
|
|
let month = Math.round(monthDom.scrollTop / 26) + 1 |
|
|
|
let day = Math.round(dayDom.scrollTop / 26) + 1 |
|
|
|
if (month === 2) { |
|
|
|
if ( (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0 && year % 4000 !== 0) ) { |
|
|
|
if(day > 29) { |
|
|
|
day = 29 |
|
|
|
} |
|
|
|
} else { |
|
|
|
alert(msg || '添加失败') |
|
|
|
if(day > 28) { |
|
|
|
day = 28 |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (month === 2 || month === 4 || month === 6 || month === 9 || month === 11) { |
|
|
|
if(day > 30) { |
|
|
|
day = 30 |
|
|
|
} |
|
|
|
} else { |
|
|
|
if(day > 31) { |
|
|
|
day = 31 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
let hour = Math.round(hourDom.scrollTop / 26) |
|
|
|
let min = Math.round(minDom.scrollTop / 26) |
|
|
|
if(month<10) { |
|
|
|
month = '0' + month |
|
|
|
} |
|
|
|
if(day<10) { |
|
|
|
day = '0' + day |
|
|
|
} |
|
|
|
if(hour<10) { |
|
|
|
hour = '0' + hour |
|
|
|
} |
|
|
|
if(min<10) { |
|
|
|
min = '0' + min |
|
|
|
} |
|
|
|
console.log(`${year}-${month}-${day} ${hour}:${min}`) |
|
|
|
const chooseTime = `${year}-${month}-${day} ${hour}:${min}` |
|
|
|
if(chooseTime){ |
|
|
|
await this.choose(new Date(chooseTime).getTime()) |
|
|
|
console.log('new Date(chooseTime).getTime(): ', new Date(chooseTime).getTime()); |
|
|
|
this.cancelTime() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 开始到场 |
|
|
|
jumpDetails(that) { |
|
|
|
console.log(that.parentNode.getAttribute('data-tname')) |
|
|
|
console.log(that.parentNode.getAttribute('data-pid')) |
|
|
|
location.href = 'https://www.baidu.com' |
|
|
|
// 设置时间数据 |
|
|
|
setTimeData(){ |
|
|
|
const hourDom = this.dom.querySelector('.hour-box'); |
|
|
|
const minDom = this.dom.querySelector('.min-box'); |
|
|
|
const yearDom = this.dom.querySelector('.year-box'); |
|
|
|
const monthDom = this.dom.querySelector('.month-box'); |
|
|
|
const dateDom = this.dom.querySelector('.day-box'); |
|
|
|
/* 生成小时数组 */ |
|
|
|
for(let i=0;i<24;i++) { |
|
|
|
var div = document.createElement('div'); |
|
|
|
div.style.height = '26px'; |
|
|
|
div.innerHTML = i; |
|
|
|
hourDom.appendChild(div); |
|
|
|
} |
|
|
|
/* 生成分钟数组 */ |
|
|
|
for(let i=0;i<60;i++) { |
|
|
|
var div = document.createElement('div'); |
|
|
|
div.style.height = '26px'; |
|
|
|
div.innerHTML = i; |
|
|
|
minDom.appendChild(div); |
|
|
|
} |
|
|
|
|
|
|
|
/* 生成年数组 */ |
|
|
|
var my = new Date(); |
|
|
|
var endYear = my.getFullYear();// 获取当前年份 |
|
|
|
for (var i = endYear; i > 1899; i--) { |
|
|
|
var div = document.createElement('div'); |
|
|
|
div.style.height = '26px'; |
|
|
|
div.innerHTML = i; |
|
|
|
yearDom.appendChild(div); |
|
|
|
} |
|
|
|
/* 生成月数组 */ |
|
|
|
for (var i = 1; i < 13; i++) { |
|
|
|
var div = document.createElement('div'); |
|
|
|
div.style.height = '26px'; |
|
|
|
div.innerHTML = i; |
|
|
|
monthDom.appendChild(div); |
|
|
|
} |
|
|
|
/* 生成日数组 */ |
|
|
|
for (var i = 1; i < 32; i++) { |
|
|
|
var div = document.createElement('div'); |
|
|
|
div.style.height = '26px'; |
|
|
|
div.innerHTML = i; |
|
|
|
dateDom.appendChild(div); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
p1419895659787722752.init() |
|
|
|