import Vue from 'vue'
import Vuex from 'vuex'


const state = {
	tab_ids: [{
			"name": "工艺路线",
			"index": "roke.routing",
			"function_id": 13,
			"general_order": true,
			"icon": "../../static/roke.routing.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "生产订单",
			"index": "roke.production.order",
			"function_id": 16,
			"general_order": true,
			"icon": "../../static/roke.production.order.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "生产任务",
			"index": "roke.production.task",
			"function_id": 17,
			"general_order": true,
			"icon": "../../static/roke.production.task.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "文档管理",
			"index": "wendangguanli",
			"function_id": 38,
			"general_order": false,
			"icon": "../../static/wendangguanli.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "仓库调拨单",
			"index": "roke.mes.stock.picking",
			"function_id": 56,
			"general_order": true,
			"icon": "../../static/roke.mes.stock.picking.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "采购订单",
			"index": "roke.purchase.order",
			"function_id": 57,
			"general_order": true,
			"icon": "../../static/roke.purchase.order.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "销售订单",
			"index": "roke.sale.order",
			"function_id": 58,
			"general_order": true,
			"icon": "../../static/roke.sale.order.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "设备运行记录",
			"index": "roke.mes.equipemnt.record",
			"function_id": 61,
			"general_order": true,
			"icon": "../../static/roke.mes.equipemnt.record.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "条码打包",
			"index": "roke.barcode.package",
			"function_id": 87,
			"general_order": true,
			"icon": "../../static/roke.barcode.package.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "文档管理",
			"index": "wendangguanli",
			"function_id": 38,
			"general_order": false,
			"icon": "../../static/wendangguanli.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "仓库调拨单",
			"index": "roke.mes.stock.picking",
			"function_id": 56,
			"general_order": true,
			"icon": "../../static/roke.mes.stock.picking.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "采购订单",
			"index": "roke.purchase.order",
			"function_id": 57,
			"general_order": true,
			"icon": "../../static/roke.purchase.order.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
		{
			"name": "销售订单",
			"index": "roke.sale.order",
			"function_id": 58,
			"general_order": true,
			"icon": "../../static/roke.sale.order.png",
			"default": false,
			"custom_report": false,
			"report_url": "",
			"table": false
		},
	],
	showTab: false,
}
const mutations = {
	SHOW_TAB(state, tab_ids) {
		if (tab_ids && tab_ids.length > 0) {
			state.tab_ids = tab_ids;
			state.showTab = true;
		} else {
			state.showTab = false;
		}
	},
	OFF_TAB(state) {
		state.showTab = false;
		state.tab_ids = [];
	}
}

const actions = {
	scanShowTab({
		commit,
		dispatch,
		getters,
		state
	}, tab_ids = []) {
		commit('SHOW_TAB', tab_ids);
	},
	offTab({
		commit,
	}) {
		commit('OFF_TAB');
	}
}



const getters = {
	tab_ids: state => state.tab_ids,
	showTab: state => state.showTab,
}



export default {
	state,
	mutations,
	actions,
	getters
}