feat(production-master-data): 新增班组管理功能模块

1. 新增班组管理路由配置,添加对应页面访问路径
2. 新建班组管理API接口文件,封装增删改查、导入导出等接口
3. 补充中英文多语言文案,适配页面所有交互文本
4. 新增班组管理页面组件,包含搜索、列表、新增/编辑、成员管理、导入导出全功能
5. 更新功能测试文档,补充35条班组管理测试用例并更新用例统计
6. 更新系统功能清单对照表,新增班组管理模块条目
This commit is contained in:
sheng
2026-06-22 14:27:18 +08:00
parent 3f546564cc
commit 248557a293
7 changed files with 1321 additions and 3 deletions

View File

@@ -0,0 +1,76 @@
import { request } from '@/api/_service'
const BASE = 'system_settings/organization/production_team_manage/'
function apiParams (method, data = {}) {
return {
method: `system_settings_organization_production_team_manage_${method}`,
platform: 'background',
...data
}
}
export function getTeamManagementList (data) {
return request({
url: BASE + 'list',
method: 'get',
params: apiParams('list', data)
})
}
export function createTeamManagement (data) {
return request({
url: BASE + 'create',
method: 'post',
data: apiParams('create', data)
})
}
export function editTeamManagement (data) {
return request({
url: BASE + 'edit',
method: 'put',
data: apiParams('edit', data)
})
}
export function deleteTeamManagement (data) {
return request({
url: BASE + 'delete',
method: 'delete',
data: apiParams('delete', data)
})
}
export function getTeamManagementALL (data) {
return request({
url: BASE + 'all',
method: 'get',
params: apiParams('all', data)
})
}
export function getImportTemplate (data) {
return request({
url: BASE + 'get_import_template',
method: 'post',
responseType: 'blob',
data: apiParams('get_import_template', data)
})
}
export function importTeamManagement (data) {
return request({
url: BASE + 'data_import',
method: 'post',
data: apiParams('data_import', data)
})
}
export function exportTeamManagementTask (data) {
return request({
url: BASE + 'data_export_task',
method: 'post',
data: apiParams('data_export_task', data)
})
}

View File

@@ -417,6 +417,74 @@
"help": "Configure SPC data collection parameters and bind SCADA nodes"
}
},
"team_model": {
"team_management": {
"search": "Search",
"reset": "Reset",
"team_name": "Team Name",
"enter_team_name": "Please enter team name",
"area": "Area",
"select_area": "Please select area",
"production_line": "Production Line",
"select_area_then_line": "Please select the plant area first, then the production line.",
"last_create_time": "Latest Creation Time",
"select_create_time": "Please select creation time",
"download_task_created": "Download task created successfully",
"affiliated_factory": "Plant Area",
"affiliated_production_line": "Production Line",
"please_select": "Please select",
"please_select_factory_then_line": "Please select the plant area first, then the production line.",
"add_member": "Add Member",
"member_name": "Member Name",
"is_team_leader": "Is Team Leader",
"yes": "Yes",
"no": "No",
"operation": "Actions",
"delete": "Delete",
"cancel": "Cancel",
"confirm": "Confirm",
"production_team_data_import": "Team Data Import",
"upload_file_alert_title": "Files must be in .xls or .xlsx format and follow the template. Uploads will fail otherwise.",
"upload_file_alert_description": "To import multiple members, add rows with the same team name, plant, and production line. Differentiate them by member name.",
"production_team_data_import_table": "Team Import Table",
"select_file": "Select File",
"download_template": "Download Template",
"preview": "Preview",
"add": "Add",
"batch_delete": "Batch Delete",
"import": "Import",
"export": "Export",
"edit": "Edit",
"serial_number": "No.",
"create_time": "Create Time",
"update_time": "Update Time",
"select_affiliated_factory": "Please select plant area",
"select_affiliated_production_line": "Please select production line",
"please_enter_team_name": "Please enter team name",
"length_2_to_20_characters": "Length must be 2-20 characters.",
"please_select_affiliated_factory": "Please select plant area",
"please_select_affiliated_production_line": "Please select production line",
"please_select_team_leader": "Please select a team leader",
"add_team": "Add Team",
"edit_team": "Edit Team",
"export_confirm_message": "Exporting data requires creating a download task first. Track progress via the Download Tasks menu at the top. Continue?",
"prompt": "Notice",
"operation_cancelled": "Operation canceled",
"operation_success": "Operation succeeded",
"confirm_delete": "Are you sure to delete?",
"validation_fail": "Validation failed",
"select_rows_first": "Please select rows first",
"confirm_batch_delete": "Are you sure to delete selected data?",
"import_success": "Import succeeded",
"import_failed": "Import failed",
"export_failed": "Export failed",
"download_template_failed": "Download template failed",
"create_download_task": "Create download task",
"create_download_task_failed": "Create download task failed",
"team_members": "Team Members",
"upload_file": "Upload File"
}
},
"product_management": {
"product_list": {
"search": "Search",

View File

@@ -417,6 +417,74 @@
"help": "配置SPC数据采集参数绑定SCADA节点"
}
},
"team_model": {
"team_management": {
"search": "查询",
"reset": "重置",
"team_name": "班组名称",
"enter_team_name": "请输入班组名称",
"area": "所区",
"select_area": "请选择所区",
"production_line": "产线",
"select_area_then_line": "请选择先所属厂区,再选择所属产线",
"last_create_time": "最后创建时间",
"select_create_time": "请选择创建时间",
"download_task_created": "创建下载任务成功",
"affiliated_factory": "所属厂区",
"affiliated_production_line": "所属产线",
"please_select": "请选择",
"please_select_factory_then_line": "请选择先所属厂区,再选择所属产线",
"add_member": "添加成员",
"member_name": "成员名称",
"is_team_leader": "是否班组组长",
"yes": "是",
"no": "否",
"operation": "操作",
"delete": "删除",
"cancel": "取 消",
"confirm": "确 定",
"production_team_data_import": "生产班组数据导入",
"upload_file_alert_title": "上传的文件后辍必须是(xlsx/xls),且根据模板上传,否则不能上传成功!",
"upload_file_alert_description": "如需导入多个成员,在模板中增加一行相同班组名称、厂区、产线数据,成员名称不同即可",
"production_team_data_import_table": "生产班组数据导入表格",
"select_file": "选择文件",
"download_template": "下载模板",
"preview": "预览",
"add": "新增",
"batch_delete": "批量删除",
"import": "导入",
"export": "导出",
"edit": "编辑",
"serial_number": "序号",
"create_time": "创建时间",
"update_time": "修改时间",
"select_affiliated_factory": "请选择所属厂区",
"select_affiliated_production_line": "请选择所属产线",
"please_enter_team_name": "请输入班组名称",
"length_2_to_20_characters": "长度在 2 到 20 个字符",
"please_select_affiliated_factory": "请选择所属厂区",
"please_select_affiliated_production_line": "请选择所属产线",
"please_select_team_leader": "请选择班组负责人",
"add_team": "新增班组",
"edit_team": "编辑班组",
"export_confirm_message": "数据导出需要先创建下载任务(可在系统顶部系统下载任务中查看下载进度并下载文件),是否继续?",
"prompt": "提示",
"operation_cancelled": "已取消操作",
"operation_success": "操作成功",
"confirm_delete": "确定要执行该操作吗?",
"validation_fail": "校验失败",
"select_rows_first": "请先选择要操作的数据",
"confirm_batch_delete": "确定要删除所选数据吗?",
"import_success": "导入成功",
"import_failed": "导入失败",
"export_failed": "导出失败",
"download_template_failed": "下载模板失败",
"create_download_task": "创建下载任务",
"create_download_task_failed": "创建下载任务失败",
"team_members": "班组成员",
"upload_file": "上传文件"
}
},
"product_management": {
"product_list": {
"search": "查询",

View File

@@ -85,6 +85,12 @@ export default {
name: `${pre}spc_configuration-data_collection_configuration`,
meta: { ...meta, cache: true, title: 'SPC采集配置' },
component: _import('production-master-data/spc-configuration/data-collection-configuration')
},
{
path: 'team_model/team_management',
name: `${pre}team_model-team_management`,
meta: { ...meta, cache: true, title: '班组管理' },
component: _import('production-master-data/team-model/team-management')
}
])('production_configuration-')
}

View File

