save
This commit is contained in:
parent
113b2fe7a6
commit
dfa90eea43
@ -58,10 +58,14 @@ class UploadController extends Crud
|
||||
* 更新
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public function update(Request $request): Response
|
||||
{
|
||||
return not_found();
|
||||
if ($request->method() === 'GET') {
|
||||
return view("upload/update");
|
||||
}
|
||||
return parent::update($request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ use plugin\admin\app\model\Base;
|
||||
* @property integer $admin_id 管理员id
|
||||
* @property integer $user_id 用户id
|
||||
* @property integer $file_size 文件大小
|
||||
* @property integer $mime_type mime类型
|
||||
* @property string $mime_type mime类型
|
||||
* @property integer $image_width 图片宽度
|
||||
* @property integer $image_height 图片高度
|
||||
* @property string $ext 扩展名
|
||||
|
131
src/plugin/admin/app/view/upload/update.html
Normal file
131
src/plugin/admin/app/view/upload/update.html
Normal file
@ -0,0 +1,131 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>更新页面</title>
|
||||
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form class="layui-form">
|
||||
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">类别</label>
|
||||
<div class="layui-input-block">
|
||||
<div name="category" id="category" value="" ></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit="" lay-filter="save">
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md">
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script src="/app/admin/component/layui/layui.js"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const PRIMARY_KEY = 'id';
|
||||
const SELECT_API = "/app/admin/upload/select" + location.search;
|
||||
const UPDATE_API = "/app/admin/upload/update";
|
||||
|
||||
// 获取数据库记录
|
||||
layui.use(['form', 'jquery', 'util'], function () {
|
||||
let $ = layui.jquery;
|
||||
$.ajax({
|
||||
url: SELECT_API,
|
||||
dataType: 'json',
|
||||
success: function (e) {
|
||||
|
||||
// 给表单初始化数据
|
||||
layui.each(e.data[0], function (key, value) {
|
||||
let obj = $('*[name="'+key+'"]');
|
||||
if (typeof obj[0] === 'undefined' || !obj[0].nodeName) return;
|
||||
obj.attr('value', value);
|
||||
});
|
||||
|
||||
// 字段 url url
|
||||
layui.use(['upload', 'layer', 'jquery', 'popup', 'util'], function() {
|
||||
let input = layui.jquery('#url').prev();
|
||||
input.prev().html(layui.util.escape(input.val()));
|
||||
layui.upload.render({
|
||||
elem: "#url",
|
||||
url: '/app/admin/upload/attachment',
|
||||
accept: 'file',
|
||||
field: '__file__',
|
||||
done: function (res) {
|
||||
if (res.code) return layui.popup.failure(res.msg);
|
||||
this.item.prev().val(res.data.path).prev().html(layui.util.escape(res.data.path));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 字段 类别 category
|
||||
layui.use(["jquery", "xmSelect"], function() {
|
||||
layui.jquery.ajax({
|
||||
url: "/app/admin/dict/get/upload",
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
let value = layui.jquery("#category").attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: "#category",
|
||||
name: "category",
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: 'true',
|
||||
radio: 'true',
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(['form', 'jquery', 'popup'], function () {
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||
layui.jquery.ajax({
|
||||
url: UPDATE_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user