Skip to content

Commit 8ff8eaf

Browse files
committed
完成bug内容编辑器操作
1 parent 1fa95a9 commit 8ff8eaf

File tree

211 files changed

+18808
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+18808
-71
lines changed

application/index/controller/Bug.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public function edit()
137137
return view('bug/edit');
138138
}else{
139139

140+
return BugService::edit($this->request->param('id'),$this->user_id,$this->request->post());
140141
}
141142
}
142143

application/index/service/Bug.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,55 @@ public static function handle($bug_id,$user_id,$data)
163163
return ServiceResult::Success([],'提交成功');
164164

165165
}
166+
167+
/**
168+
* 修改bug内容
169+
* @param $id
170+
* @param $user_id
171+
* @param $data
172+
*
173+
* @return ServiceResult
174+
*/
175+
public static function edit($id,$user_id,$data)
176+
{
177+
$bug = BugModel::get($id);
178+
179+
if(!$bug)
180+
{
181+
return ServiceResult::Error('数据不存在');
182+
}
183+
184+
$bug->startTrans();
185+
186+
try{
187+
$saveData = [
188+
'bug_content'=>$data['bug_content'],
189+
'bug_status'=>$data['bug_status'],
190+
'priority_status'=>$data['priority_status'],
191+
'module_id'=>$data['module_id'],
192+
'version_id'=>$data['version_id'],
193+
'bug_title'=>$data['bug_title'],
194+
];
195+
196+
$save = $bug->save($saveData);
197+
198+
}catch (\Exception $e)
199+
{
200+
$bug->rollback();
201+
202+
return ServiceResult::Error($e->getMessage());
203+
}
204+
205+
if($save !== false)
206+
{
207+
$bug->commit();
208+
209+
return ServiceResult::Success([],'修改成功');
210+
}else{
211+
$bug->rollback();
212+
213+
return ServiceResult::Error('修改失败');
214+
}
215+
216+
}
166217
}

application/index/view/bug/edit.html

Lines changed: 37 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{extend name="extend/main" /}
2+
{block name="head"}
3+
4+
{/block}
25
{block name="content"}
36
<div class="container-fluid">
47
<div class="row">
@@ -24,7 +27,7 @@ <h4 class="card-title">{:lang('Edit Bug')}</h4>
2427
<div class="col-sm-10">
2528
<div class="form-group label-floating is-empty">
2629
<label class="control-label"></label>
27-
<input type="text" class="form-control" value="{$bug.bug_title}" >
30+
<input type="text" class="form-control" value="{$bug.bug_title}" name="bug_title" >
2831
<span class="help-block"></span>
2932
</div>
3033
</div>
@@ -100,12 +103,22 @@ <h4 class="card-title">{:lang('Edit Bug')}</h4>
100103
<div class="col-sm-10">
101104
<div class="form-group label-floating is-empty">
102105
<label class="control-label"></label>
103-
{$bug.bug_content}
106+
<textarea name="bug_content" class="form-control " cols="100" rows="10" id="bug_content">{$bug.bug_content}</textarea>
107+
104108
</div>
105109
</div>
106110
</div>
107111

