Commit f7024cbe by huangqy

查询功能

parent 9c216eae
...@@ -118,11 +118,14 @@ export class WzcrkDao extends BaseTable<Wzcrk> { ...@@ -118,11 +118,14 @@ export class WzcrkDao extends BaseTable<Wzcrk> {
return this.update(item,predicates) return this.update(item,predicates)
} }
async getWzcrk(crklx: string, pzh?: number): Promise<Wzcrk[]> { async getWzcrk(crklx: string, pzh?: string, wczt?: string): Promise<Wzcrk[]> {
let wp = this.getPredicates(); let wp = this.getPredicates();
if (pzh) { if (pzh) {
wp.equalTo('PZH', pzh) wp.equalTo('PZH', pzh)
} }
if (wczt) {
wp.equalTo('WCZT', wczt)
}
wp.equalTo('CRKLX', crklx) wp.equalTo('CRKLX', crklx)
wp.orderByAsc('PZH'); wp.orderByAsc('PZH');
return this.query(wp, this.getTableColumns()); return this.query(wp, this.getTableColumns());
......
...@@ -43,8 +43,8 @@ class WzcrkModel { ...@@ -43,8 +43,8 @@ class WzcrkModel {
} }
// 查询 // 查询
async query(crklx:string, pzh?: number): Promise<Wzcrk[]> { async query(crklx:string, pzh?: string, wczt?: string): Promise<Wzcrk[]> {
let res = await SQLiteContext.with(WzcrkDao).getWzcrk(crklx) let res = await SQLiteContext.with(WzcrkDao).getWzcrk(crklx, pzh, wczt)
return res; return res;
} }
/*获取物资出入库*/ /*获取物资出入库*/
......
...@@ -12,7 +12,11 @@ export struct WzInList { ...@@ -12,7 +12,11 @@ export struct WzInList {
.selectedColor('#007DFF') .selectedColor('#007DFF')
.select(this.checkedList.includes(this.item.guid)) .select(this.checkedList.includes(this.item.guid))
.onChange((value: boolean) => { .onChange((value: boolean) => {
console.info('Checkbox1 change is' + value) if (value) {
this.checkedList.push(this.item.guid)
} else {
this.checkedList = this.checkedList.filter(i => i !== this.item.guid);
}
}).margin({ right: 10, left: 10 }) }).margin({ right: 10, left: 10 })
Column() { Column() {
Text(this.item.crkrq).alignSelf(ItemAlign.Start).width("30%") Text(this.item.crkrq).alignSelf(ItemAlign.Start).width("30%")
...@@ -45,7 +49,7 @@ export struct WzInList { ...@@ -45,7 +49,7 @@ export struct WzInList {
Row() { Row() {
Text("状态:") Text("状态:")
if(this.item.wczt != '未完成') { if(this.item.wczt == '未完成') {
Text( "未完成").fontColor('#ff3d43') Text( "未完成").fontColor('#ff3d43')
} }
else { else {
......
import { TitleBar } from '../../../view/title/TitleBar' import { TitleBar } from '../../../view/title/TitleBar'
import router from '@ohos.router'; import router from '@ohos.router';
import { WzInList } from './WzInList'; import { WzInList } from './WzInList';
import { BasicDialog } from '../../../view/BasicDialog/BasicDialog';
import wzcrkModel from '../../../model/WzcrkModel'; import wzcrkModel from '../../../model/WzcrkModel';
import { Logger } from '@ohos/common/src/main/ets/utils/Logger'; import { Logger } from '@ohos/common/src/main/ets/utils/Logger';
import { WzinClass } from './Wzin.data' import { WzinClass } from './Wzin.data'
import promptAction from '@ohos.promptAction'; import promptAction from '@ohos.promptAction';
import { SetStatusDialog } from '../../../view/SetStatusDialog/SetStatusDialog';
@Extend(Button) function bottomBtnSty() { @Extend(Button) function bottomBtnSty() {
.borderWidth(1) .borderWidth(1)
...@@ -18,6 +18,11 @@ import promptAction from '@ohos.promptAction'; ...@@ -18,6 +18,11 @@ import promptAction from '@ohos.promptAction';
.stateEffect(true) .stateEffect(true)
} }
interface SearchData {
pzh?: string;
wczt?: string;
}
@Entry @Entry
@Component @Component
export struct WzInPage { export struct WzInPage {
...@@ -26,6 +31,11 @@ export struct WzInPage { ...@@ -26,6 +31,11 @@ export struct WzInPage {
@State currentIndex: number = 0 @State currentIndex: number = 0
@State dataSource: WzinClass[] = [] @State dataSource: WzinClass[] = []
@State checkedList: Array<string> = [] @State checkedList: Array<string> = []
@State radioChecked: boolean = true
@State searchData: SearchData = {
pzh: '',
wczt: '未完成'
}
private controller: TabsController = new TabsController() private controller: TabsController = new TabsController()
private searchcontroller: SearchController = new SearchController() private searchcontroller: SearchController = new SearchController()
@State defaultSelectValue:Array<SelectOption>=[{ value: "未完成" }, { value: "已完成" }] @State defaultSelectValue:Array<SelectOption>=[{ value: "未完成" }, { value: "已完成" }]
...@@ -51,8 +61,10 @@ export struct WzInPage { ...@@ -51,8 +61,10 @@ export struct WzInPage {
this.getWzcrkList() this.getWzcrkList()
} }
async getWzcrkList(qzh?: number) { async getWzcrkList(qzh?: number, wczt?: string) {
const res = await wzcrkModel.query('2', qzh) Logger.info('出入库传入参数>>:', JSON.stringify(this.searchData))
this.dataSource = []
const res = await wzcrkModel.query('2', this.searchData.pzh, this.searchData.wczt)
Logger.info('出入库数据>>:', JSON.stringify(res)) Logger.info('出入库数据>>:', JSON.stringify(res))
Logger.info('出入库数据长度>>:', JSON.stringify(res.length)) Logger.info('出入库数据长度>>:', JSON.stringify(res.length))
for (let index = 0; index < res.length; index++) { for (let index = 0; index < res.length; index++) {
...@@ -67,36 +79,35 @@ export struct WzInPage { ...@@ -67,36 +79,35 @@ export struct WzInPage {
Flex({ justifyContent: FlexAlign.SpaceBetween }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) {
Text('完成').margin({ left: 20 }) Text('完成').margin({ left: 20 })
Radio({ value: 'Radio1', group: 'radioGroup' }) Radio({ value: 'Radio1', group: 'radioGroup' })
.checked(this.radioChecked)
.onChange((isChecked: boolean) => { .onChange((isChecked: boolean) => {
console.log('Radio1 status is ' + isChecked) this.radioChecked = isChecked
}).margin({ right: 20 }) }).margin({ right: 20 })
} }
}.padding({ top: 10, bottom: 10 }) }.padding({ top: 10, bottom: 10 })
Divider().strokeWidth(1).color('rgb(242,242,242)')
Row() { Row() {
Flex({ justifyContent: FlexAlign.SpaceBetween }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) {
Text('未完成').margin({ left: 20 }) Text('未完成').margin({ left: 20 })
Radio({ value: 'Radio1', group: 'radioGroup' }) Radio({ value: 'Radio1', group: 'radioGroup' })
.onChange((isChecked: boolean) => { .onChange((isChecked: boolean) => {
console.log('Radio1 status is ' + isChecked)
}).margin({ right: 20 }) }).margin({ right: 20 })
} }
}.padding({ top: 10, bottom: 10 }) }.padding({ top: 10, bottom: 10 })
Divider().strokeWidth(1).color('rgb(242,242,242)')
} }
} }
dialogController: CustomDialogController = new CustomDialogController({ dialogController: CustomDialogController = new CustomDialogController({
builder: BasicDialog({ builder: SetStatusDialog({
cancel: this.onCancel, cancel: this.onCancel,
confirm: this.onSubmit, confirm: this.onSubmit,
title: '设置状态', checkedList: $checkedList,
container: this.container container: this.container
}), }),
autoCancel: true, autoCancel: true,
alignment: DialogAlignment.Bottom, alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: -20 }, customStyle: true
gridCount: 4,
customStyle: false
}) })
onCancel() { onCancel() {
...@@ -104,7 +115,9 @@ export struct WzInPage { ...@@ -104,7 +115,9 @@ export struct WzInPage {
} }
onSubmit() { onSubmit() {
console.info('------确认------') promptAction.showToast({
message: '选择了这些单子,把这些单子设置为:' + (this.radioChecked ? '已完成' : '未完成') + JSON.stringify(this.checkedList)
})
} }
@Builder TabBuilder(index: number, name: string) { @Builder TabBuilder(index: number, name: string) {
...@@ -114,7 +127,7 @@ export struct WzInPage { ...@@ -114,7 +127,7 @@ export struct WzInPage {
.fontSize(16) .fontSize(16)
.lineHeight(22) .lineHeight(22)
.margin({ bottom: 7 }) .margin({ bottom: 7 })
Divider() Divider().strokeWidth(1).color('rgb(242,242,242)')
.strokeWidth(2) .strokeWidth(2)
.color('#fff') .color('#fff')
.width(50) .width(50)
...@@ -138,8 +151,14 @@ export struct WzInPage { ...@@ -138,8 +151,14 @@ export struct WzInPage {
Button("设置状态") Button("设置状态")
.bottomBtnSty() .bottomBtnSty()
.onClick(() => { .onClick(() => {
if (this.dialogController != undefined) { if (this.checkedList.length == 0) {
this.dialogController.open() promptAction.showToast({
message: '请至少选择一条单据'
})
} else {
if (this.dialogController != undefined) {
this.dialogController.open()
}
} }
}) })
.fontColor("#0fa983") .fontColor("#0fa983")
...@@ -214,6 +233,8 @@ export struct WzInPage { ...@@ -214,6 +233,8 @@ export struct WzInPage {
this.pzh=value this.pzh=value
}) })
.onChange((value: string) => { .onChange((value: string) => {
this.searchData.pzh = value
this.getWzcrkList()
}) })
.borderRadius(5) .borderRadius(5)
Select(this.currentIndex===1?this.selectValue:this.defaultSelectValue) Select(this.currentIndex===1?this.selectValue:this.defaultSelectValue)
...@@ -224,11 +245,8 @@ export struct WzInPage { ...@@ -224,11 +245,8 @@ export struct WzInPage {
.margin({ left: 10 }) .margin({ left: 10 })
.borderColor("#454545") .borderColor("#454545")
.onSelect(async (index: number, value?: string) => { .onSelect(async (index: number, value?: string) => {
if (value == '未完成') { this.searchData.wczt = value
console.log("未完成", '未完成') this.getWzcrkList()
} else {
console.log("已完成", '已完成')
}
}) })
.width(120) .width(120)
.padding({ .padding({
......
...@@ -130,7 +130,7 @@ export struct Pmhx { ...@@ -130,7 +130,7 @@ export struct Pmhx {
return { return {
...row, ...row,
sjlx:"导入", sjlx:"导入",
wzct:"未完成", wczt:"未完成",
}; };
}); });
wzcrkModel.set(mappedRows) wzcrkModel.set(mappedRows)
......
...@@ -30,13 +30,15 @@ interface FormData { ...@@ -30,13 +30,15 @@ interface FormData {
@CustomDialog @CustomDialog
@Component @Component
export struct GeneralDialog { export struct SetStatusDialog {
@Link formData: FormData;
@Link clickItem: UniListItem @Link checkedList: Array<string>
controller: CustomDialogController controller: CustomDialogController
cancel: () => void cancel: () => void
confirm: () => void confirm: () => void
@BuilderParam container: () => void
build() { build() {
Column() { Column() {
Flex({ alignItems: ItemAlign.Start }) { Flex({ alignItems: ItemAlign.Start }) {
...@@ -48,14 +50,12 @@ export struct GeneralDialog { ...@@ -48,14 +50,12 @@ export struct GeneralDialog {
.color('#19ac88') .color('#19ac88')
.opacity(0.6) .opacity(0.6)
.margin({ left: 8, right: 8 }) .margin({ left: 8, right: 8 })
Text(this.clickItem.title).fontSize(20) Text('设置状态').fontSize(20)
} }
.padding({ top: 10, bottom: 10 }) .padding({ top: 10, bottom: 10 })
} }
Column() { this.container()
}
Flex({ justifyContent: FlexAlign.SpaceAround }) { Flex({ justifyContent: FlexAlign.SpaceAround }) {
Button('确认') Button('确认')
...@@ -65,13 +65,12 @@ export struct GeneralDialog { ...@@ -65,13 +65,12 @@ export struct GeneralDialog {
}).CommonButtonStyle() }).CommonButtonStyle()
Button('取消') Button('取消')
.onClick(() => { .onClick(() => {
this.formData[this.clickItem?.key] = ''
this.controller.close() this.controller.close()
this.cancel() this.cancel()
}).CommonButtonStyle() }).CommonButtonStyle()
}.margin({ top: 10, bottom: 10 }) }.margin({ top: 10, bottom: 10 })
} }
.width('86%') .width('100%')
.borderRadius(5) .borderRadius(5)
.backgroundColor('#fff') .backgroundColor('#fff')
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论