ruleBpmn.js 1.66 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
function cloneObj(obj) {
	var str;
	var newObj = obj.constructor === Array ? [] : {};
	if (typeof obj !== 'object') {
		return;
	} else if (JSON) {
		str = JSON.stringify(obj); //系列化对象
		newObj = JSON.parse(str); //还原
	} else {
		for (var i in obj) {
			newObj[i] = typeof obj[i] === 'object' ? cloneObj(obj[i]) : obj[i];
		}
	}
	return newObj;
}
/**
 * 规则流 程中保存 大数据
 */
const state = {
	constaintsItem: [],
	projectCode: '',
	cond: {},
	addResult: {},
	treeData: [],
	nodeList: [],
	rp: {},
	graph: null,
	tagsArry: [] //首页页签
}
const mutations = {
	SETCValue: (state, data) => {
		let itemList = state.constaintsItem;
		if (itemList.length > 0) {
			var index = itemList.findIndex(item => item.id == data.id)
			if (index > -1) {
				itemList[index] = cloneObj(data)
			} else {
				state.constaintsItem.push(data)
			}
		} else {
			state.constaintsItem.push(data)
		}
	},
	DELCValue: (state, data) => {
		state.constaintsItem = data;
	},
	setProjectCode: (state, data) => {
		state.projectCode = data;
	},
	setCond: (state, data) => {
		state.cond = data
	},
	setaddResult: (state, data) => {
		state.addResult = data
	},
	settreeData: (state, data) => {
		state.treeData = data
	},
	getnodeList: (state, data) => {
		state.nodeList = data
	},
	getRp: (state, data) => {
		state.rp = data
	},
	getGraph: (state, data) => {
		state.graph = data
	},
	// 添加标签
	setTagsArry: (state, data) => {
		state.tagsArry = data
	},
	//  删除当前的tag
	delTagsArry: (state, data) => {
		state.tagsArry.map((item, index) => {
			if (item.path.indexOf(data) > -1) {
				state.tagsArry.splice(index, 1)
			}
		})
	},
}
export default {
	state,
	mutations
}