101 lines
3.8 KiB
JavaScript
101 lines
3.8 KiB
JavaScript
const consClients = ylotc.clients;
|
|
|
|
const inputFormatPremiumRate = Object.freeze({ precision: otcformat.trading.premiumRateP.precision, negative: true, append: '%' });
|
|
const inputFormatSinglePrice = Object.freeze({ precision: otcformat.trading.tradeSinglePrice.precision, negative: true, append: '' });
|
|
const inputFormatInteger = Object.freeze({ precision: 0, append: '' });
|
|
|
|
const vue = new Vue({
|
|
el: '#clientVarietyConfigForm',
|
|
data: {
|
|
isAdd: page.isAdd,
|
|
client_variety_config: page.client_variety_config
|
|
},
|
|
methods: {
|
|
changeClient(yldata) {
|
|
let client = yldata || { id: 0 };
|
|
this.client_variety_config.ClientId = client.id;
|
|
},
|
|
changeVariety(variety) {
|
|
this.client_variety_config.VarietyId = variety.id;
|
|
},
|
|
saveClientVarietyConfig() {
|
|
if (!this.client_variety_config.ClientId) {
|
|
main.message("客户名称不能为空");
|
|
return;
|
|
}
|
|
if (!this.client_variety_config.VarietyId) {
|
|
main.message("标的品种不能为空");
|
|
return;
|
|
}
|
|
main.post("/swaptrade/clientVarietyConfigEditJson", { req: this.client_variety_config }).done(function (resp) {
|
|
try {
|
|
window.parent.reloadData();
|
|
} catch (e) { }
|
|
});
|
|
}
|
|
},
|
|
components: {
|
|
'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);
|
|
});
|
|
|
|
SetAceDropDown();
|
|
|
|
var width = 152;
|
|
for (var i = 0; i < consClients.length; i++) {
|
|
let ele = document.createElement('span')
|
|
ele.innerText = consClients[i].Name;
|
|
ele.style.fontSize = '14px';
|
|
document.documentElement.append(ele);
|
|
var charLength = ele.offsetWidth + 28;//滚动条
|
|
document.documentElement.removeChild(ele);
|
|
if (charLength > width) {
|
|
width = charLength
|
|
}
|
|
}
|
|
let autoClient = FastVue.autocomplete(document.getElementById('ClientId'), {
|
|
nameField: 'Name', valueField: 'id', searchField: ['Name', 'PinYin'], width: width,
|
|
lookup: consClients, onSelect: vue.changeClient
|
|
});
|
|
let clientId = page.client_variety_config.ClientId;
|
|
let client = clientId ? consClients.find(x => x.id === clientId) : null;
|
|
!client && page.isAdd && (client = consClients[0]);
|
|
autoClient.setData(client);
|
|
vue.changeClient(client);
|
|
//ylotc.varieties.forEach(function (value, index) {
|
|
// value['Name'] = value['Name'] +"("+ value['Code']+")"
|
|
//});
|
|
var autoVariety = FastVue.autocomplete(document.getElementById('VarietyId'), {
|
|
nameField: 'Code', valueField: 'id', searchField: ['Name', 'Code', 'PinYin'],
|
|
lookup: ylotc.varieties, onSelect: vue.changeVariety
|
|
});
|
|
let varietyId = page.client_variety_config.VarietyId;
|
|
let variety = varietyId ? ylotc.varieties.find(x => x.id === varietyId) : null;
|
|
!variety && page.isAdd && (variety = ylotc.varieties[0]);
|
|
autoVariety.setData(variety);
|
|
vue.changeVariety(variety);
|
|
}); |