Commit d3bc6ce9 by 李伟康

commit 场景集市&接待记录新增字段

1 parent fca8df4f
......@@ -123,6 +123,7 @@ export default {
carBrandList = [];
list?.map((e) => {
e.childs.map((i) => {
i.brandName = e.name
i.brandId = e.id;
carBrandList.push(i);
});
......@@ -199,7 +200,12 @@ export default {
handleSelect (item) {
const customerInfo = this.$store.state.user.customerInfo,
{ selectItem, linkage } = this
customerInfo.carBrand = selectItem.carChildsBrandName
Object.assign(customerInfo, {
carBrand: selectItem.carChildsBrandName,
carBrandId: selectItem.carChildsBrandId,
oneCarBrand: selectItem.carBrand,
oneCarBrandId: selectItem.carBrandId
})
if (linkage) {
this.$store.dispatch('setCustomerInfo', customerInfo)
this.$store.dispatch('updateViewKey')
......
export default {
data () {
return {
AIUrl: ''
}
},
mounted () {
},
methods: {
async getAiagent (options, agentCode = 'AI7') {
const { phone } = uni.$storage.get('userInfo'),
[data] = await uni.$api.sceneMarketApi.getAiagent({
ownerShipType: 1,
accountPhone: phone,
agentCode//AI6
})
if (data) {
const { sceneType, uuid, phone, channelType = 1 } = uni.$storage.get('userInfo'),
bussinessType = sceneType == 0 ? 1 : 2,// sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
brand = {
1: '问界',
2: '比亚迪',
3: '其他'
}[channelType],
title = options.title || ''
let { agentUrl, domainName } = data
this.AIUrl = `${agentUrl}?no_header=1&business_type=${bussinessType}&phone=${phone}&brand=${brand}&one_id=${uuid}&platformType=1&domain=${domainName}&presuppositionProblem=${title}`
this.setWebviewStyle()
} else uni.showToast({
title: '获取智能体失败',
icon: 'error'
})
},
setWebviewStyle () {
const setWebviewStyleWithRetry = () => {
const currentWebview = this.$scope.$getAppWebview()
let [wv1, wv2] = currentWebview.children()
let wv1Flag = false,
wv2Flag = false
if (wv2) {
if (wv1) {
wv1.setStyle({
left: '0',
top: '9.37%',
height: '90.63%',
width: '71.36%'
});
wv1Flag = true;
}
if (wv2) {
wv2.setStyle({
left: '71.9%',
top: '17.18%',
height: '82.82%',
width: '28.3%'
});
wv2Flag = true;
}
} else {
if (wv1) {
wv1.setStyle({
left: '71.9%',
top: '17.18%',
height: '82.82%',
width: '28.3%'
});
wv1Flag = true;
wv2Flag = true;
}
}
return wv1Flag && wv2Flag
};
const retrySetWebviewStyle = () => {
if (!setWebviewStyleWithRetry()) {
// 如果未成功,继续重试
setTimeout(retrySetWebviewStyle, 50);
} else {
// 成功设置样式,结束循环
console.log('Webview样式设置成功');
}
};
setTimeout(retrySetWebviewStyle, 100);
}
}
}
import loginMixin from './loginMixin'
import receptionTrackMixin from './receptionTrackMixin'
import aiUrlMixin from './aiUrlMixin'
import report from './report'
module.exports = {
loginMixin,
receptionTrackMixin
receptionTrackMixin,
aiUrlMixin,
report
}
......@@ -12,12 +12,12 @@ import utils from '@/utils/utils.js'
import { storageApi } from '@/utils/cache'
import permision from '@/js_sdk/wa-permission/permission.js'
export default {
provide() {
provide () {
return {
getRecorder: () => this.record
}
},
async mounted() {
async mounted () {
this.audioManager = new AudioManager(this.onAudioStart, this.onAudioStop, this.onError)
this.initDto()
this.record = new TempRecord(this.tempRecord, this.triggleTempNumber)
......@@ -34,31 +34,31 @@ export default {
// },
// deep: true
// },
customerKey:{
handler() {
customerKey: {
handler () {
this.handler(this.customerInfo, this.updateCustomerInfo)
},
deep: true
},
booksList: {
handler(val) {
handler (val) {
this.handler(val, this.updateBookList)
}
},
receptionStatus: {
handler(val) {
handler (val) {
this.handler(val, this.updateReceptionStatus)
}
},
receptionKey: {
handler(val) {
handler (val) {
this.handler(this.receptionTrack, this.updateMaterialPointList)
}
}
},
computed: {
...mapState(['user.customerInfo']),
...mapGetters(['customerInfo', 'receptionStatus', 'booksList', 'receptionTrack', 'receptionKey','customerKey'])
...mapGetters(['customerInfo', 'receptionStatus', 'booksList', 'receptionTrack', 'receptionKey', 'customerKey'])
},
methods: {
...mapMutations('audio', ['setReceptionStatus', 'setBooks', 'setPerRecordNumber']),
......@@ -72,20 +72,20 @@ export default {
this.audioManager.start()
}, 300),
initReception() {
initReception () {
this.setBooks([])
this.clearCustomerInfo()
this.setReceptionStatus('')
this.initTime()
},
async onAudioStart() {
async onAudioStart () {
if (this.audioManager.counter === 0) {
await this.record.add()
} else {
this.record.addAudio()
}
},
async onAudioStop() {
async onAudioStop () {
if (this.audioManager.isRecording) {
uni.$logger.local.info('〖接待管理Recorder〗 == 接待中,再次开启录音! ')
this.audioManager.start()
......@@ -93,7 +93,7 @@ export default {
uni.$logger.local.info('〖接待管理Recorder〗 == 断开录音! ')
}
},
onAudioError(error) {
onAudioError (error) {
const message = error.message
this.reportError(`录音异常: error: ${message}`, message)
},
......@@ -102,12 +102,12 @@ export default {
* @params {boolean} status true 不保存记录/AUDIO_STATUS.ABNORMAL 只要断开录音
* @returns {void}
*/
async stopAudio(isNotSave = false) {
async stopAudio (isNotSave = false) {
uni.$logger.local.info('〖接待管理Recorder〗 == 结束接待! ')
this.stop()
await this.saveAndClearRecord(isNotSave)
},
async saveAndClearRecord(isNotSave = false) {
async saveAndClearRecord (isNotSave = false) {
if (isNotSave) {
uni.$logger.local.info('〖接待管理Recorder〗 == 不保存记录! ')
return this.record.clearLocalRecord()
......@@ -116,24 +116,24 @@ export default {
//如果不需要保存记录
await this.record.save()
},
stop() {
stop () {
this.endWatchClick()
this.record.clearLoopTimer()
if (this.audioManager.isRecording) {
this.audioManager.stop()
}
},
handler(params, fn) {
handler (params, fn) {
if (this.audioManager.isRecording || this.record?.currentRecord?.endReasonType == 1) {
fn.call(this, params)
}
},
reset() {
reset () {
this.audioManager = null
this.record = null
this.tempRecord = null
},
initDto() {
initDto () {
const { shopMerchantId, phone, sceneType, uuid, name, merchantId, channelType, merchantName } = storageApi.getUserInfo()
const { deviceId: appCode } = uni.getDeviceInfo()
const dto = new RecordDto({
......@@ -146,22 +146,26 @@ export default {
merchantId: shopMerchantId,
merchantName,
bussinessType: sceneType == 0 ? 1 : 2, // sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
channelType: channelType || 1 //1问界 2 比亚迪 3 其他
channelType: channelType || 1,//1问界 2 比亚迪 3 其他
})
this.sceneType = sceneType
this.tempRecord = dto
},
updateCustomerInfo(customerInfo = {}) {
const { customerName, phoneNumber, salesUuid, carModel, staffName: salesName } = customerInfo
updateCustomerInfo (customerInfo = {}) {
const { customerName, phoneNumber, salesUuid, carModel, staffName: salesName, carBrand, carBrandId, oneCarBrand, oneCarBrandId } = customerInfo
this.record.updatePreRecords({
customerName,
phoneNumber,
carModel,
salesUuid,
salesName
salesName,
carBrand,
carBrandId,
oneCarBrand,
oneCarBrandId
})
},
updateBookList(booksList) {
updateBookList (booksList) {
const receptionCustomerPaySourceList = booksList.map(item => {
return {
id: item.id,
......@@ -171,7 +175,7 @@ export default {
})
this.record.updatePreRecords({ receptionCustomerPaySourceList })
},
updateMaterialPointList(receptionTrack) {
updateMaterialPointList (receptionTrack) {
const { merchantId, staffUuid, staffName } = this.tempRecord
let receptionCustomerMaterialPointList = []
Object.keys(receptionTrack).map(key => {
......@@ -185,17 +189,17 @@ export default {
})
this.record.updatePreRecords({ receptionCustomerMaterialPointList })
},
updateReceptionStatus(status) {
updateReceptionStatus (status) {
this.record.updatePreRecords({ receptionStatus: status })
},
getRecorder() {
getRecorder () {
return this.record
},
async triggleTempNumber() {
async triggleTempNumber () {
const _records = await this.record.getRecords()
this.setPerRecordNumber(_records.length)
},
async isPermission(hintText = '为了记录语音通话,请打开录音权限') {
async isPermission (hintText = '为了记录语音通话,请打开录音权限') {
const result = await permision.requestAndroidPermission('android.permission.RECORD_AUDIO')
await helpler.sleep(0)
if (result !== 1) {
......@@ -206,13 +210,13 @@ export default {
}
return result === 1
},
async checkBeforeStart() {
async checkBeforeStart () {
const isPermission = await this.isPermission()
const isRecording = this.audioManager.isRecording
return isPermission && !isRecording
}
},
beforeDestroy() {
beforeDestroy () {
this.stop()
this.reset()
}
......
......@@ -3,7 +3,7 @@ export default {
return {
goodsId: '',
visitsId: '',
source: 1
source: ''
}
},
onLoad (options) {
......@@ -15,22 +15,22 @@ export default {
methods: {
addRecord () {
const { shopMerchantId: merchantId, shopMerchantName: merchantName } = uni.$storage.get('userInfo')
if(!merchantId || !this.goodsId) return
if (!merchantId || !this.goodsId) return
const params = {
goodsId: this.goodsId,
goodsType: 0,
merchantId,
merchantName,
searchSource: this.source
}
if (this.visitsId) params.visitsId = this.visitsId
if (this.source) params.searchSource = this.source
uni.$api.commonApi.addRecord(params).then(res => {
this.addId = res
})
}
},
onUnload () {
if(!this.addId) return
if (!this.addId) return
const params = {
id: this.addId
}
......
......@@ -44,8 +44,10 @@
</view>
</template>
<script type="text/ecmascript-6">
import report from "@/mixin/report.js";
import { aiUrlMixin, report } from '@/mixin/index.js'
export default {
mixins: [report, aiUrlMixin],
props: {
isComponents: Boolean,
show: Boolean,
......@@ -56,7 +58,7 @@ export default {
title: '',
sourceType: '',
detailUrl: '',
AIUrl: ''
}
},
watch: {
......@@ -77,7 +79,6 @@ export default {
return status
},
},
mixins: [report],
onLoad (options) {
this.init(options)
},
......@@ -87,66 +88,13 @@ export default {
this.title = tabName
this.sourceType = sourceType
this.detailUrl = detailUrl
options.title = tabName
if (specialFlag == 1) this.getAiagent(options)
},
back () {
if (this.isComponents) this.$emit('previewBack')
else uni.navigateBack()
},
async getAiagent (options) {
const { phone } = uni.$storage.get('userInfo'),
[data] = await uni.$api.sceneMarketApi.getAiagent({
ownerShipType: 1,
accountPhone: phone,
agentCode: 'AI7' //AI6
})
if (data) {
const { sceneType, uuid, phone, channelType = 1 } = uni.$storage.get('userInfo'),
bussinessType = sceneType == 0 ? 1 : 2,// sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
brand = {
1: '问界',
2: '比亚迪',
3: '其他'
}[channelType],
title = options.title || ''
let { agentUrl, domainName } = data
this.AIUrl = `${agentUrl}?no_header=1&business_type=${bussinessType}&phone=${phone}&brand=${brand}&one_id=${uuid}&platformType=1&domain=${domainName}&presuppositionProblem=${title}`
this.setWebviewStyle()
} else uni.showToast({
title: '获取智能体失败',
icon: 'error'
})
},
setWebviewStyle () {
//修改UA为PC端
const setWebviewStyleWithRetry = () => {
const currentWebview = this.$scope.$getAppWebview()
const [wv1] = currentWebview.children()
let wv1Flag = false
if (wv1) {
wv1.setStyle({
left: '71.9%',
top: '17.18%',
height: '82.82%',
width: '28.3%'
});
wv2Flag = true; // 成功设置样式
}
return wv1Flag
};
const retrySetWebviewStyle = () => {
if (!setWebviewStyleWithRetry()) {
// 如果未成功,继续重试
setTimeout(retrySetWebviewStyle, 50);
} else {
// 成功设置样式,结束循环
console.log('Webview样式设置成功');
}
};
setTimeout(retrySetWebviewStyle, 100);
}
}
}
</script>
......
......@@ -176,14 +176,15 @@
<script type="text/ecmascript-6">
import AudioComponent from './components/AudioComponent.vue'
import report from "@/mixin/report.js";
import { aiUrlMixin, report } from '@/mixin/index.js'
let view_padding_top = 88,
menuHeight = 68
export default {
components: {
AudioComponent
},
mixins: [report],
mixins: [report, aiUrlMixin],
data () {
return {
detailInfo: [],
......@@ -196,7 +197,6 @@ export default {
caseObject: {},
imgLength: 0,
contentScrollNumber: 0,
AIUrl: '',
}
},
onLoad (options) {
......@@ -404,60 +404,6 @@ export default {
if (this.imgLength == 0) uni.hideLoading()
this.initScrollListTop()
},
async getAiagent (options) {
const { phone } = uni.$storage.get('userInfo'),
[data] = await uni.$api.sceneMarketApi.getAiagent({
ownerShipType: 1,
accountPhone: phone,
agentCode: 'AI7' //AI6
})
if (data) {
const { sceneType, uuid, phone, channelType = 1 } = uni.$storage.get('userInfo'),
bussinessType = sceneType == 0 ? 1 : 2,// sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
brand = {
1: '问界',
2: '比亚迪',
3: '其他'
}[channelType],
title = options.title || ''
let { agentUrl, domainName } = data
this.AIUrl = `${agentUrl}?no_header=1&business_type=${bussinessType}&phone=${phone}&brand=${brand}&one_id=${uuid}&platformType=1&domain=${domainName}&presuppositionProblem=${title}`
this.setWebviewStyle()
} else uni.showToast({
title: '获取智能体失败',
icon: 'error'
})
},
setWebviewStyle () {
//修改UA为PC端
const setWebviewStyleWithRetry = () => {
const currentWebview = this.$scope.$getAppWebview()
const [wv1] = currentWebview.children()
let wv1Flag = false
if (wv1) {
wv1.setStyle({
left: '71.9%',
top: '17.18%',
height: '82.82%',
width: '28.3%'
});
wv2Flag = true; // 成功设置样式
}
return wv1Flag
};
const retrySetWebviewStyle = () => {
if (!setWebviewStyleWithRetry()) {
// 如果未成功,继续重试
setTimeout(retrySetWebviewStyle, 50);
} else {
// 成功设置样式,结束循环
console.log('Webview样式设置成功');
}
};
setTimeout(retrySetWebviewStyle, 100);
}
}
}
</script>
......
......@@ -26,19 +26,20 @@
</template>
<script type="text/ecmascript-6">
import report from "@/mixin/report.js";
import { aiUrlMixin, report } from '@/mixin/index.js'
export default {
name: '',
mixins: [report],
mixins: [report , aiUrlMixin],
data () {
return {
url: '',
viewerUrl: '/hybrid/html/web/viewer.html',
viewerUrl: Object.freeze('/hybrid/html/web/viewer.html'),
AIUrl: '',
title: ''
}
},
onLoad (options) {
console.log(options)
if (options.fileUrl) this.url = `${this.viewerUrl}?file=${options.fileUrl}`
else this.url = options.url
if (options.title) this.title = options.title
......@@ -54,70 +55,6 @@ export default {
animationDuration: 100
})
},
async getAiagent (options) {
const { phone } = uni.$storage.get('userInfo'),
[data] = await uni.$api.sceneMarketApi.getAiagent({
ownerShipType: 1,
accountPhone: phone,
agentCode: 'AI7' //AI6
})
if (data) {
const { sceneType, uuid, phone, channelType = 1 } = uni.$storage.get('userInfo'),
bussinessType = sceneType == 0 ? 1 : 2,// sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
brand = {
1: '问界',
2: '比亚迪',
3: '其他'
}[channelType],
title = options.title || ''
let { agentUrl, domainName } = data
this.AIUrl = `${agentUrl}?no_header=1&business_type=${bussinessType}&phone=${phone}&brand=${brand}&one_id=${uuid}&platformType=1&domain=${domainName}&presuppositionProblem=${title}`
this.setWebviewStyle()
} else uni.showToast({
title: '获取智能体失败',
icon: 'error'
})
},
setWebviewStyle () {
//修改UA为PC端
const setWebviewStyleWithRetry = () => {
const currentWebview = this.$scope.$getAppWebview()
const [wv1, wv2] = currentWebview.children()
let wv1Flag = false,
wv2Flag = false
if (wv1) {
wv1.setStyle({
left: '0',
top: '9.37%',
height: '90.63%',
width: '71.36%'
});
wv1Flag = true; // 成功设置样式
}
if (wv2) {
wv2.setStyle({
left: '71.9%',
top: '17.18%',
height: '82.82%',
width: '28.3%'
});
wv2Flag = true; // 成功设置样式
}
return wv1Flag && wv2Flag
};
const retrySetWebviewStyle = () => {
if (!setWebviewStyleWithRetry()) {
// 如果未成功,继续重试
setTimeout(retrySetWebviewStyle, 50);
} else {
// 成功设置样式,结束循环
console.log('Webview样式设置成功');
}
};
setTimeout(retrySetWebviewStyle, 100);
}
}
}
</script>
......
......@@ -99,10 +99,7 @@
v-if="AIUrl"
>
<view class="AI-title flex">AI导师</view>
<web-view
:src="AIUrl"
class="webview"
></web-view>
<web-view :src="AIUrl"></web-view>
</view>
<template v-else>
<view class="nothing flex">
......@@ -374,7 +371,7 @@ export default {
url = `${agentUrl}?no_header=1&business_type=${bussinessType}&phone=${phone}&brand=${brand}&one_id=${uuid}&platformType=1&domain=${domainName}&presuppositionProblem=${title}`
if (checkDate) url += `&date=${checkDate}`
if (taskStatus) url += `&practice_status=${taskStatus}`
// this.AIUrl = url
this.AIUrl = url
this.setWebviewStyle()
} else uni.showToast({
title: '获取智能体失败',
......@@ -395,7 +392,6 @@ export default {
top: '16.65%',
height: '78.17%',
width: '56.52%',
// margin: '0 0 1% 0'
});
return true; // 成功设置样式
} else {
......@@ -620,24 +616,20 @@ export default {
opacity: 1;
background: #f5f9ff;
box-sizing: border-box;
overflow-y: auto;
position: relative;
.AI-window {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
.AI-title {
height: 96rpx;
font-size: 36rpx;
font-weight: 500;
justify-content: center;
color: #333333;
}
.webview {
iframe {
border-radius: 0 0 32rpx 32rpx;
overflow: hidden;
}
}
}
.nothing {
width: 100%;
......
......@@ -115,6 +115,7 @@ export default {
subBrandIdList = []
list?.map(e => {
e.childs.map(i => {
i.brandName = e.name
i.brandId = e.id
carBrandList.push(i)
subBrandIdList.push(i.id)
......
......@@ -20,8 +20,10 @@ export default {
staffName: "",
newCarFare: '',
carModelId: '',
carBuyers:'',
carPurchaseMethod:''
carBuyers: '',
carPurchaseMethod: '',
oneCarBrand: '',
oneCarBrandId: ''
},
historyStatus: Date.now(),
carBrands: [],
......@@ -32,11 +34,11 @@ export default {
receptionTrack: {}, //接待记录埋点
boutiqueDefaultCarBrandId: '',
viewKey: Date.now(),
boutiqueCarList:[],
receptionKey:Date.now(), //接待记录埋点KEY
defaultCarId:'',
customerKey:Date.now(), //客户信息KEY
currentCarInfo:{},//当前选中的车品牌车系
boutiqueCarList: [],
receptionKey: Date.now(), //接待记录埋点KEY
defaultCarId: '',
customerKey: Date.now(), //客户信息KEY
currentCarInfo: {},//当前选中的车品牌车系
};
},
mutations: {
......@@ -60,7 +62,12 @@ export default {
phoneNumber: "",
salesUuid: "",
staffName: "",
newCarFare: ''
newCarFare: '',
carModelId: '',
carBuyers: '',
carPurchaseMethod: '',
oneCarBrand: '',
oneCarBrandId: ''
};
uni.$storage.set("customerInfo", JSON.stringify(info));
state.customerInfo = info
......@@ -98,7 +105,7 @@ export default {
state.receptionTrack = {}
state.receptionKey = Date.now()
},
updateViewKey({ state }){
updateViewKey ({ state }) {
state.viewKey = Date.now();
},
......
......@@ -19,15 +19,42 @@ class DBManager {
db_table_name = 'records'
db_description = 'zyzs db'
db_size = 50 * 1024 * 1024
table_columns = [`id TEXT PRIMARY KEY`, `staffUuid TEXT`, `staffName TEXT`, `serviceMerchantId INTEGER`, 'carModel TEXT', 'endReasonType INTEGER', 'customerName TEXT', 'phoneNumber TEXT', 'appCode TEXT', 'loginPhone TEXT', 'salesName TEXT', 'salesUuid TEXT', 'receptionStatus INTEGER', 'receptionStartTime TEXT', 'receptionEndTime TEXT', 'receptionCustomerPaySourceList TEXT', 'merchantId INTEGER', 'merchantName TEXT', 'bussinessType INTEGER', 'channelType INTEGER', 'receptionCustomerMaterialPointList TEXT', 'recordUrlList TEXT']
table_columns = [
`id TEXT PRIMARY KEY`,
`staffUuid TEXT`,
`staffName TEXT`,
`serviceMerchantId INTEGER`,
'carModel TEXT',
'endReasonType INTEGER',
'customerName TEXT',
'phoneNumber TEXT',
'appCode TEXT',
'loginPhone TEXT',
'salesName TEXT',
'salesUuid TEXT',
'receptionStatus INTEGER',
'receptionStartTime TEXT',
'receptionEndTime TEXT',
'receptionCustomerPaySourceList TEXT',
'merchantId INTEGER',
'merchantName TEXT',
'bussinessType INTEGER',
'channelType INTEGER',
'receptionCustomerMaterialPointList TEXT',
'recordUrlList TEXT',
'carBrand TEXT',
'carBrandId INTEGER',
'oneCarBrand TEXT',
'oneCarBrandId INTEGER'
]
sqlite = null
isTableExists = false
constructor(table_name, table_columns) {
constructor(table_name, table_columns) {
this.table_name = table_name || this.db_table_name
this.table_columns = table_columns || this.table_columns
this.db = new SQLite(this.db_name, this.db_version, this.db_description, this.db_size)
}
async init() {
async init () {
try {
const isOpen = await this.db.isOpen()
if (!isOpen) {
......@@ -43,8 +70,8 @@ class DBManager {
throw new Error(error.message)
}
}
async openDB(){
async openDB () {
}
/**
* 将一条新记录添加到当前对象的记录列表中
......@@ -52,7 +79,7 @@ class DBManager {
* @param {Object} record - 要添加的新记录对象
* @returns {Array} - 包含新记录的更新后的记录列表
*/
async addRecord(record) {
async addRecord (record) {
await this.db.insert(this.table_name, record)
}
/**
......@@ -61,7 +88,7 @@ class DBManager {
* @param {number} id - 要移除的记录的ID
* @returns {Array} - 移除记录后的更新后的记录列表
*/
async removeRecord(id) {
async removeRecord (id) {
return this.db.delete(this.table_name, { id })
}
/**
......@@ -71,7 +98,7 @@ class DBManager {
* @returns {Object} - 具有给定 ID 的记录对象,如果没有找到符合条件的记录,则返回 undefined
*
*/
async getRecordById(id) {
async getRecordById (id) {
const records = await this.db.select(this.table_name, { id })
return Array.isArray(records) ? records[0] : records // sqlite 返回数组
}
......@@ -80,7 +107,7 @@ class DBManager {
*
* @returns {Array} - 从 storageApi 获取的记录列表
*/
async getRecords() {
async getRecords () {
return this.db.select(this.table_name)
}
/**
......@@ -89,7 +116,7 @@ class DBManager {
* @param {Array} records - 要设置的记录列表
* @returns {void} - 此函数不返回任何值
*/
async setRecords(records) {
async setRecords (records) {
return records.forEach(async record => {
this.addRecord(record)
})
......@@ -102,17 +129,17 @@ class DBManager {
* @param {Object} record - 要更新的记录对象,必须包含一个唯一的 id 属性
* @throws {Error} 如果记录数组中找不到具有给定 id 的记录,将抛出错误
*/
async updateRecord(setData, where) {
async updateRecord (setData, where) {
const { id, ...record } = setData
if (!where) {
where = { id }
}
return this.db.update(this.table_name, record, where)
}
async isOpen() {
async isOpen () {
return this.db.isOpen()
}
async isTableExists() {
async isTableExists () {
return this.db.isTableExists(this.table_name)
}
/**
......@@ -120,10 +147,10 @@ class DBManager {
*
* @returns {void} - 此函数不返回任何值
*/
async clearRecords() {
async clearRecords () {
this.db.delete(this.table_name)
}
async drop() {
async drop () {
this.db.drop(this.table_name)
}
}
......
......@@ -28,6 +28,11 @@ export default class RecordDto {
bussinessType = 0 // sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
channelType = 1 //1问界 2 比亚迪 3 其他
receptionCustomerMaterialPointList = []
carBrand = ''
carBrandId = ''
oneCarBrand = ''
oneCarBrandId = ''
constructor(options) {
Object.assign(this, options)
}
......
......@@ -9,7 +9,35 @@
*/
import DBManager from '../DBManager.js'
class DBRecord {
table_columns = [`id TEXT PRIMARY KEY`, `staffUuid TEXT`, `staffName TEXT`, `serviceMerchantId INTEGER`, 'carModel TEXT', 'endReasonType INTEGER', 'customerName TEXT', 'phoneNumber TEXT', 'appCode TEXT', 'loginPhone TEXT', 'salesName TEXT', 'salesUuid TEXT', 'receptionStatus INTEGER', 'receptionStartTime TEXT', 'receptionEndTime TEXT', 'receptionCustomerPaySourceList TEXT', 'merchantId INTEGER', 'merchantName TEXT', 'bussinessType INTEGER', 'channelType INTEGER', 'receptionCustomerMaterialPointList TEXT', 'recordUrlList TEXT', 'tempFilePath TEXT']
table_columns = [
`id TEXT PRIMARY KEY`,
`staffUuid TEXT`,
`staffName TEXT`,
`serviceMerchantId INTEGER`,
'carModel TEXT',
'endReasonType INTEGER',
'customerName TEXT',
'phoneNumber TEXT',
'appCode TEXT',
'loginPhone TEXT',
'salesName TEXT',
'salesUuid TEXT',
'receptionStatus INTEGER',
'receptionStartTime TEXT',
'receptionEndTime TEXT',
'receptionCustomerPaySourceList TEXT',
'merchantId INTEGER',
'merchantName TEXT',
'bussinessType INTEGER',
'channelType INTEGER',
'receptionCustomerMaterialPointList TEXT',
'recordUrlList TEXT',
'tempFilePath TEXT',
'carBrand TEXT',
'carBrandId INTEGER',
'oneCarBrand TEXT',
'oneCarBrandId INTEGER'
]
table_name = 'temp_records'
constructor() {
this.db = new DBManager(this.table_name, this.table_columns)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!