diff --git a/js/accessory/child/accessory_store_form.js b/js/accessory/child/accessory_store_form.js index 7a78952..98490c8 100644 --- a/js/accessory/child/accessory_store_form.js +++ b/js/accessory/child/accessory_store_form.js @@ -219,7 +219,7 @@ function chooseFitType() { /* if (jjDataArr && jjDataArr.length > 0) { params.jjDataArrStr = JSON.stringify(jjDataArr); } */ - openIframeByParamObj("choose_fit_type", '选择入库配件类型', "./choose_fit_type_list.html", '82%', '90%', params); + openIframeByParamObj("choose_fit_type", '选择入库配件类型', "./choose_fit_type_list.html", '92%', '95%', params); } function addJjDatas(data) { diff --git a/js/accessory/child/choose_fit_type_list.js b/js/accessory/child/choose_fit_type_list.js index 7e75541..a334169 100644 --- a/js/accessory/child/choose_fit_type_list.js +++ b/js/accessory/child/choose_fit_type_list.js @@ -1,15 +1,19 @@ let objParam; -let form, table, element, tableIns, layer; +let form, table, element, tableIns, layer, util; let pageNum = 1; +let quanju = new Array();//全局 +let huancun = new Array();//缓存 +let huancunObj = new Array();//缓存2 function setParams(obj) { objParam = JSON.parse(obj); console.log(objParam); $('#proName').html(objParam.proName); - layui.use(["form", "table", 'element', 'layer'], function () { + layui.use(["form", "table", 'element', 'layer', 'util'], function () { form = layui.form; table = layui.table; element = layui.element; layer = layui.layer; + util = layui.util; initTable(); }); } @@ -19,17 +23,13 @@ function queryTable(type) { if (type === 1) { reloadTable(1); } else if (type === 2) { - $('#keyWord').val(''); + $('#name').val(''); + $('#module').val(''); layui.form.render(); reloadTable(1); } } -// 刷新页面数据 -function reloadData() { - reloadData(pageNum); -} - // 重载表格 function reloadTable(pageNum) { table.reload("currentTableId", { @@ -38,27 +38,29 @@ function reloadTable(pageNum) { }, where: { encryptedData: JSON.stringify({ - 'keyWord': $('#keyWord').val(), - 'proId': objParam.proId + 'name': $('#name').val(), + 'module': $('#module').val(), }), }, }, ); } + +// 表格数据 function initTable() { tableIns = table.render({ elem: "#currentTableId", id: 'currentTableId', + height: "full-200", headers: { authorization: sessionStorage.getItem("gz-token"), }, - height: "full-180", - url: dataUrl + "backstage/planOut/getProPlanListByProId", + url: dataUrl + "backstage/planOut/getPorInfoDetail", where: { encryptedData: JSON.stringify({ - 'keyWord': $('#keyWord').val(), - 'proId': objParam.proId + 'name': $('#name').val(), + 'module': $('#module').val(), }), }, request: { @@ -66,6 +68,17 @@ function initTable() { limitName: 'pageSize' }, parseData: function (res) { // res 即为原始返回的数据 + /* if (jjDetailArr && res.list) { + $.each(res.list, function (index, item) { + $.each(jjDetailArr, function (index2, item2) { + if (item.id === item2.id) { + item.num = item2.num; + item.tzNum = item2.tzNum; + item.outId = item2.outId; + } + }); + }); + } */ return { "code": 0, // 解析接口状态 "msg": '获取成功', // 解析提示文本 @@ -75,106 +88,228 @@ function initTable() { }, cols: [ [ + { type: 'checkbox', width: '5%' }, { - width: '9.9%', + width: '6%', title: "序号", align: "center", - unresize: true, templet: function (d) { return d.LAY_NUM; }, }, { - field: "code", + field: "type", + width: '11.8%', + title: "配件类型", + unresize: true, + align: "center", + }, + { + field: "name", + width: '12%', + title: "配件名称", + unresize: true, + align: "center", + }, + { + field: "module", + width: '10%', + title: "规格型号", + unresize: true, + align: "center", + }, + { + field: "unit", + title: "单位", + width: '8%', + unresize: true, + align: "center", + }, + { + field: "num", + width: '10%', + title: " * 本次入库量", + unresize: true, + align: "center", + edit: 'text', + style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' + }, + { + field: "num", + width: '9.8%', + title: "单价(元)", + unresize: true, + align: "center", + edit: 'text', + style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' + }, + { + field: "num", width: '15%', - title: "计划编号", - unresize: true, - align: "center", - }, - { - field: "proName", - width: '20%', - title: "工程名称", - unresize: true, - align: "center", - }, - { - field: "needTime", - width: '10%', - title: "需用日期", - unresize: true, - align: "center", - }, - { - field: "creator", - width: '10%', - title: "申请人 ", - unresize: true, - align: "center", - }, - { - field: "createTime", - width: '10%', - title: "申请时间", + title: " * 配件厂家", unresize: true, align: "center", + templet: '#TPL-select-demo' + // style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' }, { field: "remark", - width: '15%', - title: "计划说明 ", + width: '12%', + title: "备注", unresize: true, align: "center", + edit: 'textarea', + style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' }, - { - width: '10%', - title: "操作 ", - unresize: true, - align: "center", - templet: function (d) { - let html = ""; - html += "详情"; - return html; - }, - }, - ] + + ], ], limits: [10, 15, 20, 25, 50, 100], limit: 10, page: true, done: function (res, curr, count) { - pageNum = tableIns.config.page.curr; - element.render(); + var options = this; table.resize("currentTableId"); + pageNum = tableIns.config.page.curr; + // layui form select 事件 + form.on('select(select-demo)', function (obj) { + console.log(obj); + + var value = obj.value; // 获取选中项 value + // 获取当前行数据(如 id 等字段,以作为数据修改的索引) + var data = table.getRowData(options.id, obj.elem); + // 更新数据中对应的字段 + data.city = value; + // 显示当前行最新数据 - 仅用于示例展示 + showData(data); + }); + // 展示数据 - 仅用于演示 + var showData = function (data) { + return layer.msg('当前行最新数据:
' + util.escape(JSON.stringify(data)), { + offset: '16px', + anim: 'slideDown' + }); + }; + // 获取当前行数据 - 自定义方法 + table.getRowData = function (tableId, elem) { + var index = $(elem).closest('tr').data('index'); + return table.cache[tableId][index] || {}; + }; + + //设置全部数据到全局变量 + quanju = res.data; + //在缓存中找到id ,然后设置data表格中的选中状态 + //循环所有数据,找出对应关系,设置checkbox选中状态 + for (var i = 0; i < res.data.length; i++) { + for (var j = 0; j < huancun.length; j++) { + //数据id和要勾选的id相同时checkbox选中 + if (res.data[i].id === huancun[j]) { + //这里才是真正的有效勾选 + res.data[i]["LAY_CHECKED"] = 'true'; + //找到对应数据改变勾选样式,呈现出选中效果 + var index = res.data[i]['LAY_INDEX']; + $('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true); + $('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked'); + } + } + } + //设置全选checkbox的选中状态,只有改变LAY_CHECKED的值, table.checkStatus才能抓取到选中的状态 + let checkStatus = table.checkStatus('currentTableId');//这里的lightTable是指分页中的id + if (checkStatus.isAll) {//是否全选 + //layTableAllChoose + $('.layui-table th[data-field="0"] input[type="checkbox"]').prop('checked', true);//data-field值默认为0,如果在分页部分自定义了属性名,则需要改成对应的属性名 + $('.layui-table th[data-field="0"] input[type="checkbox"]').next().addClass('layui-form-checked');//data-field值默认为0,如果在分页部分自定义了属性名,则需要改成对应的属性名 + } }, }); + table.on('edit(currentTableId)', function (obj) { + console.log(obj); + var field = obj.field; // 得到修改的字段 + var value = obj.value // 得到修改后的值 + var oldValue = obj.oldValue // 得到修改前的值 -- v2.8.0 新增 + var data = obj.data // 得到所在行所有键值 + var col = obj.getCol(); // 得到当前列的表头配置属性 -- v2.8.0 新增 + if (field === 'num' || field === 'tzNum') { // 本次发货量/调整量 + if (value) { + const regex = /^(0|[1-9]\d{0,6})$/; + if (!regex.test(value)) { + obj.reedit(); + return layer.msg('格式不正确,最大输入6位数,且为正整数!', { icon: 7 }) + } + } + } else if (field === 'outId') { // 备注 + if (value) { + if (value.length > 255) { + obj.reedit(); + return layer.msg('备注最多输入255位!', { icon: 7 }) + } + } + } + // 显示 - 仅用于演示 + // layer.msg('[ID: ' + data.id + '] ' + field + ' 字段更改值为:' + util.escape(value)); + let id = obj.data.id; + let num = obj.data.num; + let tzNum = obj.data.tzNum; + let outId = obj.data.outId; + let type = obj.data.type; + let name = obj.data.name; + let module = obj.data.module; + let objParam = { + id: id, + num: num, + tzNum: tzNum, + outId: outId, + type: type, + name: name, + module: module, + remarks: outId + } + updateOrAddObject(id, objParam); + }); + //复选框选中监听,将选中的id 设置到缓存数组,或者删除缓存数组 + table.on('checkbox(currentTableId2)', function (obj) { + alert(12); + if (obj.checked === true) { + if (obj.type === 'one' && huancun.indexOf(obj.data.id) === -1) { + huancun.push(obj.data.id); + } else { + for (let i = 0; i < quanju.length; i++) { + if (huancun.indexOf(quanju[i].id) === -1) { + huancun.push(quanju[i].id); + } + } + } + } else { + if (obj.type === 'one') { + for (let i = 0; i < huancun.length; i++) { + if (huancun[i] === obj.data.id) { + removeByValue(huancun, huancun[i]);//调用自定义的根据值移除函数 + } + } + } else { + for (let i = 0; i < quanju.length; i++) { + for (let j = 0; j < huancun.length; j++) { + if (huancun[j] === quanju[i].id) { + removeByValue(huancun, +huancun[j]);//调用自定义的根据值移除函数 + } + } + } + } + } + }); } -// 数量颜色 1.需要量 2.已发货量 3.待发货量 -function setNumColor(value, type) { - let color = "#409Eff"; - if (type === 1) { - color = "#409Eff"; - } else if (type === 2) { - color = "#19be6b"; - } else if (type === 3) { - color = "#f56c6c"; - } - return '' + value + ""; -} - -// 导出 -function exportExcel() { - let params = { - 'keyWord': $('#keyWord').val(), - 'proId': objParam.proId - } - let url = dataUrl + "backstage/export/export"; - exportExcelUtil(url, '需求计划', JSON.stringify(params)); -} - -// 需求计划编号 +// 配件类型 function addFitTypeData() { - openIframeByParamObj2("add_fit_type_data", "配件类型", "../../../page/basic/fit_type_list.html", "82%", "90%", {}); + openIframeByParamObj2("add_fit_type_data", "配件类型", "../../../page/basic/fit_type_list.html", "92%", "95%", {}); +} + +function closePage(type) { + let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引 + parent.layer.close(index); // 再执行关闭 + if (type == 1) { + window.parent.reloadData(); + } + } \ No newline at end of file diff --git a/page/accessory/child/choose_fit_type_list.html b/page/accessory/child/choose_fit_type_list.html index 7c0bc18..f1a6101 100644 --- a/page/accessory/child/choose_fit_type_list.html +++ b/page/accessory/child/choose_fit_type_list.html @@ -15,6 +15,22 @@ padding: 0; height: 100%; } + + .layui-table-view .layui-table th { + font-size: 18px; + color: #262626; + letter-spacing: 1px; + outline: none !important; + } + + .btn-box { + width: 100%; + height: 60px; + box-sizing: border-box; + display: flex; + justify-content: center; + align-items: center; + } @@ -26,9 +42,21 @@
-
+
+ class="layui-input" lay-affix="clear" placeholder="输入配件类型" maxlength="30"> +
+
+
+
+ +
+
+
+
+
@@ -50,9 +78,22 @@
+
+ + +
+