通道号、项目排序

This commit is contained in:
wyuu 2025-12-19 17:28:33 +08:00
parent 9e5365c96f
commit 182d43fd84
4 changed files with 186 additions and 106 deletions

View File

@ -107,3 +107,43 @@ export function querySjcs(data?: Object) {
params: data params: data
}); });
} }
// 查询检验项目排序
export function getitemsort(data?: Object) {
return request({
url: '/xminfo/getitemsort',
method: 'get',
params: data
});
}
// 保存检验项目排序
export function saveitemsort(data?: Object) {
return request({
url: '/xminfo/saveitemsort',
method: 'post',
data
});
}
// 查询检验项目通道号
export function getitemtdh(data?: Object) {
return request({
url: '/xminfo/getitemtdh',
method: 'get',
params: data
});
}
// 保存检验项目通道号
export function saveitemtdh(data?: Object) {
return request({
url: '/xminfo/saveitemtdh',
method: 'post',
data
});
}
// 删除检验项目通道号
export function delitemtdh(data?: Object) {
return request({
url: '/xminfo/delitemtdh',
method: 'get',
params: data
});
}

View File

@ -18,18 +18,15 @@
<el-row :gutter="10" class="table-row"> <el-row :gutter="10" class="table-row">
<el-col :span="12" class="table-box"> <el-col :span="12" class="table-box">
<el-table :data="tableData" height="100%" border highlight-current-row> <CustomTable ref="tableRef" :data="tableData" :columns="columns" :config="tableConfig"
<el-table-column label="通道号" align="center"> @row-click="handleRowClick">
<template #default="scope"> <template #tdh="{ row }">
<el-input v-model="scope.row.channel" placeholder="请输入通道号" class="full-width-input" /> <el-input v-model="row.tdh" placeholder="请输入通道号" class="full-width-input" />
</template> </template>
</el-table-column> <template #xmmc="{ row }">
<el-table-column label="项目" align="center"> <SelectTable v-model:data="row.xmdh" :tableData="xmList" class="full-width-input" />
<template #default="scope">
<SelectTable v-model:data="scope.row.xmid" :tableData="xmList" class="full-width-input" />
</template> </template>
</el-table-column> </CustomTable>
</el-table>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<div class="tips"> <div class="tips">
@ -44,37 +41,93 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { queryXmInfoNewService } from '@/api/liswork/labItem/labItemApi'; import { queryXmInfo, } from '@/api/liswork/work/LisWork';
import { getitemtdh, saveitemtdh, delitemtdh } from '@/api/liswork/xtwh/ComOpt';
import { ElMessage } from 'element-plus';
const yq = defineModel<string>(); const yq = defineModel<string>();
const tableRef = ref();
const tableData = ref<Array<{ channel: string }>>([]); const tableData = ref<Array<{ tdh: string, xmdh: string }>>([]);
const columns = [
{ label: '序号', type: 'index', visible: true, width: 50, align: 'center' },
{ label: '通道号', prop: 'tdh', visible: true, align: 'center', slot: 'tdh' },
{ label: '项目代号', prop: 'xmdh', visible: true, align: 'center' },
{ label: '项目', prop: 'xmmc', visible: true, align: 'center', slot: 'xmmc', showOverflowTooltip: false },
{ label: '项目id', prop: 'xmid', visible: true, align: 'center' },
];
const tableConfig = {
border: true,
height: '100%',
highlightCurrentRow: true,
}
const handleSave = () => { const handleSave = () => {
}; const flag = tableData.value.every(item => item.tdh)
if (!flag) return ElMessage.error('请检查填写参数,通道号不能为空!')
let index = -1;
tableData.value.forEach((item, i) => {
const tdhLower = item.tdh.trim().toUpperCase();
index = tableData.value.findIndex(i => i.tdh.trim().toUpperCase() === tdhLower && i.tdh !== item.tdh);
if (index !== -1) {
return ElMessage.error(`通道号 ${item.tdh} ${i + 1}行已存在!`)
}
})
if (index !== -1) return
const arr = tableData.value.map(item => {
return {
...item,
tdh: item.tdh.trim().toUpperCase(),
yq: yq.value
}
})
saveitemtdh(arr).then((res: any) => {
if (res.code == 0) {
ElMessage.success('保存成功!')
getChannel()
}
})
};
const selectedRow = ref<any>(null);
const handleRowClick = (row: any) => {
selectedRow.value = row;
};
const addItem = () => { const addItem = () => {
tableData.value.push({ channel: '' }) tableData.value.push({ tdh: '', xmdh: '' })
nextTick(() => {
tableRef.value.setScrollTop(tableData.value.length)
})
}; };
const delItem = () => { const delItem = () => {
if (!selectedRow.value) return ElMessage.error('请选择要删除的行!')
delitemtdh({ yq: yq.value, tdh: selectedRow.value.tdh })
tableData.value = tableData.value.filter(item => item.xmdh !== selectedRow.value.xmdh)
getChannel()
} }
const allClear = () => { const allClear = () => {
} }
const xmList = ref<Array<{ xmmc: string, xmid: string }>>([]); const xmList = ref<Array<{ xmmc: string, xmdh: string }>>([]);
const getXmList = () => { const getXmList = () => {
queryXmInfoNewService({ yq: yq.value }).then((res: any) => { queryXmInfo({ yq: yq.value }).then((res: any) => {
xmList.value = res.rows.map((item: any) => { xmList.value = res.data.map((item: any) => {
return { return {
label: item.xmmc, label: item.xmmc,
value: item.xmid.toString(), value: item.xmdh,
} }
}) })
}) })
}; };
watch(() => yq.value, (val) => { const getChannel = () => {
getitemtdh({ yq: yq.value }).then((res: any) => {
tableData.value = res.data
})
}
watch(yq, (val) => {
if (val) { if (val) {
getXmList(); getXmList();
getChannel();
} }
}, { immediate: true }); }, { immediate: true });
</script> </script>

