12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109 |
- var ExcelData, ExcelKind;
- var clickflag = 0;
- function ConfirmImport() {
- var index = layer.load(1, {
- shade: [0.5, '#000']
- });
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/Import?r=" + Math.random(1),
- data: "Kind=" + ExcelKind + "&ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
- dataType: "text",
- success: function (data) {
- layer.close(index);
- if (data.indexOf("success") == 0) {
- layer.msg("成功操作" + data.split('|')[1] + "部机具", {
- time: 2000
- }, function () {
- window.location.reload();
- });
- } else {
- layer.msg(data);
- }
- }
- });
- }
- function ConfirmRejectImport() {
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/RejectStore?r=" + Math.random(1),
- data: "ExcelKind=" + ExcelKind + "&ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
- dataType: "text",
- success: function (data) {
- if (data == "success") {
- layer.msg("导入成功", { time: 2000 }, function () {
- window.location.reload();
- });
- } else if (data.indexOf("warning") == 0) {
- var datalist = data.split('|');
- layer.alert(datalist[0], { time: 20000 }, function () {
- window.location.reload();
- });
- } else {
- layer.msg(data);
- }
- }
- });
- }
- function CheckImport(table, key, loadindex, index) {
- $.ajax({
- url: "/Admin/StoreHouse/CheckImportV2?r=" + Math.random(1),
- data: "key=" + key,
- dataType: "json",
- success: function (data) {
- if (data.status == 1) {
- layer.msg("成功操作" + data.data + "部机具", {
- time: 2000
- }, function () {
- layer.close(index); //关闭弹层
- layer.close(loadindex);
- table.reload('LAY-list-manage'); //数据刷新
- });
- } else if (data.status == 2) {
- layer.close(index); //关闭弹层
- layer.close(loadindex);
- var content = '';
- for (var i = 0; i < data.errList.length; i++) {
- content += data.errList[i] + '<br/>'
- }
- layer.alert(content);
- } else {
- layer.msg(data.data, {
- time: 1000
- }, function () {
- CheckImport(table, key, loadindex, index);
- });
- }
- }
- });
- }
- var excel;
- var loadindex;
- layui.config({
- base: '/layuiadmin/' //静态资源所在路径
- }).extend({
- myexcel: 'layui/lay/modules/excel',
- index: 'lib/index' //主入口模块
- }).use(['index', 'table', 'excel', 'laydate'], function () {
- var $ = layui.$,
- form = layui.form,
- table = layui.table;
- //- 筛选条件-日期
- var laydate = layui.laydate;
- var layCreateDate = laydate.render({
- elem: '#CreateDate',
- type: 'date',
- range: true,
- trigger: 'click',
- change: function (value, date, endDate) {
- var op = true;
- if (date.year == endDate.year && endDate.month - date.month <= 1) {
- if (endDate.month - date.month == 1 && endDate.date > date.date) {
- op = false;
- layCreateDate.hint('日期范围请不要超过1个月');
- setTimeout(function () {
- $(".laydate-btns-confirm").addClass("laydate-disabled");
- }, 1);
- }
- } else {
- op = false;
- layCreateDate.hint('日期范围请不要超过1个月');
- setTimeout(function () {
- $(".laydate-btns-confirm").addClass("laydate-disabled");
- }, 1);
- }
- if (op) {
- $('#CreateDate').val(value);
- }
- }
- });
- //excel导入
- excel = layui.excel;
- $('#ExcelFile').change(function (e) {
- var files = e.target.files;
- excel.importExcel(files, {}, function (data) {
- ExcelData = data[0].Sheet1;
- });
- });
- //监听单元格编辑
- table.on('edit(LAY-list-manage)', function (obj) {
- var value = obj.value //得到修改后的值
- ,
- data = obj.data //得到所在行所有键值
- ,
- field = obj.field; //得到字段
- if (field == "Sort") {
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/Sort?r=" + Math.random(1),
- data: "Id=" + data.Id + "&Sort=" + value,
- dataType: "text",
- success: function (data) { }
- });
- }
- });
- //列表数据
- table.render({
- elem: '#LAY-list-manage',
- url: '/Admin/StoreHouse/IndexData' //模拟接口
- ,
- cols: [
- [{
- type: 'checkbox',
- fixed: 'left'
- }, {
- field: 'StoreNo',
- width: 110,
- title: '仓库编号',
- sort: true
- }, {
- field: 'StoreName',
- width: 110,
- title: '仓库名称',
- sort: true
- }, {
- field: 'ManageUserIdMakerCode',
- width: 145,
- title: '仓库负责人编号',
- sort: true,
- templet: '#ManageTpl'
- }, {
- field: 'ManageUserIdRealName',
- width: 120,
- title: '仓库管理员',
- sort: true
- }, {
- field: 'UserIdMakerCode',
- width: 160,
- title: '仓库归属创客编号',
- sort: true,
- templet: '#MakerCodeTpl'
- }, {
- field: 'UserIdRealName',
- width: 175,
- title: '仓库归属人真实姓名',
- sort: true
- }, {
- field: 'BrandId',
- width: 110,
- title: '产品类型',
- sort: true
- }, {
- field: 'Address',
- width: 110,
- title: '仓库地址',
- sort: true
- }, {
- field: 'ManageUserIdMobile',
- width: 160,
- title: '仓库管理员手机号',
- sort: true
- }, {
- field: 'ManagerEmail',
- width: 120,
- title: '管理者邮箱',
- sort: true
- }, {
- field: 'StoreType',
- width: 110,
- title: '仓库类型',
- sort: true
- }, {
- field: 'TotalNum',
- width: 110,
- title: '总库存数',
- sort: true
- }, {
- field: 'LaveNum',
- width: 120,
- title: '剩余库存数',
- sort: true
- }, {
- field: 'PreNum',
- width: 120,
- title: '小分仓数',
- sort: true
- }, {
- field: 'OutNum',
- width: 100,
- title: '出库数',
- sort: true
- }, {
- field: 'LimitTopUserId',
- width: 160,
- title: '限制创客特殊仓库',
- sort: true
- }, {
- field: 'Status',
- width: 110,
- title: '仓库状态',
- sort: true
- }, {
- field: 'OpIdStatus',
- width: 130,
- title: '关联运营中心',
- sort: true
- }, {
- field: 'StoreKind',
- width: 130,
- title: '仓库归属类型',
- sort: true
- }, {
- field: 'CreateMan',
- width: 130,
- title: '创建/修改人',
- sort: true
- }, {
- field: 'CreateDate',
- width: 110,
- title: '创建时间',
- sort: true
- }, {
- field: 'Deposit',
- width: 110,
- title: '押金',
- sort: true
- }, {
- field: 'ValidAmount',
- width: 110,
- title: '可用额度',
- sort: true
- }, {
- field: 'FixedAmount',
- width: 110,
- title: '固定额度',
- sort: true
- }, {
- field: 'TempAmount',
- width: 110,
- title: '临时额度',
- sort: true
- }, {
- field: 'PromissAmount',
- width: 110,
- title: '担保额度',
- sort: true
- }, {
- field: 'ThisMonthPreAmount',
- width: 150,
- title: '本月小分仓额度',
- sort: true
- }, {
- field: 'ValidPreAmount',
- width: 150,
- title: '可用小分仓额度',
- sort: true
- }, {
- title: '操作',
- width: 500,
- align: 'center',
- fixed: 'right',
- toolbar: '#table-list-tools'
- }
- ]
- ],
- where: {
- },
- page: true,
- limit: 500,
- height: 'full-' + String($('.layui-card-header').height() + 130),
- text: '对不起,加载出现异常!',
- done: function (res, curr, count) {
- $(".layui-none").text("无数据");
- layer.close(loadindex);
- }
- });
- //监听工具条
- table.on('tool(LAY-list-manage)', function (obj) {
- var data = obj.data;
- if (obj.event === 'del') {
- var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
- data: "Id=" + data.Id,
- dataType: "text",
- success: function (data) {
- if (data == "success") {
- obj.del();
- layer.close(index);
- } else {
- parent.layer.msg(data);
- }
- }
- });
- });
- } else if (obj.event === 'sycn') {
- var index = layer.confirm('确定要同步该仓库的库存数据吗?', function (index) {
- layer.close(index);
- var loadindex = layer.load(1, {
- shade: [0.5, '#000']
- });
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
- data: "Id=" + data.Id,
- dataType: "text",
- success: function (data) {
- layer.close(loadindex);
- if (data == "success") {
- layer.msg('同步成功');
- table.reload('LAY-list-manage');
- } else {
- layer.msg(data);
- }
- }
- });
- });
- } else if (obj.event === 'sycnamount') {
- var index = layer.confirm('确定要重置该仓库额度吗?', function (index) {
- layer.close(index);
- var loadindex = layer.load(1, {
- shade: [0.5, '#000']
- });
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/SycnAmountData?r=" + Math.random(1),
- data: "Id=" + data.Id,
- dataType: "text",
- success: function (data) {
- layer.close(loadindex);
- if (data == "success") {
- layer.msg('重置成功');
- table.reload('LAY-list-manage');
- } else {
- layer.msg(data);
- }
- }
- });
- });
- } else if (obj.event === 'edit') {
- var tr = $(obj.tr);
- var perContent = layer.open({
- type: 2,
- title: '仓库-编辑',
- content: 'Edit?Id=' + data.Id + '',
- maxmin: true,
- area: ['800px', '650px'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- var iframeWindow = window['layui-layer-iframe' + index],
- submitID = 'LAY-list-front-submit',
- submit = layero.find('iframe').contents().find('#' + submitID);
- setTimeout(function () {
- layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
- var errObj = $(this).find('.layui-form-danger');
- if (errObj.length > 0) {
- iframeWindow.element.tabChange('mytabbar', String(i + 1));
- submit.click();
- }
- });
- }, 300);
- //监听提交
- iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
- var field = data.field; //获取提交的字段
- var userdata = "";
- for (var prop in field) {
- userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
- }
- //提交 Ajax 成功后,静态更新表格中的数据
- //$.ajax({});
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/Edit?r=" + Math.random(1),
- data: userdata,
- dataType: "text",
- success: function (data) {
- if (data == "success") {
- layer.close(index); //关闭弹层
- table.reload('LAY-list-manage'); //数据刷新
- } else {
- layer.msg(data);
- }
- }
- });
- });
- submit.trigger('click');
- },
- success: function (layero, index) {
- }
- });
- } else if (obj.event === 'edits') {
- var tr = $(obj.tr);
- var perContent = layer.open({
- type: 2,
- title: '一键新建仓库',
- content: 'Edits?Id=' + data.Id + '',
- maxmin: true,
- area: ['860px', '650px'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- var iframeWindow = window['layui-layer-iframe' + index],
- submitID = 'LAY-list-front-submit',
- submit = layero.find('iframe').contents().find('#' + submitID);
- setTimeout(function () {
- layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
- var errObj = $(this).find('.layui-form-danger');
- if (errObj.length > 0) {
- iframeWindow.element.tabChange('mytabbar', String(i + 1));
- submit.click();
- }
- });
- }, 300);
- //监听提交
- iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
- var field = data.field; //获取提交的字段
- var userdata = "";
- for (var prop in field) {
- userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
- }
- //提交 Ajax 成功后,静态更新表格中的数据
- //$.ajax({});
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/Edits?r=" + Math.random(1),
- data: userdata,
- dataType: "text",
- success: function (data) {
- if (data == "success") {
- layer.close(index); //关闭弹层
- table.reload('LAY-list-manage'); //数据刷新
- } else {
- layer.msg(data);
- }
- }
- });
- });
- submit.trigger('click');
- },
- success: function (layero, index) {
- }
- });
- }
- });
- //监听搜索
- form.on('submit(LAY-list-front-search)', function (data) {
- var field = data.field;
- field.ShowFlag = 1;
- if (field.StoreNo == "" && field.StoreName == "" && field.UserIdMakerCode == "" && field.BrandId == "" && field.UserIdRealName == "" && field.ManageUserIdRealName == "" && field.ManageUserIdMobile == "" && field.ManageUserIdMakerCode == "" && field.ManagerEmail == "" && field.StoreStatusSelect == "" && field.CreateDateData == "" && field.MakerCode == "" && field.YZOpCode == "" && field.OpStatusSelect == "" && field.StoreKindSelect == "") {
- layer.alert('请输入查询条件');
- }
- else {
- //执行重载
- table.reload('LAY-list-manage', {
- where: field,
- page: {
- curr: 1
- }
- });
- }
- });
- form.on('submit(LAY-list-front-searchall)', function (data) {
- var field = data.field;
- field.ShowFlag = 1;
- console.log(field.ShowFlag)
- field.StoreNo = "";
- field.StoreName = "";
- field.ManagerEmail = "";
- field.UserIdMakerCode = "";
- field.BrandId == "";
- field.UserIdRealName = "";
- field.ManageUserIdRealName = "";
- field.ManageUserIdMobile = "";
- field.ManageUserIdMakerCode = "";
- field.StoreStatusSelect = "";
- field.CreateDateData = "";
- table.reload('LAY-list-manage', {
- where: field,
- page: {
- curr: 1
- }
- });
- });
- //事件
- var active = {
- batchdel: function () {
- var checkStatus = table.checkStatus('LAY-list-manage'),
- data = checkStatus.data; //得到选中的数据
- if (data.length < 1) {
- parent.layer.msg("请选择要删除的项");
- } else {
- var ids = "";
- $.each(data, function (index, value) {
- ids += data[index].Id + ",";
- });
- ids = ids.substring(0, ids.length - 1);
- var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
- data: "Id=" + ids,
- dataType: "text",
- success: function (data) {
- layer.close(index);
- if (data == "success") {
- table.reload('LAY-list-manage');
- } else {
- layer.msg(data);
- }
- }
- });
- });
- }
- },
- add: function () {
- var perContent = layer.open({
- type: 2,
- title: '仓库-添加',
- content: 'Add',
- maxmin: true,
- area: ['950px', '650px'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- var iframeWindow = window['layui-layer-iframe' + index],
- submitID = 'LAY-list-front-submit',
- submit = layero.find('iframe').contents().find('#' + submitID);
- setTimeout(function () {
- layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
- var errObj = $(this).find('.layui-form-danger');
- if (errObj.length > 0) {
- iframeWindow.element.tabChange('mytabbar', String(i + 1));
- submit.click();
- }
- });
- }, 300);
- //监听提交
- iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
- var field = data.field; //获取提交的字段
- var userdata = "";
- for (var prop in field) {
- userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
- }
- //提交 Ajax 成功后,静态更新表格中的数据
- //$.ajax({});
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/Add?r=" + Math.random(1),
- data: userdata,
- dataType: "text",
- success: function (data) {
- if (data == "success") {
- layer.close(index); //关闭弹层
- table.reload('LAY-list-manage'); //数据刷新
- } else {
- layer.msg(data);
- }
- }
- });
- });
- submit.trigger('click');
- }
- });
- },
- ImportMachine: function () {
- var perContent = layer.open({
- type: 2,
- title: '机具入库',
- content: 'Import?ExcelKind=1',
- maxmin: true,
- area: ['650px', '350px'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- var iframeWindow = window['layui-layer-iframe' + index],
- submitID = 'LAY-list-front-submit',
- submit = layero.find('iframe').contents().find('#' + submitID);
- //监听提交
- iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
- var field = data.field; //获取提交的字段
- var userdata = "";
- for (var prop in field) {
- userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
- }
- //提交 Ajax 成功后,静态更新表格中的数据
- //$.ajax({});
- var loadindex = layer.load(1, {
- shade: [0.5, '#000']
- });
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
- data: userdata,
- dataType: "text",
- success: function (data) {
- if (data.indexOf("success") == 0) {
- var datalist = data.split('|');
- var key = datalist[1];
- CheckImport(table, key, loadindex, index);
- } else {
- layer.msg(data);
- }
- }
- });
- });
- submit.trigger('click');
- }
- });
- },
- ImportChange: function () {
- var perContent = layer.open({
- type: 2,
- title: '仓库调拨',
- content: 'Import?ExcelKind=2',
- maxmin: true,
- area: ['650px', '350px'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- var iframeWindow = window['layui-layer-iframe' + index],
- submitID = 'LAY-list-front-submit',
- submit = layero.find('iframe').contents().find('#' + submitID);
- //监听提交
- iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
- var field = data.field; //获取提交的字段
- var userdata = "";
- for (var prop in field) {
- userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
- }
- //提交 Ajax 成功后,静态更新表格中的数据
- //$.ajax({});
- var loadindex = layer.load(1, {
- shade: [0.5, '#000']
- });
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
- data: userdata,
- dataType: "text",
- success: function (data) {
- if (data.indexOf("success") == 0) {
- var datalist = data.split('|');
- var key = datalist[1];
- CheckImport(table, key, loadindex, index);
- } else {
- layer.msg(data);
- }
- }
- });
- });
- submit.trigger('click');
- }
- });
- },
- ImportSend: function () {
- var perContent = layer.open({
- type: 2,
- title: '仓库发货至创客',
- content: 'Import?ExcelKind=3',
- maxmin: true,
- area: ['650px', '350px'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- var iframeWindow = window['layui-layer-iframe' + index],
- submitID = 'LAY-list-front-submit',
- submit = layero.find('iframe').contents().find('#' + submitID);
- //监听提交
- iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
- var field = data.field; //获取提交的字段
- var userdata = "";
- for (var prop in field) {
- userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
- }
- //提交 Ajax 成功后,静态更新表格中的数据
- //$.ajax({});
- var loadindex = layer.load(1, {
- shade: [0.5, '#000']
- });
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
- data: userdata,
- dataType: "text",
- success: function (data) {
- if (data.indexOf("success") == 0) {
- var datalist = data.split('|');
- var key = datalist[1];
- CheckImport(table, key, loadindex, index);
- } else {
- layer.msg(data);
- }
- }
- });
- });
- submit.trigger('click');
- }
- });
- },
- ImportBack: function () {
- var perContent = layer.open({
- type: 2,
- title: '机具回仓库',
- content: 'Import?ExcelKind=4',
- maxmin: true,
- area: ['650px', '350px'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- var iframeWindow = window['layui-layer-iframe' + index],
- submitID = 'LAY-list-front-submit',
- submit = layero.find('iframe').contents().find('#' + submitID);
- //监听提交
- iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
- var field = data.field; //获取提交的字段
- var userdata = "";
- for (var prop in field) {
- userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
- }
- //提交 Ajax 成功后,静态更新表格中的数据
- //$.ajax({});
- var loadindex = layer.load(1, {
- shade: [0.5, '#000']
- });
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
- data: userdata,
- dataType: "text",
- success: function (data) {
- if (data.indexOf("success") == 0) {
- var datalist = data.split('|');
- var key = datalist[1];
- CheckImport(table, key, loadindex, index);
- } else {
- layer.msg(data);
- }
- }
- });
- });
- submit.trigger('click');
- }
- });
- }, ImportRejectStore: function () {
- ExcelKind = 1;
- layer.open({
- type: 1,
- title: '导入',
- maxmin: false,
- area: ['650px', '350px'],
- // btn: ['确定', '取消'],
- content: $('#excelForm'),
- cancel: function () {
- }
- });
- $("#excelTemp").html('<a href="/users/创客机具驳回仓库模版.xlsx">点击下载创客机具驳回仓库模版</a>');
- },
- ExportExcel: function () {
- var userdata = '';
- $(".layuiadmin-card-header-auto input").each(function (i) {
- userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
- });
- $(".layuiadmin-card-header-auto select").each(function (i) {
- userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
- });
- $.ajax({
- type: "GET",
- url: "/Admin/StoreHouse/ExportExcel?r=" + Math.random(1),
- data: userdata,
- dataType: "json",
- success: function (data) {
- data.Obj.unshift(data.Fields);
- excel.exportExcel(data.Obj, data.Info, 'xlsx');
- }
- });
- }, BatchSetting: function () {
- var checkStatus = table.checkStatus('LAY-list-manage'),
- data = checkStatus.data; //得到选中的数据
- if (data.length < 1) {
- parent.layer.msg("请选择要关联的分仓");
- } else {
- var ids = "";
- $.each(data, function (index, value) {
- ids += data[index].Id + ",";
- });
- ids = ids.substring(0, ids.length - 1);
- var perContent = layer.open({
- type: 2,
- title: '关联分仓',
- content: 'BatchSetting?StoreIds=' + ids,
- maxmin: true,
- area: ['550px', '350px'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- loadindex = layer.load(1, {
- shade: [0.5, '#000']
- });
- var iframeWindow = window['layui-layer-iframe' + index],
- submitID = 'LAY-list-front-submit',
- submit = layero.find('iframe').contents().find('#' + submitID);
- setTimeout(function () {
- layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
- var errObj = $(this).find('.layui-form-danger');
- if (errObj.length > 0) {
- iframeWindow.element.tabChange('mytabbar', String(i + 1));
- submit.click();
- }
- });
- }, 300);
- //监听提交
- iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
- if (clickflag == 0) {
- clickflag = 1;
- var field = data.field; //获取提交的字段
- var userdata = "";
- for (var prop in field) {
- userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
- }
- //提交 Ajax 成功后,静态更新表格中的数据
- //$.ajax({});
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/BatchSetting?r=" + Math.random(1),
- data: userdata + "Id=" + ids,
- dataType: "text",
- success: function (data) {
- clickflag = 0;
- layer.close(index);
- if (data == "success") {
- layer.close(loadindex);
- layer.msg('关联成功', {
- time: 1000
- }, function () {
- table.reload('LAY-list-manage'); //数据刷新
- });
- }
- else if (data.indexOf("Warning") == 0) {
- var datalist = data.split('|');
- layer.alert(datalist[1], { time: 20000 }, function () {
- window.location.reload();
- });
- }
- else {
- layer.msg(data);
- }
- }
- });
- }
- });
- submit.trigger('click');
- }
- });
- }
- },
- BatchCancle: function () {
- var checkStatus = table.checkStatus('LAY-list-manage'),
- data = checkStatus.data; //得到选中的数据
- if (data.length < 1) {
- parent.layer.msg("请选择要取消关联的分仓");
- } else {
- var ids = "";
- $.each(data, function (index, value) {
- ids += data[index].Id + ",";
- });
- ids = ids.substring(0, ids.length - 1);
- var perContent = layer.open({
- type: 2,
- title: '取消关联',
- content: 'BatchCancle?StoreIds=' + ids,
- maxmin: true,
- area: ['650px', '550px'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- loadindex = layer.load(1, {
- shade: [0.5, '#000']
- });
- var iframeWindow = window['layui-layer-iframe' + index],
- submitID = 'LAY-list-front-submit',
- submit = layero.find('iframe').contents().find('#' + submitID);
- setTimeout(function () {
- layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
- var errObj = $(this).find('.layui-form-danger');
- if (errObj.length > 0) {
- iframeWindow.element.tabChange('mytabbar', String(i + 1));
- submit.click();
- }
- });
- }, 300);
- //监听提交
- iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
- if (clickflag == 0) {
- clickflag = 1;
- var field = data.field; //获取提交的字段
- var userdata = "";
- for (var prop in field) {
- userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
- }
- //提交 Ajax 成功后,静态更新表格中的数据
- //$.ajax({});
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/BatchCancle?r=" + Math.random(1),
- data: userdata + "Id=" + ids,
- dataType: "text",
- success: function (data) {
- clickflag = 0;
- layer.close(index);
- if (data == "success") {
- layer.close(loadindex);
- layer.msg('取消成功', {
- time: 1000
- }, function () {
- table.reload('LAY-list-manage'); //数据刷新
- });
- }
- else if (data.indexOf("Warning") == 0) {
- var datalist = data.split('|');
- layer.alert(datalist[1], { time: 20000 }, function () {
- window.location.reload();
- });
- }
- else {
- layer.msg(data);
- }
- }
- });
- }
- });
- submit.trigger('click');
- }
- });
- }
- },
- Open: function () {
- var checkStatus = table.checkStatus('LAY-list-manage'),
- data = checkStatus.data; //得到选中的数据
- if (data.length < 1) {
- parent.layer.msg("请选择要开启的项");
- } else {
- var ids = "";
- $.each(data, function (index, value) {
- ids += data[index].Id + ",";
- });
- ids = ids.substring(0, ids.length - 1);
- var index = layer.confirm('确定要开启吗?', function (index) {
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/Open?r=" + Math.random(1),
- data: "Id=" + ids,
- dataType: "text",
- success: function (data) {
- layer.close(index);
- if (data == "success") {
- table.reload('LAY-list-manage');
- } else {
- layer.msg(data);
- }
- }
- });
- });
- }
- },
- Close: function () {
- var checkStatus = table.checkStatus('LAY-list-manage'),
- data = checkStatus.data; //得到选中的数据
- if (data.length < 1) {
- parent.layer.msg("请选择要关闭的项");
- } else {
- var ids = "";
- $.each(data, function (index, value) {
- ids += data[index].Id + ",";
- });
- ids = ids.substring(0, ids.length - 1);
- var index = layer.confirm('确定要关闭吗?', function (index) {
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/Close?r=" + Math.random(1),
- data: "Id=" + ids,
- dataType: "text",
- success: function (data) {
- layer.close(index);
- if (data == "success") {
- table.reload('LAY-list-manage');
- } else {
- layer.msg(data);
- }
- }
- });
- });
- }
- },
- SycnData: function () {
- var index = layer.confirm('确定要同步所有仓库的库存数据吗?', function (index) {
- layer.close(index);
- var loadindex = layer.load(1, {
- shade: [0.5, '#000']
- });
- $.ajax({
- type: "POST",
- url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
- data: "Id=0",
- dataType: "text",
- success: function (data) {
- layer.close(loadindex);
- if (data == "success") {
- layer.msg('同步成功');
- table.reload('LAY-list-manage');
- } else {
- layer.msg(data);
- }
- }
- });
- });
- },
- };
- $('.layui-btn').on('click', function () {
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- });
|