import conditionObjectBase from "./condition-chat-class.js"

export default {
	...conditionObjectBase,
	dependentKeys: ['chatGradeId', 'chatTarget'],
	key: 'chatClassIds',
	title: '班级',
	template: 'multiple',
	disableAllByForce: true,
	isDependencyReady(params) {
		// 选择发送至班级时，班级多选(这里将依赖条件设置成！=学生，即默认会班级多选，但当指定为学生时，不启动该条件)
		return params.chatGradeId && params.chatTarget != 2;
	},
	transferToEffectiveDisplayValue(val, list) {
		const safeArrayVal = Array.isArray(val) ? val : isNaN(val) ? [] : [val]
		return list.length && safeArrayVal.every(v => list.some(i => i.code == v)) ? safeArrayVal : []
	},
	codeEquals(codeL, codeR) {
		return codeL?.toString() == codeR?.toString()
	}
}
