Commit eb2d36d3 authored by Mr.Tang's avatar Mr.Tang

对应关系国内国际bug修复

parent f676ae7e
......@@ -3,7 +3,7 @@ import request from '@/utils/request'
export function list(query) {
return request({
url: '/control/lawPartMiddle/list',
method: 'get',
method: 'post',
data: query,
})
}
......
......@@ -27,15 +27,6 @@ export function partDetails(query) {
})
}
// 新增法规与关键件对应数据管理
export function addRelation(data) {
return request({
url: '/control/lawPartRelation/add',
method: 'post',
data: data,
})
}
// 修改法规与关键件对应数据管理
export function updateRelation(data) {
return request({
......@@ -56,8 +47,8 @@ export function addBatchRelation(query) {
/** 移除对应关系 */
export function delRelation(id) {
return request({
url: '/control/lawPartRelation/del/' + id,
method: 'delete',
url: `/control/lawPartRelation/del/${id}`,
method: 'get',
})
}
/**查询没有关联的零部件 */
......
......@@ -3,7 +3,7 @@
"source": "来源",
"standardName": "标准名称",
"partName": "零件名称",
"notice": "共5个未关联法规的CQC关键零部件",
"notice": "共个未关联法规的CQC关键零部件",
"serialNumber": "序号",
"correspondingParts": "对应零件",
"createTime": "创建时间",
......
......@@ -3,7 +3,7 @@
"source": "Source",
"standardName": "Standard Name",
"partName": "Part Name",
"notice": "A total of 5 CQC key components not related to regulations",
"notice": "CQC key components without associated regulations",
"serialNumber": "Serial Number",
"correspondingParts": "Corresponding Parts",
"order": "order",
......
......@@ -54,7 +54,7 @@
>
{{ unrelatedCount }}
</span>
个未关联法规的CQC关键零部件
个未关联法规的CQC关键零部件/{{ unrelatedCount }} {{ en.notice }}
</el-form-item>
</el-form>
......@@ -129,24 +129,31 @@
</el-table>
<pagination
v-show="total > 0"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
:total="total"
v-show="paginationStates.mainTable.total > 0"
v-model:page="paginationStates.mainTable.pageNum"
v-model:limit="paginationStates.mainTable.pageSize"
:total="paginationStates.mainTable.total"
@pagination="getList"
/>
</div>
<!--待关联法规的CQC关键零部件-->
<el-drawer v-model="open1" :title="title" append-to-body>
<el-form ref="partRef" :model="form" label-width="80px">
<el-row>
<el-form-item label="零件名称" prop="criticalPartNameCn">
<el-form ref="partRef" :model="queryParams">
<el-form-item
:label="`${cn.partName}/${en.partName}`"
prop="criticalPartNameCn"
>
<el-input
v-model="queryParams.criticalPartNameCn"
placeholder="请输入"
:placeholder="`${cn.pleaseEnter}/${en.pleaseEnter}`"
clearable
style="width: 200px"
/>
</el-form-item>
<el-form-item label="来源" prop="certificationBody">
<el-form-item
:label="`${cn.source}/${en.source}`"
prop="certificationBody"
>
<el-select
v-model="queryParams.certificationBody"
:placeholder="`${cn.pleaseChoose}/${en.pleaseChoose}`"
......@@ -165,11 +172,10 @@
<el-button class="btn-A" @click="handleQuery1">
{{ cn.search }}/{{ en.search }}
</el-button>
<el-button class="btn-B" @click="resetQuery">
<el-button class="btn-B" @click="resetQuery1">
{{ cn.reset }}/{{ en.reset }}
</el-button>
</el-form-item>
</el-row>
</el-form>
<el-table
......@@ -232,7 +238,7 @@
<el-table
v-loading="loading"
:data="lawList"
@selection-change="handleSelectionChange"
@selection-change="handleLawSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" width="150" fixed="left">
......@@ -275,7 +281,7 @@
<el-button class="btn-B" @click="cancelRelationLaw"
>{{ cn.cancel }}/{{ en.cancel }}</el-button
>
<el-button class="btn-A" @click="addRelations"
<el-button class="btn-A" @click="addLawRelations"
>{{ cn.submitForm }}/{{ en.submitForm }}</el-button
>
</div>
......@@ -284,10 +290,19 @@
<!-- 查看对应零件 -->
<el-drawer v-model="open2" :title="title" append-to-body>
<el-form ref="partRef" :model="form" :rules="rules" label-width="70px">
<el-form
ref="partRef"
:model="queryParams"
:rules="rules"
label-width="70px"
>
<el-row>
<el-form-item label="零件名称" prop="partName">
<el-input v-model="form.partName" placeholder="请输入" />
<el-form-item label="零件名称" prop="criticalPartNameCn">
<el-input
v-model="queryParams.criticalPartNameCn"
placeholder="请输入"
clearable
/>
</el-form-item>
<el-form-item label="来源" prop="certificationBody">
<el-select
......@@ -305,10 +320,10 @@
</el-select>
</el-form-item>
<el-form-item>
<el-button class="btn-A" @click="handleQuery"
<el-button class="btn-A" @click="handleQuery2"
>{{ cn.search }}/{{ en.search }}</el-button
>
<el-button class="btn-B" @click="resetQuery"
<el-button class="btn-B" @click="resetQuery2"
>{{ cn.reset }}/{{ en.reset }}</el-button
>
<el-button class="btn-C" @click="handleAdd"
......@@ -430,7 +445,6 @@ import {
partDetails,
addBatchRelation,
selectCanRelateLaw,
addRelation,
updateRelation,
delRelation,
} from '@/api/RelationManagement/baseLawPartRelation'
......@@ -462,29 +476,23 @@ const addPartsList = ref([])
// 存储选中行的数据
const selectedRows = ref([])
// 定义行唯一标识(根据实际字段调整)
// 在 setup() 或 script setup 中定义响应式变量
const currentStandardNo = ref('')
const currentPartName = ref('') // 存储当前操作的零件名称
const selectedLaws = ref([]) // 存储选中的法规数据
const getRowKey = (row) => row.id // 假设每行有唯一id字段
const paginationStates = reactive({
// 主表格分页
mainTable: {
pageNum: 1,
pageSize: 10,
total: 0,
},
})
const queryForm = reactive({
standardNo: '',
criticalPartNameCn: '',
certificationBody: '',
})
const queryParams1 = [
{
pageNum: 1,
pageSize: 10,
id: null,
partId: null,
partName: null,
standardNo: null,
standardName: null,
standardNumber: null,
criticalPartNameCn: null,
criticalPartNameEn: null,
certificationBody: null,
},
]
const data = reactive({
form: {},
......@@ -499,7 +507,6 @@ const data = reactive({
standardNumber: null,
criticalPartNameCn: null,
criticalPartNameEn: null,
certificationBody: null,
},
rules: {
createTime: [
......@@ -518,10 +525,14 @@ const { queryParams, form, rules } = toRefs(data)
/** 查询国内法规与关键件 */
function getList() {
loading.value = true
listRelation(queryParams.value).then((response) => {
listRelation({
...queryParams.value,
pageNum: paginationStates.mainTable.pageNum,
pageSize: paginationStates.mainTable.pageSize,
}).then((response) => {
//console.log('789', response)
partList.value = response.rows
total.value = response.total
paginationStates.mainTable.total = response.total
loading.value = false
})
}
......@@ -535,28 +546,38 @@ function openDialogForNotRelation() {
/**查看没有关联法规的零件*/
function getSelectNoRelateLawPart() {
loading.value = true
selectNoRelatePart(queryParams).then((response) => {
selectNoRelatePart(queryParams.value).then((response) => {
noRelateCQCList.value = response
// 确保使用正确的响应数据结构
total.value = response.length
loading.value = false
// 将总数传递到模板中
updateUnrelatedCount(total.value)
/*updateUnrelatedCount(total.value)*/
})
}
/**查看没有关联的零件*/
function getSelectNoRelatePart() {
loading.value = true
selectNoRelatePart(queryParams).then((response) => {
const params = {
...queryParams, // 保留其他参数(如果有)
certificationBody: '1', // 强制设置为字符串 '1'
}
selectNoRelatePart(params)
.then((response) => {
addRelationList.value = response
// 确保使用正确的响应数据结构
total.value = response.length
loading.value = false
// 将总数传递到模板中
updateUnrelatedCount(total.value)
// 统计 certificationBody == '手动' 的数据数量
const manualCount = response.filter(
(item) => item.certificationBody === '手动',
).length
// 将统计结果传递给更新函数
updateUnrelatedCount(manualCount)
})
.finally(() => {
loading.value = false
})
}
......@@ -602,6 +623,18 @@ function handleQuery1() {
//queryParams.value.pageNum = 1
getSelectNoRelateLawPart()
}
function resetQuery1() {
proxy.resetForm('queryRef')
handleQuery1()
}
function handleQuery2() {
//queryParams.value.pageNum = 1
getPartDetail()
}
function resetQuery2() {
proxy.resetForm('queryRef')
handleQuery2()
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm('queryRef')
......@@ -630,7 +663,10 @@ function showPartDialog(row) {
function getPartDetail(row) {
// 2. 发起请求
loading.value = true
partDetails({ standardNo: currentStandardNo.value })
partDetails({
...queryParams.value,
standardNo: currentStandardNo.value,
})
.then((response) => {
partDetailsList.value = response.data || response // 兼容不同API结构
total.value = partDetailsList.value.length
......@@ -644,16 +680,25 @@ function getPartDetail(row) {
}
/*选择要关联的法规弹框*/
function handleRelation() {
function handleRelation(row) {
currentPartName.value = row.criticalPartNameCn // 存储零件名称
currentStandardNo.value = '' // 清空之前的标准编号
//lawStandardName.value = row.standardNumber
open.value = true
title.value = '选择要关联的法规'
handleRelationLaw()
handleRelationLaw(row)
}
// 修改法规选择处理
const handleLawSelectionChange = (selection) => {
selectedLaws.value = selection
}
/*查询所有关联法规*/
function handleRelationLaw() {
function handleRelationLaw(row) {
loading.value = true
selectCanRelateLaw(queryParams)
selectCanRelateLaw({
standardNo: row.standardNumber,
standardName: row.criticalPartNameCn,
})
.then((response) => {
//console.log('8767837837', response)
lawList.value = response.rows
......@@ -695,10 +740,10 @@ function handleDelete(row) {
proxy.$modal
.confirm('是否确认删除编号为"' + _ids + '"的数据项?')
.then(function () {
return delPart(_ids)
return delRelation(_ids)
})
.then(() => {
getList()
getPartDetail()
proxy.$modal.msgSuccess('删除成功')
})
.catch(() => {})
......@@ -720,10 +765,33 @@ function addRelations() {
proxy.$modal.msgSuccess('新增成功')
open3.value = false
getPartDetail()
handleRelationLaw()
selectedRows.value = [] // 清空选中状态
})
}
function addLawRelations() {
if (selectedLaws.value.length === 0) {
proxy.$modal.msgWarning('请至少选择一条法规数据')
return
}
const requestData = selectedLaws.value.map((law) => ({
partName: currentPartName.value,
standardNo: law.standardNumber, // 使用选中法规的编号
}))
addBatchRelation(requestData).then(() => {
proxy.$modal.msgSuccess('关联成功')
open.value = false
// 刷新相关数据
getList()
getSelectNoRelateLawPart()
// 清空状态
currentPartName.value = ''
selectedLaws.value = []
currentStandardNo.value = ''
})
}
/** 提交按钮 */
function submitForm() {
proxy.$refs['partRef'].validate((valid) => {
......
......@@ -167,27 +167,35 @@
<!-- 维护类型描述抽屉 -->
<el-drawer v-model="open" :title="title" width="800px" append-to-body>
<el-form ref="middleRef" :model="form" :rules="rules" label-width="80px">
<el-form
ref="middleRef"
:model="queryParams"
:rules="rules"
label-width="80px"
>
<el-row>
<el-form-item label="项目" prop="project">
<el-input placeholder="请输入" style="width: 150px" />
<el-form-item label="项目" prop="typeDescription">
<el-input
v-model="queryParams.typeDescription"
placeholder="请输入"
style="width: 150px"
/>
</el-form-item>
<el-button
style="margin-left: 10px; width: 110px"
class="btn-A"
@click="handleQuery"
@click="handleQuery2"
>{{ cn.search }}/{{ en.search }}</el-button
>
<el-button class="btn-B" @click="resetQuery"
<el-button class="btn-B" @click="resetQuery2"
>{{ cn.reset }}/{{ en.reset }}</el-button
>
<el-button class="btn-C" @click="handleAdd"
<el-button class="btn-C" @click="() => handleAdd(currentRow)"
>{{ cn.add }}/{{ en.add }}</el-button
>
</el-row>
</el-form>
<el-table
:key="drawerPartKey"
v-loading="loading"
:data="drawerPartList"
border
......@@ -335,16 +343,19 @@
</el-dialog>
<!-- 查看对应零件 -->
<el-drawer v-model="open2" :title="title" append-to-body>
<el-form ref="partRef" :model="form" label-width="70px">
<el-form ref="middleRef" :model="queryParams" label-width="70px">
<el-row>
<el-form-item label="零件名称" prop="partName">
<el-input v-model="form.partName" placeholder="请输入" />
<el-form-item label="零件名称" prop="criticalPartNameCn">
<el-input
v-model="queryParams.criticalPartNameCn"
placeholder="请输入"
/>
</el-form-item>
<el-form-item>
<el-button class="btn-A" @click="handleQuery"
<el-button class="btn-A" @click="handleQuery1"
>{{ cn.search }}/{{ en.search }}</el-button
>
<el-button class="btn-B" @click="resetQuery"
<el-button class="btn-B" @click="resetQuery1"
>{{ cn.reset }}/{{ en.reset }}</el-button
>
</el-form-item>
......@@ -439,8 +450,22 @@ const multiple = ref(true)
const total = ref(0)
const title = ref('')
const partDetailsList = ref([])
const currentRow = ref(null) // 存储当前行的数据
const currentStandardName = ref('')
const currentStandardNo = ref('')
// 在父组件中定义当前行数据
const currentRow = ref({})
// 修改后的数据部分
const drawerData = ref({
open: false,
title: '',
currentStandardName: '',
list: [],
query: {
pageNum: 1,
pageSize: 10,
standardName: '',
},
})
const data = reactive({
form: {},
queryParams: {
......@@ -478,16 +503,6 @@ function getList() {
})
}
function listAll() {
loading.value = true
list(queryParams.value).then((response) => {
drawerPartList.value = response
console.log('------------------', response)
total.value = response.total
loading.value = false
})
}
// 取消按钮
function cancel() {
open.value = false
......@@ -506,13 +521,14 @@ function reset() {
delFlag: null,
partId: null,
standardNumberId: null,
typeDescription: null,
}
proxy.resetForm('middleRef')
}
/*查看零件详情抽屉*/
function showPartDialog(row) {
//currentRow.value = row // 保存当前行
currentStandardName.value = row.standardName // 保存当前行的 standardName
open2.value = true // 打开对话框
this.title = `查看对应零件(${row.standardNumber},共${row.partCount}个零件)` // 设置对话框标题
getPartDetail(row)
......@@ -521,7 +537,11 @@ function getPartDetail(row) {
// 2. 发起请求
loading.value = true
console.log('row', row)
partDetails({ standardNo: row.standardNumber })
currentStandardNo.value = row.standardNumber
partDetails({
...queryParams.value,
standardNo: currentStandardNo.value,
})
.then((response) => {
partDetailsList.value = response.data || response // 兼容不同API结构
total.value = partDetailsList.value.length
......@@ -545,6 +565,30 @@ function resetQuery() {
proxy.resetForm('middleRef')
handleQuery()
}
function handleQuery1() {
queryParams.value.pageNum = 1
getPartDetail({
criticalPartNameCn: queryParams.value.criticalPartNameCn,
standardNo: currentStandardNo.value, // 确保此处已赋值
})
}
/** 重置按钮操作 */
function resetQuery1() {
proxy.resetForm('middleRef')
handleQuery1()
}
function handleQuery2() {
//queryParams.value.pageNum = 1
listAll()
}
/** 重置按钮操作 */
function resetQuery2() {
proxy.resetForm('middleRef')
handleQuery2()
}
// 多选框选中数据
function handleSelectionChange(selection) {
......@@ -554,10 +598,16 @@ function handleSelectionChange(selection) {
}
/** 新增按钮操作 */
function handleAdd() {
function handleAdd(row) {
reset()
open1.value = true
title.value = '新增类型描述'
// 确保 standardName 的来源
if (row?.standardName) {
form.value.standardName = row.standardName
} else if (currentRow.value?.standardName) {
form.value.standardName = currentRow.value.standardName
}
}
/** 修改按钮操作 */
......@@ -567,15 +617,55 @@ function openDialogOpen1(row) {
}
// 维护类型描述抽屉
function handleMaintain(row) {
reset()
const { id, standardName } = row
const _id = id || ids.value
list(_id, standardName).then((response) => {
drawerPartList.value = response
currentRow.value = row
console.log('main', row)
currentStandardName.value = row.standardName
title.value = '维护类型描述'
open.value = true
listAll(row)
}
function listAll(row = currentRow.value) {
loading.value = true
list({
// 显式声明为 URL 参数
...queryParams.value,
standardName: row?.standardName,
}).then((response) => {
drawerPartList.value = response.data || response
total.value = response.length || response.total
loading.value = false
})
}
// 修改后的方法部分
/*function handleMaintain(row) {
drawerData.value = {
...drawerData.value,
open: true,
title: `维护类型描述`,
currentStandardName: row.standardName,
query: {
...drawerData.value.query,
standardName: row.standardName,
},
}
listAll() // 立即加载数据
}
// 修改后的数据获取方法
function listAll() {
loading.value = true
list({
...drawerData.value.query,
standardName: drawerData.value.currentStandardName, // 确保使用当前标准名称
})
.then((response) => {
drawerData.value.list = response.rows || response
drawerData.value.total = response.total || response.length
})
.finally(() => {
loading.value = false
})
}*/
// 编辑对话框
function handleEdit(row) {
reset()
......@@ -584,20 +674,28 @@ function handleEdit(row) {
open1.value = true
}
/** 提交按钮 */
function submitForm() {
function submitForm(row) {
proxy.$refs['middleRef'].validate((valid) => {
if (valid) {
if (form.value.id != null) {
updateMiddle(form.value).then((response) => {
updateMiddle({
...form.value,
standardName: row.standardName,
}).then((response) => {
proxy.$modal.msgSuccess('修改成功')
open1.value = false
listAll()
getList()
})
} else {
addMiddle(form.value).then((response) => {
addMiddle({
...form.value,
standardName: form.value.standardName,
}).then((response) => {
proxy.$modal.msgSuccess('新增成功')
open1.value = false
listAll()
getList()
})
}
}
......@@ -631,7 +729,6 @@ function handleExport() {
}
/** 修改按钮操作 */
const handleMoveUp = async (row) => {
console.log()
try {
await moveUp(row.id)
proxy.$modal.msgSuccess('上移成功')
......@@ -659,5 +756,4 @@ function colseDialogOpen1() {
open1.value = false
}
getList()
listAll()
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment