|
|
|
@ -11,39 +11,63 @@
@@ -11,39 +11,63 @@
|
|
|
|
|
<el-row> |
|
|
|
|
<FormItemInput label="任务名称" v-model="formData.name" require /> |
|
|
|
|
</el-row> |
|
|
|
|
|
|
|
|
|
<el-row> |
|
|
|
|
<span class="label">固件选择:</span> |
|
|
|
|
<span class="label"> <span class="require">*</span>设备类别: </span> |
|
|
|
|
<el-cascader |
|
|
|
|
:props="cascaderFirmware" |
|
|
|
|
v-model="firmwareSelect" |
|
|
|
|
ref="firmwareCascaderRef" |
|
|
|
|
:show-all-levels="false" |
|
|
|
|
placeholder="请选择" |
|
|
|
|
v-model="formData.type" |
|
|
|
|
:options="categoryTreeData" |
|
|
|
|
style="flex: 1" |
|
|
|
|
:props="{ |
|
|
|
|
checkStrictly: true, |
|
|
|
|
value: 'id', |
|
|
|
|
label: 'name', |
|
|
|
|
emitPath: false, |
|
|
|
|
}" |
|
|
|
|
/> |
|
|
|
|
</el-row> |
|
|
|
|
<el-row v-if="isShowDeviceSelect"> |
|
|
|
|
<!-- <span class="label">设备选择</span> |
|
|
|
|
<el-cascader |
|
|
|
|
style="flex: 1" |
|
|
|
|
v-model="deviceSelect" |
|
|
|
|
:props="cascaderDevice" |
|
|
|
|
@change="devChange" |
|
|
|
|
ref="deviceCascaderRef" |
|
|
|
|
:show-all-levels="false" |
|
|
|
|
popper-class="task-device-select-cascader" |
|
|
|
|
placeholder="请选择" |
|
|
|
|
<el-row v-if="typeof formData.type !== 'undefined'"> |
|
|
|
|
<span class="label"> <span class="require">*</span>设备: </span> |
|
|
|
|
<el-select |
|
|
|
|
v-model="formData.deviceSns" |
|
|
|
|
multiple |
|
|
|
|
collapse-tags |
|
|
|
|
style="flex: 1" |
|
|
|
|
:max-collapse-tags="4" |
|
|
|
|
collapse-tags-tooltip |
|
|
|
|
@expand-change="changeSourceType" |
|
|
|
|
/> --> |
|
|
|
|
placeholder="请选择设备" |
|
|
|
|
@visible-change="loadDeviceList" |
|
|
|
|
> |
|
|
|
|
<el-option |
|
|
|
|
v-for="item in deviceList" |
|
|
|
|
:key="item.sn" |
|
|
|
|
:label="item.sn" |
|
|
|
|
:value="item.sn" |
|
|
|
|
/> |
|
|
|
|
</el-select> |
|
|
|
|
</el-row> |
|
|
|
|
|
|
|
|
|
<el-row v-if="typeof formData.type !== 'undefined'"> |
|
|
|
|
<span class="label"> <span class="require">*</span>固件选择: </span> |
|
|
|
|
<el-select |
|
|
|
|
v-model="formData.firmwareId" |
|
|
|
|
placeholder="请选择固件" |
|
|
|
|
style="flex: 1" |
|
|
|
|
:disabled="false" |
|
|
|
|
class="input" |
|
|
|
|
@visible-change="loadFirmwareList" |
|
|
|
|
> |
|
|
|
|
<el-option |
|
|
|
|
v-for="item in firmwareList" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.name" |
|
|
|
|
:value="item.id" |
|
|
|
|
/> |
|
|
|
|
</el-select> |
|
|
|
|
</el-row> |
|
|
|
|
<el-row> |
|
|
|
|
<span class="label">是否立即执行</span> |
|
|
|
|
<el-switch |
|
|
|
|
v-model="formData.executeNow" |
|
|
|
|
style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" |
|
|
|
|
/> |
|
|
|
|
<el-switch v-model="formData.executeNow" /> |
|
|
|
|
</el-row> |
|
|
|
|
<el-row v-if="!formData.executeNow"> |
|
|
|
|
<span class="label">任务执行时间</span> |
|
|
|
@ -74,135 +98,32 @@ import EdfsDialog from '@/components/dashboard/Edfs-dialog.vue'
@@ -74,135 +98,32 @@ import EdfsDialog from '@/components/dashboard/Edfs-dialog.vue'
|
|
|
|
|
import FormItemInput from '@/components/dashboard/FormItemInput.vue' |
|
|
|
|
import { isResError, useMessage } from '@/hooks/useMessage' |
|
|
|
|
import EdfsNumberInput from '@/components/dashboard/Edfs-number-item-input.vue' |
|
|
|
|
import FormItemSelect from '@/components/dashboard/FormItemSelect.vue' |
|
|
|
|
import type { CascaderProps, CascaderValue, ElCascader } from 'element-plus' |
|
|
|
|
// import { getSimpleStationList } from '@/api/module/app/station' |
|
|
|
|
// import { getSimpleDeviceList } from '@/api/module/app/device' |
|
|
|
|
import { getIntDictOptions } from '@/utils/dict' |
|
|
|
|
import { getSimpleDeviceList } from '@/api/module/eam/device/index' |
|
|
|
|
import { getSimpleFirmwareList } from '@/api/module/eam/device/firmware' |
|
|
|
|
import { isEmpty } from '@/utils/is' |
|
|
|
|
import { clone, cloneDeep } from 'lodash' |
|
|
|
|
import { cloneDeep } from 'lodash' |
|
|
|
|
import { createTask } from '@/api/module/eam/device/task' |
|
|
|
|
|
|
|
|
|
import { getCategoryTree, type ICategoryTree } from '@/api/module/eam/device/category' |
|
|
|
|
import { useRoute } from 'vue-router' |
|
|
|
|
const route = useRoute() |
|
|
|
|
const message = useMessage() |
|
|
|
|
interface Props { |
|
|
|
|
isShow: boolean |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const emits = defineEmits(['on-save', 'on-close']) |
|
|
|
|
const props = withDefaults(defineProps<Props>(), { |
|
|
|
|
withDefaults(defineProps<Props>(), { |
|
|
|
|
isShow: false, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const firmwareSelect = ref<CascaderValue>([]) |
|
|
|
|
const firmwareCascaderRef = ref<InstanceType<typeof ElCascader>>() |
|
|
|
|
const cascaderFirmware: CascaderProps = { |
|
|
|
|
lazy: true, |
|
|
|
|
async lazyLoad(node, resolve) { |
|
|
|
|
const { level } = node |
|
|
|
|
|
|
|
|
|
if (level === 0) { |
|
|
|
|
const deviceTypes = getIntDictOptions('device_entity_type').map(item => ({ |
|
|
|
|
value: item.value, |
|
|
|
|
label: item.label, |
|
|
|
|
isLeaf: false, |
|
|
|
|
})) |
|
|
|
|
resolve(deviceTypes) |
|
|
|
|
} |
|
|
|
|
if (level === 1) { |
|
|
|
|
const res = await getSimpleFirmwareList({ |
|
|
|
|
type: node.data?.value as number, |
|
|
|
|
}) |
|
|
|
|
const data = Array.isArray(res?.data) ? res.data : [] |
|
|
|
|
const firmware = data.map((item: any) => ({ |
|
|
|
|
value: item.id, |
|
|
|
|
label: item.name, |
|
|
|
|
isLeaf: true, |
|
|
|
|
leaf: true, |
|
|
|
|
})) |
|
|
|
|
resolve(firmware) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const selectFirmwareType = ref() |
|
|
|
|
watch(firmwareSelect, (value: any) => { |
|
|
|
|
selectFirmwareType.value = value[0] ?? '' |
|
|
|
|
formData.value.firmwareId = String(value[1]) ?? '' |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const isShowDeviceSelect = ref(false) |
|
|
|
|
watch( |
|
|
|
|
() => selectFirmwareType.value, |
|
|
|
|
() => { |
|
|
|
|
isShowDeviceSelect.value = false |
|
|
|
|
nextTick(() => { |
|
|
|
|
isShowDeviceSelect.value = |
|
|
|
|
!isEmpty(selectFirmwareType.value) && |
|
|
|
|
typeof selectFirmwareType.value !== 'undefined' |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// const deviceCascaderRef = ref<InstanceType<typeof ElCascader>>() |
|
|
|
|
// const cascaderDevice: CascaderProps = { |
|
|
|
|
// lazy: true, |
|
|
|
|
// multiple: true, |
|
|
|
|
// async lazyLoad(node, resolve) { |
|
|
|
|
// const { level } = node |
|
|
|
|
// if (level === 0) { |
|
|
|
|
// const res = await getSimpleStationList() |
|
|
|
|
// if (isResError(res)) return |
|
|
|
|
// const data = Array.isArray(res?.data) ? res.data : [] |
|
|
|
|
// const nodes = data.map((item: any) => ({ |
|
|
|
|
// value: item.id, |
|
|
|
|
// label: item.name, |
|
|
|
|
// isLeaf: false, |
|
|
|
|
// })) |
|
|
|
|
// resolve(nodes) |
|
|
|
|
// } |
|
|
|
|
// if (level === 1) { |
|
|
|
|
// const res = await getSimpleDeviceList({ |
|
|
|
|
// siteId: node.data?.value as number, |
|
|
|
|
// type: selectFirmwareType.value, |
|
|
|
|
// }) |
|
|
|
|
|
|
|
|
|
// const data = Array.isArray(res?.data) ? res.data : [] |
|
|
|
|
// const devices = data.map((item: any) => ({ |
|
|
|
|
// value: item.sn, |
|
|
|
|
// label: item.name, |
|
|
|
|
// isLeaf: true, |
|
|
|
|
// leaf: true, |
|
|
|
|
// })) |
|
|
|
|
// resolve(devices) |
|
|
|
|
// } |
|
|
|
|
// }, |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
const deviceSelect = ref<CascaderValue>([]) |
|
|
|
|
watch(deviceSelect, (value: any) => { |
|
|
|
|
formData.value.deviceSns = value.map((item: any) => item[1]) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
function devChange() {} |
|
|
|
|
|
|
|
|
|
const cascaderTag = ref<any[]>([]) |
|
|
|
|
function changeSourceType(selectItem: any) { |
|
|
|
|
if (!cascaderTag.value.includes(selectItem[0])) { |
|
|
|
|
deviceSelect.value = [] |
|
|
|
|
} |
|
|
|
|
cascaderTag.value = selectItem |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const form = { |
|
|
|
|
name: '', |
|
|
|
|
name: undefined, |
|
|
|
|
executeNow: false, // 立即执行 |
|
|
|
|
executeTime: '', // 执行时间 |
|
|
|
|
executeTime: undefined, // 执行时间 |
|
|
|
|
retryCount: 3, // 重试次数 |
|
|
|
|
retryInterval: 1000, // 重试间隔 |
|
|
|
|
monitorTimeout: 1000, // 监控超时 |
|
|
|
|
firmwareId: '', // 固件ID |
|
|
|
|
deviceSns: [], // 设备SN |
|
|
|
|
firmwareId: undefined, // 固件ID |
|
|
|
|
type: undefined, // 设备类别 |
|
|
|
|
deviceSns: [], // 设备 |
|
|
|
|
} |
|
|
|
|
const formData = ref(cloneDeep(form)) |
|
|
|
|
|
|
|
|
@ -211,14 +132,15 @@ function validate() {
@@ -211,14 +132,15 @@ function validate() {
|
|
|
|
|
message.error('请输入任务名称') |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
if (!formData.value.firmwareId) { |
|
|
|
|
message.error('请选择固件') |
|
|
|
|
if (!formData.value.type) { |
|
|
|
|
message.error('请选择设备类别') |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
if (!formData.value.deviceSns.length) { |
|
|
|
|
message.error('请选择设备') |
|
|
|
|
if (!formData.value.firmwareId) { |
|
|
|
|
message.error('请选择固件') |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!formData.value.executeNow && !formData.value.executeTime) { |
|
|
|
|
message.error('请选择执行时间') |
|
|
|
|
return true |
|
|
|
@ -255,10 +177,49 @@ function onClone() {
@@ -255,10 +177,49 @@ function onClone() {
|
|
|
|
|
|
|
|
|
|
function clearData() { |
|
|
|
|
formData.value = cloneDeep(form) |
|
|
|
|
firmwareSelect.value = [] |
|
|
|
|
cascaderTag.value = [] |
|
|
|
|
deviceSelect.value = [] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const categoryTreeData = ref<ICategoryTree[]>([]) |
|
|
|
|
async function loadDeviceTypeTree() { |
|
|
|
|
const res = await getCategoryTree() |
|
|
|
|
if (!isResError(res)) { |
|
|
|
|
categoryTreeData.value = res.data |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const firmwareList = ref<any[]>([]) |
|
|
|
|
async function loadFirmwareList(value: boolean) { |
|
|
|
|
if (!value) return |
|
|
|
|
const res = await getSimpleFirmwareList({ type: formData.value.type as any }) |
|
|
|
|
if (!isResError(res)) { |
|
|
|
|
firmwareList.value = res.data |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const deviceList = ref<any[]>([]) |
|
|
|
|
async function loadDeviceList(value: boolean) { |
|
|
|
|
if (!value) return |
|
|
|
|
const res = await getSimpleDeviceList({ categoryId: formData.value.type as any }) |
|
|
|
|
if (!isResError(res)) { |
|
|
|
|
deviceList.value = res.data |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onMounted(async () => { |
|
|
|
|
await loadDeviceTypeTree() |
|
|
|
|
if (route.query.categoryId) { |
|
|
|
|
formData.value.type = Number(route.query.categoryId) |
|
|
|
|
await loadFirmwareList(true) |
|
|
|
|
await loadDeviceList(true) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (route.query.deviceSn) { |
|
|
|
|
formData.value.deviceSns = [route.query.deviceSn] |
|
|
|
|
} |
|
|
|
|
if (route.query.firmwareId) { |
|
|
|
|
formData.value.firmwareId = Number(route.query.firmwareId) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<style lang="scss"> |
|
|
|
@ -277,9 +238,6 @@ function clearData() {
@@ -277,9 +238,6 @@ function clearData() {
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
|
|
.create-task-dlg { |
|
|
|
|
.dlg-body { |
|
|
|
|
max-height: 400px; |
|
|
|
|
} |
|
|
|
|
.el-row { |
|
|
|
|
height: 32px; |
|
|
|
|
width: 74%; |
|
|
|
|