@@ -0,0 +1,717 @@
<template>
<d2-container>
<template #header>
<div class="search-bar">
<el-form :inline="true" size="mini">
<el-form-item :label="$t(key('team_name'))">
<el-input
v-model="search.name"
:placeholder="$t(key('enter_team_name'))"
clearable
style="width:200px"
@keyup.enter.native="onSearch"
/>
</el-form-item>
<el-form-item :label="$t(key('area'))">
<el-select
v-model="search.area_id"
:placeholder="$t(key('select_area'))"
clearable
filterable
style="width:200px"
@change="onAreaChange"
>
<el-option
v-for="item in areaOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item :label="$t(key('production_line'))">
<el-select
v-model="search.line_id"
:placeholder="$t(key('select_area_then_line'))"
clearable
filterable
style="width:200px"
>
<el-option
v-for="item in lineOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item :label="$t(key('last_create_time'))">
<el-date-picker
v-model="search.create_time"
type="datetimerange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd HH:mm:ss"
style="width:350px"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="onSearch">
{{ $t(key('search')) }}
</el-button>
<el-button icon="el-icon-refresh" @click="onReset">
{{ $t(key('reset')) }}
</el-button>
<el-dropdown @command="handleExportCommand" style="margin-left: 10px;">
<el-button type="info">
{{ $t(key('export')) }}<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="export">{{ $t(key('export')) }}</el-dropdown-item>
<el-dropdown-item command="export_task">{{ $t(key('create_download_task')) }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-form-item>
</el-form>
</div>
</template>
<page-table
ref="pageTable"
:columns="columns"
:data="tableData"
:loading="loading"
:toolbar-buttons="toolbarButtons"
:row-buttons="rowButtons"
:pagination="pagination"
help-url="/help/team-management"
:help-text="$t(ckey('help'))"
auto-height
@page-change="onPageChange"
@selection-change="onSelect"
/>
<!-- 新增/编辑班组弹框 -->
<el-dialog
:visible.sync="dialogVisible"
:title="dialogTitle"
:width="'60%'"
@close="handleDialogClose"
>
<el-form
ref="teamForm"
:model="formData"
:rules="rules"
label-width="150px"
size="small"
>
<el-row>
<el-col :span="12">
<el-form-item :label="$t(key('team_name'))" prop="name">
<el-input v-model="formData.name" :placeholder="$t(key('enter_team_name'))"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t(key('affiliated_factory'))" prop="area_id">
<el-select
v-model="formData.area_id"
:placeholder="$t(key('please_select'))"
clearable
filterable
@change="areaDataChange"
>
<el-option
v-for="item in areaOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item :label="$t(key('affiliated_production_line'))" prop="line_id">
<el-select
v-model="formData.line_id"
:placeholder="$t(key('please_select_factory_then_line'))"
clearable
filterable
>
<el-option
v-for="item in lineOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-divider>{{ $t(key('team_members')) }}</el-divider>
<el-button @click="handleTeamAddMembers" size="mini" type="success">
{{ $t(key('add_member')) }}
</el-button>
<el-table :data="membersData" style="width: 100%; margin-top: 10px;">
<el-table-column :label="$t(key('member_name'))" width="250">
<template slot-scope="scope">
<el-select
v-model="membersData[scope.$index]['user_id']"
size="small"
clearable
filterable
:placeholder="$t(key('please_select'))"
style="width: 100%"
>
<el-option
v-for="item in userOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="is_main" :label="$t(key('is_team_leader'))" width="150">
<template slot-scope="scope">
<el-switch
v-model="membersData[scope.$index]['is_main']"
:active-text="$t(key('yes'))"
:inactive-text="$t(key('no'))"
:active-value="1"
:inactive-value="0"
@change="
(val) => {
is_main_change(val, scope.$index);
}
"
>
</el-switch>
</template>
</el-table-column>
<el-table-column :label="$t(key('operation'))" width="100">
<template slot-scope="scope">
<el-button
type="danger"
@click="handleMembersDelete(scope.row, scope.$index)"
size="mini"
icon="el-icon-delete"
>
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pagination.currentPage"
:hide-on-single-page="true"
:page-sizes="[8, 20, 50, 100]"
:page-size="pagination.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="pagination.total"
style="margin-top: 10px;"
>
</el-pagination>
<div slot="footer" class="dialog-footer">
<el-button @click="handleDialogClose">{{ $t(key('cancel')) }}</el-button>
<el-button type="primary" @click="handleSubmitDialogMembersAdd">
{{ $t(key('confirm')) }}
</el-button>
</div>
</el-dialog>
<!-- 导入弹框 -->
<el-dialog
:visible.sync="importDialogVisible"
:title="$t(key('production_team_data_import'))"
width="50%"
@close="handleImportDialogClose"
>
<el-form>
<el-alert
:title="$t(key('upload_file_alert_title'))"
:description="$t(key('upload_file_alert_description'))"
:closable="false"
type="warning"
style="margin-bottom: 20px;"
>
</el-alert>
<el-form-item :label="$t(key('production_team_data_import_table'))">
<el-upload
class="upload-demo"
action=""
:auto-upload="false"
:multiple="false"
:show-file-list="true"
:file-list="importFileList"
accept=".xlsx,.xls"
:on-change="handleFileUpload"
:limit="1"
>
<el-button slot="trigger" size="mini" type="success">
{{ $t(key('select_file')) }}
</el-button>
<el-button
style="margin-left: 10px;"
size="mini"
type="primary"
@click="handleDownloadTemplate"
>
{{ $t(key('download_template')) }}
</el-button>
</el-upload>
</el-form-item>
<el-form-item :label="$t(key('preview'))">
<el-table
v-loading="importTableLoading"
:data="importPreviewData"
height="300"
>
<el-table-column prop="name" :label="$t(key('team_name'))" width="120"></el-table-column>
<el-table-column prop="area_name" :label="$t(key('affiliated_factory'))" width="120"></el-table-column>
<el-table-column prop="line_name" :label="$t(key('affiliated_production_line'))" width="120"></el-table-column>
<el-table-column prop="members_user_name" :label="$t(key('member_name'))" width="120"></el-table-column>
<el-table-column prop="is_main" :label="$t(key('is_team_leader'))" width="100"></el-table-column>
</el-table>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="handleImportDialogClose">{{ $t(key('cancel')) }}</el-button>
<el-button type="primary" @click="handleStartImport" :loading="importLoading">
{{ $t(key('confirm')) }}
</el-button>
</div>
</el-dialog>
</d2-container>
</template>
<script>
import { useTableColumns } from '@/composables/useTableColumns'
import { useTableButtons } from '@/composables/useTableButtons'
import { i18nMixin } from '@/composables/useI18n'
import { confirmMixin } from '@/composables/useConfirmHandle'
import {
getTeamManagementList,
createTeamManagement,
editTeamManagement,
deleteTeamManagement,
getTeamManagementALL,
getImportTemplate,
importTeamManagement,
exportTeamManagementTask
} from '@/api/production-master-data/team-management'
import { getFactoryAreaALL } from '@/api/production-master-data/factory-area'
import { getProductionLineList } from '@/api/production-master-data/production-line'
import { getUserAll } from '@/api/system-administration/user-management/user'
import PageTable from '@/components/page-table'
export default {
name: 'production-master-data-team-management',
components: { PageTable },
mixins: [i18nMixin('page.production_master_data.team_model.team_management'), confirmMixin],
data () {
return {
loading: false,
submitting: false,
tableData: [],
selectedRows: [],
dialogVisible: false,
importDialogVisible: false,
dialogTitle: '',
editId: '',
handleType: 'create',
search: { name: '', area_id: '', line_id: '', create_time: '' },
pagination: { current: 1, size: 10, total: 0 },
areaOptions: [],
lineOptions: [],
userOptions: [],
formData: { name: '', area_id: '', line_id: '', user_id: '' },
membersData: [],
membersForm: {
members_user_id: undefined,
is_main: '1'
},
rules: {
name: [
{ required: true, message: this.key('please_enter_team_name'), trigger: 'blur' },
{ min: 2, max: 20, message: this.key('length_2_to_20_characters'), trigger: 'blur' }
],
area_id: [
{ required: true, message: this.key('please_select_affiliated_factory'), trigger: 'change' }
],
line_id: [
{ required: true, message: this.key('please_select_affiliated_production_line'), trigger: 'change' }
]
},
columns: [],
toolbarButtons: [],
rowButtons: [],
importFileList: [],
importPreviewData: [],
importTableLoading: false,
importLoading: false,
pagination: {
total: 0,
pageSize: 8,
currentPage: 1,
}
}
},
created () {
this.initAreaOptions()
this.initUserOptions()
this.columns = useTableColumns([
{ prop: 'sort', label: this.key('serial_number'), width: 80 },
{ prop: 'name', label: this.key('team_name'), minWidth: 120 },
{ prop: 'area_name', label: this.key('affiliated_factory'), minWidth: 120 },
{ prop: 'line_name', label: this.key('affiliated_production_line'), minWidth: 120 },
{ prop: 'create_time', label: this.key('create_time'), width: 160 },
{ prop: 'update_time', label: this.key('update_time'), width: 160 },
{ prop: '_actions', label: this.key('operation'), width: 250, fixed: 'right' }
])
const btns = useTableButtons({
toolbar: [
{
key: 'add',
label: this.key('add'),
icon: 'el-icon-plus',
type: 'primary',
auth: '/system_settings/organization/production_team_manage/create',
onClick: this.openAdd
},
{
key: 'batch_delete',
label: this.key('batch_delete'),
icon: 'el-icon-delete',
type: 'danger',
auth: '/system_settings/organization/production_team_manage/batch-delete',
onClick: this.handleBatchDelete
},
{
key: 'import',
label: this.key('import'),
icon: 'el-icon-upload2',
type: '',
style: { background: '#3CBA92', color: '#FFFFFF' },
auth: '/system_settings/organization/production_team_manage/import',
onClick: this.openImport
}
],
row: [
{
key: 'edit',
label: this.key('edit'),
icon: 'el-icon-edit',
auth: '/system_settings/organization/production_team_manage/edit',
onClick: this.openEdit
},
{
key: 'delete',
label: this.key('delete'),
icon: 'el-icon-delete',
color: 'danger',
auth: '/system_settings/organization/production_team_manage/delete',
onClick: this.handleDelete
}
]
}, this.$permission)
this.toolbarButtons = btns.toolbarButtons
this.rowButtons = btns.rowButtons
this.fetchData()
},
methods: {
async fetchData () {
this.loading = true
try {
const res = await getTeamManagementList({
...this.search,
page_no: this.pagination.current,
page_size: this.pagination.size
})
const list = Array.isArray(res) ? res : (res.data?.data || [])
const total = Array.isArray(res) ? res.length : (res.data?.count || 0)
this.tableData = list
this.pagination.total = total
} finally {
this.loading = false
}
},
async initAreaOptions () {
try {
const res = await getFactoryAreaALL()
const data = Array.isArray(res) ? res : (res.data || [])
this.areaOptions = data.map(item => ({ value: item.area_id || item.id, label: item.name }))
} catch { /* 忽略加载失败 */ }
},
async initUserOptions () {
try {
const res = await getUserAll()
const data = Array.isArray(res) ? res : (res.data || [])
this.userOptions = data.map(item => ({ value: item.user_id || item.id, label: item.nickname || item.username }))
} catch { /* 忽略加载失败 */ }
},
async loadLineOptionsByArea(areaId) {
if (!areaId) {
this.lineOptions = []
return
}
try {
const res = await getProductionLineList({ area_id: areaId, page_no: 1, page_size: 1000 })
const data = Array.isArray(res) ? res : (res.data?.data || [])
this.lineOptions = data.map(item => ({ value: item.id, label: item.name }))
} catch { /* 忽略加载失败 */ }
},
onSearch () {
this.pagination.current = 1
this.fetchData()
},
onReset () {
this.search = { name: '', area_id: '', line_id: '', create_time: '' }
this.lineOptions = []
this.pagination.current = 1
this.fetchData()
},
onAreaChange(value) {
this.search.line_id = '' // 清空产线选择
this.loadLineOptionsByArea(value)
},
onPageChange (page) {
this.pagination.current = page.current
this.pagination.size = page.size
this.fetchData()
},
onSelect (rows) {
this.selectedRows = rows
},
resetForm () {
this.formData = { name: '', area_id: '', line_id: '', user_id: '' }
this.membersData = []
this.editId = ''
},
async openAdd () {
this.handleType = 'create'
this.dialogTitle = this.key('add_team')
await this.$nextTick()
this.resetForm()
this.dialogVisible = true
},
async openEdit (row) {
this.handleType = 'edit'
this.dialogTitle = this.key('edit_team')
this.editId = row.id
this.formData = {
name: row.name,
area_id: row.area_id,
line_id: row.line_id
}
// 加载产线选项
await this.loadLineOptionsByArea(row.area_id)
// 加载成员数据
this.membersData = row.members || []
await this.$nextTick()
this.dialogVisible = true
},
async onDialogSubmit () {
this.submitting = true
try {
const submitData = {
...this.formData,
members: this.membersData
}
if (this.handleType === 'create') {
await createTeamManagement(submitData)
} else {
await editTeamManagement({ ...submitData, id: this.editId })
}
this.$message.success(this.$t(this.key('operation_success')))
this.dialogVisible = false
this.fetchData()
} finally {
this.submitting = false
}
},
handleDialogClose () {
this.resetForm()
this.dialogVisible = false
},
async handleDelete (row) {
const cancelled = await this.$confirmAction(
{
message: this.key('confirm_delete'),
title: this.key('tip')
},
() => deleteTeamManagement({ id: [row.id] })
)
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
this.pagination.current = Math.min(
this.pagination.current,
Math.ceil((this.pagination.total - 1) / this.pagination.size) || 1
)
this.fetchData()
},
handleBatchDelete () {
if (this.selectedRows.length === 0) {
this.$message.warning(this.$t(this.key('select_rows_first')))
return
}
this.$confirm(this.$t(this.key('confirm_batch_delete')), this.$t(this.key('tip')), {
confirmButtonText: this.$t(this.key('confirm')),
cancelButtonText: this.$t(this.key('cancel')),
type: 'warning'
}).then(async () => {
const ids = this.selectedRows.map(row => row.id)
await deleteTeamManagement({ id: ids })
this.$message.success(this.$t(this.key('operation_success')))
this.fetchData()
}).catch(() => {})
},
openImport() {
this.importFileList = []
this.importPreviewData = []
this.importDialogVisible = true
},
handleImportDialogClose() {
this.importDialogVisible = false
this.importFileList = []
this.importPreviewData = []
},
handleFileUpload(file, fileList) {
this.importFileList = fileList.slice(-1) // 只保留最后一个文件
},
async handleDownloadTemplate() {
try {
const res = await getImportTemplate({})
// 创建下载链接
const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
const url = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = 'team_management_import_template.xlsx'
a.click()
window.URL.revokeObjectURL(url)
} catch (error) {
this.$message.error(this.$t(this.key('download_template_failed')))
}
},
async handleStartImport() {
if (this.importFileList.length === 0) {
this.$message.warning(this.$t(this.key('please_select_file')))
return
}
this.importLoading = true
try {
const file = this.importFileList[0].raw || this.importFileList[0]
const formData = new FormData()
formData.append('file', file)
await importTeamManagement(formData)
this.$message.success(this.$t(this.key('import_success')))
this.importDialogVisible = false
this.fetchData()
} catch (error) {
this.$message.error(this.$t(this.key('import_failed')))
} finally {
this.importLoading = false
}
},
async handleExportCommand(command) {
if (command === 'export') {
// 直接导出
try {
const res = await exportTeamManagementTask({...this.search, action: 'download'})
// 创建下载链接
const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
const url = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = 'team_management_export.xlsx'
a.click()
window.URL.revokeObjectURL(url)
} catch (error) {
this.$message.error(this.$t(this.key('export_failed')))
}
} else if (command === 'export_task') {
// 创建下载任务
try {
await exportTeamManagementTask({...this.search, action: 'task'})
this.$message.success(this.$t(this.key('download_task_created')))
// 跳转到下载任务页面
this.$router.push({ name: 'task' })
} catch (error) {
this.$message.error(this.$t(this.key('create_download_task_failed')))
}
}
},
// 以下是成员管理相关方法
areaDataChange(value) {
this.loadLineOptionsByArea(value)
},
handleTeamAddMembers() {
// 添加一个新的成员行
this.membersData.push({
user_id: null,
is_main: 0
})
},
handleMembersDelete(row, index) {
this.membersData.splice(index, 1)
},
is_main_change(val, index) {
// 确保只有一个主负责人
if (val === 1) {
this.membersData.forEach((item, idx) => {
if (idx !== index) {
item.is_main = 0
}
})
}
},
handleSizeChange(val) {
this.pagination.pageSize = val
this.fetchData()
},
handleCurrentChange(val) {
this.pagination.currentPage = val
this.fetchData()
},
handleSubmitDialogMembersAdd() {
// 验证表单
this.$refs.teamForm.validate((valid) => {
if (valid) {
this.onDialogSubmit()
} else {
this.$message.error(this.$t(this.key('validation_failed')))
}
})
}
}
}
</script>
<style scoped>
.search-bar {
padding: 10px 0;
}
/deep/ .el-form-item--mini.el-form-item {
margin-bottom: 4px;
}
/deep/ .el-table .el-table__header th {
background-color: #f5f7fa;
}
</style>