Files
sgxt_web/src/views/backOfficeSystem/DeploymentDisposal/mpvPeo/model/contact.vue

311 lines
7.5 KiB
Vue
Raw Normal View History

2025-09-10 20:22:00 +08:00
<template>
<div>
<div class="headClass" style="">
<h3>密切联系人</h3>
2025-09-15 17:48:21 +08:00
<el-button type="primary" @click="openDialog('新增密切联系人', {}, true)">新增</el-button>
2025-09-10 20:22:00 +08:00
</div>
<div class="headSelect">
<el-form :model="formData" :inline="true" ref="formRef" :rules="rulesForm" class="form-inline">
<!-- 姓名 -->
2025-09-15 17:48:21 +08:00
<!-- <el-form-item label="姓名">
<el-input v-model="formData.username" placeholder="请输入姓名" />
</el-form-item> -->
2025-09-10 20:22:00 +08:00
<!-- 身份证号码 -->
2025-09-15 17:48:21 +08:00
<el-form-item label="身份证号码">
<el-input v-model="formData.rySfzh" placeholder="请输入身份证号码" />
2025-09-10 20:22:00 +08:00
</el-form-item>
<!-- 按钮组统一放在一个 item -->
<el-form-item class="form-actions">
<el-button type="primary" @click="check">查询</el-button>
<el-button @click="resetForm">重置</el-button>
</el-form-item>
</el-form>
</div>
<MyTable :tableData="pageData.tableData" :tableColumn="pageData.tableColumn" :tableHeight="pageData.tableHeight"
:key="pageData.keyCount" :tableConfiger="pageData.tableConfiger" :controlsWidth="pageData.controlsWidth">
2025-09-15 17:48:21 +08:00
<template #dygx="{ row }">
<DictTag :tag="false" :value="row.dygx" :options="D_BZ_QSGXDM" />
</template>
2025-09-10 20:22:00 +08:00
<!-- 操作 -->
<template #controls="{ row }">
<el-link type="danger" @click="delDictItem(row.id)">删除</el-link>
2025-09-15 17:48:21 +08:00
<el-link type="danger" @click="openDialog('修改密切联系人', row, false)">修改</el-link>
2025-09-10 20:22:00 +08:00
</template>
</MyTable>
2025-09-15 17:48:21 +08:00
<diaLogForm v-model="dialogVisible" :data="diaLogRuleForm" @submit="addPersonOrModifica" :title="Tips"
:dict="{ D_BZ_QSGXDM }">
2025-09-12 18:21:03 +08:00
</diaLogForm>
2025-09-10 20:22:00 +08:00
</div>
</template>
<script setup>
import { identityCardRule } from "@/utils/rules"
import { ref, reactive, watch, toRaw, getCurrentInstance, onMounted, onUnmounted } from "vue";
import MyTable from "@/components/aboutTable/MyTable.vue";
2025-09-15 17:48:21 +08:00
import diaLogForm from "../component/diaLogForm.vue";
import { tbZdryClxxUpdate, tbGsxtZdryLxrsaveOrUpdateLxr,tbGsxtZdryLxrselectLxrBy ,tbGsxtZdryLxr} from '@/api/zdr.js'
2025-09-10 20:22:00 +08:00
import { ElMessage, ElMessageBox } from "element-plus";
const { proxy } = getCurrentInstance();
2025-09-15 17:48:21 +08:00
const { D_BZ_QSGXDM } = proxy.$dict("D_BZ_QSGXDM"); //获取字典数据
2025-09-10 20:22:00 +08:00
const props = defineProps({
dataList: {
type: Object,
default: () => { },
}, disabled: {
type: Boolean,
default: false
},
showBut: {
type: Boolean,
default: false
},
})
2025-09-12 18:21:03 +08:00
const dialogVisible = ref(false)
2025-09-10 20:22:00 +08:00
const listData = ref({})
2025-09-15 17:48:21 +08:00
const Tips = ref("密切联系人")
2025-09-10 20:22:00 +08:00
// 表格数据
const pageData = reactive({
tableData: [],
tableColumn: [{
2025-09-12 18:21:03 +08:00
prop: 'ryXm',
2025-09-10 20:22:00 +08:00
label: '人员姓名',
}, {
2025-09-12 18:21:03 +08:00
prop: 'rySfzh',
2025-09-10 20:22:00 +08:00
label: '身份证号码',
}, {
2025-09-12 18:21:03 +08:00
prop: 'dygx',
2025-09-10 20:22:00 +08:00
label: '关系',
2025-09-15 17:48:21 +08:00
showSolt: true,
2025-09-10 20:22:00 +08:00
}, {
2025-09-12 18:21:03 +08:00
prop: 'lxrDh',
2025-09-10 20:22:00 +08:00
label: '联系电话',
}],
tableHeight: '200px',
keyCount: 0,
tableConfiger: {
border: true,
stripe: true,
showHeader: true,
showIndex: true,
indexLabel: '序号',
indexWidth: 60,
align: 'center',
showOverflowTooltip: true,
haveControls: !props.disabled
},
controlsWidth: 200,
})
// 表单数据
2025-09-15 17:48:21 +08:00
const formData = ref({
2025-09-10 20:22:00 +08:00
username: "",
ID: ""
})
2025-09-15 17:48:21 +08:00
const touchIn = ref(true)
2025-09-12 18:21:03 +08:00
const rulesForm = ref(identityCardRule({ validator: true }, 'rySfzh'))
2025-09-15 17:48:21 +08:00
const diaLogRuleForm = ref({})
2025-09-12 18:21:03 +08:00
watch(() => props.dataList, (val) => {
if (val) {
listData.value = val
2025-09-15 17:48:21 +08:00
getContact()
2025-09-12 18:21:03 +08:00
}
}, { deep: true })
// 弹出增加或者修改弹窗
2025-09-15 17:48:21 +08:00
const openDialog = (type, formVal, bool) => {
touchIn.value = bool
2025-09-12 18:21:03 +08:00
dialogVisible.value = true
Tips.value = type
2025-09-15 17:48:21 +08:00
diaLogRuleForm.value = { ...formVal }
2025-09-12 18:21:03 +08:00
}
2025-09-15 17:48:21 +08:00
// 提交表单
const addPersonOrModifica = (val) => {
if (touchIn.value) {
const item = pageData.tableData.findIndex(item => item.rySfzh == val.rySfzh)
if (item != -1) {
proxy.$message({
message: '该人员已存在',
type: 'warning'
})
return
2025-09-10 20:22:00 +08:00
}
}
2025-09-15 17:48:21 +08:00
const promes = {
...val,
zdryId: listData.value.id
}
tbGsxtZdryLxrsaveOrUpdateLxr(promes).then((res) => {
proxy.$message({
message: '操作成功',
type: 'success'
})
getContact()
}).catch((err) => {
proxy.$message({
message: '操作失败',
type: 'error'
})
});
2025-09-10 20:22:00 +08:00
}
const delDictItem = (val) => {
2025-09-15 17:48:21 +08:00
ElMessageBox.confirm(
'是否删除该联系人',
'提示',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
tbGsxtZdryLxr(val).then((res) => {
proxy.$message({
message: '删除成功',
type: 'success'
2025-09-10 20:22:00 +08:00
})
2025-09-15 17:48:21 +08:00
getContact()
}).catch((err) => {
2025-09-10 20:22:00 +08:00
2025-09-15 17:48:21 +08:00
});
})
.catch(() => {
proxy.$message({
message: '删除失败',
type: 'info',
})
})
2025-09-10 20:22:00 +08:00
}
2025-09-15 17:48:21 +08:00
const getContact = () => {
const promes = { zdryId: listData.value.id }
tbGsxtZdryLxrselectLxrBy(promes).then((res) => {
pageData.tableData = res
})
2025-09-10 20:22:00 +08:00
}
2025-09-15 17:48:21 +08:00
const resetForm = () => {
formData.value = {}
getContact()
2025-09-10 20:22:00 +08:00
}
2025-09-15 17:48:21 +08:00
const check = () => {
if (formData.value.rySfzh) {
// 模糊查询:检查身份证号码是否包含输入的内容
pageData.tableData = pageData.tableData.filter(item => item.rySfzh && item.rySfzh.includes(formData.value.rySfzh))
} else {
// 如果输入为空,显示所有数据
getContact()
2025-09-10 20:22:00 +08:00
}
}
2025-09-15 17:48:21 +08:00
2025-09-10 20:22:00 +08:00
// 抛出数据并验证标签列表不为空
const throwData = () => {
return new Promise((resolve) => {
// // 验证:确保标签列表不为空
// if (!pageData.tableData || pageData.tableData.length === 0) {
// throw new Error('请录入车辆信息');
// }
resolve(pageData.tableData);
});
}
defineExpose({
throwData
})
</script>
<style lang="scss" scoped>
@import "~@/assets/css/layout.scss";
@import "~@/assets/css/element-plus.scss";
.backinfo-container {
padding: 10px;
}
2025-09-12 18:21:03 +08:00
2025-09-10 20:22:00 +08:00
.left_box {
width: 200px;
border: 1px solid #c8c8c89a;
border-radius: 5px;
padding: 5px;
}
.right_box {
width: calc(100% - 230px);
overflow-y: auto;
padding: 5px;
}
::v-deep .el-form-item__content {
display: block !important;
}
.headClass {
font-size: 18px;
font-weight: 600;
color: #303133;
margin: 0 0 10px 0;
padding-bottom: 10px;
border-bottom: 2px solid #409eff;
position: relative;
2025-09-15 17:48:21 +08:00
display: flex;
justify-content: space-between;
align-items: center;
2025-09-10 20:22:00 +08:00
}
.headSelect {
width: 100%;
padding: 0 16px;
background-color: #fff;
border-bottom: 1px solid #eee;
2025-09-12 18:21:03 +08:00
::v-deep(.el-form) {
display: flex;
justify-content: space-between;
}
2025-09-10 20:22:00 +08:00
2025-09-12 18:21:03 +08:00
/* 移除冲突样式:不要用 justify-content */
2025-09-10 20:22:00 +08:00
2025-09-12 18:21:03 +08:00
/* 控制所有 el-form-item 高度和垂直居中 */
.form-inline :deep(.el-form-item) {
margin-bottom: 0;
height: 60px;
display: flex;
align-items: center;
}
2025-09-10 20:22:00 +08:00
2025-09-12 18:21:03 +08:00
/* ✅ 按钮区域靠右,且不换行 */
.form-inline .form-actions {
margin-left: auto;
/* 推到最右边 */
white-space: nowrap;
/* 防止按钮换行 */
}
/* 统一按钮样式,增加间距和视觉舒适度 */
.form-inline :deep(.el-button) {
height: 36px;
padding: 8px 16px;
font-size: 14px;
border-radius: 4px;
}
2025-09-10 20:22:00 +08:00
2025-09-12 18:21:03 +08:00
/* 按钮之间留出间距(除了第一个) */
.form-inline :deep(.el-button:not(:first-child)) {
margin-left: 12px;
/* 比原来的 8px 更宽松 */
}
2025-09-10 20:22:00 +08:00
}
2025-09-12 18:21:03 +08:00
2025-09-10 20:22:00 +08:00
// .headClass::after {
// content: '';
// position: absolute;
// left: 0;
// bottom: -2px;
// width: 60px;
// height: 2px;
// background-color: #409eff;
// }
h3 {
margin: 0;
}
2025-09-12 18:21:03 +08:00
</style>