|
@@ -198,13 +198,30 @@
|
|
<!-- 关联委托单 -->
|
|
<!-- 关联委托单 -->
|
|
<LinkAssociation v-model="isLinksAssociation" :cid="contractId" :ids="ids" @change="commissionChange" @close="isLinksAssociation = false" />
|
|
<LinkAssociation v-model="isLinksAssociation" :cid="contractId" :ids="ids" @change="commissionChange" @close="isLinksAssociation = false" />
|
|
|
|
|
|
- <!-- 关联设备数据 -->
|
|
|
|
- <hc-new-dialog v-model="isLinkAcquisition" is-table is-footer-center title="关联设备数据" widths="80%" @close="linksAcquisitionClose">
|
|
|
|
- <LinkAcquisition v-if="isLinkAcquisition" v-model="linkAcquisitionLoadDataId" @change="linkAcquisitionChange" />
|
|
|
|
- <template #footer>
|
|
|
|
- <el-button @click="linksAcquisitionClose">取消</el-button>
|
|
|
|
- <el-button hc-btn type="primary" :loading="linksAcquisitionLoading" @click="linksAcquisitionClick">确定</el-button>
|
|
|
|
- </template>
|
|
|
|
|
|
+ <!-- 引用设备仪器 -->
|
|
|
|
+ <hc-new-dialog v-model="deviceModal" is-table save-text="确认引用" title="引用设备仪器" widths="84%" :loading="deviceLoad" @close="deviceModalClose" @save="deviceModalSave">
|
|
|
|
+ <div class="adding-form-dialog-box">
|
|
|
|
+ <div class="dialog-tree-box">
|
|
|
|
+ <el-scrollbar>
|
|
|
|
+ <HcMenuSimple
|
|
|
|
+ :datas="equipmentmenus" :keys="equipmentmenuKey" :props="equipmentmenuProps"
|
|
|
|
+ @change="equipmentmenuChange"
|
|
|
|
+ />
|
|
|
|
+ </el-scrollbar>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="dialog-table-box">
|
|
|
|
+ <div class="dialog-table">
|
|
|
|
+ <HcTable
|
|
|
|
+ ref="deviceTableRef" :column="deviceTableColumn" :datas="deviceTableData" :loading="deviceTableLoading"
|
|
|
|
+ is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
|
|
|
|
+ @selection-change="deviceTableSelection"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ <div class="dialog-pages">
|
|
|
|
+ <HcPages :pages="equipmentPage" @change="equipmentTablePageChange" />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</hc-new-dialog>
|
|
</hc-new-dialog>
|
|
</hc-drawer>
|
|
</hc-drawer>
|
|
</template>
|
|
</template>
|
|
@@ -213,12 +230,12 @@
|
|
import { nextTick, ref, watch } from 'vue'
|
|
import { nextTick, ref, watch } from 'vue'
|
|
import TestTree from '../../material/components/TestTree.vue'
|
|
import TestTree from '../../material/components/TestTree.vue'
|
|
import { useAppStore } from '~src/store'
|
|
import { useAppStore } from '~src/store'
|
|
-
|
|
|
|
|
|
+import dataApi2 from '~api/tentative/device/approach'
|
|
import dataApi from '~api/tentative/detect/test'
|
|
import dataApi from '~api/tentative/detect/test'
|
|
import LinkAssociation from '../../detect/components/linkAssociation.vue'
|
|
import LinkAssociation from '../../detect/components/linkAssociation.vue'
|
|
-import LinkAcquisition from '../../detect/components/linkAcquisition.vue'
|
|
|
|
|
|
+import { getClassList } from '~api/tentative'
|
|
import codeApi from '~api/basic/code'
|
|
import codeApi from '~api/basic/code'
|
|
-import { getArrValue, getObjValue } from 'js-fast-way'
|
|
|
|
|
|
+import { arrToId, getArrValue, getObjValue } from 'js-fast-way'
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
nodeId:{
|
|
nodeId:{
|
|
type: [String, Number],
|
|
type: [String, Number],
|
|
@@ -501,53 +518,8 @@ const commissionChange = (id, data) => {
|
|
|
|
|
|
//关联设备
|
|
//关联设备
|
|
//关联设备数据
|
|
//关联设备数据
|
|
-const isLinkAcquisition = ref(false)
|
|
|
|
-const linkAcquisitionLoadDataId = ref('')
|
|
|
|
-const linkAcquisitionIndex = ref(-1)
|
|
|
|
-const linkAcquisitionRow = ref({})
|
|
|
|
-const linkAcquisitionClick = (item, index) => {
|
|
|
|
- isLinkAcquisition.value = true
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
|
|
-//确定
|
|
|
|
-const linksAcquisitionLoading = ref(false)
|
|
|
|
-const linksAcquisitionClick = async () => {
|
|
|
|
- linksAcquisitionLoading.value = true
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- linksAcquisitionClose()
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//关闭关联
|
|
|
|
-const linksAcquisitionClose = () => {
|
|
|
|
- isLinkAcquisition.value = false
|
|
|
|
- linkAcquisitionRow.value = {}
|
|
|
|
- linkAcquisitionLoadDataId.value = null
|
|
|
|
- linkAcquisitionIndex.value = -1
|
|
|
|
- linksAcquisitionLoading.value = false
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const linkAcquisitionChange = async (ids, rows) => {
|
|
|
|
- linkAcquisitionLoadDataId.value = ids
|
|
|
|
- basicInfoData.value.deviceUseIds = ids
|
|
|
|
- const { error, code, data, msg } = await codeApi.getDeviceInfoByIds({
|
|
|
|
- deviceInfoIds: ids,
|
|
|
|
-
|
|
|
|
- })
|
|
|
|
- handleSaveLoad.value = false
|
|
|
|
- if (!error && code === 200) {
|
|
|
|
- let resArr = getArrValue(data)
|
|
|
|
- if (resArr.length > 0) {
|
|
|
|
- resArr.forEach((item)=>{
|
|
|
|
- basicInfoData.value.trailDeviceUseInfoDTOS.push(item)
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
//保存
|
|
//保存
|
|
const handleSaveLoad = ref(false)
|
|
const handleSaveLoad = ref(false)
|
|
const handleSave = async () => {
|
|
const handleSave = async () => {
|
|
@@ -600,6 +572,179 @@ const linkLast = async ()=>{
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+//引用设备
|
|
|
|
+const deviceModal = ref(false)
|
|
|
|
+const deviceTableRef = ref(null)
|
|
|
|
+const linkAcquisitionClick = ()=>{
|
|
|
|
+ deviceModal.value = true
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ deviceTableRef.value?.clearSelection()
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ getequipmentMenusData()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//表格数据
|
|
|
|
+const deviceTableColumn = ref([
|
|
|
|
+ { key: 'deviceNumber', name: '设备编号' },
|
|
|
|
+ { key: 'deviceName', name: '设备仪器名称' },
|
|
|
|
+])
|
|
|
|
+const deviceTableData = ref([])
|
|
|
|
+const equipmentPage = ref({ current: 1, size: 20, total: 0 })
|
|
|
|
+const equipmentTablePageChange = ({ current, size }) => {
|
|
|
|
+ equipmentPage.value.current = current
|
|
|
|
+ equipmentPage.value.size = size
|
|
|
|
+ getDeviceTableData()
|
|
|
|
+}
|
|
|
|
+//数组去重
|
|
|
|
+let temp = []
|
|
|
|
+const getnewArr = (tempArr) => {
|
|
|
|
+ tempArr.forEach(function (a) {
|
|
|
|
+ let check = temp.every(function (b) {
|
|
|
|
+ return a.id !== b.id
|
|
|
|
+ })
|
|
|
|
+ check ? temp.push(a) : ''
|
|
|
|
+ })
|
|
|
|
+ return temp
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const equipmentmenuKey = ref('')
|
|
|
|
+const equipmentmenus = ref([])
|
|
|
|
+const equipmentmenuProps = {
|
|
|
|
+ key: 'id',
|
|
|
|
+ label: 'className',
|
|
|
|
+}
|
|
|
|
+const getequipmentMenusData = async () => {
|
|
|
|
+ const { data } = await getClassList({
|
|
|
|
+ projectId: projectId.value,
|
|
|
|
+ contractId: contractId.value,
|
|
|
|
+ })
|
|
|
|
+ const arr = getArrValue(data)
|
|
|
|
+ equipmentmenus.value = arr
|
|
|
|
+ if (arr.length > 0) {
|
|
|
|
+ const item = arr[0]
|
|
|
|
+ equipmentmenuItem.value = item
|
|
|
|
+ equipmentmenuKey.value = item?.id
|
|
|
|
+ getDeviceTableData()
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//菜单被点击
|
|
|
|
+
|
|
|
|
+const equipmentmenuItem = ref({})
|
|
|
|
+const equipmentmenuChange = (item) => {
|
|
|
|
+ equipmentmenuItem.value = item
|
|
|
|
+ equipmentmenuKey.value = item?.id
|
|
|
|
+ getDeviceTableData()
|
|
|
|
+}
|
|
|
|
+//获取表格数据
|
|
|
|
+const deviceTableLoading = ref(false)
|
|
|
|
+const getDeviceTableData = async () => {
|
|
|
|
+ deviceTableLoading.value = true
|
|
|
|
+ const { error, code, data } = await dataApi2.queryPage({
|
|
|
|
+ projectId: projectId.value,
|
|
|
|
+ contractId: contractId.value,
|
|
|
|
+ deviceClassId: equipmentmenuKey.value,
|
|
|
|
+ size: equipmentPage.value.size,
|
|
|
|
+ current: equipmentPage.value.current,
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ //处理数据
|
|
|
|
+ deviceTableLoading.value = false
|
|
|
|
+ if (!error && code === 200) {
|
|
|
|
+ deviceTableData.value = getArrValue(data['records'])
|
|
|
|
+ equipmentPage.value.total = data.total || 0
|
|
|
|
+
|
|
|
|
+ //去重
|
|
|
|
+ let uniqueArray = getnewArr(checkList.value)
|
|
|
|
+ deviceTableKeys.value = uniqueArray
|
|
|
|
+
|
|
|
|
+ if (uniqueArray.length > 0) {
|
|
|
|
+ uniqueArray.forEach((item) => {
|
|
|
|
+ if (item.deviceClassId === equipmentmenuKey.value) {
|
|
|
|
+ deviceTableData.value.forEach((ele) => {
|
|
|
|
+ if (ele.id === item.id) {
|
|
|
|
+ item = ele
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ deviceTableRef.value?.toggleRowSelection(item, true)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ deviceTableData.value = []
|
|
|
|
+ equipmentPage.value.total = 0
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//多选
|
|
|
|
+const deviceTableKeys = ref([])
|
|
|
|
+//选中的设备仪器
|
|
|
|
+const checkList = ref([])
|
|
|
|
+const deviceTableSelection = (rows) => {
|
|
|
|
+
|
|
|
|
+ // deviceTableKeys.value = rows
|
|
|
|
+ if (rows.length > 0) {
|
|
|
|
+ rows.forEach((item) => {
|
|
|
|
+ checkList.value.push(item)
|
|
|
|
+ })
|
|
|
|
+ //去重
|
|
|
|
+ let uniqueArray = getnewArr(checkList.value)
|
|
|
|
+ deviceTableKeys.value = uniqueArray
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//确认引用
|
|
|
|
+const deviceLoad = ref(false)
|
|
|
|
+const deviceModalSave = async () => {
|
|
|
|
+ if (deviceTableKeys.value.length > 0) {
|
|
|
|
+ let ids = arrToId(deviceTableKeys.value)
|
|
|
|
+ deviceLoad.value = true
|
|
|
|
+ const { error, code, data, msg } = await codeApi.getDeviceInfoByIds({
|
|
|
|
+ deviceInfoIds: ids,
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ deviceLoad.value = false
|
|
|
|
+ if (!error && code === 200) {
|
|
|
|
+ window.$message.success(msg)
|
|
|
|
+ let resArr = getArrValue(data)
|
|
|
|
+ if (resArr.length > 0) {
|
|
|
|
+ resArr.forEach((item)=>{
|
|
|
|
+ basicInfoData.value.trailDeviceUseInfoDTOS.push(item)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ deviceModalClose()
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ window?.$message?.warning('请先选择引用容器设备')
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ deviceTableKeys.value = []
|
|
|
|
+ checkList.value = []
|
|
|
|
+ temp = []
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+//关闭
|
|
|
|
+const deviceModalClose = () => {
|
|
|
|
+ deviceModal.value = false
|
|
|
|
+ deviceTableKeys.value = []
|
|
|
|
+ checkList.value = []
|
|
|
|
+ temp = []
|
|
|
|
+}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|