var dzjy_wt ={};
dzjy_wt.preZqdm = '';
dzjy_wt.curWtPrice = 0;
dzjy_wt.curWtKyzj = 0;
dzjy_wt.curWtje =0;
dzjy_wt.curSwitch =0;
dzjy_wt.gridIdList=['#ccgp_grid', '#cd_grid', '#drcj_grid'];
dzjy_wt.wtCtrlList = ['#cd', '#cklabel', '#mycheck'];
var multipleCdCount =0;
var multipleCdCur =0;
var multipleCdSelRows ={};
var pageList=[''];
var pageCur = 0; 
/*
	持仓股票字段
*/
var ccgpList =	[
				[			
				{field:'stock_code',title:'证券代码',width:70,halign:'center',align:'center',sortable:true,styler:setFieldColor},
				{field:'stock_name',title:'证券名称',width:70,halign:'center',align:'center',sortable:true,styler:setFieldColor},
				{field:'hold_amount',title:'证券数量',width:100,halign:'center',align:'center',sortable:true,sorter:sortNumber,styler:setFieldColor},
				{field:'enable_amount',title:'可卖数量',width:100,halign:'center',align:'center',sortable:true,sorter:sortNumber,styler:setFieldColor},
				{field:'cost_price',title:'成本价',width:70,halign:'center',align:'center',sortable:true,sorter:sortNumber,styler:setFieldColor},
				{field:'last_price',title:'当前价',width:70,halign:'center',align:'center',sortable:true,sorter:sortNumber,styler:setFieldColor},
				{field:'market_value',title:'最新市值',width:100,halign:'center',align:'center',sortable:true,sorter:sortNumber,styler:setFieldColor},
				{field:'fdyk',title:'浮动盈亏',width:100,halign:'center',align:'center',sortable:true,sorter:sortNumber,styler:setFieldColor},
				{field:'ykbl',title:'盈亏比例(%)',width:90,halign:'center',align:'center',sortable:true,sorter:sortNumber,styler:setFieldColor},
				{field:'stock_account',title:'股东代码',width:130,halign:'center',align:'center',sortable:true,styler:setFieldColor}
				]
			    ];

/*
	当日委托字段
*/
var cdList =	[
				[
				{checkbox:true,width:12},
				{field:'entrust_no',title:'委托号',width:60,halign:'center',align:'center',sortable:true},
				{field:'curr_date',title:'委托日期',width:70,halign:'center',align:'center',sortable:true},
				{field:'curr_time',title:'委托时间',width:70,halign:'center',align:'center',sortable:true,formatter:formatTimeStr,sorter:sortNumber},
				{field:'op_entrust_way',title:'委托方式',width:80,halign:'center',align:'center',sortable:true,formatter:formatWtfs},
				{field:'exchange_type',title:'交易类别',width:70,halign:'center',align:'center',sortable:true,formatter:formatJylb},
				{field:'stock_code',title:'证券代码',width:70,halign:'center',align:'center',sortable:true},
				{field:'stock_name',title:'证券名称',width:70,halign:'center',align:'center',sortable:true},
				{field:'entrust_bs',title:'买卖方向',width:60,halign:'center',align:'center',sortable:true,formatter:formatMmfx},
				{field:'entrust_type',title:'委托类别',width:70,halign:'center',align:'center',sortable:true,formatter:formatWtlb},
				{field:'entrust_prop',title:'委托属性',width:180,halign:'center',align:'center',sortable:true,formatter:formatWtsx},
				{field:'entrust_price',title:'委托价格',width:70,halign:'center',align:'center',sortable:true,sorter:sortNumber},
				{field:'entrust_amount',title:'委托数量',width:100,halign:'center',align:'center',sortable:true,sorter:sortNumber},
				{field:'business_amount',title:'成交数量',width:100,halign:'center',align:'center',sortable:true,sorter:sortNumber},
				{field:'entrust_status',title:'委托状态',width:100,halign:'center',align:'center',sortable:true,formatter:formatWtzt}
				]
			    ];

