feat:触点添加校验

This commit is contained in:
du.meimei
2025-03-19 15:47:38 +08:00
parent 0d9458a31d
commit 3e019b4b57
3 changed files with 71 additions and 26 deletions

View File

@@ -52,3 +52,11 @@ export function updatePublishInfo(data) {
data
});
}
// 查询触点窗台
export function checkPublishNode(data) {
return request({
url: `console/question/publish/check`,
method: 'post',
data
});
}

View File

@@ -24,7 +24,8 @@
</div>
</a-form>
<a-table class="table" :dataSource="dataSource" :columns="columns"
:row-selection="rowSelection" :pagination="false" :scroll="{y:400}">
:row-selection="rowSelection"
:pagination="false" :scroll="{y:300}" :row-key="(record) => record.appId">
<template #contactPerson="{ record }">
<div>
{{ record.contactPerson }} ({{ record.contactPersonCode }})
@@ -35,10 +36,14 @@
</template>
<script setup>
import { ref, defineExpose, defineEmits, onMounted, defineProps } from 'vue';
import { getTeamSigns } from '@/api/accurate';
import { ref, defineExpose, defineEmits, onMounted, defineProps,computed,watch } from 'vue';
import { checkPublishNode, getTeamSigns } from '@/api/accurate';
import { useRoute } from 'vue-router';
import { message } from 'ant-design-vue';
const route = useRoute()
const props = defineProps({
channel: { type: [Object], default: {}}
channel: { type: [Object], default: {}},
selectAppId: { type: Array, default: []},
});
// 定义emit事件
const emit = defineEmits(['getData']);
@@ -54,6 +59,7 @@ const labelCol = ref({ span: 7 });
const wrapperCol = ref({ span: 16 });
const dataSource = ref([]);
const selectedData = ref([])
const selectedRowKeys = ref([])
const columns = ref([
{
title: '应用名称',
@@ -77,32 +83,51 @@ const columns = ref([
*/
const init = () => {
console.log('init');
dataSource.value = [];
visible.value = true;
selectedRowKeys.value = props.selectAppId;
getContactList();
};
const onSubmit = () => {
init()
};
const handleOk = () => {
// 获取选中的数据
const handleOk = async () => {
const { sn } = route.query;
const selectedRows = selectedData.value;
// 调用父组件的getData方法并传递数据
emit('getData', selectedRows);
if (selectedRows.length === 0){
message.error('请勾选触点')
return
}
let appId = [];
selectedData.value.forEach(item=>{
appId.push(item.appId)
})
let params = {
appId,
"publishSn": sn
}
let res = await checkPublishNode(params)
let data = {
appId,
selectedData:selectedData.value
}
emit('getData', data);
// 关闭弹窗
visible.value = false;
}
const rowSelection = {
onSelect: (record, selected, selectedRows) => {
console.log('record');
console.log(record);
console.log(selectedRows);
selectedData.value = selectedRows
console.log(record, selected, selectedRows);
},
};
// 配置 rowSelection
const rowSelection = computed(() => {
return {
selectedRowKeys: selectedRowKeys.value,
onChange: (selectedKeys,selectedRows) => {
selectedRowKeys.value = selectedKeys;
selectedData.value = selectedRows
},
getCheckboxProps: (record) => ({
disabled: false, // 可以在这里设置某些行不可选
}),
};
});
// 添加这行代码将init方法暴露出去
defineExpose({
init,
@@ -136,6 +161,11 @@ const getContactList = async () => {
onMounted(() => {
});
watch(props.selectAppId, (newVal) => {
console.log(newVal);
selectedRowKeys.value = newVal;
}, { immediate: true }
);
</script>
<style scoped lang="scss">
p {

View File

@@ -48,7 +48,12 @@
<span>取消</span>
</a-button>
</div>
<contact-add :channel="props.channel" ref="addContactRef" @getData="getNodeData"></contact-add>
<contact-add
:channel="props.channel"
:selectAppId="selectAppId"
ref="addContactRef"
@getData="getNodeData">
</contact-add>
</template>
<script setup>
@@ -57,7 +62,6 @@ import ContactAdd from '@/views/Publish/accurate/channel/ContactAdd.vue';
import { getPublishDetail,savePublish } from '@/api/accurate';
import { useRoute, useRouter } from 'vue-router';
import { message } from 'ant-design-vue';
const route = useRoute()
const router = useRouter()
@@ -116,7 +120,7 @@ const columns = ref([
key: 'action'
}
]);
const selectAppId = ref([]);
// 获取详情数据
const getDetail = async (id) => {
try {
@@ -127,6 +131,7 @@ const getDetail = async (id) => {
launchName: res.data.launchName,
launchMessage: res.data.launchMessage
};
selectAppId.value = res.data.appId;
}
} catch (error) {
console.error('获取详情失败:', error);
@@ -153,9 +158,10 @@ const addContact = () => {
addContactRef.value.init();
};
const getNodeData = (value) => {
console.log(value);
dataSource.value = value;
const getNodeData = (data) => {
console.log(data);
selectAppId.value = data.appId;
dataSource.value = data.selectedData;
};
const onSubmit = () => {
@@ -179,7 +185,7 @@ async function submitData() {
let params ={
...formState.value,
appId,
appId:selectAppId.value,
"publishSn": route.query.sn
}
await savePublish(params)
@@ -187,6 +193,7 @@ async function submitData() {
cancel()
}
function delClick(item){
selectAppId.value = selectAppId.value.filter(select => select !== item.appId);
dataSource.value = dataSource.value.filter(record => record.appId !== item.appId);
message.success('删除成功!');
}