提交 f1c61c91 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

create and delete node

上级 51865f6c
......@@ -24,6 +24,7 @@ var (
ResponseParseErr = ResponseCode{6000, "Json Parse Error"}
NeedInitErr = ResponseCode{1000, "Data Not Init"}
ErrDirNotEmpty = ResponseCode{1100, "Dir Not Empty Error"}
ErrZentaoConfig = ResponseCode{2000, "Zentao Config Error"}
ErrZentaoRequest = ResponseCode{3000, "zentao request Error"}
ErrRecordNotExist = ResponseCode{4000, "Record Not Found"}
......
......@@ -81,13 +81,13 @@ func (c *TestScriptCtrl) Create(ctx iris.Context) {
ctx.JSON(c.ErrResp(commConsts.CommErr, err.Error()))
}
err = c.TestScriptService.CreateNode(req)
pth, err := c.TestScriptService.CreateNode(req)
if err != nil {
ctx.JSON(c.ErrResp(commConsts.CommErr, err.Error()))
return
}
ctx.JSON(c.SuccessResp(nil))
ctx.JSON(c.SuccessResp(pth))
}
func (c *TestScriptCtrl) UpdateCode(ctx iris.Context) {
......@@ -134,7 +134,7 @@ func (c *TestScriptCtrl) Delete(ctx iris.Context) {
err = c.TestScriptService.Delete(req.Path)
if err != nil {
ctx.JSON(c.ErrResp(commConsts.CommErr, err.Error()))
ctx.JSON(c.ErrResp(commConsts.ErrDirNotEmpty, ""))
return
}
......
......@@ -126,7 +126,7 @@ func (s *TestScriptService) GetCaseIdsFromReport(workspaceId int, seq, scope str
return
}
func (s *TestScriptService) CreateNode(req serverDomain.CreateScriptReq) (err error) {
func (s *TestScriptService) CreateNode(req serverDomain.CreateScriptReq) (pth string, err error) {
name := req.Name
extName := fileUtils.GetExtNameWithoutDot(name)
mode := req.Mode
......@@ -146,7 +146,7 @@ func (s *TestScriptService) CreateNode(req serverDomain.CreateScriptReq) (err er
dir = filepath.Dir(target)
}
pth := filepath.Join(dir, name)
pth = filepath.Join(dir, name)
if typ == commConsts.CreateDir {
fileUtils.MkDirIfNeeded(pth)
} else {
......@@ -177,7 +177,7 @@ func (s *TestScriptService) UpdateName(script serverDomain.TestScript) (err erro
}
func (s *TestScriptService) Delete(pth string) (err error) {
os.Remove(pth)
err = os.Remove(pth)
return
}
......@@ -143,6 +143,8 @@ export default {
'error_detail': 'Error Detail',
'save_success': 'Save successfully.',
'save_fail': 'Save failed.',
'create_success': 'Create successfully.',
'create_fail': 'Create failed.',
'expand_all': 'Expand',
'collapse_all': 'Collapse',
......@@ -218,6 +220,7 @@ export default {
'biz_401': 'UnAuthorized',
'biz_1000': 'Data Not Init',
'biz_1100': 'Can not delete dir that is not empty.',
'biz_2000': 'Zentao Config Failed',
'biz_4000': 'Record Not Found',
'biz_5000': 'Not Available',
......
......@@ -142,6 +142,8 @@ export default {
'error_detail': '错误详情',
'save_success': '保存成功',
'save_fail': '保存失败',
'create_success': '创建成功',
'create_fail': '创建失败',
'expand_all': '展开',
'collapse_all': '收缩',
......@@ -218,6 +220,7 @@ export default {
'biz_401': '未授权',
'biz_1000': '数据为初始化',
'biz_1100': '无法删除非空目录。',
'biz_2000': '禅道配置失败',
'biz_3000': '禅道请求错误',
'biz_4000': '记录不存在',
......
......@@ -567,6 +567,22 @@ export default defineComponent({
scriptStore.dispatch('Script/createScript', {
name: model.name, mode: mode, type: type, target: rightClickedNode.path,
workspaceId: rightClickedNode.workspaceId, productId: currProduct.value.id,
}).then((result) => {
if (result) {
notification.success({message: t('create_success')});
nameFormVisible.value = false
if (mode == 'child') {
expandedKeys.value.push(rightClickedNode.path)
}
if (type === 'dir') {
expandedKeys.value.push(result)
}
setExpandedKeys(currSite.value.id, currProduct.value.id, expandedKeys.value)
} else {
notification.error({message: t('create_fail')});
}
})
}
......
......@@ -138,12 +138,16 @@ const StoreModel: ModuleType = {
return data.done
},
async createScript({ commit }, payload: any) {
async createScript({ commit , dispatch, state}, payload: any) {
try {
await create(payload);
return true;
const jsn = await create(payload);
const path = jsn.data
await dispatch('listScript', state.queryParams)
return path;
} catch (error) {
return false;
return ''
}
},
async updateScript({ commit }, payload: any ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册