108-
112+
<div class="row">
113+
<label class="col-sm-2 label-on-left"> </label>
114+
<div class="col-sm-10">
115+
<div class="form-group label-floating is-empty">
116+
<label class="control-label"></label>
117+
<input type="button" class="btn btn-success" value="{:lang('Submit')}" id="edit_bug_log">
118+
<span class="help-block"></span>
119+
</div>
120+
</div>
121+
</div>
109122
</div>
110123
</form>
111124
</div>
@@ -114,71 +127,32 @@ <h4 class="card-title">{:lang('Edit Bug')}</h4>
114127
</div>
115128
{/block}
116129
{block name="footer"}
130+
<script charset="utf-8" src="/static/kindeditor/kindeditor-all-min.js"></script>
131+
<script charset="utf-8" src="/static/kindeditor/lang/zh-CN.js"></script>
117132
<script>
118-
$(function(){
119-
var isRequest = false;
120-
121-
$('#user_radio_1').click(function () {
122-
$('#to_other_user').hide();
133+
KindEditor.ready(function(K) {
134+
window.editor = K.create('#bug_content', {
135+
filterMode : true,
136+
width:'100%',
137+
height:500
123138
});
139+
});
140+
</script>
141+
<script>
142+
$(function(){
124143

125-
$('#user_radio').click(function(){
126-
127-
$('#to_other_user').removeClass('hide');
128-
129-
$('#to_other_user').show();
130-
131-
if(isRequest)
132-
{
133-
134-
}else{
135-
136-
axios.post('/index/bug/project_users', {
137-
id:'{$bug.project_id}'
138-
}).then(function (response) {
139-
//拼接select
140-
if(response.data.status == 1)
141-
{
142-
isRequest = true;
143-
144-
for(var i =0;i<response.data.data.length;i++)
145-
{
146-
$('#to_other_user').append('<option value='+response.data.data[i].user_id+'>'+response.data.data[i].username+'</option>');
147-
}
148-
149-
$('#to_other_user').show();
150-
151-
}else{
152-
$('#to_other_user').show();
153-
}
154-
155-
}).catch(function (error) {
156-
console.log(error);
157-
});
158-
159-
$('#to_other_user').show();
160-
}
161-
})
162-
163-
$('#add_bug_log').click(function(){
164-
165-
166-
var current_user_id = '{$bug.current_user_id}';
167-
var status = 0;
168-
if($('#user_radio').is(':checked'))
169-
{
170-
current_user_id = $('#to_other_user').val();
171-
}else{
172-
// 待审核状态 处理完成
173-
status = 1;
174-
}
144+
$('#edit_bug_log').click(function(){
175145

146+
editor.sync();
176147

177-
axios.post('/index/bug/handle', {
178-
content:$('input[name=content]').val(),
179-
bug_id:'{$bug.id}',
180-
current_user_id:current_user_id,
181-
status:status
148+
axios.post('/index/bug/edit', {
149+
bug_content:document.getElementById('bug_content').value,
150+
id:'{$bug.id}',
151+
bug_status:$('select[name=bug_status]').val(),
152+
priority_status:$('select[name=priority_status]').val(),
153+
module_id:$('select[name=module_id]').val(),
154+
version_id:$('select[name=version_id]').val(),
155+
bug_title:$('input[name=bug_title]').val()
182156
}).then(function (response) {
183157

184158
swal({
@@ -188,13 +162,6 @@ <h4 class="card-title">{:lang('Edit Bug')}</h4>
188162
showConfirmButton: false
189163
}).catch(swal.noop)
190164

191-
if(response.data.status == 1)
192-
{
193-
setTimeout(function(){
194-
window.location.reload();
195-
},2100);
196-
197-
}
198165

199166
}).catch(function (error) {
200167
console.log(error);

application/index/view/bug/handle.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ <h4 class="card-title">{:lang('Handle Bug')}</h4>
106106
<div class="col-sm-10">
107107
<div class="form-group label-floating is-empty">
108108
<label class="control-label"></label>
109-
{$bug.bug_content}
109+
<div class="row">
110+
111+
112+
<?php echo html_entity_decode($bug['bug_content']);?>
113+
</div>
110114
</div>
111115
</div>
112116
</div>
@@ -204,6 +208,7 @@ <h4 class="card-title">{:lang('Handle Bug')}</h4>
204208
</div>
205209
{/block}
206210
{block name="footer"}
211+
207212
<script>
208213
$(function(){
209214
var isRequest = false;

application/index/view/extend/main.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<!--<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700%7CMaterial+Icons" />
2222
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">-->
2323
<link href="/static/iconfont/material-icons.css" rel="stylesheet">
24+
{block name="head"}{/block}
2425
</head>
2526

2627
<body>

config/template.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'__CSS__'=>'/static/css',
3737
'__JS__'=>'/static/js',
3838
'__IMG__'=>'/static/img',
39+
'__UEDITOR__'=>'/static/UEditor',
3940
],
4041

4142
];

public/static/kindeditor/kindeditor-all-min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)