// 沙盘
import { configOpt } from '@/views/sandbox_manage/common/toolConfig';

const sand = {
	namespaced: true,
	state: () => ({
		initConfig: {
			...configOpt
		},//默认工具栏配置
		DisableText: true,// 禁用文本设置
		DisableLine: true, //禁用线条设置
		DisableBorder: true, //禁用线框设置
		selectCell: null,
	}),
  mutations: {
		/* 节点选中 toolbar设置状态 */
		SET_SELECT_STATUS(state,payload) {
			switch(payload.key) {
				case 'rect':
					state.DisableText = false; 
					state.DisableLine = true; 
					state.DisableBorder = false;
					state.initConfig = {
						...configOpt,
						...payload.options
					}
					break;
				case 'date':
					state.DisableText = false; 
					state.DisableLine = true;
					state.DisableBorder = false; 
					state.initConfig = {
						...configOpt,
						...payload.options
					}
					break;
				case 'text':
					state.DisableText = false; 
					state.DisableLine = true; 
					state.DisableBorder = true;
					state.initConfig = {
						...configOpt,
						...payload.options
					}
					break;
				case'line':
					state.DisableText = true; 
					state.DisableLine = false; 
					state.DisableBorder = true; 
					state.initConfig = {
						...configOpt,
						...payload.options
					}
					break;
				default:
					state.DisableText = true; 
					state.DisableLine = true; 
					state.DisableBorder = true;
					break;
			}
		},

		/* 设置选中节点 */
		SET_SELECT_CELL(state,payload) {
			state.selectCell = payload;
		},

		/* 设置加粗样式 */
		SET_BOLD_STYLE(state,{attr,val}) {
			state.initConfig.text.fontWeight = val;
			state.selectCell.attr(`${attr}`,val);
		}

	},
  actions: {
		
	},
  getters: {

	}
}

export default sand;