

<script setup>
import { reactive, onMounted, watch, ref } from "vue";
import {
  listPost,
  addPost,
  delPost,
  getPost,
  updatePost,
} from "./api";
const { proxy } = getCurrentInstance();
import { getCurrentInstance } from "vue";
import { baseModelOptions, baseFilterOptions } from "./options";
const table = ref();
const state = reactive({
  baseModelOptions: baseModelOptions(),
  baseFilterOptions: baseFilterOptions(),
  columnCount: 1,
  title: "",
  baseModelName: "",
  editBtnName: "",
  delBtnName: "",
  primaryKey: "postId",
  deleteKey: "id",
  getTableFn: listPost,
  addFn: addPost,
  editFn: updatePost,
  deleteFn: delPost,
  detailFn: getPost,
  showEditBtn: true,
  showDeleteBtn: true,
  permission: {
    //菜单管理中添加权限
    add: "system:post:add",
    edit: "system:post:edit",
    delete: "system:post:remove",
    detail: "system:post:query",
  },
  showLoading: false,
  pageInfo: { total: 0, base: { limit: 8, current: 1 } },
  deptOptions: [],
  baseQuery: {},
  showPassword: false,
  pasData: [],
  showFilter: true,
  pswTitle: "",
  columns: [
    { key: 1, label: '岗位编号', visible: true },
    // { key: 2, label: '岗位编码', visible: true },
    { key: 3, label: '岗位名称', visible: true },
    { key: 4, label: '状态', visible: true },
    { key: 5, label: '创建时间', visible: true },
  ],
  beforeSubmit: (res) => {
    res.postCode = proxy.$util.getUUID();
  },
});
const sys_normal_disable = [
  { label: "正常", value: "0" },
  { label: "停用", value: "1" },
];
</script>
<template>
  <div class="app-container">
    <BaseTablePage :tableOptions="state" ref="table">
      <template v-slot:column>
        <el-table-column v-if="state.columns[0].visible" label="岗位编号" align="center" prop="postId" />
        <!-- <el-table-column v-if="state.columns[1].visible" label="岗位编码" align="center" prop="postCode" /> -->
        <el-table-column v-if="state.columns[1].visible" label="岗位名称" align="center" prop="postName" />
        <!-- <el-table-column label="岗位排序" align="center" prop="postSort" /> -->
        <el-table-column v-if="state.columns[2].visible" label="状态" align="center" prop="status">
          <template #default="scope">
            <dict-tag :options="sys_normal_disable" :value="scope.row.status" />
          </template>
        </el-table-column>
        <el-table-column
          label="创建时间"
          align="center"
          v-if="state.columns[3].visible"
          prop="createTime"
          width="180"
        >
          <template #default="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>
      </template>
      <template #control="baseScope">
        <el-table-column label="操作" width="350">
          <template #default="scope">
            <el-button
              plain
              type="text"
              icon="Edit"
              @click="baseScope.handleEdit(scope.$index, scope.row)"
              v-hasPermi="['system:post:edit']"
              >修改</el-button
            >
            <el-button
              plain
              type="text"
              icon="Delete"
              @click="baseScope.deleteTableData(scope.$index, scope.row)"
              v-hasPermi="['system:post:remove']"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </template>
    </BaseTablePage>
  </div>
</template>
