|
@@ -34,7 +34,7 @@
|
|
|
</el-col>
|
|
|
<el-col :span="12" class="h-full">
|
|
|
<div class="right-card h-full">
|
|
|
- <hc-table :column="tableColumn" :datas="tableData" :is-index="false">
|
|
|
+ <hc-table :column="tableColumn" :datas="tableData" :is-index="false" :is-current-row="false">
|
|
|
<template #action="{ row }">
|
|
|
<el-link v-if="row.isLinkTable !== 2" type="primary" @click="rowRelation(row)">关联</el-link>
|
|
|
<el-link v-if="row.isLinkTable === 2" type="warning" @click="rowCancel(row)">取消关联</el-link>
|
|
@@ -52,10 +52,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { getArrValue, getObjValue } from 'js-fast-way'
|
|
|
import { nextTick, ref, watch } from 'vue'
|
|
|
-import mainApi from '~api/exctab/exceltab'
|
|
|
import { getDictionaryData } from '~uti/tools'
|
|
|
+import { formValidate, getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
|
+import mainApi from '~api/exctab/exceltab'
|
|
|
|
|
|
const props = defineProps({
|
|
|
info: {
|
|
@@ -124,6 +124,7 @@ const isWbsTree = ref(false)
|
|
|
const wbsModelChange = () => {
|
|
|
isWbsTree.value = false
|
|
|
tableData.value = []
|
|
|
+ tableList.value = []
|
|
|
const wbsId = formModel.value.wbsId
|
|
|
wbsModel.value.forEach(item => {
|
|
|
if (item.id === wbsId) {
|
|
@@ -157,10 +158,40 @@ const wbsTreeLoad = async (node, resolve) => {
|
|
|
}
|
|
|
|
|
|
//树节点被点击
|
|
|
-const wbsTreeClick = (data) => {
|
|
|
- console.log(data)
|
|
|
+const wbsForm = ref({})
|
|
|
+const wbsTreeClick = ({ id, type, nodeName }) => {
|
|
|
+ wbsForm.value = { id, wbsType: type, wbsName: nodeName }
|
|
|
+ const form = formModel.value
|
|
|
+ if (tableList.value.length <= 0) {
|
|
|
+ selectByNodeTable(id, type, form.id, form.wbsId)
|
|
|
+ } else {
|
|
|
+ let tag = true
|
|
|
+ tableList.value.forEach((item) => {
|
|
|
+ if (item.id === id) {
|
|
|
+ tableData.value = item.arrs
|
|
|
+ tag = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (tag) {
|
|
|
+ selectByNodeTable(id, type, form.id, form.wbsId)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+//获取数据
|
|
|
+const selectByNodeTable = async (id, type, formId, wbsId) => {
|
|
|
+ const { data } = await mainApi.selectByNodeTable({
|
|
|
+ id,
|
|
|
+ wbsType: type ?? '',
|
|
|
+ liunxId: formId ?? '',
|
|
|
+ projectid: wbsId ?? '',
|
|
|
+ })
|
|
|
+ const res = getArrValue(data)
|
|
|
+ res.forEach(item => {
|
|
|
+ item.changeTable = item.isLinkTable
|
|
|
+ })
|
|
|
+ tableData.value = res
|
|
|
+}
|
|
|
|
|
|
//基础表单
|
|
|
const formRef = ref(null)
|
|
@@ -184,21 +215,63 @@ const tableColumn = [
|
|
|
{ key: 'action', name: '操作', width: 80, align: 'center' },
|
|
|
]
|
|
|
const tableData = ref([])
|
|
|
-
|
|
|
+const tableList = ref([])
|
|
|
|
|
|
//关联
|
|
|
const rowRelation = (row) => {
|
|
|
-
|
|
|
+ row.isLinkTable = 2
|
|
|
+ setTableList()
|
|
|
}
|
|
|
|
|
|
//取消关联
|
|
|
const rowCancel = (row) => {
|
|
|
+ row.isLinkTable = 1
|
|
|
+ setTableList()
|
|
|
+}
|
|
|
|
|
|
+//处理数据
|
|
|
+const setTableList = () => {
|
|
|
+ const form = wbsForm.value
|
|
|
+ let tap = tableList.value.find((item) => {
|
|
|
+ return item.id === form.id
|
|
|
+ })
|
|
|
+ if (!tap) {
|
|
|
+ tableList.value.push({
|
|
|
+ id: form.id,
|
|
|
+ wbsType: form.wbsType,
|
|
|
+ wbsName: form.wbsName,
|
|
|
+ arrs: tableData.value,
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//提交
|
|
|
const submitLoading = ref(false)
|
|
|
const dialogSubmit = async () => {
|
|
|
+ const isValidate = await formValidate(formRef.value)
|
|
|
+ if (!isValidate) return false
|
|
|
+ submitLoading.value = true
|
|
|
+ let linkDataInfo = []
|
|
|
+ const list = tableList.value
|
|
|
+ if (list.length > 0) {
|
|
|
+ list.forEach(item => {
|
|
|
+ let linkIds = ''
|
|
|
+ item.arrs.forEach(data => {
|
|
|
+ if (data.isLinkTable !== data.changeTable) {
|
|
|
+ linkIds = `${linkIds}${linkIds !== '' ? ',' : ''}${data.pkeyId}_${data.isLinkTable}`
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (!isNullES(linkIds)) {
|
|
|
+ linkDataInfo.push({
|
|
|
+ id: item.id,
|
|
|
+ linkIds: linkIds,
|
|
|
+ wbsName: item.wbsName,
|
|
|
+ wbsType: item.wbsType,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log(linkDataInfo)
|
|
|
emit('finish')
|
|
|
}
|
|
|
|