Эх сурвалжийг харах

试验,设备进场,接口调试

iZaiZaiA 2 жил өмнө
parent
commit
6a316969f3

+ 10 - 3
src/views/tentative/device/components/HcSelectTree.vue

@@ -1,5 +1,5 @@
 <template>
-    <el-popover :width="widths" :visible="visible" trigger="click">
+    <el-popover :width="widths" :visible="visible">
         <template #reference>
             <div class="form-item-div" :id="uuid" @click="itemClick">
                 <div class="lable truncate" v-if="nodeId && nodeTitle">{{nodeTitle}}</div>
@@ -7,14 +7,17 @@
                 <HcIcon name="arrow-down-s"/>
             </div>
         </template>
-        <TestTree ui="hc-select-tree" :projectId="projectId" :contractId="contractId" :wbsId="wbsId" @nodeTap="testTreeClick"/>
+        <div v-click-outside="onClickOutside">
+            <TestTree ui="hc-select-tree" :projectId="projectId" :contractId="contractId" :wbsId="wbsId" @nodeTap="testTreeClick"/>
+        </div>
     </el-popover>
 </template>
 
 <script setup>
-import {ref, watch, onMounted, nextTick} from "vue";
+import {ref, watch, nextTick} from "vue";
 import {getRandom} from "vue-utils-plus"
 import TestTree from "./TestTree.vue"
+import {ClickOutside as vClickOutside} from 'element-plus'
 
 const props = defineProps({
     modelValue: {
@@ -80,6 +83,10 @@ const itemClick = () => {
     visible.value = true
 }
 
+const onClickOutside = () => {
+    visible.value = false
+}
+
 //事件
 const emit = defineEmits(['update:modelValue', 'change'])
 

+ 2 - 2
src/views/tentative/device/components/TestTree.vue

@@ -1,6 +1,6 @@
 <template>
-    <ElTree class="hc-tree-node tree-line" :class="ui" ref="treeRef" :props="treeProps" :data="treeData"
-            highlight-current accordion node-key="primaryKeyId" @node-click="treeClick" :indent="0">
+    <ElTree class="hc-tree-node tree-line" :class="ui" ref="treeRef" :props="treeProps" :data="treeData" auto-expand-parent current-node-key="1570335808521502732"
+            highlight-current accordion :default-expanded-keys="['1570335808521502732']" node-key="primaryKeyId" @node-click="treeClick" :indent="0">
         <template #default="{ node, data }">
             <div class="data-custom-tree-node" :id="`${idPrefix}${data['primaryKeyId']}`">
                 <div class="label">{{ node.label }}</div>

+ 30 - 6
src/views/tentative/device/employ.vue

@@ -343,18 +343,27 @@ const tableImportSelection = (rows) => {
     })
 }
 
-
-
-//新增/编辑 材料进场
+//新增/编辑
 const addEditFormModal = ref(false)
 const addFormModalClick = () => {
+    addEditFormModel.value = {}
     addEditFormModal.value = true
 }
+
+//编辑
 const editFormModalClick = () => {
-    addEditFormModal.value = true
+    const keys = tableCheckedKeys.value
+    if (keys.length === 1) {
+        addEditFormModel.value = keys[0]
+        addEditFormModal.value = true
+    } else if (keys.length > 1) {
+        window?.$message?.warning('只能选择一条数据编辑')
+    }
 }
+
 const addEditFormModalClose = () => {
     addEditFormModal.value = false
+    addEditFormModel.value = {}
 }
 
 //新增/编辑 表单
@@ -437,8 +446,23 @@ const nodeMaterialChange = async (val) => {
 
 //新增/编辑 保存
 const addEditFormLoading = ref(false)
-const addEditFormClick = () => {
-
+const addEditFormClick = async () => {
+    const validate = await formValidate(addEditFormRef.value)
+    if (validate) {
+        addEditFormLoading.value = true
+        const { error, code } = await dataApi.submitForm({
+            ...addEditFormModel.value,
+            projectId: projectId.value,
+            contractId: contractId.value
+        })
+        //处理数据
+        addEditFormLoading.value = false
+        if (!error && code === 200) {
+            window?.$message?.success('操作成功')
+            addEditFormModal.value = false
+            await getTableData()
+        }
+    }
 }