/*
	当日成交展示字段
*/
var drcjList =	[
				[
				{field:'entrust_no',title:'委托号',width:100,halign:'center',align:'center',sortable:true},
				{field:'stock_code',title:'证券代码',width:100,halign:'center',align:'center',sortable:true},
				{field:'stock_name',title:'证券名称',width:100,halign:'center',align:'center',sortable:true},
				{field:'entrust_bs',title:'买卖方向',width:100,halign:'center',align:'center',sortable:true,formatter:formatMmfx},
				{field:'business_amount',title:'成交数量',width:100,halign:'center',align:'center',sortable:true,sorter:sortNumber},
				{field:'business_price',title:'成交价格',width:100,halign:'center',align:'center',sortable:true,sorter:sortNumber},
				{field:'business_balance',title:'成交金额',width:100,halign:'center',align:'center',sortable:true,sorter:sortNumber}
				]
			    ];

$(function(){
	$("#tab").tabs({
		height:26,
		border:false
	});
	var tabList=["持仓股票","当日委托","当日成交"];
	gf_dzjy_share.addTab('tab',tabList,0);
	$("#tab").tabs("options").onSelect=function(title,index){
		dzjy_wt.curSwitch = index;
		wtCtrlShow(index); 
		wtGridShow(index);
		getGridData(index);
	};

	gf_dzjy_share.createGrid('ccgp_grid','tdx_center',null,ccgpList,false);
	$("#ccgp_grid").datagrid("options").onDblClickRow = onDblClickGetHq;
	$("#ccgp_grid").datagrid("options").singleSelect = true;
	get_ccgp('');

	gf_dzjy_share.createGrid('cd_grid','tdx_center',null,cdList,false);
	$("#cd_grid").datagrid("options").onDblClickRow = onDblClickRow;
	$("#cd_grid").datagrid("options").alignColList =['entrust_prop'];
	$("#cd_grid").datagrid("options").text_align ='left';
	$('#cd_grid').datagrid("options").onLoadSuccess = gridColAlign;

	gf_dzjy_share.createGrid('drcj_grid','tdx_center',null,drcjList,false);
	$("#drcj_grid").datagrid("options").singleSelect = true;
	wtGridShow(dzjy_wt.curSwitch);

	var resizeTimer = null;
	window.onresize = function(){
	   	resizeTimer = resizeTimer ? null : setTimeout(doResize,300);
	}
	function doResize(){
		$('#right_panel').layout('resize');
		$(dzjy_wt.gridIdList[dzjy_wt.curSwitch]).datagrid('resize');

	}
})

function onKeyUp(node,e){
	if($(node).attr('value').length==6){
		var zqdm = $(node).attr('value');
		if (dzjy_wt.preZqdm !=zqdm){
			dzjy_wt.preZqdm = zqdm;
			get_stockhq(zqdm);
		}
	}
}

function onKeyPress(node,e){
	var k = window.event ? e.keyCode:e.which;
	if (((k >= 48) && (k <= 57)) ||k==8|| k==0){	
		if($(node).attr('value').length==6){
			var txt=getSelectedText($(node)[0])
			if(txt.length==0){
				if(window.event) window.event.returnValue = false; 
				else e.preventDefault();
				return
			}
		}
	}
	else{
		if(window.event) window.event.returnValue = false; 
		else e.preventDefault();
	}
}

/*
	获取证券行情数据
	判断证券是否合法
*/
function get_stockhq(stock_code){
	var _ix = new IXContent();
	_ix.Set('stock_code',stock_code);
	_ix.Set('exchange_type','2');//1上海2深圳
	Win_CallTQL('ret_stockhq', '5010:SIMPLE.394', _ix, '');
}

