|
@@ -36,13 +36,14 @@
|
|
|
</div>
|
|
|
<div class="action">
|
|
|
<el-button hc-btn class="mr-4" :loading="submitLoading" @click="saveAndExit">保存并退出</el-button>
|
|
|
+ <el-button hc-btn type="success" :loading="submitLoading" @click="saveAndBackStep">保存并返回上一步</el-button>
|
|
|
<el-button hc-btn type="primary" :loading="submitLoading" @click="saveAndNextStep">保存并进入下一步</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onMounted, ref, watch } from 'vue'
|
|
|
+import { nextTick, onMounted, ref, watch } from 'vue'
|
|
|
import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
|
import projectApi from '~api/project/project'
|
|
|
import contractApi from '~api/project/contract'
|
|
@@ -55,7 +56,7 @@ const props = defineProps({
|
|
|
})
|
|
|
|
|
|
//事件
|
|
|
-const emit = defineEmits(['close', 'next'])
|
|
|
+const emit = defineEmits(['close', 'next', 'back'])
|
|
|
|
|
|
//监听数据
|
|
|
const dataInfo = ref(props.data)
|
|
@@ -128,6 +129,7 @@ const getRightTreeApi = async () => {
|
|
|
})
|
|
|
rightTreeData.value = getArrValue(data)
|
|
|
rightLoading.value = false
|
|
|
+ setRightTree()
|
|
|
}
|
|
|
|
|
|
//左边树被展开
|
|
@@ -249,22 +251,79 @@ const delTreeClick = () => {
|
|
|
checkRightTreeChange()
|
|
|
}
|
|
|
|
|
|
+const setRightTree = () => {
|
|
|
+ let ids = []
|
|
|
+ const data = rightTreeData.value
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ getLeafIds(ids, data[i])
|
|
|
+ }
|
|
|
+ //在左边把右边的节点勾选上
|
|
|
+ const e = leftTreeRef.value
|
|
|
+ nextTick(() => {
|
|
|
+ e.setCheckedKeys(ids, true)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const getLeafIds = (ids, data) => {
|
|
|
+ if (data.children && data.children.length) {
|
|
|
+ for (let i = 0; i < data.children.length; i++) {
|
|
|
+ getLeafIds(ids, data.children[i])
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ids.push(data.id)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const getTreeAllId = async (name) => {
|
|
|
+ let tree
|
|
|
+ if (name === 'left') {
|
|
|
+ tree = leftTreeRef.value
|
|
|
+ } else if (name === 'right') {
|
|
|
+ tree = rightTreeRef.value
|
|
|
+ }
|
|
|
+ let ids = []
|
|
|
+ for (let i = 0; i < tree.data.length; i++) {
|
|
|
+ await getIds(ids, tree.data[i])
|
|
|
+ }
|
|
|
+ return ids.join(',')
|
|
|
+}
|
|
|
+
|
|
|
+const getIds = async (ids, data) => {
|
|
|
+ ids.push(data.id)
|
|
|
+ if (data.children && data.children.length) {
|
|
|
+ for (let i = 0; i < data.children.length; i++) {
|
|
|
+ await getIds(ids, data.children[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
//保存并退出
|
|
|
const saveAndExit = async () => {
|
|
|
- /*const isRes = await saveDataApi()
|
|
|
+ const isRes = await saveDataApi()
|
|
|
if (!isRes) return
|
|
|
- emit('close', dataInfo.value)*/
|
|
|
+ ///emit('close', dataInfo.value)
|
|
|
+}
|
|
|
+
|
|
|
+//保存并返回上一步
|
|
|
+const saveAndBackStep = async () => {
|
|
|
+ const isRes = await saveDataApi()
|
|
|
+ if (!isRes) return
|
|
|
+ //emit('back', dataInfo.value)
|
|
|
}
|
|
|
|
|
|
//保存并进入下一步
|
|
|
const saveAndNextStep = async () => {
|
|
|
- /*const isRes = await saveDataApi()
|
|
|
+ const isRes = await saveDataApi()
|
|
|
if (!isRes) return
|
|
|
- emit('next', dataInfo.value)*/
|
|
|
+ //emit('next', dataInfo.value)
|
|
|
}
|
|
|
|
|
|
+//保存
|
|
|
const submitLoading = ref(false)
|
|
|
+const saveDataApi = async () => {
|
|
|
+ const ids = await getTreeAllId('right')
|
|
|
+ console.log(ids)
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|