|
@@ -33,16 +33,16 @@
|
|
|
</el-form>
|
|
</el-form>
|
|
|
|
|
|
|
|
<el-row :gutter="10" class="mb8">
|
|
<el-row :gutter="10" class="mb8">
|
|
|
- <el-col :span="1.5">
|
|
|
|
|
- <el-button
|
|
|
|
|
- type="primary"
|
|
|
|
|
- plain
|
|
|
|
|
- icon="el-icon-plus"
|
|
|
|
|
- size="mini"
|
|
|
|
|
- v-hasPermi="['app:customerMember:add']"
|
|
|
|
|
- @click="handleAdd"
|
|
|
|
|
- >新增</el-button>
|
|
|
|
|
- </el-col>
|
|
|
|
|
|
|
+<!-- <el-col :span="1.5">-->
|
|
|
|
|
+<!-- <el-button-->
|
|
|
|
|
+<!-- type="primary"-->
|
|
|
|
|
+<!-- plain-->
|
|
|
|
|
+<!-- icon="el-icon-plus"-->
|
|
|
|
|
+<!-- size="mini"-->
|
|
|
|
|
+<!-- v-hasPermi="['app:customerMember:add']"-->
|
|
|
|
|
+<!-- @click="handleAdd"-->
|
|
|
|
|
+<!-- >新增</el-button>-->
|
|
|
|
|
+<!-- </el-col>-->
|
|
|
<el-col :span="1.5">
|
|
<el-col :span="1.5">
|
|
|
<el-button
|
|
<el-button
|
|
|
type="success"
|
|
type="success"
|
|
@@ -65,6 +65,24 @@
|
|
|
@click="handleDelete()"
|
|
@click="handleDelete()"
|
|
|
>删除</el-button>
|
|
>删除</el-button>
|
|
|
</el-col>
|
|
</el-col>
|
|
|
|
|
+ <el-col :span="1.5">
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="warning"
|
|
|
|
|
+ plain
|
|
|
|
|
+ icon="el-icon-refresh"
|
|
|
|
|
+ size="mini"
|
|
|
|
|
+ :loading="syncLoading"
|
|
|
|
|
+ v-hasPermi="['app:customerMember:add']"
|
|
|
|
|
+ @click="handleSyncSales"
|
|
|
|
|
+ >同步销售</el-button>
|
|
|
|
|
+ <el-tooltip
|
|
|
|
|
+ effect="dark"
|
|
|
|
|
+ content="该按钮初次同步可能较慢,后续再次同步只会新增新的销售数据"
|
|
|
|
|
+ placement="top"
|
|
|
|
|
+ >
|
|
|
|
|
+ <i class="el-icon-question sync-sales-tip"></i>
|
|
|
|
|
+ </el-tooltip>
|
|
|
|
|
+ </el-col>
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
</el-row>
|
|
</el-row>
|
|
|
|
|
|
|
@@ -212,7 +230,9 @@ import {
|
|
|
listCustomerMember,
|
|
listCustomerMember,
|
|
|
addCustomerMember,
|
|
addCustomerMember,
|
|
|
updateCustomerMember,
|
|
updateCustomerMember,
|
|
|
- delCustomerMember
|
|
|
|
|
|
|
+ delCustomerMember,
|
|
|
|
|
+ syncSalesCustomerMember,
|
|
|
|
|
+ getSyncSalesCustomerMemberStatus
|
|
|
} from '@/api/app/customerMember'
|
|
} from '@/api/app/customerMember'
|
|
|
import { listCustomerRoleOptions } from '@/api/app/customerRole'
|
|
import { listCustomerRoleOptions } from '@/api/app/customerRole'
|
|
|
import { getCompanyList, getCompanyUserList } from '@/api/company/companyUser'
|
|
import { getCompanyList, getCompanyUserList } from '@/api/company/companyUser'
|
|
@@ -224,6 +244,8 @@ export default {
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
loading: true,
|
|
loading: true,
|
|
|
|
|
+ syncLoading: false,
|
|
|
|
|
+ syncTimer: null,
|
|
|
showSearch: true,
|
|
showSearch: true,
|
|
|
total: 0,
|
|
total: 0,
|
|
|
ids: [],
|
|
ids: [],
|
|
@@ -272,7 +294,64 @@ export default {
|
|
|
this.loadRoleOptions()
|
|
this.loadRoleOptions()
|
|
|
this.getList()
|
|
this.getList()
|
|
|
},
|
|
},
|
|
|
|
|
+ beforeDestroy() {
|
|
|
|
|
+ this.clearSyncTimer()
|
|
|
|
|
+ },
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ clearSyncTimer() {
|
|
|
|
|
+ if (this.syncTimer) {
|
|
|
|
|
+ clearInterval(this.syncTimer)
|
|
|
|
|
+ this.syncTimer = null
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleSyncSales() {
|
|
|
|
|
+ this.$confirm('是否确认同步销售数据', '提示', {
|
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
|
+ type: 'warning'
|
|
|
|
|
+ }).then(() => {
|
|
|
|
|
+ this.syncLoading = true
|
|
|
|
|
+ return syncSalesCustomerMember()
|
|
|
|
|
+ }).then(response => {
|
|
|
|
|
+ if (response.code !== 200) {
|
|
|
|
|
+ this.syncLoading = false
|
|
|
|
|
+ this.msgError(response.msg || '提交同步任务失败')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this.msgSuccess('同步任务已提交,同步中。。。')
|
|
|
|
|
+ this.clearSyncTimer()
|
|
|
|
|
+ this.syncTimer = setInterval(() => {
|
|
|
|
|
+ this.pollSyncSalesStatus()
|
|
|
|
|
+ }, 2000)
|
|
|
|
|
+ this.pollSyncSalesStatus()
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ this.syncLoading = false
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ pollSyncSalesStatus() {
|
|
|
|
|
+ getSyncSalesCustomerMemberStatus().then(response => {
|
|
|
|
|
+ if (response.code !== 200) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ const data = response.data || {}
|
|
|
|
|
+ if (data.status === 'running') {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this.clearSyncTimer()
|
|
|
|
|
+ this.syncLoading = false
|
|
|
|
|
+ if (data.status === 'success') {
|
|
|
|
|
+ this.msgSuccess(data.message || '同步完成')
|
|
|
|
|
+ this.getList()
|
|
|
|
|
+ this.loadRoleOptions()
|
|
|
|
|
+ } else if (data.status === 'fail') {
|
|
|
|
|
+ this.msgError(data.message || '同步失败')
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ this.clearSyncTimer()
|
|
|
|
|
+ this.syncLoading = false
|
|
|
|
|
+ this.msgError('查询同步状态失败')
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
parseRoleId(value) {
|
|
parseRoleId(value) {
|
|
|
if (value === null || value === undefined || value === '') {
|
|
if (value === null || value === undefined || value === '') {
|
|
|
return null
|
|
return null
|
|
@@ -472,4 +551,11 @@ export default {
|
|
|
.el-input__icon {
|
|
.el-input__icon {
|
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
|
}
|
|
}
|
|
|
|
|
+.sync-sales-tip {
|
|
|
|
|
+ margin-left: 6px;
|
|
|
|
|
+ color: #909399;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ vertical-align: middle;
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|