Files
ipms-sjy-ui/src/views/crm/business/status/index.vue

151 lines
4.0 KiB
Vue
Raw Normal View History

2023-11-24 14:21:21 +08:00
<template>
<doc-alert title="【商机】商机管理、商机状态" url="https://doc.iocoder.cn/crm/business/" />
<doc-alert title="【通用】数据权限" url="https://doc.iocoder.cn/crm/permission/" />
2023-11-24 14:21:21 +08:00
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item>
<el-button
type="primary"
plain
@click="openForm('create')"
2024-02-21 21:13:30 +08:00
v-hasPermi="['crm:business-status:create']"
2023-11-24 14:21:21 +08:00
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
2024-02-21 21:13:30 +08:00
<el-table-column label="状态组名" align="center" prop="name" />
<el-table-column label="应用部门" align="center" prop="deptNames">
<template #default="scope">
<span v-if="scope.row?.deptNames?.length > 0">
{{ scope.row.deptNames.join(' ') }}
</span>
<span v-else>全公司</span>
</template>
</el-table-column>
2023-11-24 14:21:21 +08:00
<el-table-column label="创建人" align="center" prop="creator" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
2024-02-21 21:13:30 +08:00
v-hasPermi="['crm:business-status:update']"
2023-11-24 14:21:21 +08:00
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
2024-02-21 21:13:30 +08:00
v-hasPermi="['crm:business-status:delete']"
2023-11-24 14:21:21 +08:00
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
2024-02-21 21:13:30 +08:00
<BusinessStatusForm ref="formRef" @success="getList" />
2023-11-24 14:21:21 +08:00
</template>
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
2024-02-21 21:13:30 +08:00
import * as BusinessStatusApi from '@/api/crm/business/status'
import BusinessStatusForm from './BusinessStatusForm.vue'
import { deleteBusinessStatus } from '@/api/crm/business/status'
2023-11-24 14:21:21 +08:00
2024-02-21 21:13:30 +08:00
defineOptions({ name: 'CrmBusinessStatus' })
2023-11-24 14:21:21 +08:00
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const loading = ref(true) // 列表的加载中
const list = ref([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
pageNo: 1,
2023-12-01 18:57:46 +08:00
pageSize: 10
2023-11-24 14:21:21 +08:00
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
2024-02-21 21:13:30 +08:00
const data = await BusinessStatusApi.getBusinessStatusPage(queryParams)
2023-11-24 14:21:21 +08:00
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
// 删除的二次确认
await message.delConfirm()
// 发起删除
await BusinessStatusApi.deleteBusinessStatus(id)
2023-11-24 14:21:21 +08:00
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>