2024-03-27 20:29:51 +08:00
|
|
|
<template>
|
2024-04-01 11:16:28 +08:00
|
|
|
<el-dialog draggable v-model="dialogVisible" title="模板绑定" width="500px" :before-close="handleClose">
|
2024-03-27 20:29:51 +08:00
|
|
|
<el-tree
|
|
|
|
|
default-expand-all
|
|
|
|
|
show-checkbox
|
|
|
|
|
node-key="id"
|
|
|
|
|
:data="dataTree"
|
|
|
|
|
:expand-on-click-node="false"
|
|
|
|
|
ref="tree"
|
|
|
|
|
style="height: 440px; overflow-y: auto"
|
|
|
|
|
>
|
|
|
|
|
<template #default="{ node, data }">
|
|
|
|
|
<span class="custom-tree-node">
|
|
|
|
|
<span>{{ data.name }}</span>
|
|
|
|
|
<span>
|
|
|
|
|
<el-switch
|
|
|
|
|
v-model="data.activation"
|
|
|
|
|
active-value="1"
|
|
|
|
|
inactive-value="0"
|
|
|
|
|
:active-text="data.activation == 1 ? '激活 ' : '未激活'"
|
|
|
|
|
/>
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-tree>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div class="dialog-footer">
|
2024-03-28 15:21:58 +08:00
|
|
|
<el-button type="primary" @click="bind">绑定</el-button>
|
2024-03-27 20:29:51 +08:00
|
|
|
<el-button @click="handleClose">取消</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
import { ElMessageBox } from 'element-plus'
|
|
|
|
|
import { useDictData } from '@/stores/dictData'
|
2024-03-28 15:21:58 +08:00
|
|
|
import { getDataByTempId, updateBindTemplate } from '@/api/harmonic-boot/luckyexcel'
|
2024-03-27 20:29:51 +08:00
|
|
|
const emit = defineEmits(['shutDown'])
|
|
|
|
|
const dictData = useDictData()
|
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
const keyarr: any = ref([])
|
|
|
|
|
const idarr: any = ref([])
|
|
|
|
|
const dataTree: any = ref([])
|
|
|
|
|
const area = ref(dictData.state.area)
|
|
|
|
|
|
|
|
|
|
const handleClose = () => {
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
// emit('handleClose')
|
|
|
|
|
}
|
|
|
|
|
const open = (row: any) => {
|
|
|
|
|
dialogVisible.value = true
|
|
|
|
|
getDataByTempId({ id: row.id }).then(res => {
|
|
|
|
|
res.data.forEach(item => {
|
|
|
|
|
keyarr.value.push({
|
|
|
|
|
name: item.deptName,
|
|
|
|
|
id: item.deptId,
|
|
|
|
|
activation: item.activation
|
|
|
|
|
})
|
|
|
|
|
idarr.value.push({ id: item.deptId })
|
|
|
|
|
})
|
|
|
|
|
gettreeData(area.value, keyarr.value)
|
|
|
|
|
dataTree.value = area.value
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
//过滤数据
|
|
|
|
|
const gettreeData = (mdata, ids) => {
|
|
|
|
|
mdata.forEach(m => {
|
|
|
|
|
ids.forEach(n => {
|
|
|
|
|
if (m.id == n.id && n.activation == 1) {
|
|
|
|
|
m.activation = 1
|
|
|
|
|
} else {
|
|
|
|
|
m.activation = 0
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (m.children != null || m.children.length > 0) {
|
|
|
|
|
gettreeData(m.children, ids)
|
|
|
|
|
} else {
|
|
|
|
|
m.children = null
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-03-28 15:21:58 +08:00
|
|
|
// 绑定
|
2024-04-01 11:16:28 +08:00
|
|
|
const bind = () => {
|
|
|
|
|
updateBindTemplate().then(res => {
|
2024-03-28 15:21:58 +08:00
|
|
|
// ElMessage.success('绑定成功')
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-03-27 20:29:51 +08:00
|
|
|
defineExpose({ open })
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.custom-tree-node {
|
|
|
|
|
flex: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
padding-right: 8px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|