mui.init();

mui.ready(function() {
	if(!mui.os.plus) {
		getFlowList();
	}
});

mui.plusReady(function() {
	getFlowList();
});

var url = API.API_URL();

var vm = new Vue({
	el: '#flowList', //bodydiv
	data: {
		fList: [],
		ftypeList: []
	},
	methods: {
		getTUserName: function(tmodel) {
			return "usersName" + tmodel.nextTmodelId;
		},
		getTUserId: function(tmodel) {
			return "users" + tmodel.nextTmodelId;
		},
	}
});

function getFlowList() {

	var state = app.getState(); //获取登陆信息
	var staffId = state.user.useId;
	var unitId = state.user.unitId;
	var groupId = state.user.groupid;
	mui.ajax(url, {

		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		data: {
			'serviceId': 'bpm_20150319001GetFlowList',
			'params': '{staffId:"' + staffId + '",unitid:"' + unitId + '"}'
		},
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Accept': 'application/json'
		},
		success: function(data) {
			//服务器返回响应
			console.log("流程列表信息11:" + JSON.stringify(data));
			if(data.returnCode == "0") {

				var returnParams = data.returnParams;
				vm.fList = returnParams.fList;
			
				for(var i=0; i<vm.fList.length; i++){
					vm.fList[i].model_picture = '../../images/modelPicture/' + vm.fList[i].model_picture;
					//console.log(vm.fList[i].model_picture);
				}
				vm.ftypeList = returnParams.ftypeList;
			} else {
				mui.toast("获取流程信息错误");
			}
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(xhr + "========" + type + "===========" + errorThrown);
		}
	});
}

function to_strt(flow) {
	//触发子窗口变更新闻详情
	var modelId = flow.modelId;
	var modelName = flow.modelName;
	var page = "dynamic/flow_start.html";
	mui.openWindow({
		createNew: true,
		url: page,
		extras: {
			modelId: modelId,
			modelName: modelName
		}
	});
}

//document.getElementById("to_list").addEventListener('click', function() {
//
//	var page = "flow_approve_list2.html";
//	mui.openWindow({
//		url: page
//	});
//})