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

84 lines
2.5 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="onAddClick">增加</el-button>
<el-button type="primary" @click="onDelClick">删除</el-button>
</div>
<CustomTable ref="tableRef" :data="modelParam.commonDescriptionsData" :columns="columns" :enable-column-drag="true"
@column-drag-end="handleColumnDragEnd" :config="tableConfig" @row-click="rowClick">
<template #textresult="{ row }">
<el-input type="textarea" v-model="row.textresult" class="full-width-input" autosize></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-11-25 18:05:50 +08:00
import { XmTextresultNew } from '@/types';
import { ElMessageBox } from 'element-plus';
2025-10-28 16:22:44 +08:00
import { ref } from 'vue';
2025-12-02 18:14:03 +08:00
import { delXmTextresultNew } from '@/api/liswork/labItem/labItemApi';
2025-10-24 15:37:24 +08:00
2025-12-02 18:14:03 +08:00
const modelParam = defineModel<any>()
2025-10-28 16:22:44 +08:00
2025-11-25 18:05:50 +08:00
const tableRef = ref();
2025-10-28 16:22:44 +08:00
const columns = ref([
2025-12-05 17:44:21 +08:00
{ prop: 'textresult', label: '文字描述', visible: true, align: 'center', slot: 'textresult', width: 500, showOverflowTooltip: false },
2025-10-28 16:22:44 +08:00
]);
const tableConfig = ref({
border: true, // 边框
height: '80vh', // 高度
highlightCurrentRow: true, // 高亮当前行
// cellStyle: cellStyleHd
})
//退拽属性
const handleColumnDragEnd = (data: any) => {
// 更新列配置
columns.value = data.columns;
}
2025-11-25 18:05:50 +08:00
const selectRow = ref()
2025-12-02 18:14:03 +08:00
const emit = defineEmits(['refreshTabData'])
2025-11-25 18:05:50 +08:00
//序号最大值
const maxXh = computed(() => {
2025-12-05 17:44:21 +08:00
return modelParam.value.commonDescriptionsData.length > 0 ? Math.max(...modelParam.value.commonDescriptionsData.map((item: any) => item.xh || 0)) : 0;
2025-11-25 18:05:50 +08:00
});
2025-12-05 17:44:21 +08:00
const rowClick = (row: any) => {
2025-11-25 18:05:50 +08:00
selectRow.value = row
}
const onAddClick = () => {
const newData: XmTextresultNew = {
2025-12-02 18:14:03 +08:00
xmid: modelParam.value.basicData.xmid,
xmdh: modelParam.value.basicData.xmdh,
2025-11-25 18:05:50 +08:00
xh: maxXh.value + 1
}
2025-12-05 17:44:21 +08:00
modelParam.value.commonDescriptionsData.push(newData)
2025-11-25 18:05:50 +08:00
}
2025-12-05 17:44:21 +08:00
const onDelClick = async () => {
if (selectRow.value) {
await ElMessageBox.confirm('是否要删除选中的数据?', '警告',
{ confirmButtonText: 'OK', cancelButtonText: 'Cancel', type: 'warning', });
2025-12-02 18:14:03 +08:00
//tableList.value = tableList.value.filter((item:any) => item.xh != selectRow.value.xh)
2025-12-05 17:44:21 +08:00
await delXmTextresultNew({ xmid: modelParam.value.basicData.xmid, xh: selectRow.value.xh })
emit('refreshTabData', modelParam.value.basicData)
2025-11-25 18:05:50 +08:00
}
}
</script>
<style lang="scss" scoped>
:deep(.el-table .cell) {
padding: 0;
}
</style>