ZaiZai 8 meses atrás
pai
commit
ff35bacf9f

+ 0 - 1
src/components/table-form/components.vue

@@ -58,7 +58,6 @@ const matchingType = () => {
     border-radius: 3px;
     transition: border 0.2s;
     &:hover {
-        border-color: #1682f1;
         background: #eddac4;
     }
     &.cur {

+ 14 - 0
src/components/table-form/table-form.vue

@@ -156,6 +156,19 @@ const clearClick = async () => {
     }
 }
 
+//设置选中
+const setSelect = async (arr) => {
+    await clearClick()
+    if (arr.length <= 0) return
+    const boxs = await getAllComponents()
+    for (let i = 0; i < boxs.length; i++) {
+        const index = boxs[i].getAttribute('data-index')
+        if (arr.indexOf(index) > -1) {
+            boxs[i].classList.add('cur')
+        }
+    }
+}
+
 // 暴露出去
 defineExpose({
     getFormData,
@@ -163,6 +176,7 @@ defineExpose({
     setExcelHtml,
     unmountHtml,
     clearClick,
+    setSelect,
 })
 </script>
 

+ 8 - 2
src/views/exctab/element/index.vue

@@ -35,7 +35,7 @@
                         <el-button color="#FF986A" size="small" class="text-white">添加到元素库</el-button>
                         <el-button color="#2550A2" size="small" class="text-white">关联WBS并创建元素</el-button>
                     </template>
-                    <hc-table ref="tabRef" :column="tableColumn" :datas="tableData" :index-style="{ width: 60 }">
+                    <hc-table ref="tabRef" :column="tableColumn" :datas="tableData" :index-style="{ width: 60 }" @row-click="tableRowClick">
                         <template #textInfo="{ row }">
                             <hc-table-input v-model="row.textInfo" />
                         </template>
@@ -192,7 +192,7 @@ const excelClick = async (item) => {
     const arr = tableData.value
     let key = item.target.getAttribute('data-index')
     for (let i = 0; i < arr.length; i++) {
-        let xys = arr[i].xys.split(',')
+        let xys = isNullES(arr[i].xys) ? [] : arr[i].xys.split(',')
         if (xys.indexOf(key) > -1) {
             tabRef.value?.tableRef?.setCurrentRow(arr[i])
             await tableScrollToRow(i)
@@ -208,6 +208,12 @@ const tableScrollToRow = async (index) => {
     tabRef.value?.tableRef?.setScrollTop(row.offsetTop)
 }
 
+//表格的某一行被点击
+const tableRowClick = ({ row }) => {
+    let xys = isNullES(row.xys) ? [] : row.xys.split(',')
+    excelRef.value?.setSelect(xys)
+}
+
 //保存元素表格
 const saveRowClick = (row) => {