代码优化

dev2
Panzihang 2023-08-01 16:32:50 +08:00
parent 9daa1cb4b2
commit 710a105632
6 changed files with 86 additions and 70 deletions

View File

@ -81,7 +81,7 @@ module.exports = {
createShipmentShipLoadPlansRespList() { createShipmentShipLoadPlansRespList() {
console.log("创建作业查询表"); console.log("创建作业查询表");
let sql = let sql =
'CREATE TABLE if not exists shipmentShipLoadPlansRespList ("webId" text NOT NULL,"agentId" text,"agentName" text,"amount" text,"brdId" text,"brdName" text,"bvdId" text,"bvdName" text,"bvmId" text,"bvmName" text,"carHeight" text,"carLength" text,"carWidth" text,"customsDeclareNo" text,"customsDeclareStatus" text,"mnfBl" text,"potId" text,"potName" text,"sourceType" text,"vvyId" text,"vvyName" text,"yardPos" text, PRIMARY KEY("webId"));' 'CREATE TABLE if not exists shipmentShipLoadPlansRespList ("webId" text NOT NULL,"agentId" text,"agentName" text,"amount" text,"brdId" text,"brdName" text,"bvdId" text,"bvdName" text,"bvmId" text,"bvmName" text,"carHeight" text,"carLength" text,"carWidth" text,"customsDeclareNo" text,"customsDeclareStatus" text,"mnfBl" text,"potId" text,"potName" text,"sourceType" text,"vvyId" text,"vvyName" text,"yardPos" text,"webStatus" text,"webDate" text, PRIMARY KEY("webId"));'
this.executeSql(sql) this.executeSql(sql)
}, },
executeSql(sql) { executeSql(sql) {

View File

@ -34,6 +34,7 @@
</template> </template>
<script> <script>
import sqlite from "../../common/sqlite.js"
export default { export default {
data() { data() {
return { return {
@ -46,7 +47,7 @@
} }
}, },
mounted() { mounted() {
this.initData() this.executeSql1('shipmentShipLoadPlansRespList')
setTimeout(() => { setTimeout(() => {
this.menuList = [{ this.menuList = [{
'title': '按港口', 'title': '按港口',
@ -168,50 +169,17 @@
}, 2000) }, 2000)
}, },
methods: { methods: {
initData() { //
this.listInfo = [{ executeSql1(tableName) {
brdName: "特斯拉", let sql = `select * from ${tableName}`
mnfBl: "TD85875876", sqlite.executeSqlCeshi(sql).then((value) => {
sourceType: "新能源", // resolve
yardPos: "C4区15道*2,16道*2", this.listInfo = value
vvyName: "HC8595986", console.log(this.listInfo)
customsDeclareStatus: "未报关", }).catch((error) => {
bvmName: "轿车", // reject
amount: "100", console.error(error);
potName: "巴塞罗那", });
customsDeclareNo: "BG09759724",
bvdName: "无动力半挂车",
agentName: "华图供应链管理(天津)有限公司",
},
{
brdName: "比亚迪",
mnfBl: "TD85875876A",
sourceType: "新能源",
yardPos: "C4区15道*2,16道*2",
vvyName: "HC8595986",
customsDeclareStatus: "未报关",
bvmName: "轿车",
amount: "100",
potName: "巴塞罗那",
customsDeclareNo: "BG09759724",
bvdName: "无动力半挂车",
agentName: "华图供应链管理(天津)有限公司",
},
{
brdName: "比亚迪",
mnfBl: "TD85875876A",
sourceType: "新能源",
yardPos: "C4区15道*2,16道*2",
vvyName: "HC8595986",
customsDeclareStatus: "未报关",
bvmName: "轿车",
amount: "100",
potName: "巴塞罗那",
customsDeclareNo: "BG09759724",
bvdName: "无动力半挂车",
agentName: "华图供应链管理(天津)有限公司",
}
]
}, },
// //
iconClick() { iconClick() {
@ -243,7 +211,6 @@
resultConditon(obj) { resultConditon(obj) {
this.$refs.condition.visibleDrawer = false; this.$refs.condition.visibleDrawer = false;
this.hasChoose = obj.hasChoose; this.hasChoose = obj.hasChoose;
console.log(obj);
}, },
// //
togoCar(item) { togoCar(item) {

View File

@ -97,6 +97,7 @@
import HeadInfo from '@/components/head-info/head-info'; import HeadInfo from '@/components/head-info/head-info';
import sqlite from "../../common/sqlite.js" import sqlite from "../../common/sqlite.js"
import tableList from "../../common/createDataTable.js" import tableList from "../../common/createDataTable.js"
import api from "../../common/api.js"
export default { export default {
data() { data() {
return { return {
@ -114,11 +115,55 @@
pageSize: 4, pageSize: 4,
current: 1, current: 1,
shipInfo: {} shipInfo: {},
} workList: [{
agentId: "1",
agentName: "华图供应链管理(天津)有限公司",
amount: "100",
brdId: "1",
brdName: "特斯拉1",
bvdId: "1",
bvdName: "无动力半挂车",
bvmId: "1",
bvmName: "轿车",
carHeight: "100",
carLength: "111",
carWidth: "123",
customsDeclareNo: "BG09759724",
customsDeclareStatus: "未报关",
mnfBl: "TD85875876",
potId: "1",
potName: "巴塞罗那",
sourceType: "新能源",
vvyId: "1",
vvyName: "HC8595986",
yardPos: "C4区15道*2,16道*2",
}, },
onLoad() { {
agentId: "1",
agentName: "华图供应链管理(天津)有限公司",
amount: "100",
brdId: "1",
brdName: "特斯拉2",
bvdId: "1",
bvdName: "无动力半挂车",
bvmId: "1",
bvmName: "轿车",
carHeight: "100",
carLength: "111",
carWidth: "123",
customsDeclareNo: "BG09759724",
customsDeclareStatus: "未报关",
mnfBl: "TD85875876",
potId: "1",
potName: "巴塞罗那",
sourceType: "新能源",
vvyId: "1",
vvyName: "HC8595986",
yardPos: "C4区15道*2,16道*2",
}
]
}
}, },
components: { components: {
SideBar, SideBar,
@ -165,11 +210,11 @@
}, },
dropTable() { dropTable() {
console.log('删除表'); console.log('删除表');
let sql = 'DROP TABLE attachUnmoorRespList;' let sql = 'DROP TABLE shipmentShipLoadPlansRespList;'
this.executeSql(sql) this.executeSql(sql)
}, },
dropData() { dropData() {
let sql = "delete from messageRespList" let sql = "delete from shipmentShipLoadPlansRespList"
this.executeSql(sql) this.executeSql(sql)
}, },
add() { add() {
@ -282,6 +327,22 @@
download(item) { download(item) {
// //
tableList.createAllTable() tableList.createAllTable()
let webStatus = 0
let sql = ""
for (let i = 0; i < this.workList.length; i++) {
let date = new Date().getTime()
let str = String(date)
let webId = Number(str.slice(str.length - 5))
let webDate = api.getDate(date)
sql =
`insert into shipmentShipLoadPlansRespList values('${webId}','${this.workList[i].agentId}','${this.workList[i].agentName}',
'${this.workList[i].amount}','${this.workList[i].brdId}','${this.workList[i].brdName}','${this.workList[i].bvdId}','${this.workList[i].bvdName}','${this.workList[i].bvmId}',
'${this.workList[i].bvmName}','${this.workList[i].carHeight}','${this.workList[i].carLength}','${this.workList[i].carWidth}',
'${this.workList[i].customsDeclareNo}','${this.workList[i].customsDeclareStatus}','${this.workList[i].mnfBl}','${this.workList[i].potId}','${this.workList[i].potName}',
'${this.workList[i].sourceType}','${this.workList[i].vvyId}','${this.workList[i].vvyName}','${this.workList[i].yardPos}',
'${webStatus}','${webDate}')`
this.executeSql(sql)
}
// let ids = [] // let ids = []
// if (item.inVvyId != null && item.outVvyId == null) { // if (item.inVvyId != null && item.outVvyId == null) {
// ids.push(item.inVvyId) // ids.push(item.inVvyId)

View File

@ -39,7 +39,8 @@
}, },
methods: { methods: {
// //
executeSql(sql) { executeSql1(tableName) {
let sql = `select * from ${tableName}`
sqlite.executeSqlCeshi(sql).then((value) => { sqlite.executeSqlCeshi(sql).then((value) => {
// resolve // resolve
this.infoList = value this.infoList = value
@ -49,10 +50,6 @@
console.error(error); console.error(error);
}); });
}, },
executeSql1(tableName) {
let sql = `select * from ${tableName}`
this.executeSql(sql)
},
// //
sign() { sign() {
uni.navigateTo({ uni.navigateTo({

View File

@ -65,6 +65,7 @@
<script> <script>
import sqlite from "../../common/sqlite.js" import sqlite from "../../common/sqlite.js"
import api from "../../common/api.js"
export default { export default {
data() { data() {
return { return {
@ -208,7 +209,7 @@
let str = String(date) let str = String(date)
let webId = Number(str.slice(str.length - 5)) let webId = Number(str.slice(str.length - 5))
let webStatus = 0 let webStatus = 0
let webDate = this.getDate(date) let webDate = api.getDate(date)
if (this.obj.state == "edit") { if (this.obj.state == "edit") {
let sql = let sql =
`UPDATE shipmentQualityConsultationRespList SET vvyId = '${this.vvyId}', vvyName = '${this.vvyName}', `UPDATE shipmentQualityConsultationRespList SET vvyId = '${this.vvyId}', vvyName = '${this.vvyName}',
@ -265,17 +266,6 @@
url: `/pages/shipWork/opinionAdd?params=${params}` url: `/pages/shipWork/opinionAdd?params=${params}`
}) })
}, },
//
getDate(date) {
var date = new Date(date);
var YY = date.getFullYear() + '-';
var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
return YY + MM + DD + " " + hh + mm + ss;
},
executeSql(sql) { executeSql(sql) {
sqlite.executeSqlCeshi(sql).then((value) => { sqlite.executeSqlCeshi(sql).then((value) => {
// resolve // resolve

View File

@ -167,6 +167,7 @@
} }
}); });
} }
} }
}; };
</script> </script>