/*
 * @Company: 沈阳信诚科技
 * @Email: html_venustar@163.com
 * @Author: Liuqiming
 * @Description: 角色管理页面配置
 * @LastEditors: Liuqiming
 * @LastEditTime: 2024-03-27 10:12:00
 * @Date: 2024-03-27 09:39:42
 */
/*
 * @Company: 沈阳信诚科技
 * @Email: html_venustar@163.com
 * @Author: Liuqiming
 * @Description: 岗位配置
 * @LastEditors: Liuqiming
 * @LastEditTime: 2024-03-06 14:09:46
 * @Date: 2024-02-04 16:56:20
 */

const handleUpdateFn = ref(null)
const handleDeleteFn = ref(null)
const handleStatusChangeFn = ref(null)


export const init = (proxy, { handleUpdate, handleDelete, handleStatusChange }) => {
  handleUpdateFn.value = handleUpdate
  handleDeleteFn.value = handleDelete
  handleStatusChangeFn.value = handleStatusChange

  // 表格筛选条件
  const searchList = ref([
    {
      label: '角色名称',
      field: 'roleName',
      searchBtn: true,
      clearable: true,
      placeholder: '请输入角色名称'
    },
  ])
  // 表格配置按钮
  const btnList = ref([
    { label: '新增角色', type: 'primary', plain: false, icon: 'Plus', met: 'handleAdd', hasPermi:'system:role:add' },
  ])
  // 表格配置项
  const tableOption = ref({
    checkbox: false, // 是否展示多选框
    index: true, // 是否展示序号
    fixed: "", // 是否将多选框及序号列固定在最左侧
    stripe: true, // 是否斑马纹表格
    border: false, // 是否表格边框
    pageHidden: false, // 是否隐藏分页
    maxHeight: '65vh'
  })
  // 表格列
  const columns = ref([
    // {
    //   label: "角色编号",
    //   prop: "roleId",
    //   minWidth: 100
    // },
    {
      label: "角色名称",
      prop: "roleName",
      minWidth: 100,
    },
    {
      label: "角色描述",
      prop: "remark",
      minWidth: 100,
    },
    {
      label: "权限字符",
      prop: "roleKey",
      minWidth: 100,
    },
    {
      label: "显示顺序",
      prop: "roleSort",
      minWidth: 100,
    },
    {
      label: "状态",
      prop: "status",
      minWidth: 100,
      slots: (row) => {
        return <el-switch v-model={row.status} active-value="0" inactive-value="1" onChange={()=>{handleStatusChangeFn.value(row)}}></el-switch>
      }
    },
    {
      label: "创建时间",
      prop: "createTime",
      sort: true,
      minWidth: 100,
      slots: (row) => {
        return <span>{ proxy.parseTime(row.createTime) }</span>
      }
    },
    {
      label: "操作",
      minWidth: 100,
      slots: (row) => {
        return (<>
          <el-button type="primary" link onClick={()=>{handleUpdateFn.value(row)}} v-hasPermi={['system:role:edit']}>修改</el-button>
          <el-button type="danger" link onClick={()=>{handleDeleteFn.value(row)}} v-hasPermi={['system:role:remove']}>删除</el-button>
        </>)
      }
    },
  ])
  // 分页配置
  const pageSet = ref({
    pageNum: 1,
    pageSize: 10,
    total:0
  })
  return {
    searchList,
    btnList,
    columns,
    pageSet,
    tableOption,
  }
}

