Commit 3ee1d9e0 by 陈桂东

数据保存

parent 9521010d
...@@ -58,4 +58,18 @@ export class GldwDao extends BaseTable<Gldw> { ...@@ -58,4 +58,18 @@ export class GldwDao extends BaseTable<Gldw> {
} }
return this.query(wp, this.getTableColumns()); return this.query(wp, this.getTableColumns());
} }
/**
* 询管理单位列表
* @param 库房名称
*/
async queryByData(data:Partial<Gldw>): Promise<Gldw[]> {
let wp = this.getPredicates();
for (const [key, value] of Object.entries(data)) {
wp.equalTo(key,value)
}
wp.orderByAsc("DWDM");
return this.query(wp, this.getTableColumns());
}
} }
...@@ -48,10 +48,13 @@ export class KfInfoDao extends BaseTable<KfInfo> { ...@@ -48,10 +48,13 @@ export class KfInfoDao extends BaseTable<KfInfo> {
* 查询库房列表 * 查询库房列表
* @param 库房名称 * @param 库房名称
*/ */
async getKf(kfmc: string): Promise<KfInfo[]> { async getKf(data:Partial<KfInfo>): Promise<KfInfo[]> {
let wp = this.getPredicates(); let wp = this.getPredicates();
if (kfmc) { // if (kfmc) {
wp.like('KFMC', `%${kfmc}%`); // wp.like('KFMC', `%${kfmc}%`);
// }
for (const [key, value] of Object.entries(data)) {
wp.equalTo(key,value)
} }
wp.orderByAsc("KFDM"); wp.orderByAsc("KFDM");
return this.query(wp, this.getTableColumns()); return this.query(wp, this.getTableColumns());
......
...@@ -128,4 +128,20 @@ export class WzcrkmxDao extends BaseTable<Wzcrkmx> { ...@@ -128,4 +128,20 @@ export class WzcrkmxDao extends BaseTable<Wzcrkmx> {
wp.equalTo('WZCRKGUID', wzcrkguid) wp.equalTo('WZCRKGUID', wzcrkguid)
return this.query(wp, this.getTableColumns()); return this.query(wp, this.getTableColumns());
} }
/**
* 更新单据状态
*/
async updateWcztmxByData(guid: string, data: Partial<Wzcrkmx>): Promise<number> {
const valueBucket = {
// "wczt": wczt
};
for (const [key, value] of Object.entries(data)) {
valueBucket[key] = value
}
let wp = this.getPredicates()
wp.equalTo('guid', guid)
return this.updateData(valueBucket, wp)
}
} }
\ No newline at end of file
...@@ -14,6 +14,12 @@ class GldwModel { ...@@ -14,6 +14,12 @@ class GldwModel {
return res; return res;
} }
// 查询管理单位
async queryByData(data:Partial<Gldw>): Promise<Gldw[]> {
let res = await SQLiteContext.with(GldwDao).queryByData(data)
return res;
}
// 清空表 // 清空表
async clear() { async clear() {
await SQLiteContext.with(GldwDao).clearTable() await SQLiteContext.with(GldwDao).clearTable()
......
...@@ -8,8 +8,8 @@ class KfModel { ...@@ -8,8 +8,8 @@ class KfModel {
} }
// 查询库房 // 查询库房
async query(kfmc? : string): Promise<KfInfo[]> { async query(data: Partial<KfInfo>): Promise<KfInfo[]> {
let res = await SQLiteContext.with(KfInfoDao).getKf(kfmc) let res = await SQLiteContext.with(KfInfoDao).getKf(data)
return res; return res;
} }
......
...@@ -13,11 +13,19 @@ class WzcrkmxModel { ...@@ -13,11 +13,19 @@ class WzcrkmxModel {
return res; return res;
} }
// 更新单据信息
async updateWcztmxByData(guid: string, data: Partial<Wzcrkmx>):Promise<number> {
let res = await SQLiteContext.with(WzcrkmxDao).updateWcztmxByData(guid, data)
return res;
}
// 清空表 // 清空表
async clear() { async clear() {
await SQLiteContext.with(WzcrkmxDao).clearTable() await SQLiteContext.with(WzcrkmxDao).clearTable()
} }
} }
const wzcrkmxModel = new WzcrkmxModel() const wzcrkmxModel = new WzcrkmxModel()
export default wzcrkmxModel export default wzcrkmxModel
\ No newline at end of file
import { pzlx_dict, szlx_dict,new_zmlx_dict } from '@ohos/common' import { pzlx_dict, szlx_dict,new_zmlx_dict, Logger } from '@ohos/common'
@Observed @Observed
export class WzinClass { export class WzinClass {
guid?: string guid?: string
...@@ -247,16 +247,19 @@ export class WzmxClass { ...@@ -247,16 +247,19 @@ export class WzmxClass {
// 凭证类型 // 凭证类型
export function renderPzlx(pzlx) { export function renderPzlx(pzlx) {
Logger.info('szlx>>', pzlx)
const res = pzlx_dict.find(v => v.value == pzlx) const res = pzlx_dict.find(v => v.value == pzlx)
return res ? res.text : '' return res ? res.text : ''
} }
// 收支类型 // 收支类型
export function renderSzlx(szlx) { export function renderSzlx(szlx) {
Logger.info('szlx>>', szlx)
const res = szlx_dict.find(v => v.value == szlx) const res = szlx_dict.find(v => v.value == szlx)
return res ? res.text : '' return res ? res.text : ''
} }
// 账目类型 // 账目类型
export function renderZmlx(zmlx) { export function renderZmlx(zmlx) {
Logger.info('szlx>>', zmlx)
const res = new_zmlx_dict.find(v => v.value == zmlx) const res = new_zmlx_dict.find(v => v.value == zmlx)
return res ? res.text : '' return res ? res.text : ''
} }
\ No newline at end of file
import { Wzcrk } from '@ohos/common/src/main/ets/entity/Wzcrk' import { Wzcrk } from '@ohos/common/src/main/ets/entity/Wzcrk'
import gldwModel from '../../../../model/GldwModel'
import kfModel from '../../../../model/KfModel'
import { renderPzlx, renderSzlx, renderZmlx, WzinClass } from '../Wzin.data' import { renderPzlx, renderSzlx, renderZmlx, WzinClass } from '../Wzin.data'
@Component @Component
// 物资信息 // 物资信息
export struct PzInfo { export struct PzInfo {
@State kfmc: string = ''
@State fwgldw: string = ''
@State swgldw: string = ''
arr = [{ title: "凭证类型", key: 'pzlx', enabled: false }, arr = [{ title: "凭证类型", key: 'pzlx', enabled: false },
{ title: "凭证号", key: 'pzh', enabled: false }, { title: "凭证号", key: 'pzh', enabled: false },
{ title: "库房", key: 'kfguid', enabled: false }, { title: "库房", key: 'kfguid', enabled: false },
...@@ -13,6 +19,21 @@ export struct PzInfo { ...@@ -13,6 +19,21 @@ export struct PzInfo {
{ title: "备注", key: 'dec', enabled: true } { title: "备注", key: 'dec', enabled: true }
] ]
aboutToAppear(){
this.getData()
}
async getData() {
const res = await kfModel.query({guid: this.wzcrk.kfguid})
this.kfmc = res[0].kfmc ?? ''
const res1 = await gldwModel.queryByData({dwdm:this.wzcrk.fwgldwdm})
this.fwgldw = res1[0].dwfh ?? ''
const res2 = await gldwModel.queryByData({dwdm:this.wzcrk.swgldwdm})
this.swgldw = res2[0].dwfh ?? ''
}
@ObjectLink wzcrk: WzinClass @ObjectLink wzcrk: WzinClass
handleText(key: string): string { handleText(key: string): string {
...@@ -26,6 +47,15 @@ export struct PzInfo { ...@@ -26,6 +47,15 @@ export struct PzInfo {
case 'zmlx': case 'zmlx':
return renderZmlx(this.wzcrk.zmlx) return renderZmlx(this.wzcrk.zmlx)
case 'kfguid':
return this.kfmc
case 'fwgldwdm':
return this.fwgldw
case 'swgldwdm':
return this.swgldw
default: default:
return String(this.wzcrk[key]) return String(this.wzcrk[key])
} }
...@@ -52,7 +82,9 @@ export struct PzInfo { ...@@ -52,7 +82,9 @@ export struct PzInfo {
.backgroundColor(item.enabled ? '#fff' : "app.color.disabledColor") .backgroundColor(item.enabled ? '#fff' : "app.color.disabledColor")
.enabled(item.enabled) .enabled(item.enabled)
.onChange((value: string) => { .onChange((value: string) => {
if(item.enabled) {
this.wzcrk[item.key] = value this.wzcrk[item.key] = value
}
}) })
}.padding("10vp") }.padding("10vp")
}) })
......
...@@ -113,14 +113,21 @@ struct WzinDetail { ...@@ -113,14 +113,21 @@ struct WzinDetail {
try { try {
Logger.info('保存的入库数据>>', JSON.stringify(this.wzcrk)) Logger.info('保存的入库数据>>', JSON.stringify(this.wzcrk))
Logger.info('保存的入库明细数据>>', JSON.stringify(this.wzmx))
await wzcrkModel.updateWcztByData(this.wzcrk.guid, { dec: this.wzcrk.dec, ydh: this.wzcrk.ydh }) await wzcrkModel.updateWcztByData(this.wzcrk.guid, { dec: this.wzcrk.dec, ydh: this.wzcrk.ydh })
for (let index = 0; index < this.wzmx.length; index++) {
const element = this.wzmx[index];
await wzcrkmxModel.updateWcztmxByData(element.guid, {crksl:element.crksl})
}
promptAction.showToast({ promptAction.showToast({
message: '保存入库数据成功', message: '保存入库数据成功',
bottom: 200 bottom: 200
}) })
setTimeout(() => { setTimeout(() => {
router.pushUrl({ url: 'pages/metailmange/WzInPage/WzInPage' }) router.replaceUrl({ url: 'pages/metailmange/WzInPage/WzInPage' })
}, 1000) }, 500)
}catch (e) { }catch (e) {
promptAction.showToast({ promptAction.showToast({
message: '保存入库数据失败', message: '保存入库数据失败',
......
...@@ -16,7 +16,7 @@ export struct Warehouse { ...@@ -16,7 +16,7 @@ export struct Warehouse {
// 获取库房数据 // 获取库房数据
async getWarehouseList(kfmc?: string ) { async getWarehouseList(kfmc?: string ) {
const res = await kfModel.query(kfmc) const res = await kfModel.query({kfmc})
this.dataSource = res this.dataSource = res
Logger.info(this, "库房数据>" + JSON.stringify(res)); Logger.info(this, "库房数据>" + JSON.stringify(res));
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论