字典管理数据联调
Showing
2 changed files
with
91 additions
and
27 deletions
... | @@ -43,3 +43,25 @@ export function addDdicNode(data) { | ... | @@ -43,3 +43,25 @@ export function addDdicNode(data) { |
43 | data: data, | 43 | data: data, |
44 | }) | 44 | }) |
45 | } | 45 | } |
46 | |||
47 | /** | ||
48 | * 删除字典节点 | ||
49 | */ | ||
50 | export function deleteDdicNode(data) { | ||
51 | return request({ | ||
52 | url: '/system/dictionary/deleteDdicNode', | ||
53 | method: 'post', | ||
54 | data: data, | ||
55 | }) | ||
56 | } | ||
57 | |||
58 | /** | ||
59 | * 添加字典节点 | ||
60 | */ | ||
61 | export function editDdicNode(data) { | ||
62 | return request({ | ||
63 | url: '/system/dictionary/editDdicNode', | ||
64 | method: 'post', | ||
65 | data: data, | ||
66 | }) | ||
67 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -2,14 +2,7 @@ | ... | @@ -2,14 +2,7 @@ |
2 | <div class="log-content"> | 2 | <div class="log-content"> |
3 | <div class="log-search"> | 3 | <div class="log-search"> |
4 | 字典名称: | 4 | 字典名称: |
5 | <el-date-picker | 5 | <el-input v-model="searchKey" style="border: 1px solid #C0C4CC;width: 230px;border-radius: 4px" placeholder="请输入内容"></el-input> |
6 | v-model="startValue" | ||
7 | type="datetime" | ||
8 | placeholder="选择日期时间" | ||
9 | align="right" | ||
10 | value-format="yyyy-MM-dd HH:mm:ss" | ||
11 | :picker-options="pickerOptions"> | ||
12 | </el-date-picker> | ||
13 | <el-button type="primary" @click="query">查询</el-button> | 6 | <el-button type="primary" @click="query">查询</el-button> |
14 | <el-button type="warning" @click="reset">重置</el-button> | 7 | <el-button type="warning" @click="reset">重置</el-button> |
15 | </div> | 8 | </div> |
... | @@ -34,9 +27,8 @@ | ... | @@ -34,9 +27,8 @@ |
34 | :style="{ left: menuleft + 'px', top: menutop + 'px' }" | 27 | :style="{ left: menuleft + 'px', top: menutop + 'px' }" |
35 | class="contextmenu" | 28 | class="contextmenu" |
36 | > | 29 | > |
37 | <li @click="editNode">编辑</li> | ||
38 | <li @click="addNode(zdType,0)">添加</li> | 30 | <li @click="addNode(zdType,0)">添加</li> |
39 | <li @click="deleteNode">删除</li> | 31 | <li @click="deleteNode(zdType,0)">删除</li> |
40 | </ul> | 32 | </ul> |
41 | <div class="log-table"> | 33 | <div class="log-table"> |
42 | <el-table | 34 | <el-table |
... | @@ -56,15 +48,15 @@ | ... | @@ -56,15 +48,15 @@ |
56 | </el-table-column> | 48 | </el-table-column> |
57 | <el-table-column align="center" label="操作"> | 49 | <el-table-column align="center" label="操作"> |
58 | <template slot-scope="scope"> | 50 | <template slot-scope="scope"> |
59 | <el-button type="text" class="operatorBtn">编辑</el-button> | 51 | <el-button type="text" class="operatorBtn" @click="editNode(scope.row)">编辑</el-button> |
60 | <el-button type="text" class="operatorBtn">删除</el-button> | 52 | <el-button type="text" class="operatorBtn" @click="deleteNode(scope.row,1)">删除</el-button> |
61 | <el-button type="text" class="operatorBtn" @click="addNode(scope.row,1)">添加</el-button> | 53 | <el-button type="text" class="operatorBtn" @click="addNode(scope.row,1)">添加</el-button> |
62 | </template> | 54 | </template> |
63 | </el-table-column> | 55 | </el-table-column> |
64 | </el-table> | 56 | </el-table> |
65 | </div> | 57 | </div> |
66 | 58 | ||
67 | <el-dialog v-dialogDrag title="添加字典" width="69%" :visible.sync="outerVisible"> | 59 | <el-dialog v-dialogDrag :title="isAdd ? '添加字典':'编辑字典'" width="69%" :visible.sync="outerVisible"> |
68 | <div style="height: 240px"> | 60 | <div style="height: 240px"> |
69 | <div style="width: 100%;border: 1px solid #a8adad;"> | 61 | <div style="width: 100%;border: 1px solid #a8adad;"> |
70 | 62 | ||
... | @@ -103,16 +95,20 @@ | ... | @@ -103,16 +95,20 @@ |
103 | </tr> | 95 | </tr> |
104 | <tr height="30"> | 96 | <tr height="30"> |
105 | <td colspan="2" align="center" >字典类型</td> | 97 | <td colspan="2" align="center" >字典类型</td> |
106 | <td colspan="10" > | 98 | <td colspan="4" > |
107 | <el-input v-model="form.zdType"></el-input> | 99 | <el-input v-model="form.zdType"></el-input> |
108 | </td> | 100 | </td> |
101 | <td colspan="2" align="center" >顺序号</td> | ||
102 | <td colspan="4" > | ||
103 | <el-input v-model="form.sxh"></el-input> | ||
104 | </td> | ||
109 | </tr> | 105 | </tr> |
110 | </tbody> | 106 | </tbody> |
111 | </table> | 107 | </table> |
112 | </el-form> | 108 | </el-form> |
113 | </div> | 109 | </div> |
114 | <div class="handleBtn"> | 110 | <div class="handleBtn"> |
115 | <el-button type="primary" class="w98 creat" @click="insertDdicNode">保存</el-button> | 111 | <el-button type="primary" class="w98 creat" @click="saveDdicNode">保存</el-button> |
116 | <el-button type="primary" class="w98 cancel" @click="outerVisible = false">取消</el-button> | 112 | <el-button type="primary" class="w98 cancel" @click="outerVisible = false">取消</el-button> |
117 | </div> | 113 | </div> |
118 | </div> | 114 | </div> |
... | @@ -123,7 +119,7 @@ | ... | @@ -123,7 +119,7 @@ |
123 | </template> | 119 | </template> |
124 | 120 | ||
125 | <script> | 121 | <script> |
126 | import {getAllDdic,addDdicNode} from "@api/manage"; | 122 | import {getAllDdic,addDdicNode,deleteDdicNode,editDdicNode} from "@api/manage"; |
127 | export default { | 123 | export default { |
128 | name: "index", | 124 | name: "index", |
129 | data(){ | 125 | data(){ |
... | @@ -137,11 +133,14 @@ | ... | @@ -137,11 +133,14 @@ |
137 | qtmc:'', | 133 | qtmc:'', |
138 | bz:'', | 134 | bz:'', |
139 | zdType:'', | 135 | zdType:'', |
136 | sxh:'', | ||
140 | }, | 137 | }, |
141 | 138 | ||
139 | searchKey:'', | ||
140 | isAdd:true, | ||
142 | tableData:[], | 141 | tableData:[], |
143 | errorLog:[], | 142 | errorLog:[], |
144 | concreteDic:'', | 143 | concreteDic:[], |
145 | zdType:'', | 144 | zdType:'', |
146 | 145 | ||
147 | menuvisible:false, | 146 | menuvisible:false, |
... | @@ -180,19 +179,35 @@ | ... | @@ -180,19 +179,35 @@ |
180 | }, | 179 | }, |
181 | methods:{ | 180 | methods:{ |
182 | 181 | ||
183 | insertDdicNode(){ | 182 | saveDdicNode(){ |
183 | if(this.isAdd){ | ||
184 | addDdicNode(this.form).then((res)=>{ | 184 | addDdicNode(this.form).then((res)=>{ |
185 | if(res.code === 200){ | 185 | if(res.code === 200){ |
186 | this.$message.success("添加成功!"); | 186 | this.$message.success("添加成功!"); |
187 | this.outerVisible = false; | 187 | this.outerVisible = false; |
188 | this.removeStorage(); | ||
189 | this.getData(); | ||
190 | } | ||
191 | }); | ||
192 | }else { | ||
193 | editDdicNode(this.form).then((res)=>{ | ||
194 | if(res.code === 200){ | ||
195 | this.$message.success("修改成功!"); | ||
196 | this.outerVisible = false; | ||
197 | this.removeStorage(); | ||
198 | this.getData(); | ||
188 | } | 199 | } |
189 | }); | 200 | }); |
201 | } | ||
190 | }, | 202 | }, |
191 | 203 | ||
192 | editNode(){ | 204 | editNode(data){ |
193 | 205 | this.isAdd = false; | |
206 | this.form = data; | ||
207 | this.outerVisible = true | ||
194 | }, | 208 | }, |
195 | addNode(data,source){ | 209 | addNode(data,source){ |
210 | this.isAdd = true; | ||
196 | this.form={ | 211 | this.form={ |
197 | mc:'', | 212 | mc:'', |
198 | jc:'', | 213 | jc:'', |
... | @@ -203,23 +218,45 @@ | ... | @@ -203,23 +218,45 @@ |
203 | zdType:'', | 218 | zdType:'', |
204 | pbsm:'', | 219 | pbsm:'', |
205 | bsm:'', | 220 | bsm:'', |
221 | sxh:'', | ||
206 | }; | 222 | }; |
207 | // alert(JSON.stringify(data)) | 223 | // alert(JSON.stringify(data)) |
208 | if(source === 0){ | 224 | if(source === 0){ |
209 | this.form.zdType = data; | 225 | this.form.zdType = data; |
210 | }else if(source === 1){ | 226 | }else if(source === 1){ |
211 | this.form = data; | 227 | this.form.zdType = data.zdType; |
212 | this.form.pbsm = data.bsm; | 228 | this.form.pbsm = data.bsm; |
213 | } | 229 | } |
214 | this.outerVisible = true | 230 | this.outerVisible = true |
215 | }, | 231 | }, |
216 | deleteNode(){ | 232 | deleteNode(data,source){ |
217 | 233 | this.$confirm('是否确定删除该'+name+'?', '提示', { | |
234 | confirmButtonText: '确定', | ||
235 | cancelButtonText: '取消', | ||
236 | type: 'warning' | ||
237 | }).then((res)=>{ | ||
238 | let params = { | ||
239 | "bsm": "", | ||
240 | "zdType": "" | ||
241 | }; | ||
242 | if(source === 0){ | ||
243 | params.zdType = data; | ||
244 | }else if(source === 1){ | ||
245 | params.bsm = data.bsm; | ||
246 | } | ||
247 | deleteDdicNode(params).then((res)=>{ | ||
248 | if(res.code === 200){ | ||
249 | this.$message.success("删除完成!"); | ||
250 | } | ||
251 | this.removeStorage(); | ||
252 | this.getData(); | ||
253 | }) | ||
254 | }); | ||
218 | }, | 255 | }, |
219 | 256 | ||
220 | getData(){ | 257 | getData(){ |
221 | let data={ | 258 | let data={ |
222 | "mc": "", | 259 | "mc": this.searchKey, |
223 | "pbsm": "" | 260 | "pbsm": "" |
224 | }; | 261 | }; |
225 | getAllDdic(data).then((res)=>{ | 262 | getAllDdic(data).then((res)=>{ |
... | @@ -235,17 +272,19 @@ | ... | @@ -235,17 +272,19 @@ |
235 | }, | 272 | }, |
236 | query(){ | 273 | query(){ |
237 | let data={ | 274 | let data={ |
238 | "mc": "", | 275 | "mc": this.searchKey, |
239 | "pbsm": "" | 276 | "pbsm": "" |
240 | }; | 277 | }; |
241 | getAllDdic(data).then((res)=>{ | 278 | getAllDdic(data).then((res)=>{ |
242 | console.log(res.result); | 279 | console.log(res.result); |
243 | this.tableData = res.result; | 280 | this.tableData = res.result; |
281 | if(this.tableData.length>0){ | ||
282 | this.concreteDic = this.tableData[0].value; | ||
283 | } | ||
244 | }) | 284 | }) |
245 | }, | 285 | }, |
246 | reset(){ | 286 | reset(){ |
247 | this.startValue = ""; | 287 | this.searchKey = ""; |
248 | this.endValue = ""; | ||
249 | }, | 288 | }, |
250 | openMenu(e,item){ | 289 | openMenu(e,item){ |
251 | // alert(JSON.stringify(item)); | 290 | // alert(JSON.stringify(item)); |
... | @@ -261,6 +300,9 @@ | ... | @@ -261,6 +300,9 @@ |
261 | closeMenu(){ | 300 | closeMenu(){ |
262 | this.menuvisible = false; | 301 | this.menuvisible = false; |
263 | }, | 302 | }, |
303 | removeStorage(){ | ||
304 | sessionStorage.removeItem("state"); | ||
305 | }, | ||
264 | }, | 306 | }, |
265 | mounted() { | 307 | mounted() { |
266 | this.getData(); | 308 | this.getData(); | ... | ... |
-
Please register or sign in to post a comment