feat:触点添加校验
This commit is contained in:
@@ -52,3 +52,11 @@ export function updatePublishInfo(data) {
|
|||||||
data
|
data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 查询触点窗台
|
||||||
|
export function checkPublishNode(data) {
|
||||||
|
return request({
|
||||||
|
url: `console/question/publish/check`,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</a-form>
|
</a-form>
|
||||||
<a-table class="table" :dataSource="dataSource" :columns="columns"
|
<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 }">
|
<template #contactPerson="{ record }">
|
||||||
<div>
|
<div>
|
||||||
{{ record.contactPerson }} ({{ record.contactPersonCode }})
|
{{ record.contactPerson }} ({{ record.contactPersonCode }})
|
||||||
@@ -35,10 +36,14 @@
|
|||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, defineExpose, defineEmits, onMounted, defineProps } from 'vue';
|
import { ref, defineExpose, defineEmits, onMounted, defineProps,computed,watch } from 'vue';
|
||||||
import { getTeamSigns } from '@/api/accurate';
|
import { checkPublishNode, getTeamSigns } from '@/api/accurate';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
const route = useRoute()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
channel: { type: [Object], default: {}}
|
channel: { type: [Object], default: {}},
|
||||||
|
selectAppId: { type: Array, default: []},
|
||||||
});
|
});
|
||||||
// 定义emit事件
|
// 定义emit事件
|
||||||
const emit = defineEmits(['getData']);
|
const emit = defineEmits(['getData']);
|
||||||
@@ -54,6 +59,7 @@ const labelCol = ref({ span: 7 });
|
|||||||
const wrapperCol = ref({ span: 16 });
|
const wrapperCol = ref({ span: 16 });
|
||||||
const dataSource = ref([]);
|
const dataSource = ref([]);
|
||||||
const selectedData = ref([])
|
const selectedData = ref([])
|
||||||
|
const selectedRowKeys = ref([])
|
||||||
const columns = ref([
|
const columns = ref([
|
||||||
{
|
{
|
||||||
title: '应用名称',
|
title: '应用名称',
|
||||||
@@ -77,32 +83,51 @@ const columns = ref([
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const init = () => {
|
const init = () => {
|
||||||
console.log('init');
|
|
||||||
dataSource.value = [];
|
dataSource.value = [];
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
|
selectedRowKeys.value = props.selectAppId;
|
||||||
getContactList();
|
getContactList();
|
||||||
};
|
};
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
init()
|
init()
|
||||||
};
|
};
|
||||||
const handleOk = () => {
|
const handleOk = async () => {
|
||||||
// 获取选中的数据
|
const { sn } = route.query;
|
||||||
const selectedRows = selectedData.value;
|
const selectedRows = selectedData.value;
|
||||||
// 调用父组件的getData方法并传递数据
|
if (selectedRows.length === 0){
|
||||||
emit('getData', selectedRows);
|
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;
|
visible.value = false;
|
||||||
}
|
}
|
||||||
|
// 配置 rowSelection
|
||||||
const rowSelection = {
|
const rowSelection = computed(() => {
|
||||||
onSelect: (record, selected, selectedRows) => {
|
return {
|
||||||
console.log('record');
|
selectedRowKeys: selectedRowKeys.value,
|
||||||
console.log(record);
|
onChange: (selectedKeys,selectedRows) => {
|
||||||
console.log(selectedRows);
|
selectedRowKeys.value = selectedKeys;
|
||||||
selectedData.value = selectedRows
|
selectedData.value = selectedRows
|
||||||
console.log(record, selected, selectedRows);
|
},
|
||||||
},
|
getCheckboxProps: (record) => ({
|
||||||
};
|
disabled: false, // 可以在这里设置某些行不可选
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
});
|
||||||
// 添加这行代码,将init方法暴露出去
|
// 添加这行代码,将init方法暴露出去
|
||||||
defineExpose({
|
defineExpose({
|
||||||
init,
|
init,
|
||||||
@@ -136,6 +161,11 @@ const getContactList = async () => {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
watch(props.selectAppId, (newVal) => {
|
||||||
|
console.log(newVal);
|
||||||
|
selectedRowKeys.value = newVal;
|
||||||
|
}, { immediate: true }
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
p {
|
p {
|
||||||
|
|||||||
@@ -48,7 +48,12 @@
|
|||||||
<span>取消</span>
|
<span>取消</span>
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -57,7 +62,6 @@ import ContactAdd from '@/views/Publish/accurate/channel/ContactAdd.vue';
|
|||||||
import { getPublishDetail,savePublish } from '@/api/accurate';
|
import { getPublishDetail,savePublish } from '@/api/accurate';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
@@ -116,7 +120,7 @@ const columns = ref([
|
|||||||
key: 'action'
|
key: 'action'
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
const selectAppId = ref([]);
|
||||||
// 获取详情数据
|
// 获取详情数据
|
||||||
const getDetail = async (id) => {
|
const getDetail = async (id) => {
|
||||||
try {
|
try {
|
||||||
@@ -127,6 +131,7 @@ const getDetail = async (id) => {
|
|||||||
launchName: res.data.launchName,
|
launchName: res.data.launchName,
|
||||||
launchMessage: res.data.launchMessage
|
launchMessage: res.data.launchMessage
|
||||||
};
|
};
|
||||||
|
selectAppId.value = res.data.appId;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取详情失败:', error);
|
console.error('获取详情失败:', error);
|
||||||
@@ -153,9 +158,10 @@ const addContact = () => {
|
|||||||
addContactRef.value.init();
|
addContactRef.value.init();
|
||||||
};
|
};
|
||||||
|
|
||||||
const getNodeData = (value) => {
|
const getNodeData = (data) => {
|
||||||
console.log(value);
|
console.log(data);
|
||||||
dataSource.value = value;
|
selectAppId.value = data.appId;
|
||||||
|
dataSource.value = data.selectedData;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
@@ -179,7 +185,7 @@ async function submitData() {
|
|||||||
|
|
||||||
let params ={
|
let params ={
|
||||||
...formState.value,
|
...formState.value,
|
||||||
appId,
|
appId:selectAppId.value,
|
||||||
"publishSn": route.query.sn
|
"publishSn": route.query.sn
|
||||||
}
|
}
|
||||||
await savePublish(params)
|
await savePublish(params)
|
||||||
@@ -187,6 +193,7 @@ async function submitData() {
|
|||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
function delClick(item){
|
function delClick(item){
|
||||||
|
selectAppId.value = selectAppId.value.filter(select => select !== item.appId);
|
||||||
dataSource.value = dataSource.value.filter(record => record.appId !== item.appId);
|
dataSource.value = dataSource.value.filter(record => record.appId !== item.appId);
|
||||||
message.success('删除成功!');
|
message.success('删除成功!');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user