Commit f7024cbe by huangqy

查询功能

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