165 lines
6.0 KiB
JavaScript
165 lines
6.0 KiB
JavaScript
layui.config({
|
|
base: '../../js/layuiModules/', // 第三方模块所在目录
|
|
version: 'v1.6.4' // 插件版本号
|
|
}).extend({
|
|
soulTable: 'notice,layNotify', // 模块
|
|
});
|
|
let form;
|
|
var tree;
|
|
var table ;
|
|
var notice;
|
|
var layNotify;
|
|
|
|
layui.use(['table', 'form','notice', 'layNotify'], function () {
|
|
//getData();
|
|
table = layui.table;
|
|
form = layui.form;
|
|
tree = layui.tree;
|
|
layNotify = layui.layNotify;
|
|
notice = layui.notice;
|
|
form.on('submit(formDemo)', function (data) {
|
|
|
|
});
|
|
getTowerType(form, "");
|
|
createTable();
|
|
|
|
form.on('submit(formDemo)', function (data) {
|
|
var tableData = table.cache.demo; //
|
|
var tf = true;
|
|
tableData.forEach(item => {
|
|
if(tf){
|
|
let id = item.id;
|
|
let choseNum = $("#"+id+"_choseId").val()
|
|
let dictKey = item.dictKey;
|
|
console.log("choseNum="+choseNum);
|
|
item.choseNum = choseNum;
|
|
}
|
|
});
|
|
let resourceName = $("#resourceName").val();
|
|
let teamType = $("#teamType").find("option:selected").val();//获取选中值
|
|
let notes = $("#notes").val();
|
|
if(resourceName == ""){
|
|
layer.msg("请填写班组名称!", {icon: 2});
|
|
return;
|
|
}
|
|
if(teamType == ""){
|
|
layer.msg("请选择团队类型!", {icon: 2});
|
|
return;
|
|
}
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
async: false, // 默认异步true,false表示同步
|
|
url: ctxPath + "/teamSet/getTeamByTeamTypeAndName",// 请求地址
|
|
dataType: 'json', // 服务器返回数据类型
|
|
data: {"resourceName":resourceName,
|
|
"groupType":teamType,
|
|
"notes":notes,
|
|
"resourceType":"2"}, //获取提交的表单字段
|
|
success: function (data) {
|
|
var objData = data.data;
|
|
if(objData=="允许添加"){
|
|
$.ajax({
|
|
type: 'POST',
|
|
async: false, // 默认异步true,false表示同步
|
|
url: ctxPath + "/teamSet/addBranchOfficeTeamSet",// 请求地址
|
|
dataType: 'json', // 服务器返回数据类型
|
|
data: {"stringKey":JSON.stringify(tableData),
|
|
"resourceName":resourceName,
|
|
"groupType":teamType,
|
|
"notes":notes,
|
|
"resourceType":"2",
|
|
'type':'1'}, //获取提交的表单字段 type:1新增 2修改
|
|
success: function (data) {
|
|
var status = data.data;
|
|
if("添加成功"==status){
|
|
//layer.msg("数据添加成功!", {icon: 1});
|
|
reloadTip("添加","添加成功",'success',layNotify);
|
|
setTimeout(function(){
|
|
parent.layer.closeAll();
|
|
}, 2000);
|
|
|
|
}else{
|
|
// layer.msg("数据添加失败!", {icon: 2});
|
|
reloadTip("添加","添加失败",'error',layNotify);
|
|
setTimeout(function(){
|
|
parent.layer.closeAll();
|
|
}, 2000);
|
|
parent.layer.closeAll();
|
|
}
|
|
}
|
|
});
|
|
}else{
|
|
layer.msg("团队名称已存在!", {icon: 2});
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
$("#typeManage").click(function () {
|
|
var index = layer.open({
|
|
type: 2,
|
|
title: '分类管理',
|
|
content: 'ownTeamAdd.html',
|
|
area: ['62%', '90%'],
|
|
maxmin: false,
|
|
closeBtn: true,
|
|
btn: ['确定', '取消'],
|
|
yes: function(index, layero){
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|
//var submited = formSubmit.find('button')[0];
|
|
let submited = formSubmit.find('button.subBtn');
|
|
submited.click();
|
|
return false;
|
|
},
|
|
end: function(){
|
|
createTable();
|
|
}
|
|
});
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
function createTable() {
|
|
$.ajax({
|
|
type: 'POST',
|
|
async: false, // 默认异步true,false表示同步
|
|
url: ctxPath + "/selectUtil/getDataDictByDickVal",// 请求地址
|
|
dataType: 'json', // 服务器返回数据类型
|
|
data: {"dictKey":"own_type"}, //获取提交的表单字段
|
|
success: function (data) {
|
|
let objData= data
|
|
//渲染表格
|
|
table.render({
|
|
elem: '#demo',
|
|
cols: [[ //表头
|
|
{field: 'dictKey', title: '岗位',width:'200',align: 'center'},
|
|
{field: 'nums', title: '数量', width:'200',templet:function (d) {
|
|
var choseNum = d.choseNum;
|
|
var choseId = d.id+"_choseId";
|
|
var opt = '<input id="'+choseId+'" type="number" value="'+choseNum+'" name="price_min" placeholder="" autocomplete="off" class="layui-input " min="0" step="1" lay-affix="number">';
|
|
return opt;
|
|
}
|
|
}
|
|
// {field: 'nums', title: '数量', width:'200',edit: 'number',align: 'center'}
|
|
|
|
]],
|
|
data: objData,
|
|
done: function (res, curr, count) {
|
|
//merge(res);
|
|
},
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
|