hn_cloud_web/czl-web/js/newPro/newProPreArrangementList.js

234 lines
9.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

layui.config({
base: '../../js/layuiModules/', // 第三方模块所在目录
version: 'v1.6.4' // 插件版本号
}).extend({
soulTable: 'notice,layNotify', // 模块
});
let form;
var table;
var notice;
var layNotify;
const token = localStorage.getItem("token");
let pers = checkPermission();
$("#resetBt").click(function(){
table.reload('menuTable', {
url: ctxPath + '/newPro/getBasicDataList'
, method: 'post' //方式默认是get
, page: true
, where: {
keyWord: "",
orgId: "",
voltageLevel: "",
} //设定异步数据接口的额外参数
});
$("#keyWord").val("");
getVoltageLevel(form,"");
getOrgName(form,"");
})
$("#searchBt").click(function(){
table.reload('menuTable', {
url: ctxPath + '/newPro/getBasicDataList'
, method: 'post' //方式默认是get
, page: true
, where: {
keyWord: $("#keyWord").val(),
voltageLevelId: $("#volLevelIds").val(),
orgId: $("#orgId").val(),
} //设定异步数据接口的额外参数
});
})
$("#exportBt").click(function(){
window.location.href = ctxPath + "/newPro/export?token=" + token //下载文件;
+"&keyWord=" + $("#keyWord").val()
+"&orgId=" + $("#orgId").val()
+"&voltageLevelId=" + $("#volLevelIds").val()
})
$("#addBt").click(function(){
localStorage.setItem('type',"1");
localStorage.setItem('newProId',"");
layerOpenFormForSencond("新增","./newProForm.html");
})
layui.use(['table', 'form','notice', 'layNotify'], function () {
table = layui.table;
form = layui.form;
notice = layui.notice;
layNotify = layui.layNotify;
if ($.inArray('sysBasicData:add', pers) < 0) {
$("#addBt").addClass("layui-hide");
}
getVoltageLevel(form,"");
getOrgName(form,"");
//渲染表格
table.render({
elem: '#demo'
, url: ctxPath + '/newPro/getBasicDataList' //数据接口
, method: 'post' //方式默认是get
, toolbar: 'default' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
, where: {} //post请求必须加where post请求需要的参数
, cellMinWidth: 80
, cols: [[ //表头
{
field: 'number', width:80,title: '序号', align: 'center', type: 'numbers'
}
, {field: 'orgName', align: 'center',width: 200, title: '分公司'}
, {field: 'proName', align: 'center', width: 200, title: '工程名称'}
, {field: 'voltageLevel', align: 'center',width: 100, title: '电压等级'}
, {field: 'scale', align: 'center',width: 100, title: '规模(km) '}
, {field: 'time', align: 'center', width: 200,title: '开竣工时间'}
, {field: 'theQuantityRequiredNum', align: 'center',width: 240, title: '预安排承接分包商及班组需求数量'}
, {field: 'teamNum', align: 'center', title: '班组和'}
, {field: 'efficacy', align: 'center', title: '功效'}
, {field: 'planToDay', align: 'center',width: 200, title: '计数(月数)转化为天数'}
, {field: 'kilometers', align: 'center', title: '公里数'}
, {field: 'clothSpacing', align: 'center', title: '布距'}
, {field: 'baseNumberOfTowers', align: 'center', title: '塔基数'}
, {field: 'totalConstructionDays', align: 'center',width: 150, title: '总施工天数'}
, {
fixed: 'right', width:180, title: '操作', align: 'center', templet: d => {
let text = "";
text +='<a lay-event="view" style="color: #009688;cursor: pointer;font-size: 15px">详情</a>';
if ($.inArray('sysBasicData:update', pers) > 0) {
text +='<span lay-event="com" style="font-size: 15px;"> | </span>';
text +='<a lay-event="update" style="color: #009688;cursor: pointer;font-size: 15px" id="updateBtn">修改</a>';
}
if ($.inArray('sysBasicData:del', pers) > 0) {
text +='<span lay-event="com" style="font-size: 15px;"> | </span>';
text +='<a lay-event="del" style="color: #a90f45;cursor: pointer;font-size: 15px">删除</a>';
}
return text;
}
}
]]
,done: function (res, curr, count) {
}
, id: 'menuTable'
, page: true //开启分页
, loading: true //数据加载中。。。
, limits: [5, 10, 20, 100] //一页选择显示3,5或10条数据
, limit: 10 //一页显示5条数据
, response: {
statusCode: 200 //规定成功的状态码默认0
}, parseData: function (res) { //将原始数据解析成 table 组件所规定的数据res为从url中get到的数据
let result;
if (res.data !== '' && res.data != null && res.data !== "null") {
if (this.page.curr) {
result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
} else {
result = res.data.slice(0, this.limit);
}
}
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.count, //解析数据长度
"data": result, //解析数据列表
};
},
toolbar: "#toolbar"
});
//监听工具条
table.on('tool(test)', function (obj) {
var data = obj.data; //当前行数据
var rowIndex = obj.index;
var layEvent = obj.event; //当前点击的事件名
if (layEvent === 'view') {
localStorage.setItem("newProId",data.id)
localStorage.setItem("type",'3')
layerOpenProgressView("详情","./newProForm.html");
}
if (layEvent === 'update') {
localStorage.setItem("newProId",data.id)
localStorage.setItem("type",'2')
layerOpenFormForSencond("修改","./newProForm.html");
}
if (layEvent === 'del') {
var index = layer.confirm('确定要删除吗?', {
btn : [ '确定', '取消' ]
}, function() {
layer.close(index);
ajaxCommonMethod('/newPro/delById',{'id': data.id},"删除成功","删除失败");
});
}
});
});
function layerOpenProgressView(title,contentUrl){
var index = layer.open({
title: [title, 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: contentUrl,
area: ['90%', '95%'],
maxmin: false,
cancel:function (){
localStorage.removeItem("newProId")
localStorage.removeItem("type")
table.reload('menuTable', {
url: ctxPath + '/newPro/getBasicDataList'
, method: 'post' //方式默认是get
, page: true
, where: {
keyWord: "",
orgId: "",
voltageLevel: "",
} //设定异步数据接口的额外参数
});
}
});
}
function ajaxCommonMethod(url,data,success,error){
$.ajax({
type: 'POST',
async: false, // 默认异步true,false表示同步
url: ctxPath + url,// 请求地址
contentType: "application/x-www-form-urlencoded",
dataType: 'json', // 服务器返回数据类型
data: data, //获取提交的表单字段
success: function (data) {
var resMsg = data.resMsg;
if ("数据获取成功" == resMsg) {
reloadTip("删除",success,'success');
setTimeout(function(){
table.reload('menuTable');
}, 2000);
}else {
reloadTip("删除",error,"error");
}
}
});
}
function layerOpenFormForSencond(title,contentUrl){
var index = layer.open({
title: [title, 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: contentUrl,
area: ['90%', '95%'],
maxmin: false,
btn: ['确定'],
success: function (layero, index) {
},
yes: function (index, layero) {
//提交子页面时执行
// 获取弹出层中的form表单元素
var formSubmit = layer.getChildFrame('form', index);
// 查找class样式为submitBtn的按钮
let submited = formSubmit.find('button.subBtn');
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
submited.click();
}
, cancel:function (index, layero){
localStorage.removeItem("newProId")
localStorage.removeItem("type")
}
});
}
function reloadTip(tip,message,type){
layNotify.notice({
title: tip+"提示",
type: type,
message: message
});
}