lis8.0-vue3/src/views/liswork/labItem/tab/CommonlyValues.vue

121 lines
3.4 KiB
Vue
Raw Normal View History

2025-10-21 17:43:57 +08:00
<!-- 常用取值 -->
<template>
2025-11-04 17:54:29 +08:00
<div>
2025-10-28 16:22:44 +08:00
<div class="modifyClass">
2025-11-07 17:50:06 +08:00
<el-button type="primary" @click="bClickAdd">增加</el-button>
<el-button type="primary" @click="bClickDel">删除</el-button>
2025-10-28 16:22:44 +08:00
</div>
2025-11-28 18:02:07 +08:00
<CustomTable ref="tableRef" :data="tableList" :columns="columns" :enable-column-drag="true" @column-drag-end="handleColumnDragEnd"
2025-11-14 09:09:33 +08:00
:config="tableConfig" @row-click="handRowClick">
2025-11-17 17:42:09 +08:00
<template #qz = {row}>
<el-select v-model="row.qz" clearable allow-create filterable default-first-option>
2025-11-17 09:35:56 +08:00
<el-option v-for="item in qzOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
2025-11-07 17:50:06 +08:00
</el-select>
2025-11-17 09:35:56 +08:00
</template>
2025-11-17 17:42:09 +08:00
<template #jgbz = {row}>
<el-select v-model="row.jgbz" clearable>
2025-11-17 09:35:56 +08:00
<el-option v-for="item in jgbzOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
</template>
2025-11-17 17:42:09 +08:00
<template #srm = {row}>
<el-input v-model="row.srm" class="full-width-input"></el-input>
2025-11-17 09:35:56 +08:00
</template>
2025-11-07 17:50:06 +08:00
</CustomTable>
2025-10-28 16:22:44 +08:00
</div>
2025-10-21 17:43:57 +08:00
</template>
2025-10-24 15:37:24 +08:00
<script setup lang="ts">
2025-10-28 16:22:44 +08:00
import CustomTable from '@/components/elTable/index.vue'
2025-11-07 17:50:06 +08:00
import { dictData,getDictData } from '@/hooks';
2025-11-14 09:09:33 +08:00
import { ElMessageBox } from 'element-plus';
2025-11-28 18:02:07 +08:00
import {delXmValNewService} from '@/api/liswork/labItem/labItemApi'
2025-10-21 17:43:57 +08:00
const props = defineProps({
2025-11-07 17:50:06 +08:00
formData: {
type: Object,
default: {}
}
2025-10-21 17:43:57 +08:00
});
2025-10-28 16:22:44 +08:00
2025-11-28 18:02:07 +08:00
const modelParam = defineModel<any>()
const emit = defineEmits(['refreshTabData'])
const tableRef = ref<any>();
const tableList = ref<any>();
2025-10-28 16:22:44 +08:00
const columns = ref([
2025-11-07 17:50:06 +08:00
{ prop: 'qz', label: '取值', visible: true, align: 'center', slot:'qz', width: 200 },
2025-11-17 09:35:56 +08:00
{ prop: 'srm', label: '快速输入码', visible: true, align: 'center',slot: 'srm', width: 100 },
{ prop: 'jgbz', label: '结果标志', visible: true, align: 'center', slot: 'jgbz', width: 100 }
2025-10-28 16:22:44 +08:00
]);
const tableConfig = ref({
border: true, // 边框
height: '80vh', // 高度
highlightCurrentRow: true, // 高亮当前行
// cellStyle: cellStyleHd
})
2025-11-17 09:35:56 +08:00
const qzOptions = ref()
2025-11-14 09:09:33 +08:00
const selectRow = ref()
2025-11-17 09:35:56 +08:00
const jgbzOptions = ref()
2025-10-28 16:22:44 +08:00
//退拽属性
const handleColumnDragEnd = (data: any) => {
// 更新列配置
columns.value = data.columns;
}
2025-11-28 18:02:07 +08:00
watch(
() => modelParam.value,
(newVal:any) => {
tableList.value = [...newVal.commonlyValuesData];
},
{ immediate: true, deep: true }
);
//序号最大值
const maxXh = computed(() => {
return tableList.value.length > 0 ? Math.max(...tableList.value.map((item:any) => item.xh || 0)) : 0;
});
2025-11-07 17:50:06 +08:00
const bClickAdd = () => {
2025-11-28 18:02:07 +08:00
const newData = {
2025-11-07 17:50:06 +08:00
xmid: props.formData.xmid,
2025-11-17 17:42:09 +08:00
qz: '',
2025-11-14 09:09:33 +08:00
srm: '',
2025-11-28 18:02:07 +08:00
jgbz: '',
xh: maxXh.value + 1
2025-11-07 17:50:06 +08:00
}
2025-11-28 18:02:07 +08:00
tableList.value.push(newData);
2025-11-17 09:35:56 +08:00
2025-11-14 09:09:33 +08:00
}
2025-11-07 17:50:06 +08:00
2025-11-14 09:09:33 +08:00
const bClickDel = async () => {
2025-11-28 18:02:07 +08:00
if(selectRow.value){
await ElMessageBox.confirm('是否要删除选中的数据?','警告',
{confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'});
2025-11-14 09:09:33 +08:00
//删掉界面上面的数据
2025-11-28 18:02:07 +08:00
//tableList.value = tableList.value?.filter((item:any) => item.xh != selectRow.value.xh );
await delXmValNewService({xmid:props.formData.xmid,xh:selectRow.value.xh})
emit('refreshTabData',props.formData)
}
2025-11-07 17:50:06 +08:00
}
2025-11-14 09:09:33 +08:00
const handRowClick = (row:any) => {
selectRow.value = row
2025-11-07 17:50:06 +08:00
}
2025-11-17 09:35:56 +08:00
onActivated(async ()=>{
2025-11-07 17:50:06 +08:00
//默认取值
2025-11-17 09:35:56 +08:00
await getDictData('VA','LF')
qzOptions.value = dictData.value.VA
jgbzOptions.value = dictData.value.LF
2025-11-28 18:02:07 +08:00
tableList.value = modelParam.value.commonlyValuesData || []
2025-11-07 17:50:06 +08:00
})
2025-10-28 16:22:44 +08:00
2025-11-28 18:02:07 +08:00
</script>
<style lang="scss" scoped>
</style>