|
|
@ -105,6 +105,13 @@ |
|
|
|
</div> --> |
|
|
|
|
|
|
|
<div class="formulate-plan"> |
|
|
|
<div class="status-box mb-2.5 px-2 py-1.5 w-full border border-gray-200 rounded-sm text-sm" style="display: none;"> |
|
|
|
<div class="flex justify-between items-center w-full" style="height: 20px;"> |
|
|
|
<p class="w-20 flex-shrink-0 text-gray-400">当前状态</p> |
|
|
|
<span>待审核</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="p-2 border border-gray-200 rounded-sm text-sm"> |
|
|
|
<div class="temp flex justify-between items-center w-full"> |
|
|
|
<p class="w-20 flex-shrink-0 text-gray-400">选择模板</p> |
|
|
@ -232,6 +239,8 @@ |
|
|
|
curIndex: 0, // 当前选择的模板 |
|
|
|
tempList: [{name: '模板1', organizer: '国家体育总局社会体育指导中心', title: ''}, {name: '模板2', organizer: '', title: ''}, {name: '模板3', organizer: '', title: ''}], |
|
|
|
tempData: {}, |
|
|
|
checkArr: [], |
|
|
|
templateId: 0, // 选中的模板id |
|
|
|
|
|
|
|
init() { |
|
|
|
this.dom = document.querySelector("div[data-root=p1449927427387301888]"); |
|
|
@ -258,9 +267,9 @@ |
|
|
|
if (success && code === 200) { |
|
|
|
that.token = data.token; |
|
|
|
// 查询培训计划 |
|
|
|
that.getTrainPlan() |
|
|
|
that.getTrainPlan(); |
|
|
|
// 查询所有模板 |
|
|
|
that.getAllTemp(); |
|
|
|
// that.getAllTemp(); |
|
|
|
} else { |
|
|
|
console.log('msg: ', msg); |
|
|
|
} |
|
|
@ -288,29 +297,17 @@ |
|
|
|
.then(function(res) { |
|
|
|
const { success, code, data, msg } = res; |
|
|
|
if (success && code === 200) { |
|
|
|
// if (!data) { |
|
|
|
// that.showOrHide(1, -1, 0, 0); |
|
|
|
// } else { |
|
|
|
// that.dom.querySelector('.train-name').value = data.name; |
|
|
|
// that.dom.querySelector('.train-desc').value = data.description; |
|
|
|
// let start = that.format(data.startTime); |
|
|
|
// that.dom.querySelector('.train-start-time').value = that.format(data.startTime); |
|
|
|
// that.dom.querySelector('.train-end-time').value = that.format(data.endTime); |
|
|
|
// that.fileId = data.fileId; |
|
|
|
// that.filePath = data.path; |
|
|
|
// that.dom.querySelector('.file-name').innerHTML = data.name; |
|
|
|
// console.log(data.startTime, start) |
|
|
|
|
|
|
|
// if (data && data.checkStatus === 0) { |
|
|
|
// that.showOrHide(1, 0, 1, 0); |
|
|
|
// } else if (data && data.checkStatus === 2) { |
|
|
|
// that.showOrHide(1, 2, 1, 1); |
|
|
|
// that.dom.querySelector('.reason').innerHTML = data.rejectCause; |
|
|
|
// } else { |
|
|
|
// that.showOrHide(2, 0, 0, 0); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// that.tempData = data; |
|
|
|
that.getAllTemp(); |
|
|
|
if (data) { |
|
|
|
if (data.checkStatus === 0) { |
|
|
|
that.dom.querySelector('.status-box').style.display = 'flex'; |
|
|
|
} |
|
|
|
|
|
|
|
that.templateId = data.templateId; |
|
|
|
that.tempData = data.trainingInfos; |
|
|
|
that.renderTempData(); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
console.log('msg: ', msg); |
|
|
|
} |
|
|
@ -365,6 +362,7 @@ |
|
|
|
} |
|
|
|
temps[index].classList.add("border-blue-400"); |
|
|
|
this.curIndex = index; |
|
|
|
this.templateId = obj.id; |
|
|
|
this.getTempData(obj.id); |
|
|
|
}, |
|
|
|
|
|
|
@ -403,12 +401,14 @@ |
|
|
|
// 渲染模板 |
|
|
|
renderTemp() { |
|
|
|
let that = this; |
|
|
|
// this.tempList |
|
|
|
|
|
|
|
let html = ''; |
|
|
|
|
|
|
|
for (let j = 0; j < that.tempList.length; j++) { |
|
|
|
html += `<div class="temp-item border border-gray-200 flex justify-center items-center ${j > 2 ? 'mt-2' : ''}" style="width: 30%; height: 100px; ${j % 3 == 2 ? '' : 'margin-right: 5%;'}" onclick="p1449927427387301888.selTemp(${j})"> |
|
|
|
if (that.tempList[j].id == that.templateId) { |
|
|
|
that.dom.querySelector('.sel-temp-name').innerHTML = that.tempList[j].name; |
|
|
|
} |
|
|
|
|
|
|
|
html += `<div class="temp-item border ${that.tempList[j].id == that.templateId ? 'border-blue-400' : 'border-gray-200'} flex justify-center items-center ${j > 2 ? 'mt-2' : ''}" style="width: 30%; height: 100px; ${j % 3 == 2 ? '' : 'margin-right: 5%;'}" onclick="p1449927427387301888.selTemp(${j})"> |
|
|
|
<img style="max-width: 100%; max-height: 100%;" src="${that.tempList[j].path}" /> |
|
|
|
</div>`; |
|
|
|
} |
|
|
@ -426,13 +426,13 @@ |
|
|
|
html += `<div class="ques-box mt-2.5 px-2 py-1.5 w-full border border-gray-200 rounded-sm text-sm" data-id="${data.questionId}"> |
|
|
|
<div class="flex justify-between items-center w-full" style="height: 20px;"> |
|
|
|
<p class="w-20 flex-shrink-0 text-gray-400">${data.question}</p> |
|
|
|
<input data-id="${data.questionId}" class="train-name text-right outline-none" style="width: calc(100% - 6rem)" type="text" placeholder="请输入${data.question}" /> |
|
|
|
<input data-id="${data.questionId}" class="train-name text-right outline-none" style="width: calc(100% - 6rem)" type="text" value="${!data.answer ? '' : data.answer}" placeholder="请输入${data.question}" /> |
|
|
|
</div> |
|
|
|
</div>`; |
|
|
|
} else if (data.type === 2) { |
|
|
|
html += `<div class="mt-2.5 px-2 py-1.5 flex justify-between w-full h-16 border border-gray-200 rounded-sm text-sm" data-id="${data.questionId}"> |
|
|
|
<p class="w-20 flex-shrink-0 text-gray-400">${data.question}</p> |
|
|
|
<textarea data-id="${data.questionId}" class="train-desc text-right outline-none" style="width: calc(100% - 6rem)" placeholder="请输入${data.question}"></textarea> |
|
|
|
<textarea data-id="${data.questionId}" class="train-desc text-right outline-none" style="width: calc(100% - 6rem)" value="${!data.answer ? '' : data.answer}" placeholder="请输入${data.question}"></textarea> |
|
|
|
</div>`; |
|
|
|
} else if (data.type === 3) { |
|
|
|
html += `<div class="mt-2.5 px-2 py-1.5 flex justify-between w-full border border-gray-200 rounded-sm text-sm" data-id="${data.questionId}">`; |
|
|
@ -456,9 +456,10 @@ |
|
|
|
} else if (data.type === 5) { |
|
|
|
html += `<div class="mt-2.5 px-2 py-1.5 flex justify-between w-full border border-gray-200 rounded-sm text-sm" data-id="${data.questionId}">`; |
|
|
|
html += `<p class="w-20 flex-shrink-0 text-gray-400">${data.question}</p>`; |
|
|
|
html += `<select id="group" value="1">`; |
|
|
|
html += `<select id="group" value="" data-id="${data.questionId}">`; |
|
|
|
html += `<option class="text-right" data-id="${data.questionId}" value="">请选择${data.question}</option>`; |
|
|
|
for (let j = 0; j < data.optionList.length; j++) { |
|
|
|
html += `<option data-id="${data.questionId}" value="${data.optionList[j].submitValue}">${data.optionList[j].showValue} </option>`; |
|
|
|
html += `<option class="text-right" data-id="${data.questionId}" value="${data.optionList[j].submitValue}">${data.optionList[j].showValue}</option>`; |
|
|
|
} |
|
|
|
html += `</select>`; |
|
|
|
html += `</div>`; |
|
|
@ -466,7 +467,7 @@ |
|
|
|
html += `<div class="mt-2.5 px-2 py-1.5 flex justify-between w-full border border-gray-200 rounded-sm text-sm" data-id="${data.questionId}"> |
|
|
|
<div class="flex justify-between items-center w-full" style="height: 20px;"> |
|
|
|
<p class="w-20 flex-shrink-0 text-gray-400">${data.question}</p> |
|
|
|
<input class="train-start-time text-right outline-none" data-id="${data.questionId}" type="date" placeholder="请选择${data.question}"> |
|
|
|
<input class="train-start-time text-right outline-none" data-id="${data.questionId}" type="date" value="${!data.answer ? '' : data.answer}" placeholder="请选择${data.question}"> |
|
|
|
</div> |
|
|
|
</div>`; |
|
|
|
} else if (data.type === 7) { |
|
|
@ -490,14 +491,26 @@ |
|
|
|
var tar = event.target || event.srcElement; |
|
|
|
let id = tar.getAttribute("data-id"); |
|
|
|
|
|
|
|
console.log("event", event, "tar", tar, "id", id) |
|
|
|
|
|
|
|
let arr = this.tempData; |
|
|
|
arr.forEach(function(item, index) { |
|
|
|
if (item.type === 1 || item.type === 2 || item.type === 3 || item.type === 6) { |
|
|
|
if (item.type === 1 || item.type === 2 || item.type === 3 || item.type === 5 || item.type === 6) { |
|
|
|
if (item.questionId == id) { |
|
|
|
item.answer = tar.value; |
|
|
|
item.answer = [tar.value]; |
|
|
|
} |
|
|
|
} else if (item.type === 4) { |
|
|
|
if (tar.checked) { |
|
|
|
that.checkArr.push(tar.value); |
|
|
|
} else { |
|
|
|
let currIndex = 0; |
|
|
|
for (let i = 0; i < that.checkArr.length; i++) { |
|
|
|
if (that.checkArr[i] == tar.value) { |
|
|
|
currIndex = i; |
|
|
|
} |
|
|
|
} |
|
|
|
that.checkArr.splice(currIndex, 1); |
|
|
|
} |
|
|
|
|
|
|
|
item.answer = that.checkArr; |
|
|
|
} else if (item.type === 7) { |
|
|
|
tar.addEventListener('change', function(event) { |
|
|
|
var files = event.target.files; |
|
|
@ -507,8 +520,6 @@ |
|
|
|
}, false); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
console.log(arr); |
|
|
|
}, |
|
|
|
|
|
|
|
// 预览 |
|
|
@ -517,24 +528,41 @@ |
|
|
|
}, |
|
|
|
|
|
|
|
submit() { |
|
|
|
// this.tempData |
|
|
|
let that = this; |
|
|
|
console.log("that.tempData",that.tempData) |
|
|
|
let questionList = [], arr = that.tempData; |
|
|
|
let questionList = []; |
|
|
|
let arr = this.tempData; |
|
|
|
arr.forEach(function(item, index) { |
|
|
|
console.log(item, index); |
|
|
|
if (item.type === 1 || item.type === 2) { |
|
|
|
item.answer = that.dom.querySelector('.ques-' + item.questionId).value; |
|
|
|
let obj = {}; |
|
|
|
obj.questionId = item.questionId; |
|
|
|
obj.answerList = item.answer; |
|
|
|
} else if (item.type === 3) { |
|
|
|
item.answer = that.dom.querySelector('.ques-' + item.questionId).value; |
|
|
|
let obj = {}; |
|
|
|
obj.questionId = item.questionId; |
|
|
|
obj.answerList = item.answer; |
|
|
|
} |
|
|
|
let obj = {}; |
|
|
|
obj.questionId = item.questionId; |
|
|
|
obj.answerList = item.answer; |
|
|
|
questionList.push(obj); |
|
|
|
}) |
|
|
|
|
|
|
|
fetch(`https://test.tall.wiki/gateway/sports/training/save`, { |
|
|
|
headers: new Headers({ |
|
|
|
'Authorization': 'Bearer ' + that.token, |
|
|
|
'Content-Type': 'application/json; charset=utf-8' |
|
|
|
}), |
|
|
|
method: 'POST', |
|
|
|
body: JSON.stringify({ |
|
|
|
param: { |
|
|
|
projectId: that.projectId, |
|
|
|
templateId: that.templateId, |
|
|
|
questionList: questionList |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then(function(response) { |
|
|
|
return response.json(); |
|
|
|
}) |
|
|
|
.then(function(res) { |
|
|
|
const { success, code, data, msg } = res; |
|
|
|
if (success && code === 200) { |
|
|
|
|
|
|
|
} else { |
|
|
|
console.log('msg: ', msg); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 文件上传 |
|
|
@ -557,8 +585,7 @@ |
|
|
|
that.filePath = data.path; |
|
|
|
let fileName = that.dom.querySelector('.file-name'); |
|
|
|
fileName.innerHTML = data.name; |
|
|
|
that.tempData[index].answer = data.path; |
|
|
|
console.log("that.tempData", that.tempData) |
|
|
|
that.tempData[index].answer = [data.path]; |
|
|
|
} else { |
|
|
|
console.log('msg: ', msg); |
|
|
|
} |
|
|
|