TaoLer/app/admin/view/addon/addons/add.html

107 lines
3.3 KiB
HTML
Raw Normal View History

2023-03-16 22:40:15 +08:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>新增管理员</title>
<link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form" action="">
<div class="mainBox">
<div class="main-container">
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">压缩包</label>
<div class="layui-input-inline">
<input type="text" name="addons_src" lay-verify="required" placeholder="请上传zip包" autocomplete="off" class="layui-input" >
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label"></label>
<div class="layui-input-inline">
<button style="float: left;" type="button" class="layui-btn " id="layuiadmin-upload-addons">上传插件</button>
</div>
</div></div>
</div>
<div class="bottom">
<div class="button-container">
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
lay-filter="addon-save">
<i class="layui-icon layui-icon-ok"></i>
提交
</button>
<button type="reset" class="pear-btn pear-btn-sm">
<i class="layui-icon layui-icon-refresh"></i>
重置
</button>
</div>
</div>
</form>
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
layui.use(['form', 'upload'], function() {
var $ = layui.$, form = layui.form, upload = layui.upload;
let ADDON_ADD = "{:url('addon.addons/add')}";
upload.render({
elem: '#layuiadmin-upload-addons'
, url: 'uploadZip'
, accept: 'file'
, field: 'file'
, method: 'get'
, exts: 'zip|rar|7z'
, done: function (res) {
$(this.item).prev("div").children("input").val(res.src)
if (res.code == 0) {
layer.msg(res.msg, {
icon: 6,
tiye: 2000
});
} else {
layer.open({
title: "上传失败",
content: res.msg,
icon: 5,
anim: 6
});
}
}
});
form.on('submit(addon-save)', function (data) {
$.ajax({
url: ADDON_ADD,
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
type: 'post',
success: function (result) {
if (result.code === 0) {
layer.msg(result.msg, {
icon: 1,
time: 1000
}, function () {
parent.layer.close(parent.layer.getFrameIndex(window
.name)); //关闭当前页
//parent.layui.table.reload("user-table");
});
} else {
layer.msg(result.msg, {
icon: 2,
time: 1000
});
}
}
})
return false;
})
});
</script>
</body>
</html>