Files
JY1.0/sql/物料标准维护_查看禁用物料_测试库_20260803.sql

117 lines
4.4 KiB
Transact-SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
USE [ERPTOOL_JY_20250826Back]
GO
ALTER PROCEDURE [dbo].[物料管理_查询数据_分页]
@物料名称_check bit = null,
@物料名称 nvarchar(50) = null,
@物料编码_check bit = null,
@物料编码 nvarchar(50) = null,
@图号_check bit = null,
@图号 nvarchar(50) = null,
@类型_check bit = null,
@类型 int = null,
@时间_check bit = null,
@开始时间 nvarchar(50) = null,
@结束时间 nvarchar(50) = null,
@排序名称 int =null,
@排序方式 int =null,
@物料库_check bit = null,
@物料库 int = null,
@是否禁用_check bit = null, -- 修改人:Ld 修改时间:2026-08-03 07:55:23; 支持前端切换查看启用/禁用物料
@是否禁用 bit = null, -- 修改人:Ld 修改时间:2026-08-03 07:55:23; 1 查询禁用物料0 查询启用物料
@PageCurrent int=1, --要显示的页码
@PageSize int = 20, --每页的大小(记录数)
@PageCount int = '1111' OUTPUT, --总页数
@ItemCount int = '1111' OUTPUT --总记录数
AS
declare @selectStrWhere nvarchar(4000)
set @selectStrWhere = '1=1 ' -- 修改人:Ld 修改时间:2026-08-03 07:55:23; 默认条件改为可拼接启用状态
if (ISNULL(@是否禁用_check, 0) = 1) -- 修改人:Ld 修改时间:2026-08-03 07:55:23; 按按钮传入状态筛选禁用/启用物料
set @selectStrWhere = @selectStrWhere + ' and 是否禁用 = ' + str(ISNULL(@是否禁用, 0))
else
set @selectStrWhere = @selectStrWhere + ' and 是否禁用=0 '
--if(@物料名称_check = 1)
-- set @selectStrWhere = @selectStrWhere+' and 名称 like + ''%'' + @物料名称 + ''%'' '
--if(@时间_check = 1)
-- set @selectStrWhere = @selectStrWhere+' and 修改日期 >=@开始时间 and 修改日期 <=@结束时间 '
--if(@图号_check = 1)
-- set @selectStrWhere = @selectStrWhere+' and 代号 like + ''%'' + @图号 + ''%'' '
--if(@类型_check = 1)
-- set @selectStrWhere = @selectStrWhere+' and 类型 = @类型 '
if (@物料名称_check = 1)
if(@物料名称 is not null)
set @selectStrWhere = @selectStrWhere+' and 名称 like '+N'''%'+@物料名称+N'%'''
if (@物料编码_check = 1)
if(@物料编码 is not null)
set @selectStrWhere = @selectStrWhere+' and 物料编码 like '+N'''%'+@物料编码+N'%'''
if (@时间_check = 1)
if(@开始时间 is not null and @结束时间 is not null)
set @selectStrWhere = @selectStrWhere+' and ' + N''''+@开始时间+N'''' + '<=修改日期' + ' and '+ N''''+@结束时间+N'''' + '>=修改日期'
if (@图号_check = 1)
if(@图号 is not null)
set @selectStrWhere = @selectStrWhere+' and 代号 like '+N'''%'+@图号+N'%'''
if (@类型_check = 1)
if(@类型 is not null)
set @selectStrWhere = @selectStrWhere+' and 类型 = '+str(@类型)
---if (@物料库_check = 1)
-- if(@物料库 is not null)
-- set @selectStrWhere = @selectStrWhere+' and 物料库流水号 = '+ str(@物料库)
declare @tbname sysname --要分页显示的表名
declare @fieldkey sysname --用于定位记录的主键(唯一键)字段,只能是单个字段
declare @where nvarchar(4000) --查询条件
declare @fieldshow nvarchar(1000) --以逗号分隔的要显示的字段列表,如果不指定,则显示所有字段
declare @fieldOrder nvarchar(1000) ----以逗号分隔的排序字段列表,可以指定在字段后面指定DESC/ASC --不指定则按主键顺序
set @tbname = '物料视图'
set @fieldkey = '物料流水号'
set @where = @selectStrWhere
set @fieldshow =' [代号], [修改人], [修改日期], [单位], [单位流水号],[名称], [库位], [货位流水号], [操作日期],[文件内容],[文件后缀], [物料类型],[物料库流水号],
[是否启用], [是否禁用], [材料], [材料流水号],
[物料流水号], [物料编码], [类型], [类型名称], [物料说明],[规格],[曾用物料编码],[Expr1]' -- 修改人:Ld 修改时间:2026-08-03 07:55:23; 保持原输出字段并继续返回是否禁用状态
if @排序名称 = 1
begin
if @排序方式 = 1
begin
set @fieldOrder ='名称 DESC'
end
else
begin
set @fieldOrder = '名称 ASC'
end
end
else if @排序名称 = 2
begin
if @排序方式 = 1
begin
set @fieldOrder = '代号 DESC'
end
else
begin
set @fieldOrder = '代号 ASC'
end
end
else
begin
set @fieldOrder = '操作日期 DESC'
end
exec sp_xt_pagesplit @tbname,@fieldkey,@where,@fieldshow,@fieldOrder,'',@PageCurrent,@PageSize,@PageCount out,@ItemCount out
GO