|
@@ -14,7 +14,8 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="应用程序" :rules="{required: true, message: '应用程序不能为空', trigger: 'blur'}" v-if="form.objType==1">
|
|
|
+ <el-form-item label="应用程序" :rules="{required: true, message: '应用程序不能为空', trigger: 'blur'}"
|
|
|
+ v-if="form.objType==1">
|
|
|
<el-select
|
|
|
v-model="form.appId"
|
|
|
filterable
|
|
@@ -36,8 +37,6 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
-
|
|
|
-
|
|
|
<el-form-item label="对象名称" prop="objName">
|
|
|
<el-input v-model="form.objName" placeholder="请输入对象名称"/>
|
|
|
</el-form-item>
|
|
@@ -50,17 +49,18 @@
|
|
|
</el-form>
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
-import { listApp } from "@/api/obj/app";
|
|
|
-import { addObj } from "@/api/obj/obj";
|
|
|
-import {ref} from "vue";
|
|
|
+import {listApp} from "@/api/obj/app";
|
|
|
+import {addObj, getObj,updateObj} from "@/api/obj/obj";
|
|
|
+import {nextTick, onMounted, ref} from "vue";
|
|
|
|
|
|
-const {proxy,emit} = getCurrentInstance();
|
|
|
+const props = defineProps(['rowId'])
|
|
|
+const {proxy, emit} = getCurrentInstance();
|
|
|
const {biz_type} = proxy.useDict('biz_type');
|
|
|
-const form=ref({})
|
|
|
+const form = ref({})
|
|
|
const loading = ref(false)
|
|
|
-const options=ref([])
|
|
|
+const options = ref([])
|
|
|
|
|
|
-const rules= {
|
|
|
+const rules = {
|
|
|
objType: [
|
|
|
{required: true, message: "业务类型不能为空", trigger: "change"}
|
|
|
],
|
|
@@ -75,7 +75,30 @@ const rules= {
|
|
|
],
|
|
|
}
|
|
|
|
|
|
-const resetForm=()=>{
|
|
|
+// watchEffect(() => {
|
|
|
+// if (props.rowId) {
|
|
|
+// nextTick(()=>{
|
|
|
+// editForm()
|
|
|
+// })
|
|
|
+// }
|
|
|
+// })
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ if (props.rowId) {
|
|
|
+ nextTick(() => {
|
|
|
+ editForm()
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const editForm = () => {
|
|
|
+ getObj(props.rowId).then(res => {
|
|
|
+ const {objId, objType, appId, objName, objAddr, objPort} = res.data
|
|
|
+ form.value = {objId, objType, appId, objName, objAddr, objPort}
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+const resetForm = () => {
|
|
|
form.value = {
|
|
|
objId: null,
|
|
|
objType: null,
|
|
@@ -87,8 +110,7 @@ const resetForm=()=>{
|
|
|
proxy.resetForm("objRef");
|
|
|
}
|
|
|
|
|
|
-const remoteMethod=(appName:string)=>{
|
|
|
-
|
|
|
+const remoteMethod = (appName: string) => {
|
|
|
if (appName) {
|
|
|
const params = {
|
|
|
pageNum: 1,
|
|
@@ -96,8 +118,8 @@ const remoteMethod=(appName:string)=>{
|
|
|
appName,
|
|
|
}
|
|
|
loading.value = true
|
|
|
- listApp(params).then(res=>{
|
|
|
- options.value = res.rows.map(item=>{
|
|
|
+ listApp(params).then(res => {
|
|
|
+ options.value = res.rows.map(item => {
|
|
|
return {
|
|
|
value: item.appId,
|
|
|
label: item.appName
|
|
@@ -113,16 +135,20 @@ const remoteMethod=(appName:string)=>{
|
|
|
const submitForm = () => {
|
|
|
proxy.$refs.objRef.validate(valid => {
|
|
|
if (valid) {
|
|
|
- addObj(form.value).then(response => {
|
|
|
+ const req = form.value.objId !==null ? updateObj : addObj
|
|
|
+ req(form.value).then(response => {
|
|
|
// proxy.$modal.msgSuccess("新增成功");
|
|
|
resetForm();
|
|
|
- emit("nextStep",1)
|
|
|
+ emit("updateData", response)
|
|
|
+ nextTick(()=>{
|
|
|
+ emit("nextStep", 1)
|
|
|
+ })
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-defineExpose({resetForm,submitForm})
|
|
|
+defineExpose({resetForm, submitForm})
|
|
|
|
|
|
</script>
|
|
|
<style scoped lang="scss">
|