程控源调整
This commit is contained in:
@@ -158,18 +158,20 @@
|
||||
type="primary"
|
||||
size="large"
|
||||
@click="startLoading"
|
||||
:disabled="pauseDisabled"
|
||||
:loading="isStarting"
|
||||
:disabled="props.startDisabeld || isStarting || isStopping"
|
||||
>
|
||||
启动
|
||||
{{ isStarting ? '启动中' : '启动' }}
|
||||
</el-button>
|
||||
<el-button
|
||||
:icon="VideoPause"
|
||||
type="primary"
|
||||
type="danger"
|
||||
size="large"
|
||||
@click="stopLoading"
|
||||
:disabled="pauseDisabled"
|
||||
:loading="isStopping"
|
||||
:disabled="props.pauseDisabled || isStarting || isStopping"
|
||||
>
|
||||
停止
|
||||
{{ isStopping ? '停止中' : '停止' }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -269,6 +271,10 @@ const tableData: any = ref([])
|
||||
const tabData: any = ref([])
|
||||
|
||||
const showLoading = ref(false)
|
||||
const isStarting = ref(false)
|
||||
const isStopping = ref(false)
|
||||
const selectedScriptName = ref('')
|
||||
const pendingScriptName = ref('')
|
||||
const column = ref([
|
||||
{
|
||||
label: 'L1',
|
||||
@@ -291,7 +297,13 @@ const hour = ref(0)
|
||||
const minute = ref(0)
|
||||
const second = ref(0)
|
||||
|
||||
const emit = defineEmits(['update:activeName', 'update:activeIndex', 'update:startDisabeld', 'update:pauseDisabled'])
|
||||
const emit = defineEmits([
|
||||
'update:activeName',
|
||||
'update:activeIndex',
|
||||
'update:startDisabeld',
|
||||
'update:pauseDisabled',
|
||||
'update:runningScriptName'
|
||||
])
|
||||
|
||||
watch(
|
||||
() => props.formControl.scriptId,
|
||||
@@ -305,6 +317,16 @@ watch(
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.startDisabeld,
|
||||
value => {
|
||||
if (!value) {
|
||||
isStarting.value = false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const controlContent = ref<controlSource.ResControl>({
|
||||
userPageId: '',
|
||||
scriptId: '',
|
||||
@@ -376,6 +398,7 @@ const setTab = row => {
|
||||
activeName.value = row.activeName
|
||||
childActiveName.value = row.childActiveName
|
||||
childActiveIndex.value = row.activeIndex
|
||||
selectedScriptName.value = row.scriptName || ''
|
||||
getTree()
|
||||
emit('update:activeName', activeName.value) // 触发事件并传递 activeName.value
|
||||
emit('update:activeIndex', row.activeIndex) // 触发事件并传递 activeName.value
|
||||
@@ -450,6 +473,12 @@ const view = (row: Partial<TestScript.ResTestScript> = {}) => {
|
||||
|
||||
// 定义 startLoading 方法
|
||||
const startLoading = async () => {
|
||||
if (props.startDisabeld || isStarting.value || isStopping.value) {
|
||||
return
|
||||
}
|
||||
|
||||
isStarting.value = true
|
||||
pendingScriptName.value = selectedScriptName.value
|
||||
emit('update:startDisabeld', true)
|
||||
emit('update:pauseDisabled', true)
|
||||
ElMessage.success({ message: '启动中...', duration: 6000 })
|
||||
@@ -458,25 +487,49 @@ const startLoading = async () => {
|
||||
controlContent.value.scriptId = props.formControl.scriptId
|
||||
controlContent.value.scriptIndex = childActiveIndex.value
|
||||
controlContent.value.sourceId = props.formControl.sourceId
|
||||
setTimeout(async () => {
|
||||
|
||||
try {
|
||||
await new Promise(resolve => setTimeout(resolve, 3000))
|
||||
await startSimulateTest(controlContent.value)
|
||||
}, 3000)
|
||||
} catch (error) {
|
||||
isStarting.value = false
|
||||
pendingScriptName.value = ''
|
||||
emit('update:startDisabeld', false)
|
||||
emit('update:pauseDisabled', true)
|
||||
ElMessage.error('启动失败!')
|
||||
}
|
||||
}
|
||||
|
||||
// 定义 startLoading 方法
|
||||
const stopLoading = async () => {
|
||||
if (props.pauseDisabled || isStarting.value || isStopping.value) {
|
||||
return
|
||||
}
|
||||
|
||||
isStopping.value = true
|
||||
// 启动加载逻辑
|
||||
controlContent.value.userPageId = JwtUtil.getLoginName()
|
||||
controlContent.value.scriptId = props.formControl.scriptId
|
||||
controlContent.value.scriptIndex = childActiveIndex.value
|
||||
controlContent.value.sourceId = props.formControl.sourceId
|
||||
|
||||
try {
|
||||
await closeSimulateTest(controlContent.value)
|
||||
emit('update:pauseDisabled', true)
|
||||
emit('update:startDisabeld', true)
|
||||
ElMessage.success({ message: '停止中...', duration: 5000 })
|
||||
} catch (error) {
|
||||
isStopping.value = false
|
||||
emit('update:pauseDisabled', false)
|
||||
emit('update:startDisabeld', false)
|
||||
ElMessage.error('停止失败!')
|
||||
}
|
||||
}
|
||||
|
||||
const startTimeCount = () => {
|
||||
isStarting.value = false
|
||||
emit('update:runningScriptName', pendingScriptName.value || selectedScriptName.value)
|
||||
pendingScriptName.value = ''
|
||||
// Loading效果展示
|
||||
showLoading.value = true
|
||||
|
||||
@@ -500,6 +553,8 @@ const secondToTime = (secd: number) => {
|
||||
}
|
||||
|
||||
const stopTimeCount = () => {
|
||||
isStopping.value = false
|
||||
emit('update:runningScriptName', '')
|
||||
if (timer) {
|
||||
clearInterval(timer)
|
||||
timer = null
|
||||
|
||||
@@ -60,7 +60,8 @@ const handleNodeClick = (data, node) => {
|
||||
emit('setTab', {
|
||||
activeName: active,
|
||||
childActiveName: childActive,
|
||||
activeIndex:data.index
|
||||
activeIndex:data.index,
|
||||
scriptName: data.sourceDesc || data.scriptTypeName || ''
|
||||
})
|
||||
}
|
||||
|
||||
@@ -112,7 +113,8 @@ function handleCheckChange(data,isChecked) {
|
||||
emit('setTab', {
|
||||
activeName: data.scriptType,
|
||||
childActiveName: data.scriptTypeCode,
|
||||
activeIndex:data.index
|
||||
activeIndex:data.index,
|
||||
scriptName: data.sourceDesc || data.scriptTypeName || ''
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +53,12 @@
|
||||
|
||||
<el-card v-if="show" style="margin-bottom: 10px">
|
||||
<div class="connection-status-row">
|
||||
<div class="connection-status-left">
|
||||
<span class="connection-status-dot" :class="`is-${connectionState.status}`"></span>
|
||||
<span>{{ connectionStatusText }}</span>
|
||||
<span class="connection-status-text">{{ connectionStatusText }}</span>
|
||||
</div>
|
||||
<el-divider direction="vertical" />
|
||||
<div class="running-script-status" :title="runningScriptStatusText">{{ runningScriptStatusText }}</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
@@ -71,6 +75,7 @@
|
||||
@update:startDisabeld="startDisabeld = $event"
|
||||
v-model:pauseDisabled="pauseDisabled"
|
||||
@update:pauseDisabled="pauseDisabled = $event"
|
||||
@update:runningScriptName="runningScriptName = $event"
|
||||
/>
|
||||
</el-card>
|
||||
</div>
|
||||
@@ -128,6 +133,7 @@ const formContent = ref<TestScript.ResTestScript>({
|
||||
const connectionState = ref(createDisconnectedState());
|
||||
const startDisabeld = ref(true);
|
||||
const pauseDisabled = ref(true);
|
||||
const runningScriptName = ref("");
|
||||
const controlSourceDetailRef = ref<InstanceType<typeof ControlSourceDetail>>();
|
||||
|
||||
const controlContent = ref<controlSource.ResControl>({
|
||||
@@ -171,6 +177,9 @@ const closeSocket = () => {
|
||||
const isSourceSwitchEnabled = computed(() => isSourceSelectable(connectionState.value));
|
||||
const isConnectButtonEnabled = computed(() => canConnect(connectionState.value));
|
||||
const connectionStatusText = computed(() => getConnectionStatusText(connectionState.value));
|
||||
const runningScriptStatusText = computed(() =>
|
||||
runningScriptName.value ? `当前正在加量的脚本:${runningScriptName.value}` : "当前无正在加量脚本"
|
||||
);
|
||||
const connectionStatusColor = computed(() => {
|
||||
switch (connectionState.value.status) {
|
||||
case "connecting":
|
||||
@@ -363,6 +372,7 @@ watch(
|
||||
resetConnectionState();
|
||||
startDisabeld.value = true;
|
||||
pauseDisabled.value = true;
|
||||
runningScriptName.value = "";
|
||||
controlSourceDetailRef.value?.stopTimeCount();
|
||||
}
|
||||
);
|
||||
@@ -481,9 +491,37 @@ const start = async () => {
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: var(--el-text-color-regular);
|
||||
min-width: 0;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.connection-status-left {
|
||||
flex: 0 0 10%;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.connection-status-text {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.running-script-status {
|
||||
flex: 0 0 80%;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.connection-status-dot {
|
||||
flex: 0 0 auto;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
|
||||
Reference in New Issue
Block a user