需求计划申请导入表格
This commit is contained in:
parent
b509e975e5
commit
7de35ffbc2
|
|
@ -14,6 +14,10 @@ function setParams(obj) {
|
|||
element = layui.element;
|
||||
layer = layui.layer;
|
||||
util = layui.util;
|
||||
|
||||
$("#saveZipButton").click(function(){
|
||||
importExcel();
|
||||
});
|
||||
initTable();
|
||||
});
|
||||
}
|
||||
|
|
@ -113,7 +117,7 @@ function initTable() {
|
|||
},
|
||||
},
|
||||
{
|
||||
field: "ppName",
|
||||
field: "type",
|
||||
width: '10%',
|
||||
title: "车辆类型",
|
||||
unresize: true,
|
||||
|
|
@ -121,7 +125,7 @@ function initTable() {
|
|||
sort:true,
|
||||
},
|
||||
{
|
||||
field: "pName",
|
||||
field: "name",
|
||||
width: '10%',
|
||||
title: "车辆名称",
|
||||
unresize: true,
|
||||
|
|
@ -129,7 +133,7 @@ function initTable() {
|
|||
sort:true,
|
||||
},
|
||||
{
|
||||
field: "name",
|
||||
field: "model",
|
||||
width: '10%',
|
||||
title: "规格",
|
||||
unresize: true,
|
||||
|
|
@ -339,4 +343,83 @@ function closePage(type, params,pageSource) {
|
|||
window.parent.addFitDatas(params,pageSource);
|
||||
}
|
||||
parent.layer.close(index); // 再执行关闭
|
||||
}
|
||||
}
|
||||
|
||||
// 下载模板文件
|
||||
function craneDownload() {
|
||||
window.location.href = '../../../template/吊车类型导入模板.xlsx';
|
||||
}
|
||||
|
||||
//导入excel文件
|
||||
function importExcel() {
|
||||
var formData = new FormData($('form')[0]);
|
||||
var name = $("#articleImageFile").val();
|
||||
if (name == null || name == "") {
|
||||
return;
|
||||
}
|
||||
if (!(name.endsWith(".xls") || name.endsWith(".xlsx") || name.endsWith(".xlsm"))) {
|
||||
layer.msg("请上传正确的Excel表格!");
|
||||
$("#articleImageFile").val("");
|
||||
return;
|
||||
}
|
||||
formData.append("file[]", $("#articleImageFile")[0].files[0]);
|
||||
let loadingMsg = layer.msg('正在提交,请稍等...', { icon: 16, shade: 0.01, time: '0' });
|
||||
let url = dataUrlCar + "backstage/carType/importExcelTools";
|
||||
ajaxRequestByUploadFile(url, formData, function () {
|
||||
$('.save').addClass("layui-btn-disabled").attr("disabled", true);
|
||||
$('.cancel').addClass("layui-btn-disabled").attr("disabled", true);
|
||||
}, function (result) {
|
||||
$('.save').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
$('.cancel').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
if (result.code === 200) {
|
||||
layer.close(loadingMsg);
|
||||
// 对返回的数据进行处理
|
||||
updateTableWithImportedData(result.data);
|
||||
} else {
|
||||
layer.close(loadingMsg);
|
||||
layer.msg(result.msg, { icon: 2 });
|
||||
}
|
||||
}, function (xhr, status, error) {
|
||||
layer.close(loadingMsg); // 关闭提示层
|
||||
layer.msg('服务异常,请稍后重试', { icon: 16, scrollbar: false, time: 2000 });
|
||||
$('.save').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
$('.cancel').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
errorFn(xhr, status, error)
|
||||
}, null);
|
||||
$("#articleImageFile").val("");
|
||||
}
|
||||
|
||||
function updateTableWithImportedData(data) {
|
||||
// 更新当前表格中显示的数据
|
||||
const tableData = table.cache.currentTableId || []
|
||||
let updated = false
|
||||
|
||||
// 遍历当前表格数据,更新匹配的行
|
||||
for (let i = 0; i < tableData.length; i++) {
|
||||
const rowData = tableData[i]
|
||||
// 在导入数据中查找匹配项
|
||||
const importedItem = data.find((item) => item.id === rowData.id)
|
||||
if (importedItem) {
|
||||
// 更新表格数据
|
||||
rowData.needNum = importedItem.needNum
|
||||
rowData.times = importedItem.times
|
||||
rowData.remarks = importedItem.remarks
|
||||
updated = true
|
||||
|
||||
// 更新表格中对应单元格的显示
|
||||
const rowIndex = rowData.LAY_INDEX
|
||||
// 更新需用量单元格
|
||||
$(`tr[data-index="${rowIndex}"] td[data-field="needNum"] .layui-table-cell`).text(importedItem.needNum || "")
|
||||
// 更新退还日期单元格
|
||||
$(`tr[data-index="${rowIndex}"] td[data-field="times"] .layui-table-cell`).text(importedItem.times || "")
|
||||
// 更新备注单元格
|
||||
$(`tr[data-index="${rowIndex}"] td[data-field="remarks"] .layui-table-cell`).text(importedItem.remarks || "")
|
||||
}
|
||||
}
|
||||
|
||||
// 如果有更新,同步更新全局数据
|
||||
if (updated) {
|
||||
quanju = [...tableData]
|
||||
}
|
||||
layer.msg("数据导入成功", { icon: 1 })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@ function setParams(obj) {
|
|||
element = layui.element;
|
||||
layer = layui.layer;
|
||||
util = layui.util;
|
||||
|
||||
$("#saveZipButton").click(function(){
|
||||
importExcel();
|
||||
});
|
||||
|
||||
initTable();
|
||||
});
|
||||
}
|
||||
|
|
@ -339,4 +344,83 @@ function closePage(type, params,pageSource) {
|
|||
window.parent.addFitDatas(params,pageSource);
|
||||
}
|
||||
parent.layer.close(index); // 再执行关闭
|
||||
}
|
||||
}
|
||||
|
||||
// 下载模板文件
|
||||
function toolsDownload() {
|
||||
window.location.href = '../../../template/机具类型导入模板.xlsx';
|
||||
}
|
||||
|
||||
//导入excel文件
|
||||
function importExcel() {
|
||||
var formData = new FormData($('form')[0]);
|
||||
var name = $("#articleImageFile").val();
|
||||
if (name == null || name == "") {
|
||||
return;
|
||||
}
|
||||
if (!(name.endsWith(".xls") || name.endsWith(".xlsx") || name.endsWith(".xlsm"))) {
|
||||
layer.msg("请上传正确的Excel表格!");
|
||||
$("#articleImageFile").val("");
|
||||
return;
|
||||
}
|
||||
formData.append("file[]", $("#articleImageFile")[0].files[0]);
|
||||
let loadingMsg = layer.msg('正在提交,请稍等...', { icon: 16, shade: 0.01, time: '0' });
|
||||
let url = dataUrlDevice + "backstage/planApplication/importExcelTools";
|
||||
ajaxRequestByUploadFile(url, formData, function () {
|
||||
$('.save').addClass("layui-btn-disabled").attr("disabled", true);
|
||||
$('.cancel').addClass("layui-btn-disabled").attr("disabled", true);
|
||||
}, function (result) {
|
||||
$('.save').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
$('.cancel').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
if (result.code === 200) {
|
||||
layer.close(loadingMsg);
|
||||
// 对返回的数据进行处理
|
||||
updateTableWithImportedData(result.data);
|
||||
} else {
|
||||
layer.close(loadingMsg);
|
||||
layer.msg(result.msg, { icon: 2 });
|
||||
}
|
||||
}, function (xhr, status, error) {
|
||||
layer.close(loadingMsg); // 关闭提示层
|
||||
layer.msg('服务异常,请稍后重试', { icon: 16, scrollbar: false, time: 2000 });
|
||||
$('.save').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
$('.cancel').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
errorFn(xhr, status, error)
|
||||
}, null);
|
||||
$("#articleImageFile").val("");
|
||||
}
|
||||
|
||||
function updateTableWithImportedData(data) {
|
||||
// 更新当前表格中显示的数据
|
||||
const tableData = table.cache.currentTableId || []
|
||||
let updated = false
|
||||
|
||||
// 遍历当前表格数据,更新匹配的行
|
||||
for (let i = 0; i < tableData.length; i++) {
|
||||
const rowData = tableData[i]
|
||||
// 在导入数据中查找匹配项
|
||||
const importedItem = data.find((item) => item.id === rowData.id)
|
||||
if (importedItem) {
|
||||
// 更新表格数据
|
||||
rowData.needNum = importedItem.needNum
|
||||
rowData.times = importedItem.times
|
||||
rowData.remarks = importedItem.remarks
|
||||
updated = true
|
||||
|
||||
// 更新表格中对应单元格的显示
|
||||
const rowIndex = rowData.LAY_INDEX
|
||||
// 更新需用量单元格
|
||||
$(`tr[data-index="${rowIndex}"] td[data-field="needNum"] .layui-table-cell`).text(importedItem.needNum || "")
|
||||
// 更新退还日期单元格
|
||||
$(`tr[data-index="${rowIndex}"] td[data-field="times"] .layui-table-cell`).text(importedItem.times || "")
|
||||
// 更新备注单元格
|
||||
$(`tr[data-index="${rowIndex}"] td[data-field="remarks"] .layui-table-cell`).text(importedItem.remarks || "")
|
||||
}
|
||||
}
|
||||
|
||||
// 如果有更新,同步更新全局数据
|
||||
if (updated) {
|
||||
quanju = [...tableData]
|
||||
}
|
||||
layer.msg("数据导入成功", { icon: 1 })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@ function setParams(obj) {
|
|||
layer = layui.layer;
|
||||
util = layui.util;
|
||||
laydate = layui.laydate;
|
||||
|
||||
$("#saveZipButton").click(function(){
|
||||
importExcel();
|
||||
});
|
||||
|
||||
initTable();
|
||||
});
|
||||
}
|
||||
|
|
@ -362,4 +367,83 @@ function closePage(type, params,pageSource) {
|
|||
window.parent.addFitDatas(params,pageSource);
|
||||
}
|
||||
parent.layer.close(index); // 再执行关闭
|
||||
}
|
||||
}
|
||||
|
||||
// 下载模板文件
|
||||
function typeDownload() {
|
||||
window.location.href = '../../../template/安全工器具类型导入模板.xlsx';
|
||||
}
|
||||
|
||||
//导入excel文件
|
||||
function importExcel() {
|
||||
var formData = new FormData($('form')[0]);
|
||||
var name = $("#articleImageFile").val();
|
||||
if (name == null || name == "") {
|
||||
return;
|
||||
}
|
||||
if (!(name.endsWith(".xls") || name.endsWith(".xlsx") || name.endsWith(".xlsm"))) {
|
||||
layer.msg("请上传正确的Excel表格!");
|
||||
$("#articleImageFile").val("");
|
||||
return;
|
||||
}
|
||||
formData.append("file[]", $("#articleImageFile")[0].files[0]);
|
||||
let loadingMsg = layer.msg('正在提交,请稍等...', { icon: 16, shade: 0.01, time: '0' });
|
||||
let url = dataUrlDevice + "backstage/planApply/importExcelTools";
|
||||
ajaxRequestByUploadFile(url, formData, function () {
|
||||
$('.save').addClass("layui-btn-disabled").attr("disabled", true);
|
||||
$('.cancel').addClass("layui-btn-disabled").attr("disabled", true);
|
||||
}, function (result) {
|
||||
$('.save').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
$('.cancel').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
if (result.code === 200) {
|
||||
layer.close(loadingMsg);
|
||||
// 对返回的数据进行处理
|
||||
updateTableWithImportedData(result.data);
|
||||
} else {
|
||||
layer.close(loadingMsg);
|
||||
layer.msg(result.msg, { icon: 2 });
|
||||
}
|
||||
}, function (xhr, status, error) {
|
||||
layer.close(loadingMsg); // 关闭提示层
|
||||
layer.msg('服务异常,请稍后重试', { icon: 16, scrollbar: false, time: 2000 });
|
||||
$('.save').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
$('.cancel').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
errorFn(xhr, status, error)
|
||||
}, null);
|
||||
$("#articleImageFile").val("");
|
||||
}
|
||||
|
||||
function updateTableWithImportedData(data) {
|
||||
// 更新当前表格中显示的数据
|
||||
const tableData = table.cache.currentTableId || []
|
||||
let updated = false
|
||||
|
||||
// 遍历当前表格数据,更新匹配的行
|
||||
for (let i = 0; i < tableData.length; i++) {
|
||||
const rowData = tableData[i]
|
||||
// 在导入数据中查找匹配项
|
||||
const importedItem = data.find((item) => item.id === rowData.id)
|
||||
if (importedItem) {
|
||||
// 更新表格数据
|
||||
rowData.needNum = importedItem.needNum
|
||||
rowData.times = importedItem.times
|
||||
rowData.remarks = importedItem.remarks
|
||||
updated = true
|
||||
|
||||
// 更新表格中对应单元格的显示
|
||||
const rowIndex = rowData.LAY_INDEX
|
||||
// 更新需用量单元格
|
||||
$(`tr[data-index="${rowIndex}"] td[data-field="needNum"] .layui-table-cell`).text(importedItem.needNum || "")
|
||||
// 更新退还日期单元格
|
||||
$(`tr[data-index="${rowIndex}"] td[data-field="times"] .layui-table-cell`).text(importedItem.times || "")
|
||||
// 更新备注单元格
|
||||
$(`tr[data-index="${rowIndex}"] td[data-field="remarks"] .layui-table-cell`).text(importedItem.remarks || "")
|
||||
}
|
||||
}
|
||||
|
||||
// 如果有更新,同步更新全局数据
|
||||
if (updated) {
|
||||
quanju = [...tableData]
|
||||
}
|
||||
layer.msg("数据导入成功", { icon: 1 })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,15 @@
|
|||
<div class="layui-inline">
|
||||
<p style="color: red;font-weight: bold;">已选:<span id="num">0</span></p>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary" onclick="craneDownload()"><i
|
||||
class="layui-icon layui-icon-down"></i>模版下载</button>
|
||||
|
||||
<input id="articleImageFile" name="excelFile" type="file" class="form-control" style="width: 300px; display: inline;" />
|
||||
<input id="saveZipButton" type="button" style="width: 60px;height: 35px;" value="导入" />
|
||||
<input type="file" id="import-excel" name="image" style="display: none;"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -83,4 +92,4 @@
|
|||
<script src="../../../js/aq_demand_plan/child/choose_crane_type_list.js" charset="utf-8"></script>
|
||||
<script src="../../../js/openIframe.js" charset="utf-8"></script>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -59,9 +59,19 @@
|
|||
<button class="layui-btn layui-btn-primary" onclick="queryTable(2)"><i
|
||||
class="layui-icon layui-icon-refresh"></i> 重 置</button>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<p style="color: red;font-weight: bold;">已选:<span id="num">0</span></p>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary" onclick="toolsDownload()"><i
|
||||
class="layui-icon layui-icon-down"></i>模版下载</button>
|
||||
|
||||
<input id="articleImageFile" name="excelFile" type="file" class="form-control" style="width: 300px; display: inline;" />
|
||||
<input id="saveZipButton" type="button" style="width: 60px;height: 35px;" value="导入" />
|
||||
<input type="file" id="import-excel" name="image" style="display: none;"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -83,4 +93,4 @@
|
|||
<script src="../../../js/aq_demand_plan/child/choose_tool_type_list.js" charset="utf-8"></script>
|
||||
<script src="../../../js/openIframe.js" charset="utf-8"></script>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -62,6 +62,15 @@
|
|||
<div class="layui-inline">
|
||||
<p style="color: red;font-weight: bold;">已选:<span id="num">0</span></p>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary" onclick="typeDownload()"><i
|
||||
class="layui-icon layui-icon-down"></i>模版下载</button>
|
||||
|
||||
<input id="articleImageFile" name="excelFile" type="file" class="form-control" style="width: 300px; display: inline;" />
|
||||
<input id="saveZipButton" type="button" style="width: 60px;height: 35px;" value="导入" />
|
||||
<input type="file" id="import-excel" name="image" style="display: none;"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -83,4 +92,4 @@
|
|||
<script src="../../../js/aq_demand_plan/child/choose_type_list.js" charset="utf-8"></script>
|
||||
<script src="../../../js/openIframe.js" charset="utf-8"></script>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue