class CreateEducodeSalesRolePermissions < ActiveRecord::Migration[5.2] def change create_table :educode_sales_role_permissions do |t| t.references :role t.references :permission t.timestamps end if EducodeSales::Permission.last.nil? #绩效考核权限 EducodeSales::Permission.find_or_create_by(name: '查看人员任务列表', subject: 'AssessmentsSetting', action: 'show', clazz: 'assessments_setting', position: '191') EducodeSales::Permission.find_or_create_by(name: '添加人员任务列表', subject: 'AssessmentsSetting', action: 'create', clazz: 'assessments_setting', position: '192') EducodeSales::Permission.find_or_create_by(name: '编辑人员任务列表', subject: 'AssessmentsSetting', action: 'edit', clazz: 'assessments_setting', position: '193') EducodeSales::Permission.find_or_create_by(name: '删除人员任务列表', subject: 'AssessmentsSetting', action: 'destroy', clazz: 'assessments_setting', position: '194') EducodeSales::Permission.find_or_create_by(name: '查看指标完成情况', subject: 'AssessmentsSetting', action: 'show_result', clazz: 'assessments_setting', position: '195') EducodeSales::Permission.find_or_create_by(name: '导出指标完成情况', subject: 'AssessmentsSetting', action: 'export_result', clazz: 'assessments_setting', position: '196') #导出商机 EducodeSales::Permission.create(name: '导出商机', subject: 'Business', action: 'export_business', clazz: 'business', position: '11') #附件管理权限 EducodeSales::Permission.create(name: '查看附件', subject: 'Business', action: 'show_file', clazz: 'business', position: '11') EducodeSales::Permission.create(name: '上传附件', subject: 'Business', action: 'upload_file', clazz: 'business', position: '11') EducodeSales::Permission.create(name: '下载附件', subject: 'Business', action: 'download_file', clazz: 'business', position: '11') EducodeSales::Permission.create(name: '删除附件', subject: 'Business', action: 'delete_file', clazz: 'business', position: '11') #商机个人权限 EducodeSales::Permission.create(name: '编辑商机(本人商机)', subject: 'Business', action: 'self_edit_business', clazz: 'business', position: '5') EducodeSales::Permission.create(name: '添加跟进记录(本人商机)', subject: 'Business', action: 'self_add_follow', clazz: 'business', position: '8') EducodeSales::Permission.create(name: '编辑跟进记录(本人创建)', subject: 'Business', action: 'self_edit_follow', clazz: 'business', position: '9') EducodeSales::Permission.create(name: '删除跟进记录(本人创建)', subject: 'Business', action: 'self_delete_follow', clazz: 'business', position: '10') EducodeSales::Permission.create(name: '合并商机', subject: 'Business', action: 'merge_business', clazz: 'business', position: '12') EducodeSales::Permission.create(name: '专项管理商机', subject: 'Business', action: 'special', clazz: 'business', position: '13') EducodeSales::Permission.create(name: '区域管理商机', subject: 'Business', action: 'area_manage', clazz: 'business', position: '14') #回款管理权限 EducodeSales::Permission.create(name: '查看回款列表', subject: 'MoneyPlan', action: 'read', clazz: 'money_plan', position: '15') #客户管理权限 EducodeSales::Permission.create(name: '查看客户', subject: 'Customer', action: 'read', clazz: 'customer') EducodeSales::Permission.create(name: '添加客户', subject: 'Customer', action: 'create', clazz: 'customer') EducodeSales::Permission.create(name: '编辑客户', subject: 'Customer', action: 'update', clazz: 'customer') EducodeSales::Permission.create(name: '分配/移交', subject: 'Customer', action: 'give', clazz: 'customer') EducodeSales::Permission.create(name: '查看部门', subject: 'Customer', action: 'read_department', clazz: 'customer') EducodeSales::Permission.create(name: '添加部门', subject: 'Customer', action: 'create_department', clazz: 'customer') EducodeSales::Permission.create(name: '编辑部门', subject: 'Customer', action: 'update_department', clazz: 'customer') EducodeSales::Permission.create(name: '查看跟进记录', subject: 'Customer', action: 'read_follow', clazz: 'customer') EducodeSales::Permission.create(name: '添加跟进记录', subject: 'Customer', action: 'create_follow', clazz: 'customer') EducodeSales::Permission.create(name: '编辑跟进记录', subject: 'Customer', action: 'update_follow', clazz: 'customer') EducodeSales::Permission.create(name: '删除跟进记录', subject: 'Customer', action: 'destroy_follow', clazz: 'customer') EducodeSales::Permission.create(name: '导出', subject: 'Customer', action: 'export', clazz: 'customer') EducodeSales::Permission.create(name: '批量导入修改客户类型', subject: 'Customer', action: 'modify_school_tag', clazz: 'customer') EducodeSales::Permission.create(name: '查看数据', subject: 'SaleTrend', action: 'trends', clazz: 'market') EducodeSales::Permission.create(name: '编辑目标', subject: 'SaleTrend', action: 'sale_trends', clazz: 'market') EducodeSales::Permission.create(name: '查看数据', subject: 'Staff', action: 'sales', clazz: 'sale_job') EducodeSales::Permission.create(name: '查看数据', subject: 'Business', action: 'read', clazz: 'business') EducodeSales::Permission.create(name: '添加商机', subject: 'Business', action: 'create', clazz: 'business') EducodeSales::Permission.create(name: '编辑商机', subject: 'Business', action: 'update', clazz: 'business') EducodeSales::Permission.create(name: '删除商机', subject: 'Business', action: 'destroy', clazz: 'business') EducodeSales::Permission.create(name: '查看跟进记录', subject: 'Business', action: 'follow', clazz: 'business') EducodeSales::Permission.create(name: '添加跟进记录', subject: 'Business', action: 'add_follow', clazz: 'business') EducodeSales::Permission.create(name: '编辑跟进记录', subject: 'Business', action: 'update_follow', clazz: 'business') EducodeSales::Permission.create(name: '删除跟进记录', subject: 'Business', action: 'destroy_follow', clazz: 'business') EducodeSales::Permission.create(name: '查看计划', subject: 'SalePlan', action: 'read', clazz: 'sale_plan') EducodeSales::Permission.create(name: '添加计划', subject: 'SalePlan', action: 'create', clazz: 'sale_plan') EducodeSales::Permission.create(name: '编辑计划', subject: 'SalePlan', action: 'update', clazz: 'sale_plan') EducodeSales::Permission.create(name: '删除计划', subject: 'SalePlan', action: 'destroy', clazz: 'sale_plan') EducodeSales::Permission.create(name: '审查报告', subject: 'SaleReport', action: 'audit', clazz: 'sale_plan') EducodeSales::Permission.create(name: '填写大区意见', subject: 'SaleReport', action: 'level1_audit', clazz: 'sale_plan') EducodeSales::Permission.create(name: '填写总监意见', subject: 'SaleReport', action: 'level2_audit', clazz: 'sale_plan') EducodeSales::Permission.create(name: '填写副总意见', subject: 'SaleReport', action: 'level3_audit', clazz: 'sale_plan') EducodeSales::Permission.create(name: '查看渠道', subject: 'Place', action: 'read', clazz: 'place') EducodeSales::Permission.create(name: '添加渠道', subject: 'Place', action: 'create', clazz: 'place') EducodeSales::Permission.create(name: '编辑渠道', subject: 'Place', action: 'update', clazz: 'place') EducodeSales::Permission.create(name: '删除渠道', subject: 'Place', action: 'destroy', clazz: 'place') EducodeSales::Permission.create(name: '查看数据', subject: 'OperationTrend', action: 'read', clazz: 'operation') EducodeSales::Permission.create(name: '编辑目标', subject: 'OperationTrend', action: 'update', clazz: 'operation') EducodeSales::Permission.create(name: '运营分工', subject: 'Staff', action: 'operations', clazz: 'operation_job') EducodeSales::Permission.create(name: '查看教师', subject: 'Teacher', action: 'read', clazz: 'teacher') EducodeSales::Permission.create(name: '添加教师', subject: 'Teacher', action: 'create', clazz: 'teacher') EducodeSales::Permission.create(name: '编辑教师', subject: 'Teacher', action: 'update', clazz: 'teacher') EducodeSales::Permission.create(name: '删除教师', subject: 'Teacher', action: 'destroy', clazz: 'teacher') EducodeSales::Permission.create(name: '查看跟进记录', subject: 'TeacherFollow', action: 'read', clazz: 'teacher') EducodeSales::Permission.create(name: '添加跟进记录', subject: 'TeacherFollow', action: 'create', clazz: 'teacher') EducodeSales::Permission.create(name: '编辑跟进记录', subject: 'TeacherFollow', action: 'update', clazz: 'teacher') EducodeSales::Permission.create(name: '删除跟进记录', subject: 'TeacherFollow', action: 'destroy', clazz: 'teacher') EducodeSales::Permission.create(name: '查看计划', subject: 'OperationPlan', action: 'read', clazz: 'operation_plan') EducodeSales::Permission.create(name: '添加计划', subject: 'OperationPlan', action: 'create', clazz: 'operation_plan') EducodeSales::Permission.create(name: '编辑计划', subject: 'OperationPlan', action: 'update', clazz: 'operation_plan') EducodeSales::Permission.create(name: '删除计划', subject: 'OperationPlan', action: 'destroy', clazz: 'operation_plan') EducodeSales::Permission.create(name: '审查报告', subject: 'OperationReport', action: 'audit', clazz: 'operation_plan') EducodeSales::Permission.create(name: '填写大区意见', subject: 'OperationReport', action: 'level1_audit', clazz: 'operation_plan') EducodeSales::Permission.create(name: '填写总监意见', subject: 'OperationReport', action: 'level2_audit', clazz: 'operation_plan') EducodeSales::Permission.create(name: '填写副总意见', subject: 'OperationReport', action: 'level3_audit', clazz: 'operation_plan') EducodeSales::Permission.create(name: '查看活动', subject: 'Activity', action: 'read', clazz: 'activity') EducodeSales::Permission.create(name: '添加活动', subject: 'Activity', action: 'create', clazz: 'activity') EducodeSales::Permission.create(name: '编辑活动', subject: 'Activity', action: 'update', clazz: 'activity') EducodeSales::Permission.create(name: '删除活动', subject: 'Activity', action: 'destroy', clazz: 'activity') # EducodeSales::Permission.create(name: '查看方案', subject: 'Idea', action: 'read', clazz: 'idea') # EducodeSales::Permission.create(name: '添加方案', subject: 'Idea', action: 'create', clazz: 'idea') # EducodeSales::Permission.create(name: '编辑方案', subject: 'Idea', action: 'update', clazz: 'idea') # EducodeSales::Permission.create(name: '移除方案', subject: 'Idea', action: 'destroy', clazz: 'idea') # EducodeSales::Permission.create(name: '恢复方案', subject: 'Idea', action: 'recycle', clazz: 'idea') # EducodeSales::Permission.create(name: '查看历史记录', subject: 'Idea', action: 'read_history', clazz: 'idea') end end end