/*
 * @Company: 沈阳信诚科技
 * @Email: html_venustar@163.com
 * @Author: Liuqiming
 * @Description: 设备坐标设定配置
 * @LastEditors: Liuqiming
 * @LastEditTime: 2024-03-18 14:36:16
 * @Date: 2024-03-18 12:30:06
 */
const editFn = ref(null)
const saveFn = ref(null)
const cancelFn = ref(null)
export const init = ({ edit, save, cancel }) => {
  editFn.value = edit
  saveFn.value = save
  cancelFn.value = cancel
  const searchList = ref([])
  const columns = ref([
    {
      label: "设备名称",
      prop: "equipmentName",
      minWidth: 150,
      tooltip:true,
    },
    {
      label: "设定坐标（m）",
      prop: "equipmentCoordinate",
      minWidth: 150,
      tooltip:true,
      slots: (row) => {
        return row.is_edit ?
          (row.dataType === 0 ?
          <el-input-number v-model={row.equipmentCoordinate} placeholder="请输入设定坐标" size="small" max={99.99} step={0.1} precision={2} style="width:100%"></el-input-number> :
          <el-input v-model={row.equipmentCoordinate} placeholder="请输入设定坐标" size="small" style="width:100%"></el-input>)
        : <span>{row.equipmentCoordinate}</span>
      }
    },
    {
      label: "最后修改时间",
      prop: "updateTime",
      minWidth: 100,
      tooltip:true,
    },
    {
      label: "操作",
      minWidth: 150,
      slots: (row) => {
        return row.is_edit ? <>
          <el-button link type="primary" onClick={() => {saveFn.value(row)}}>保存</el-button>
          <el-button link type="primary" onClick={() => {cancelFn.value(row)}}>取消</el-button>
        </> : <el-button link type="primary" onClick={() => {editFn.value(row)}}>编辑</el-button>
      }
    },
  ])
  const tableOption = ref({
    checkbox: false, // 是否展示多选框
    index: true, // 是否展示序号
    fixed: "left", // 是否将多选框及序号列固定在最左侧
    stripe: true, // 是否斑马纹表格
    border: false, // 是否表格边框
    pageHidden: true // 是否隐藏分页
  })
  return {
    searchList,
    columns,
    tableOption
  }
}
