1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
| /**
| * 状态的值
| * @author weidy@2020-07-27
| */
| layui.define(['layer','element','form','table','util'],function(exports){
| var Class = function(){
| this.MODELNAME = "platform/objectService/VciOsStatus";
| this.moduleKey = "VciOsStatus";
| this.id='VciOsStatus';
| this.sourceData={};
| this.columns = [];
| this.backPath = configData.compatibility?path:configData.objectServicePath;
| this.url={
| controller:'statusController/',
| dataGrid:'gridStatus',
| addSave:'addSave',
| editSave:'editSave',
| deleteUrl:'delete',
| getObjectByOid:'getObjectByOid',
| listUsed:'listUsed'
| };
| this.buttonIconMap = {
| SEARCH:'layui-icon-refresh-2',
| SENIORSEARCH:'layui-icon-query',
| ADD:'layui-icon-add-1',
| EDIT:'layui-icon-edit',
| DELETE:'layui-icon-delete'
| };
| this.getContent=function(){//返回这个组件的基础html
| var that = this;
| var html = "";
| html = [
| '<div class="layui-layout-border">',
| '<div class="layui-center">',
| that.getToolbarHtml(),
| '<table id="table_', that.id , '" lay-filter="',that.id , '" style="overflow-x:auto;"></table>',
| '</div>',
| '</div>'
| ].join("");
| return html;
| };
| this.getToolbarHtml =function(){
| var that = this;
| var html = [
| '<div layui-filter="toolbar_',that.id,'" class="layui-btn-container">',
| '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_ADD"><i class="layui-icon layui-icon-add-1"></i>添加</button>',
| // '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_EDIT"><i class="layui-icon layui-icon-edit"></i>修改</button>',
| '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_DEL"><i class="layui-icon layui-icon-delete"></i>删除</button>',
| '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_refresh"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
| // '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_LISTUSED"><i class="layui-icon layui-icon-search"></i>查看应用范围</button>',
| '</div>',
| ].join("");
| return html;
| };
| this.init=function(){//基础的html被添加后,再执行初始化
| var that = this;
| $webUtil.copyConfig(that,that.moduleKey);
| var table = layui.table;
| that.checkColumns();//主列表中列。
| that.firstGridLoad = false;
| table.render({
| elem: '#table_' + that.id,
| id: 'table_' + that.id,
| url: that.url.controller + that.url.dataGrid,
| backPath:that.backPath,
| page: {
| limit: 20,
| page: 1
| },
| selectMode:table.selectMode.muti,
| cols: [that.columns],
| done:function(res, cur, count){
| table.on('tool(' + that.id + ')',function(obj) {
| var data = obj.data;//当前选择行的数据
| var layEvent = obj.event;//点的是什么按钮
| if (layEvent == 'edit') {
| that.addOrEdit(false, data.oid);
| }else if(layEvent == 'listUsed'){
| that.listUsed(data);
| }
| });
| }
| });
| $webUtil.createSearchHtml({
| id:'英文名称',
| name:'中文名称'
| },$("[layui-filter='toolbar_" + that.id + "']"),'table_' + that.id);
| $webUtil.bindDefultButtonLisenter(that, that.id);
| };
| this.checkColumns = function(){
| var that = this;
| var table = layui.table;
| if(that.columns==null || that.columns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
| that.columns = [table.getIndexColumn(),table.getCheckColumn(),{
| field:'id',
| title:'英文名称',
| sort:true,
| width:200
| },{
| field:'name',
| title:'状态中文名称',
| sort:true,
| width:200
| },{
| field:'description',
| title:'描述',
| width:250
| },{
| field: "options",
| title:'操作',
| width:200,
| templet:function (d){
| return ['<a class="layui-btn layui-btn-intable" lay-event="edit" >编辑</a>',
| '<a class="layui-btn layui-btn-intable" lay-event="listUsed" >查看应用范围</a>'].join('');
| }
| }];
| }
| };
| this.getFormItems = function(onlyShow,edit) {
| return [
| {
| field: 'id',
| title: '状态英文名称(唯一)',
| required: true,
| readOnly:(onlyShow||edit)
| } , {
| field: 'name',
| title: '状态中文名称',
| required: true,
| readOnly:onlyShow
| } , {
| field: 'description',
| title: '描述',
| type: 'text',
| inputWidth:535,
| readOnly:onlyShow
| } ];
| };
| this.ADD = function () {
| var that = this;
| that.addOrEdit(true);
| };
| this.EDIT = function(){
| var that = this;
| var oid = webUtil.getOidFromGrid("table_" + that.id,true,true);
| if(!oid){
| return false;
| }
| that.addOrEdit(false,oid);
| };
| this.addOrEdit = function(add,oid) {
| var that = this;
| var form = layui.form;
| var filter ="form_" + that.id;
| var addSaveIndex =webUtil.dialog({
| title:add?'添加状态':'修改状态',
| btn:['保存','取消'],
| skin:'layui-layer-lan',
| content:'<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
| //fullScreen:true,
| area:['920px','300px'],
| resizing:function(layero){
| form.doResize(filter);
| },
| success:function(layero) {
| form.addItems(filter,that.getFormItems(false,!add),
| function () {
| if(!add){
| form.load(filter,{
| backPath:that.backPath,
| url:that.url.controller + that.url.getObjectByOid,
| method:'get',
| params:{
| oid:oid
| }
| });
| }else{
| var defaultValues = {};
| //可以手动在此处添加默认值
| form.setValues(defaultValues,filter);
| }
| }, {}, {defaultColumnOneRow: 2,labelWidth:130});
| },
| yes:function(layero){
| if(form.validata(filter)){
| var values = form.getValues(filter,true);
| var url = that.url.controller + (add?that.url.addSave:that.url.editSave);
| webUtil.ajax(add?'post':'put',url,values,function(result){
| if(result.success){
| webUtil.showMsgFromResult(result,(add ? "添加成功" : "修改成功"));
| layer.close(addSaveIndex);
| that.refresh();
| }else{
| webUtil.showErrorMsg(result.msg);
| }
| },function(xhr,err){
| webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
| },that.backPath);
| }
| },
| btn2:function(layero){
| layer.close(addSaveIndex);
| }
| });
| };
| this.DEL = function(){
| var that = this;
| var oid = webUtil.getOidFromGrid("table_" +that.id,true,false);
| if(!oid){
| return false;
| }
| webUtil.showConfirmMsg("是否删除这条数据?如果被引用将不能被删除!",function () {
| webUtil.deleteRequest(that.url.controller + that.url.deleteUrl,{oids:oid},function(result){
| if(result.success){
| webUtil.showMsgFromResult(result,"删除成功");
| that.refresh();
| }else{
| webUtil.showErrorMsg(result.msg);
| }
| },function(xhr,err){
| webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
| },that.backPath);
| });
| };
|
| this.refresh = function(){
| var that = this;
| layui.table.reload("table_" + that.id);
| };
| this.listUsed = function (data){
| var that = this;
| if(!data){
| return false;
| }
| var filter = data.oid;
| webUtil.dialog({
| title: '查看状态[' + data.name + "(" + data.id + ")]的应用范围",
| content: '<table id="used_' + filter + '" lay-filter="' + filter + '" style="margin-top:5px;margin-left:5px;" ></table>',
| area: ['900px', '600px'],
| success: function (layero) {
| layui.table.render({
| elem: '#used_' + filter,
| id: 'used_' + filter,
| url: that.url.controller + that.url.listUsed,
| backPath:that.backPath,
| where:{
| oid:data.oid
| },
| cols: [[{
| field:'id',
| title:'生命周期英文名称',
| width:150
| },{
| field: 'name',
| title: '生命周期名称',
| width: 250
| },{
| field: 'description',
| title:'描述',
| width: 200
| },{
| field: 'lastModifier',
| title: '最后修改人',
| width: 90
| },{
| field: 'lastModifyTime',
| title: '最后修改时间',
| dateFormate:$webUtil.dateFormate.dateNoSecond,
| width:110
| }]]
| });
| }
| });
| };
| };
| var cs = new Class();
| exports(cs.MODELNAME,cs);
| });
|
|