✨ feat(mes): 更新班组表单和成员列表组件逻辑
优化班组表单的弹窗标题逻辑,支持不同表单类型的动态标题显示。调整成员列表组件,确保操作按钮仅在编辑模式下可见。简化消息提示内容,提升用户体验。pull/871/MERGE
parent
e0238243aa
commit
f133e4f5c5
|
|
@ -59,7 +59,7 @@
|
||||||
<el-button v-if="!isDetail" @click="submitForm" type="primary" :disabled="formLoading">
|
<el-button v-if="!isDetail" @click="submitForm" type="primary" :disabled="formLoading">
|
||||||
确 定
|
确 定
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button @click="dialogVisible = false">关 闭</el-button>
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -72,16 +72,23 @@ import { MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
|
||||||
import CalTeamMemberList from './CalTeamMemberList.vue'
|
import CalTeamMemberList from './CalTeamMemberList.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'CalTeamForm' })
|
defineOptions({ name: 'CalTeamForm' })
|
||||||
|
const emit = defineEmits(['success'])
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
const dialogTitle = ref('') // 弹窗的标题
|
|
||||||
const formLoading = ref(false) // 表单的加载中
|
const formLoading = ref(false) // 表单的加载中
|
||||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改;detail - 详情
|
||||||
const activeTab = ref('member') // 当前激活的资源 Tab
|
const activeTab = ref('member') // 当前激活的资源 Tab
|
||||||
const isDetail = computed(() => formType.value === 'detail') // 是否详情模式(只读)
|
const isDetail = computed(() => formType.value === 'detail') // 是否详情模式(只读)
|
||||||
|
const dialogTitle = computed(() => {
|
||||||
|
const titles: Record<string, string> = {
|
||||||
|
create: '新增班组',
|
||||||
|
update: '编辑班组',
|
||||||
|
detail: '班组详情'
|
||||||
|
}
|
||||||
|
return titles[formType.value] || formType.value
|
||||||
|
})
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
|
|
@ -110,10 +117,9 @@ const generateCode = async () => {
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (type: string, id?: number) => {
|
const open = async (type: string, id?: number) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
dialogTitle.value = t('action.' + type)
|
|
||||||
formType.value = type
|
formType.value = type
|
||||||
resetForm()
|
resetForm()
|
||||||
// 修改时,设置数据
|
// 修改/详情时,设置数据
|
||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
|
|
@ -123,10 +129,8 @@ const open = async (type: string, id?: number) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defineExpose({ open })
|
|
||||||
|
|
||||||
/** 提交表单 */
|
/** 提交表单 */
|
||||||
const emit = defineEmits(['success'])
|
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
await formRef.value.validate()
|
await formRef.value.validate()
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
|
|
@ -134,10 +138,10 @@ const submitForm = async () => {
|
||||||
const data = formData.value as unknown as CalTeamVO
|
const data = formData.value as unknown as CalTeamVO
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
await CalTeamApi.createTeam(data)
|
await CalTeamApi.createTeam(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success('新增成功')
|
||||||
} else {
|
} else {
|
||||||
await CalTeamApi.updateTeam(data)
|
await CalTeamApi.updateTeam(data)
|
||||||
message.success(t('common.updateSuccess'))
|
message.success('修改成功')
|
||||||
}
|
}
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
emit('success')
|
emit('success')
|
||||||
|
|
@ -157,4 +161,6 @@ const resetForm = () => {
|
||||||
}
|
}
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defineExpose({ open })
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!-- 操作栏 -->
|
<!-- 操作栏 -->
|
||||||
<el-button type="primary" plain size="small" @click="openForm()" class="mb-10px">
|
<el-button v-if="isEditable" type="primary" plain size="small" @click="openForm()" class="mb-10px">
|
||||||
<Icon icon="ep:plus" class="mr-5px" /> 添加成员
|
<Icon icon="ep:plus" class="mr-5px" /> 添加成员
|
||||||
</el-button>
|
</el-button>
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<el-table-column label="用户昵称" align="center" prop="nickname" min-width="120" />
|
<el-table-column label="用户昵称" align="center" prop="nickname" min-width="120" />
|
||||||
<el-table-column label="手机号" align="center" prop="telephone" min-width="120" />
|
<el-table-column label="手机号" align="center" prop="telephone" min-width="120" />
|
||||||
<el-table-column label="备注" align="center" prop="remark" min-width="150" />
|
<el-table-column label="备注" align="center" prop="remark" min-width="150" />
|
||||||
<el-table-column label="操作" align="center" width="80">
|
<el-table-column v-if="isEditable" label="操作" align="center" width="80">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
<el-button link type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -58,11 +58,14 @@ defineOptions({ name: 'CalTeamMemberList' })
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
teamId: number // 班组编号
|
teamId: number // 班组编号
|
||||||
|
formType: string // 表单类型:create / update / detail
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const isEditable = computed(() => ['create', 'update'].includes(props.formType)) // 是否为编辑模式
|
||||||
|
|
||||||
|
// ==================== 列表 ====================
|
||||||
const loading = ref(false) // 列表的加载中
|
const loading = ref(false) // 列表的加载中
|
||||||
const list = ref<CalTeamMemberVO[]>([]) // 列表的数据
|
const list = ref<CalTeamMemberVO[]>([]) // 列表的数据
|
||||||
|
|
||||||
|
|
@ -76,6 +79,16 @@ const getList = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.delConfirm()
|
||||||
|
await CalTeamMemberApi.deleteTeamMember(id)
|
||||||
|
message.success('删除成功')
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== 添加/修改 ====================
|
// ==================== 添加/修改 ====================
|
||||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
const formLoading = ref(false) // 表单的加载中
|
const formLoading = ref(false) // 表单的加载中
|
||||||
|
|
@ -106,25 +119,14 @@ const submitForm = async () => {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
await CalTeamMemberApi.createTeamMember(formData.value as unknown as CalTeamMemberVO)
|
await CalTeamMemberApi.createTeamMember(formData.value as unknown as CalTeamMemberVO)
|
||||||
message.success(t('common.createSuccess'))
|
message.success('添加成功')
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
// 刷新列表
|
|
||||||
await getList()
|
await getList()
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
|
||||||
const handleDelete = async (id: number) => {
|
|
||||||
try {
|
|
||||||
await message.delConfirm()
|
|
||||||
await CalTeamMemberApi.deleteTeamMember(id)
|
|
||||||
message.success('删除成功')
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 监听 teamId 变化,加载列表 */
|
/** 监听 teamId 变化,加载列表 */
|
||||||
watch(
|
watch(
|
||||||
() => props.teamId,
|
() => props.teamId,
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,7 @@ const { t } = useI18n() // 国际化
|
||||||
const loading = ref(true) // 列表的加载中
|
const loading = ref(true) // 列表的加载中
|
||||||
const list = ref<CalTeamVO[]>([]) // 列表的数据
|
const list = ref<CalTeamVO[]>([]) // 列表的数据
|
||||||
const total = ref(0) // 列表的总页数
|
const total = ref(0) // 列表的总页数
|
||||||
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
|
|
@ -146,7 +147,7 @@ const queryParams = reactive({
|
||||||
calendarType: undefined
|
calendarType: undefined
|
||||||
})
|
})
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const exportLoading = ref(false) // 导出的加载中
|
const formRef = ref() // 表单弹窗
|
||||||
|
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
|
|
@ -173,7 +174,6 @@ const resetQuery = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 添加/修改操作 */
|
/** 添加/修改操作 */
|
||||||
const formRef = ref()
|
|
||||||
const openForm = (type: string, id?: number) => {
|
const openForm = (type: string, id?: number) => {
|
||||||
formRef.value.open(type, id)
|
formRef.value.open(type, id)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue