You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

334 lines
9.1 KiB

3 months ago
<template>
<div class="app-container">
<el-row :gutter="20">
<el-col :span="4" :xs="24">
<div class="head-container">
<el-input
v-model="dbResoursName"
placeholder="请输入代码分类"
clearable
prefix-icon="search"
style="margin-bottom: 20px"
/>
</div>
<div class="head-container">
<el-tree
:data="dbResourceOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
node-key="id"
default-expand-all
highlight-current
@node-click="handleNodeClick"
>
<template #default="{ node, data }">
<span class="custom-tree-node">
<!-- <i :class="getIconClass(data)"></i> -->
<span>{{ data.name }}</span>
</span>
</template>
</el-tree>
</div>
</el-col>
<el-col :span="20" :xs="24">
<el-form :model="queryParams" ref="queryRef" :inline="true">
4 weeks ago
<el-form-item label="标准代码编号" prop="cdNo">
<el-input v-model="queryParams.cdNo" placeholder="请输入标准代码编号" clearable style="width: 220px" />
3 months ago
</el-form-item>
4 weeks ago
<el-form-item label="标准代码值" prop="cdValCnMean">
<el-input v-model="queryParams.cdValCnMean" placeholder="请输入标准代码值" clearable style="width: 220px" />
3 months ago
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 表格展示 -->
<el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="代码归属" align="center" prop="sysName" />
4 weeks ago
<el-table-column label="标准代码编号" align="center" prop="cdNo" />
<el-table-column label="标准代码名称" align="center" prop="cdValCnMean" >
3 months ago
<template #default="scope">
<el-link
type="primary"
:underline="true"
@click="handleCodeClick(scope.row)"
style="cursor: pointer"
>
4 weeks ago
{{ scope.row.cdValCnMean }}
3 months ago
</el-link>
</template>
</el-table-column>
4 weeks ago
<el-table-column label="代码状态" align="center" prop="cdValStat">
3 months ago
<template #default="scope">
<dict-tag
:options="std_code_appr"
4 weeks ago
:value="scope.row.cdValStat"
3 months ago
/>
</template>
</el-table-column>
<el-table-column label="引用情况" align="center" >
<template #default="scope">
<el-link
type="primary"
:underline="true"
@click="handleCodeClick(scope.row)"
style="cursor: pointer"
>
查看
</el-link>
</template>
</el-table-column>
<el-table-column label="代码关系" align="center" >
<template #default="scope">
<el-link
type="primary"
:underline="true"
@click="handleMapCodeClick(scope.row)"
style="cursor: pointer"
>
4 weeks ago
<span v-if="!scope.row.codeMapName||scope.row.cdType=='company'">代码映射</span>
3 months ago
<span v-else>{{ scope.row.codeMapName }}</span>
</el-link>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="handlePagination" />
</el-col>
</el-row>
<!-- 查看标准代码详情 -->
<el-dialog :title="dialogTitle2" v-model="dialogVisible2" width="1000px">
<!-- 引入第二个页面组件 -->
<code-item ref="editCodeDialog" v-if="dialogVisible2" :rowData="selectedRow" :dbResourceOldList="dbResourceOldList"/>
<template #footer>
<el-button @click="handleCancel2">取消</el-button>
<el-button type="primary" @click="handleSave2">确定</el-button>
</template>
</el-dialog>
<el-dialog v-model="codeVisible" width="1000px">
<!-- 引入第二个页面组件 -->
<code-item-common ref="showCodeDialog" v-if="codeVisible" :codeId="codeMapId"/>
</el-dialog>
<el-dialog v-model="mapVisible" width="1200px">
<!-- 引入第三个页面组件 -->
<code-map ref="showMapCodeDialog" v-if="mapVisible" :codeId="codeMapId"/>
</el-dialog>
</div>
</template>
<script setup>
import { ref, reactive, onMounted, toRefs } from 'vue';
import { listStdCode, addStdCode, getStdCode, updateStdCode, deleteStdCode } from "@/api/datastd/std"; // 更新为新的接口
import { datasourcetree } from "@/api/meta/metatask";
import { ElLink } from 'element-plus';
import CodeItem from './codeItem.vue'; // 引入第二个页面组件
import codeItemCommon from './codeItemCommon.vue'; // 引入第二个页面组件
import codeMap from './codeMap'; // 引入第二个页面组件
const { proxy } = getCurrentInstance();
const { std_code_status,std_code_appr } = proxy.useDict("std_code_status","std_code_appr");
const queryParams = ref({
4 weeks ago
cdNo: '',
cdValCnMean: '',
cdType: '',
3 months ago
sysName: '',
classId:'code',
sysId: '',
pageNum: 1,
pageSize: 10
});
const single = ref(true);
const multiple = ref(true);
const dbResoursName = ref(undefined);
const defaultProps = {
children: "children",
label: "name"
};
// 用于第二个对话框
const dialogVisible2 = ref(false);
const dialogTitle2 = ref('标准代码');
const selectedRow = ref(null); // 传递给 codeItem 组件的数据
const handlePagination = (pageNum, pageSize) => {
queryParams.value.pageNum = pageNum;
queryParams.value.pageSize = pageSize;
handleQuery();
};
const filterNode = (value, data) => {
if (!value) return true;
return data.name.indexOf(value) !== -1;
};
const handleNodeClick = (data) => {
if(data==9999){
queryParams.value.sysId =undefined;
}else{
queryParams.value.sysId = data.id;
}
handleQuery();
};
const dbResourceOptions = ref(undefined);
const form = ref({
id: '',
4 weeks ago
cdNo: '',
cdValCnMean: '',
cdType: 'company',
cdValStat: '',
3 months ago
sysName: '',
sysId: undefined
});
const ids = ref([]);
4 weeks ago
const cdNos = ref([]);
3 months ago
// 获取数据列表
const getList = async () => {
loading.value = true;
const response = await listStdCode(queryParams.value);
tableData.value = response.rows;
total.value = response.total;
loading.value = false;
};
const codeVisible = ref(false);
const mapVisible = ref(false);
const codeMapId = ref(null);
const selections = ref(null);
// 点击代码名称,弹出第二个对话框并传递数据
const handleCodeClick = (row) => {
codeMapId.value=row.id
codeVisible.value = true;
};
const handleMapCodeClick = (row) => {
codeMapId.value=row.id
mapVisible.value = true;
};
function handleSelectionChange(selection) {
selections.value = selection; // 保存选中的行数据
console.log(selections.value,"子页面选中")
}
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
defineExpose({
selections
});
const resetQuery = () => {
queryParams.value = {
4 weeks ago
cdNo: '',
cdValCnMean: '',
cdType: '',
3 months ago
sysName: '',
sysId: '',
pageNum: 1,
pageSize: 10
};
getList();
};
const handleAdd = () => {
dialogTitle.value = "新增标准代码";
form.value = {
id: '',
4 weeks ago
cdNo: '',
cdValCnMean: '',
cdType: '',
cdValStat: '',
3 months ago
sysName: '',
sysId: '',
};
selectedRow.value={...form.value}
dialogVisible2.value = true;
};
const handleSave2 =async () => {
const child = proxy.$refs.editCodeDialog;
let isSuccess= await child.handleSave()
if(isSuccess){
dialogVisible2.value = false;
handleQuery()
}
};
const handleCancel = () => {
dialogVisible.value = false;
};
const handleCancel2 = () => {
dialogVisible2.value = false;
};
const dbResourceOldList = ref([]);
const tableData = ref([]);
const total = ref(0);
const loading = ref(false);
const dialogVisible = ref(false);
const dialogTitle = ref("");
onMounted(() => {
datasourcetree().then(response => {
dbResourceOldList.value = response.rows;
const childrenList = dbResourceOldList.value.map(element => ({ ...element, parentId: "99999" }));
dbResourceOptions.value = [
{
id: 10000, // 新的节点 ID,可以根据需要调整
name: "公司级代码",
parentId: 0,
children: [] // 这里可以根据需要填充子节点
},
{
id: 99999,
name: "系统级代码",
parentId: 0,
children: childrenList
},
]; });
getList();
});
</script>
<style scoped>
.app-container {
padding: 20px;
}
.head-container {
margin-bottom: 0px;
}
.custom-tree-node {
display: flex;
align-items: center;
}
.custom-tree-node i {
margin-right: 8px;
}
</style>