
const onDeleteFn = ref(null)
const onStaffingFn = ref(null)
const onModifyFn = ref(null)
const teamLeaderNameVal = ref(null)
export const init = ({ onDelete ,onStaffing ,onModify,teamLeaderNameList}) => {
  onDeleteFn.value = onDelete
  onStaffingFn.value = onStaffing
  onModifyFn.value = onModify
  teamLeaderNameVal.value = teamLeaderNameList
  const btnList = ref([
    { label: '新增', type: 'primary', icon:'Plus', met: 'handlerAdd', hasPermi:'system:team:add'},
  ])
  const columns = ref([
    {
      label: "班组",
      prop: "teamName",
      minWidth: 100
    },
    {
      label: "班组长",
      prop: "teamLeaderName",
      minWidth: 100
    },
    {
      label: "操作",
      minWidth: 100,
      slots: (row) => {
        return (<>
                <el-button type="primary" v-hasPermi={['system:teamUser:add']} link  onClick={() => onStaffingFn.value(row)}>人员配置</el-button>
                <el-button type="primary" v-hasPermi={['system:team:edit']} link  onClick={() => onModifyFn.value(row)}>编辑</el-button>
                <el-button type="danger" v-hasPermi={['system:team:remove']} link  onClick={() => onDeleteFn.value(row)}>删除</el-button>
               </>)
               }
    },
  ])
  const pageSet = ref({
    pageNum: 1,
    pageSize: 10,
    total:0
  })
    // 表格配置项目
    const tableOption = ref({
      checkbox: false, // 是否展示多选框
      index: false, // 是否展示序号
      fixed: "left", // 是否将多选框及序号列固定在最左侧
      stripe: true, // 是否斑马纹表格
      border: false, // 是否表格边框
      pageHidden: true // 是否隐藏分页
    })
  // form表单组件
  const fieldList = ref([
    {
      label: '班组',
      field: 'teamName',
      width:'320px',
      rules: [{required: true,message: '请输入班组信息',trigger: 'blur'}],
      placeholder: '请输入'
    },
    {
      label: '班组长',
      field: 'teamLeaderId',
      type: 'select',
      filterable: true, 
      width:'320px',
      clearable: true,
      rules: [{required: true,message: '请选择班组长',trigger: 'change'}],
      placeholder: '请选择',
      options: teamLeaderNameVal.value
    },
  ])
    // 表单配置项目
    const formOption = ref({
      inline: false,  // 是否行内模式表单
      labelWidth: '120px',  // 表单标签宽度
      scrollToError: true,  // 自动滚动到校验失败的第一项
      btnCenter: true, // 表单的查询提交等按钮是否展示在中间，弹窗通用展示中间
      btn: ['submit', 'cancel'] // 按钮展示组
    })


  return {
    btnList,
    columns,
    pageSet,
    tableOption,
    fieldList,
    formOption,
  }
}
