Browse Source

红头文件上传

ts-red-header-file
xuesinan 4 years ago
parent
commit
136d4f5540
  1. 80
      index.html

80
index.html

@ -63,8 +63,8 @@
</div>
<div class="mt-4 flex justify-between items-center w-full text-sm">
<button class="border border-blue-500 text-blue-500 rounded-sm" style="width: 45%; height: 34px;" onclick="p1472866674721169408.bigImg()">预览</button>
<div class="mt-4 flex justify-center items-center w-full text-sm">
<!-- <button class="border border-blue-500 text-blue-500 rounded-sm" style="width: 45%; height: 34px; margin-right: 10%;" onclick="p1472866674721169408.bigImg()">预览</button> -->
<button class="border border-blue-500 bg-blue-500 text-white rounded-sm" style="width: 45%; height: 34px;" onclick="p1472866674721169408.submit()">提交</button>
</div>
@ -302,11 +302,12 @@
html += `</div>`;
html += `</div>`;
} else if (data.type === 5) {
data.answer = '1';
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" data-id="${data.questionId}" value="1">`;
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 value="${data.optionList[j].submitValue}">${data.optionList[j].showValue} </option>`;
}
html += `</select>`;
html += `</div>`;
@ -338,25 +339,40 @@
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;
}
} else if (item.type === 4) {
if (item.questionId == id) {
item.optionList.forEach(v => {
if (v.submitValue === tar.value) {
v.choose = v.choose === 1 ? 0 : 1;
}
})
item.answer = '';
item.optionList.forEach(v => {
if (v.choose === 1) {
item.answer += ',' + v.submitValue;
}
})
}
} else if (item.type === 7) {
tar.addEventListener('change', function(event) {
var files = event.target.files;
var formData = new FormData();
formData.append('param', files[0]);
that.upload(formData, index);
if (files && files.length > 0) {
var formData = new FormData();
formData.append('param', files[0]);
that.upload(formData, index);
}
}, false);
}
});
console.log(arr);
},
// 预览
@ -368,20 +384,41 @@
let that = this;
console.log("that.tempData",that.tempData)
let questionList = [], arr = that.tempData;
if (!arr.length) {
alert("请选择红头文件模板");
return false;
}
arr.forEach(item => {
if (!item.answer) {
alert("请填写" + item.question);
return false;
}
})
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 = {};
let obj = { questionId: '', answerList: [] };
if (item.type === 1 || item.type === 2 || item.type === 3 || item.type === 6 || item.type === 7) {
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.answerList.push(item.answer);
} else if (item.type === 4) {
obj.questionId = item.questionId;
obj.answerList = item.answer;
item.optionList.forEach(v => {
if (v.choose === 1) {
obj.answerList.push(v.submitValue);
}
})
} else if (item.type === 5) {
obj.questionId = item.questionId;
obj.answerList.push(item.answer ? item.answer : 1);
}
questionList.push(obj);
})
console.log('questionList', questionList)
},
// 文件上传
@ -405,7 +442,6 @@
let fileName = that.dom.querySelector('.file-name');
fileName.innerHTML = data.name;
that.tempData[index].answer = data.path;
console.log("that.tempData", that.tempData)
} else {
console.log('msg: ', msg);
}

Loading…
Cancel
Save