From 74b848570567ef70c42a09c1aef8d53c9a8a562d Mon Sep 17 00:00:00 2001 From: dushixiang <798148596@qq.com> Date: Mon, 4 Jan 2021 23:06:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BA=86=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/api/asset.go | 4 ++++ web/src/components/asset/Asset.js | 4 +++- web/src/components/asset/AssetModal.js | 18 ++++++------------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/api/asset.go b/pkg/api/asset.go index 2108aa7..755a068 100644 --- a/pkg/api/asset.go +++ b/pkg/api/asset.go @@ -72,6 +72,10 @@ func AssetUpdateEndpoint(c echo.Context) error { item.CredentialId = "-" } + if len(item.Tags) == 0 { + item.Tags = "-" + } + model.UpdateAssetById(&item, id) return Success(c, nil) diff --git a/web/src/components/asset/Asset.js b/web/src/components/asset/Asset.js index 29c4962..ab72f46 100644 --- a/web/src/components/asset/Asset.js +++ b/web/src/components/asset/Asset.js @@ -235,7 +235,9 @@ class Asset extends Component { modalConfirmLoading: true }); - formData.tags = formData.tags.join(','); + if (formData['tagArr']) { + formData.tags = formData['tagArr'].join(','); + } if (formData.id) { // 向后台提交数据 diff --git a/web/src/components/asset/AssetModal.js b/web/src/components/asset/AssetModal.js index 8d844b1..9b2de35 100644 --- a/web/src/components/asset/AssetModal.js +++ b/web/src/components/asset/AssetModal.js @@ -1,4 +1,4 @@ -import React, {useEffect, useState} from 'react'; +import React, {useState} from 'react'; import {Form, Input, InputNumber, Modal, Radio, Select, Tooltip} from "antd/lib/index"; import {isEmpty} from "../../utils/utils"; @@ -31,10 +31,6 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa } let [accountTypes, setAccountTypes] = useState(initAccountTypes); - useEffect(() => { - setAccountType(model.accountType); - }); - for (let key in model) { if (model.hasOwnProperty(key)) { if (model[key] === '-') { @@ -43,14 +39,12 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa } } - let initAssetTags = [] + let initAssetTags = []; if (!isEmpty(model['tags'])) { initAssetTags = model['tags'].split(','); } let [assetTags, setAssetTags] = useState(initAssetTags); - console.log('初始元素', assetTags) - model['tags'] = undefined; const formItemLayout = { labelCol: {span: 6}, @@ -107,7 +101,6 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa } const handleTagsChange = v => { - console.log(v) setAssetTags(v); } @@ -213,14 +206,15 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa