|
@@ -45,8 +45,8 @@
|
|
|
<el-tag v-else type="info" effect="dark">未引用</el-tag>
|
|
|
</template>
|
|
|
<template #action="{ row }">
|
|
|
- <el-link v-if="row.id == dataId" type="warning" @click="rowCancel(row)">取消选择</el-link>
|
|
|
- <el-link v-else type="primary" @click="rowSelect(row)">选择</el-link>
|
|
|
+ <el-link v-if="dataIds.indexOf(row.id) !== -1" type="warning" @click="rowCancel(row.id)">取消选择</el-link>
|
|
|
+ <el-link v-else type="primary" @click="rowSelect(row.id)">选择</el-link>
|
|
|
<!-- el-link v-if="row.key24 === 2" type="info">选择</el-link -->
|
|
|
</template>
|
|
|
</hc-table>
|
|
@@ -61,7 +61,7 @@
|
|
|
import { onMounted, ref, watch } from 'vue'
|
|
|
import { useAppStore } from '~src/store'
|
|
|
import { getErtractInfo } from '~api/other'
|
|
|
-import { getArrValue } from 'js-fast-way'
|
|
|
+import { deepClone, getArrValue, isNullES } from 'js-fast-way'
|
|
|
import mainApi from '~api/tentative/acquisition/data'
|
|
|
|
|
|
//事件
|
|
@@ -83,9 +83,9 @@ const curId = defineModel('modelValue', {
|
|
|
})
|
|
|
|
|
|
//监听
|
|
|
-const dataId = ref(curId.value)
|
|
|
+const dataIds = ref([])
|
|
|
watch(() => curId.value, (id) => {
|
|
|
- dataId.value = id
|
|
|
+ dataIds.value = isNullES(id) ? [] : id.split(',')
|
|
|
})
|
|
|
|
|
|
//分割配置
|
|
@@ -310,17 +310,32 @@ const getTableData = async () => {
|
|
|
}
|
|
|
|
|
|
//选择
|
|
|
-const rowSelect = (row) => {
|
|
|
- dataId.value = row.id
|
|
|
- curId.value = row.id
|
|
|
- emit('change', row.id)
|
|
|
+const rowSelect = (id) => {
|
|
|
+ const ids = deepClone(dataIds.value)
|
|
|
+ if (ids.length >= 7) {
|
|
|
+ window?.$message.warning('最多只能选择7条数据关联')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (ids.indexOf(id) !== -1) {
|
|
|
+ window?.$message.warning('当前选择的数据已关联')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ids.push(id)
|
|
|
+ dataIds.value = ids
|
|
|
+ curId.value = ids.join(',')
|
|
|
+ emit('change', ids.join(','))
|
|
|
}
|
|
|
|
|
|
//取消选择
|
|
|
-const rowCancel = () => {
|
|
|
- dataId.value = null
|
|
|
- curId.value = null
|
|
|
- emit('change', '')
|
|
|
+const rowCancel = (id) => {
|
|
|
+ const ids = deepClone(dataIds.value)
|
|
|
+ const index = ids.indexOf(id)
|
|
|
+ if (index !== -1) {
|
|
|
+ ids.splice(index, 1)
|
|
|
+ }
|
|
|
+ dataIds.value = ids
|
|
|
+ curId.value = ids.join(',')
|
|
|
+ emit('change', ids.join(','))
|
|
|
}
|
|
|
</script>
|
|
|
|