feat(qc): 新增检查项模板管理功能及穿梭框组件
refactor(warehouse): 优化库位网格布局和响应式设计 fix(wms): 移除异常详情页的路由变化条件判断 style(qc): 统一检查任务对话框宽度为700px feat(qc): 新增检查项模板API及相关页面组件
This commit is contained in:
55
klp-ui/src/api/mes/qc/inspectionItemTemplate.js
Normal file
55
klp-ui/src/api/mes/qc/inspectionItemTemplate.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询待检项模板列表
|
||||
export function listInspectionItemTemplate(query) {
|
||||
return request({
|
||||
url: '/qc/inspectionItemTemplate/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询待检项模板详细
|
||||
export function getInspectionItemTemplate(templateId) {
|
||||
return request({
|
||||
url: '/qc/inspectionItemTemplate/' + templateId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增待检项模板
|
||||
export function addInspectionItemTemplate(data) {
|
||||
return request({
|
||||
url: '/qc/inspectionItemTemplate',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改待检项模板
|
||||
export function updateInspectionItemTemplate(data) {
|
||||
return request({
|
||||
url: '/qc/inspectionItemTemplate',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除待检项模板
|
||||
export function delInspectionItemTemplate(templateId) {
|
||||
return request({
|
||||
url: '/qc/inspectionItemTemplate/' + templateId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询模版详情
|
||||
export function getInfoByInspectionItem(inspectionItemIds) {
|
||||
return request({
|
||||
url: '/qc/inspectionItemTemplate/getInfoByInspectionItem',
|
||||
method: 'post',
|
||||
params: {
|
||||
inspectionItemIds
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,64 +1,182 @@
|
||||
<template>
|
||||
<el-select
|
||||
v-model="selected"
|
||||
multiple
|
||||
filterable
|
||||
placeholder="请选择检查项"
|
||||
@change="handleChange"
|
||||
size="mini"
|
||||
style="width: 100%;"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in checkItems"
|
||||
:key="item.itemId"
|
||||
:label="item.itemName"
|
||||
:value="item.itemId"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="check-item-transfer">
|
||||
<!-- Element-UI穿梭框核心组件 -->
|
||||
<el-transfer v-model="internalValue" :data="transferData" :titles="['待选检查项', '已选检查项']" :props="transferProps"
|
||||
@change="handleTransferChange" filterable filter-placeholder="请输入检查项名称搜索" v-loading="loading" :disabled="loading">
|
||||
<!-- 自定义选项内容(单根节点包裹,解决Vue2警告) -->
|
||||
<template slot-scope="{ option }">
|
||||
<span class="transfer-option-content">
|
||||
<span>{{ option.itemName }}</span>
|
||||
<span style="margin-left: 8px; color: #999; font-size: 12px">
|
||||
({{ option.qualitativeQuantitative === 0 ? '定性' : '定量' }})
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<el-button class="transfer-footer" slot="right-footer" size="small"
|
||||
@click="loadInspectionItemTemplateList">选择模版</el-button>
|
||||
</el-transfer>
|
||||
|
||||
<el-dialog title="选择待检项方案" :visible.sync="open" width="700px" append-to-body>
|
||||
<el-form ref="form" :model="queryParams" :rules="rules" label-width="80px">
|
||||
<el-form-item label="任务名称" prop="templateName">
|
||||
<el-input v-model="queryParams.templateName" placeholder="请输入任务名称" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table highlight-current-row border @row-click="handleRowClick" v-loading="loading"
|
||||
:data="inspectionItemTemplateList" @selection-change="handleSelectionChange">
|
||||
<el-table-column label="方案名称" align="center" prop="templateName" />
|
||||
<el-table-column label="方案描述" align="center" prop="templateDesc" />
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listCheckItem } from '@/api/mes/qc/checkItem'
|
||||
import { listCheckItem } from "@/api/mes/qc/checkItem";
|
||||
import { listInspectionItemTemplate } from "@/api/mes/qc/inspectionItemTemplate";
|
||||
|
||||
export default {
|
||||
name: 'CheckItemSelect',
|
||||
name: "CheckItemTransfer",
|
||||
// 接收外部v-model绑定的itemIds字符串(逗号分隔)
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
value: {
|
||||
type: String,
|
||||
default: ""
|
||||
}
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
data() {
|
||||
return {
|
||||
checkItems: [],
|
||||
selected: this.modelValue.slice()
|
||||
}
|
||||
// 穿梭框数据源(去重后的检查项列表)
|
||||
transferData: [],
|
||||
// 内部选中值(数组,与v-model的字符串双向同步)
|
||||
internalValue: [],
|
||||
// 穿梭框字段映射(key必须唯一)
|
||||
transferProps: {
|
||||
key: "itemId", // 唯一标识字段
|
||||
label: "itemName" // 显示文本字段
|
||||
},
|
||||
// 数据加载状态
|
||||
loading: false,
|
||||
templateList: [],
|
||||
open: false,
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
templateName: undefined,
|
||||
},
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
modelValue(val) {
|
||||
this.selected = val.slice()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleChange(val) {
|
||||
this.$emit('input', val)
|
||||
},
|
||||
async fetchCheckItems() {
|
||||
try {
|
||||
const res = await listCheckItem({ pageSize: 1000 })
|
||||
this.checkItems = res.rows
|
||||
} catch (e) {
|
||||
this.checkItems = []
|
||||
// 监听外部传入的value变化,同步到内部选中值
|
||||
value: {
|
||||
immediate: true, // 初始化时立即执行
|
||||
handler(newVal) {
|
||||
if (newVal && typeof newVal === "string") {
|
||||
// 字符串转数字数组(过滤空值,统一类型)
|
||||
this.internalValue = newVal
|
||||
.split(",")
|
||||
.filter(Boolean) // 过滤空字符串
|
||||
.map(id => id.toString()); // 统一转为字符串类型
|
||||
} else {
|
||||
this.internalValue = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 组件创建时加载检查项列表
|
||||
this.loadCheckItemList();
|
||||
},
|
||||
methods: {
|
||||
/** 加载检查项列表(核心修复:去重+类型统一) */
|
||||
async loadCheckItemList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
// 查询全部检查项(不分页)
|
||||
const queryParams = { pageNum: 1, pageSize: 9999 };
|
||||
const response = await listCheckItem(queryParams);
|
||||
let rawList = response.rows || [];
|
||||
|
||||
mounted() {
|
||||
this.fetchCheckItems()
|
||||
// 修复1:统一itemId为字符串类型(避免字符串/数字不匹配)
|
||||
rawList = rawList.map(item => ({
|
||||
...item,
|
||||
itemId: item.itemId.toString() // 强制转为字符串类型
|
||||
}));
|
||||
|
||||
// 修复2:按itemId去重(解决重复key导致穿梭无效的核心问题)
|
||||
this.transferData = [...new Map(
|
||||
rawList.map(item => [item.itemId, item]) // Map的key唯一,自动去重
|
||||
).values()];
|
||||
|
||||
} catch (error) {
|
||||
// 兼容不同的提示方式
|
||||
if (this.$modal) {
|
||||
this.$modal.msgError("加载检查项列表失败");
|
||||
} else if (this.$message) {
|
||||
this.$message.error("加载检查项列表失败");
|
||||
}
|
||||
console.error("检查项列表加载异常:", error);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
handleRowClick(row) {
|
||||
this.$emit("input", row.inspectionItem);
|
||||
this.open = false;
|
||||
},
|
||||
|
||||
/** 加载待检项方案列表 */
|
||||
async loadInspectionItemTemplateList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
this.open = true;
|
||||
const response = await listInspectionItemTemplate(this.queryParams);
|
||||
this.inspectionItemTemplateList = response.rows || [];
|
||||
} catch (error) {
|
||||
if (this.$modal) {
|
||||
this.$message.error("加载待检项方案列表失败");
|
||||
} else if (this.$message) {
|
||||
this.$message.error("加载待检项方案列表失败");
|
||||
}
|
||||
console.error("待检项方案列表加载异常:", error);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
/** 穿梭框选中状态变化处理(双向绑定核心逻辑) */
|
||||
handleTransferChange(newVal) {
|
||||
// 过滤空值后转逗号分隔的字符串
|
||||
const itemIdsStr = newVal
|
||||
.filter(Boolean)
|
||||
.join(",");
|
||||
|
||||
// 触发input事件实现v-model双向绑定
|
||||
this.$emit("input", itemIdsStr);
|
||||
// 向外暴露change事件,返回数组和字符串两种格式
|
||||
this.$emit("change", newVal, itemIdsStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
.check-item-transfer {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 自定义选项样式,确保显示完整 */
|
||||
.transfer-option-content {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
padding: 2px 0;
|
||||
box-sizing: border-box;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
143
klp-ui/src/views/mes/qc/components/CheckItemTransfer/index.vue
Normal file
143
klp-ui/src/views/mes/qc/components/CheckItemTransfer/index.vue
Normal file
@@ -0,0 +1,143 @@
|
||||
<template>
|
||||
<div class="check-item-transfer">
|
||||
<!-- Element-UI穿梭框核心组件 -->
|
||||
<el-transfer
|
||||
v-model="internalValue"
|
||||
:data="transferData"
|
||||
:titles="['待选检查项', '已选检查项']"
|
||||
:props="transferProps"
|
||||
@change="handleTransferChange"
|
||||
filterable
|
||||
filter-placeholder="请输入检查项名称搜索"
|
||||
v-loading="loading"
|
||||
:disabled="loading"
|
||||
>
|
||||
<!-- 自定义选项内容(单根节点包裹,解决Vue2警告) -->
|
||||
<template slot-scope="{ option }">
|
||||
<span class="transfer-option-content">
|
||||
<span>{{ option.itemName }}</span>
|
||||
<span style="margin-left: 8px; color: #999; font-size: 12px">
|
||||
({{ option.qualitativeQuantitative === 0 ? '定性' : '定量' }})
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-transfer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listCheckItem } from "@/api/mes/qc/checkItem";
|
||||
|
||||
export default {
|
||||
name: "CheckItemTransfer",
|
||||
// 接收外部v-model绑定的itemIds字符串(逗号分隔)
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: ""
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 穿梭框数据源(去重后的检查项列表)
|
||||
transferData: [],
|
||||
// 内部选中值(数组,与v-model的字符串双向同步)
|
||||
internalValue: [],
|
||||
// 穿梭框字段映射(key必须唯一)
|
||||
transferProps: {
|
||||
key: "itemId", // 唯一标识字段
|
||||
label: "itemName" // 显示文本字段
|
||||
},
|
||||
// 数据加载状态
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
// 监听外部传入的value变化,同步到内部选中值
|
||||
value: {
|
||||
immediate: true, // 初始化时立即执行
|
||||
handler(newVal) {
|
||||
if (newVal && typeof newVal === "string") {
|
||||
// 字符串转数字数组(过滤空值,统一类型)
|
||||
this.internalValue = newVal
|
||||
.split(",")
|
||||
.filter(Boolean) // 过滤空字符串
|
||||
.map(id => id.toString()); // 统一转为字符串类型
|
||||
} else {
|
||||
this.internalValue = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 组件创建时加载检查项列表
|
||||
this.loadCheckItemList();
|
||||
},
|
||||
methods: {
|
||||
/** 加载检查项列表(核心修复:去重+类型统一) */
|
||||
async loadCheckItemList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
// 查询全部检查项(不分页)
|
||||
const queryParams = { pageNum: 1, pageSize: 9999 };
|
||||
const response = await listCheckItem(queryParams);
|
||||
let rawList = response.rows || [];
|
||||
|
||||
// 修复1:统一itemId为字符串类型(避免字符串/数字不匹配)
|
||||
rawList = rawList.map(item => ({
|
||||
...item,
|
||||
itemId: item.itemId.toString() // 强制转为字符串类型
|
||||
}));
|
||||
|
||||
// 修复2:按itemId去重(解决重复key导致穿梭无效的核心问题)
|
||||
this.transferData = [...new Map(
|
||||
rawList.map(item => [item.itemId, item]) // Map的key唯一,自动去重
|
||||
).values()];
|
||||
|
||||
} catch (error) {
|
||||
// 兼容不同的提示方式
|
||||
if (this.$modal) {
|
||||
this.$modal.msgError("加载检查项列表失败");
|
||||
} else if (this.$message) {
|
||||
this.$message.error("加载检查项列表失败");
|
||||
}
|
||||
console.error("检查项列表加载异常:", error);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
/** 穿梭框选中状态变化处理(双向绑定核心逻辑) */
|
||||
handleTransferChange(newVal) {
|
||||
// 过滤空值后转逗号分隔的字符串
|
||||
const itemIdsStr = newVal
|
||||
.filter(Boolean)
|
||||
.join(",");
|
||||
|
||||
// 触发input事件实现v-model双向绑定
|
||||
this.$emit("input", itemIdsStr);
|
||||
// 向外暴露change事件,返回数组和字符串两种格式
|
||||
this.$emit("change", newVal, itemIdsStr);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.check-item-transfer {
|
||||
width: 100%;
|
||||
min-height: 400px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 自定义选项样式,确保显示完整 */
|
||||
.transfer-option-content {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
padding: 2px 0;
|
||||
box-sizing: border-box;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
@@ -126,7 +126,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 添加或修改检查任务对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="任务名称" prop="taskName">
|
||||
<el-input v-model="form.taskName" placeholder="请输入任务名称" />
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 添加或修改检查任务对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="任务名称" prop="taskName">
|
||||
<el-input v-model="form.taskName" placeholder="请输入任务名称" />
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 添加或修改检查任务对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="任务名称" prop="taskName">
|
||||
<el-input v-model="form.taskName" placeholder="请输入任务名称" />
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 添加或修改检查任务对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="任务名称" prop="taskName">
|
||||
<el-input v-model="form.taskName" placeholder="请输入任务名称" />
|
||||
|
||||
254
klp-ui/src/views/mes/qc/template/index.vue
Normal file
254
klp-ui/src/views/mes/qc/template/index.vue
Normal file
@@ -0,0 +1,254 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
|
||||
label-width="68px">
|
||||
<el-form-item label="方案名称" prop="templateName">
|
||||
<el-input v-model="queryParams.templateName" placeholder="请输入方案名称" clearable
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table highlight-current-row border @row-click="handleRowClick" v-loading="loading"
|
||||
:data="inspectionItemTemplateList" @selection-change="handleSelectionChange">
|
||||
<el-table-column label="方案名称" align="center" prop="templateName" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- 添加或修改待检项方案对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="方案名称" prop="templateName">
|
||||
<el-input v-model="form.templateName" placeholder="请输入方案名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="方案描述" prop="templateDesc">
|
||||
<el-input v-model="form.templateDesc" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="待检项" prop="inspectionItem">
|
||||
<CheckItemTransfer v-model="form.inspectionItem" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-col>
|
||||
<el-col :span="16" v-loading="rightLoading">
|
||||
<KLPTable v-if="checkItemList.length > 0" v-loading="loading" :data="checkItemList"
|
||||
@selection-change="handleSelectionChange">
|
||||
<el-table-column label="检查项名称" align="center" prop="itemName" />
|
||||
<el-table-column label="标准目标" align="center" prop="standardTarget" />
|
||||
<el-table-column label="目标上限" align="center" prop="targetUpper" />
|
||||
<el-table-column label="目标下限" align="center" prop="targetLower" />
|
||||
<el-table-column label="单位" align="center" prop="unit" />
|
||||
<el-table-column label="定性定量" align="center" prop="qualitativeQuantitative">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.qualitativeQuantitative === 0 ? '定性' : '定量' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
</KLPTable>
|
||||
|
||||
<el-empty v-else description="暂无数据" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listInspectionItemTemplate, getInspectionItemTemplate, delInspectionItemTemplate, addInspectionItemTemplate, updateInspectionItemTemplate, getInfoByInspectionItem } from "@/api/mes/qc/inspectionItemTemplate";
|
||||
import CheckItemTransfer from '@/components/KLPService/CheckItemSelect/index'
|
||||
|
||||
export default {
|
||||
name: "InspectionItemTemplate",
|
||||
components: {
|
||||
CheckItemTransfer,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 按钮loading
|
||||
buttonLoading: false,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 待检项方案表格数据
|
||||
inspectionItemTemplateList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
templateName: undefined,
|
||||
templateDesc: undefined,
|
||||
inspectionItem: undefined,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
},
|
||||
checkItemList: [],
|
||||
rightLoading: false,
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询待检项方案列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listInspectionItemTemplate(this.queryParams).then(response => {
|
||||
this.inspectionItemTemplateList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
handleRowClick(row) {
|
||||
this.rightLoading = true;
|
||||
getInfoByInspectionItem(row.inspectionItem).then(response => {
|
||||
this.checkItemList = response.data || [];
|
||||
this.rightLoading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
templateId: undefined,
|
||||
templateName: undefined,
|
||||
templateDesc: undefined,
|
||||
inspectionItem: undefined,
|
||||
createBy: undefined,
|
||||
createTime: undefined,
|
||||
updateBy: undefined,
|
||||
updateTime: undefined,
|
||||
delFlag: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.templateId)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加待检项方案";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.loading = true;
|
||||
this.reset();
|
||||
const templateId = row.templateId || this.ids
|
||||
getInspectionItemTemplate(templateId).then(response => {
|
||||
this.loading = false;
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改待检项方案";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
this.buttonLoading = true;
|
||||
if (this.form.templateId != null) {
|
||||
updateInspectionItemTemplate(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
} else {
|
||||
addInspectionItemTemplate(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const templateIds = row.templateId || this.ids;
|
||||
this.$modal.confirm('是否确认删除待检项方案编号为"' + templateIds + '"的数据项?').then(() => {
|
||||
this.loading = true;
|
||||
return delInspectionItemTemplate(templateIds);
|
||||
}).then(() => {
|
||||
this.loading = false;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('qc/inspectionItemTemplate/export', {
|
||||
...this.queryParams
|
||||
}, `inspectionItemTemplate_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -198,10 +198,10 @@ export default {
|
||||
watch: {
|
||||
'$route.query.coilId': {
|
||||
handler(newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
// if (newVal !== oldVal) {
|
||||
this.queryParams.coilId = newVal
|
||||
this.handleQuery()
|
||||
}
|
||||
// }
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
<div>
|
||||
<div style="display: flex; align-items: center;">
|
||||
<el-divider content-position="left">第{{ layer }}层库位</el-divider>
|
||||
<!-- 转置按钮 -->
|
||||
<el-button type="text" icon="el-icon-refresh-left" size="mini" @click="toggleTranspose">
|
||||
{{ isTransposed ? '恢复行列' : '行列转置' }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="grid-wrapper">
|
||||
<div class="grid-scroll-container" ref="scrollContainerRef">
|
||||
<div class="scroll-content">
|
||||
<div class="scroll-content" ref="contentRef">
|
||||
<!-- 列标尺(顶部) -->
|
||||
<div class="col-ruler">
|
||||
<div class="col-ruler" :style="{ '--cell-width': `${cellWidth}px` }">
|
||||
<div class="ruler-empty"></div>
|
||||
<div v-for="col in transposedLayerData.maxColumn" :key="`col-${layer}-${col}`" class="ruler-item">
|
||||
{{ col }}
|
||||
@@ -27,9 +26,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 库位网格 -->
|
||||
<div class="grid-container"
|
||||
:style="{ gridTemplateColumns: `repeat(${transposedLayerData.maxColumn}, 60px)` }">
|
||||
<!-- 库位网格 - 修复伪元素遮挡问题 -->
|
||||
<div class="grid-container"
|
||||
:style="{
|
||||
'--cell-width': `${cellWidth}px`,
|
||||
'--column-count': transposedLayerData.maxColumn
|
||||
}">
|
||||
<!-- 库位格子 -->
|
||||
<div v-for="warehouse in transposedLayerData.warehouses" :key="warehouse.actualWarehouseId"
|
||||
class="warehouse-cell" :class="{ disabled: warehouse.isEnabled === 0 }"
|
||||
@@ -47,23 +49,20 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 库位详情弹窗 -->
|
||||
<!-- 弹窗修复:改回 .sync 绑定,恢复 footer 插槽写法 -->
|
||||
<el-dialog title="库位详情" :visible.sync="dialogVisible" width="600px" destroy-on-close append-to-body center>
|
||||
<el-descriptions :column="2" border size="small" v-if="currentWarehouse">
|
||||
<el-descriptions-item label="库位编码">{{ currentWarehouse.actualWarehouseCode }}</el-descriptions-item>
|
||||
<el-descriptions-item label="库位名称">{{ currentWarehouse.actualWarehouseName || '无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="所属层级">{{ currentWarehouse.parsedInfo.layer || '未知' }}</el-descriptions-item>
|
||||
<!-- 弹窗内行列显示适配转置状态 -->
|
||||
<el-descriptions-item label="行号">
|
||||
{{ isTransposed ? currentWarehouse.parsedInfo.column : currentWarehouse.parsedInfo.row || '未知' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="列号">
|
||||
{{ isTransposed ? currentWarehouse.parsedInfo.row : currentWarehouse.parsedInfo.column || '未知' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="一级编码">{{ currentWarehouse.parsedInfo.warehouseFirst || '未知'
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="二级编码">{{ currentWarehouse.parsedInfo.warehouseSecond || '未知'
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="一级编码">{{ currentWarehouse.parsedInfo.warehouseFirst || '未知' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="二级编码">{{ currentWarehouse.parsedInfo.warehouseSecond || '未知' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="启用状态">
|
||||
<el-tag :type="currentWarehouse.isEnabled === 1 ? 'success' : 'danger'">
|
||||
{{ currentWarehouse.isEnabled === 1 ? '启用' : '禁用' }}
|
||||
@@ -81,7 +80,6 @@
|
||||
</el-dialog>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -91,12 +89,10 @@ export default {
|
||||
name: "WarehouseGrid",
|
||||
components: { QRCode },
|
||||
props: {
|
||||
// 层号
|
||||
layer: {
|
||||
type: [String, Number],
|
||||
required: true
|
||||
},
|
||||
// 层数据
|
||||
layerData: {
|
||||
type: Object,
|
||||
required: true,
|
||||
@@ -110,27 +106,21 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 弹窗状态
|
||||
dialogVisible: false,
|
||||
currentWarehouse: null,
|
||||
// 转置状态:false-原始布局 | true-行列转置
|
||||
isTransposed: false
|
||||
isTransposed: false,
|
||||
containerWidth: 0,
|
||||
resizeTimer: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
/**
|
||||
* 处理转置后的层数据(视图层映射,不修改原数据)
|
||||
*/
|
||||
transposedLayerData() {
|
||||
const { maxRow, maxColumn, warehouses } = this.layerData;
|
||||
|
||||
// 转置后的基础行列数
|
||||
const transMaxRow = this.isTransposed ? maxColumn : maxRow;
|
||||
const transMaxColumn = this.isTransposed ? maxRow : maxColumn;
|
||||
|
||||
// 深拷贝库位数据,避免修改原数据
|
||||
// 深拷贝避免修改原数据
|
||||
const transWarehouses = JSON.parse(JSON.stringify(warehouses)).map(item => {
|
||||
// 转置时互换行列解析值
|
||||
if (this.isTransposed && item.parsedInfo) {
|
||||
const { row, column } = item.parsedInfo;
|
||||
item.parsedInfo.row = column;
|
||||
@@ -139,7 +129,7 @@ export default {
|
||||
return item;
|
||||
});
|
||||
|
||||
// 转置后重新排序(原:行→列 | 转置:列→行)
|
||||
// 排序保证网格展示顺序正确
|
||||
transWarehouses.sort((a, b) => {
|
||||
if (a.parsedInfo.row !== b.parsedInfo.row) {
|
||||
return a.parsedInfo.row - b.parsedInfo.row;
|
||||
@@ -147,7 +137,6 @@ export default {
|
||||
return a.parsedInfo.column - b.parsedInfo.column;
|
||||
});
|
||||
|
||||
// 转置后重新计算空占位数量
|
||||
const totalGrid = transMaxRow * transMaxColumn;
|
||||
const emptyCount = Math.max(0, totalGrid - transWarehouses.length);
|
||||
|
||||
@@ -157,23 +146,55 @@ export default {
|
||||
warehouses: transWarehouses,
|
||||
emptyCount
|
||||
};
|
||||
},
|
||||
cellWidth() {
|
||||
if (!this.containerWidth || this.transposedLayerData.maxColumn === 0) return 60;
|
||||
// 容器可用宽度 = 滚动容器宽度 - 行标尺宽度(30px)
|
||||
const availableWidth = Math.max(0, this.containerWidth - 30);
|
||||
// 均分宽度,最小60px
|
||||
const averageWidth = availableWidth / this.transposedLayerData.maxColumn;
|
||||
return Math.max(60, averageWidth);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
isTransposed() {
|
||||
this.calcContainerWidth();
|
||||
},
|
||||
layerData: {
|
||||
deep: true,
|
||||
handler() {
|
||||
this.calcContainerWidth();
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.calcContainerWidth();
|
||||
window.addEventListener('resize', this.handleResize);
|
||||
},
|
||||
beforeUnmount() {
|
||||
window.removeEventListener('resize', this.handleResize);
|
||||
clearTimeout(this.resizeTimer);
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 切换转置状态
|
||||
*/
|
||||
calcContainerWidth() {
|
||||
if (this.$refs.scrollContainerRef) {
|
||||
this.containerWidth = this.$refs.scrollContainerRef.clientWidth;
|
||||
}
|
||||
},
|
||||
handleResize() {
|
||||
clearTimeout(this.resizeTimer);
|
||||
this.resizeTimer = setTimeout(() => {
|
||||
this.calcContainerWidth();
|
||||
}, 100);
|
||||
},
|
||||
toggleTranspose() {
|
||||
this.isTransposed = !this.isTransposed;
|
||||
// 重置弹窗选中状态(可选)
|
||||
this.dialogVisible = false;
|
||||
this.currentWarehouse = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击库位格子展示详情
|
||||
*/
|
||||
// 修复点击事件:增加日志便于调试,确保赋值正确
|
||||
handleCellClick(warehouse) {
|
||||
console.log('点击库位:', warehouse); // 调试用
|
||||
this.currentWarehouse = warehouse;
|
||||
this.dialogVisible = true;
|
||||
}
|
||||
@@ -187,68 +208,41 @@ export default {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
position: relative; // 为转置按钮提供定位上下文
|
||||
min-height: 100px; // 防止空数据时高度为0
|
||||
position: relative;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
// 转置按钮(固定位置)
|
||||
.transpose-btn {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
z-index: 20; // 高于滚动容器
|
||||
color: #409eff;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 0 8px;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border-radius: 4px;
|
||||
|
||||
&:hover {
|
||||
color: #1e88e5;
|
||||
background: #e8f4ff;
|
||||
}
|
||||
}
|
||||
|
||||
// 核心滚动容器:横向滚动,列标尺+网格共享滚动条
|
||||
.grid-scroll-container {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
position: relative;
|
||||
padding-bottom: 8px; // 给滚动条留空间
|
||||
padding-bottom: 8px;
|
||||
|
||||
// 优化滚动条样式
|
||||
&::-webkit-scrollbar {
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: #c1c1c1;
|
||||
border-radius: 4px;
|
||||
|
||||
&:hover {
|
||||
background: #a8a8a8;
|
||||
}
|
||||
}
|
||||
|
||||
// 兼容非webkit浏览器
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: #c1c1c1 #f1f1f1;
|
||||
}
|
||||
|
||||
// 滚动内容容器:列标尺 + 行标尺+网格
|
||||
.scroll-content {
|
||||
display: inline-block;
|
||||
background: #fff;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
// 列标尺样式
|
||||
.col-ruler {
|
||||
display: flex;
|
||||
height: 30px;
|
||||
@@ -266,7 +260,8 @@ export default {
|
||||
}
|
||||
|
||||
.ruler-item {
|
||||
width: 60px;
|
||||
width: var(--cell-width);
|
||||
min-width: 60px;
|
||||
text-align: center;
|
||||
font-weight: 600;
|
||||
color: #606266;
|
||||
@@ -276,13 +271,11 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
// 行标尺 + 网格容器
|
||||
.row-grid-wrapper {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
// 行标尺样式
|
||||
.row-ruler {
|
||||
width: 30px;
|
||||
background: #eef2f7;
|
||||
@@ -300,16 +293,26 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
// 库位网格容器
|
||||
.grid-container {
|
||||
display: grid;
|
||||
gap: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
// 库位格子
|
||||
// 修复伪元素遮挡点击事件:添加 pointer-events: none
|
||||
&::before {
|
||||
content: '';
|
||||
width: calc(var(--cell-width) * var(--column-count));
|
||||
display: block;
|
||||
height: 0;
|
||||
visibility: hidden;
|
||||
pointer-events: none; // 关键:让伪元素不拦截点击事件
|
||||
}
|
||||
|
||||
.warehouse-cell {
|
||||
width: var(--cell-width);
|
||||
min-width: 60px;
|
||||
height: 60px;
|
||||
width: 60px;
|
||||
border: 1px solid #e6e6e6;
|
||||
border-radius: 0;
|
||||
display: flex;
|
||||
@@ -320,18 +323,20 @@ export default {
|
||||
transition: all 0.2s;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
flex-shrink: 0;
|
||||
position: relative; // 确保层级正常
|
||||
z-index: 1; // 高于伪元素
|
||||
|
||||
&:hover {
|
||||
border-color: #409eff;
|
||||
background: #e8f4ff;
|
||||
z-index: 1;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
background: #f5f5f5;
|
||||
color: #909399;
|
||||
cursor: not-allowed;
|
||||
|
||||
&:hover {
|
||||
border-color: #e6e6e6;
|
||||
background: #f5f5f5;
|
||||
@@ -341,14 +346,17 @@ export default {
|
||||
.cell-name {
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
word-break: break-all;
|
||||
text-align: center;
|
||||
padding: 0 2px;
|
||||
}
|
||||
}
|
||||
|
||||
// 空占位格子
|
||||
.empty-cell {
|
||||
background: #fafafa;
|
||||
border-style: solid;
|
||||
border-color: #e6e6e6;
|
||||
pointer-events: none; // 空格子不需要点击事件
|
||||
|
||||
.cell-code {
|
||||
color: #c0c4cc;
|
||||
|
||||
Reference in New Issue
Block a user