123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- starter.factory('WorkFlow', function ($ionicPopup, $resource, formatFilter, cfg, Tool, showPopup) {
- var workflow = {};
- workflow.templates = $resource(formatFilter('{0}workflow/template/:id', cfg.api));
- workflow.templateitem = $resource(formatFilter('{0}workflow/templateitem/', cfg.api));
- workflow.templatecc = $resource(formatFilter('{0}workflow/templatecc/', cfg.api));
- workflow.templatestep = $resource(formatFilter('{0}workflow/templatestep/', cfg.api));
- workflow.templatepermission = $resource(formatFilter('{0}workflow/templatepermission/', cfg.api));
- workflow.templatefield = $resource(formatFilter('{0}daily/templatefield/', cfg.api));
- workflow.templatedata = {template_id: -1, items: [], steps: [], cc: [], permission: {'depts': [], 'users': [], 'all': true}};
- workflow.create_template = function (templatedata) {
- var template = _.pick(templatedata, "name", "description");
- template.type = templatedata.template_id == -1 ? 1 : 0;
- workflow.templates.save(template, function (data) {
- var items = _.map(templatedata.items, function (item) {
- return _.pick(item, 'name', 'required')
- })
- })
- };
- workflow.showDialog = function (scope, titlename, placeholder, itemlabel, righttext) {
- var customTemplate = formatFilter(
- '<div set-popover-style><label class="item item-input"><input type="text" placeholder="{0}" ng-model="auditstep.name"></label>' +
- '<ion-item ng-click="toselect()" class="item item-icon-right">{1}<p class="label-right-text">{2}</p> <i class="icon ion-chevron-right icon-accessory"></i> </ion-item></div>', placeholder, itemlabel, righttext);
- var popup = $ionicPopup.show({
- scope: scope,
- template: customTemplate,
- title: '<div><h5>' + titlename + '</h5></div>',
- buttons: [{
- text: '取消',
- onTap: function (e) {
- return false;
- }
- }, {
- text: '<b>保存</b>',
- type: 'button-positive',
- onTap: function (e) {
- if (Tool.trim(scope.auditstep.name).length < 2) {
- showPopup.PopupWindow(0, "不能少于2个字!", false);
- e.preventDefault();
- } else
- return true;
- }
- }]
- });
- return popup;
- };
- return workflow;
- })
- ;
|