function ret_stockhq(_fromid,_funid,_flagtype,data){
	if (_funid == '5010:SIMPLE.394'){
		var data = FormatResult(data, 1);
		if (data.ErrorCode == 0){
			if(data.rows[0].error_no == undefined){
				dzjy_wt.curWtKbuyfe = [];
				dzjy_wt.curWtPrice = 0;
				dzjy_wt.curWtKyzj = 0;
				dzjy_wt.curWtje =0;
				$('#mmfx').get(0).options[0].selected = true;
				$('#jglx').get(0).options[0].selected = true;
				$('#wtsl').numberspinner('setValue','');
				$('#wtsldx').text('');
				$('#wtje').css('background-color', '#fff');
				$('#wtje').text('');
				dzjy_wt.closing_price = data.rows[0].closing_price;
				dzjy_wt.weightave_price = data.rows[0].weightave_price;
				$('#zqmc').text(data.rows[0].stock_name);
				$('#spj').text(dzjy_wt.closing_price);
				$('#jqpjj').text(dzjy_wt.weightave_price);
				setWtPrice(getSelIndex('jglx'));
				get_dzjykyzj();
			}
			else{
				$.messager.alert("提示",'['+dzjy_wt.preZqdm+']<br>[证券参数错]',"error");
				initCtrl();
			}
		} 
		else{
			$.messager.alert("提示",data.ErrorInfo,"error");
			initCtrl();
		}
	} 
}

/*
	获取大宗交易可用资金
*/
function get_dzjykyzj(){
	gf_dzjy_share.setIX({"funcid":"332700","funcname":'ret_dzjykyzj'})
}

function ret_dzjykyzj(_fromid,_funid,_flagtype,data){
	if (_funid == '5010:SIMPLE.332700'){
		var data = FormatResult(data, 1);
		if (data.ErrorCode == 0){
			dzjy_wt.curWtKyzj = data.rows[0].enable_balance;
			(dzjy_wt.closing_price==0)?dzjy_wt.curWtKbuyfe.push(100000000):dzjy_wt.curWtKbuyfe.push((dzjy_wt.curWtKyzj/dzjy_wt.closing_price).toFixed(0));
			(dzjy_wt.weightave_price==0)?dzjy_wt.curWtKbuyfe.push(100000000):dzjy_wt.curWtKbuyfe.push((dzjy_wt.curWtKyzj/dzjy_wt.weightave_price).toFixed(0));
			$('#zdg').val(dzjy_wt.curWtKbuyfe[0]);
			get_gpcodexx(dzjy_wt.preZqdm);
		} 
		else{
			$.messager.alert("提示",data.ErrorInfo,"error");
		}
	} 
}

/*获取证券代码信息*/
function get_gpcodexx(stockCode){
	var _ix = new IXContent();
	_ix.Set('F140', stockCode);
	Win_CallTQL('ret_gpcodexx', 'JY:102', _ix, '');
}

function ret_gpcodexx(_fromid,_funid,_flagtype,data) {
	if(_funid == 'JY:102'){
		var data = FormatResult(data, 1);
		if(data.ErrorCode == 0){
			User.stockMarket=data.rows[0]["F125"];
			get_Gddm();	
		}
		else
		{
			$.messager.alert('提示',data.ErrorInfo,"error");
		}
	}
}

/*
	获取股东代码
*/
function get_Gddm(){
	var _ix = new IXContent();
	_ix.Set('F113', '0');
	Win_CallTQL('ret_Gddm', 'JY:1122', _ix, '');
}

function ret_Gddm(_fromid,_funid,_flagtype,data) {
	if (_funid == 'JY:1122') {
		var data = FormatResult(data, 1);
		if (data.ErrorCode == 0){
			for (var i = 0; i < data.rows.length; i++) {
				if(data.rows[i]["F125"]==User.stockMarket){
					User.gddm = data.rows[i]["F123"];
					break;
				} 
			}
			get_dzjykyfe();
		} 
		else{
			$.messager.alert("提示",data.ErrorInfo,"error");
		}
	}
}


/*
	获取大宗交易可用份额
*/
function get_dzjykyfe(){
	gf_dzjy_share.setIX({"funcid":"332701","funcname":'ret_dzjykyfe',"exchange_type":'2',"stock_code":dzjy_wt.preZqdm,"stock_account":User.gddm})
}

function ret_dzjykyfe(_fromid,_funid,_flagtype,data){
	
	if (_funid == '5010:SIMPLE.332701'){
		var data = FormatResult(data, 1);
		if (data.ErrorCode == 0){
			dzjy_wt.curWtKyfe = data.rows[0].enable_amount;
		} 
		else{
			$.messager.alert("提示",data.ErrorInfo,"error");
		}
	} 
}

/*
	获取Select当前索引值
*/
function getSelIndex(id){
	return $('#'+id).get(0).selectedIndex;
}

/*
	获取最大买入卖出份额
*/
function setMaxCount(selIndex){
	if(dzjy_wt.curWtKbuyfe != undefined)
	(selIndex==0)?$('#zdg').val(dzjy_wt.curWtKbuyfe[$('#jglx').get(0).selectedIndex]):$('#zdg').val(dzjy_wt.curWtKyfe);
	var wtsl = $('#wtsl').numberspinner('getValue');
	if(wtsl!= undefined && wtsl!= null && wtsl!= '') setWtje(wtsl);
}

/*
	设置委托价格
*/
function setWtPrice(selIndex){
	dzjy_wt.curWtPrice = (selIndex==0)?dzjy_wt.closing_price:dzjy_wt.weightave_price;
	$('#wtjg').val(dzjy_wt.curWtPrice);
	if(dzjy_wt.curWtKbuyfe!=[]){
		if($('#mmfx').get(0).selectedIndex==0) $('#zdg').val(dzjy_wt.curWtKbuyfe[selIndex]);
	}
	var wtsl = $('#wtsl').numberspinner('getValue');
	if(wtsl!= undefined && wtsl!= null && wtsl!= '') setWtje(wtsl);	
}

/*
	重填按钮响应事件
*/
function reSetCtrl(){
	initCtrl();
}

/*
	初始化所有控件
*/
function initCtrl(){
	$('#zqdm').val('');
	$('#zqmc').text('');
	$('#spj').text('');
	$('#jqpjj').text('');
	$('#mmfx').get(0).options[0].selected = true;
	$('#zdg').val('');
	$('#jglx').get(0).options[0].selected = true;
	$('#wtjg').val('');
	$('#wtsl').numberspinner('setValue','');
	$('#wtsldx').text('');
	$('#wtje').css('background-color', '#fff');
	$('#wtje').text('');
	dzjy_wt.preZqdm = '';
	dzjy_wt.curWtPrice = 0;
	dzjy_wt.curWtKyzj = 0;
	dzjy_wt.closing_price = '';
	dzjy_wt.weightave_price = '';
	dzjy_wt.curWtKbuyfe = undefined;
	dzjy_wt.curWtKyfe ='';
	dzjy_wt.curWtsl = undefined;
	dzjy_wt.curWtje =0;
}

/*
	设置委托数量为汉子大写
*/
function onChangeSpinVal(newValue,oldValue){
	dzjy_wt.curWtsl = newValue;
	var rmbString = (newValue=='')?'':gf_dzjy_share.getChineseCurrencyString(newValue);
	$('#wtsldx').text(rmbString);
	setWtje(newValue);
}

/*
	设置委托金额
*/
function setWtje(wtsl){
	var dzjyje ='';
	dzjy_wt.curWtje = (dzjy_wt.curWtPrice*wtsl).toFixed(3);
	dzjyje+=$('#mmfx').find("option:selected").text();
	dzjyje+='金额:';
	dzjyje+=(dzjy_wt.curWtPrice*wtsl).toFixed(3);
	$('#wtje').css('background-color', '#FC0301');
	$('#wtje').text(dzjyje);
}

/*
	表格的显示隐藏
*/
function wtGridShow(cur) {
	$(dzjy_wt.gridIdList).each(function(index, id) {
		if(cur==index){
			$(id).datagrid("getPanel").show();
			$(id).datagrid("resize");
		}
		else{
			$(id).datagrid("getPanel").hide();
		}
	});

}

/*
	控件的显示隐藏
*/
function wtCtrlShow(cur){
	if (cur == 1) {
		$(dzjy_wt.wtCtrlList).each(function(index,val) {
			$(val).show();
		})
	} else {
		$(dzjy_wt.wtCtrlList).each(function(index,val) {
			$(val).hide();
		})
	}

}
/*
	发起委托
*/
function goWt() {
	var temp_zqdm = $('#zqdm').val();
	if (isNum(temp_zqdm) && temp_zqdm.length == 6){
		var temp_wtsl = $('#wtsl').numberspinner('getValue');
		if (temp_wtsl == "" || temp_wtsl == null || temp_wtsl == undefined) {
			$.messager.alert("警告", '<h3>委托数量不能为空!</h3>', "warning");
		}
		else{
			(getSelIndex('mmfx')==0)?$('#mmimg').attr('src', '../images/buy.jpg'):$('#mmimg').attr('src', '../images/sale.jpg');
			$('#gdzh').text(User.gddm);
			$('#sssc').text(transGddm[User.stockMarket]);
			$('#gpdm').text(dzjy_wt.preZqdm);
			$('#sl').text(temp_wtsl);
			$('#wtprice').text(dzjy_wt.curWtPrice);
			$('#jgtype').text($('#jglx').find("option:selected").text());
			$("#fqwt").window("open");
		}
	} else {
		if (temp_zqdm == "" || temp_zqdm == null || temp_zqdm == undefined) {
			$.messager.alert("警告", '<h3>证券代码不能为空!</h3>', "warning");
		}
		else{
			$.messager.alert("警告", '<h3>证券代码有误!</h3>', "warning");
		}
	}
}

/*
	取消委托
*/
function onWtCancelBtnClick(){
	$("#fqwt").window("close");	
}

/*
	确认委托
*/
function onWtSureBtnClick(){
	var wtcfg ={
		"funcid":"332702",
		"funcname":'ret_wtqr',
		"exchange_type":'2',
		'stock_account':User.gddm,
		'stock_code':dzjy_wt.preZqdm,
		'entrust_price':dzjy_wt.curWtPrice,
		'entrust_amount':dzjy_wt.curWtsl,
		'entrust_balance':dzjy_wt.curWtje,
		'entrust_prop':(getSelIndex('jglx')==0)?'AFC':'AFW',
		'entrust_bs':(getSelIndex('mmfx')+1).toString()
	};
	gf_dzjy_share.setIX(wtcfg);
}

function ret_wtqr(_fromid, _funid, _flagtype, data) {
	if (_funid == '5010:SIMPLE.332702') {
		try {
			var data = FormatResult(data, 1);
			if (data.ErrorCode == 0) {
				$.messager.alert("提示", "委托成功,<br>委托编号:"+data.rows[0].entrust_no,"info");
				initCtrl();
				if(dzjy_wt.curSwitch==1) init_wtcx();
			}
			else{
				alert(data.ErrorInfo.substr(5));
			}
		} catch (e) {
			var temp_list =data.split('"');
			var tslabel = temp_list[1].substr(5)
			alert(tslabel);
		}
		$("#fqwt").window("close");	
	}
}

/*
	持仓股票查询
*/
function get_ccgp(sPos){
	var wtcfg ={
		"funcid":"333104",
		"sysnode_id":User.sysnode_id,
		"position_str":"",
		'@POS':sPos,
		'@COND':'SELECT stock_code,stock_name,hold_amount,enable_amount,cost_price,last_price,market_value,stock_account FROM 333104 ',
		"funcname":'ret_ccgp'
	};
	gf_dzjy_share.setIX(wtcfg);
}

function ret_ccgp(_fromid,_funid,_flagtype,data){
	if (_funid == '5010:SIMPLE.333104'){
		var data = FormatResult(data, 1);
		if (data.ErrorCode == 0){
			if($.inArray(data.POS, pageList)==-1){
				pageList.push(data.POS);
			}
			for(var i=0;i<data.rows.length;i++){
				var rowData = data.rows[i];
				data.rows[i].fdyk = formatFdykVal(rowData);
				data.rows[i].ykbl = formatYkblVal(rowData);
			}
			rowData ={};
			gridUpdateData('ccgp_grid',0,data);
		} 
		else{
			$.messager.alert("提示",data.ErrorInfo,"error");
		}
	} 
}

