diff --git a/js/accessory/child/accessory_store_form.js b/js/accessory/child/accessory_store_form.js index 8291d7d..4214bbb 100644 --- a/js/accessory/child/accessory_store_form.js +++ b/js/accessory/child/accessory_store_form.js @@ -52,8 +52,8 @@ function setParams(obj) { }); } }); + getVendList(); }); - getVendList(); } // 设置文件类型 function handleFileType(index, file, result) { diff --git a/js/accessory/child/inventory_count_form.js b/js/accessory/child/inventory_count_form.js deleted file mode 100644 index 8291d7d..0000000 --- a/js/accessory/child/inventory_count_form.js +++ /dev/null @@ -1,442 +0,0 @@ -let idParam, objParam, fileList = new Array(), imgListUp = new Array(); -let form, laydate, layer, upload, table, util; -let pageNum = 1, tableIns; // 定义分页 -let jjDataArr = []; // 入库配件数据 -let cjList = []; // 厂家下拉选 -let delIdArr = []; -function setParams(obj) { - objParam = JSON.parse(obj); - layui.use(['form', 'layer', 'laydate', 'upload', 'table'], function () { - form = layui.form; - layer = layui.layer; - laydate = layui.laydate; - upload = layui.upload; - table = layui.table; - util = layui.util; - laydate.render({ - elem: '#inputDay' - }); - form.verify(); - form.on('submit(formData)', function (data) { - submitApply(data); - }); - form.render(); - let uploadObj = upload.render({ - elem: '#test2', - multiple: true, - dataType: "json", - exts: 'jpg|png|jpeg|doc|docx|pdf|xlsx|xls', - acceptMime: 'image/jpg,image/png,image/jpeg,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - number: 5, //最大上传数量 - size: 1024 * 10, //最大文件大小,单位k - auto: false, //是否自动上传 ,默认为true - bindAction: '#hideUpload', //绑定的按钮 - choose: function (obj) { - let length = $('.file-iteme').length; - if(length >= 5){ - return layer.msg('最多上传5个附件证明', { icon: 7 }); - } - uploadObj.config.elem.next()[0].value = ''; - obj.preview(function (index, file, result) { - console.log(file); - $('#uploader-list').append( - '
' + - '

x

' + - handleFileType(index, file, result) + - '
' - ); - let map = new Map();//将选择的图片索引和图片写成对象存入集合 - map.index = index; - map.file = file; - fileList.push(map); - }); - } - }); - }); - getVendList(); -} -// 设置文件类型 -function handleFileType(index, file, result) { - let html = '', img = ''; - if (file.ext === 'doc' || file.ext === 'docx') { - img = '../../../images/docx.png'; - } else if (file.ext === 'xls' || file.ext === 'xlsx') { - img = '../../../images/xlsx.png'; - } else if (file.ext === 'pdf') { - img = '../../../images/PDF.png'; - } else { - return ''; - } - html += '
' + - '' + - '

' + file.name + '

