//客户选择组件 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: '' }; }; 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(''); } }); }; 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 = `