/*
	设置持仓股票字段颜色
*/
function setFieldColor(value,rowData,rowIndex){
	var fdyk = gf_dzjy_share.parseFloat(rowData.fdyk);
	var color = (fdyk<0)?'color:blue;' :'color:red;';
	return color;
}

/*
	计算浮动盈亏
*/
function formatFdykVal(rowData){
	var fdyk = 0;
	try{
		fdyk = (rowData.last_price-rowData.cost_price)*rowData.hold_amount;
	}
	catch(e){
		fdyk = 0;
	}
	return fdyk.toFixed(2);
}

/*
	计算盈亏比例
*/
function formatYkblVal(rowData){
	var ykbl = 0;
	if (rowData.cost_price <= 0) {
		ykbl = 0;
	} else {
		try {
			ykbl = (rowData.last_price - rowData.cost_price) * 100 / rowData.cost_price;
		} catch (e) {
			ykbl = 0;
		}
	}
	return ykbl.toFixed(3);
}

/*
	委托查询
*/
function get_wtcx(sPos){
	var query_kind = (document.getElementById("mycheck").checked)?1:0;
	var wtcfg ={
		"funcid":"332704",
		'en_entrust_prop':'AFC,AFW',
		"query_kind":query_kind,
		"position_str":"",
		'@POS':sPos,
		"funcname":'ret_wtcx'
	};
	gf_dzjy_share.setIX(wtcfg);
}

function ret_wtcx(_fromid,_funid,_flagtype,data){
	if (_funid == '5010:SIMPLE.332704'){
		var data = FormatResult(data, 1);
		if (data.ErrorCode == 0){
			if($.inArray(data.POS, pageList)==-1){
				pageList.push(data.POS);
			}
			gridUpdateData('cd_grid',1,data);
		} 
		else{
			$.messager.alert("提示",data.ErrorInfo,"error");
		}
	} 
}

/*
	成交查询
*/
function get_cjcx(sPos){
	var wtcfg ={
		"funcid":"332705",
		'en_entrust_prop':'AFC,AFW',
		"position_str":"",
		'@POS':sPos,
		"funcname":'ret_cjcx'
	};
	gf_dzjy_share.setIX(wtcfg);
}

function ret_cjcx(_fromid,_funid,_flagtype,data){
	if (_funid == '5010:SIMPLE.332705'){
		var data = FormatResult(data, 1);
		if (data.ErrorCode == 0){
			if($.inArray(data.POS, pageList)==-1){
				pageList.push(data.POS);
			}
			gridUpdateData('drcj_grid',0,data);
		} 
		else{
			$.messager.alert("提示",data.ErrorInfo,"error");
		}
	} 
}

/*
	获取表格数据
*/
function getGridData(index) {
	pageList=[''];
	pageCur = 0; 
	if (index == 0) {
		get_ccgp('');
	} else if (index == 1) {
		get_wtcx('');
	} else if (index == 2) {
		get_cjcx('');
	}
}

/*
	委托查询初始化
*/
function init_wtcx(){
	pageList=[''];
	pageCur = 0; 
	get_wtcx('');
}

/*
	设置可撤委托checkbox
*/
function setCheckSta(){
	init_wtcx();
}

/*
	刷新按钮响应
*/
function refreshClick(){
	getGridData(dzjy_wt.curSwitch);
}

/*
	下一页按钮响应
*/
function setNextPage() {
	if (pageCur < (pageList.length - 1)) {
		pageCur += 1;
		if (dzjy_wt.curSwitch == 0) {
			get_ccgp(pageList[pageCur]);
		}
		else if(dzjy_wt.curSwitch == 1){
			get_wtcx(pageList[pageCur]);
		}
		else if(dzjy_wt.curSwitch == 2){
			get_cjcx(pageList[pageCur]);
		}
	}
}

