12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- /**
- * Created by zhang on 2018/9/11.
- */
- async function initCompilationSelect() {
- try {
- $('#compilationSels').empty();
- let result = await ajaxPost("/stdBillsEditor/getCompilationList");
- for(let r of result){
- let $option = $("<option >"+r.name +"</option>");
- $option.val( r._id);
- $('#compilationSels').append($option);
- }
- }catch (err){
- alert("取编办信息有误");
- console.log(err)
- }
- }
- //对JSON对象排序,按属性key的顺序显示
- function sortJson(obj, compare) {
- if(obj === null){
- return null;
- }
- if(obj instanceof Array){
- for(let o in obj){
- obj[o] = sortJson(obj[o], compare);
- }
- return obj;
- }else if(typeof obj == 'object'){
- let arr=[];
- let newOjb ={};
- for(let key in obj){
- arr.push(key);
- }
- if (compare) {
- arr.sort(compare);
- } else {
- arr.sort();
- }
- for(let a of arr){
- newOjb[a]= sortJson(obj[a], compare);
- }
- return newOjb;
- }else {
- return obj;
- }
- }
|