Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
note-library
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6780167d
authored
May 13, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
up
parent
6c4da0ba
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
2 deletions
app/Http/Controllers/AjaxController.php
public/js/web/labelList.js
resources/views/web/labelList.blade.php
app/Http/Controllers/AjaxController.php
View file @
6780167d
...
...
@@ -118,8 +118,17 @@ Class AjaxController extends Controller
if
(
!
$tmpl
){
return
$this
->
ajaxReturn
(
-
1
,
"您只能修改自己创建的模板哦!"
);
}
$count
=
TemplateListModel
::
where
([
"create_userid"
=>
$request
->
user
->
userId
,
"template_name"
=>
$template_name
])
->
count
();
if
(
$count
>
0
){
return
$this
->
ajaxReturn
(
-
1
,
"模板名称不能重复哟!"
);
}
$tmpl
->
template_name
=
$template_name
;
$tmpl
->
save
();
$bk
=
$tmpl
->
save
();
if
(
$bk
===
false
){
return
$this
->
ajaxReturn
(
-
1
,
"修改模板失败!"
);
}
//此处推送到erp
if
(
!
$this
->
pushTemplateErp
(
intval
(
$id
))){
...
...
@@ -290,6 +299,55 @@ Class AjaxController extends Controller
}
/*
* 复制模板
*/
public
function
copy_template
(
$request
){
$id
=
$request
->
input
(
"t_id"
,
0
);
$copyTemplate
=
TemplateListModel
::
find
(
$id
);
if
(
!
$copyTemplate
){
return
$this
->
ajaxReturn
(
-
1
,
"没找到该模板相关信息"
);
}
try
{
DB
::
Connection
(
"label"
)
->
transaction
(
function
()
use
(
$copyTemplate
,
$request
)
{
$templateList
=
TemplateListModel
::
create
([
"template_name"
=>
$copyTemplate
->
template_name
.
"_copy"
.
"_"
.
time
(),
"create_userid"
=>
$request
->
user
->
userId
,
"create_username"
=>
$request
->
user
->
name
,
"create_time"
=>
time
(),
"update_time"
=>
time
(),
]);
if
(
!
$templateList
){
throw
new
\Exception
(
"复制模板失败"
,
-
1
);
}
//创建模板扩展信息 属性
$templateExtend
=
TemplateExtendModel
::
create
([
"template_id"
=>
$templateList
->
id
,
"html"
=>
$copyTemplate
->
template_extend
->
html
,
"attribute"
=>
$copyTemplate
->
template_extend
->
attribute
,
]);
if
(
!
$templateExtend
){
throw
new
\Exception
(
"复制模板失败"
,
-
1
);
}
//此处推送到erp
if
(
!
$this
->
pushTemplateErp
(
$templateList
->
id
)){
throw
new
\Exception
(
"模板信息推送至erp失败"
,
-
1
);
}
});
$data
=
[];
if
(
$copyTemplate
->
create_userid
==
"1000"
){
$data
=
[
"redictUrl"
=>
"/web/labelList"
];
}
return
$this
->
ajaxReturn
(
0
,
"复制模板成功"
,
$data
);
}
catch
(
\Exception
$e
){
return
$this
->
ajaxReturn
(
-
1
,
$e
->
getMessage
());
}
}
/**
* 编辑模板 获取模板详情
*/
...
...
public/js/web/labelList.js
View file @
6780167d
...
...
@@ -64,7 +64,9 @@ layui.use(['form', 'table', 'laydate'], function(){
layer
.
msg
(
resp
.
err_msg
);
// renderTable(); // 重新加载table
$
(
'.search'
).
trigger
(
"click"
);
// 触发搜索按钮
if
(
typeof
resp
.
data
.
redictUrl
!=
"undefined"
){
window
.
location
.
href
=
resp
.
data
.
redictUrl
;
}
return
false
;
}
...
...
@@ -102,6 +104,12 @@ layui.use(['form', 'table', 'laydate'], function(){
url
=
'/ajax/template_status'
;
datax
=
{
id
:
data
.
id
,
status
:
data
.
status
}
enable_tool
(
title
,
content
,
url
,
datax
);
}
else
if
(
layEvent
==
"copy"
){
title
=
'复制模板'
;
content
=
'确定要复制该模板?'
;
url
=
'/ajax/copy_template'
;
datax
=
{
t_id
:
data
.
id
}
enable_tool
(
title
,
content
,
url
,
datax
);
}
})
...
...
resources/views/web/labelList.blade.php
View file @
6780167d
...
...
@@ -64,6 +64,7 @@
@{{# }else{ }}
<a class="
btn
btn
-
xs
btn
-
outline
btn
-
info
" lay-event="
forbid
">禁用</a>
@{{# } }}
<a class="
btn
btn
-
xs
btn
-
outline
btn
-
info
" lay-event="
copy
">复制</a>
</script>
<script type="
text
/
html
" id="
status
">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment