From 91f2cd5b0f832091f654cce926585d2f05cad114 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <xltys1995>
Date: 星期四, 08 四月 2021 23:22:32 +0800
Subject: [PATCH] Merge branches 'dev' and 'master' of https://gitee.com/luxiaotao1123/xtywms into master
---
src/main/webapp/static/js/locNormal/locNormal.js | 360 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 360 insertions(+), 0 deletions(-)
diff --git a/src/main/webapp/static/js/locNormal/locNormal.js b/src/main/webapp/static/js/locNormal/locNormal.js
new file mode 100644
index 0000000..c331026
--- /dev/null
+++ b/src/main/webapp/static/js/locNormal/locNormal.js
@@ -0,0 +1,360 @@
+var pageCurr;
+var locNormalList = [];
+var locArea = [];
+
+function getCol() {
+ var cols = [];
+ cols.push(
+ {field: 'anfme', align: 'center', title: '鏁伴噺', sort: true, edit: 'text'}
+ )
+ cols.push.apply(cols, locNormalCols);
+ cols.push(
+ {field: 'warehouse', align: 'center', title: '搴撳尯'}
+ , {field: 'state', align: 'center', title: '鍑哄叆搴撶姸鎬�', templet: '#locNormalState'}
+ , {field: 'modiUser$', align: 'center', title: '淇敼浜哄憳', hide: true}
+ , {field: 'modiTime$', align: 'center', title: '淇敼鏃堕棿', hide: true}
+ , {field: 'appeTime$', align: 'center', title: '鍒涘缓鏃堕棿', hide: true}
+ , {field: '', align: 'center', title: '鎿嶄綔', width: 135, fixed: 'right', templet: '#operate'}
+ );
+ return cols;
+}
+
+// 鑾峰彇浠撳簱涓嬫媺
+$.ajax({
+ url: baseUrl+"/locArea/queryAll/auth",
+ headers: {'token': localStorage.getItem('token')},
+ // data: top.reObject(data),
+ method: 'POST',
+ success: function (res) {
+ if (res.data && res.data.length > 0) {
+ locArea = res.data;
+ }
+ },
+});
+
+// 搴撳尯涓嬫媺
+// 鑾峰彇浠撳簱涓嬫媺
+$.ajax({
+ url: baseUrl + "/locArea/queryAll/auth",
+ headers: {'token': localStorage.getItem('token')},
+ method: 'POST',
+ success: function (res) {
+ if (res.code === 200) {
+ var html = "";
+ if (res.data && res.data.length > 0) {
+ html += res.data.map(function (item) {
+ return "<Option value=" + item.uuid + ">" + item.name + "</Option>";
+ });
+ }
+ $('#putSiteSelect').append(html);
+ } else if (res.code === 403) {
+ top.location.href = baseUrl + "/";
+ } else {
+ layer.msg(res.msg)
+ }
+ }
+})
+
+layui.use(['table', 'laydate', 'form', 'upload'], function () {
+ var table = layui.table;
+ var $ = layui.jquery;
+ var layer = layui.layer;
+ var layDate = layui.laydate;
+ var form = layui.form;
+ var upload = layui.upload;
+
+ // 瀵煎叆excel
+ var uploader = upload.render({
+ elem: '#uploadEx'
+ , url: baseUrl + '/locNormal/import/auth'
+ , headers: {token: localStorage.getItem('token')}
+ , accept: 'file'
+ , exts: 'xls|excel|xlsx'
+ , auto: false
+ , bindAction: '#uploadDo'
+ , before: function (obj) {
+ layer.closeAll();
+ layer.load(1, {shade: [0.1, '#fff']});
+ }
+ , choose: function (obj) {
+ $('#uploadDesc').hide();
+ $('#uploadDemoView').show();
+ obj.preview(function (index, file, result) {
+ $('#fileMame').html(file.name);
+ });
+ }
+ , done: function (res) {
+ limit();
+ $('#uploadDesc').show();
+ $('#uploadDemoView').hide();
+ $('#fileMame').html("");
+ layer.closeAll('loading');
+ layer.msg(res.msg);
+ tableReload(false);
+ }
+ , error: function (index, upload) {
+ layer.closeAll('loading');
+ }
+ });
+
+ /* 瀵煎叆 */
+ table.on('toolbar(locNormal)', function (obj) {
+ switch (obj.event) {
+ // 瀵煎叆
+ case 'intoData':
+ layer.open({
+ type: 1,
+ title: '鏁版嵁瀵煎叆',
+ shadeClose: true,
+ content: $('#importDataDiv'),
+ success: function (layero, index) {
+ uploader.reload();
+ },
+ end: function () {
+ $('#uploadDesc').show();
+ $('#uploadDemoView').hide();
+ $('#fileMame').html("");
+ }
+ });
+ break;
+ }
+ });
+
+
+ // 鏁版嵁娓叉煋
+ tableIns = table.render({
+ elem: '#locNormal',
+ headers: {token: localStorage.getItem('token')},
+ url: baseUrl + '/locNomal/list/auth',
+ page: true,
+ limit: 16,
+ limits: [16, 30, 50, 100, 200, 500],
+ even: true,
+ toolbar: '#toolbar',
+ cellMinWidth: 50,
+ cols: [getCol()],
+ request: {
+ pageName: 'curr',
+ pageSize: 'limit'
+ },
+ parseData: function (res) {
+ // 瑙f瀽搴撳尯鍚嶇О
+ var records = res.data.records;
+ records.map(function (item) {
+ locArea.map(function (d) {
+ if (d.uuid == item.warehouse) {
+ item.warehouse = d.name;
+ }
+ })
+ });
+ return {
+ 'code': res.code,
+ 'msg': res.msg,
+ 'count': res.data.total,
+ 'data': res.data.records,
+ }
+ },
+ response: {
+ statusCode: 200
+ },
+ done: function (res, curr, count) {
+ if (res.code === 403) {
+ top.location.href = baseUrl + "/";
+ }
+ pageCurr = curr;
+ limit();
+ // 褰撳墠鍒嗛〉鏁版嵁瀛樺偍
+ locNormalList = res.data;
+ }
+ });
+
+ // 鐩戝惉鎺掑簭浜嬩欢
+ table.on('sort(locNormal)', function (obj) {
+ var searchData = {};
+ $.each($('#search-box [name]').serializeArray(), function () {
+ searchData[this.name] = this.value;
+ });
+ searchData['orderByField'] = obj.field;
+ searchData['orderByType'] = obj.type;
+ tableIns.reload({
+ where: searchData,
+ page: {
+ curr: 1
+ },
+ done: function (res, curr, count) {
+ if (res.code === 403) {
+ top.location.href = baseUrl + "/";
+ }
+ pageCurr = curr;
+ limit();
+ // 褰撳墠鍒嗛〉鏁版嵁瀛樺偍
+ locNormalList = res.data;
+ }
+ });
+ });
+
+ // 椤甸潰淇敼
+ table.on('edit(locNormal)', function (obj) {
+ var count = obj.value;
+ var matnr = obj.data.matnr;
+ var id = obj.data.id;
+
+ if (isNaN(count)) {
+ layer.msg("璇疯緭鍏ユ暟瀛�");
+ // 鏁版嵁閲嶈浇
+ tableIns.reload({
+ data: locNormalList, done: function (res) {
+ limit();
+ }
+ });
+ } else {
+ if (count > 0) {
+ for (var i = 0; i < locNormalList.length; i++) {
+ if (locNormalList[i]["matnr"] === matnr) {
+ locNormalList[i]["anfme"] = count;
+ }
+ }
+ } else {
+ layer.msg("鏁伴噺蹇呴』澶т簬闆�");
+ }
+ }
+ // 璇锋眰鏇存柊鎺ュ彛瀹屾垚鏁伴噺鐨勬洿鏂�
+ const param = {
+ matnr: matnr,
+ anfme: count,
+ id: id,
+ }
+ $.ajax({
+ url: baseUrl + "/locNormal/update/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: top.reObject(param),
+ method: 'POST',
+ success: function (res) {
+ },
+ });
+ });
+
+ // 鎼滅储鏍忛噸缃簨浠�
+ form.on('submit(reset)', function (data) {
+ pageCurr = 1;
+ clearFormVal($('#search-box'));
+ tableReload(false);
+ });
+
+ // 鎼滅储鏍忔悳绱簨浠�
+ form.on('submit(search)', function (data) {
+ pageCurr = 1;
+ tableReload(false);
+ });
+
+ // 鐩戝惉琛屽伐鍏蜂簨浠�
+ table.on('tool(locNormal)', function (obj) {
+ var data = obj.data;
+ var param = {
+ matnr: data.matnr,
+ id: data.id,
+ }
+ switch (obj.event) {
+ case 'outLocNormal':
+ layer.confirm('纭畾瑕佸嚭搴揫'+data.matnr+']鍚楋紵', {
+ btn: ['纭畾', '鍙栨秷'] //鍙互鏃犻檺涓寜閽�
+ }, function(index, layero){
+ //纭畾鍥炶皟-鍑哄簱
+ $.ajax({
+ url: baseUrl + "/locNormal/outLoc/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: top.reObject(param),
+ method: 'POST',
+ success: function (res) {
+ tableReload(false);
+ layer.closeAll();
+ layer.msg("鍑哄簱鎴愬姛");
+ },
+ });
+ }, function(index){
+ //鎸夐挳銆愭寜閽簩銆戠殑鍥炶皟
+ });
+ break;
+ case 'removeLocNormal':
+ // 绉婚櫎
+ layer.confirm('纭畾瑕佺Щ闄'+data.matnr+']鍚楋紵', {
+ btn: ['纭畾', '鍙栨秷'] //鍙互鏃犻檺涓寜閽�
+ }, function(index, layero){
+ //纭畾鍥炶皟-绉婚櫎
+ $.ajax({
+ url: baseUrl + "/locNormal/removeLoc/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: top.reObject(param),
+ method: 'POST',
+ success: function (res) {
+ tableReload(false);
+ layer.closeAll();
+ layer.msg("绉婚櫎鎴愬姛");
+ },
+ });
+ }, function(index){
+ //鎸夐挳銆愭寜閽簩銆戠殑鍥炶皟
+ });
+ break;
+ }
+ });
+
+
+});
+
+/* 琛ㄦ牸鏁版嵁閲嶈浇 */
+function tableReload(child) {
+ var searchData = {};
+ $.each($('#search-box [name]').serializeArray(), function () {
+ searchData[this.name] = this.value;
+ });
+ (child ? parent.tableIns : tableIns).reload({
+ where: searchData,
+ page: {
+ curr: pageCurr
+ },
+ done: function (res, curr, count) {
+ if (res.code === 403) {
+ top.location.href = baseUrl + "/";
+ }
+ pageCurr = curr;
+ if (res.data.length === 0 && count !== 0) {
+ tableIns.reload({
+ where: searchData,
+ page: {
+ curr: pageCurr - 1
+ }
+ });
+ pageCurr -= 1;
+ }
+ limit(child);
+ // 褰撳墠鍒嗛〉鏁版嵁瀛樺偍
+ locNormalList = res.data;
+ }
+ });
+}
+
+/* 鐩戝惉鍥炶溅浜嬩欢 */
+$('body').keydown(function () {
+ if (event.keyCode === 13) {
+ $("#search").click();
+ }
+});
+
+// 鎻愬彇鐗╂枡
+var addLocNormalIdx;
+
+function addLocNormal() {
+ addLocNormalIdx = layer.open({
+ type: 2,
+ title: '鏂板',
+ maxmin: true,
+ area: [top.detailWidth, '550px'],
+ shadeClose: true,
+ content: 'addLocNormal.html',
+ success: function (layero, index) {
+ }
+ });
+}
+
+
--
Gitblit v1.9.1