master
xy 3 years ago
parent e3f77112f0
commit 3a3c8d9a92

@ -10,6 +10,10 @@
{
"launchtype" : "local"
},
"mp-weixin" :
{
"launchtype" : "local"
},
"type" : "uniCloud"
}
]

@ -29,7 +29,7 @@
</view>
<view slot="foot">
<u-button :ripple="true" :custom-style="btnStyle" @click="getAllAssets"></u-button>
<u-button :disabled="isSync" :ripple="true" :custom-style="btnStyle" @click="getAllAssets">{{ isSync ? "..." : "" }}</u-button>
</view>
</u-card>
</view>
@ -54,6 +54,7 @@
"color": "#fff",
'background': "#107fc9"
},
isSync:false,
}
},
methods: {
@ -102,13 +103,14 @@
const getSql = () => {
let sql = ""
res.data?.forEach(item => {
sql += `INSERT INTO property (id,serial,name,position,worker_name)
sql += `INSERT INTO property (id,serial,name,position,worker_name,remark)
VALUES (
${item.id},
${item.serial},
${item.name},
${item.position},
${item.worker_name}); `
${item.worker_name}),
${item.remark}; `
})
return sql;
}
@ -116,7 +118,7 @@
// #ifdef APP-PLUS
androidModule.showToast("开始同步资产...")
// #endif
this.isSync = true
let res = await this.$u.api.getAll()
//
await executeSql(`
@ -155,9 +157,12 @@
// #ifdef APP-PLUS
androidModule.showToast(`获取到${this.baseInfo.num}条资产`)
this.isSync = false
uni.hideLoading()
console.log(await selectFromTable(`select * from property;`));
// #endif
uni.$emit('assetsSync',{msg:'success'})
}catch(err){
console.warn('sqlite-err',err)
}

@ -9,6 +9,10 @@
@click="scanClick">{{ flag ? "停止扫描" : "开始扫描" }}</u-button>
<u-card title="资产列表" v-show="info.length > 0">
<view slot="head" style="display: flex;justify-content: space-between;align-items: center;">
<view style="flex: 1;">资产列表</view>
<u-button size="medium" type="primary" @click="clear"></u-button>
</view>
<view class="card-body" slot="body">
<view v-for="(item,index) in info" :key="item.id"
style="display: flex;justify-content: space-between;padding: 10rpx 0;align-items: center;">
@ -180,6 +184,20 @@
}
},
methods: {
clear() {
this.info = []
this.fund = {
id: 0,
name: '',
serial: '',
position: '',
worker_name: '',
active_status: '',
files: '',
remark: ''
}
},
async getLogs() {
this.logs = await selectFromTable(`
select * from log where type = 1;
@ -204,7 +222,7 @@
this.fund.files = filePath[1]?.savedFilePath
}
await executeSql(`
update property set active_status = "${this.fund.active_status}",remark = "${this.fund.remark}",is_check = 1,${this.fund.files ? 'files = "' + this.fund.files + '"' : '' } where id = ${this.fund.id};
update property set active_status = "${this.fund.active_status}",remark = "${this.fund.remark}",is_check = 1${this.fund.files ? ',files = "' + this.fund.files + '"' : '' } where id = ${this.fund.id};
`)
uni.showToast({
icon: 'success',
@ -306,7 +324,7 @@
`)
androidModule.showToast(`扫描到:${propertys.length}件资产`)
this.info = propertys
if(this.info.length > 0)this.fund = this.info[0]
this.fund = propertys[0]
} catch (e) {
console.warn('sqlite-err', e);
androidModule.showToast(err)
@ -354,6 +372,25 @@
androidModule.showToast(err)
}
// #endif
uni.$on('uploadSuccess',() => {
this.clear()
})
uni.$on('assetsSync',async () => {
try{
await executeSql(`
DELETE from log;
`)
await executeSql(`
UPDATE sqlite_sequence SET seq = 0 where name = 'log';
`)
}catch(err){
}
})
},
destroyed() {
uni.$off()
}
}
</script>

@ -29,7 +29,7 @@
</view>
<view slot="foot">
<u-button :ripple="true" :custom-style="btnStyle" @click="uploadClick"></u-button>
<u-button :disabled="isUpload" :ripple="true" :custom-style="btnStyle" @click="uploadClick">{{ isUpload ? "" : "" }}</u-button>
</view>
</u-card>
</view>
@ -57,6 +57,7 @@
num: 0
},
isConnect: false,
isUpload:false,
btnStyle: {
"color": "#fff",
'background': "#107fc9"
@ -86,8 +87,10 @@
}
androidModule.showToast("开始上传...")
this.isUpload = true
for(let i = 0;i < res.length;i++){
if(res[i].files){
let picRes = await uni.uploadFile({
url:`${ROOTPATH}/index.php?s=/Home/Worker/upload.html`,
filePath:res[i].files,
@ -95,6 +98,7 @@
})
res[i].files = JSON.parse(picRes[1]?.data).data?.id
}
}
let promiseAll = res.map(item => {
return this.upload(item)
@ -104,18 +108,20 @@
console.log(result);
androidModule.showToast(`上传成功`)
this.isUpload = false
//
await executeSql(`
DELETE from property;
`)
await executeSql(`
UPDATE sqlite_sequence SET seq = 0 where name = 'property';
delete from property where is_check = 1;
`)
//
await executeSql(`
INSERT INTO log (remark) VALUES ("数据上传");
`)
await this.getInitInfo()
uni.$emit('uploadSuccess',{msg:'success'})
}catch(err){
console.warn('sqlite-err',err)
androidModule.showToast(err)

Loading…
Cancel
Save