' + - '
'; - return html; -} - -// 删除文件 -$(document).on("click", ".file-iteme .handle", function (event) { - imgListUp.splice(0, imgListUp.length); - let index = $(this).next().attr('data-index'); - $.each(fileList, function (inx, ele) { - //对比删除文件索引 - //将未删除的存入新集合 - if (index != ele.index) { - imgListUp.push(ele); - } - }); - $(this).parent().remove(); - //将新文件集合替换老集合 - fileList.splice(0, fileList.length); - $.each(imgListUp, function (inx, ele) { - fileList.push(ele) - }); -}); - -function saveData2() { - $('#formSubmit').trigger('click') -} - -function setNumColor(value, type) { // 1.需要量 2.已发货量 3.差缺量 - let color = '#66b1ff'; - if (type === 1) { - color = '#66b1ff'; - } else if (type === 2) { - color = '#19be6b'; - } else if (type === 3) { - color = '#ff9900'; - } - return '' + value + ""; -} - - -// 提交 -function submitApply(data) { - let list = getBaseTableData(); - // 校验附件证明是否上传 - if (fileList.length === 0) { - return layer.msg('请上传附件证明', { icon: 7 }); - } - // 校验配件入库数量 - if (list.length === 0) { - return layer.msg('未填写配件入库数量', { icon: 7 }); - } - for (let i = 0; i < list.length; i++) { - - if (!list[i].inputNum || list[i].inputNum === '0') { - return layer.msg('入库配件明细,第' + (i + 1) + '行,未填写配件入库数量', { icon: 7 }); - } - } - data.field.details = list; - let formData = new FormData(); - //遍历最终文件集合 - for (let i = 0; i < fileList.length; i++) { - formData.append("file[]", fileList[i].file) - } - formData.append('params', JSON.stringify(data.field)); - console.log(JSON.stringify(data.field)); - let loadingMsg = layer.msg('正在提交保存,请稍等...', { icon: 16, shade: 0.01, time: '0' }); - console.log(JSON.stringify(data.field)); - let url = dataUrl + 'backstage/partInput/addInputData'; - ajaxRequestByUploadFile(url, formData, function () { - $('.save').addClass("layui-btn-disabled").attr("disabled", true); - $('.cancel').addClass("layui-btn-disabled").attr("disabled", true); - }, function (result) { - console.log(result); - layer.close(loadingMsg); - $('.save').removeClass("layui-btn-disabled").attr("disabled", false); - $('.cancel').removeClass("layui-btn-disabled").attr("disabled", false); - if (result.code === 200) { - parent.layer.msg(result.msg, { icon: 1 }); - closePage(1); - } else { - 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); -} - -// 获取入库配件明细数据 -function getBaseTableData() { - let tableData = []; - $('#baseTable tbody tr').each(function (index, item) { - let price = $(this).find('td').eq(7).find('input[name="price"]').val(); - let num = $(this).find('td').eq(6).find('input[name="num"]').val(); - tableData.push({ - partId: $(this).attr('id'), - partType: $(this).find('td').eq(2).html(), - partName: $(this).find('td').eq(3).html(), - partModel: $(this).find('td').eq(4).html(), - partUnit: $(this).find('td').eq(5).html(), - inputNum: num ? num : 0, - partPrice: price ? price : 0, - vendId: $(this).find('td').eq(8).find('select[name="manufacturer"]').val(), - vendName: $(this).find('td').eq(8).find('select[name="manufacturer"]').find('option:checked').text(), - remark: $(this).find('td').eq(9).find('input[name="remarks"]').val(), - }) - }) - return tableData; -} - - -// 选择入库配件类型 -function chooseFitType() { - let params = {}; - /* if (jjDataArr && jjDataArr.length > 0) { - params.jjDataArrStr = JSON.stringify(jjDataArr); - } */ - openIframeByParamObj("choose_fit_type", '选择入库配件类型', "./choose_fit_type_list.html", '92%', '95%', params); -} - -// 查询 -function search() { - let keyWord = $('#type').val(); - let keyWord2 = $('#name').val(); - let keyWord3 = $('#model').val(); - if (!keyWord && !keyWord2 && !keyWord3) { - setTableData(jjDataArr); - } else if (keyWord && !keyWord2 && !keyWord3) { - let dataList = jjDataArr.filter(item => { - return item.type.indexOf(keyWord) > -1; - }) - setTableData(dataList); - } else if (!keyWord && keyWord2 && !keyWord3) { - let dataList = jjDataArr.filter(item => { - return item.name.indexOf(keyWord2) > -1; - }) - setTableData(dataList); - } else if (!keyWord && !keyWord2 && keyWord3) { - let dataList = jjDataArr.filter(item => { - return item.model.indexOf(keyWord3) > -1; - }) - setTableData(dataList); - } else if (keyWord && keyWord2 && !keyWord3) { - let dataList = jjDataArr.filter(item => { - return item.type.indexOf(keyWord) > -1 && item.name.indexOf(keyWord2) > -1; - }) - setTableData(dataList); - } else if (keyWord && !keyWord2 && keyWord3) { - let dataList = jjDataArr.filter(item => { - return item.type.indexOf(keyWord) > -1 && item.model.indexOf(keyWord3) > -1; - }) - setTableData(dataList); - } else if (!keyWord && keyWord2 && keyWord3) { - let dataList = jjDataArr.filter(item => { - return item.name.indexOf(keyWord2) > -1 && item.model.indexOf(keyWord3) > -1; - }) - setTableData(dataList); - } else if (keyWord && keyWord2 && keyWord3) { - let dataList = jjDataArr.filter(item => { - return item.type.indexOf(keyWord) > -1 && item.name.indexOf(keyWord2) > -1 && item.model.indexOf(keyWord3) > -1; - }) - setTableData(dataList); - } -} - -// 重置 -function resetSearch() { - $('#type').val(''); - $('#name').val(''); - $('#model').val(''); - setTableData(jjDataArr); -} - -// 子页面回调数据 -function addFitDatas(data) { - console.log('新增的数据:' + data); - if (jjDataArr.length > 0) { // 继续添加数据 - let newJjDataArr = JSON.parse(data); - $.each(newJjDataArr, function (index, item) { - updateOrAddObject(item.id, item); - }); - setTableData(jjDataArr); - } else { // 第一次添加数据 - jjDataArr = JSON.parse(data); - if (jjDataArr && jjDataArr.length > 0) { - $('#no_data_title').css({ 'display': 'none' }); - $('#search-info').removeAttr('style'); - $('#table-box').removeAttr('style'); - setTableData(jjDataArr); - } - } - - function updateOrAddObject(id, newObject) { - const index = jjDataArr.findIndex(obj => obj.id === id); - if (index !== -1) { - // 如果对象存在,则替换它 - jjDataArr[index] = newObject; - } else { - // 如果对象不存在,则添加到数组 - jjDataArr.push(newObject); - } - } -} - -// 入库配件明细表格赋值 -function setTableData(results) { - $('#allCheck').prop('checked', false) - var html = ""; - if (results && results.length > 0) { - for (var i = 0; i < results.length; i++) { - var l = results[i]; - html += ""; - html += ''; - html += "" - + (i + 1) + ""; - html += "" + l.type + ""; - html += "" + l.name + ""; - html += "" + l.model + ""; - html += "" + l.unit + ""; - html += "" + setFormInput(l.num, 1) + ""; - html += "" + setFormInput(l.price, 2) + ""; - html += "" + setFormInput(l.manufacturer, 3) + ""; - html += "" + setFormInput(l.remarks, 4) + ""; - html += ""; - } - } else { - html += "没有相关数据"; - } - $("#baseTable tbody").empty().append(html); - layui.form.render(); -} - -function setFormInput(value, type) { - let html = '
'; - if (type === 1) { // 入库量 - html += ''; - } else if (type === 2) { // 单价 - html += ''; - } else if (type === 3) { // 厂家 - html += ''; - } else if (type === 4) { // 备注 - html += ''; - } - html += '
'; - return html; - -} - -function setSelectData(value) { - let html = ''; - $.each(cjList, function (index, item) { - if (item.id === value) { - html += '' - } else { - html += '' - } - - }) - return html; -} - -// 厂家下拉选 -function getVendList() { - cjList.splice(0, cjList.length); - let encryptedData = {}; - let url = dataUrl + 'backstage/paType/getVendList?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData)); - ajaxRequest(url, "GET", null, false, function () { - }, function (result) { - console.log(result); - if (result.code === 200) { - cjList = result.data; - } - }, function (xhr, status, error) { - errorFn(xhr, status, error) - }, null); -} - -// 复选框全选 -function selectAll(selectStatus) {//传入参数(全选框的选中状态) - if (selectStatus) { - $("input[name='check']").each(function (i, n) { - n.checked = true; - }); - $.each(jjDataArr, function (index, item) { - delIdArr.push(item.id); - }) - } else { - $("input[name='check']").each(function (i, n) { - n.checked = false; - }); - delIdArr.splice(0, delIdArr.length); - } -} - -// 单个选中 -function sel(selectStatus, that, id) { - if (selectStatus) { - $(that).prop('checked', true); - delIdArr.push(id); - } else { - $(that).prop('checked', false); - for (let i = 0; i < delIdArr.length; i++) { - if (delIdArr[i] == id) { - arr.splice(i, 1); - break; - } - } - } -} - -// 删除选中 -function delFitType() { - if (delIdArr.length == 0) { - layer.msg('请先选择需要删除的数据!', { icon: 7 }) - return; - } - let layerIndex = layer.confirm('
确定要删除选中数据吗!
', { title: '操作提示' }, function () { - layer.close(layerIndex); - for (let i = 0; i < delIdArr.length; i++) { - for (let j = 0; j < jjDataArr.length; j++) { - let id = jjDataArr[j].id; - if (delIdArr[i] == id) { - jjDataArr.splice(j, 1); - break; - } - } - } - if (jjDataArr.length === 0) { - $('#no_data_title').removeAttr('style'); - $('#search-info').css({ 'display': 'none' }); - $('#table-box').css({ 'display': 'none' }); - } else { - setTableData(jjDataArr); - } - - }); -} - -// 校验数据 -function checkValue(that, type) { - let value = $(that).val(); - if (type === 1) { // 入库量 - const regex = /^(0|[1-9]\d{0,6})$/; - if (!regex.test(value) && value) { - layer.msg('入库量输入不合法,请重新输入!', { icon: 5 }) - $(that).val(''); - } - } else if (type === 2) { // 单价 - const regex = /^(?:1(?:\d{0,8}|[0-9]*\.\d{1,2})|(?:[1-9]\d{0,7}|[1-9]\d{0,6}\.\d{1,2}|[1-9]\d{1,7}\.\d{2}|100000000(?:\.00)?))$/; - if (!regex.test(value) && value) { - layer.msg('单价输入不合法,请重新输入!', { icon: 5 }) - $(that).val(''); - } - } -} - -// 关闭页面 -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/inventory_count_form.html b/page/accessory/child/inventory_count_form.html deleted file mode 100644 index b9685d4..0000000 --- a/page/accessory/child/inventory_count_form.html +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - 发货 - - - - - - - -
-
-
-
-
- -
- -
-
-
- -
-
- -
- -
-
-
-
- -
- -
-
- -
-
-
-

附件证明*

-
-
- -
-

(最多上传5个附件)

-
-
-
- -

入库配件明细

-
- -
- 无数据 -

您还没选择入库配件类型

-

需要添加配件类型后才能执行入库操作

- -
- - -
-
- - -
-
- - - - - - - - \ No newline at end of file