From ba70aab661ff2ec52777ac17bec2406bedc8d4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E4=BB=AA=E5=BC=8F?= <854085467@qq.com> Date: Sun, 15 Nov 2020 17:41:02 +0800 Subject: [PATCH] add common modules with checkField Api --- component/pear/modules/common.js | 26 ++++++++++++++++++++++++++ view/system/user.html | 15 +++++++-------- 2 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 component/pear/modules/common.js diff --git a/component/pear/modules/common.js b/component/pear/modules/common.js new file mode 100644 index 0000000..ac6f21f --- /dev/null +++ b/component/pear/modules/common.js @@ -0,0 +1,26 @@ +layui.define(['jquery', 'element','table'], function(exports) { + "use strict"; + + var MOD_NAME = 'common', + $ = layui.jquery, + table = layui.table, + element = layui.element; + + var common = new function() { + + // 获 取 表 格 选 中 数 据 + this.checkField = function(obj, field) { + let data = table.checkStatus(obj.config.id).data; + if (data.length === 0) { + return ""; + } + let ids = ""; + for (let i = 0; i < data.length; i++) { + ids += data[i][field] + ","; + } + ids = ids.substr(0, ids.length - 1); + return ids; + } + } + exports(MOD_NAME, common); +}); diff --git a/view/system/user.html b/view/system/user.html index e5ce4c9..08e491f 100644 --- a/view/system/user.html +++ b/view/system/user.html @@ -94,10 +94,11 @@