gz_car_ui/js/car_settlement/payment_list.js

219 lines
6.8 KiB
JavaScript

let form, table, laydate;
let tableIns;
let pageNum = 1; // 定义分页
layui.use(["form", "table", 'laydate'], function () {
form = layui.form;
table = layui.table;
laydate = layui.laydate;
laydate.render({
elem: '#ID-laydate-rangeLinked',
range: ['#startDay', '#endDay'],
rangeLinked: true
});
initTable();
});
// 查询/重置
function queryTable(type) {
if (type === 1) {
let keyWord = $('#keyWord').val();
let flag = checkValue(keyWord);
if (flag) {
$('#keyWord').val('');
return layer.msg('关键字查询包含特殊字符,请重新输入', { icon: 2 });
}
reloadTable(1);
} else if (type === 2) {
$('#keyWord').val('');
layui.form.render();
reloadTable(1);
}
}
// 刷新页面数据
function reloadData() {
reloadTable(1);
}
// 重载表格
function reloadTable(pageNum) {
table.reload("currentTableId", {
page: {
curr: pageNum ? pageNum : 1,
},
where: {
encryptedData: JSON.stringify({
'keyWord': $('#keyWord').val(),
}),
},
},
);
}
// 初始化表格
function initTable() {
tableIns = table.render({
elem: "#currentTableId",
id: 'currentTableId',
headers: {
authorization: sessionStorage.getItem("gz-token"),
},
height: "full-170",
url: dataUrl + "backstage/carBalance/getSupPageList",
where: {
encryptedData: JSON.stringify({
'keyWord': $('#keyWord').val(),
}),
},
request: {
pageName: 'pageNum',
limitName: 'pageSize'
},
parseData: function (res) { // res 即为原始返回的数据
if (res.code === 401) {
closeWindowOpen();
}
return {
"code": 0, // 解析接口状态
"msg": '获取成功', // 解析提示文本
"count": res.total, // 解析数据长度
"data": res.list // 解析数据列表
};
},
cols: [
[
{
width: '5.9%',
title: "序号",
align: "center",
templet: function (d) {
return d.LAY_NUM;
},
},
{
field: "supName",
width: '14%',
title: "供应商名称",
unresize: true,
align: "center",
sort:true,
},
{
field: "status",
width: '10%',
title: "合同状态",
unresize: true,
align: "center",
sort:true,
templet: function (d) {
if(d.status === '已生效'){
return "<span style='color:#19BE6B;margin:0 5px 0 5px;font-size:16px'>●</span>生效中";
}else if(d.status === '未生效'){
return "<span style='color:#FF9900;margin:0 5px 0 5px;font-size:16px'>●</span>已失效";
}
},
},
{
field: "planNum",
width: '10%',
title: "需求计划数量",
unresize: true,
align: "center",
sort:true,
},
{
field: "proNum",
width: '8%',
title: "工程数量",
unresize: true,
align: "center",
sort:true,
},
{
field: "carNum",
width: '12%',
title: "租用车辆、吊车数量",
unresize: true,
align: "center",
sort:true,
},
{
field: "money",
width: '11%',
title: "租赁金额(元) ",
unresize: true,
sort:true,
align: "center",
templet: function (d) {
return ' ¥ '+ (d.money ? d.money : 0);
},
},
{
field: "payMoney",
width: '10%',
title: "已付金额(元)",
unresize: true,
align: "center",
sort:true,
templet: function (d) {
return ' ¥ '+ (d.payMoney ? d.payMoney : 0);
},
},
{
field: "noPayMoney",
width: '10%',
title: "待付金额(元)",
unresize: true,
align: "center",
sort:true,
templet: function (d) {
return ' ¥ '+ (d.noPayMoney ? d.noPayMoney : 0);
},
},
{
title: "操作",
width: '9%',
align: "center",
unresize: true,
templet: function (d) {
let html = "";
html += "<a onclick='paymentDetail(" + JSON.stringify(d) + ")'>详情</a>";
// html += "<div class='splitLine'>|</div><a onclick='payment(" + JSON.stringify(d) + ")'>付款</a>";
if(d.money !== d.payMoney){
html += "<div class='splitLine'>|</div><a onclick='payment(" + JSON.stringify(d) + ")'>付款</a>";
}
return html;
},
},
],
],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
done: function (res, curr, count) {
pageNum = tableIns.config.page.curr;
table.resize("currentTableId");
},
});
}
// 导出
function exportExcel() {
let params = {
'keyWord': $('#keyWord').val(),
}
let url = dataUrl + "backstage/carBalance/export";
exportExcelUtil(url, '付款单录入', JSON.stringify(params));
}
// 详情
function paymentDetail(obj) {
openIframeByParamObj("paymentDetail", "详情", "./child/payment_detail_list.html", "92%", "95%", obj);
}
// 付款
function payment(obj) {
openIframeByParamObj("payment", "付款", "./child/payment_form.html", "92%", "95%", obj);
}