解决门店管理编辑问题
This commit is contained in:
@@ -1,31 +1,19 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 分页查询经销商列表
|
||||
// 获取门店列表
|
||||
export function getDealershipList(params) {
|
||||
return request({
|
||||
url: '/dealership/list',
|
||||
method: 'get',
|
||||
params: {
|
||||
current: params.current || 1,
|
||||
size: params.size || 10,
|
||||
dealershipName: params.dealershipName,
|
||||
dealershipCode: params.dealershipCode,
|
||||
region: params.region,
|
||||
status: params.status
|
||||
current: params?.current || 1,
|
||||
size: params?.size || 1000, // 获取所有门店
|
||||
...params
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 根据经销商代码查询经销商信息
|
||||
export function getDealershipByCode(dealershipCode) {
|
||||
return request({
|
||||
url: '/dealership/getByCode',
|
||||
method: 'get',
|
||||
params: { dealershipCode }
|
||||
})
|
||||
}
|
||||
|
||||
// 根据ID查询经销商
|
||||
// 根据ID查询门店
|
||||
export function getDealershipById(id) {
|
||||
return request({
|
||||
url: `/dealership/get/${id}`,
|
||||
@@ -33,24 +21,7 @@ export function getDealershipById(id) {
|
||||
})
|
||||
}
|
||||
|
||||
// 删除经销商
|
||||
export function deleteDealership(id) {
|
||||
return request({
|
||||
url: `/dealership/delete/${id}`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 批量删除经销商
|
||||
export function batchDeleteDealership(ids) {
|
||||
return request({
|
||||
url: '/dealership/batchDelete',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
// 添加新的经销商信息
|
||||
// 添加门店
|
||||
export function addDealership(data) {
|
||||
return request({
|
||||
url: '/dealership/add',
|
||||
@@ -59,7 +30,7 @@ export function addDealership(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 更新经销商信息
|
||||
// 更新门店
|
||||
export function updateDealership(data) {
|
||||
return request({
|
||||
url: '/dealership/update',
|
||||
@@ -68,10 +39,10 @@ export function updateDealership(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 获取经销商统计信息
|
||||
export function getDealershipStatistics() {
|
||||
// 删除门店
|
||||
export function deleteDealership(id) {
|
||||
return request({
|
||||
url: '/dealership/statistics',
|
||||
method: 'get'
|
||||
url: `/dealership/delete/${id}`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,26 +6,31 @@ export function getSalesList(params) {
|
||||
url: '/salesManagement/list',
|
||||
method: 'get',
|
||||
params: {
|
||||
pageNum: params.pageNum || 1,
|
||||
pageSize: params.pageSize || 10,
|
||||
current: params.pageNum || 1,
|
||||
size: params.pageSize || 10,
|
||||
salesName: params.salesName,
|
||||
storeId: params.storeId,
|
||||
projectId: params.projectId,
|
||||
loginAccount: params.loginAccount,
|
||||
dealershipId: params.storeId,
|
||||
status: params.status,
|
||||
createTimeStart: params.createTimeStart,
|
||||
createTimeEnd: params.createTimeEnd,
|
||||
recordingTimeStart: params.recordingTimeStart,
|
||||
recordingTimeEnd: params.recordingTimeEnd
|
||||
role: params.role
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 根据ID查询销售
|
||||
export function getSalesById(id) {
|
||||
return request({
|
||||
url: `/salesManagement/get/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 根据销售登录账号查询销售信息
|
||||
export function getSalesByAccount(account) {
|
||||
export function getSalesByAccount(loginAccount) {
|
||||
return request({
|
||||
url: '/salesManagement/getByAccount',
|
||||
method: 'get',
|
||||
params: { account }
|
||||
params: { loginAccount }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -42,7 +47,7 @@ export function batchDeleteSales(ids) {
|
||||
return request({
|
||||
url: '/salesManagement/batchDelete',
|
||||
method: 'delete',
|
||||
data: { ids }
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="序号" type="index" width="50" />
|
||||
<el-table-column label="所属门店" prop="dealershipId" min-width="150" />
|
||||
<el-table-column label="所属门店" prop="dealershipName" min-width="150" />
|
||||
<el-table-column label="项目名称" prop="projectName" min-width="150" />
|
||||
<el-table-column label="话术版本" prop="scriptVersion" min-width="100" />
|
||||
<el-table-column label="话术发布时间" prop="scriptPublishTime" sortable min-width="150">
|
||||
@@ -143,10 +143,8 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目状态" prop="status">
|
||||
<el-radio-group v-model="projectForm.status">
|
||||
<el-radio value="1">启用</el-radio>
|
||||
<el-radio value="0">停用</el-radio>
|
||||
</el-radio-group>
|
||||
<el-radio v-model="projectForm.status" value="1">启用</el-radio>
|
||||
<el-radio v-model="projectForm.status" value="0">停用</el-radio>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
@@ -159,6 +157,7 @@
|
||||
|
||||
<script>
|
||||
import { getProjectList, getProjectById, addProject, updateProject, deleteProject, configureScript, publishScript, batchDeleteProject } from '@/api/project'
|
||||
import { getDealershipList } from '@/api/dealership'
|
||||
|
||||
export default {
|
||||
name: 'Project',
|
||||
@@ -202,15 +201,12 @@ export default {
|
||||
]
|
||||
},
|
||||
// 门店选项
|
||||
storeOptions: [
|
||||
{ value: 'DEAL001', label: '销售演示-奔驰' },
|
||||
{ value: 'DEAL002', label: '销售演示-上汽' },
|
||||
{ value: 'DEAL003', label: '销售演示-比亚迪' }
|
||||
]
|
||||
storeOptions: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
this.getDealershipList() // 获取门店列表
|
||||
},
|
||||
watch: {
|
||||
// 监听项目表单状态值变化
|
||||
@@ -332,7 +328,7 @@ export default {
|
||||
description: '',
|
||||
status: '1' // 修复单选按钮组,使用字符串值而不是布尔值
|
||||
}
|
||||
|
||||
|
||||
// 使用$nextTick确保DOM更新完成后再显示对话框
|
||||
this.$nextTick(() => {
|
||||
this.dialogVisible = true
|
||||
@@ -351,17 +347,17 @@ export default {
|
||||
if (response && response.code === 20000) {
|
||||
const backendResponse = response
|
||||
console.log('编辑项目数据,backendResponse.data :', backendResponse.data)
|
||||
|
||||
|
||||
// 处理状态值转换
|
||||
const projectData = { ...backendResponse.data }
|
||||
if (typeof projectData.status === 'boolean') {
|
||||
projectData.status = projectData.status ? '1' : '0'
|
||||
}
|
||||
|
||||
|
||||
this.projectForm = projectData
|
||||
console.log('编辑项目数据projectForm :', this.projectForm)
|
||||
console.log('编辑项目状态值:', this.projectForm.status)
|
||||
|
||||
|
||||
// 使用$nextTick确保DOM更新完成后再显示对话框
|
||||
this.$nextTick(() => {
|
||||
this.dialogVisible = true
|
||||
@@ -469,22 +465,18 @@ export default {
|
||||
if (typeof submitData.status === 'string') {
|
||||
submitData.status = submitData.status === '1'
|
||||
}
|
||||
|
||||
|
||||
console.log('提交数据:', submitData) // 调试日志
|
||||
|
||||
|
||||
const submitFunc = this.isEdit ? updateProject : addProject
|
||||
submitFunc(submitData).then(response => {
|
||||
console.log('提交表单响应:', response) // 调试日志
|
||||
|
||||
if (response && response.code === 20000) {
|
||||
const backendResponse = response.data
|
||||
if (backendResponse && backendResponse.success) {
|
||||
this.$message.success(backendResponse.message || (this.isEdit ? '更新成功' : '添加成功'))
|
||||
this.dialogVisible = false
|
||||
this.getList()
|
||||
} else {
|
||||
this.$message.error(backendResponse?.message || (this.isEdit ? '更新失败' : '添加失败'))
|
||||
}
|
||||
this.$message.success(backendResponse.message || (this.isEdit ? '更新成功' : '添加成功'))
|
||||
this.dialogVisible = false
|
||||
this.getList()
|
||||
} else {
|
||||
this.$message.error(response?.message || (this.isEdit ? '更新失败' : '添加失败'))
|
||||
}
|
||||
@@ -501,6 +493,34 @@ export default {
|
||||
this.$refs.projectForm.resetFields()
|
||||
},
|
||||
|
||||
// 获取门店列表
|
||||
getDealershipList() {
|
||||
getDealershipList().then(response => {
|
||||
console.log('门店列表响应:', response) // 调试日志
|
||||
if (response && response.code === 20000) {
|
||||
const backendResponse = response.data
|
||||
console.log('门店列表响应 response.data :', response.data) // 调试日志
|
||||
this.storeOptions = response.data.map(item => ({
|
||||
value: item.id,
|
||||
label: item.dealershipName
|
||||
}))
|
||||
console.log('门店选项(按修改时间倒序):', this.storeOptions)
|
||||
|
||||
} else {
|
||||
this.$message.error(response?.message || '获取门店列表失败')
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('获取门店列表失败:', error)
|
||||
// 开发环境使用模拟数据
|
||||
this.storeOptions = [
|
||||
{ value: 'DEAL001', label: '销售演示-奔驰' },
|
||||
{ value: 'DEAL002', label: '销售演示-上汽' },
|
||||
{ value: 'DEAL003', label: '销售演示-比亚迪' }
|
||||
]
|
||||
console.log('使用模拟门店数据:', this.storeOptions)
|
||||
})
|
||||
},
|
||||
|
||||
// 格式化时间
|
||||
formatDateTime(timestamp) {
|
||||
if (!timestamp) return ''
|
||||
|
||||
@@ -58,12 +58,10 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
|
||||
<el-option label="启用" value="1" />
|
||||
<el-option label="禁用" value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="请选择状态" prop="status">
|
||||
<el-radio v-model="queryParams.status" label="true" value="true2">启用</el-radio>
|
||||
<el-radio v-model="queryParams.status" label="false" value="false1">停用</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" @click="handleQuery">筛选</el-button>
|
||||
@@ -72,6 +70,12 @@
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 操作按钮区域 -->
|
||||
<el-card class="action-container" shadow="never">
|
||||
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">添加销售</el-button>
|
||||
<el-button type="danger" icon="el-icon-delete" :disabled="selectedIds.length === 0" @click="handleBatchDelete">批量删除</el-button>
|
||||
</el-card>
|
||||
|
||||
<!-- 数据表格区域 -->
|
||||
<el-card class="table-container" shadow="never">
|
||||
<el-table
|
||||
@@ -85,11 +89,11 @@
|
||||
<el-table-column label="序号" type="index" width="50" />
|
||||
<el-table-column label="销售名称" prop="salesName" min-width="120" />
|
||||
<el-table-column label="登录账号" prop="loginAccount" min-width="120" />
|
||||
<el-table-column label="录音数" prop="recordingCount" sortable min-width="100" />
|
||||
<el-table-column label="录音数" prop="totalRecordingHours" sortable min-width="100" />
|
||||
<el-table-column label="平均录音时间(分钟)" prop="avgRecordingTime" sortable min-width="150" />
|
||||
<el-table-column label="录音总时长(小时)" prop="totalRecordingTime" sortable min-width="150" />
|
||||
<el-table-column label="所属项目" prop="projectName" min-width="150" />
|
||||
<el-table-column label="所属门店" prop="storeName" min-width="150" />
|
||||
<el-table-column label="所属门店" prop="dealershipName" min-width="150" />
|
||||
<el-table-column label="角色" prop="role" min-width="100" />
|
||||
<el-table-column label="创建时间" prop="createTime" min-width="150" />
|
||||
<el-table-column label="最近录音时间" prop="lastRecordingTime" min-width="150" />
|
||||
@@ -102,9 +106,11 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<el-table-column label="操作" width="200" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="handleViewRecordings(scope.row)">查看录音</el-button>
|
||||
<el-button type="text" size="small" @click="handleEdit(scope.row)">编辑</el-button>
|
||||
<el-button type="text" size="small" @click="handleViewRecordings(scope.row)">查看录音</el-button>
|
||||
<el-button type="text" size="small" style="color: #F56C6C;" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -121,11 +127,54 @@
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<!-- 添加/编辑销售对话框 -->
|
||||
<el-dialog
|
||||
:title="dialogTitle"
|
||||
:visible.sync="dialogVisible"
|
||||
width="600px"
|
||||
@close="handleDialogClose"
|
||||
>
|
||||
<el-form ref="salesForm" :model="salesForm" :rules="salesRules" label-width="100px">
|
||||
<el-form-item label="销售名称" prop="salesName">
|
||||
<el-input v-model="salesForm.salesName" placeholder="请输入销售名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="登录账号" prop="loginAccount">
|
||||
<el-input v-model="salesForm.loginAccount" placeholder="请输入登录账号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="所属门店" prop="dealershipId">
|
||||
<el-select v-model="salesForm.dealershipId" placeholder="请选择所属门店" style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in storeOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色" prop="role">
|
||||
<el-select v-model="salesForm.role" placeholder="请选择角色" style="width: 100%">
|
||||
<el-option label="销售" value="销售" />
|
||||
<el-option label="呼叫员" value="呼叫员" />
|
||||
<el-option label="管理员" value="管理员" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="销售状态" prop="status">
|
||||
<el-radio v-model="salesForm.status" label="true">启用</el-radio>
|
||||
<el-radio v-model="salesForm.status" label="false">停用</el-radio>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getSalesList, deleteSales } from '@/api/sales'
|
||||
import { getSalesList, getSalesById, addSales, updateSales, deleteSales, batchDeleteSales } from '@/api/sales'
|
||||
import { getDealershipList } from '@/api/dealership'
|
||||
|
||||
export default {
|
||||
name: 'Sales',
|
||||
@@ -147,31 +196,42 @@ export default {
|
||||
recordingTimeRange: []
|
||||
},
|
||||
// 门店选项
|
||||
storeOptions: [
|
||||
{ value: '1', label: '销售演示-上汽' },
|
||||
{ value: '2', label: 'DCC演示' }
|
||||
],
|
||||
storeOptions: [],
|
||||
// 项目选项
|
||||
projectOptions: [
|
||||
{ value: '1', label: '广丰项目' },
|
||||
{ value: '2', label: '广丰项目 电话接访话术' }
|
||||
]
|
||||
],
|
||||
// 添加/编辑对话框相关
|
||||
dialogVisible: false,
|
||||
dialogTitle: '',
|
||||
isEdit: false,
|
||||
salesForm: {
|
||||
id: undefined,
|
||||
salesName: '',
|
||||
loginAccount: '',
|
||||
dealershipId: '',
|
||||
role: '',
|
||||
status: '1'
|
||||
},
|
||||
salesRules: {
|
||||
salesName: [{ required: true, message: '请输入销售名称', trigger: 'blur' }],
|
||||
loginAccount: [{ required: true, message: '请输入登录账号', trigger: 'blur' }],
|
||||
dealershipId: [{ required: true, message: '请选择所属门店', trigger: 'change' }],
|
||||
role: [{ required: true, message: '请选择角色', trigger: 'change' }],
|
||||
status: [{ required: true, message: '请选择销售状态', trigger: 'change' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
this.getStoreOptions()
|
||||
},
|
||||
methods: {
|
||||
// 获取列表数据
|
||||
getList() {
|
||||
this.loading = true
|
||||
const params = {
|
||||
...this.queryParams,
|
||||
createTimeStart: this.queryParams.createTimeRange && this.queryParams.createTimeRange[0],
|
||||
createTimeEnd: this.queryParams.createTimeRange && this.queryParams.createTimeRange[1],
|
||||
recordingTimeStart: this.queryParams.recordingTimeRange && this.queryParams.recordingTimeRange[0],
|
||||
recordingTimeEnd: this.queryParams.recordingTimeRange && this.queryParams.recordingTimeRange[1]
|
||||
}
|
||||
const params = { ...this.queryParams }
|
||||
|
||||
// 移除空值
|
||||
Object.keys(params).forEach(key => {
|
||||
@@ -181,10 +241,27 @@ export default {
|
||||
})
|
||||
|
||||
getSalesList(params).then(response => {
|
||||
this.salesList = response.data.records || response.data
|
||||
this.total = response.data.total || response.data.length
|
||||
console.log('销售列表响应:', response) // 调试日志
|
||||
if (response && response.code === 20000) {
|
||||
const backendResponse = response
|
||||
this.salesList = backendResponse.data || []
|
||||
this.total = backendResponse.total || 0
|
||||
// 更新分页信息
|
||||
if (backendResponse.current) {
|
||||
this.queryParams.pageNum = backendResponse.current
|
||||
}
|
||||
if (backendResponse.size) {
|
||||
this.queryParams.pageSize = backendResponse.size
|
||||
}
|
||||
console.log('解析后的销售数据:', this.salesList)
|
||||
} else {
|
||||
this.$message.error(response?.message || '获取销售列表失败')
|
||||
this.salesList = []
|
||||
this.total = 0
|
||||
}
|
||||
this.loading = false
|
||||
}).catch(() => {
|
||||
}).catch(error => {
|
||||
console.error('获取销售列表失败:', error)
|
||||
// 开发环境使用模拟数据
|
||||
this.salesList = [
|
||||
{
|
||||
@@ -225,6 +302,22 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
// 获取门店选项
|
||||
getStoreOptions() {
|
||||
getDealershipList().then(response => {
|
||||
this.storeOptions = response.data.map(item => ({
|
||||
value: item.id,
|
||||
label: item.dealershipName
|
||||
}))
|
||||
}).catch(() => {
|
||||
// 开发环境使用模拟数据
|
||||
this.storeOptions = [
|
||||
{ value: '1', label: '销售演示-上汽' },
|
||||
{ value: '2', label: 'DCC演示' }
|
||||
]
|
||||
})
|
||||
},
|
||||
|
||||
// 查询
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
@@ -272,21 +365,137 @@ export default {
|
||||
|
||||
// 编辑
|
||||
handleEdit(row) {
|
||||
console.log('编辑', row)
|
||||
this.dialogTitle = '编辑销售'
|
||||
this.isEdit = true
|
||||
this.loading = true
|
||||
|
||||
getSalesById(row.id).then(response => {
|
||||
console.log('编辑销售响应:', response) // 调试日志
|
||||
|
||||
if (response && response.code === 20000) {
|
||||
this.salesForm = { ...response.data }
|
||||
console.log('编辑销售响应 salesForm:', this.salesForm)
|
||||
this.dialogVisible = true
|
||||
} else {
|
||||
this.$message.error(response?.message || '获取销售信息失败')
|
||||
}
|
||||
this.loading = false
|
||||
}).catch(error => {
|
||||
console.error('获取销售信息失败:', error)
|
||||
this.$message.error('获取销售信息失败,请稍后重试')
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
|
||||
// 删除
|
||||
handleDelete(row) {
|
||||
this.$confirm('确认删除?', '提示', {
|
||||
this.$confirm(`确定要删除销售 "${row.salesName}" 吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
deleteSales(row.id).then(() => {
|
||||
this.$message.success('删除成功')
|
||||
this.getList()
|
||||
deleteSales(row.id).then(response => {
|
||||
console.log('删除销售响应:', response) // 调试日志
|
||||
|
||||
if (response && response.code === 20000) {
|
||||
const backendResponse = response.data
|
||||
if (backendResponse && backendResponse.success) {
|
||||
this.$message.success(backendResponse.message || '删除成功')
|
||||
this.getList()
|
||||
} else {
|
||||
this.$message.error(backendResponse?.message || '删除失败')
|
||||
}
|
||||
} else {
|
||||
this.$message.error(response?.message || '删除失败')
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('删除失败:', error)
|
||||
this.$message.error('删除失败,请稍后重试')
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message.info('已取消删除')
|
||||
})
|
||||
},
|
||||
|
||||
// 批量删除
|
||||
handleBatchDelete() {
|
||||
if (this.selectedIds.length === 0) {
|
||||
this.$message.warning('请先选择要删除的销售')
|
||||
return
|
||||
}
|
||||
|
||||
this.$confirm(`确定要删除选中的 ${this.selectedIds.length} 个销售吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
batchDeleteSales(this.selectedIds).then(response => {
|
||||
console.log('批量删除响应:', response) // 调试日志
|
||||
|
||||
if (response && response.code === 20000) {
|
||||
const backendResponse = response.data
|
||||
if (backendResponse && backendResponse.success) {
|
||||
this.$message.success(backendResponse.message || '批量删除成功')
|
||||
this.selectedIds = []
|
||||
this.getList()
|
||||
} else {
|
||||
this.$message.error(backendResponse?.message || '批量删除失败')
|
||||
}
|
||||
} else {
|
||||
this.$message.error(response?.message || '批量删除失败')
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('批量删除失败:', error)
|
||||
this.$message.error('批量删除失败,请稍后重试')
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message.info('已取消删除')
|
||||
})
|
||||
},
|
||||
|
||||
// 添加
|
||||
handleAdd() {
|
||||
this.dialogTitle = '添加销售'
|
||||
this.isEdit = false
|
||||
this.salesForm = {
|
||||
id: undefined,
|
||||
salesName: '',
|
||||
loginAccount: '',
|
||||
dealershipId: '',
|
||||
role: '',
|
||||
status: '1'
|
||||
}
|
||||
this.dialogVisible = true
|
||||
},
|
||||
|
||||
// 提交表单
|
||||
handleSubmit() {
|
||||
console.log('提交表单:', this.salesForm)
|
||||
this.$refs.salesForm.validate(valid => {
|
||||
if (valid) {
|
||||
const submitFunc = this.isEdit ? updateSales : addSales
|
||||
submitFunc(this.salesForm).then(response => {
|
||||
console.log('提交表单响应:', response) // 调试日志
|
||||
|
||||
if (response && response.code === 20000) {
|
||||
const backendResponse = response.data
|
||||
this.$message.success(backendResponse.message || (this.isEdit ? '更新成功' : '添加成功'))
|
||||
this.dialogVisible = false
|
||||
this.getList()
|
||||
} else {
|
||||
this.$message.error(response?.message || (this.isEdit ? '更新失败' : '添加失败'))
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('提交失败:', error)
|
||||
this.$message.error(this.isEdit ? '更新失败,请稍后重试' : '添加失败,请稍后重试')
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 对话框关闭
|
||||
handleDialogClose() {
|
||||
this.$refs.salesForm.resetFields()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,6 +506,10 @@ export default {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.action-container {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
margin-top: 20px;
|
||||
}
|
||||
@@ -304,4 +517,29 @@ export default {
|
||||
.el-form-item {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.el-button--text {
|
||||
padding: 0;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.el-button--text:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.el-table .el-button--text {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.el-table .el-button--text:hover {
|
||||
color: #409EFF;
|
||||
}
|
||||
|
||||
.el-table .el-button--text.el-button--danger:hover {
|
||||
color: #F56C6C;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user