var sysFormly = angular.module('formlySystem', [ 'formly', 'formlyBootstrap', 'ui.bootstrap', 'ngSanitize', 'ui.select', 'ui.grid' ]); app.requires.push('formlySystem'); // var appFormly = angular.module('formlyExample', [ // 'formly', 'formlyBootstrap','ui.bootstrap', // 'ngSanitize','ui.select','ui.grid'], sysFormly.config( function config(formlyConfigProvider) { //格式转换方法 XXX-XXX转驼峰命名 }); sysFormly.controller('knowledgeformCtrl', ['$rootScope', '$scope', '$parse', '$filter', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'SweetAlert', 'FileUploader', 'i18nService', 'moment', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_bpm_domain', 'api_bpm_data', 'api_user_data','api_solution', function($rootScope, $scope, $parse, $filter, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, SweetAlert, FileUploader, i18nService, moment, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_bpm_domain, api_bpm_data, api_user_data,api_solution) { //console.log($stateParams); var vm = this; vm.options = {}; vm.exampleTitle = ['expressionProperties', 'model property']; vm.fields = []; vm.model = {}; var loginUser = $rootScope.user; $scope.ZZKGLY=false; for(var i=0;i>>");console.log(responseData); var vmForm = Restangular.stripRestangular(responseData); if (vmForm) { //console.log("vmForm>>>");console.log(vmForm); var modelData = {}; //modelData=myData.data; decodeVMForm(vmForm); } } }); } else { // if (angular.isDefined(fieldsWatch) && fieldsWatch.length > 0) { var vmForm = { fields: fieldsWatch, model: modelWatch } angular.extend(vmForm, formWatch); //$scope.formData = vmForm; if (vmForm) { decodeVMForm(vmForm); } } else { //for form //TODO //测试数据 开始 var testJson = { fields: [{ key: 'formtitle', type: 'ui-title', noFormControl: true, templateOptions: { label: 'title is ', placeholder: 'Formly is terrific!' } }, { key: 'b', type: 'ui-input', className: 'col-xs-4', templateOptions: { type: 'input', label: 'input a', placeholder: 'search a...', rBtn: { icon: 'fa fa-phone', onClick: function(val, opt, el, ev, model) { alert(val); } }, lAddon: '' } }, { key: 'id', type: 'ui-select', //initialValue:"false", templateOptions: { label: "测试默认值", optionsUrl: "abc", //options:[{"id":"false","name":"不取消"},{"id":"true","name":"取消"}], // refresh:function(){ // return [{"id":1,"name":"事件","code":1},{"id":2,"name":"问题","code":2},{"id":3,"name":"配置","code":3},{"id":4,"name":"服务级别","code":4},{"id":5,"name":"内部需求","code":5}]; // }, //options:[{"id":1,"name":"事件","code":1},{"id":2,"name":"问题","code":2},{"id":3,"name":"配置","code":3},{"id":4,"name":"服务级别","code":4},{"id":5,"name":"内部需求","code":5}], valueProp: "id", labelProp: "name", pkey: "change.source" } }, { key: 'systemType', type: 'ui-multiselect', className: 'col-xs-4', templateOptions: { label: "所属系统类型", pkey: "change", valueProp: "id", labelProp: "source", optionsUrl: "data/fetchDataList/changesystemtype", optionsDataKey: "list", onChange: function(value, options, that, event, model) { var field = null; angular.forEach(that.$parent.fields, function(item) { if (item.key == 'influenceDepartment') { field = item; } if (item.key == 'notificationDepartment') { notifyField = item; } }) if (field != null) { field.templateOptions.optionsPostData = { 'systemIds': [] } angular.forEach(value, function(vue) { field.templateOptions.optionsPostData['systemIds'].push({ 'id': vue }); }) field.value([]); if (value.length > 0) { field.templateOptions.refreshData(null, field); } } if (notifyField != null) { notifyField.templateOptions.optionsPostData = { 'systemIds': [] } angular.forEach(value, function(vue) { notifyField.templateOptions.optionsPostData['systemIds'].push({ 'id': vue }); }) notifyField.value([]); if (value.length > 0) { notifyField.templateOptions.refreshData(null, notifyField); } } } } }, { key: 'influenceDepartment', type: 'ui-multiselectplus', className: 'col-xs-4', templateOptions: { label: '所影响的应用系统、部门', pkey: "change", valueProp: '', //对应value labelProp: 'dept', //对应key optionsUrl: 'dept/findBySystemType', //对应后台地址,api/之前的部分省略 optionsDataKey: 'list', //对应返回数组数据的键值, optionsPostData: function(options, model, scope) { return { "systemIds": [] }; }, refreshData: function(search, options, model, that) { options.templateOptions.options = [{ "id": 13, "dept": "村镇银行管理部" }, { "id": 14, "dept": "电子银行部" }]; options.value(options.templateOptions.options); }, optionsChecked: true, required: true, ApiService: UserRestangular } }, { key: 'notificationDepartment', type: 'ui-multiselectplus', className: 'col-xs-4', templateOptions: { label: '需通知部门', pkey: "change", valueProp: 'id', //对应value labelProp: 'dept', //对应key optionsUrl: 'dept/findBySystemType', //对应后台地址,api/之前的部分省略 optionsDataKey: 'list', //对应返回数组数据的键值, optionsPostData: function(options, model, scope) { return { "systemIds": [] }; }, optionsChecked: true, required: true, ApiService: UserRestangular } }, { type: 'ui-label', key: 'arrayData', className: 'col-xs-4', templateOptions: { label: '数组label数据', labelProp: 'dept' } }, { key: 'selectUser', type: 'ui-requesterselect', className: 'col-xs-12', templateOptions: { label: '报修人信息', modalTitle: '报修人列表', fetchItems: function(filterData, APIService) { return APIService.fetchDataList('requester', filterData); }, Restangular: Restangular, ApiService: api_user_data // onClick:function(val, options, field, event , model){ // console.log(options); // } } }, { key: 'cabUser', type: 'ui-multiuserselect', className: 'col-xs-12', templateOptions: { label: 'CAB评审成员', modalTitle: 'CAB成员列表', fetchItems: function(filterData, APIService) { return APIService.fetchDataList('user', filterData); }, Restangular: Restangular, ApiService: api_user_data, onClick: function(val, options, field, event, model) { console.log(model); } } }, // { // key:'incident', // type:'ui-modelselect', // className:'col-xs-3', // templateOptions:{ // label:'关联事件工单', // modalTitle:'事件列表', // fetchItems:function(filterData,APIService){ // return APIService.fetchDataList('incident',filterData); // }, // Restangular:"Restangular", // ApiService:"api_bpm_data", // columnDefs:[ // { name:'id', width:80, enableFiltering:false}, // { name:'title', displayName:'事件主题', width:140}, // { name:'type.name', displayName:'事件类型', width:140}, // { name:'emergency.name', displayName:'紧急度', width:80}, // { name:'state.name', displayName:'状态', width:100}, // { name:'emergency.name', displayName:'紧急度', width:80}, // { name:'influence.name', displayName:'影响度', width:80}, // { name:'priority.name', displayName:'优先级', width:80}, // { name:'handlerUser.name', displayName:'当前处理人', width:100}, // { name:'acceptDate', displayName:'创建时间', width:100} // ], // displayName:'title', // onClick:function(val, options, field, event , model){ // //model.start_code++; // console.log(options); // } // } // }, // { // key: 'worknumber', // type: 'ui-workernumber', // className:'col-xs-3', // templateOptions: { // label: 'work number', // Restangular:Restangular, // ApiService:api_bpm_domain, // getWorkernumber: function(APIService){ // return APIService.workernumber('bg'); // } // } // }, // { // key: 'chkme', // type: 'ui-checkbox', // className:'col-xs-3', // templateOptions: { // label: 'Check me out' // } // }, // { // key: 'droplink', // type: 'ui-link', // className: 'col-xs-3', // templateOptions:{ // label:'添加附件', // onClick:function(val, options, field, event ,model){ // if(angular.isUndefined(field.form.dropState)){ // field.form.dropState=false; // } // field.form.dropState=!field.form.dropState; // console.log(field); // } // } // }, // { // key: 'dropfile', // type: 'ui-dropfile', // className: 'col-xs-12', // templateOptions:{ // label:'附件', // uploadUrl:'http://127.0.0.1:9008/saveAttachments' // } // }, // { // type: 'ui-label', // key: 'changesign', // className: 'col-xs-4', // templateOptions: { // label:'变更请求单号', // pkey:'change' // } // }, // { // type: 'ui-label', // key: 'title', // className: 'col-xs-4', // templateOptions: { // label:'变更标题', // pkey:'change' // } // }, // //关联发布单号 // //新建发布 // { // key: 'droplist', // type: 'ui-dropfiletable', // className: 'col-xs-12', // templateOptions:{ // label:'附件下载列表', // Restangular:Restangular, // processInstanceId:'250033', // ApiService:api_bpm_domain // } // }, // { // type: 'ui-repeatSection', // key: 'investments', // className: 'col-xs-12', // templateOptions: { // btnText: '新增变更施工单', // fields: [ // { // className: 'col-xs-3', // type: 'ui-input', // key: 'aboutci', // templateOptions: { // label: '关联的配置项', // required: true // } // }, // { // className: 'col-xs-3', // type: 'ui-datepicker', // key: 'planbegintime', // templateOptions: { // label: '计划开始时间', // required: true // } // }, // { // className: 'col-xs-3', // type: 'ui-datepicker', // key: 'planendtime', // templateOptions: { // label: '计划完成时间', // required: true // } // }, // { // className: 'col-xs-12', // type: 'ui-userselect', // key: 'handleruser', // templateOptions: { // label: '实施人员信息', // modalTitle:'实施人列表', // required: true, // fetchItems:function(filterData, APIService){ // return APIService.fetchDataList('user',filterData); // }, // Restangular:Restangular, // ApiService:api_user_data, // onClick:function(val, options, field, event , model){ // //model.start_code++; // console.log(options); // } // } // }, // { // className: 'col-xs-8', // type: 'ui-textarea', // key: 'handlerContent', // templateOptions: { // label: '实施内容', // required: true, // row:10 // } // },{ // noFormControl: true, // template:'
' // }] // } // }, // { // key: 'droplist', // type: 'ui-dropfiletable', // className: 'col-xs-12', // templateOptions:{ // label:'附件下载列表', // Restangular:Restangular, // processInstanceId:'250033', // ApiService:api_bpm_domain // } // }, // { // key: 'start_code', // className:'col-xs-6', // type: 'ui-hidden' // }, // { // key:'remark', // type:'ui-textarea', // className:'col-xs-12', // templateOptions:{ // label:'remark is ', // rows:3 // } // }, // { // key:'setStartCode', // type:'ui-button', // className:'col-xs-4', // templateOptions:{ // label:'升级为变更', // onClick:function(val, options, field, event ,model){ // console.log(options); // event.preventDefault(); // //model.start_code++; // //console.log(options); // } // } // } ], model: { username: "robin lau", password: "123456", change: { source: { id: 5 } }, chkme: false, start_code: 0, arrayData: [{ "id": 13, "dept": "村镇银行管理部" }, { "id": 14, "dept": "电子银行部" }], formtitle: "Hey!I am title value!", name: { first: "robin", last: "lau" }, multiselectItem: [] //date:"2015-09-15 00:00:00" } }; setTimeout(function() { decodeVMForm(testJson); $scope.$apply(); }, 500); //测试数据结束 } } console.log("end decode"); } ]);