|  | @@ -1,71 +1,192 @@
 | 
	
		
			
				|  |  |  <template>
 | 
	
		
			
				|  |  | -  <ContentWrap>
 | 
	
		
			
				|  |  | -    <!-- 列表 -->
 | 
	
		
			
				|  |  | -    <XTable @register="registerTable">
 | 
	
		
			
				|  |  | -      <template #toolbar_buttons>
 | 
	
		
			
				|  |  | -        <!-- 操作:新增 -->
 | 
	
		
			
				|  |  | -        <XButton
 | 
	
		
			
				|  |  | -          type="primary"
 | 
	
		
			
				|  |  | -          preIcon="ep:zoom-in"
 | 
	
		
			
				|  |  | -          :title="t('action.add')"
 | 
	
		
			
				|  |  | -          v-hasPermi="['system:post:create']"
 | 
	
		
			
				|  |  | -          @click="openModal('create')"
 | 
	
		
			
				|  |  | +  <content-wrap>
 | 
	
		
			
				|  |  | +    <!-- 搜索工作栏 -->
 | 
	
		
			
				|  |  | +    <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
 | 
	
		
			
				|  |  | +      <el-form-item label="岗位名称" prop="name">
 | 
	
		
			
				|  |  | +        <el-input
 | 
	
		
			
				|  |  | +          v-model="queryParams.name"
 | 
	
		
			
				|  |  | +          placeholder="请输入岗位名称"
 | 
	
		
			
				|  |  | +          clearable
 | 
	
		
			
				|  |  | +          @keyup.enter="handleQuery"
 | 
	
		
			
				|  |  | +        />
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +      <el-form-item label="岗位编码" prop="code">
 | 
	
		
			
				|  |  | +        <el-input
 | 
	
		
			
				|  |  | +          v-model="queryParams.code"
 | 
	
		
			
				|  |  | +          placeholder="请输入岗位编码"
 | 
	
		
			
				|  |  | +          clearable
 | 
	
		
			
				|  |  | +          @keyup.enter="handleQuery"
 | 
	
		
			
				|  |  |          />
 | 
	
		
			
				|  |  | -        <!-- 操作:导出 -->
 | 
	
		
			
				|  |  | -        <XButton
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +      <el-form-item label="状态" prop="status">
 | 
	
		
			
				|  |  | +        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
 | 
	
		
			
				|  |  | +          <el-option
 | 
	
		
			
				|  |  | +            v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
 | 
	
		
			
				|  |  | +            :key="parseInt(dict.value)"
 | 
	
		
			
				|  |  | +            :label="dict.label"
 | 
	
		
			
				|  |  | +            :value="parseInt(dict.value)"
 | 
	
		
			
				|  |  | +          />
 | 
	
		
			
				|  |  | +        </el-select>
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +      <el-form-item>
 | 
	
		
			
				|  |  | +        <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
 | 
	
		
			
				|  |  | +        <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
 | 
	
		
			
				|  |  | +        <el-button
 | 
	
		
			
				|  |  |            type="primary"
 | 
	
		
			
				|  |  | +          @click="openModal('create')"
 | 
	
		
			
				|  |  | +          v-hasPermi="['system:notice:create']"
 | 
	
		
			
				|  |  | +        >
 | 
	
		
			
				|  |  | +          <Icon icon="ep:plus" class="mr-5px" /> 新增
 | 
	
		
			
				|  |  | +        </el-button>
 | 
	
		
			
				|  |  | +        <el-button
 | 
	
		
			
				|  |  | +          type="success"
 | 
	
		
			
				|  |  |            plain
 | 
	
		
			
				|  |  | -          preIcon="ep:download"
 | 
	
		
			
				|  |  | -          :title="t('action.export')"
 | 
	
		
			
				|  |  | -          v-hasPermi="['system:post:export']"
 | 
	
		
			
				|  |  | -          @click="exportList('岗位列表.xls')"
 | 
	
		
			
				|  |  | -        />
 | 
	
		
			
				|  |  | -      </template>
 | 
	
		
			
				|  |  | -      <template #actionbtns_default="{ row }">
 | 
	
		
			
				|  |  | -        <!-- 操作:修改 -->
 | 
	
		
			
				|  |  | -        <XTextButton
 | 
	
		
			
				|  |  | -          preIcon="ep:edit"
 | 
	
		
			
				|  |  | -          :title="t('action.edit')"
 | 
	
		
			
				|  |  | -          v-hasPermi="['system:post:update']"
 | 
	
		
			
				|  |  | -          @click="openModal('update', row?.id)"
 | 
	
		
			
				|  |  | -        />
 | 
	
		
			
				|  |  | -        <!-- 操作:详情 -->
 | 
	
		
			
				|  |  | -        <XTextButton
 | 
	
		
			
				|  |  | -          preIcon="ep:view"
 | 
	
		
			
				|  |  | -          :title="t('action.detail')"
 | 
	
		
			
				|  |  | -          v-hasPermi="['system:post:query']"
 | 
	
		
			
				|  |  | -          @click="openModal('detail', row?.id)"
 | 
	
		
			
				|  |  | -        />
 | 
	
		
			
				|  |  | -        <!-- 操作:删除 -->
 | 
	
		
			
				|  |  | -        <XTextButton
 | 
	
		
			
				|  |  | -          preIcon="ep:delete"
 | 
	
		
			
				|  |  | -          :title="t('action.delete')"
 | 
	
		
			
				|  |  | -          v-hasPermi="['system:post:delete']"
 | 
	
		
			
				|  |  | -          @click="deleteData(row?.id)"
 | 
	
		
			
				|  |  | -        />
 | 
	
		
			
				|  |  | -      </template>
 | 
	
		
			
				|  |  | -    </XTable>
 | 
	
		
			
				|  |  | -  </ContentWrap>
 | 
	
		
			
				|  |  | -  <!-- 表单弹窗:添加/修改/详情 -->
 | 
	
		
			
				|  |  | -  <PostForm ref="modalRef" @success="reload()" />
 | 
	
		
			
				|  |  | +          @click="handleExport"
 | 
	
		
			
				|  |  | +          :loading="exportLoading"
 | 
	
		
			
				|  |  | +          v-hasPermi="['infra:config:export']"
 | 
	
		
			
				|  |  | +        >
 | 
	
		
			
				|  |  | +          <Icon icon="ep:download" class="mr-5px" /> 导出
 | 
	
		
			
				|  |  | +        </el-button>
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +    </el-form>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <!-- 列表 -->
 | 
	
		
			
				|  |  | +    <el-table v-loading="loading" :data="list" align="center">
 | 
	
		
			
				|  |  | +      <el-table-column label="岗位编号" align="center" prop="id" />
 | 
	
		
			
				|  |  | +      <el-table-column label="岗位名称" align="center" prop="name" />
 | 
	
		
			
				|  |  | +      <el-table-column label="岗位编码" align="center" prop="code" />
 | 
	
		
			
				|  |  | +      <el-table-column label="岗位顺序" align="center" prop="sort" />
 | 
	
		
			
				|  |  | +      <el-table-column label="岗位备注" align="center" prop="remark" />
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      <el-table-column label="状态" align="center" prop="status">
 | 
	
		
			
				|  |  | +        <template #default="scope">
 | 
	
		
			
				|  |  | +          <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +      </el-table-column>
 | 
	
		
			
				|  |  | +      <el-table-column
 | 
	
		
			
				|  |  | +        label="创建时间"
 | 
	
		
			
				|  |  | +        align="center"
 | 
	
		
			
				|  |  | +        prop="createTime"
 | 
	
		
			
				|  |  | +        width="180"
 | 
	
		
			
				|  |  | +        :formatter="dateFormatter"
 | 
	
		
			
				|  |  | +      />
 | 
	
		
			
				|  |  | +      <el-table-column label="操作" align="center">
 | 
	
		
			
				|  |  | +        <template #default="scope">
 | 
	
		
			
				|  |  | +          <el-button
 | 
	
		
			
				|  |  | +            link
 | 
	
		
			
				|  |  | +            type="primary"
 | 
	
		
			
				|  |  | +            @click="openModal('update', scope.row.id)"
 | 
	
		
			
				|  |  | +            v-hasPermi="['system:post:update']"
 | 
	
		
			
				|  |  | +          >
 | 
	
		
			
				|  |  | +            编辑
 | 
	
		
			
				|  |  | +          </el-button>
 | 
	
		
			
				|  |  | +          <el-button
 | 
	
		
			
				|  |  | +            link
 | 
	
		
			
				|  |  | +            type="danger"
 | 
	
		
			
				|  |  | +            @click="handleDelete(scope.row.id)"
 | 
	
		
			
				|  |  | +            v-hasPermi="['system:post:delete']"
 | 
	
		
			
				|  |  | +          >
 | 
	
		
			
				|  |  | +            删除
 | 
	
		
			
				|  |  | +          </el-button>
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +      </el-table-column>
 | 
	
		
			
				|  |  | +    </el-table>
 | 
	
		
			
				|  |  | +    <!-- 分页 -->
 | 
	
		
			
				|  |  | +    <Pagination
 | 
	
		
			
				|  |  | +      :total="total"
 | 
	
		
			
				|  |  | +      v-model:page="queryParams.pageNo"
 | 
	
		
			
				|  |  | +      v-model:limit="queryParams.pageSize"
 | 
	
		
			
				|  |  | +      @pagination="getList"
 | 
	
		
			
				|  |  | +    />
 | 
	
		
			
				|  |  | +  </content-wrap>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  <!-- 表单弹窗:添加/修改 -->
 | 
	
		
			
				|  |  | +  <post-form ref="modalRef" @success="getList" />
 | 
	
		
			
				|  |  |  </template>
 | 
	
		
			
				|  |  | -<script setup lang="ts" name="Post">
 | 
	
		
			
				|  |  | +<script setup lang="tsx">
 | 
	
		
			
				|  |  |  import * as PostApi from '@/api/system/post'
 | 
	
		
			
				|  |  | -import { allSchemas } from './post.data'
 | 
	
		
			
				|  |  |  import PostForm from './form.vue'
 | 
	
		
			
				|  |  | +import { DICT_TYPE, getDictOptions } from '@/utils/dict'
 | 
	
		
			
				|  |  | +import { dateFormatter } from '@/utils/formatTime'
 | 
	
		
			
				|  |  | +import download from '@/utils/download'
 | 
	
		
			
				|  |  | +import { DictTag } from '@/components/DictTag'
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const message = useMessage() // 消息弹窗
 | 
	
		
			
				|  |  |  const { t } = useI18n() // 国际化
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -// 列表相关的变量
 | 
	
		
			
				|  |  | -const [registerTable, { reload, deleteData, exportList }] = useXTable({
 | 
	
		
			
				|  |  | -  allSchemas: allSchemas, // 列表配置
 | 
	
		
			
				|  |  | -  getListApi: PostApi.getPostPageApi, // 加载列表的 API
 | 
	
		
			
				|  |  | -  deleteApi: PostApi.deletePostApi, // 删除数据的 API
 | 
	
		
			
				|  |  | -  exportListApi: PostApi.exportPostApi // 导出数据的 API
 | 
	
		
			
				|  |  | +const loading = ref(true) // 列表的加载中
 | 
	
		
			
				|  |  | +const total = ref(0) // 列表的总页数
 | 
	
		
			
				|  |  | +const list = ref([]) // 列表的数据
 | 
	
		
			
				|  |  | +const queryParams = reactive({
 | 
	
		
			
				|  |  | +  code: '',
 | 
	
		
			
				|  |  | +  name: '',
 | 
	
		
			
				|  |  | +  status: undefined,
 | 
	
		
			
				|  |  | +  pageNo: 1,
 | 
	
		
			
				|  |  | +  pageSize: 100
 | 
	
		
			
				|  |  |  })
 | 
	
		
			
				|  |  | +const queryFormRef = ref() // 搜索的表单
 | 
	
		
			
				|  |  | +const exportLoading = ref(false) // 导出的加载中
 | 
	
		
			
				|  |  | +/** 查询岗位列表 */
 | 
	
		
			
				|  |  | +const getList = async () => {
 | 
	
		
			
				|  |  | +  loading.value = true
 | 
	
		
			
				|  |  | +  try {
 | 
	
		
			
				|  |  | +    const data = await PostApi.getPostPageApi(queryParams)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    list.value = data.list
 | 
	
		
			
				|  |  | +    total.value = data.total
 | 
	
		
			
				|  |  | +  } finally {
 | 
	
		
			
				|  |  | +    loading.value = false
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/** 导出按钮操作 */
 | 
	
		
			
				|  |  | +const handleExport = async () => {
 | 
	
		
			
				|  |  | +  try {
 | 
	
		
			
				|  |  | +    // 导出的二次确认
 | 
	
		
			
				|  |  | +    await message.exportConfirm()
 | 
	
		
			
				|  |  | +    // 发起导出
 | 
	
		
			
				|  |  | +    exportLoading.value = true
 | 
	
		
			
				|  |  | +    const data = await PostApi.exportPostApi(queryParams)
 | 
	
		
			
				|  |  | +    download.excel(data, '岗位列表.xls')
 | 
	
		
			
				|  |  | +  } catch {
 | 
	
		
			
				|  |  | +  } finally {
 | 
	
		
			
				|  |  | +    exportLoading.value = false
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/** 搜索按钮操作 */
 | 
	
		
			
				|  |  | +const handleQuery = () => {
 | 
	
		
			
				|  |  | +  queryParams.pageNo = 1
 | 
	
		
			
				|  |  | +  getList()
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -// 表单相关的变量
 | 
	
		
			
				|  |  | +/** 重置按钮操作 */
 | 
	
		
			
				|  |  | +const resetQuery = () => {
 | 
	
		
			
				|  |  | +  queryFormRef.value.resetFields()
 | 
	
		
			
				|  |  | +  handleQuery()
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/** 添加/修改操作 */
 | 
	
		
			
				|  |  |  const modalRef = ref()
 | 
	
		
			
				|  |  |  const openModal = (type: string, id?: number) => {
 | 
	
		
			
				|  |  |    modalRef.value.openModal(type, id)
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/** 删除按钮操作 */
 | 
	
		
			
				|  |  | +const handleDelete = async (id: number) => {
 | 
	
		
			
				|  |  | +  try {
 | 
	
		
			
				|  |  | +    // 删除的二次确认
 | 
	
		
			
				|  |  | +    await message.delConfirm()
 | 
	
		
			
				|  |  | +    // 发起删除
 | 
	
		
			
				|  |  | +    await PostApi.deletePostApi(id)
 | 
	
		
			
				|  |  | +    message.success(t('common.delSuccess'))
 | 
	
		
			
				|  |  | +    // 刷新列表
 | 
	
		
			
				|  |  | +    await getList()
 | 
	
		
			
				|  |  | +  } catch {}
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/** 初始化 **/
 | 
	
		
			
				|  |  | +onMounted(() => {
 | 
	
		
			
				|  |  | +  getList()
 | 
	
		
			
				|  |  | +})
 | 
	
		
			
				|  |  |  </script>
 |