easyui-prompt弹出框操作

效果图如下:

代码如下:

 1 $(document).ready(function () {
 2 
 3 //绑定按钮操作
 4 
 5             $('#btnMove').click(function () {
 6                 var ids = getSelectedIds('转移商品', 'CPID');
 7                 if (ids.length <= 0) return;
 8                 $.messager.prompt("转移商品", "请输入要转移到的分类ID?", function (data) {
 9                     if (data) {
10                         moveProduct(ids, data);
11                     }
12                 });
13             });
14  }
15         /*
16          * 获取选中行的的ID
17          * actionType {String} 操作类型
18          */
19         function getSelectedIds(actionType, keyId) {
20             var rows = $('#grid').datagrid('getSelections');
21             var action = '修改';
22             var id = 'CPID';
23             if (arguments.length > 0) {
24                 if (actionType == 'delete') {
25                     action = '删除';
26                 }
27             }
28             if (arguments.length >= 2) {
29                 if (keyId.length) {
30                     id = keyId;
31                 }
32             }
33             if (rows.length == 0) {
34                 $.dialog.alert('请选择要' + action + '的数据!');
35                 return '';
36             }
37             else if (rows.length > 1 && actionType == 'edit') {
38                 $.dialog.alert('一次只能修改一条数据');
39                 return '';
40             }
41             var ids = '';
42             for (var i = 0, j = rows.length; i < j; i++) {
43                 if (ids.length > 0) {
44                     ids += ',';
45                 }
46                 ids += rows[i][id];
47             }
48             return ids;
49         }
原文地址:https://www.cnblogs.com/Idus/p/5208838.html