通道号、项目排序
This commit is contained in:
parent
9e5365c96f
commit
182d43fd84
@ -106,4 +106,44 @@ export function querySjcs(data?: Object) {
|
||||
method: 'get',
|
||||
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
|
||||
});
|
||||
}
|
||||
@ -18,18 +18,15 @@
|
||||
|
||||
<el-row :gutter="10" class="table-row">
|
||||
<el-col :span="12" class="table-box">
|
||||
<el-table :data="tableData" height="100%" border highlight-current-row>
|
||||
<el-table-column label="通道号" align="center">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.channel" placeholder="请输入通道号" class="full-width-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="项目" align="center">
|
||||
<template #default="scope">
|
||||
<SelectTable v-model:data="scope.row.xmid" :tableData="xmList" class="full-width-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<CustomTable ref="tableRef" :data="tableData" :columns="columns" :config="tableConfig"
|
||||
@row-click="handleRowClick">
|
||||
<template #tdh="{ row }">
|
||||
<el-input v-model="row.tdh" placeholder="请输入通道号" class="full-width-input" />
|
||||
</template>
|
||||
<template #xmmc="{ row }">
|
||||
<SelectTable v-model:data="row.xmdh" :tableData="xmList" class="full-width-input" />
|
||||
</template>
|
||||
</CustomTable>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<div class="tips">
|
||||
@ -44,37 +41,93 @@
|
||||
</template>
|
||||
|
||||
<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 tableData = ref<Array<{ channel: string }>>([]);
|
||||
const tableRef = ref();
|
||||
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 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 = () => {
|
||||
tableData.value.push({ channel: '' })
|
||||
tableData.value.push({ tdh: '', xmdh: '' })
|
||||
nextTick(() => {
|
||||
tableRef.value.setScrollTop(tableData.value.length)
|
||||
})
|
||||
};
|
||||
|
||||
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 xmList = ref<Array<{ xmmc: string, xmid: string }>>([]);
|
||||
const xmList = ref<Array<{ xmmc: string, xmdh: string }>>([]);
|
||||
const getXmList = () => {
|
||||
queryXmInfoNewService({ yq: yq.value }).then((res: any) => {
|
||||
xmList.value = res.rows.map((item: any) => {
|
||||
queryXmInfo({ yq: yq.value }).then((res: any) => {
|
||||
xmList.value = res.data.map((item: any) => {
|
||||
return {
|
||||
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) {
|
||||
getXmList();
|
||||
getChannel();
|
||||
}
|
||||
}, { immediate: true });
|
||||
</script>
|
||||
|
||||
@ -1,44 +1,28 @@
|
||||
<template>
|
||||
<!-- 整体排序 -->
|
||||
<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-row :gutter="10" class="table-toolbar">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" @click="refresh">刷新</el-button>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<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-button type="primary" @click="refresh">刷新</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" @click="cpHandle">存盘</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" :disabled="radio == '2'" @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 :span="1.5">
|
||||
<el-button type="primary" icon="bottom" :disabled="radio == '2'" @click="nextHandle">下移</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 :span="1.5">
|
||||
<el-button type="primary" @click="cpHandle">存盘</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" @click="firstHandle">首位</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" @click="lastHadnle">末位</el-button>
|
||||
</el-col>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
@ -46,28 +30,21 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { formatDict, dictData } from '@/hooks';
|
||||
import { getitemsort, saveitemsort } from '@/api/liswork/xtwh/ComOpt';
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
dataList: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
});
|
||||
|
||||
const yq = defineModel<string>()
|
||||
interface DataItem {
|
||||
xmid: string | number;
|
||||
xmmc: string | number;
|
||||
sort: string | number;
|
||||
dyxh: string | number;
|
||||
}
|
||||
const currentIndex = ref(0);
|
||||
const radio = ref('1');
|
||||
const selectedRow = ref<DataItem | null>(null)
|
||||
const tableRef = ref();
|
||||
const dataList = ref<DataItem[]>([]);
|
||||
const columns = ref([
|
||||
{ prop: 'xmid', label: '项目ID', visible: true, align: 'center', },
|
||||
{ prop: 'xmmc', label: '项目名称', visible: true, align: 'center', },
|
||||
{ prop: 'sort', label: '整体排序', visible: true, align: 'center', slot: "sort" },
|
||||
{ prop: 'xmid', label: '项目ID', visible: true, align: 'center' },
|
||||
{ prop: 'xmmc', label: '项目名称', visible: true, align: 'center' },
|
||||
{ prop: 'dyxh', label: '排序', visible: true, align: 'center', slot: "dyxh" },
|
||||
]);
|
||||
const tableConfig = ref({
|
||||
border: true, // 边框
|
||||
@ -78,19 +55,26 @@ const tableConfig = ref({
|
||||
|
||||
|
||||
//退拽属性
|
||||
const handleColumnDragEnd = (data: any) => {
|
||||
// 更新列配置
|
||||
dataList.value = data.list;
|
||||
const handleRowDragEnd = (data: any) => {
|
||||
// 更新行顺序
|
||||
dataList.value = data.list.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
dyxh: item.sort,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const handleRowClick = (row: DataItem) => {
|
||||
currentIndex.value = dataList.value.indexOf(row);
|
||||
selectedRow.value = row
|
||||
}
|
||||
|
||||
|
||||
|
||||
const getList = () => {
|
||||
|
||||
getitemsort({ yq: yq.value }).then((res: any) => {
|
||||
dataList.value = res.data;
|
||||
})
|
||||
}
|
||||
|
||||
const refresh = () => {
|
||||
@ -98,56 +82,59 @@ const refresh = () => {
|
||||
}
|
||||
|
||||
const cpHandle = () => {
|
||||
|
||||
saveitemsort(dataList.value).then(() => {
|
||||
getList();
|
||||
})
|
||||
}
|
||||
const firstHandle = () => {
|
||||
currentIndex.value = 0;
|
||||
tableRef.value.setCurrentRow(dataList.value[0]);
|
||||
if (!selectedRow.value) return
|
||||
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)
|
||||
}
|
||||
|
||||
const lastHadnle = () => {
|
||||
currentIndex.value = dataList.value.length - 1;
|
||||
tableRef.value.setCurrentRow(dataList.value[currentIndex.value]);
|
||||
if (!selectedRow.value) return
|
||||
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)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
for (let index = 0; index < 20; index++) {
|
||||
dataList.value.push(
|
||||
{ xmid: 'ID' + index, xmmc: 'xmmc' + index, sort: '', }
|
||||
)
|
||||
}
|
||||
})
|
||||
const resetSortNumber = () => {
|
||||
dataList.value.forEach((item, index) => {
|
||||
item.dyxh = index + 1
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
watch(yq, (newVal) => {
|
||||
getList();
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.sort_box {
|
||||
height: calc(100% - 58px);
|
||||
padding-top: 8px;
|
||||
height: calc(100% - 56px);
|
||||
}
|
||||
|
||||
.table-toolbar {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.el-col {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.el-button {
|
||||
width: 80%;
|
||||
margin-top: 20px;
|
||||
}
|
||||
margin-bottom: 8px;
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.table-row {
|
||||
height: 100%;
|
||||
flex: 3;
|
||||
width: 50%;
|
||||
height: calc(100% - 45px);
|
||||
|
||||
|
||||
.table-box {
|
||||
height: 100%;
|
||||
|
||||
@ -112,7 +112,7 @@ const tabList = [
|
||||
{ key: 'SysSort', label: '项目排序', component: SysSort },
|
||||
{ key: 'SysReport', label: '报告单设置', component: SysReport },
|
||||
]
|
||||
const activeName = ref('SysSort')
|
||||
const activeName = ref('SysChannel')
|
||||
|
||||
// 计算当前要渲染的组件
|
||||
const currentComponent = computed(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user