View File

@ -1,23 +1,7 @@
<template> <template>
<!-- 整体排序 --> <!-- 整体排序 -->
<div class="sort_box"> <div class="sort_box">
<el-row :gutter="10" class="table-row">
<el-col :span="20" class="table-box">
<CustomTable ref="tableRef" :data="dataList" :columns="columns" :config="tableConfig"
@row-click="handleRowClick">
<template #sort="{ row }">
<el-input v-model="row.sort" class="full-width-input" />
</template>
</CustomTable>
</el-col>
<el-col :span="4">
<el-row :gutter="10" class="table-toolbar"> <el-row :gutter="10" class="table-toolbar">
<!-- <el-col :span="1.5">
<el-radio-group v-model="radio" @change="radioChange">
<el-radio value="1">上下移动调整</el-radio>
<el-radio value="2">手工输入工号</el-radio>
</el-radio-group>
</el-col> -->
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" @click="refresh">刷新</el-button> <el-button type="primary" @click="refresh">刷新</el-button>
</el-col> </el-col>
@ -25,20 +9,20 @@
<el-button type="primary" @click="cpHandle">存盘</el-button> <el-button type="primary" @click="cpHandle">存盘</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" :disabled="radio == '2'" @click="firstHandle">首位</el-button> <el-button type="primary" @click="firstHandle">首位</el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button type="primary" icon="top" :disabled="radio == '2'" @click="prevHandle">上移</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" icon="bottom" :disabled="radio == '2'" @click="nextHandle">下移</el-button> <el-button type="primary" @click="lastHadnle">末位</el-button>
</el-col> -->
<el-col :span="1.5">
<el-button type="primary" :disabled="radio == '2'" @click="lastHadnle">末位</el-button>
</el-col>
</el-row>
</el-col> </el-col>
</el-row> </el-row>
<div class="table-row">
<CustomTable ref="tableRef" :data="dataList" :columns="columns" :config="tableConfig" :enableRowDrag="true"
@row-drag-end="handleRowDragEnd" @row-click="handleRowClick">
<template #dyxh="{ row }">
<el-input v-model="row.dyxh" class="full-width-input" />
</template>
</CustomTable>
</div>
</div> </div>
</template> </template>
@ -46,28 +30,21 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import { ref } from 'vue';
import { formatDict, dictData } from '@/hooks'; import { formatDict, dictData } from '@/hooks';
import { getitemsort, saveitemsort } from '@/api/liswork/xtwh/ComOpt';
const yq = defineModel<string>()
const props = defineProps({
dataList: {
type: Array,
default: []
}
});
interface DataItem { interface DataItem {
xmid: string | number; xmid: string | number;
xmmc: string | number; xmmc: string | number;
sort: string | number; dyxh: string | number;
} }
const currentIndex = ref(0); const selectedRow = ref<DataItem | null>(null)
const radio = ref('1');
const tableRef = ref(); const tableRef = ref();
const dataList = ref<DataItem[]>([]); const dataList = ref<DataItem[]>([]);
const columns = ref([ const columns = ref([
{ prop: 'xmid', label: '项目ID', visible: true, align: 'center', }, { prop: 'xmid', label: '项目ID', visible: true, align: 'center' },
{ prop: 'xmmc', label: '项目名称', visible: true, align: 'center', }, { prop: 'xmmc', label: '项目名称', visible: true, align: 'center' },
{ prop: 'sort', label: '整体排序', visible: true, align: 'center', slot: "sort" }, { prop: 'dyxh', label: '排序', visible: true, align: 'center', slot: "dyxh" },
]); ]);
const tableConfig = ref({ const tableConfig = ref({
border: true, // 边框 border: true, // 边框
@ -78,19 +55,26 @@ const tableConfig = ref({
//退拽属性 //退拽属性
const handleColumnDragEnd = (data: any) => { const handleRowDragEnd = (data: any) => {
// 更新列配置 // 更新行顺序
dataList.value = data.list; dataList.value = data.list.map((item: any) => {
return {
...item,
dyxh: item.sort,
}
})
} }
const handleRowClick = (row: DataItem) => { const handleRowClick = (row: DataItem) => {
currentIndex.value = dataList.value.indexOf(row); selectedRow.value = row
} }
const getList = () => { const getList = () => {
getitemsort({ yq: yq.value }).then((res: any) => {
dataList.value = res.data;
})
} }
const refresh = () => { const refresh = () => {
@ -98,56 +82,59 @@ const refresh = () => {
} }
const cpHandle = () => { const cpHandle = () => {
saveitemsort(dataList.value).then(() => {
getList();
})
} }
const firstHandle = () => { const firstHandle = () => {
currentIndex.value = 0; if (!selectedRow.value) return
tableRef.value.setCurrentRow(dataList.value[0]); const currentIndex = dataList.value.findIndex(item => item.xmid === selectedRow.value!.xmid)
if (currentIndex === 0) return
const [movedRow] = dataList.value.splice(currentIndex, 1)
dataList.value.unshift(movedRow)
resetSortNumber()
tableRef.value.setScrollTop(0) tableRef.value.setScrollTop(0)
} }
const lastHadnle = () => { const lastHadnle = () => {
currentIndex.value = dataList.value.length - 1; if (!selectedRow.value) return
tableRef.value.setCurrentRow(dataList.value[currentIndex.value]); const currentIndex = dataList.value.findIndex(item => item.xmid === selectedRow.value!.xmid)
if (currentIndex === dataList.value.length - 1) return
const [movedRow] = dataList.value.splice(currentIndex, 1)
dataList.value.push(movedRow)
resetSortNumber()
tableRef.value.setScrollTop(dataList.value.length) tableRef.value.setScrollTop(dataList.value.length)
} }
onMounted(() => { const resetSortNumber = () => {
for (let index = 0; index < 20; index++) { dataList.value.forEach((item, index) => {
dataList.value.push( item.dyxh = index + 1
{ xmid: 'ID' + index, xmmc: 'xmmc' + index, sort: '', } })
) }
}
})
watch(yq, (newVal) => {
getList();
}, { immediate: true })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.sort_box { .sort_box {
height: calc(100% - 58px); height: calc(100% - 56px);
padding-top: 8px;
} }
.table-toolbar { .table-toolbar {
flex: 1; margin-bottom: 8px;
display: flex; height: 36px;
flex-direction: column; line-height: 36px;
align-items: center;
.el-col {
width: 50%;
}
.el-button {
width: 80%;
margin-top: 20px;
}
} }
.table-row { .table-row {
height: 100%; width: 50%;
flex: 3; height: calc(100% - 45px);
.table-box { .table-box {
height: 100%; height: 100%;

View File

@ -112,7 +112,7 @@ const tabList = [
{ key: 'SysSort', label: '项目排序', component: SysSort }, { key: 'SysSort', label: '项目排序', component: SysSort },
{ key: 'SysReport', label: '报告单设置', component: SysReport }, { key: 'SysReport', label: '报告单设置', component: SysReport },
] ]
const activeName = ref('SysSort') const activeName = ref('SysChannel')
// 计算当前要渲染的组件 // 计算当前要渲染的组件
const currentComponent = computed(() => { const currentComponent = computed(() => {