/*
	上一页按钮响应
*/
function setPrePage() {
	if (pageCur > 0) {
		pageCur -= 1;
		if (dzjy_wt.curSwitch == 0) {
			get_ccgp(pageList[pageCur]);
		}
		else if(dzjy_wt.curSwitch == 1){
			get_wtcx(pageList[pageCur]);
		}
		else if(dzjy_wt.curSwitch == 2){
			get_cjcx(pageList[pageCur]);
		}
	}
}
/*
	撤单按钮响应
*/
function cdClick(){
	var selrows=$("#cd_grid").datagrid("getChecked");
	cdOperation(selrows);
}

/*
	双击表格撤单
*/
function onDblClickRow(rowIndex, rowData) {
	singleCdOperation(rowData);
}

/*
	双击表格查询股票行情
*/
function onDblClickGetHq(rowIndex, rowData) {
	var zqdm = rowData.stock_code;
	$('#zqdm').val(zqdm);
	dzjy_wt.preZqdm = zqdm;
	get_stockhq(zqdm);
}


/*
	撤单操作
*/
function cdOperation(selrows) {
	if (selrows.length == 0) {
		$.messager.alert('提示',"请至少选择一笔需要撤单的委托!",'info');
		return;
	} else if (selrows.length == 1) {
		singleCdOperation(selrows[0]);
	} else if (selrows.length > 1) {
		multiplCdOperation(selrows);
	}
}

/*
	单笔撤单
*/
function singleCdOperation(selrow){
	var wtbh = selrow.entrust_no;
	if (wtbh==nullGridStr) return;
	var s = '';
	s += '<div class="confirm_txt">';
	s += '<p>操作类别:撤单</p>';
	s += '<p>委托编号:' + selrow.entrust_no + '</p>';
	s += '<p>证券代码:' + selrow.stock_code + '</p>';
	s += '<p>证券名称:' + selrow.stock_name + '</p>';
	s += '<p>买卖方向:' + formatMmfx(selrow.entrust_bs) + '</p>';
	s += '</div>';
	$.messager.confirm('委托确认', s, function(r) {
		if (r) {
			get_cd(selrow.entrust_no);
		}
	});
}

/*
	单笔撤单请求
*/
function get_cd(wt_no){
	var wtcfg ={
		"funcid":"332703",
		'entrust_no':wt_no,
		"funcname":'ret_cd'
	};
	gf_dzjy_share.setIX(wtcfg);
}

function ret_cd(_fromid, _funid, _flagtype, data) {
	if (_funid == '5010:SIMPLE.332703') {
		try {
			var data = FormatResult(data, 1);
			if (data.ErrorCode == 0) {
				$.messager.alert("提示", "撤单成功！","info");
				init_wtcx();
			} else {
				alert(data.ErrorInfo.substr(5));
			}

		} catch (e) {
			var temp_list =data.split('"');
			var tslabel = temp_list[1].substr(5)
			alert(tslabel);
		}
	}
}

/*
	多笔撤单
*/
function multiplCdOperation(selrows) {
	var s = '';
	s += '<p>共有' + selrows.length + '笔委托需要撤单，请确认！</p>';
	$.messager.confirm('提示', s, function(r) {
			if (r) {
				multipleCdSelRows =selrows;
				get_multipleCd();
		}
	});
}

/*
	多笔撤单请求
*/
function get_multipleCd(){
	var wtcfg ={
		"funcid":"332703",
		'entrust_no':multipleCdSelRows[multipleCdCur].entrust_no,
		"funcname":'ret_multipleCd'
	};
	gf_dzjy_share.setIX(wtcfg);
}

function ret_multipleCd(_fromid, _funid, _flagtype, data) {
	if (_funid == '5010:SIMPLE.332703') {
		multipleCdCur+=1;
		try {
			var data = FormatResult(data, 1);
			if (data.ErrorCode == 0) {
				multipleCdCount +=1;
			} else {
			}

		} catch (e) {
		}
		if(multipleCdCur>(multipleCdSelRows.length-1)){
			multipleCdSelRows ={};
			multipleCdCur =0;
			$.messager.alert("提示", "共有"+multipleCdCount+"笔撤单成功！","info");
			multipleCdCount =0;
			init_wtcx();
		}
		else{
			get_multipleCd();
		}
	}
}