提交 4cf67238 编写于 作者: doc_wei's avatar doc_wei

用户管理上传修改

上级 5172e38e
layui.config({
base: basePath,
version: skyeyeVersion
}).define(['table', 'jquery', 'winui'], function (exports) {
}).define(['table', 'jquery', 'winui', 'fileUpload'], function (exports) {
winui.renderColor();
layui.use(['form'], function (form) {
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
......@@ -27,55 +27,21 @@ layui.config({
//设置性别
$("input:radio[name=userSex][value=" + json.bean.userSex + "]").attr("checked", true);
//初始化上传
$("#showForm").find('.fileUploadContent').each(function(i, dom) {
if($.inArray($(dom).attr("id"), picArray) < 0){
picArray.push($(dom).attr("id"));
var fileType = "*";
if($(dom).attr("id") == "userPhoto")//图片上传
fileType = filePicType;
var vali = $(dom).attr('validate');
if(vali)
vali = eval('(' + vali + ')').vali;
var maxNum = vali.maxnum; //最大数量
var minNum = vali.minnum; //最小数量
var required = vali.required; //必传
if(!maxNum)
maxNum = 10;
var msg = '';
if(required)
msg = '请至少上传1个文件,';
if(minNum && required)
msg = '请至少上传' + minNum + '个文件,';
if(maxNum)
msg += '至多可上传' + maxNum + '个文件';
var fileParam = {
id: '#' + $(dom).attr('id'),
onUploadFun: onUploadFun,//回执函数
maxFileNumber: maxNum,
uploadUrl: '/common/upload',//上传路径
async: false,//是否异步
fileType: fileType,//文件类型
msg: msg//提示消息
}
fileUpload(fileParam);
}
});
$("#userPhoto").upload({
"action": reqBasePath + "common003",
"data-num": "1",
"data-type": "PNG,JPG,jpeg,gif",
"uploadType": 2,
"data-value": json.bean.userPhoto,
//该函数为点击放大镜的回调函数,如没有该函数,则不显示放大镜
"function": function (_this, data) {
show("#userPhoto", data);
}
});
form.render();
form.on('submit(formEditUser)', function (data) {
// console.log(data.elem);
//表单验证
if (winui.verifyForm(data.elem)) {
//执行上传操作
$("#showForm").find('.fileUploadContent').each(function(i, dom) {
var id = $(dom).attr('id');
if(id != undefined && id == 'userPhoto') {
var opt = uploadTools.getOpt(id);
if(uploadTools.getFileNumber(opt) > 0) {
uploadTools.uploadFile(opt);
}
}
});
var params = {
rowId: parent.rowId,
userName: $("#userName").val(),
......@@ -83,6 +49,8 @@ layui.config({
userSex: $("input[name='userSex']:checked").val(),
userPhoto: "11"
};
params.userPhoto = $("#userPhoto").find("input[type='hidden'][name='upload']").attr("oldurl");
AjaxPostUtil.request({url:reqBasePath + "sys005", params:params, type:'json', callback:function(json){
if(json.returnCode == 0){
parent.layer.close(index);
......@@ -97,15 +65,6 @@ layui.config({
}
});
//上传回执函数
function onUploadFun(opt, data) {
if(data.code == 1) {
if(opt.uploadId == "userPhoto") {
userPhoto = data.content;
}
}
}
$("body").on("click", "#cancle", function(){
parent.layer.close(index);
});
......
......@@ -28,7 +28,7 @@
<div class="layui-form-item">
<label class="layui-form-label">头像</label>
<div class="layui-input-block">
<div id="userPhoto" validate="{vali:{type:'fileUpload',minnum:1,maxnum:1}}" class="fileUploadContent"></div>
<div class="upload" id="userPhoto"></div>
</div>
</div>
<div class="layui-form-item">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册