Files
zszq-trs/YLErpWeb/wwwroot/Scripts/app/trade/tradeObservationDates.js
T
2024-05-09 14:06:26 +08:00

940 lines
35 KiB
JavaScript

//定价格式化(来自配置)
const pricingFormat = otcformat.trading;
otcformat.options.disableGrouping = true;
//数字格式化
const consNumberFormat = Object.freeze(new function () {
this.umpriceP = pricingFormat.umpriceP;
this.umprice = pricingFormat.umprice;
this.premiumRateP = pricingFormat.premiumRateP;
return this;
}());
$(document).ready(function () {
otcformat.options.disableGrouping = true;
FastVue.numberInput(document.getElementById('ObservationNum'), { precision: 0 });
if (model.ShowDate2OffsetControl) {
FastVue.numberInput(document.getElementById('CouponDayInterval'), { precision: 0 });
}
//报送敲出观察频率 可以设置其他
let submission = model.ObservationFrequency;
if (submission != "" && submission != null && submission != "undefined") {
if (submission == "OTHER") {
$("#SelObservationUnit").val(submission);
$("#ObservationFrequency").val("").attr("readonly", "readonly");
}
else if (submission == "TERM") {
$("#SelObservationUnit").val(submission);
$("#ObservationFrequency").val("").attr("readonly", "readonly");
}
else {
if (model.TradeType == null || model.TradeType == "" || model.TradeType == "undefined") {
let isTerm = false;
if (model.ObservationDates == null || model.ObservationDates == "" || model.ObservationDates == "undefined") {
isTerm = true;
}
else {
let ODArray = model.ObservationDates.split(";");
if (ODArray.length >= 1) {
let odArray2 = ODArray[0].split(",");
if (odArray2.length == 1) {
isTerm = true;
}
}
}
if (isTerm) {
$("#SelObservationUnit").val("TERM");
$("#ObservationFrequency").val("").attr("readonly", "readonly");
} else {
let oNum = submission.replace("DAIL", "").replace("WEEK", "").replace("MNTH", "").replace("YEAR", "");
$("#ObservationFrequency").val(oNum);
let oUnit = submission.replace(oNum, "");
$("#SelObservationUnit").val(oUnit);
}
}
else {
let oNum = submission.replace("DAIL", "").replace("WEEK", "").replace("MNTH", "").replace("YEAR", "");
$("#ObservationFrequency").val(oNum);
let oUnit = submission.replace(oNum, "");
$("#SelObservationUnit").val(oUnit);
}
}
} else {
if (model.TradeType == null || model.TradeType == "" || model.TradeType == "undefined") {
$("#SelObservationUnit").val("TERM");
$("#ObservationFrequency").val("").attr("readonly", "readonly");
} else {
$("#ObservationFrequency").val($("#ObservationNum").val());
$("#SelObservationUnit").val(getObservationUnitStr($("#ObservationUnit").val()));
}
}
});
var vuedivItems = new Vue({
el: "#divItems",
data: {
observationDatesarr: [],
fieldList0: null, fieldList1: null, fieldList2: null, fieldList3: null,
dateTitle1: "", dateTitle2: "",
checkedall: true, lastDeleteCss: false, endDate: ""
},
created() {
model.ObservationDates = sessionStorage.getItem(model.BtnId + "_observationdates");
this.observationDates = model.ObservationDates;
this.dateTitle1 = model.DateTitle ? model.DateTitle : "日期";
this.dateTitle2 = model.Date2Title ? model.Date2Title : "日期";
this.endDate = GetDateOffset(model.endTime, 0);
this.getinitialfieldListdate();
if (this.fieldList0 != null && this.fieldList0[0] != 'null') {
if (!model.ShowCloseCheck) {
this.getTableArr(true);
} else {
this.getTableStringClose();
}
}
},
methods: {
getinitialfieldListdate: function () {
var fields = this.observationDates.split(';');
if (!model.ShowCloseCheck) {
this.fieldList0 = fields[0] ? fields[0].split(',') : null;
if (fields.length == 4 && model.isTitle2TrueFalse) {
this.fieldList1 = fields[1] ? fields[1].split(',') : null;
this.fieldList2 = fields[2] ? fields[2].split(',') : null;
this.fieldList3 = fields[3] ? fields[3].split(',') : null;
}
else if (fields.length == 4) {
this.fieldList3 = fields[1] ? fields[1].split(',') : null;
this.fieldList1 = fields[2] ? fields[2].split(',') : null;
this.fieldList2 = fields[3] ? fields[3].split(',') : null;
}
else {
this.fieldList1 = fields[1] ? fields[1].split(',') : null;
this.fieldList2 = fields[2] ? fields[2].split(',') : null;
}
} else {
this.fieldList0 = fields[0] ? fields[0].split(',') : null;
this.fieldList1 = fields[1] ? fields[1].split(',') : null;
this.fieldList2 = fields[2] ? fields[2].split(',') : null;//是否结算
}
},
getTableArr: function (init) {
var arrlist = [];
var fieldList0 = this.fieldList0;
var fieldList1 = this.fieldList1;
var fieldList2 = this.fieldList2;
var fieldList3 = this.fieldList3;
$.each(fieldList0, function (i) {
var arr = { field0: "", field1: "", field2: "", field3: "" };
if (this.length > 0) {
var m = new moment(fieldList0[i]);
if (!isNaN(m.date())) {
arr.field0 = m.format("YYYY-MM-DD");
}
}
if (model.ShowDate2) {
if (fieldList3 && fieldList3[i] && fieldList3[i].length > 0) {
var m = new moment(fieldList3[i]);
arr.field3 = m.format("YYYY-MM-DD");
} else {
var m = new moment(fieldList0[i]);
arr.field3 = m.format("YYYY-MM-DD");
}
}
if (model.Title1) {
let val = fieldList1 != null && (fieldList1[i] || model.TradeType == "凤凰期权" && init) ? fieldList1[i] : model.DefaultTitle1Value;
if (model.IsTitle1Percent) {
val = _.trim(val) && _.toString(val) ? parseFloat(consNumberFormat.umpriceP(val)) : "";
}
else {
val = _.trim(val) && _.toString(val) ? parseFloat(consNumberFormat.umprice(val)) : "";
}
arr.field1 = val;
}
if (model.Title2 && model.isTitle2TrueFalse) {
var val = fieldList2 != null && fieldList2[i] ? fieldList2[i] : model.DefaultTitle2Value;
if (!_.trim(val)) {
val = "false";
}
val = val.replace("True", "true").replace("False", "false");
arr.field2 = val
}
else if (model.Title2) {
let val = fieldList2 != null && fieldList2[i] ? fieldList2[i] : model.DefaultTitle2Value;
if (model.IsTitle2Percent) {
val = parseFloat(consNumberFormat.premiumRateP(val));
}
else {
val = parseFloat(val).toFixed(2);
}
arr.field2 = val
}
if (model.Title3) {
let val = fieldList3 != null && fieldList3[i] ? fieldList3[i] : model.DefaultTitle3Value;
if (!_.trim(val)) {
val = "";
} else {
if (model.IsTitle2Percent) {
val = parseFloat(consNumberFormat.premiumRateP(val));
}
else {
val = parseFloat(val).toFixed(2);
}
}
arr.field3 = val;
}
arrlist.push(arr);
});
this.observationDatesarr = arrlist;
},
getTableStringClose: function () {
var arrlist = [];
var fieldList0 = this.fieldList0;
var fieldList1 = this.fieldList1;
var fieldList2 = this.fieldList2;
var checkedall = this.checkedall;
if (fieldList2 && fieldList2.length > 0) {
var checkfirst = fieldList2[0];
var exerciseDate = this.endDate;
checkedall = checkfirst.indexOf('true') >= 0 ? true : false;
fieldList2.forEach(function (item, index) {
var date = fieldList0[index];
if (checkfirst != item && date != exerciseDate) {
checkedall = false;
}
})
this.checkedall = checkedall;
}
$.each(fieldList0, function (i) {
var arr = { field0: "", field1: "", field2: "" };
if (this.length > 0) {
var m = new moment(fieldList0[i]);
if (!isNaN(m.date())) {
arr.field0 = m.format("YYYY-MM-DD");
}
}
if (model.Title1) {
let val = fieldList1 != null && fieldList1[i] ? fieldList1[i] : model.DefaultTitle1Value;
if (model.IsTitle1Percent) {
val = _.toString(val) ? parseFloat(consNumberFormat.umpriceP(val)) : "";
}
else {
val = _.toString(val) ? parseFloat(consNumberFormat.umprice(val)) : "";
}
arr.field1 = val;
}
if (fieldList2 && fieldList2[i]) {
arr.field2 = fieldList2[i].trim() == "true" ? true : false;
} else {
arr.field2 = true;
}
arrlist.push(arr);
});
this.observationDatesarr = arrlist;
this.lastDeleteChecked();
},
deleteobservationDatesarr: function (item) {
var arrRemoveJson = function (arr, attr, value) {
if (!arr || arr.length == 0) {
return ""
}
let newArr = arr.filter(function (item, index) {
return item[attr] != value
})
return newArr
}
this.observationDatesarr = arrRemoveJson(this.observationDatesarr, 'field0', item.field0);
//互换,生成只有1个日期时,报送设置为到期支付
if (model.TradeType == null || model.TradeType == "" || model.TradeType == "undefined") {
if ($("#divItems").find("li").length == 1) {
$("#SelObservationUnit").val("TERM");
$("#ObservationFrequency").val("").attr("readonly", "readonly");
}
}
if (model.ShowCloseCheck) {
this.lastDeleteChecked();
}
},
checkedAll: function () {
var checkedAll = $('#checkAllclose').is(':checked');
var checkcloseArr = $("[name='checkclose']:not(:disabled)");
checkcloseArr.each(function () {
$(this).prop("checked", checkedAll)
});
},
checkedItem: function () {
var checkcloseArr = $("[name='checkclose']:not(:disabled)");
var flag = true;
checkcloseArr.each(function () {
if (!$(this).prop("checked")) {
flag = false;
return;
}
});
$('#checkAllclose').prop("checked", flag);
},
lastDeleteChecked: function () {
if (model.ShowCloseCheck) {
var lastindex = this.fieldList0.length - 1;
var lastDate = GetDateOffset(this.fieldList0[lastindex], 0);
if (lastDate == this.endDate) {
this.observationDatesarr[lastindex].field2 = false;
this.lastDeleteCss = true;
}
}
}
},
components: {}
});
function GetDateOffset(dateStr, interval) {
var date = new Date(dateStr);
var num = parseInt(interval);
date = new Date(date.setDate(date.getDate() + num));
return new moment(date).format("YYYY-MM-DD");
}
function addnewitem() {
var arr = { field0: "", field1: "", field2: "", field3: "" };
if (model.Title2 && model.isTitle2TrueFalse) {
arr.field2 = 'false';
}
if (model.ShowCloseCheck) {
arr.field2 = true;
}
vuedivItems.observationDatesarr.push(arr);
}
function Confirm() {
var observationNum = $("#ObservationNum").val();
var observationUnit = $("#ObservationUnit").val();
var observationHolidayType = $("#ObservationHolidayType").val();
var field1 = $(".field1");
var arr1 = [];
var hasTimeError = false;
field1.each(function () {
var dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
if (dateFormat.test($(this).val())) {
arr1.push($(this).val());
}
else {
hasTimeError = true;
}
});
if (hasTimeError) {
alert("日期格式有误,请输入正确格式");
return false;
}
var observationDates = arr1.join(',');
//互换,生成只有1个日期时,报送设置为到期支付
var sw_IsTrem = false;
if (model.TradeType == null || model.TradeType == "" || model.TradeType == "undefined") {
if (observationDates.split(",").length == 1 && $("#SelObservationUnit").val() != "TERM") {
sw_IsTrem = true;
}
}
if (model.ShowDate2) {
var field4 = $(".field4");
var arr4 = [];
var hasTimeError = false;
field4.each(function () {
var dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
if (dateFormat.test($(this).val())) {
arr4.push($(this).val());
}
else {
hasTimeError = true;
}
});
if (hasTimeError) {
alert("日期格式有误,请输入正确格式");
return false;
}
if (arr4 && arr4.length > 0) {
observationDates += ";" + arr4.join(',');
}
}
var hasNumberError = 0;
if (model.Title1) {
var field2 = $(".field2");
var arr2 = [];
field2.each(function () {
var dateFormat = /^(-?\d+)(\.\d+)?$/;
if (dateFormat.test($(this).val())) {
if (model.IsTitle1Percent) {
arr2.push(($(this).val() / 100).toFixed(6));
}
else {
arr2.push($(this).val());
}
} else if (model.DefaultTitle1Value == null) {
arr2.push($(this).val());
}
else {
arr2.push('');
if (model.TradeType != "凤凰期权") { hasNumberError = 1; }
//hasNumberError = 1;
}
});
if (arr2 && arr2.length > 0) {
if (model.TradeType == "凤凰期权" && !_.toString(arr2[arr2.length - 1])) {
alert("请填入最后一个观察日的障碍价格!");
return false;
}
observationDates += ";" + arr2.join(',');
}
}
if (model.Title2) {
var field3 = $(".field3");
var arr3 = [];
field3.each(function () {
var dateFormat = /^(-?\d+)(\.\d+)?$/;
if (dateFormat.test($(this).val())) {
if (model.IsTitle2Percent) {
arr3.push(($(this).val() / 100).toFixed(6));
}
else {
arr3.push($(this).val());
}
}
else if (model.isTitle2TrueFalse) {
arr3.push($(this).find("option:selected").val());
}
else if (model.DefaultTitle2Value == null) {
arr3.push($(this).val());
}
else {
hasNumberError = 2;
}
});
if (arr3 && arr3.length > 0) {
observationDates += ";" + arr3.join(',');
}
}
if (model.Title3) {
var field4 = $(".field4");
var arr4 = [];
field4.each(function () {
var dateFormat = /^(-?\d+)(\.\d+)?$/;
if (dateFormat.test($(this).val())) {
if (model.IsTitle3Percent) {
arr4.push(($(this).val() / 100).toFixed(6));
}
else {
arr4.push($(this).val());
}
}
else if (model.DefaultTitle3Value == null) {
arr4.push($(this).val());
}
else {
hasNumberError = 2;
}
});
if (arr4 && arr4.length > 0) {
observationDates += ";" + arr4.join(',');
}
}
if (model.ShowCloseCheck) {
vuedivItems.lastDeleteChecked();
var field5 = $(".field5");
var arr5 = [];
field5.each(function () {
arr5.push($(this).prop("checked"));
});
if (arr5 && arr5.length > 0) {
observationDates += ";" + arr5.join(',');
}
}
if (hasNumberError && (model.TradeType !== "累计期权" || hasNumberError !== 1)) {
alert("请输入正确的数字格式");
return false;
}
var alignEnd = $("#AlignEnd").val();
var btnId = $("#btnId").val();
var couponDayInterval = $("#CouponDayInterval").val();
var Comments = $("#Comments").val();
var ObservationFrequency = $("#ObservationFrequency").val();
var ObservationUnit = $("#SelObservationUnit").val();
if (ObservationUnit == "OTHER") {
ObservationFrequency = ObservationUnit;
}
else if (ObservationUnit == "TERM") {
ObservationFrequency = ObservationUnit;
}
else {
if (sw_IsTrem) {
ObservationFrequency = "TERM";
} else {
ObservationFrequency += ObservationUnit;
}
}
window.parent.getObservationDatesSetting(observationNum, observationUnit, observationHolidayType, observationDates, alignEnd, btnId, couponDayInterval, Comments, ObservationFrequency);
closeParentWindow();
}
function GetObservationDatesText() {
var field1 = $(".field1");
var arr1 = [];
var hasTimeError = false;
field1.each(function () {
var dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
if (dateFormat.test($(this).val())) {
arr1.push($(this).val());
}
else {
hasTimeError = true;
}
});
if (hasTimeError) {
alert("日期格式有误,请输入正确格式");
return false;
}
var observationDates = arr1.join(',');
if (model.ShowDate2) {
var field4 = $(".field4");
var arr4 = [];
var hasTimeError = false;
field4.each(function () {
var dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
if (dateFormat.test($(this).val())) {
arr4.push($(this).val());
}
else {
hasTimeError = true;
}
});
if (hasTimeError) {
alert("日期格式有误,请输入正确格式");
return false;
}
if (arr4 && arr4.length > 0) {
observationDates += ";" + arr4.join(',');
}
}
var hasNumberError = false;
if (model.Title1) {
var field2 = $(".field2");
var arr2 = [];
field2.each(function () {
var dateFormat = /^(-?\d+)(\.\d+)?$/;
if (dateFormat.test($(this).val())) {
if (model.IsTitle1Percent) {
arr2.push(($(this).val() / 100).toFixed(6));
}
else {
arr2.push($(this).val());
}
}
else if (model.DefaultTitle1Value == null) {
arr2.push($(this).val());
}
else {
hasNumberError = true;
}
});
if (arr2 && arr2.length > 0) {
observationDates += ";" + arr2.join(',');
}
}
if (model.Title2) {
var field3 = $(".field3");
var arr3 = [];
field3.each(function () {
var dateFormat = /^(-?\d+)(\.\d+)?$/;
if (dateFormat.test($(this).val())) {
if (model.IsTitle2Percent) {
arr3.push(($(this).val() / 100).toFixed(6));
}
else {
arr3.push($(this).val());
}
}
else if (model.isTitle2TrueFalse) {
arr3.push($(this).find("option:selected").val());
}
else if (model.DefaultTitle2Value == null) {
arr3.push($(this).val());
}
else {
hasNumberError = true;
}
});
if (arr3 && arr3.length > 0) {
observationDates += ";" + arr3.join(',');
}
}
if (model.Title3) {
var field4 = $(".field4");
var arr4 = [];
field4.each(function () {
var dateFormat = /^(-?\d+)(\.\d+)?$/;
if (dateFormat.test($(this).val())) {
if (model.IsTitle2Percent) {
arr4.push(($(this).val() / 100).toFixed(6));
}
else {
arr4.push($(this).val());
}
}
else if (model.DefaultTitle3Value == null) {
arr4.push($(this).val());
}
else {
hasNumberError = true;
}
});
if (arr4 && arr4.length > 0) {
observationDates += ";" + arr4.join(',');
}
}
if (model.ShowCloseCheck) {
var field5 = $(".field5");
var arr5 = [];
field5.each(function () {
arr5.push($(this).prop("checked"));
});
if (arr5 && arr5.length > 0) {
observationDates += ";" + arr5.join(',');
}
}
if (hasNumberError) {
alert("请输入正确的数字格式");
return false;
}
}
function closeParentWindow() {
try { window.parent.layer.closeAll(); } catch (e) { }
}
function SetObservationDates() {
var field1 = $(".field1");
var arr1 = [];
var hasTimeError = false;
field1.each(function () {
var dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
if (dateFormat.test($(this).val())) {
arr1.push($(this).val());
}
else {
hasTimeError = true;
}
});
if (arr1.length > 0) {
var observationDates = arr1.join(";\n") + ";";
if (model.ShowDate2) {
var field4 = $(".field4");
var arr4 = [];
field4.each(function () {
var dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
if (dateFormat.test($(this).val())) {
arr4.push($(this).val());
}
else {
hasTimeError = true;
}
});
if (arr4 && arr4.length > 0) {
var curIndex = 0;
arr4.forEach(function (curValue) {
var index = observationDates.indexOf(";", curIndex);
observationDates = observationDates.slice(0, index) + ", " + curValue + observationDates.slice(index);
curIndex = observationDates.indexOf(";", curIndex) + 2;
});
}
}
if (hasTimeError) {
alert("日期格式有误,请输入正确格式");
return false;
}
var hasNumberError = false;
if (model.Title1) {
var field2 = $(".field2");
var arr2 = [];
field2.each(function () {
var dateFormat = /^(-?\d+)(\.\d+)?$/;
if (dateFormat.test($(this).val())) {
if (model.IsTitle1Percent) {
arr2.push(($(this).val() / 100).toFixed(6));
}
else {
arr2.push($(this).val());
}
}
else if (model.DefaultTitle1Value == null) {
arr2.push($(this).val());
}
else {
arr2.push($(this).val());
//hasNumberError = true;
}
});
if (arr2 && arr2.length > 0) {
var curIndex = 0;
arr2.forEach(function (curValue) {
var index = observationDates.indexOf(";", curIndex);
observationDates = observationDates.slice(0, index) + ", " + curValue + observationDates.slice(index);
curIndex = observationDates.indexOf(";", curIndex) + 2;
});
}
}
if (model.Title2) {
var field3 = $(".field3");
var arr3 = [];
field3.each(function () {
var dateFormat = /^(-?\d+)(\.\d+)?$/;
if (dateFormat.test($(this).val())) {
if (model.IsTitle2Percent) {
arr3.push(($(this).val() / 100).toFixed(6));
}
else {
arr3.push($(this).val());
}
}
else if (model.isTitle2TrueFalse) {
arr3.push($(this).find("option:selected").text());
}
else if (model.DefaultTitle2Value == null) {
arr3.push($(this).val());
}
else {
hasNumberError = true;
}
});
if (arr3 && arr3.length > 0) {
var curIndex = 0;
arr3.forEach(function (curValue) {
var index = observationDates.indexOf(";", curIndex);
observationDates = observationDates.slice(0, index) + ", " + curValue + observationDates.slice(index);
curIndex = observationDates.indexOf(";", curIndex) + 2;
});
}
}
if (model.Title3) {
var field4 = $(".field4");
var arr4 = [];
field4.each(function () {
var dateFormat = /^(-?\d+)(\.\d+)?$/;
if (dateFormat.test($(this).val())) {
if (model.IsTitle2Percent) {
arr4.push(($(this).val() / 100).toFixed(6));
}
else {
arr4.push($(this).val());
}
}
else if (model.DefaultTitle3Value == null) {
arr4.push($(this).val());
}
else {
hasNumberError = true;
}
});
if (arr4 && arr4.length > 0) {
var curIndex = 0;
arr4.forEach(function (curValue) {
var index = observationDates.indexOf(";", curIndex);
observationDates = observationDates.slice(0, index) + ", " + curValue + observationDates.slice(index);
curIndex = observationDates.indexOf(";", curIndex) + 2;
});
}
}
if (model.ShowCloseCheck) {
var field5 = $(".field5");
var arr5 = [];
field5.each(function () {
arr5.push($(this).prop("checked"));
});
if (arr5 && arr5.length > 0) {
var curIndex = 0;
arr5.forEach(function (curValue) {
var index = observationDates.indexOf(";", curIndex);
observationDates = observationDates.slice(0, index) + ", " + curValue + observationDates.slice(index);
curIndex = observationDates.indexOf(";", curIndex) + 2;
});
}
}
if (hasNumberError) {
alert("请输入正确的数字格式");
return false;
}
vueDetails.observationDates = observationDates;
}
else {
vueDetails.observationDates = "";
}
$("#myModal").modal("show");
}
function GetObservationDates() {
var observationNum = $("#ObservationNum").val();
if (!observationNum) {
main.message("观察日间隔应设为大于0的值");
return;
}
var observationUnit = $("#ObservationUnit").val();
var observationHolidayType = $("#ObservationHolidayType").val();
var alignEnd = $("#AlignEnd").val();
if (!model.ShowCloseCheck) {
model.CalcMode = "01";//不算头算尾
if ($("#firstDayCheck").prop("checked")) {
model.CalcMode = "11";//算头算尾
}
}
var postData = {
startDate: model.startTime, endDate: model.endTime, termStr: observationNum + observationUnit,
holidayAdjustment: observationHolidayType, alignEnd: alignEnd, calcMode: model.CalcMode
};
main.post("/trade/GetObservationDateList", postData).done(
function (res) {
var dates = [];
if (model.ShowDate2) {
postData.offset = $("#CouponDayInterval").val() | 0;
postData.dates = res.obj;
postData.endTime = $("#endTime2").val();
main.post("/trade/GetObservationDateListOfDates", postData, { async: false }).done(function (data) {
dates = data.obj;
});
}
//互换,生成只有1个日期时,报送设置为到期支付
if (model.TradeType == null || model.TradeType == "" || model.TradeType == "undefined") {
if (res.obj.length == 1) {
$("#SelObservationUnit").val("TERM");
$("#ObservationFrequency").val("").attr("readonly", "readonly");
}
}
vuedivItems.fieldList0 = res.obj;
vuedivItems.fieldList3 = dates;
if (!model.ShowCloseCheck) {
vuedivItems.getTableArr();
} else {
$('#checkAllclose').prop("checked", true);
vuedivItems.checkedall = true;
vuedivItems.fieldList2 = null;
vuedivItems.getTableStringClose();
}
}
);
}
var vueDetails = new Vue({
el: "#myModal",
data: { observationDates: "" },
methods: {
closeModal: function () {
$('#myModal').modal('hide');
},
saveModal: function () {
var observationDates = vueDetails.observationDates.trim().replace("\n", "");
var fieldList0 = [];
var fieldList1 = [];
var fieldList2 = [];
var fieldList3 = [];
var hasNumberError = false;
var items = observationDates.split(";").filter(o => o);
items.forEach(function (item) {
if (item) {
var values = item.split(",");
fieldList0.push(values[0]);
if (values.length > 3 && (values[2].trim() === "False" || values[2].trim() === "True")) {
fieldList1.push(values[1]);
fieldList2.push(values[2].trim());
fieldList3.push(values[3]);
}
else if (values.length > 3) {
fieldList3.push(values[1]);
fieldList1.push(values[2]);
fieldList2.push(values[3]);
}
else {
fieldList1.push(values.length > 1 ? values[1] : "");
fieldList2.push(values.length > 2 ? values[2] : "");
}
}
});
if (hasNumberError) {
alert("请输入正确的数字格式");
return false;
}
vuedivItems.fieldList0 = fieldList0;
vuedivItems.fieldList1 = fieldList1;
vuedivItems.fieldList2 = fieldList2;
vuedivItems.fieldList3 = fieldList3;
if (!model.ShowCloseCheck) {
vuedivItems.getTableArr();
} else {
vuedivItems.getTableStringClose();
}
$('#myModal').modal('hide');
},
// 粘贴功能
pasteMe(e, rowData, index) {
let copyData = '';
if (e.clipboardData || e.originalEvent) {
var list = [];
var clipboardData = (e.clipboardData || e.originalEvent.clipboardData);
copyData = clipboardData.getData('Text');
var arr = copyData.replace(/\t/g, ', ').replace(/\r/g, '').split('\n');
arr.forEach((v, i) => {
if (v && !v.trim().endsWith(';')) {
arr[i] = v + ";";
}
});
this.observationDates = arr.join('\r\n');
e.preventDefault();
}
}
},
components: {
}
});
//观察间隔日变化时触发设置报送观察频率
function ObservationChange() {
if ($("#SelObservationUnit").val() != "OTHER") {
let observationNum = $("#ObservationNum").val();
let observationUnit = $("#ObservationUnit").val();
let observationUnitStr = getObservationUnitStr(observationUnit);
$("#ObservationFrequency").val(observationNum);
$("#SelObservationUnit").val(observationUnitStr);
}
}
function getObservationUnitStr(inpVal) {
if (inpVal != "" && inpVal != null && inpVal != undefined) {
let observationUnitStr;
switch (inpVal) {
case "D": observationUnitStr = "DAIL"; break;
case "W": observationUnitStr = "WEEK"; break;
case "M": observationUnitStr = "MNTH"; break;
case "Y": observationUnitStr = "YEAR"; break;
}
return observationUnitStr;
}
}
//选择其他时,报送观察频率数值文本框清空,并且只读
function ObservationChange2() {
let thisVal = $("#SelObservationUnit").val();
if (thisVal == "OTHER") {
$("#ObservationFrequency").val("").attr("readonly", "readonly");;
}
else if (thisVal == "TERM") {
$("#ObservationFrequency").val("").attr("readonly", "readonly");;
}
else {
let observationNum = $("#ObservationNum").val();
$("#ObservationFrequency").val(observationNum).removeAttr("readonly");
}
}