CZT
2023-08-18 e97e5cc1d6b14914ed2aa5cb281bfaeef78c7757
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
<?xml version="1.0" encoding="UTF-8"?>
<ViewConfig>
  <Arguments/>
  <Context/>
  <Model>
    <DataType name="dtURL">
      <Property name="creationType">com.fzzy.sys.entity.SysUrl</Property>
      <PropertyDef name="id">
        <Property></Property>
      </PropertyDef>
      <PropertyDef name="name">
        <Property></Property>
        <Property name="label">菜单名称</Property>
        <Property name="required">true</Property>
      </PropertyDef>
      <PropertyDef name="icon">
        <Property></Property>
        <Property name="label">图标</Property>
      </PropertyDef>
      <PropertyDef name="order">
        <Property name="dataType">int</Property>
        <Property name="label">顺序优先级</Property>
      </PropertyDef>
      <PropertyDef name="parentId">
        <Property></Property>
        <Property name="label">父节点ID</Property>
      </PropertyDef>
      <PropertyDef name="target">
        <Property></Property>
        <Property name="label">打开方式</Property>
      </PropertyDef>
      <PropertyDef name="url">
        <Property></Property>
        <Property name="label">菜单连接</Property>
        <Property name="required">true</Property>
      </PropertyDef>
      <Reference name="children">
        <Property name="dataProvider">sys.urlPR#listUrl</Property>
        <Property name="dataType">[SELF]</Property>
        <Property name="parameter">$${this.id}</Property>
      </Reference>
    </DataType>
  </Model>
  <View layout="padding:10;regionPadding:10">
    <ClientEvent name="onReady">&#xD;
addRoot = function(){&#xD;
    var list = view.get(&quot;#dsMain&quot;).getData();&#xD;
    var currEntity = view.get(&quot;#dataTree.currentEntity&quot;);&#xD;
    var currNode = view.get(&quot;#dataTree.currentNode&quot;);&#xD;
    var newEntity={};&#xD;
    if(!currEntity){&#xD;
        list.insert();&#xD;
    }else{&#xD;
        if(currEntity.get(&quot;parentId&quot;)){&#xD;
            newEntity = currNode.get(&quot;parent.data&quot;).createBrother({});&#xD;
        }else{&#xD;
            newEntity = currEntity.createBrother({&quot;parentId&quot;:null});&#xD;
        }&#xD;
        view.get(&quot;#dataTree&quot;).set('currentEntity', newEntity);&#xD;
    }&#xD;
    view.get(&quot;#dialog&quot;).set(&quot;caption&quot;,&quot;添加根节点&quot;);&#xD;
    view.get(&quot;#dialog&quot;).show();&#xD;
}&#xD;
&#xD;
addData = function(){&#xD;
    var node = view.get(&quot;#dataTree.currentNode&quot;);&#xD;
    var entity = view.get(&quot;#dataTree.currentEntity&quot;);&#xD;
    var sonList=entity.get(&quot;children&quot;);&#xD;
    var newEntity;&#xD;
    if(entity.get(&quot;parentId&quot;)){&#xD;
        dorado.widget.NotifyTipManager.notify(&quot;请选择根节点创建子节点!&quot;);&#xD;
        return;&#xD;
    }else{&#xD;
        newEntity = entity.createChild('children', {parentId: entity.get('id')});&#xD;
    }&#xD;
    &#xD;
    if (!node.get('expanded')) {&#xD;
        node.expand();&#xD;
    }&#xD;
    view.get(&quot;#dataTree&quot;).set('currentEntity', newEntity);&#xD;
    view.get(&quot;#dialog&quot;).set(&quot;caption&quot;,&quot;添加子节点&quot;);&#xD;
    view.get(&quot;#dialog&quot;).show();&#xD;
}&#xD;
&#xD;
updateData = function(){&#xD;
    view.get(&quot;#dialog&quot;).set(&quot;caption&quot;,&quot;编辑节点&quot;);&#xD;
    view.get(&quot;#dialog&quot;).show();&#xD;
}&#xD;
</ClientEvent>
    <Property name="packages">font-awesome,css-common</Property>
    <DataSet id="dsMain">
      <Property name="dataProvider">sys.urlPR#listUrl</Property>
      <Property name="dataType">[dtURL]</Property>
    </DataSet>
    <ToolBar>
      <ToolBarLabel>
        <Property name="text">菜单栏:</Property>
      </ToolBarLabel>
      <ToolBarButton>
        <ClientEvent name="onClick">addRoot();&#xD;
</ClientEvent>
        <Property name="caption">新增主菜单</Property>
        <Property name="iconClass">fa fa-plus</Property>
        <Property name="exClassName">toolbar-button</Property>
      </ToolBarButton>
      <ToolBarButton>
        <ClientEvent name="onClick">addData();</ClientEvent>
        <Property name="caption">新增子菜单</Property>
        <Property name="iconClass">fa fa-plus-circle</Property>
        <Property name="exClassName">toolbar-button</Property>
      </ToolBarButton>
      <ToolBarButton>
        <ClientEvent name="onClick">updateData();&#xD;
</ClientEvent>
        <Property name="caption">菜单修改</Property>
        <Property name="iconClass">fa fa-pencil</Property>
        <Property name="exClassName">toolbar-button-warm</Property>
      </ToolBarButton>
      <ToolBarButton>
        <ClientEvent name="onClick">var currentNode = view.get(&quot;#dataTree.currentNode&quot;);&#xD;
currentNode.expand();&#xD;
if(currentNode.get(&quot;hasChild&quot;)){&#xD;
    dorado.MessageBox.alert(&quot;请先删除所有子节点!&quot;);&#xD;
    return;&#xD;
}&#xD;
var currentEntity = view.get(&quot;#dataTree.currentEntity&quot;);&#xD;
view.get(&quot;#ajaxDel&quot;).set(&quot;parameter&quot;,currentEntity).execute(function(){&#xD;
    currentEntity.remove();&#xD;
});</ClientEvent>
        <Property name="caption">菜单删除</Property>
        <Property name="iconClass">fa fa-minus</Property>
        <Property name="exClassName">toolbar-button-warn</Property>
      </ToolBarButton>
    </ToolBar>
    <DataTreeGrid id="dataTree">
      <Property name="currentNodeDataPath">CURRENT_NODE</Property>
      <Property name="dataSet">dsMain</Property>
      <Property name="treeColumn">name</Property>
      <BindingConfigs>
        <BindingConfig>
          <Property name="childrenProperty">children</Property>
          <Property name="labelProperty">name</Property>
          <Property name="name">children</Property>
          <Property name="iconClass">fa fa-folder-open-o</Property>
          <Property name="expandLevel">3</Property>
          <BindingConfig>
            <Property name="childrenProperty">children</Property>
            <Property name="labelProperty">name</Property>
            <Property name="name">children</Property>
            <Property name="iconClass">fa fa-folder-o</Property>
          </BindingConfig>
        </BindingConfig>
      </BindingConfigs>
      <Columns>
        <DataColumn>
          <Property name="name">name</Property>
          <Property name="property">name</Property>
          <Property name="readOnly">true</Property>
          <Editor/>
        </DataColumn>
        <DataColumn>
          <Property name="name">url</Property>
          <Property name="property">url</Property>
          <Property name="readOnly">true</Property>
          <Editor/>
        </DataColumn>
      </Columns>
    </DataTreeGrid>
    <Dialog id="dialog">
      <Property name="width">500</Property>
      <Buttons>
        <Button>
          <ClientEvent name="onClick">var currentEntity = view.get(&quot;#dataTree.currentEntity&quot;);&#xD;
&#xD;
view.get(&quot;#ajaxUpdate&quot;).set(&quot;parameter&quot;,currentEntity).execute(function(result){&#xD;
    view.get(&quot;#dialog&quot;).hide();&#xD;
    view.get(&quot;#dataTree&quot;).set(&quot;currentEntity&quot;,result);&#xD;
});</ClientEvent>
          <Property name="caption">保存</Property>
          <Property name="width">100</Property>
          <Property name="iconClass">fa fa-check</Property>
        </Button>
        <Button>
          <ClientEvent name="onClick">view.get(&quot;#dataTree.currentEntity&quot;).cancel();&#xD;
view.get(&quot;#dialog&quot;).hide();&#xD;
</ClientEvent>
          <Property name="caption">取消</Property>
          <Property name="iconClass">fa fa-times</Property>
          <Property name="width">100</Property>
        </Button>
      </Buttons>
      <Children>
        <AutoForm>
          <Property name="dataSet">dsMain</Property>
          <Property name="dataPath">!CURRENT_NODE</Property>
          <Property name="cols">*</Property>
          <Property name="labelWidth">100</Property>
          <Property name="labelAlign">right</Property>
          <AutoFormElement>
            <Property name="name">name</Property>
            <Property name="property">name</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">url</Property>
            <Property name="property">url</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">icon</Property>
            <Property name="property">icon</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">order</Property>
            <Property name="property">order</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement id="parentId">
            <Property name="name">parentId</Property>
            <Property name="property">parentId</Property>
            <Property name="readOnly">true</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">target</Property>
            <Property name="property">target</Property>
            <Editor/>
          </AutoFormElement>
        </AutoForm>
      </Children>
      <Tools/>
    </Dialog>
    <AjaxAction id="ajaxUpdate">
      <Property name="service">sys.urlPR#updateData</Property>
    </AjaxAction>
    <AjaxAction id="ajaxDel">
      <Property name="confirmMessage">确定要删除数据么?</Property>
      <Property name="service">sys.urlPR#delData</Property>
    </AjaxAction>
  </View>
</ViewConfig>