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

98 lines
3.3 KiB
Vue
Raw Normal View History

2025-10-21 17:43:57 +08:00
<!-- 常用取值 -->
<template>
2025-12-05 17:44:21 +08:00
<div>
<div class="modifyClass">
<el-button type="primary" @click="bClickAdd">增加</el-button>
<el-button type="primary" @click="bClickDel">删除</el-button>
</div>
<CustomTable ref="tableRef" :data="modelParam.commonlyValuesData" :columns="columns" :enable-column-drag="true"
@column-drag-end="handleColumnDragEnd" :config="tableConfig" @row-click="handRowClick">
<template #qz="{ row }">
2025-12-08 17:49:43 +08:00
<el-select v-model="row.qz" clearable allow-create filterable default-first-option class="full-width-input">
2025-12-12 15:49:03 +08:00
<el-option v-for="item in dictData.VA" :key="item.value" :label="item.label" :value="item.value"></el-option>
2025-12-05 17:44:21 +08:00
</el-select>
</template>
<template #jgbz="{ row }">
2025-12-08 17:49:43 +08:00
<el-select v-model="row.jgbz" clearable class="full-width-input">
2025-12-12 15:49:03 +08:00
<el-option v-for="item in dictData.LF" :key="item.value" :label="item.label" :value="item.value"></el-option>
2025-12-05 17:44:21 +08:00
</el-select>
</template>
<template #srm="{ row }">
<el-input v-model="row.srm" class="full-width-input"></el-input>
</template>
</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-12-05 17:44:21 +08:00
import { dictData, getDictData } from '@/hooks';
2025-12-08 17:49:43 +08:00
import { ElMessage, ElMessageBox } from 'element-plus';
2025-12-05 17:44:21 +08:00
import { delXmValNewService } from '@/api/liswork/labItem/labItemApi'
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'])
2025-12-12 15:49:03 +08:00
watch(() => modelParam.value.commonlyValuesData, () => {
selectRow.value = null
})
2025-11-28 18:02:07 +08:00
const tableRef = ref<any>();
2025-10-28 16:22:44 +08:00
const columns = ref([
2025-12-08 17:49:43 +08:00
{ prop: 'qz', label: '取值', visible: true, align: 'center', slot: 'qz', showOverflowTooltip: false },
2025-12-10 18:02:35 +08:00
{ prop: 'srm', label: '快速输入码', visible: true, align: 'center', slot: 'srm', showOverflowTooltip: false },
2025-12-08 17:49:43 +08:00
{ prop: 'jgbz', label: '结果标志', visible: true, align: 'center', slot: 'jgbz', showOverflowTooltip: false }
2025-10-28 16:22:44 +08:00
]);
const tableConfig = ref({
border: true, // 边框
2025-12-08 17:49:43 +08:00
height: '78vh', // 高度
2025-10-28 16:22:44 +08:00
highlightCurrentRow: true, // 高亮当前行
// cellStyle: cellStyleHd
})
2025-11-14 09:09:33 +08:00
const selectRow = 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
//序号最大值
const maxXh = computed(() => {
2025-12-08 17:49:43 +08:00
return modelParam.value.commonlyValuesData.length > 0 ? modelParam.value.commonlyValuesData.length + 1 : 0;
2025-11-28 18:02:07 +08:00
});
2025-11-07 17:50:06 +08:00
const bClickAdd = () => {
2025-11-28 18:02:07 +08:00
const newData = {
2025-12-02 18:14:03 +08:00
xmid: modelParam.value.basicData.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: '',
2025-12-08 17:49:43 +08:00
xh: maxXh.value
2025-11-07 17:50:06 +08:00
}
2025-12-05 17:44:21 +08:00
modelParam.value.commonlyValuesData.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-12-08 17:49:43 +08:00
const bClickDel = () => {
if (!selectRow.value) return ElMessage.warning('请选择要删除的数据!');
ElMessageBox.confirm('是否要删除选中的数据?', '警告',
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(async () => {
//删掉界面上面的数据
//tableList.value = tableList.value?.filter((item:any) => item.xh != selectRow.value.xh );
await delXmValNewService({ xmid: modelParam.value.basicData.xmid, xh: selectRow.value.xh })
emit('refreshTabData', modelParam.value.basicData)
})
2025-12-05 17:44:21 +08:00
2025-11-07 17:50:06 +08:00
}
2025-12-05 17:44:21 +08:00
const handRowClick = (row: any) => {
2025-11-14 09:09:33 +08:00
selectRow.value = row
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>
2025-12-05 17:44:21 +08:00
<style lang="scss" scoped></style>