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

89 lines
2.7 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';
2025-12-12 18:02:04 +08:00
import { ElMessage, 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-12-12 18:02:04 +08:00
watch(() => modelParam.value.commonDescriptionsData, (val) => {
selectRow.value = null
})
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, // 边框
2025-12-08 17:49:43 +08:00
height: '78vh', // 高度
// highlightCurrentRow: true, // 高亮当前行
2025-10-28 16:22:44 +08:00
// 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-08 17:49:43 +08:00
return modelParam.value.commonDescriptionsData.length > 0 ? modelParam.value.commonDescriptionsData.length + 1 : 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-12-12 18:02:04 +08:00
xh: maxXh.value,
textresult: ''
2025-11-25 18:05:50 +08:00
}
2025-12-05 17:44:21 +08:00
modelParam.value.commonDescriptionsData.push(newData)
2025-11-25 18:05:50 +08:00
}
2025-12-12 18:02:04 +08:00
const onDelClick = () => {
if (!selectRow.value) return ElMessage.warning('请选择要删除的数据!');
ElMessageBox.confirm('是否要删除选中的数据?', '警告',
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', }).then(() => {
delXmTextresultNew({ xmid: modelParam.value.basicData.xmid, xh: selectRow.value.xh }).then((res: any) => {
if (res.code == 0) {
modelParam.value.commonDescriptionsData = modelParam.value.commonDescriptionsData.filter((item: any) => item.xh != selectRow.value.xh)
}
})
})
2025-11-25 18:05:50 +08:00
}
</script>
<style lang="scss" scoped>
:deep(.el-table .cell) {
padding: 0;
}
</style>