fix quality details pagination
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
ALTER PROCEDURE [dbo].[质量管理_质检明细_查询]
|
||||
@质检类型 nvarchar(4000) = '10',
|
||||
@开始日期 datetime = NULL,
|
||||
@结束日期 datetime = NULL,
|
||||
@订单号 nvarchar(4000) = '0',
|
||||
@合同号 nvarchar(4000) = '0',
|
||||
@零件编码 nvarchar(4000) = '0',
|
||||
@零件名称 nvarchar(4000) = '0',
|
||||
@PageCurrent int = 1,
|
||||
@PageSize int = 20,
|
||||
@PageCount int OUTPUT,
|
||||
@ItemCount int OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @tbname sysname = ' [dbo].[View_质检明细] '
|
||||
DECLARE @fieldkey sysname = 'QT_AID'
|
||||
DECLARE @where nvarchar(4000)
|
||||
DECLARE @fieldshow nvarchar(1000)
|
||||
DECLARE @fieldOrder nvarchar(1000) = ' 检测时间 DESC, QT_AID DESC '
|
||||
|
||||
SET @where = ' (1=1) '
|
||||
|
||||
IF @质检类型 = '10'
|
||||
SET @where = @where + ' AND (1=1) '
|
||||
ELSE IF @质检类型 = '0'
|
||||
SET @where = @where + ' AND 质检类型 = ''收检'' '
|
||||
ELSE IF @质检类型 = '1'
|
||||
SET @where = @where + ' AND 质检类型 = ''终检'' '
|
||||
ELSE IF @质检类型 = '2'
|
||||
SET @where = @where + ' AND 质检类型 = ''来料检验'' '
|
||||
ELSE IF @质检类型 = '3'
|
||||
SET @where = @where + ' AND 质检类型 = ''退库检验'' '
|
||||
|
||||
IF @订单号 <> '0'
|
||||
SET @where = @where + ' AND 计划号 LIKE ''%' + @订单号 + '%'' '
|
||||
|
||||
--IF @合同号 <> '0'
|
||||
-- SET @where = @where + ' AND 内部合同号 LIKE ''%' + @合同号 + '%'' '
|
||||
|
||||
IF @零件编码 <> '0'
|
||||
SET @where = @where + ' AND 零件编码 LIKE ''%' + @零件编码 + '%'' '
|
||||
|
||||
IF @零件名称 <> '0'
|
||||
SET @where = @where + ' AND 零件名称 LIKE ''%' + @零件名称 + '%'' '
|
||||
|
||||
IF @开始日期 IS NOT NULL
|
||||
SET @where = @where + ' AND 检测时间 >= ''' + CONVERT(nvarchar(30), @开始日期, 120) + ''' '
|
||||
|
||||
IF @结束日期 IS NOT NULL
|
||||
SET @where = @where + ' AND 检测时间 <= ''' + CONVERT(nvarchar(30), @结束日期, 120) + ''' '
|
||||
|
||||
SET @fieldshow = '
|
||||
[QT_AID]
|
||||
,[质检类型]
|
||||
,[零件编码]
|
||||
,[零件名称]
|
||||
,[内部合同号]
|
||||
,[计划号]
|
||||
,[工序名称]
|
||||
,[检验数量]
|
||||
,[合格数]
|
||||
,[不合格数]
|
||||
,[检测人]
|
||||
,[检测时间]
|
||||
,[检测说明]
|
||||
,[工位名称]
|
||||
,[订单类型]'
|
||||
|
||||
EXEC [dbo].[sp_xt_pagesplit]
|
||||
@tbname,
|
||||
@fieldkey,
|
||||
@where,
|
||||
@fieldshow,
|
||||
@fieldOrder,
|
||||
@PageCurrent,
|
||||
@PageSize,
|
||||
@PageCount OUTPUT,
|
||||
@ItemCount OUTPUT
|
||||
END
|
||||
@@ -0,0 +1,94 @@
|
||||
CREATE PROCEDURE [dbo].[sp_xt_pagesplit]
|
||||
@tbname sysname,
|
||||
@fieldkey sysname,
|
||||
@where nvarchar(1000),
|
||||
@fieldshow nvarchar(max),
|
||||
@fieldOrder nvarchar(1000),
|
||||
@PageCurrent int=1,
|
||||
@PageSize int=30,
|
||||
@PageCount int OUTPUT,
|
||||
@ItemCount int output
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
-- 参数检查
|
||||
IF ISNULL(@PageCurrent,0)<1 SET @PageCurrent=1
|
||||
IF ISNULL(@PageSize,0)<1 SET @PageSize=10
|
||||
IF ISNULL(@FieldShow,N'')=N'' SET @FieldShow=N'*'
|
||||
|
||||
-- 处理排序
|
||||
DECLARE @OrderBy nvarchar(1000)
|
||||
IF ISNULL(@FieldOrder,N'')=N''
|
||||
SET @OrderBy = N''
|
||||
ELSE
|
||||
SET @OrderBy = N'ORDER BY ' + LTRIM(@FieldOrder)
|
||||
|
||||
-- 处理条件 - 重要:去掉WHERE关键字,只保留条件内容
|
||||
DECLARE @WhereCondition nvarchar(1000)
|
||||
IF ISNULL(@Where,N'')=N''
|
||||
SET @WhereCondition = N''
|
||||
ELSE
|
||||
SET @WhereCondition = @Where -- 只保存条件内容,不加WHERE
|
||||
|
||||
-- 清理字段名
|
||||
SET @fieldkey = LTRIM(RTRIM(@fieldkey))
|
||||
DECLARE @quotedKey NVARCHAR(128) = QUOTENAME(@fieldkey)
|
||||
|
||||
-- 计算总记录数
|
||||
DECLARE @sql nvarchar(MAX)
|
||||
IF @WhereCondition = N''
|
||||
SET @sql = N'SELECT @ItemCount = COUNT(*) FROM ' + @tbname
|
||||
ELSE
|
||||
SET @sql = N'SELECT @ItemCount = COUNT(*) FROM ' + @tbname + N' WHERE ' + @WhereCondition
|
||||
|
||||
EXEC sp_executesql @sql, N'@ItemCount int OUTPUT', @ItemCount OUTPUT
|
||||
|
||||
-- 计算总页数
|
||||
SET @PageCount = CEILING((@ItemCount + 0.0) / @PageSize)
|
||||
IF @PageCount = 0 SET @PageCount = 1
|
||||
|
||||
-- 返回当前页数据
|
||||
DECLARE @TopRows INT = (@PageCurrent - 1) * @PageSize
|
||||
|
||||
IF @PageCurrent = 1
|
||||
BEGIN
|
||||
-- 第一页
|
||||
IF @WhereCondition = N''
|
||||
SET @sql = N'SELECT TOP ' + CONVERT(NVARCHAR, @PageSize) + N' ' + @FieldShow + N'
|
||||
FROM ' + @tbname + N' ' + @OrderBy
|
||||
ELSE
|
||||
SET @sql = N'SELECT TOP ' + CONVERT(NVARCHAR, @PageSize) + N' ' + @FieldShow + N'
|
||||
FROM ' + @tbname + N' WHERE ' + @WhereCondition + N' ' + @OrderBy
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
-- 其他页
|
||||
IF @WhereCondition = N''
|
||||
BEGIN
|
||||
-- 无条件的情况
|
||||
SET @sql = N'SELECT TOP ' + CONVERT(NVARCHAR, @PageSize) + N' ' + @FieldShow + N'
|
||||
FROM ' + @tbname + N'
|
||||
WHERE ' + @quotedKey + N' NOT IN (
|
||||
SELECT TOP ' + CONVERT(NVARCHAR, @TopRows) + N' ' + @quotedKey + N'
|
||||
FROM ' + @tbname + N' ' + @OrderBy + N'
|
||||
) ' + @OrderBy
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
-- 有条件的情况
|
||||
SET @sql = N'SELECT TOP ' + CONVERT(NVARCHAR, @PageSize) + N' ' + @FieldShow + N'
|
||||
FROM ' + @tbname + N'
|
||||
WHERE ' + @quotedKey + N' NOT IN (
|
||||
SELECT TOP ' + CONVERT(NVARCHAR, @TopRows) + N' ' + @quotedKey + N'
|
||||
FROM ' + @tbname + N' WHERE ' + @WhereCondition + N' ' + @OrderBy + N'
|
||||
) AND ' + @WhereCondition + N' ' + @OrderBy
|
||||
END
|
||||
END
|
||||
|
||||
-- 调试用,可以注释掉
|
||||
-- PRINT @sql
|
||||
|
||||
-- 执行
|
||||
EXEC(@sql)
|
||||
END
|
||||
@@ -0,0 +1,94 @@
|
||||
|
||||
-- 质量管理_质检明细_查询
|
||||
CREATE PROCEDURE [dbo].[质量管理_质检明细_查询]
|
||||
@质检类型 nvarchar(4000) = '10', -- 修改为字符串类型,因为传入的是字符串
|
||||
@开始日期 datetime = NULL,
|
||||
@结束日期 datetime = NULL,
|
||||
@订单号 nvarchar(4000) = '0', -- 修改为字符串类型,避免类型转换问题
|
||||
@合同号 nvarchar(4000) = '0',
|
||||
@零件编码 nvarchar(4000) = '0',
|
||||
@零件名称 nvarchar(4000) = '0',
|
||||
@PageCurrent int = 1, -- 要显示的页码
|
||||
@PageSize int = 20, -- 每页的大小(记录数)
|
||||
@PageCount int OUTPUT, -- 总页数
|
||||
@ItemCount int OUTPUT -- 数据总数
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @tbname sysname = ' [dbo].[View_质检明细] ' -- 要分页显示的表名
|
||||
DECLARE @fieldkey sysname = ' ' -- 用于定位记录的主键(惟一键)字段
|
||||
DECLARE @where nvarchar(4000) -- 查询条件
|
||||
DECLARE @fieldshow nvarchar(1000) -- 要显示的字段列表
|
||||
DECLARE @fieldOrder nvarchar(1000) = ' 检测时间 DESC ' -- 排序字段
|
||||
|
||||
-- 构建查询条件(使用参数化方式,避免SQL注入)
|
||||
SET @where = ' (1=1) '
|
||||
|
||||
-- 质检类型过滤
|
||||
IF @质检类型 = '10' -- 全部
|
||||
SET @where = @where + ' AND (1=1) '
|
||||
ELSE IF @质检类型 = '0'
|
||||
SET @where = @where + ' AND 质检类型 = ''收检'' '
|
||||
ELSE IF @质检类型 = '1'
|
||||
SET @where = @where + ' AND 质检类型 = ''终检'' '
|
||||
ELSE IF @质检类型 = '2'
|
||||
SET @where = @where + ' AND 质检类型 = ''来料检验'' '
|
||||
ELSE IF @质检类型 = '3'
|
||||
SET @where = @where + ' AND 质检类型 = ''退库检验'' '
|
||||
|
||||
-- 订单号过滤条件(修正:使用LIKE时加引号)
|
||||
IF @订单号 <> '0'
|
||||
SET @where = @where + ' AND 计划号 LIKE ''%' + @订单号 + '%'' '
|
||||
|
||||
-- 合同号过滤条件
|
||||
--IF @合同号 <> '0'
|
||||
-- SET @where = @where + ' AND 内部合同号 LIKE ''%' + @合同号 + '%'' '
|
||||
|
||||
-- 零件编码过滤条件
|
||||
IF @零件编码 <> '0'
|
||||
SET @where = @where + ' AND 零件编码 LIKE ''%' + @零件编码 + '%'' '
|
||||
|
||||
-- 零件名称过滤条件
|
||||
IF @零件名称 <> '0'
|
||||
SET @where = @where + ' AND 零件名称 LIKE ''%' + @零件名称 + '%'' '
|
||||
|
||||
-- 日期范围过滤(如果提供了日期参数)
|
||||
IF @开始日期 IS NOT NULL
|
||||
SET @where = @where + ' AND 检测时间 >= ''' + CONVERT(nvarchar(30), @开始日期, 120) + ''' '
|
||||
|
||||
IF @结束日期 IS NOT NULL
|
||||
SET @where = @where + ' AND 检测时间 <= ''' + CONVERT(nvarchar(30), @结束日期, 120) + ''' '
|
||||
|
||||
SET @fieldshow = '
|
||||
[QT_AID]
|
||||
,[质检类型]
|
||||
,[零件编码]
|
||||
,[零件名称]
|
||||
,[内部合同号]
|
||||
,[计划号]
|
||||
,[工序名称]
|
||||
,[检验数量]
|
||||
,[合格数]
|
||||
,[不合格数]
|
||||
,[检测人]
|
||||
,[检测时间]
|
||||
,[检测说明]
|
||||
,[工位名称]
|
||||
,[订单类型]'
|
||||
|
||||
-- 调试用(可以注释掉)
|
||||
PRINT @where
|
||||
|
||||
-- 执行分页存储过程
|
||||
EXEC [dbo].[sp_xt_pagesplit]
|
||||
@tbname,
|
||||
@fieldkey,
|
||||
@where,
|
||||
@fieldshow,
|
||||
@fieldOrder,
|
||||
@PageCurrent,
|
||||
@PageSize,
|
||||
@PageCount OUTPUT,
|
||||
@ItemCount OUTPUT
|
||||
END
|
||||
@@ -40,7 +40,7 @@
|
||||
format="yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd"
|
||||
style="width: 150px; margin-right: 10px" />
|
||||
<el-button :disabled="!!loading" icon="el-icon-search" plain type="primary" @click="searchTable()">查询</el-button>
|
||||
<el-button :disabled="!!loading" icon="el-icon-search" plain type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button style="width: 100px;" icon="el-icon-download" type="primary" @click="exportExcel">Excel导出</el-button>
|
||||
</div>
|
||||
|
||||
@@ -165,10 +165,10 @@ export default {
|
||||
param.push(["质检类型", this.QualityStatus]);
|
||||
param.push(["开始日期", this.startDate]);
|
||||
param.push(["结束日期", this.endDate]);
|
||||
param.push(["订单号", this.orderNo ]);
|
||||
param.push(["合同号", this.contractNo ]);
|
||||
param.push(["零件编码", this.productCode ]);
|
||||
param.push(["零件名称", this.productName ]);
|
||||
param.push(["订单号", this.normalizeQueryValue(this.orderNo) ]);
|
||||
param.push(["合同号", this.normalizeQueryValue(this.contractNo) ]);
|
||||
param.push(["零件编码", this.normalizeQueryValue(this.productCode) ]);
|
||||
param.push(["零件名称", this.normalizeQueryValue(this.productName) ]);
|
||||
|
||||
this.exporting = true
|
||||
const Data = this.CreateData('2001', '质量管理_质检明细_导出', param)
|
||||
@@ -218,6 +218,11 @@ export default {
|
||||
|
||||
|
||||
// ============ 分页方法 ============
|
||||
handleSearch() {
|
||||
this.pageCurrent = 1
|
||||
this.searchTable()
|
||||
},
|
||||
|
||||
handleSizeChanges(val) {
|
||||
this.pageCurrent = 1
|
||||
this.pageSize = val
|
||||
@@ -236,12 +241,12 @@ export default {
|
||||
param.push(["质检类型", this.QualityStatus]);
|
||||
param.push(["开始日期", this.startDate]);
|
||||
param.push(["结束日期", this.endDate]);
|
||||
param.push(["订单号", this.orderNo ]);
|
||||
param.push(["合同号", this.contractNo ]);
|
||||
param.push(["零件编码", this.productCode ]);
|
||||
param.push(["零件名称", this.productName ]);
|
||||
param.push(["订单号", this.normalizeQueryValue(this.orderNo) ]);
|
||||
param.push(["合同号", this.normalizeQueryValue(this.contractNo) ]);
|
||||
param.push(["零件编码", this.normalizeQueryValue(this.productCode) ]);
|
||||
param.push(["零件名称", this.normalizeQueryValue(this.productName) ]);
|
||||
param.push(['PageCurrent', this.pageCurrent])
|
||||
param.push(['pageSize', this.pageSize])
|
||||
param.push(['PageSize', this.pageSize])
|
||||
param.push(['PageCount', '1111', 'int', '1'])
|
||||
param.push(['ItemCount', '1111', 'int', '1'])
|
||||
|
||||
@@ -258,6 +263,10 @@ export default {
|
||||
|
||||
// ============ 工具方法 ============
|
||||
|
||||
normalizeQueryValue(value) {
|
||||
return value === null || value === undefined || value === '' ? '0' : value
|
||||
},
|
||||
|
||||
|
||||
getCurrentUser() {
|
||||
return this.$store.state.user.name
|
||||
|
||||
Reference in New Issue
Block a user