Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_admin
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
7a833ad9
authored
Nov 10, 2022
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
订单列表pdf
parent
753ab4d3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
368 additions
and
4 deletions
app/Admin/Controllers/Api/OrderApiController.php
app/Admin/routes.php
app/helpers.php
composer.json
config/database.php
resources/views/export/order_contract.blade.php
vendor/composer/autoload_files.php
vendor/composer/autoload_static.php
app/Admin/Controllers/Api/OrderApiController.php
View file @
7a833ad9
...
...
@@ -10,15 +10,29 @@ use Maatwebsite\Excel\Facades\Excel;
class
OrderApiController
extends
Controller
{
public
function
orderDownloadShow
(){
$this
->
view
();
public
function
orderDownloadShow
(
Request
$request
){
$params
=
$request
->
all
();
$type
=
arrayGet
(
$params
,
"type"
);
if
(
$type
==
"1"
){
//PI
return
view
(
'export.order_contract_PI'
);
}
elseif
(
$type
==
"2"
){
//CI
return
view
(
'export.order_contract_CI'
);
}
else
{
//PL
return
view
(
'export.order_contract_PL'
);
}
}
public
function
orderDownload
(
Request
$request
){
$params
=
$request
->
all
();
// dd($params);
return
Excel
::
download
(
new
\App\Exports\ContractExport
(),
'PI.xlsx'
);
}
}
app/Admin/routes.php
View file @
7a833ad9
...
...
@@ -22,6 +22,7 @@ Route::group([
$router
->
resource
(
'users'
,
'UserController'
);
//下载pdf
Route
::
get
(
'/api/order_download'
,
'\App\Admin\Controllers\Api\OrderApiController@orderDownload'
);
Route
::
get
(
'/api/orderDownloadShow'
,
'\App\Admin\Controllers\Api\OrderApiController@orderDownloadShow'
);
});
...
...
app/helpers.php
View file @
7a833ad9
...
...
@@ -2,6 +2,10 @@
use
Illuminate\Support\Arr
;
define
(
"DIGITS_TWO"
,
2
);
define
(
"DIGITS_FOUR"
,
4
);
define
(
"DIGITS_SIX"
,
6
);
if
(
!
function_exists
(
'user_admin_config'
))
{
function
user_admin_config
(
$key
=
null
,
$value
=
null
)
{
...
...
@@ -76,3 +80,341 @@ function curl($url, $params = false, $ispost = 0, $https = 0, $cookie = '', $tim
curl_close
(
$ch
);
return
$response
;
}
/**
* 通用格式化字符串为数字金额
* @$amount 需要格式化的数字或者字符串 1.2345
* @$digits 保留小数位数 1.23
* @$currency 币别 ¥12003.4567
* @$thousandsSymbol 千分位字符串隔开 1,200,3.4567
*
* define("DIGITS_TWO",2);
define("DIGITS_FOUR",4);
define("DIGITS_SIX",6);
*/
if
(
!
function_exists
(
'decimal_number_format'
))
{
function
decimal_number_format
(
$amount
,
$digits
=
DIGITS_TWO
,
$currency
=
""
,
$thousandsSymbol
=
""
){
$amount
=
floatval
(
strval
(
$amount
));
//格式化币别
if
(
$currency
){
$minus
=
$amount
<
0
?
'-'
:
''
;
$numerical
=
number_format
(
abs
(
$amount
),
$digits
,
"."
,
$thousandsSymbol
);
$sign
=
\Arr
::
get
(
config
(
"field.currency_sign"
),
intval
(
$currency
),
""
);
if
(
!
empty
(
$sign
))
{
$numerical
=
$sign
.
$numerical
;
}
return
$minus
?
$minus
.
$numerical
:
$numerical
;
}
else
{
$numerical
=
number_format
(
$amount
,
$digits
,
"."
,
""
);
return
$numerical
;
}
}
}
if
(
!
function_exists
(
'printJson'
))
{
function
printJson
(
$data
)
{
print_r
(
is_array
(
$data
)
?
json_encode
(
$data
)
:
$data
);
die
;
}
}
if
(
!
function_exists
(
'drawLetter'
))
{
/*
* 格式化型号, echo DrawLetter("LMGAGA 质量 &&*****") 输出:LMGAGA
* @param $g string 关键词
*/
function
drawLetter
(
$g
){
$g
=
preg_replace
(
'/[\x{4e00}-\x{9fff}]+/u'
,
''
,
$g
);
$g
=
preg_replace
(
'/[^A-Za-z0-9]+/'
,
''
,
$g
);
return
strtoupper
(
$g
);
}
}
if
(
!
function_exists
(
'buildQuery'
))
{
function
buildQuery
(
$query
,
$where
)
{
foreach
(
$where
as
$subWhere
)
{
if
(
count
(
$subWhere
)
==
2
)
{
$fiels
=
$exp
=
$subWhere
[
0
]
??
""
;
$value
=
$subWhere
[
1
]
??
null
;
if
(
empty
(
$fiels
)
||
$value
===
null
)
{
continue
;
}
if
(
$exp
==
"or"
)
{
$query
->
orWhere
(
function
(
$q
)
use
(
$value
)
{
buildQuery
(
$q
,
$value
);
});
}
else
{
$query
->
where
(
$subWhere
[
0
],
$subWhere
[
1
]);
}
}
else
if
(
count
(
$subWhere
)
==
3
)
{
$fiels
=
$subWhere
[
0
]
??
""
;
$exp
=
$subWhere
[
1
]
??
null
;
$value
=
$subWhere
[
2
]
??
null
;
if
(
empty
(
$fiels
)
||
$exp
===
null
||
$value
===
null
)
{
continue
;
}
if
(
$exp
==
"in"
&&
is_array
(
$value
)
&&
!
empty
(
$value
))
{
$query
->
whereIn
(
$fiels
,
$value
);
}
else
{
$query
->
where
(
$fiels
,
$exp
,
$value
);
}
}
}
return
$query
;
}
}
if
(
!
function_exists
(
'echoToSql'
))
{
function
echoToSql
(
$query
){
$tmp
=
str_replace
(
'?'
,
'"'
.
'%s'
.
'"'
,
$query
->
toSql
());
$tmp
=
vsprintf
(
$tmp
,
$query
->
getBindings
());
dd
(
$tmp
);
}
}
/**
* Notes:提取数组中某个字段$searchkey作为键值,然后从数组中检索给定的键的所有值
* User: sl
* Date: 2022/5/25 15:39
* @param $arr
* @param $key
* @param $val
* @return array
*/
function
flipArrayPluck
(
$arr
,
$newKey
,
$seachKey
){
$newArr
=
[];
foreach
(
$arr
as
$v
){
$newArr
[
$v
[
$newKey
]][]
=
$v
[
$seachKey
];
}
return
$newArr
;
}
if
(
!
function_exists
(
'checkArrayValuesNotEmpty'
))
{
function
checkArrayValuesNotEmpty
(
$arr
=
[]){
$result
=
true
;
if
(
is_array
(
$arr
)){
foreach
(
$arr
as
$val
){
if
(
empty
(
$val
)){
$result
=
false
;
break
;
}
}
}
else
{
$result
=
false
;
}
return
$result
;
}
}
/*
* 遍历数组中某个字段的值 作为 键 返回新数组
*/
function
arrayChangeKeyByField
(
$list
,
$searchKey
)
{
$arr
=
[];
if
(
!
$searchKey
)
{
return
$list
;
}
foreach
(
$list
as
$k
=>
$v
)
{
if
(
isset
(
$v
[
$searchKey
]))
{
$arr
[
$v
[
$searchKey
]]
=
$v
;
}
}
return
$arr
?
$arr
:
$list
;
}
/*
* 把数组中null的字符串转为空
*/
function
conversionArray
(
$arr
)
{
if
(
empty
(
$arr
))
{
return
$arr
;
}
foreach
(
$arr
as
$k
=>
$v
)
{
if
(
is_array
(
$v
))
{
$arr
[
$k
]
=
conversionArray
(
$v
);
}
else
{
if
(
$v
===
null
)
{
$arr
[
$k
]
=
""
;
}
}
}
return
$arr
;
}
function
dateDefault
(
$time
)
{
$time
=
intval
(
$time
);
if
(
$time
)
{
return
date
(
"Y-m-d H:i:s"
,
$time
);
}
return
""
;
}
function
arraySort
(
$list
,
$keys
,
$sort
=
"asc"
)
{
if
(
$sort
==
"asc"
)
{
$sort
=
SORT_ASC
;
}
else
{
$sort
=
SORT_DESC
;
}
array_multisort
(
array_column
(
$list
,
$keys
),
$sort
,
$list
);
return
$list
;
}
/*
* 去重数组
* 过滤数组
*/
function
array_filter_unique
(
$arr
)
{
return
array_unique
(
array_filter
(
$arr
));
}
/*
* 截取字符串
*/
//如果字符串长度超过10,则截取并以省略号结尾
function
truncStr
(
$str
,
$len
=
100
,
$endStr
=
""
)
{
$str
=
(
string
)
$str
;
if
(
mb_strlen
(
$str
,
'utf-8'
)
>
$len
)
{
return
mb_substr
(
$str
,
0
,
$len
,
'utf-8'
)
.
$endStr
;
}
else
{
return
$str
;
}
}
/*
* 获取登录者的信息
*/
function
getAdminUser
()
{
$admin
=
request
()
->
get
(
"user"
);
if
(
!
$admin
)
{
throw
new
\App\Exceptions\InvalidRequestException
(
"没找到登录相关信息,请先登录~_~"
);
}
$arr
=
[];
$arr
[
"userId"
]
=
$admin
->
userId
;
$arr
[
"name"
]
=
$admin
->
name
;
$arr
[
"email"
]
=
$admin
->
email
;
$arr
[
"engName"
]
=
$admin
->
engName
;
return
$arr
;
}
/*
* 获取登录者用户id
*/
function
getAdminUserId
()
{
$admin
=
request
()
->
get
(
"user"
);
if
(
!
$admin
)
{
throw
new
\App\Exceptions\InvalidRequestException
(
"没找到登录相关信息,请先登录~_~"
);
}
return
$admin
->
userId
;
}
/*
* 获取登录者的名字
*/
function
getAdminUserName
()
{
$admin
=
request
()
->
get
(
"user"
);
if
(
!
$admin
)
{
throw
new
\App\Exceptions\InvalidRequestException
(
"没找到登录相关信息,请先登录~_~"
);
}
return
$admin
->
name
;
}
/**
* 是否为多维数组
* @param array $arr
* @return bool
*/
function
isMultipleArray
(
array
&
$arr
)
:
bool
{
if
(
count
(
$arr
)
<=
0
)
{
return
false
;
}
if
(
count
(
$arr
)
==
count
(
$arr
,
COUNT_RECURSIVE
))
{
foreach
(
$arr
as
$tempArr
)
{
if
(
is_array
(
$tempArr
))
{
return
true
;
}
}
return
false
;
}
return
true
;
}
//判断是否有对应的权限
//request()->perms是Permission中间件过来的
function
checkPerm
(
$perm
)
:
bool
{
$perms
=
request
()
->
perms
?:
[];
return
in_array
(
$perm
,
$perms
);
}
/**
* 价格格式化
* @param [type] $price [description]
* @param integer $sign [description]
* @param integer $num [description]
* @return [type] [description]
*/
function
price_format
(
$price
,
$sign
=
0
,
$num
=
2
,
$sep
=
''
)
{
$minus
=
$price
<
0
?
'-'
:
''
;
$price
=
floatval
(
strval
(
$price
));
$price
=
number_format
(
abs
(
$price
),
$num
,
'.'
,
$sep
);
$sign
=
\Arr
::
get
(
config
(
"field.currency_sign"
),
intval
(
$sign
),
""
);
if
(
!
empty
(
$sign
))
{
$price
=
$sign
.
$price
;
}
if
(
$minus
){
return
$minus
.
$price
;
}
return
$price
;
}
function
arrayGet
(
$arr
,
$key
,
$default
=
""
,
$func
=
""
)
{
if
(
isset
(
$arr
[
$key
]))
{
if
(
$func
&&
is_callable
(
$func
))
{
try
{
return
$func
(
$arr
[
$key
]);
}
catch
(
\Throwable
$e
)
{
return
$arr
[
$key
];
}
}
else
{
return
$arr
[
$key
];
}
}
else
{
return
$default
;
}
}
/*
* 构建时间查询
*/
function
buildQueryTimeRange
(
$time
=
""
)
{
$time
=
explode
(
"~"
,
$time
);
$buildTimeQueryData
[
"begin_time"
]
=
isset
(
$time
[
0
])
?
$time
[
0
]
:
""
;
$buildTimeQueryData
[
"end_time"
]
=
isset
(
$time
[
1
])
?
$time
[
1
]
:
""
;
return
$buildTimeQueryData
;
}
\ No newline at end of file
composer.json
View file @
7a833ad9
...
...
@@ -44,6 +44,9 @@
"classmap"
:
[
"database/seeds"
,
"database/factories"
],
"files"
:[
"app/helpers.php"
]
},
"autoload-dev"
:
{
...
...
config/database.php
View file @
7a833ad9
...
...
@@ -162,6 +162,7 @@ return [
'database'
=>
env
(
'REDIS_CACHE_DB'
,
'1'
),
],
],
];
resources/views/export/order_contract.blade.php
deleted
100644 → 0
View file @
753ab4d3
This diff is collapsed.
Click to expand it.
vendor/composer/autoload_files.php
View file @
7a833ad9
...
...
@@ -35,4 +35,5 @@ return array(
'b6b991a57620e2fb6b2f66f03fe9ddc2'
=>
$vendorDir
.
'/symfony/string/Resources/functions.php'
,
'044fc72df35e84c745ee0d4120dc15d2'
=>
$vendorDir
.
'/dcat/laravel-admin/src/Support/helpers.php'
,
'b670c7ffff63265cc064eb6fd1051ae1'
=>
$vendorDir
.
'/mosiboom/dcat-iframe-tab/src/helpers.php'
,
'b4e3f29b106af37a2bb239f73cdf68c7'
=>
$baseDir
.
'/app/helpers.php'
,
);
vendor/composer/autoload_static.php
View file @
7a833ad9
...
...
@@ -36,6 +36,7 @@ class ComposerStaticInit14b314507a533a1b9e8248f4361c62bf
'b6b991a57620e2fb6b2f66f03fe9ddc2'
=>
__DIR__
.
'/..'
.
'/symfony/string/Resources/functions.php'
,
'044fc72df35e84c745ee0d4120dc15d2'
=>
__DIR__
.
'/..'
.
'/dcat/laravel-admin/src/Support/helpers.php'
,
'b670c7ffff63265cc064eb6fd1051ae1'
=>
__DIR__
.
'/..'
.
'/mosiboom/dcat-iframe-tab/src/helpers.php'
,
'b4e3f29b106af37a2bb239f73cdf68c7'
=>
__DIR__
.
'/../..'
.
'/app/helpers.php'
,
);
public
static
$prefixLengthsPsr4
=
array
(
...
...
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