解决门店管理编辑问题
This commit is contained in:
@@ -1,31 +1,19 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
// 分页查询经销商列表
|
// 获取门店列表
|
||||||
export function getDealershipList(params) {
|
export function getDealershipList(params) {
|
||||||
return request({
|
return request({
|
||||||
url: '/dealership/list',
|
url: '/dealership/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
current: params.current || 1,
|
current: params?.current || 1,
|
||||||
size: params.size || 10,
|
size: params?.size || 1000, // 获取所有门店
|
||||||
dealershipName: params.dealershipName,
|
...params
|
||||||
dealershipCode: params.dealershipCode,
|
|
||||||
region: params.region,
|
|
||||||
status: params.status
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据经销商代码查询经销商信息
|
// 根据ID查询门店
|
||||||
export function getDealershipByCode(dealershipCode) {
|
|
||||||
return request({
|
|
||||||
url: '/dealership/getByCode',
|
|
||||||
method: 'get',
|
|
||||||
params: { dealershipCode }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据ID查询经销商
|
|
||||||
export function getDealershipById(id) {
|
export function getDealershipById(id) {
|
||||||
return request({
|
return request({
|
||||||
url: `/dealership/get/${id}`,
|
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) {
|
export function addDealership(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/dealership/add',
|
url: '/dealership/add',
|
||||||
@@ -59,7 +30,7 @@ export function addDealership(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新经销商信息
|
// 更新门店
|
||||||
export function updateDealership(data) {
|
export function updateDealership(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/dealership/update',
|
url: '/dealership/update',
|
||||||
@@ -68,10 +39,10 @@ export function updateDealership(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取经销商统计信息
|
// 删除门店
|
||||||
export function getDealershipStatistics() {
|
export function deleteDealership(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/dealership/statistics',
|
url: `/dealership/delete/${id}`,
|
||||||
method: 'get'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,26 +6,31 @@ export function getSalesList(params) {
|
|||||||
url: '/salesManagement/list',
|
url: '/salesManagement/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
pageNum: params.pageNum || 1,
|
current: params.pageNum || 1,
|
||||||
pageSize: params.pageSize || 10,
|
size: params.pageSize || 10,
|
||||||
salesName: params.salesName,
|
salesName: params.salesName,
|
||||||
storeId: params.storeId,
|
loginAccount: params.loginAccount,
|
||||||
projectId: params.projectId,
|
dealershipId: params.storeId,
|
||||||
status: params.status,
|
status: params.status,
|
||||||
createTimeStart: params.createTimeStart,
|
role: params.role
|
||||||
createTimeEnd: params.createTimeEnd,
|
|
||||||
recordingTimeStart: params.recordingTimeStart,
|
|
||||||
recordingTimeEnd: params.recordingTimeEnd
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据ID查询销售
|
||||||
|
export function getSalesById(id) {
|
||||||
|
return request({
|
||||||
|
url: `/salesManagement/get/${id}`,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 根据销售登录账号查询销售信息
|
// 根据销售登录账号查询销售信息
|
||||||
export function getSalesByAccount(account) {
|
export function getSalesByAccount(loginAccount) {
|
||||||
return request({
|
return request({
|
||||||
url: '/salesManagement/getByAccount',
|
url: '/salesManagement/getByAccount',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: { account }
|
params: { loginAccount }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +47,7 @@ export function batchDeleteSales(ids) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/salesManagement/batchDelete',
|
url: '/salesManagement/batchDelete',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
data: { ids }
|
data: ids
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
>
|
>
|
||||||
<el-table-column type="selection" width="55" />
|
<el-table-column type="selection" width="55" />
|
||||||
<el-table-column label="序号" type="index" width="50" />
|
<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="projectName" min-width="150" />
|
||||||
<el-table-column label="话术版本" prop="scriptVersion" min-width="100" />
|
<el-table-column label="话术版本" prop="scriptVersion" min-width="100" />
|
||||||
<el-table-column label="话术发布时间" prop="scriptPublishTime" sortable min-width="150">
|
<el-table-column label="话术发布时间" prop="scriptPublishTime" sortable min-width="150">
|
||||||
@@ -143,10 +143,8 @@
|
|||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="项目状态" prop="status">
|
<el-form-item label="项目状态" prop="status">
|
||||||
<el-radio-group v-model="projectForm.status">
|
<el-radio v-model="projectForm.status" value="1">启用</el-radio>
|
||||||
<el-radio value="1">启用</el-radio>
|
<el-radio v-model="projectForm.status" value="0">停用</el-radio>
|
||||||
<el-radio value="0">停用</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
@@ -159,6 +157,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getProjectList, getProjectById, addProject, updateProject, deleteProject, configureScript, publishScript, batchDeleteProject } from '@/api/project'
|
import { getProjectList, getProjectById, addProject, updateProject, deleteProject, configureScript, publishScript, batchDeleteProject } from '@/api/project'
|
||||||
|
import { getDealershipList } from '@/api/dealership'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Project',
|
name: 'Project',
|
||||||
@@ -202,15 +201,12 @@ export default {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
// 门店选项
|
// 门店选项
|
||||||
storeOptions: [
|
storeOptions: []
|
||||||
{ value: 'DEAL001', label: '销售演示-奔驰' },
|
|
||||||
{ value: 'DEAL002', label: '销售演示-上汽' },
|
|
||||||
{ value: 'DEAL003', label: '销售演示-比亚迪' }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList()
|
this.getList()
|
||||||
|
this.getDealershipList() // 获取门店列表
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
// 监听项目表单状态值变化
|
// 监听项目表单状态值变化
|
||||||
@@ -478,13 +474,9 @@ export default {
|
|||||||
|
|
||||||
if (response && response.code === 20000) {
|
if (response && response.code === 20000) {
|
||||||
const backendResponse = response.data
|
const backendResponse = response.data
|
||||||
if (backendResponse && backendResponse.success) {
|
|
||||||
this.$message.success(backendResponse.message || (this.isEdit ? '更新成功' : '添加成功'))
|
this.$message.success(backendResponse.message || (this.isEdit ? '更新成功' : '添加成功'))
|
||||||
this.dialogVisible = false
|
this.dialogVisible = false
|
||||||
this.getList()
|
this.getList()
|
||||||
} else {
|
|
||||||
this.$message.error(backendResponse?.message || (this.isEdit ? '更新失败' : '添加失败'))
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response?.message || (this.isEdit ? '更新失败' : '添加失败'))
|
this.$message.error(response?.message || (this.isEdit ? '更新失败' : '添加失败'))
|
||||||
}
|
}
|
||||||
@@ -501,6 +493,34 @@ export default {
|
|||||||
this.$refs.projectForm.resetFields()
|
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) {
|
formatDateTime(timestamp) {
|
||||||
if (!timestamp) return ''
|
if (!timestamp) return ''
|
||||||
|
|||||||
@@ -58,11 +58,9 @@
|
|||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="状态">
|
<el-form-item label="请选择状态" prop="status">
|
||||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
|
<el-radio v-model="queryParams.status" label="true" value="true2">启用</el-radio>
|
||||||
<el-option label="启用" value="1" />
|
<el-radio v-model="queryParams.status" label="false" value="false1">停用</el-radio>
|
||||||
<el-option label="禁用" value="0" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@@ -72,6 +70,12 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</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-card class="table-container" shadow="never">
|
||||||
<el-table
|
<el-table
|
||||||
@@ -85,11 +89,11 @@
|
|||||||
<el-table-column label="序号" type="index" width="50" />
|
<el-table-column label="序号" type="index" width="50" />
|
||||||
<el-table-column label="销售名称" prop="salesName" min-width="120" />
|
<el-table-column label="销售名称" prop="salesName" min-width="120" />
|
||||||
<el-table-column label="登录账号" prop="loginAccount" 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="avgRecordingTime" sortable min-width="150" />
|
||||||
<el-table-column label="录音总时长(小时)" prop="totalRecordingTime" 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="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="role" min-width="100" />
|
||||||
<el-table-column label="创建时间" prop="createTime" min-width="150" />
|
<el-table-column label="创建时间" prop="createTime" min-width="150" />
|
||||||
<el-table-column label="最近录音时间" prop="lastRecordingTime" min-width="150" />
|
<el-table-column label="最近录音时间" prop="lastRecordingTime" min-width="150" />
|
||||||
@@ -102,9 +106,11 @@
|
|||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="120" fixed="right">
|
<el-table-column label="操作" width="200" fixed="right">
|
||||||
<template slot-scope="scope">
|
<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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -121,11 +127,54 @@
|
|||||||
@current-change="handleCurrentChange"
|
@current-change="handleCurrentChange"
|
||||||
/>
|
/>
|
||||||
</el-card>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getSalesList, deleteSales } from '@/api/sales'
|
import { getSalesList, getSalesById, addSales, updateSales, deleteSales, batchDeleteSales } from '@/api/sales'
|
||||||
|
import { getDealershipList } from '@/api/dealership'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Sales',
|
name: 'Sales',
|
||||||
@@ -147,31 +196,42 @@ export default {
|
|||||||
recordingTimeRange: []
|
recordingTimeRange: []
|
||||||
},
|
},
|
||||||
// 门店选项
|
// 门店选项
|
||||||
storeOptions: [
|
storeOptions: [],
|
||||||
{ value: '1', label: '销售演示-上汽' },
|
|
||||||
{ value: '2', label: 'DCC演示' }
|
|
||||||
],
|
|
||||||
// 项目选项
|
// 项目选项
|
||||||
projectOptions: [
|
projectOptions: [
|
||||||
{ value: '1', label: '广丰项目' },
|
{ value: '1', label: '广丰项目' },
|
||||||
{ value: '2', 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() {
|
created() {
|
||||||
this.getList()
|
this.getList()
|
||||||
|
this.getStoreOptions()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 获取列表数据
|
// 获取列表数据
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
const params = {
|
const params = { ...this.queryParams }
|
||||||
...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]
|
|
||||||
}
|
|
||||||
|
|
||||||
// 移除空值
|
// 移除空值
|
||||||
Object.keys(params).forEach(key => {
|
Object.keys(params).forEach(key => {
|
||||||
@@ -181,10 +241,27 @@ export default {
|
|||||||
})
|
})
|
||||||
|
|
||||||
getSalesList(params).then(response => {
|
getSalesList(params).then(response => {
|
||||||
this.salesList = response.data.records || response.data
|
console.log('销售列表响应:', response) // 调试日志
|
||||||
this.total = response.data.total || response.data.length
|
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
|
this.loading = false
|
||||||
}).catch(() => {
|
}).catch(error => {
|
||||||
|
console.error('获取销售列表失败:', error)
|
||||||
// 开发环境使用模拟数据
|
// 开发环境使用模拟数据
|
||||||
this.salesList = [
|
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() {
|
handleQuery() {
|
||||||
this.queryParams.pageNum = 1
|
this.queryParams.pageNum = 1
|
||||||
@@ -272,21 +365,137 @@ export default {
|
|||||||
|
|
||||||
// 编辑
|
// 编辑
|
||||||
handleEdit(row) {
|
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) {
|
handleDelete(row) {
|
||||||
this.$confirm('确认删除?', '提示', {
|
this.$confirm(`确定要删除销售 "${row.salesName}" 吗?`, '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
deleteSales(row.id).then(() => {
|
deleteSales(row.id).then(response => {
|
||||||
this.$message.success('删除成功')
|
console.log('删除销售响应:', response) // 调试日志
|
||||||
|
|
||||||
|
if (response && response.code === 20000) {
|
||||||
|
const backendResponse = response.data
|
||||||
|
if (backendResponse && backendResponse.success) {
|
||||||
|
this.$message.success(backendResponse.message || '删除成功')
|
||||||
this.getList()
|
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;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.action-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.table-container {
|
.table-container {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
@@ -304,4 +517,29 @@ export default {
|
|||||||
.el-form-item {
|
.el-form-item {
|
||||||
margin-bottom: 15px;
|
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>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user