8
0
ZaiZai vor 1 Jahr
Ursprung
Commit
f287988625

+ 8 - 0
src/api/modules/exctab/exceltab.js

@@ -176,4 +176,12 @@ export default {
             params: { ids },
         })
     },
+    //新增字段信息
+    async addColByTabId(form) {
+        return HcApi({
+            url: '/api/blade-manager/exctabcell/save',
+            method: 'post',
+            data: form,
+        })
+    },
 }

+ 52 - 5
src/views/exctab/element/add-col-tab.vue

@@ -1,6 +1,24 @@
 <template>
-    <hc-dialog v-model="isShow" ui="hc-exctab-element-add-col-tab" title="添加新元素字段" widths="800px" :padding="false" @close="dialogClose">
-        11111
+    <hc-dialog v-model="isShow" ui="hc-exctab-element-add-col-tab" title="添加新元素字段" widths="800px" :padding="false" :is-close="false" @close="dialogClose">
+        <template #extra>
+            <el-button type="primary" size="small" @click="addTableData">合成文本</el-button>
+        </template>
+        <hc-table ref="tabRef" :column="tableColumn" :datas="tableData" :is-index="false">
+            <template #textInfo="{ row }">
+                <hc-table-input v-model="row.textInfo" />
+            </template>
+            <template #textElementType="{ row }">
+                <el-select v-model="row.textElementType" filterable block>
+                    <el-option v-for="item in dataType" :key="item.value" :label="item.label" :value="item.value" />
+                </el-select>
+            </template>
+            <template #textDeviation="{ row }">
+                <hc-table-input v-model="row.textDeviation" />
+            </template>
+            <template #action="{ index }">
+                <el-link type="danger" @click="delRowClick(index)">删除</el-link>
+            </template>
+        </hc-table>
         <template #footer>
             <el-button hc-btn @click="dialogClose">取消</el-button>
             <el-button hc-btn type="primary" :loading="submitLoading" @click="dialogSubmit">提交</el-button>
@@ -9,9 +27,9 @@
 </template>
 
 <script setup>
-import { nextTick, ref, watch } from 'vue'
+import { ref, watch } from 'vue'
 import { getDictionaryData } from '~uti/tools'
-import { getArrValue, getObjValue, isNullES } from 'js-fast-way'
+import { getObjValue } from 'js-fast-way'
 import mainApi from '~api/exctab/exceltab'
 
 const props = defineProps({
@@ -42,19 +60,46 @@ watch(isShow, (val) => {
 
 //获取数据详情
 const getInfoData = () => {
-    console.log(dataInfo.value)
     getDataType()
 }
 
+//元素表格
+const tabRef = ref(null)
+const tableColumn = [
+    { key: 'textInfo', name: '元素名称' },
+    { key: 'textElementType', name: '数据类型' },
+    { key: 'textDeviation', name: '允许偏差值' },
+    { key: 'action', name: '操作', width: 80, align: 'center' },
+]
+const tableData = ref([])
+
 //获取元素类型
 const dataType = ref([])
 const getDataType = async () => {
     dataType.value = await getDictionaryData('data_type')
 }
 
+//新增元素
+const addTableData = () => {
+    tableData.value.push({
+        exctabId: dataInfo.value.id,
+        textInfo: '',
+    })
+}
+
+//删除
+const delRowClick = (index) => {
+    tableData.value.splice(index, 1)
+}
+
 //提交
 const submitLoading = ref(false)
 const dialogSubmit = async () => {
+    submitLoading.value = true
+    const { isRes } = await mainApi.addColByTabId(tableData.value)
+    submitLoading.value = false
+    if (!isRes) return
+    window.$message.success('操作成功')
     emit('finish')
 }
 
@@ -62,6 +107,8 @@ const dialogSubmit = async () => {
 const dialogClose = () => {
     isShow.value = false
     submitLoading.value = false
+    tableData.value = []
+    dataInfo.value = {}
     emit('close')
 }
 </script>

+ 7 - 5
src/views/exctab/element/index.vue

@@ -28,13 +28,13 @@
             <template #right>
                 <hc-card>
                     <template #header>
-                        <el-button color="#2550A2" size="small" class="text-white">关联WBS并创建元素</el-button>
-                        <el-button color="#FF986A" size="small" class="text-white">添加到元素库</el-button>
+                        <el-button color="#2550A2" size="small" class="text-white" :disabled="!isTreeNode">关联WBS并创建元素</el-button>
+                        <el-button color="#FF986A" size="small" class="text-white" :disabled="!isTreeNode">添加到元素库</el-button>
                         <!-- el-button color="#567722" size="small" class="text-white">元素匹配</el-button>
                         <el-button color="#67C23B" size="small" class="text-white">调整表单</el-button -->
                     </template>
                     <template #extra>
-                        <el-button type="primary" size="small" @click="addColByTab">新增</el-button>
+                        <el-button type="primary" size="small" :disabled="!isTreeNode" @click="addColByTab">新增</el-button>
                     </template>
                     <hc-table ref="tabRef" :column="tableColumn" :datas="tableData" :index-style="{ width: 60 }" @row-click="tableRowClick">
                         <template #textInfo="{ row }">
@@ -97,7 +97,7 @@ watch(isShow, (val) => {
 
 //处理相关数据
 const getDataApi = () => {
-    console.log(dataInfo.value)
+    getDataType()
 }
 
 //树搜索
@@ -144,15 +144,17 @@ const treeLoadNode = async ({ item, level }, resolve) => {
 }
 
 //树节点被点击
+const isTreeNode = ref(false)
 const nodeInfo = ref({})
 const treeNodeTap = async ({ data }) => {
     nodeInfo.value = data
     if (data.fileType !== 3) {
+        isTreeNode.value = false
         return
     }
     await getExcelHtmlCol(data.id)
-    getDataType().then()
     await getTableData()
+    isTreeNode.value = true
 }
 
 //获取excel模板