123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <!DOCTYPE html>
- <html class="x-admin-sm">
-
- <head>
- <meta charset="UTF-8">
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
- <link rel="stylesheet" href="https://osscold.baozhida.cn/css/font.css">
- <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
- <link rel="stylesheet" href="https://osscold.baozhida.cn/lib/layui/layui.css">
- <script type="text/javascript" src="https://osscold.baozhida.cn/lib/layui/layui.js" charset="utf-8"></script>
- <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.js"></script>
- <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
- <!--[if lt IE 9]>
- <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
- <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
- <![endif]--></head>
-
- <body>
- <div class="layui-fluid">
- <div class="layui-row">
- <form class="layui-form">
- <div class="layui-form-item">
- <label for="T_name" class="layui-form-label">
- <span class="x-red">*</span>分类名称</label>
- <div class="layui-input-inline">
- <input {{if gt .id 0 }}
- value="{{.T.T_name}}"
- {{end}} type="text" id="T_name" name="T_name" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item" style="text-align: center;margin-top: 20px">
- <button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">提交</button>
- </div>
- </form>
- </div>
- </div>
- <script>
- layui.use(['form', 'layer',"layedit"],
- function() {
- $ = layui.jquery;
- var form = layui.form,
- layer = layui.layer;
- //监听提交
- form.on('submit(add)',
- function(data) {
- console.log(data);
- //发异步,把数据提交给php
- layer.alert("操作成功", {
- icon: 6
- },
- function() {
- // 获得frame索引
- var index = parent.layer.getFrameIndex(window.name);
- //关闭当前frame
- parent.layer.close(index);
- parent.location.reload();
- });
- $.ajax({
- type: 'POST',
- url: 'Class_Post',//发送请求
- data: {
- Id:"{{.id}}",
- T_name:data.field.T_name,
- },
- success: function(result) {
- console.log(result)
- }
- });
- return false;
- });
- });
- </script>
- <script>
- var _img = ""
- layui.use('upload', function(){
- var $ = layui.jquery
- ,upload = layui.upload;
- //普通图片上传
- var uploadInst = upload.render({
- elem: '#test1'
- ,url: '/UpFile' //改成您自己的上传接口
- ,before: function(obj){
- //预读本地文件示例,不支持ie8
- obj.preview(function(index, file, result){
- $('#demo1').attr('src', result); //图片链接(base64)
- });
- }
- ,done: function(res){
- console.log(res)
- //如果上传失败
- if(res.code != 0){
- return layer.msg('上传失败');
- }
- _img = res.data.src
- console.log(_img)
- //上传成功
- }
- ,error: function(){
- console.log("error")
- //演示失败状态,并实现重传
- var demoText = $('#demoText');
- demoText.html('<span style="color: #ff5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
- demoText.find('.demo-reload').on('click', function(){
- uploadInst.upload();
- });
- }
- });
- //绑定原始文件域
- upload.render({
- elem: '#test20'
- ,url: 'https://httpbin.org/post' //改成您自己的上传接口
- ,done: function(res){
- layer.msg('上传成功');
- console.log(res)
- }
- });
- });
- </script>
- </body>
- </html>
|