123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341 |
- 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 < loginUser.role.length; i++) {
- // console.log(i);
- if (loginUser.role[i].role == "知识库管理员" && loginUser.role[i].rolecode == "solution") {
- $scope.ZZKGLY = true;
- }
- }
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- //alert($rootScope.user.id,null,2);
- // vm.model["loginUser"] = $rootScope.user;
- var that = $injector;
- var parse = $parse;
- var modelWatch = "";
- var fieldsWatch = [];
- var serviceWatch = null;
- var formWatch = {};
- if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
- modelWatch = JSON.parse($stateParams.model);
- // console.log("modelWatch:"+ JSON.stringify(modelWatch));
- }
- if (angular.isDefined($stateParams.fields) && $stateParams.fields != "") {
- fieldsWatch = JSON.parse($stateParams.fields);
- }
- if (angular.isDefined($stateParams.extjson) && $stateParams.extjson != "") {
- formWatch.extjson = JSON.parse($stateParams.extjson);
- }
- if (angular.isDefined($stateParams.cancelUrl) && $stateParams.cancelUrl != "") {
- formWatch.cancelUrl = $stateParams.cancelUrl;
- }
- if (angular.isDefined($stateParams.url) && $stateParams.url != "") {
- formWatch.url = $stateParams.url;
- }
- if (angular.isDefined($stateParams.service) && $stateParams.service != "") {
- if (that.has($stateParams.service)) {
- serviceWatch = that.get($stateParams.service);
- } else {
- serviceWatch = $stateParams.service;
- }
- }
- //用户测试数据,后续从header的auth中获取
- var userId = 2;
- userId = $rootScope.user.id;
- //==============处理表单设计数据 开始====================
- //处理组件加载后台数据选项的方法
- function refreshSelectOptions(searchVal, field) {
- //todo
- console.log(field);
- var filedata = {};
- if (field.key == 'id' && field.templateOptions.pkey == 'change.source') {
- field.templateOptions.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 }];
- } else if (field.templateOptions.optionsUrl) {
- var process = BpmRestangular.all("");
- filedata = { "idx": 0, "sum": 100 }
- if (field.templateOptions.ApiService) {
- process = UserRestangular.all("");
- filedata = { 'user': { 'roledata': { 'rolecode': 'inspectman' } }, "idx": 0, "sum": 1000 }
- }
- process.customPOST(filedata, field.templateOptions.optionsUrl).then(function (result) {
- if (!field.templateOptions.options) {
- field.templateOptions.options = [];
- }
- if (field.templateOptions.optionsDataKey) {
- field.templateOptions.options = result[field.templateOptions.optionsDataKey];
- } else {
- field.templateOptions.options = result;
- }
- });
- }
- }
- //解析自定义表单设计数据
- function decodeVMForm(vmForm) {
- var result = { model: {}, fields: [] };
- //设置模型实体数据 begin
- // var mdata = vmForm.model;
- //解析数据实体
- var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
- angular.extend(result.model, mdata);
- if (modelWatch != null && modelWatch != '') {
- //angular.extend(result.model.incident,modelWatch.incident);
- //result.model.alarmType = modelWatch.alarmType;
- // vmForm.cancelUrl = modelWatch.cancelUrl;
- for (var index in modelWatch.model) {
- // console.log(JSON.stringify(index + " " + JSON.stringify(modelWatch.model[index])));
- if (result.model[index] != null) {
- angular.extend(result.model[index], modelWatch.model[index]);
- } else {
- result.model[index] = modelWatch.model[index];
- }
- }
- }
- //设置模型实体数据 end
- //解析设计数据生成表单项 begin
- var fields = [];
- //处理修改设计数据中展示设置
- angular.forEach(vmForm.fields, function (field) {
- if (field.key == "") {
- delete field.key;
- }
- if (angular.isDefined(field.extjson)) {
- var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
- angular.extend(field.templateOptions, extObj.templateOptions);
- delete extObj.templateOptions;
- for (var prop in extObj) {
- if (new RegExp("Expression").test(prop)) {
- //var obj = $scope.$eval(extObj[prop]);
- //extObj[prop] = $scope.$eval(extObj[prop]);
- if (extObj[prop] != null) {
- if (new RegExp("function").test(extObj[prop])) {
- var propValue = eval(extObj[prop]);
- extObj[prop] = propValue;
- } else {
- //console.log(extObj[prop]);
- var obj = $scope.$eval(extObj[prop]);
- extObj[prop] = obj;
- //console.log(obj);
- }
- }
- } else if (new RegExp("expressionProperties").test(prop)) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- } else {
- }
- }
- } else if ("watcher" == prop) {
- if (angular.isArray(extObj[prop])) {
- angular.forEach(extObj[prop], function (item, index) {
- for (var p in item) {
- if (new RegExp("function").test(item[p])) {
- var propValue = eval(item[p]);
- extObj[prop][index][p] = propValue;
- }
- }
- });
- } else if (angular.isObject(extObj[prop])) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- }
- }
- }
- }
- }
- angular.extend(field, extObj);
- delete field.extjson;
- }
- if (angular.isDefined(field.templateOptions)) {
- var templateOs = field.templateOptions;
- for (var property in templateOs) {
- //console.log(property);
- if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
- if (new RegExp("function").test(templateOs[property])) {
- var propValue = eval(templateOs[property]);
- field.templateOptions[property] = propValue;
- } else {
- if (that.has(templateOs[property])) {
- field.templateOptions[property] = that.get(templateOs[property]);
- } else {
- field.templateOptions[property] = templateOs[property];
- }
- }
- } else if (templateOs[property] == null) {
- //delete field.templateOptions[property];
- } else { }
- }
- }
- //console.log(field);
- if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
- var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
- angular.extend(field.templateOptions, extObj);
- delete field.templateOptions.extjson;
- }
- //...
- if (field.templateOptions) {
- //处理远程获取数据控件方法调用
- if (field.templateOptions.optionsUrl) {
- field.templateOptions.refresh = refreshSelectOptions;
- }
- //处理嵌套属性数据绑定/
- if (field.templateOptions.pkey) {
- var pmodel, i = 0;
- angular.forEach(field.templateOptions.pkey.split("."), function (p) {
- if (i == 0) {
- if (result.model[p] == null) {
- result.model[p] = {};
- }
- pmodel = result.model[p];
- i++;
- } else {
- if (pmodel[p] == null) {
- pmodel[p] = {};
- }
- pmodel = pmodel[p];
- }
- });
- if (pmodel != null) {
- field.model = pmodel;
- if (pmodel[field.key] == null) {
- pmodel[field.key] = null;
- }
- }
- } else {
- if (result.model[field.key] == null) {
- result.model[field.key] = null;
- }
- }
- //处理弹出框组件初始化
- if (field.type == "ui-input-selectmodal") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-requesterselect") {
- //field.templateOptions.language = $scope.lang;
- field.templateOptions.modal = $modal;
- field.templateOptions.UserService = api_user_data;
- } else if (field.type == "ui-userselect") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-multiuserselect") {
- field.templateOptions.modal = $modal;
- } else if (field.type == "ui-search") {
- field.templateOptions.modal = $modal;
- } else if (field.type == "ui-modelselect") {
- field.templateOptions.modal = $modal;
- //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
- field.templateOptions.loginUser = $rootScope.user;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-dropfile") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- //field.ApiService=api_bpm_domain;
- } else if (field.type == "ui-dropfielknow") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- } else if (field.type == "ui-dropfilenotup") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- } else if (field.type == "ui-uploadFile") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- } else if (field.type == "ui-dropfielkn") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- } else if (field.type == "ui-upDropFile") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- } else if (field.type == "ui-dropfiletable") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-repeatSection") {
- var repeatForm = {
- model: {
- },
- fields: field.templateOptions.fields
- };
- repeatForm.model[field.key] = [];
- decodeVMForm(repeatForm);
- } else if (field.type == "ui-currentuser") {
- field.templateOptions.user = vm.model["loginUser"];
- }
- }
- // console.log(field);
- result.fields.push(field);
- });
- angular.extend($scope.vm.fields, result.fields);
- angular.extend($scope.vm.model, result.model);
- console.log($rootScope.user);
- //vm.model["loginUser"] = $rootScope.user;
- if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
- vmForm.cancelUrl = modelWatch.cancelUrl;
- }
- $scope.formData = vmForm;
- //console.log($scope.vm);
- //解析设计数据生成表单项 end
- return result;
- }
- //======================处理表单设计数据 结束========================
- $scope.ldloading = {};
- //jry
- $scope.lishi_show = $stateParams.formKey;
- console.log($stateParams.formKey);
- if ($stateParams.formKey == "knowledge_leve" || $stateParams.formKey == "knowledge_editor" || $stateParams.formKey == "knowledge_detail" || $stateParams.formKey == "knowledge_shenhe") {
- $scope.historyData = JSON.parse($stateParams.history);
- console.log($scope.historyData);
- }
- if ($stateParams.formKey == "knowledge_lishi") {
- $scope.get_id = JSON.parse($stateParams.model);
- console.log($scope.get_id);
- $scope.xianshiBG = $scope.get_id.model.knowledge.id;
- api_solution.jry_getHistory({ "idx": 0, "sum": 999, "solution": { "solutionnumber": $scope.get_id.model.knowledge.solutionnumber } }).then(function (res) {
- console.log(res);
- $scope.jry_history_data = res.list;
- })
- }
- $scope.get_lishi = function (res) {
- // console.log(res);
- // // modelWatch="";
- // console.log($scope.jry_history_data[res]);
- // // console.log(modelWatch.model.knowledge);
- // console.log(vm.model.knowledge);
- // vm.model.knowledge={};
- // vm.model.knowledge=$scope.jry_history_data[res];
- $state.go('app.knowledge.jry_save_history_data', { 'model': JSON.stringify({ "model": { "knowledge": $scope.jry_history_data[res] } }) });
- // location.reload()
- // modelWatch.model.knowledge=$scope.jry_history_data[res];
- }
- $scope.other_to_lishi = function (res) {
- console.log(res);
- $state.go('app.knowledge.jry_save_history_data', { 'model': JSON.stringify({ "model": { "knowledge": res } }) });
- }
- $scope.to_history = function () {
- var jry_tohistoryData = JSON.parse($stateParams.model);
- console.log(jry_tohistoryData)
- $state.go('app.knowledge.jry_lishi', { formKey: 'knowledge_lishi', service: 'api_solution', 'model': JSON.stringify(jry_tohistoryData) })
- }
- function filter(obj) {
- angular.forEach(obj, function (key, value) {
- if (value === "" || value === null) {
- delete obj[key];
- } else if (Object.prototype.toString.call(value) === '[object Object]') {
- filter(value);
- } else if (angular.isArray(value)) {
- angular.forEach(value, function (item) {
- filter(item);
- });
- }
- });
- }
- $scope.closeModel = function (data) {
- // console.log("$stateParams.formKey="+JSON.stringify($stateParams.formKey))
- if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
- // if($stateParams.formKey=="knowledge_editor"||$stateParams.formKey=="knowledge_detail"||$stateParams.formKey=="knowledge_create") {
- $state.go('app.knowledge.manager', { 'model': JSON.stringify(data), 'fromstate': $stateParams.fromstate });
- // }
- event.preventDefault();
- }
- }
- vm.submit = function (data, style) {
- // console.log("data="+JSON.stringify(data));
- // if($stateParams.formKey=="system_edit"){
- // console.log("roleid="+$scope.roleid);
- if (vm.form.$valid) {
- vm.options.updateInitialValue();
- $scope.ldloading[style.replace('-', '_')] = true;
- // alert(JSON.stringify(vm.model), null, 2);
- var _ = window._;
- vm.model = (function filter(obj) {
- var dateTransKeys = [];
- var filtered = _.pick(obj, function (v, k, obj) {
- if (_.isDate(v)) {
- dateTransKeys.push(k);
- }
- return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
- });
- return _.cloneDeep(filtered, function (v, index, object) {
- if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
- angular.forEach(dateTransKeys, function (item) {
- v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
- });
- dateTransKey = [];
- return v;
- }
- return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
- });
- })(vm.model);
- console.log("$scope.formData=" + $scope.formData);
- switch ($scope.formData.url) {
- case "start":
- //vm.model["initUser"]=$rootScope.user.id;
- //addData
- if (vm.model.knowledge.id) {
- serviceWatch.updData($scope.formData.modelName, vm.model).then(function (response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- if (resData && resData.status == 200) {
- uploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name, 'type': 'solution', 'solutionId': response.data.id });
- console.info('onBeforeUploadItem', item);
- };
- uploader.uploadAll();
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- } else {
- SweetAlert.swal({
- title: "提交失败",
- text: "提交失败,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- } else {
- // console.log(vm.model.knowledge);
- // var jry_createUserId=JSON.parse($stateParams.model
- // console.log(loginUser);
- vm.model.knowledge["createUser"] = { "id": loginUser.id };
- // console.log(JSON.parse($stateParams.model));
- delete (vm.model.knowledge["createUserId"]);
- delete (vm.model.knowledge["status"]);
- var filedata = { "solution": vm.model.knowledge };
- $scope.jry_time = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
- console.log($scope.jry_time);
- if ($scope.ZZKGLY == true) {
- filedata.solution["approveUser"] = { "id": filedata.solution.createUser.id };
- filedata.solution["status"] = { "id": 72 };
- filedata.solution["approvetime"] = $scope.jry_time;
- SweetAlert.swal({
- title: "你是知识库管理员",
- text: "新增就直接发布!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确认发布",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- serviceWatch.jry_addFile(filedata).then(function (response) {
- // console.log(response.data.id);
- if (response) {
- var resData = Restangular.stripRestangular(response);
- if (resData && resData.status == 200) {
- $scope.fileUploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = serviceWatch.jry_upload1(response.data.id).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name, 'type': 'solution', 'solutionId': resData.data.id });
- console.info('onBeforeUploadItem', item);
- };
- $scope.fileUploader.uploadAll();
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- });
- SweetAlert.swal("操作成功!", "该知识库已直接发布", "success");
- } else {
- SweetAlert.swal("操作取消", "已取消发布", "error");
- }
- });
- } else {
- serviceWatch.jry_addFile(filedata).then(function (response) {
- // console.log(response.data.id);
- if (response) {
- var resData = Restangular.stripRestangular(response);
- if (resData && resData.status == 200) {
- $scope.fileUploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = serviceWatch.jry_upload(response.data.id).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name, 'type': 'solution', 'solutionId': resData.data.id });
- console.info('onBeforeUploadItem', item);
- };
- $scope.fileUploader.uploadAll();
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- });
- }
- }
- break;
- case "save":
- //addData
- var filedata = vm.model.knowledge;
- if (filedata && filedata.vision) {
- var vision = filedata.vision;
- filedata.vision = vision.substring(1, vision.Length)
- }
- if ($rootScope.user.id == filedata.createUserId && filedata.status == 5) {
- filedata.status = 1;
- }
- if (filedata.status == 4) {
- filedata.status = 1;
- }
- if (filedata.status == 3) {
- filedata.status = 1;
- }
- if (filedata.status.name == '已驳回') {
- filedata.status.id = 71;
- }
- delete (filedata["item"]);
- delete (filedata.solutionType["isExpanded"]);
- $scope.updata = { "solution": filedata };
- serviceWatch.jry_updateSolution($scope.updata).then(function (response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- if (resData && resData.status == 200) {
- $scope.fileUploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = serviceWatch.jry_upload(response.data.id).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name, 'type': 'solution', 'solutionId': resData.data.id });
- console.info('onBeforeUploadItem', item);
- };
- $scope.fileUploader.uploadAll();
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- modelWatch.model
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- break;
- case "leve":
- // console.log("我是升级");
- if ($scope.ZZKGLY == true) {
- // filedata.solution["approveUser"]={"id":filedata.solution.createUser.id};
- // filedata.solution["status"]={"id":72};
- // filedata.solution["approvetime"]=$scope.jry_time;
- SweetAlert.swal({
- title: "你是知识库管理员",
- text: "升级就直接发布!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确认发布",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- var filedata = vm.model.knowledge;
- if (filedata && filedata.vision) {
- var vision = filedata.vision;
- filedata.vision = vision.substring(1, vision.Length)
- }
- if ($rootScope.user.id == filedata.createUserId && filedata.status == 5) {
- filedata.status = 1;
- }
- if (filedata.status == 4) {
- filedata.status = 1;
- }
- if (filedata.status == 3) {
- filedata.status = 1;
- }
- delete (filedata["item"]);
- delete (filedata.solutionType["isExpanded"]);
- filedata["renewUser"] = { id: loginUser.id };
- filedata.approveUser.id = loginUser.id;
- filedata["renewtime"] = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
- $scope.levedata = { "solution": filedata };
- serviceWatch.jry_leveSolution($scope.levedata).then(function (response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- modelWatch.model
- $scope.fileUploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = serviceWatch.jry_upload1(response.data.id).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name, 'type': 'knowledge', 'solutionId': resData.data.id });
- console.info('onBeforeUploadItem', item);
- };
- $scope.fileUploader.uploadAll();
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- SweetAlert.swal("操作成功!", "该知识库已直接发布", "success");
- } else {
- SweetAlert.swal("操作取消", "已取消发布", "error");
- }
- });
- } else {
- var filedata = vm.model.knowledge;
- if (filedata && filedata.vision) {
- var vision = filedata.vision;
- filedata.vision = vision.substring(1, vision.Length)
- }
- if ($rootScope.user.id == filedata.createUserId && filedata.status == 5) {
- filedata.status = 1;
- }
- if (filedata.status == 4) {
- filedata.status = 1;
- }
- if (filedata.status == 3) {
- filedata.status = 1;
- }
- delete (filedata["item"]);
- delete (filedata.solutionType["isExpanded"]);
- filedata["renewUser"] = { id: loginUser.id };
- filedata.status.id = 71;
- filedata["renewtime"] = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
- $scope.levedata = { "solution": filedata };
- serviceWatch.jry_leveSolution($scope.levedata).then(function (response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- modelWatch.model
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- }
- //addData
- break;
- case "close":
- $state.go('app.knowledge.manager');
- break;
- default:
- $scope.ldloading[style.replace('-', '_')] = false;
- break;
- }
- } else {
- SweetAlert.swal({
- title: "校验错误",
- text: "请填写必填项!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- angular.forEach(vm.form.$error.required, function (item) {
- angular.forEach(vm.fields, function (f) {
- if (f.name == item.$name) {
- f.validation.show = true;
- }
- });
- })
- }
- };
- //审核取消
- $scope.jry_shenhe_close = function () {
- $state.go("app.knowledge.manager", {})
- }
- //审核通过
- $scope.jry_shenhe_success = function () {
- var filedata = vm.model.knowledge;
- filedata.status.id = 72;
- filedata["approveUser"] = { id: loginUser.id };
- filedata.approvetime = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
- delete (filedata["item"]);
- delete (filedata.solutionType["isExpanded"]);
- // console.log(filedata,8989);
- //知识库分类必填项
- if(!(filedata.solutionType&&filedata.solutionType.id)){
- SweetAlert.swal({
- title: "知识库分类未填!",
- text:"请填写此项",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- var shenhe_data = { "solution": filedata }
- api_solution.jry_updateSolution(shenhe_data).then(function (res) {
- SweetAlert.swal({
- title: "审核通过!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- })
- }
- // 审核驳回
- $scope.jry_shenhe_bohui = function () {
- var filedata = vm.model.knowledge;
- filedata.status.id = 73;
- filedata["approveUser"] = { id: loginUser.id };
- filedata.reject = $scope.bohui_YY;
- filedata.approvetime = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
- // delete(filedata["item"]);
- // delete(filedata.solutionType["isExpanded"]);
- console.log(filedata);
- var shenhe_data = { "solution": filedata }
- api_solution.jry_updateSolution(shenhe_data).then(function (res) {
- SweetAlert.swal({
- title: "该知识已驳回!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go('app.knowledge.manager');
- });
- })
- }
- $scope.bohui_show = false;
- $scope.jry_bohuiyuanyin_show = function () {
- $scope.bohui_show = true;
- }
- $scope.bohuiyuanyin_close = function () {
- $scope.bohui_show = false;
- }
- $scope.vm = vm;
- if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
- api_configure_form.renderForm($stateParams.formKey, '00000').then(function (responseData) {
- if (responseData) {
- //console.log("responseData>>>");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: '<i class="fa fa-phone"/>'
- }
- },
- {
- 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:'<hr>'
- // }]
- // }
- // },
- // {
- // 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");
- }
- ]);
|