Commit 475994b0 by huangqy

系统配置的相关

parent dfeccf20
...@@ -27,6 +27,7 @@ export {HjInfo} from './src/main/ets/entity/HjInfo'; ...@@ -27,6 +27,7 @@ export {HjInfo} from './src/main/ets/entity/HjInfo';
export {WzPositionClass} from './src/main/ets/entity/WzPositionClass'; export {WzPositionClass} from './src/main/ets/entity/WzPositionClass';
export {WzdmDao} from './src/main/ets/db/dao/WzdmDao'; export {WzdmDao} from './src/main/ets/db/dao/WzdmDao';
export {WzhxdmDao} from './src/main/ets/db/dao/WzhxdmDao'; export {WzhxdmDao} from './src/main/ets/db/dao/WzhxdmDao';
export {XtpzInfoDao} from './src/main/ets/db/dao/XtpzInfoDao'
export {Wzdm} from './src/main/ets/entity/Wzdm'; export {Wzdm} from './src/main/ets/entity/Wzdm';
export {Wzhxdm} from './src/main/ets/entity/Wzhxdm'; export {Wzhxdm} from './src/main/ets/entity/Wzhxdm';
export {DrInfo} from './src/main/ets/entity/DrInfo'; export {DrInfo} from './src/main/ets/entity/DrInfo';
......
import relationalStore from '@ohos.data.relationalStore'; import relationalStore from '@ohos.data.relationalStore';
import { Wzhxdm } from '../../entity/Wzhxdm'; import { Wzhxdm } from '../../entity/Wzhxdm';
import { Logger } from '../../utils/Logger';
import BaseTable, { ValueType } from '../BaseTable'; import BaseTable, { ValueType } from '../BaseTable';
import { Table } from '../decorator/Decorators'; import { Table } from '../decorator/Decorators';
import { NativeSql } from '../sql/NativeSql'; import { NativeSql } from '../sql/NativeSql';
......
...@@ -52,4 +52,28 @@ export class XtpzInfoDao extends BaseTable<XtpzInfo> { ...@@ -52,4 +52,28 @@ export class XtpzInfoDao extends BaseTable<XtpzInfo> {
getCreateTableSql(): string { getCreateTableSql(): string {
return NativeSql.getXtpzInfoTable(); return NativeSql.getXtpzInfoTable();
} }
async updateSystemSql(params) {
try {
let val_sql = NativeSql.update_system_sql(params)
let db = await this.futureDb;
let rs = await db.executeSql(val_sql);
return rs;
} catch (e) {
throw new Error('[插入异常]|' + e)
}
}
async insertSystemSql(params) {
try {
let val_sql = NativeSql.insert_system_sql(params)
let db = await this.futureDb;
let rs = await db.executeSql(val_sql);
return rs;
} catch (e) {
throw new Error('[插入异常]|' + e)
}
}
} }
\ No newline at end of file
import { Bggl } from '../../entity/Bggl'; import { Bggl } from '../../entity/Bggl';
import { dateUtils, uuid } from '../../utils/util'; import { dateUtils, uuid, isEmpty } from '../../utils/util';
export class NativeSql { export class NativeSql {
/** /**
...@@ -193,6 +193,18 @@ WHERE ...@@ -193,6 +193,18 @@ WHERE
return `update tab_bzgl_knzy_app_wzcrk set crkrq = '${time}',ydh = '${params.ydh}' ,dec = '${params.dec}' where guid = '${params.wzcrkguid}'` return `update tab_bzgl_knzy_app_wzcrk set crkrq = '${time}',ydh = '${params.ydh}' ,dec = '${params.dec}' where guid = '${params.wzcrkguid}'`
} }
// 新增系统信息
static insert_system_sql(params): string {
return `insert into sysconfig_table (APPID, IMPORTBBH, XLH, INFORM, SYSTEMNAME, VERSION, GZND, HTTPURL,SCOKETURL, HTTPPORT, SCOKETPORT, THEMENAME, THEMECOLOR, RECONNECTIONMODE, PUSHMODE, TRANSMISSIONMODE,CONTINUESCANMODE, SCANREADMODE, SCANNINGMODE,BROADCASTKEY,POWER) values (${isEmpty(params.AppId)},${isEmpty(params.importbbh)},${isEmpty(params.seriesNumber)},${isEmpty(params.inform)},${isEmpty(params.systemName)},${isEmpty(params.version)},${isEmpty(params.gznd)},${isEmpty(params.httpURL)},${isEmpty(params.scoketURL)},${isEmpty(params.httpPORT)},${isEmpty(params.scoketPORT)},${isEmpty(params.themeName)},${isEmpty(params.themeColor)},${isEmpty(params.reconnection_mode)},${isEmpty(params.push_mode)},${isEmpty(params.transmission_mode)},${isEmpty(params.continue_scan_mode)},${isEmpty(params.scan_read_mode)},${isEmpty(params.scanning_mode)},${isEmpty(params.broadcastKey)}, ${isEmpty(params.power)} );`;
}
// 更新系统信息
static update_system_sql(params): string {
// XLH = ${isEmpty(params.seriesNumber)} ,
return `update sysconfig_table set IMPORTBBH = ${isEmpty(params.importbbh)} , INFORM = ${isEmpty(params.inform)} , SYSTEMNAME = ${isEmpty(params.systemName)} , VERSION = ${isEmpty(params.version)} , GZND = ${isEmpty(params.gznd)} , HTTPURL = ${isEmpty(params.httpURL)},SCOKETURL= ${isEmpty(params.scoketURL)} , HTTPPORT = ${isEmpty(params.httpPORT)} ,SCOKETPORT = ${isEmpty(params.scoketPORT)}, THEMENAME = ${isEmpty(params.themeName)} , THEMECOLOR = ${isEmpty(params.themeColor)} , RECONNECTIONMODE = ${isEmpty(params.reconnection_mode)} , PUSHMODE = ${isEmpty(params.push_mode)} , TRANSMISSIONMODE = ${isEmpty(params.transmission_mode)} , CONTINUESCANMODE = ${isEmpty(params.continue_scan_mode)} , SCANREADMODE = ${isEmpty(params.scan_read_mode)} , SCANNINGMODE = ${isEmpty(params.scanning_mode)} , BROADCASTKEY = ${isEmpty(params.broadcastKey)} ,POWER = ${isEmpty(params.power)} where APPID = ${isEmpty(params.AppId)} ;`
}
/** /**
* 包裹管理表 * 包裹管理表
*/ */
......
import { XtpzInfoDao, SQLiteContext } from '@ohos/common'
// 系统配置
class XtpzInfoModel {
async insertSystemSql(params) {
let res = await SQLiteContext.with(XtpzInfoDao).insertSystemSql(params)
return res;
}
async updateSystemSql(params) {
let res = await SQLiteContext.with(XtpzInfoDao).updateSystemSql(params)
return res;
}
// 清空表
async clear() {
await SQLiteContext.with(XtpzInfoDao).clearTable()
}
}
const xtpzInfoModel = new XtpzInfoModel()
export default xtpzInfoModel
\ No newline at end of file
...@@ -2,6 +2,7 @@ import { generalInitList, scanInitList, systemList, UniListItem } from '@ohos/sy ...@@ -2,6 +2,7 @@ import { generalInitList, scanInitList, systemList, UniListItem } from '@ohos/sy
import { TitleBar } from '../../view/title/TitleBar' import { TitleBar } from '../../view/title/TitleBar'
import promptAction from '@ohos.promptAction' import promptAction from '@ohos.promptAction'
import { GeneralDialog } from '../../view/GeneralDialog/GeneralDialog' import { GeneralDialog } from '../../view/GeneralDialog/GeneralDialog'
import xtpzInfoModel from '../../model/XtpzInfoModel'
@Extend(Button) function CommonButtonStyle() { @Extend(Button) function CommonButtonStyle() {
.borderWidth(2) .borderWidth(2)
...@@ -59,6 +60,74 @@ export struct General { ...@@ -59,6 +60,74 @@ export struct General {
power: "" power: ""
} }
onPageShow() {
this.init()
}
/***
* @description: 初始化
* @param {*}
* @return {*}
* @author: 王弘钢
*/
async init() {
try {
// const sysRes = await selectInformationType("GY_M_PMV3", sqlCommon.systemSql)
// const data = this.convertionToggleCase(sysRes)
// console.log('data', data)
// this.formData = {
// sbbm: '',
// ...data
// }
// this.handleGetSbbm()
} catch (e) {
//TODO handle the exception
promptAction.showToast({
message: '初始配置失败'
})
}
}
/***
* @description: 保存
* @param {*}
* @return {*}
* @author: 王弘钢
*/
async handleSystemSubmit() {
try {
const params = this.formData
await this.updateSystemFun(params)
this.init()
promptAction.showToast({
message: '修改配置成功'
})
} catch (e) {
//TODO handle the exception
promptAction.showToast({
message: '修改配置失败'
})
}
}
/***
* @description: 更新系统配置
* @param {*}
* @return {*}
* @author: 王弘钢
*/
async updateSystemFun(params) {
try {
await xtpzInfoModel.updateSystemSql(params)
} catch (e) {
//TODO handle the exception
promptAction.showToast({
message: '更新配置失败'
})
}
}
getListInfo(index:number):UniListItem[]{ getListInfo(index:number):UniListItem[]{
switch (index){ switch (index){
case 0: case 0:
...@@ -75,8 +144,6 @@ export struct General { ...@@ -75,8 +144,6 @@ export struct General {
dialogController: CustomDialogController = new CustomDialogController({ dialogController: CustomDialogController = new CustomDialogController({
builder: GeneralDialog({ builder: GeneralDialog({
cancel: this.onCancel,
confirm: this.onSubmit,
clickItem: $clickItem, clickItem: $clickItem,
formData: $formData, formData: $formData,
}), }),
...@@ -85,14 +152,6 @@ export struct General { ...@@ -85,14 +152,6 @@ export struct General {
customStyle: true customStyle: true
}) })
onCancel() {
console.info('------取消------')
}
onSubmit() {
console.info('------确认------')
}
build() { build() {
Column() { Column() {
...@@ -164,9 +223,7 @@ export struct General { ...@@ -164,9 +223,7 @@ export struct General {
Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) { Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) {
Button("保存").CommonButtonStyle().onClick(() => { Button("保存").CommonButtonStyle().onClick(() => {
promptAction.showToast({ this.handleSystemSubmit()
message: JSON.stringify(this.formData)
})
}) })
Button("重置").CommonButtonStyle() Button("重置").CommonButtonStyle()
} }
......
import { UniListItem } from '@ohos/system/src/main/ets/model/UniInitList'; import { UniListItem } from '@ohos/system/src/main/ets/model/UniInitList';
import promptAction from '@ohos.promptAction';
@Extend(Button) function CommonButtonStyle() { @Extend(Button) function CommonButtonStyle() {
.borderWidth(2) .borderWidth(2)
.borderColor('#0fa983') .borderColor('#0fa983')
...@@ -34,8 +35,33 @@ export struct GeneralDialog { ...@@ -34,8 +35,33 @@ export struct GeneralDialog {
@Link formData: FormData; @Link formData: FormData;
@Link clickItem: UniListItem @Link clickItem: UniListItem
controller: CustomDialogController controller: CustomDialogController
cancel: () => void
confirm: () => void /***
* @description: 弹框确认
* @param {*}
* @return {*}
* @author: 王弘钢
*/
handleSubmit() {
if (!this.formData[this.clickItem?.key]) {
// 请完善信息
promptAction.showToast({
message: '请完善' + this.clickItem.title + '信息',
})
return
}
this.handleClosePopup()
}
/***
* @description: 关闭弹框
* @param {*}
* @return {*}
* @author: 王弘钢
*/
handleClosePopup() {
this.controller.close()
}
build() { build() {
Column() { Column() {
...@@ -106,14 +132,12 @@ export struct GeneralDialog { ...@@ -106,14 +132,12 @@ export struct GeneralDialog {
Flex({ justifyContent: FlexAlign.SpaceAround }) { Flex({ justifyContent: FlexAlign.SpaceAround }) {
Button('确认') Button('确认')
.onClick(() => { .onClick(() => {
this.controller.close() this.handleSubmit()
this.confirm()
}).CommonButtonStyle() }).CommonButtonStyle()
Button('取消') Button('取消')
.onClick(() => { .onClick(() => {
this.formData[this.clickItem?.key] = '' this.formData[this.clickItem?.key] = ''
this.controller.close() this.controller.close()
this.cancel()
}).CommonButtonStyle() }).CommonButtonStyle()
}.margin({ top: 10, bottom: 10 }) }.margin({ top: 10, bottom: 10 })
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论