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>
|
|
|
|
|
<CustomTable ref="tableRef" :data="dataList" :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-07 17:50:06 +08:00
|
|
|
<template #qz>
|
|
|
|
|
<el-select v-model="selectValue" clearable>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in options"
|
|
|
|
|
:key="item.value"
|
|
|
|
|
:label="item.label"
|
|
|
|
|
:value="item.value"
|
|
|
|
|
></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</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-07 17:50:06 +08:00
|
|
|
import { dictData,getDictData } from '@/hooks';
|
|
|
|
|
import { XmValNew } from '@/types';
|
2025-11-14 09:09:33 +08:00
|
|
|
import { ElMessageBox } from 'element-plus';
|
2025-10-21 17:43:57 +08:00
|
|
|
|
|
|
|
|
const props = defineProps({
|
2025-11-14 09:09:33 +08:00
|
|
|
dataList: {
|
|
|
|
|
type: Object,
|
|
|
|
|
default: []
|
|
|
|
|
},
|
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
|
|
|
|
|
|
|
|
const tableRef = ref<any>(null);
|
2025-11-14 09:09:33 +08:00
|
|
|
const dataList = ref<Array<XmValNew>>();
|
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-10-28 16:22:44 +08:00
|
|
|
{ prop: 'srm', label: '快速输入码', visible: true, align: 'center', width: 100 },
|
|
|
|
|
{ prop: 'jgbz', label: '结果标志', visible: true, align: 'center', width: 100 }
|
|
|
|
|
]);
|
|
|
|
|
const tableConfig = ref({
|
|
|
|
|
border: true, // 边框
|
|
|
|
|
height: '80vh', // 高度
|
|
|
|
|
highlightCurrentRow: true, // 高亮当前行
|
|
|
|
|
// cellStyle: cellStyleHd
|
|
|
|
|
})
|
2025-11-07 17:50:06 +08:00
|
|
|
const options = ref()
|
|
|
|
|
const selectValue = ref()
|
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-07 17:50:06 +08:00
|
|
|
const init = () => {
|
|
|
|
|
options.value = {...dictData.value}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bClickAdd = () => {
|
|
|
|
|
const newData: XmValNew = {
|
|
|
|
|
xmid: props.formData.xmid,
|
2025-11-14 09:09:33 +08:00
|
|
|
qz: '',
|
|
|
|
|
srm: '',
|
|
|
|
|
jgbz: ''
|
2025-11-07 17:50:06 +08:00
|
|
|
}
|
2025-11-14 09:09:33 +08:00
|
|
|
console.log('@@新增行:',newData);
|
|
|
|
|
dataList.value?.push(newData);
|
|
|
|
|
}
|
2025-11-07 17:50:06 +08:00
|
|
|
|
2025-11-14 09:09:33 +08:00
|
|
|
const bClickDel = async () => {
|
|
|
|
|
await ElMessageBox.confirm('是否要删除选中的数据?','Warning',
|
|
|
|
|
{
|
|
|
|
|
confirmButtonText: 'OK',
|
|
|
|
|
cancelButtonText: 'Cancel',
|
|
|
|
|
type: 'warning',
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
//删掉界面上面的数据
|
|
|
|
|
dataList.value = dataList.value?.filter(item => item.xh != selectRow.value.xh );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(()=>{
|
|
|
|
|
//默认取值
|
|
|
|
|
getDictData('VA')
|
|
|
|
|
init()
|
2025-11-14 09:09:33 +08:00
|
|
|
console.log('常用取值:',props.formData);
|
2025-11-07 17:50:06 +08:00
|
|
|
})
|
2025-10-28 16:22:44 +08:00
|
|
|
|
|
|
|
|
|
2025-10-21 17:43:57 +08:00
|
|
|
</script>
|