diff --git a/ui/dasadmin/src/api/backend/index.ts b/ui/dasadmin/src/api/backend/index.ts
index ab227e86..e3233464 100644
--- a/ui/dasadmin/src/api/backend/index.ts
+++ b/ui/dasadmin/src/api/backend/index.ts
@@ -264,3 +264,69 @@ export function equipDetailsOrg(params: object = {}) {
data: params,
})
}
+
+export function getOtherParamsReq(params: any) {
+ return createAxios({
+ url: '/api/equipment/extProps/query',
+ method: 'POST',
+ data: params,
+ })
+}
+
+
+export function addOtherParamsReq(params: any) {
+ return createAxios({
+ url: '/api/equipment/extProps/add',
+ method: 'POST',
+ data: params,
+ })
+}
+
+export function updateOtherParamsReq(params: any) {
+ return createAxios({
+ url: '/api/equipment/extProps/update',
+ method: 'POST',
+ data: params,
+ })
+}
+
+export function delOtherParamsReq(params: any) {
+ return createAxios({
+ url: '/api/equipment/extProps/delete',
+ method: 'POST',
+ data: params,
+ })
+}
+
+export function uploadOtherParamsFileReq(formData: FormData, V: string) {
+ const token = encrypt_aes(adminInfo.token, V)
+ return createAxios({
+ url: '/api/equipment//file/upload',
+ method: 'POST',
+ data: formData,
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ V,
+ token,
+ }
+ },
+ { customEncrypt: true })
+}
+
+export function readFileReq(path: string, v: string) {
+ const formData = new FormData()
+ formData.append('path', path)
+ const token = encrypt_aes(adminInfo.token, v)
+ return createAxios({
+ url: '/api/equipment/file/read',
+ method: 'POST',
+ data: formData,
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ v,
+ token,
+ }
+ }, {
+ customEncrypt: true
+ })
+}
\ No newline at end of file
diff --git a/ui/dasadmin/src/utils/directive.ts b/ui/dasadmin/src/utils/directive.ts
new file mode 100644
index 00000000..10e97330
--- /dev/null
+++ b/ui/dasadmin/src/utils/directive.ts
@@ -0,0 +1,21 @@
+import { useAdminInfo } from '/@/stores/adminInfo'
+
+const authorityStore = useAdminInfo()
+
+export const permission = () => {
+ return {
+ mounted: (el: any, binding: { value: number[] }) => {
+ let hasShow = false
+ for (let item of binding.value) {
+ if (authorityStore.authorities.includes(item)) {
+ hasShow = true
+ break
+ }
+ }
+ if (!hasShow) {
+ el.style.display = 'none'
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/ui/dasadmin/src/views/backend/WindBlower/index.vue b/ui/dasadmin/src/views/backend/WindBlower/index.vue
index 548f33dd..d2698ca7 100644
--- a/ui/dasadmin/src/views/backend/WindBlower/index.vue
+++ b/ui/dasadmin/src/views/backend/WindBlower/index.vue
@@ -92,7 +92,7 @@
已锁定
{{ realTimeDataState }}
-
+
{
let r = Math.floor(Math.random() * 200) // 限制在0到127之间,以生成较深的颜色
let g = Math.floor(Math.random() * 200)
@@ -180,8 +181,9 @@ const createChartData = (data: { [k: string]: number }, time: string) => {
lastSeriesId.forEach((item: any) => {
if (!attrCode.includes(item)) {
const cur = realDataSeries.findIndex((val: any) => val.id === item)
- // delete cur.id
realDataSeries.splice(cur, 1)
+ const curLegendIndex = realDataLegend.findIndex((val:any)=>val.customKey===item)
+ realDataLegend.splice(curLegendIndex,1)
clearState = true
}
})
@@ -189,13 +191,13 @@ const createChartData = (data: { [k: string]: number }, time: string) => {
chartInstance.setOption(
{
series: realDataSeries,
+ legend: realDataLegend,
},
{
- replaceMerge: ['series'],
+ replaceMerge: ['series','legend'],
}
)
}
-
const seriesData = attrCode.map((item) => {
const curVal = getCutDecimalsValue(data[item], 2)
if (lastSeriesId.includes(item)) {
@@ -208,6 +210,14 @@ const createChartData = (data: { [k: string]: number }, time: string) => {
const len = list.length
const fillData = new Array(len).fill('')
fillData.push(curVal)
+ realDataLegend.push({
+ name:info.name,
+ icon: 'rect',
+ textStyle: {
+ color: color,
+ },
+ customKey:item
+ })
return {
id: item,
name: info.name + ' ' + (info?.unit ?? ''),
@@ -298,6 +308,7 @@ const createChart = () => {
},
yAxis: realDataYAxis,
series: realDataSeries,
+ legend:realDataLegend
}
} else {
option = {
@@ -386,7 +397,7 @@ const createChart = () => {
},
],
legend: {
- data: [],
+ data: realDataLegend,
textStyle: {
color: '#73767a',
},
@@ -394,7 +405,7 @@ const createChart = () => {
series: realDataSeries,
}
}
- chart.setOption(option, { replaceMerge: ['series', 'yAxis'] })
+ chart.setOption(option, { replaceMerge: ['series', 'yAxis','legend'] })
chartInstance = chart
}
diff --git a/ui/dasadmin/src/views/backend/equipment/airBlower/selectPoint.vue b/ui/dasadmin/src/views/backend/equipment/airBlower/selectPoint.vue
index aa5c8ef6..7934081c 100644
--- a/ui/dasadmin/src/views/backend/equipment/airBlower/selectPoint.vue
+++ b/ui/dasadmin/src/views/backend/equipment/airBlower/selectPoint.vue
@@ -88,13 +88,13 @@ import { Top, Bottom, Close } from '@element-plus/icons-vue'
const props = withDefaults(
defineProps<{
defaultAttr: { attributeCode: string; attributeName: string }[]
- visible: boolean,
- iotModelId:string
+ visible: boolean
+ iotModelId: string
}>(),
{
defaultAttr: () => [],
visible: false,
- iotModelId:''
+ iotModelId: '',
}
)
@@ -111,7 +111,7 @@ const subSystemVal = ref('')
const subSystemList = ref()
const getAllSubSystem = () => {
- getAllSubSystemReq({iotModelId:props.iotModelId}).then((res) => {
+ getAllSubSystemReq({ iotModelId: props.iotModelId }).then((res) => {
const data = res.data
.filter((item: any) => item)
.map((item: any) => {
@@ -125,31 +125,34 @@ const getAllSubSystem = () => {
}
const attributeTableData = ref<{ attributeName: string; attributeCode: string }[]>([])
-const selectTable = (section: any) => {
- const defaultCode = props.defaultAttr.map((item: any) => item.attributeCode)
- const addSection = section
- .filter((item: any) => !defaultCode.includes(item.attributeCode.toLowerCase()))
- .map((item: any) => {
- return {
- attributeName: item.attributeName,
- attributeCode: item.attributeCode.toLowerCase(),
- unit: item.unit,
- }
- })
- multipleSelection.value = [...props.defaultAttr, ...addSection]
+const selectTable = (section: any, row: any) => {
+ const hasSelect = section.find((item: any) => item.attributeCode === row.attributeCode)
+ if (hasSelect) {
+ const hasExist = multipleSelection.value.find((item: any) => item.attributeCode === hasSelect.attributeCode.toLowerCase())
+ if (!hasExist) {
+ multipleSelection.value.push(hasSelect)
+ }
+ } else {
+ const index = multipleSelection.value.findIndex((item: any) => item.attributeCode === row.attributeCode.toLowerCase())
+ multipleSelection.value.splice(index, 1)
+ }
}
const selectAllTable = (section: any) => {
- const defaultCode = props.defaultAttr.map((item: any) => item.attributeCode)
- const addSection = section
- .filter((item: any) => !defaultCode.includes(item.attributeCode.toLowerCase()))
- .map((item: any) => {
- return {
- attributeName: item.attributeName,
- attributeCode: item.attributeCode.toLowerCase(),
- unit: item.unit,
- }
- })
- multipleSelection.value = [...props.defaultAttr, ...addSection]
+ if (section.length) {
+ const defaultCode = multipleSelection.value.map((item: any) => item.attributeCode.toLowerCase())
+ const addSection = section
+ .filter((item: any) => !defaultCode.includes(item.attributeCode.toLowerCase()))
+ .map((item: any) => {
+ return {
+ attributeName: item.attributeName,
+ attributeCode: item.attributeCode.toLowerCase(),
+ unit: item.unit,
+ }
+ })
+ multipleSelection.value = [...multipleSelection.value, ...addSection]
+ } else {
+ multipleSelection.value = []
+ }
}
const pageSetting = reactive({
current: 1,
@@ -162,7 +165,7 @@ const pageChange = () => {
}
const attributeTableRef = ref()
-const multipleSelection = ref<{ attributeName: string; attributeCode: string }[]>(props.defaultAttr)
+const multipleSelection = ref<{ attributeName: string; attributeCode: string }[]>([])
const Statistic = computed(() => multipleSelection.value.length)
const clearList = () => {
multipleSelection.value = []
@@ -187,7 +190,7 @@ const moveDown = (index: number) => {
const moveRemove = (index: number, item: any) => {
multipleSelection.value.splice(index, 1)
nextTick(() => {
- const row = attributeTableData.value.find((attr) => attr.attributeCode === item.attributeCode)
+ const row = attributeTableData.value.find((attr) => attr.attributeCode.toLowerCase() === item.attributeCode.toLowerCase())
attributeTableRef.value?.toggleRowSelection(row, false)
})
}
@@ -219,12 +222,14 @@ const getTableData = (customData = {}) => {
})
}
const initSelect = () => {
- const defaultCode = props.defaultAttr.map((item: any) => item.attributeCode)
-
+ const defaultCode = multipleSelection.value.map((item: any) => item.attributeCode.toLowerCase())
const row = attributeTableData.value.filter((item) => defaultCode.includes(item.attributeCode.toLowerCase()))
if (row.length === 0) return
- row.forEach((item) => {
- attributeTableRef.value?.toggleRowSelection(item, true)
+ nextTick(() => {
+ attributeTableRef.value?.clearSelection()
+ row.forEach((item) => {
+ attributeTableRef.value?.toggleRowSelection(item, true)
+ })
})
}
@@ -234,6 +239,8 @@ watch(
if (props.visible) {
pageSetting.current = 1
pageSetting.pageSize = 20
+ multipleSelection.value = JSON.parse(JSON.stringify(props.defaultAttr))
+ initSelect()
}
}
)
@@ -246,6 +253,7 @@ defineExpose({
})
onMounted(() => {
+ multipleSelection.value = JSON.parse(JSON.stringify(props.defaultAttr))
getTableData()
getAllSubSystem()
})
diff --git a/ui/dasadmin/src/views/backend/equipment/equipmentManagement/index.vue b/ui/dasadmin/src/views/backend/equipment/equipmentManagement/index.vue
index 9c75668a..bbbe2ce7 100644
--- a/ui/dasadmin/src/views/backend/equipment/equipmentManagement/index.vue
+++ b/ui/dasadmin/src/views/backend/equipment/equipmentManagement/index.vue
@@ -49,13 +49,22 @@
- 量测
- |
- 调控
- |
- 查看
- |
- 删除
+
+ 量测
+ 调控
+ 查看
+ 删除
+
@@ -74,27 +83,353 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 风机详情
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 详情…
+
+
+
+
+
+
+
+
+
+
+
+
+ 详情…
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 详情…
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 详情…
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 详情…
+
+
+
+
+
+
+
+
+
+
+
+
+ 详情…
+
+
+
+
+
+
+
+
+
+
+
+
+ 详情…
+
+
+
+
+
+
+
+
+
+
+
+
+ 详情…
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 塔基柜详情
+
+
+ 机舱柜详情
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
@@ -102,88 +437,49 @@
+
+
+
+
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
@@ -191,7 +487,7 @@
-
+
@@ -241,8 +536,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -457,12 +565,12 @@
-
+
-
+
+
+
+
+
+
+
+
+ 暂无图片
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -511,14 +655,34 @@ import {
equipType,
equipDetailsModel,
equipDetailsOrg,
+ getOtherParamsReq,
+ addOtherParamsReq,
+ updateOtherParamsReq,
+ delOtherParamsReq,
+ uploadOtherParamsFileReq,
+ readFileReq,
} from '/@/api/backend'
-import { ElTable, ElMessage, ElMessageBox } from 'element-plus'
+import {
+ ElTable,
+ ElMessage,
+ ElMessageBox,
+ FormInstance,
+ UploadInstance,
+ genFileId,
+ UploadProps,
+ UploadRawFile,
+ UploadFile,
+ UploadFiles,
+ UploadRequestOptions,
+} from 'element-plus'
import { useAdminInfo } from '/@/stores/adminInfo'
import { encrypt_aes, generateRandomNumber } from '/@/utils/crypto'
import ControlPage from './control.vue'
import MeasurementPage from './measurement.vue'
import { ModelAttributeType } from '/@/views/backend/auth/model/type'
import { theoreticalpowerCurveList } from '/@/api/backend/theoreticalpowerCurve/request'
+import { permission } from '/@/utils/directive'
+const vPermission = permission()
const adminInfo = useAdminInfo()
interface Tree {
@@ -718,24 +882,16 @@ const headerForm = reactive({
// 新增按钮
const addDeviceList = () => {
- equipOrgBelonging()
- editAddDeviceDialog.value = true
- editAddDeviceData.objectType = queryParameter.value.equipmentTypeName
- editAddDeviceData.code = ''
- editAddDeviceData.name = ''
- editAddDeviceData.madeinFactory = ''
- editAddDeviceData.model = ''
- editAddDeviceData.location = ''
- editAddDeviceData.longitude = null
- editAddDeviceData.latitude = null
- editAddDeviceData.installDate = ''
- editAddDeviceData.remarks = ''
- editAddDeviceData.orgId = ''
- editAddDeviceData.parentEquipmentId = ''
- editAddDeviceData.iotModelId = ''
- editAddDeviceData.belongLine = ''
- editAddDeviceData.standard = 0
- editAddDeviceData.nominalCapacity = ''
+ // equipOrgBelonging()
+ setDevicedata()
+ if (queryParameter.value.equipmentTypeId === 10001) {
+ type10001DialogTitle.value = '新增风电场设备台账'
+ type10001DialogVisible.value = true
+ } else if (queryParameter.value.equipmentTypeId === 10002) {
+ type10002DialogTitle.value = '新增机组设备台账'
+ type10002DialogVisible.value = true
+ setOtherParamsFormData()
+ }
}
// 查看设备详情
@@ -779,42 +935,27 @@ const getModelList = () => {
}
})
}
-const selectEditModel = (value: string) => {
- editDeviceData.madeinFactory = modelList.value.find((item) => item.model == value)?.madeinFactory || ''
- editDeviceData.nominalCapacity = modelList.value.find((item) => item.model == value)?.nominalCapacity || ''
-}
-const selectAddModel = (value: string) => {
- editAddDeviceData.madeinFactory = modelList.value.find((item) => item.model == value)?.madeinFactory || ''
- editAddDeviceData.nominalCapacity = modelList.value.find((item) => item.model == value)?.nominalCapacity || ''
+const selectDeviceModel = (value: string) => {
+ deviceData.madeinFactory = modelList.value.find((item) => item.model == value)?.madeinFactory || ''
+ deviceData.nominalCapacity = modelList.value.find((item) => item.model == value)?.nominalCapacity || ''
}
const size = ref<'default' | 'large' | 'small'>('default')
-const handleCloseEditDevice = () => {
- editDeviceDialog.value = false
-}
-
+const curDeviceData = ref({})
// 设备查看按钮
const viewDeviceDetails = (data: any) => {
- equipOrgBelonging()
- modifyDeviceDetails.value?.resetFields()
- editDeviceDialog.value = true
- editDeviceData.id = data.row.id
- editDeviceData.objectType = queryParameter.value.equipmentTypeName
- editDeviceData.code = data.row.code
- editDeviceData.name = data.row.name
- editDeviceData.madeinFactory = data.row.madeinFactory
- editDeviceData.model = data.row.model
- editDeviceData.location = data.row.location
- editDeviceData.longitude = data.row.longitude
- editDeviceData.latitude = data.row.latitude
- editDeviceData.installDate = data.row.installDate
- editDeviceData.remarks = data.row.remarks
- editDeviceData.orgId = data.row.orgId
- editDeviceData.parentEquipmentId = data.row.parentEquipmentId
- editDeviceData.iotModelId = data.row.iotModelId
- editDeviceData.belongLine = data.row.belongLine
- editDeviceData.standard = data.row.standard || 0
- editDeviceData.nominalCapacity = data.row.nominalCapacity
+ curDeviceData.value = data.row
+ // equipOrgBelonging()
+ if (data.row.objectType === 10002) {
+ activeName.value = '1'
+ type10002DialogVisible.value = true
+ type10002DialogTitle.value = '编辑机组设备台账'
+ getOtherParams(data.row.id)
+ } else {
+ type10001DialogVisible.value = true
+ type10001DialogTitle.value = '编辑风电场设备台账'
+ }
+ setDevicedata(data.row)
}
// 设备删除
@@ -833,21 +974,27 @@ const del = {
id: '',
}
const dialogDeviceDeletion1 = () => {
- equipDelete(del).then((res) => {
- if (res.code == 200) {
- ElMessage({
- message: res.msg,
- type: 'success',
- })
- dialogDeviceDeletion.value = false
- deviceQuery(formQuery)
- } else {
- ElMessage.error({
- message: res.msg,
- type: 'error',
- })
- }
- })
+ delOtherParamsReq(del)
+ .then((res) => {
+ if (res) {
+ return equipDelete(del)
+ }
+ })
+ .then((res: any) => {
+ if (res.code == 200) {
+ ElMessage({
+ message: res.msg,
+ type: 'success',
+ })
+ dialogDeviceDeletion.value = false
+ deviceQuery(formQuery)
+ } else {
+ ElMessage.error({
+ message: res.msg,
+ type: 'error',
+ })
+ }
+ })
}
const longitudePass = (rule: any, value: any, callback: any) => {
if (!value) {
@@ -901,11 +1048,8 @@ const saveData = () => {
equipUpdate(editDeviceData)
.then((res: any) => {
if (res.code == 200) {
- ElMessage({
- message: res.msg,
- type: 'success',
- })
deviceQuery(formQuery)
+ return res?.data?.id
} else {
ElMessage.error({
message: res.msg,
@@ -913,6 +1057,20 @@ const saveData = () => {
})
}
})
+ .then((id) => {
+ if (id) {
+ return updateOtherParamsReq({ ...otherParamsForm, id })
+ }
+ })
+ .then((res) => {
+ if (res) {
+ ElMessage({
+ message: res.msg,
+ type: 'success',
+ })
+ }
+ editDeviceDialog.value = false
+ })
.catch((err) => {
ElMessage.error({
message: err.response?.data?.msg ?? '编辑失败!',
@@ -923,7 +1081,6 @@ const saveData = () => {
return false
}
})
- editDeviceDialog.value = false
}
// 新增设备
@@ -972,44 +1129,6 @@ const editAddDeviceRules = reactive({
latitude: [{ validator: latitudePass, trigger: 'blur' }],
})
-const editAddDeviceDialog = ref(false)
-const modifyAddDeviceDetails = ref()
-const saveAddData = () => {
- modifyAddDeviceDetails.value.validate((valid: any) => {
- if (valid) {
- deviceTypeList.value.forEach((ele: any) => {
- if (ele.equipmentTypeName === editAddDeviceData.objectType) {
- editAddDeviceData.objectType = ele.equipmentTypeId
- }
- })
- equipAdd(editAddDeviceData)
- .then((res) => {
- if (res.code == 200) {
- ElMessage({
- message: res.msg,
- type: 'success',
- })
- deviceQuery(formQuery)
- } else {
- ElMessage.error({
- message: res.msg,
- type: 'error',
- })
- }
- })
- .catch((err) => {
- ElMessage.error({
- message: err.response?.data?.msg ?? '新增失败!',
- type: 'error',
- })
- })
- editAddDeviceDialog.value = false
- }
- })
-}
-const handleCloseAddEditDevice = () => {
- editAddDeviceDialog.value = false
-}
// 导入
const upLoadModel = (file: any) => {
const formData = new FormData()
@@ -1093,6 +1212,285 @@ watch(showMeasure, (newVal: boolean) => {
})
getModelList()
+
+const deviceDataFormRef = ref()
+
+const type10001DialogVisible = ref(false)
+const type10001DialogTitle = ref('新增风电场设备台账')
+
+const type10002DialogVisible = ref(false)
+const type10002DialogTitle = ref('新增机组设备台账')
+
+const originDeviceData: any = {
+ id: null,
+ objectType: '',
+ code: '',
+ name: '',
+ madeinFactory: '',
+ model: '',
+ location: '',
+ longitude: null,
+ latitude: null,
+ installDate: '',
+ remarks: '',
+ orgId: '',
+ parentEquipmentId: '',
+ iotModelId: '',
+ belongLine: '',
+ standard: 0,
+ nominalCapacity: '',
+}
+const deviceData = reactive({})
+const setDevicedata = (formData: any = {}) => {
+ const keys = Object.keys(originDeviceData)
+ keys.forEach((key) => {
+ deviceData[key] = formData?.[key] ?? originDeviceData[key]
+ })
+}
+
+const getCurDialogState = () => {
+ if (
+ (type10001DialogVisible.value && type10001DialogTitle.value === '新增风电场设备台账') ||
+ (type10002DialogVisible.value && type10002DialogTitle.value === '新增机组设备台账')
+ ) {
+ return 'add'
+ } else if (
+ (type10001DialogVisible.value && type10001DialogTitle.value === '编辑风电场设备台账') ||
+ (type10002DialogVisible.value && type10002DialogTitle.value === '编辑机组设备台账')
+ ) {
+ return 'edit'
+ }
+}
+const saveDeviceData = () => {
+ // console.log(deviceData, 'deviceData')
+
+ deviceDataFormRef.value?.validate((valid: boolean) => {
+ if (valid) {
+ deviceData.standard = deviceData.standard ? 1 : 0
+ if (getCurDialogState() === 'add') {
+ deviceData.objectType = queryParameter.value.equipmentTypeId
+ equipAdd(deviceData)
+ .then((res) => {
+ if (res.code == 200) {
+ deviceQuery(formQuery)
+ return res?.data?.id
+ } else {
+ ElMessage.error({
+ message: res.msg,
+ type: 'error',
+ })
+ }
+ })
+ .then((id) => {
+ if (id) {
+ setUploadImgInfo(id)
+ return addOtherParamsReq({ ...otherParamsForm, id })
+ }
+ })
+ .then((res) => {
+ if (res) {
+ ElMessage({
+ message: res.msg,
+ type: 'success',
+ })
+ type10001DialogVisible.value = false
+ type10002DialogVisible.value = false
+ addImgList.value = []
+ }
+ })
+ .catch((err) => {
+ ElMessage.error({
+ message: err.response?.data?.msg ?? '新增失败!',
+ type: 'error',
+ })
+ })
+ } else if (getCurDialogState() === 'edit') {
+ equipUpdate(deviceData)
+ .then((res: any) => {
+ if (res.code == 200) {
+ deviceQuery(formQuery)
+ return res?.data?.id
+ } else {
+ ElMessage.error({
+ message: res.msg,
+ type: 'error',
+ })
+ }
+ })
+ .then((id) => {
+ if (id) {
+ setUploadImgInfo(id)
+ return updateOtherParamsReq({ ...otherParamsForm, id })
+ }
+ })
+ .then((res) => {
+ if (res) {
+ ElMessage({
+ message: res.msg,
+ type: 'success',
+ })
+ }
+ type10001DialogVisible.value = false
+ type10002DialogVisible.value = false
+ addImgList.value = []
+ })
+ .catch((err) => {
+ ElMessage.error({
+ message: err.response?.data?.msg ?? '编辑失败!',
+ type: 'error',
+ })
+ })
+ }
+ }
+ })
+}
+const cancelType10002Dialog = () => {
+ if (addImgList.value.length) {
+ ElMessageBox.confirm('上传图片未保存,确认取消?', '', {
+ confirmButtonText: '确认',
+ cancelButtonText: '取消',
+ type: 'warning',
+ })
+ .then(() => {
+ type10002DialogVisible.value = false
+ addImgList.value = []
+ imgList.value = []
+ })
+ .catch(() => {})
+ } else {
+ type10002DialogVisible.value = false
+ imgList.value = []
+ }
+}
+const activeName = ref('1')
+
+const originOtherParamsFormData = {
+ pitchSystemModel: '',
+ pitchSystemManufacturer: '',
+ blade1Model: '',
+ blade1Manufacturer: '',
+ blade1BearingModel: '',
+ blade1BearingManufacturer: '',
+ blade2Model: '',
+ blade2Manufacturer: '',
+ blade2BearingModel: '',
+ blade2BearingManufacturer: '',
+ blade3Model: '',
+ blade3Manufacturer: '',
+ blade3BearingModel: '',
+ blade3BearingManufacturer: '',
+ mainBearingModel: '',
+ mainBearingManufacturer: '',
+ gearboxModel: '',
+ gearboxManufacturer: '',
+ generatorModel: '',
+ generatorManufacturer: '',
+ converterModel: '',
+ converterManufacturer: '',
+ mainControlSystemModel: '',
+ mainControlSystemManufacturer: '',
+ mainControlSystemSoftwareVersion: '',
+ sysEquipmentDocsList: [],
+}
+const otherParamsForm = reactive(JSON.parse(JSON.stringify(originOtherParamsFormData)))
+
+const getOtherParams = (id: string) => {
+ getOtherParamsReq({ id }).then((res) => {
+ setOtherParamsFormData(res?.data ?? {})
+ })
+}
+
+const setOtherParamsFormData = (data: any = {}) => {
+ const keys = Object.keys(originOtherParamsFormData)
+ keys.forEach((key) => {
+ otherParamsForm[key] = data?.[key] ?? originOtherParamsFormData[key as keyof typeof originOtherParamsFormData]
+ })
+}
+
+const attachmentDialogVisible = ref(false)
+const attachmentDialogTitle = ref('风机详细信息')
+
+const uploadRef = ref()
+const uploadAttachment = (file: UploadRequestOptions) => {
+ const formData = new FormData()
+ formData.append('fileList', file.file)
+ const v = generateRandomNumber(16)
+ return uploadOtherParamsFileReq(formData, v).then((res) => {
+ addImgList.value.push({
+ name: file.file.name,
+ url: res.data[0].url,
+ component: attachmentComponent.value,
+ })
+ addImgList.value.push({
+ name: file.file.name,
+ url: res.data[1].url,
+ component: attachmentComponent.value,
+ })
+ const imgListUrl = imgList.value.map((item: any) => item.url)
+ for (let i = addImgList.value.length - 1; i >= 0; i--) {
+ if (imgListUrl.includes('/api/equipment/file/read?path=' + addImgList.value[i].url)) {
+ const index = imgList.value.findIndex((item: any) => item.url === '/api/equipment/file/read?path=' + addImgList.value[i].url)
+ imgList.value.splice(index, 1)
+ }
+ }
+ previewImg([...imgList.value, ...addImgList.value])
+ })
+}
+const setUploadImgInfo = (id: string) => {
+ otherParamsForm.sysEquipmentDocsList = [...otherParamsForm.sysEquipmentDocsList, ...addImgList.value]
+ otherParamsForm.sysEquipmentDocsList.forEach((item: any) => {
+ item.deviceId = id
+ })
+}
+const handleExceed: UploadProps['onExceed'] = (files) => {
+ uploadRef.value!.clearFiles()
+ const file = files[0] as UploadRawFile
+ file.uid = genFileId()
+ uploadRef.value!.handleStart(file)
+ uploadRef.value!.submit()
+}
+const attachmentComponent = ref('')
+const openAttachment = (type: string) => {
+ attachmentComponent.value = type
+ attachmentDialogTitle.value = type + '详细信息'
+ attachmentDialogVisible.value = true
+ const list = otherParamsForm.sysEquipmentDocsList.filter((item: { component: string; name: string; url: string }) => {
+ return item.component === type
+ })
+ if (list.length) {
+ previewImg(list)
+ } else {
+ imgList.value = []
+ }
+}
+const reg = /\/thumbnailPic\//
+const hasPathReg = /\/api\/equipment\/file\/read\?path=/
+const previewImg = (list: { url: string }[]) => {
+ const picList: any = []
+ for (let item of list) {
+ if (hasPathReg.test(item.url)) {
+ picList.push({ url: item.url })
+ continue
+ }
+ if (reg.test(item.url)) {
+ picList.push({ url: '/api/equipment/file/read?path=' + item.url })
+ }
+ }
+ imgList.value = picList
+}
+
+const addImgList = ref([])
+const imgList = ref<{ url: string }[]>([])
+const realImgList = computed(() => {
+ return imgList.value.map((item: { url: string }) => {
+ const realImgUrl = item.url.replace(/\/thumbnailPic\//, '/pic/')
+ return realImgUrl
+ })
+})
+const previewImgIndex = ref(0)
+const changeImgIndex = (index: number) => {
+ previewImgIndex.value = index
+}