345 lines
17 KiB
JavaScript
345 lines
17 KiB
JavaScript
//客户选择组件
|
|
const vueClient = function () {
|
|
return {
|
|
props: ['value'],
|
|
data() {
|
|
return { current: { id: 0, Name: '' } };
|
|
},
|
|
mounted() {
|
|
var self = this;
|
|
var id = parseInt(this.value);
|
|
id && (this.current = ylotc.clients.find(x => x.id === id));
|
|
FastVue.autocomplete(this.$el, {
|
|
valueField: 'Name', searchField: ['Name', 'PinYin'], lookup: ylotc.clients,
|
|
onSelect(data) {
|
|
self.current = data;
|
|
if (self.value !== data.id) {
|
|
self.value = data.id;
|
|
self.$emit('input', self.value);
|
|
}
|
|
$(self.$el).blur();
|
|
}
|
|
});
|
|
},
|
|
watch: {
|
|
value(val, old) {
|
|
if (val !== old) {
|
|
var id = parseInt(val);
|
|
if (id !== this.current.id) {
|
|
this.current = ylotc.clients.find(x => x.id === id) || { id: 0, Name: '' };
|
|
}
|
|
$(this.$el).data('select', '').attr("placeholder", '');
|
|
}
|
|
}
|
|
},
|
|
destroyed() {
|
|
FastVue.autocomplete.dispose(this.$el);
|
|
},
|
|
template: '<input id="txtCurrentClient" type="text" v-model="current.Name" :title="current.Name" :data-IsCentralClearing="current.IsCentralClearing" :data-CentralClearingPaltform="current.CentralClearingPaltform" :data-TradingPaltform="current.TradingPaltform"/>'
|
|
};
|
|
};
|
|
|
|
const customNumberFormat = { precision: 6, negative: true, };
|
|
const customNumberPercentFormat = { precision: 6, negative: true, append: '%' };
|
|
|
|
$(function () {
|
|
var assetUnit = $.grep(pageObj.assetunits, function (e) { return e.id == pageVue.Trade.AssetId; });
|
|
_setAutocomplete('GroupAssetId', pageObj.assetunits, { Name: assetUnit[0].Name, id: assetUnit[0].id }, function (data) {
|
|
groupVue.trade.AssetId = data.id;
|
|
groupVue.trade.AssetBookName = data.Name;
|
|
});
|
|
var trader = $.grep(pageObj.traders, function (e) { return e.Name == pageVue.Trade.TraderName; });
|
|
_setAutocomplete('GroupTraderId', pageObj.traders, { Name: pageVue.Trade.TraderName, id: trader[0].id }, function (data) {
|
|
groupVue.trade.TraderId = data.id;
|
|
groupVue.trade.TraderName = data.Name;
|
|
});
|
|
var client = $.grep(ylotc.clients, function (e) { return e.id == pageVue.Trade.ClientId; });
|
|
_setAutocomplete('GroupClientId', ylotc.clients, { Name: client.length > 0 ? client[0].Name : '', id: client.length > 0 ? client[0].id : 0, IsCentralClearing: client.length > 0 ? client[0].IsCentralClearing : '', CentralClearingPaltform: client.length > 0 ? client[0].CentralClearingPaltform : '', TradingPaltform: client.length > 0 ? client[0].TradingPaltform:'' }, function (data) {
|
|
groupVue.trade.ClientId = data.id;
|
|
groupVue.trade.ClientName = data.Name;
|
|
groupVue.trade.MetaDic["中央对手方清算"] = data.IsCentralClearing;
|
|
groupVue.trade.MetaDic["中央清算平台"] = data.CentralClearingPaltform;
|
|
groupVue.trade.MetaDic["交易平台"] = data.TradingPaltform;
|
|
groupVue.trade.MetaDic["ExchangeRate"] = data.ExchangeRate;
|
|
});
|
|
$("#QuoteCurrency").val(groupVue.viewState.variety.QuoteCurrency);
|
|
if ($("#QuoteCurrency").val() && $("#QuoteCurrency").val() != "CNY") {
|
|
$("#ExchangeRateDiv").show();
|
|
} else {
|
|
$("#ExchangeRateDiv").hide();
|
|
}
|
|
groupVue.changeStockEqvNotional();
|
|
|
|
})
|
|
|
|
var groupVue = new Vue({
|
|
el: '#tradeEditGroupForm',
|
|
data: {
|
|
viewState: { variety: pageObj.variety },
|
|
...consVueTrade.data(),
|
|
trade: _.cloneDeep(pageVue.Trade),
|
|
IsCheck: pageVue.IsCheck,
|
|
structureTypes: pageObj.structureTypes,
|
|
PropertyMap: pageObj.PropertyMap,
|
|
},
|
|
computed: { ...consVueTrade.computed },
|
|
methods: {
|
|
...consVueTrade.methods,
|
|
addNewProperty: function () {
|
|
this.PropertyMap[this.trade.StructureType].push({ isNew: true, ColumnName: "", ColumnDefaultValue: "", ColumnType: 0 });//0:文本
|
|
},
|
|
deleteProperty: function (index) {
|
|
this.PropertyMap[this.trade.StructureType].splice(index, 1);
|
|
},
|
|
setExtendInfo: function () {
|
|
var propertyList = [];
|
|
this.PropertyMap[this.trade.StructureType].forEach((item, index) => {
|
|
var note = { name: item.name || item.ColumnName, value: item.ColumnType !== 4 || (item.value || item.ColumnDefaultValue + "").indexOf("%") > 0 ? ((item.value || item.ColumnDefaultValue) + "") : (((item.value || item.ColumnDefaultValue) * 100) + "%") };
|
|
if (note.name) {
|
|
propertyList.push(note);
|
|
}
|
|
});
|
|
this.trade.ExtendInfo = this.trade.StructureType == "气囊结构" ? null : JSON.stringify(propertyList);
|
|
return this.trade.ExtendInfo;
|
|
},
|
|
saveTrade: function () {
|
|
this.setExtendInfo();
|
|
var tags = new Array();
|
|
$(".tag-context .tag-item").each(function (i, v) {
|
|
tags.push({ Id: $(v).data("id"), Name: $(v).data("name") });
|
|
});
|
|
this.trade.Tags = tags;
|
|
main.post("/trade/SaveGroupTrade", { trade: this.trade, tradeIds: pageObj.tradeIds }).done(function (res) {
|
|
try {
|
|
window.parent.reloadtrade();
|
|
(parent || window).main.message(res.msg);
|
|
(parent || window).layer.closeAll();
|
|
} catch (e) {
|
|
//
|
|
}
|
|
});
|
|
},
|
|
checkTrade: function () {
|
|
$(".not-match").remove();
|
|
var failFunc = function (res) {
|
|
if (!res || !res.obj || main.isEmpty(res.obj.diffList)) {
|
|
return;
|
|
}
|
|
res.obj.diffList.forEach(function (curValue) {
|
|
if (curValue === "ExtendInfo") {
|
|
main.message("自定义字段复核失败!");
|
|
} else {
|
|
$(`[name='${curValue}']`).parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;float: right;position: absolute;top: 9px;"></span>');
|
|
}
|
|
});
|
|
};
|
|
|
|
this.setExtendInfo();
|
|
//this.trade.ExtendInfo = this.trade.StructureType == "气囊结构" && this.propertyList ? null : JSON.stringify(this.propertyList);
|
|
main.post("/trade/CheckTradeGroup", { trade: this.trade }).done(function (res) {
|
|
try {
|
|
(parent || window).main.message(res.msg);
|
|
window.parent.reloadtrade();
|
|
} catch (e) {
|
|
//
|
|
}
|
|
}).fail(failFunc);
|
|
},
|
|
rejectTrade: function () {
|
|
main.post("/trade/TradeReject", this.trade).done(
|
|
function (res) {
|
|
try {
|
|
window.parent.reloadtrade();
|
|
} catch (e) { }
|
|
}
|
|
);
|
|
},
|
|
changeStrucTureType: function () {
|
|
if (groupVue.trade.StructureType != "气囊结构") {
|
|
groupVue.trade.OptionType = null;
|
|
groupVue.trade.Strike = null;
|
|
}
|
|
else {
|
|
groupVue.trade.KIParticipationRate = 1;
|
|
}
|
|
},
|
|
changeBuySell: function () {
|
|
groupVue.trade.TradePrice *= -1;
|
|
},
|
|
changeStockEqvNotional: function () {
|
|
var notional = groupVue.trade.StockEqvNotional / groupVue.trade.SpotPrice;
|
|
groupVue.trade.Notional = pricingFormat.notional(notional);
|
|
groupVue.trade.TradeAmount = pricingFormat.notional(notional / groupVue.viewState.variety.CountRatio);
|
|
groupVue.trade.TradeSinglePrice = pricingFormat.tradeSinglePrice(groupVue.trade.TradePrice / groupVue.trade.Notional);
|
|
groupVue.trade.PremiumRate = pricingFormat.premiumRate(groupVue.trade.TradePrice / groupVue.trade.StockEqvNotional);
|
|
},
|
|
changeTradeAmount: function () {
|
|
var notional = groupVue.trade.TradeAmount * groupVue.viewState.variety.CountRatio;
|
|
groupVue.trade.Notional = pricingFormat.notional(notional);
|
|
groupVue.trade.StockEqvNotional = pricingFormat.stockEqvNotional(notional * groupVue.trade.SpotPrice);
|
|
groupVue.trade.TradeSinglePrice = pricingFormat.tradeSinglePrice(groupVue.trade.TradePrice / groupVue.trade.Notional);
|
|
groupVue.trade.PremiumRate = pricingFormat.premiumRate(groupVue.trade.TradePrice / groupVue.trade.StockEqvNotional);
|
|
},
|
|
init: function () {
|
|
var assetUnit = $.grep(pageObj.assetunits, function (e) { return e.id == pageVue.Trade.AssetId; });
|
|
_setAutocomplete('GroupAssetId', pageObj.assetunits, { Name: assetUnit[0].Name, id: assetUnit[0].id }, function (data) {
|
|
groupVue.trade.AssetId = data.id;
|
|
groupVue.trade.AssetBookName = data.Name;
|
|
});
|
|
var trader = $.grep(pageObj.traders, function (e) { return e.Name == pageVue.Trade.TraderName; });
|
|
_setAutocomplete('GroupTraderId', pageObj.traders, { Name: pageVue.Trade.TraderName, id: trader[0].id }, function (data) {
|
|
groupVue.trade.TraderId = data.id;
|
|
groupVue.trade.TraderName = data.Name;
|
|
});
|
|
var client = $.grep(ylotc.clients, function (e) { return e.id == pageVue.Trade.ClientId; });
|
|
_setAutocomplete('GroupClientId', ylotc.clients, { Name: client.length > 0 ? client[0].Name : '', id: client.length > 0 ? client[0].id : 0, IsCentralClearing: client.length > 0 ? client[0].IsCentralClearing : '', CentralClearingPaltform: client.length > 0 ? client[0].CentralClearingPaltform : '', TradingPaltform: client.length > 0 ? client[0].TradingPaltform:'' }, function (data) {
|
|
groupVue.trade.ClientId = data.id;
|
|
groupVue.trade.ClientName = data.Name;
|
|
groupVue.trade.MetaDic["中央对手方清算"] = data.IsCentralClearing;
|
|
groupVue.trade.MetaDic["ExchangeRate"] = data.ExchangeRate;
|
|
groupVue.trade.MetaDic["中央清算平台"] = data.CentralClearingPaltform;
|
|
groupVue.trade.MetaDic["交易平台"] = data.TradingPaltform;
|
|
});
|
|
},
|
|
changeOption: function () {
|
|
this.PropertyMap[this.trade.StructureType].forEach(d => {
|
|
if (d.ColumnName != undefined) {
|
|
d.name = d.ColumnName;
|
|
}
|
|
if (d.ColumnDefaultValue != undefined) {
|
|
d.value = d.ColumnDefaultValue;
|
|
}
|
|
});
|
|
},
|
|
//交易审批
|
|
submit(status) {
|
|
var pop = '';
|
|
if (status === 'pass') {
|
|
pop = "确认通过审批?";
|
|
}
|
|
if (status === 'reject') {
|
|
pop = "确认拒绝?";
|
|
}
|
|
var confirmFunc = function (additionalProcessing) {
|
|
var pData = { tradeId: pageVue.Trade.id, status: status, text: "" };
|
|
if (!main.isEmpty(additionalProcessing)) {
|
|
pData.additionalProcessing = additionalProcessing;
|
|
}
|
|
main.post("/processtradelog/UpdateTradeProcessLog", pData).done(
|
|
function (data) {
|
|
if (data.obj && data.obj.proccessType == "AdditionalProcessing") {
|
|
if (data.obj.type == "LackOfMoney") {
|
|
var htmlContent = `<div style="padding:10px">${data.obj.message}</div>`;
|
|
var lackMoneyConfirmLayer = main.open2("提示",
|
|
htmlContent,
|
|
{
|
|
area: ["430px", "175px"],
|
|
btn: ['交易特批', '取消'],
|
|
yes: function (index, layero) {
|
|
var layerIndex = lackMoneyConfirmLayer;
|
|
main.confirm("客户资金或授信不足,强制成交会导致本机构产生风险!要继续审批通过?", function () {
|
|
layer.close(layerIndex);
|
|
confirmFunc("LackOfMoney");
|
|
});
|
|
},
|
|
cancel: function (index, layero) {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
(parent || window).layer.closeAll();
|
|
}
|
|
});
|
|
console.log("lackMoneyConfirmLayer:" + lackMoneyConfirmLayer);
|
|
}
|
|
return;
|
|
}
|
|
(parent || window).main.message(data.msg);
|
|
if (parent) {
|
|
parent.layer.closeAll();
|
|
}
|
|
});
|
|
}
|
|
main.confirm(pop, confirmFunc);
|
|
}
|
|
},
|
|
components: {
|
|
'vue-niceselect': FastVue.vueNiceSelect(),
|
|
'vue-client': vueClient(),
|
|
'vue-datepicker': FastVue.vueDatePicker(),
|
|
'vue-number-input': FastVue.vueNumberInput(),
|
|
},
|
|
});
|
|
|
|
$(function () {
|
|
$(".datepicker").change(function () {
|
|
var dateVal = $(this).val();
|
|
if (!dateVal) return;
|
|
dateVal = dateVal.replace(/\D/g, '').padStart(4, '0');
|
|
switch (dateVal.length) {
|
|
case 4:
|
|
dateVal = new Date().getFullYear() + dateVal; break;
|
|
case 6:
|
|
dateVal = '20' + dateVal; break;
|
|
case 8: break;
|
|
default:
|
|
dateVal = dateVal.length > 8 ? dateVal.substring(0, 8) : ''; break;
|
|
}
|
|
|
|
if (dateVal) {
|
|
dateVal = moment(dateVal).format('YYYY-MM-DD');
|
|
!/^\d+/.test(dateVal) && (dateVal = '');
|
|
}
|
|
|
|
$(this).datepicker("setDate", dateVal);
|
|
});
|
|
});
|
|
|
|
function _setAutocomplete(elId, datas, initData, onSelectFn) {
|
|
initData = initData || datas[0] || {};
|
|
if (elId === "GroupClientId") {
|
|
groupVue.trade.ClientId = initData.id;
|
|
groupVue.trade.ClientName = initData.Name;
|
|
|
|
if (groupVue.trade.MetaDic["中央对手方清算"] == "" || groupVue.trade.MetaDic["中央对手方清算"] == undefined)
|
|
groupVue.trade.MetaDic["中央对手方清算"] = initData.IsCentralClearing;
|
|
if (groupVue.trade.MetaDic["中央清算平台"] == "" || groupVue.trade.MetaDic["中央清算平台"] == undefined)
|
|
groupVue.trade.MetaDic["中央清算平台"] = initData.CentralClearingPaltform;
|
|
if (groupVue.trade.MetaDic["交易平台"] == "" || groupVue.trade.MetaDic["交易平台"] == undefined)
|
|
groupVue.trade.MetaDic["交易平台"] = initData.TradingPaltform;
|
|
if (groupVue.trade.MetaDic["ExchangeRate"] == "" || groupVue.trade.MetaDic["ExchangeRate"] == undefined)
|
|
groupVue.trade.MetaDic["ExchangeRate"] = initData.ExchangeRate;
|
|
}
|
|
else if (elId === "GroupAssetId") {
|
|
groupVue.trade.AssetId = initData.id;
|
|
groupVue.trade.AssetBookName = initData.Name;
|
|
}
|
|
else if (elId === "GroupTraderId") {
|
|
groupVue.trade.TraderId = initData.id;
|
|
groupVue.trade.TraderName = initData.Name;
|
|
}
|
|
var el = $("#" + elId);
|
|
if (el.length) {
|
|
FastVue.autocomplete(el[0], {
|
|
valueField: 'Name', searchField: ['Name', 'PinYin'], lookup: datas,
|
|
onSelect(data) {
|
|
$('#' + elId).data('id', data.id);
|
|
if (elId === "GroupClientId") {
|
|
if (data.IsCentralClearing != undefined || data.IsCentralClearing != "") {
|
|
$("#selIsCentralClearing").val(data.IsCentralClearing);
|
|
}
|
|
if (data.CentralClearingPaltform != undefined || data.CentralClearingPaltform != "") {
|
|
$("#selCentralClearingPaltform").val(data.CentralClearingPaltform);
|
|
}
|
|
if (data.TradingPaltform != undefined || data.TradingPaltform != "") {
|
|
$("#selTradingPaltform").val(data.TradingPaltform);
|
|
}
|
|
}
|
|
|
|
onSelectFn && onSelectFn(data);
|
|
},
|
|
zIndex: 300000
|
|
}).setData(initData);
|
|
el.data('id', initData.id);
|
|
}
|
|
} |