add common modules with checkField Api
parent
af33d890f5
commit
ba70aab661
|
|
@ -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);
|
||||||
|
});
|
||||||
|
|
@ -94,10 +94,11 @@
|
||||||
<script src="../../component/layui/layui.js"></script>
|
<script src="../../component/layui/layui.js"></script>
|
||||||
<script src="../../component/pear/pear.js"></script>
|
<script src="../../component/pear/pear.js"></script>
|
||||||
<script>
|
<script>
|
||||||
layui.use(['table', 'form', 'jquery'], function() {
|
layui.use(['table', 'form', 'jquery','common'], function() {
|
||||||
let table = layui.table;
|
let table = layui.table;
|
||||||
let form = layui.form;
|
let form = layui.form;
|
||||||
let $ = layui.jquery;
|
let $ = layui.jquery;
|
||||||
|
let common = layui.common;
|
||||||
|
|
||||||
let MODULE_PATH = "operate/";
|
let MODULE_PATH = "operate/";
|
||||||
|
|
||||||
|
|
@ -249,19 +250,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
window.batchRemove = function(obj) {
|
window.batchRemove = function(obj) {
|
||||||
let data = table.checkStatus(obj.config.id).data;
|
|
||||||
if (data.length === 0) {
|
var checkIds = common.checkField(obj,'userId');
|
||||||
|
|
||||||
|
if (checkIds === "") {
|
||||||
layer.msg("未选中数据", {
|
layer.msg("未选中数据", {
|
||||||
icon: 3,
|
icon: 3,
|
||||||
time: 1000
|
time: 1000
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let ids = "";
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
|
||||||
ids += data[i].userId + ",";
|
|
||||||
}
|
|
||||||
ids = ids.substr(0, ids.length - 1);
|
|
||||||
layer.confirm('确定要删除这些用户', {
|
layer.confirm('确定要删除这些用户', {
|
||||||
icon: 3,
|
icon: 3,
|
||||||
title: '提示'
|
title: '提示'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue