123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871 |
- "use strict";
- /**
- * controller for User Profile Example
- */
- app.controller("faultConsumablesCtrl", [
- "$rootScope",
- "$scope",
- "$state",
- "$timeout",
- "$interval",
- "$modal",
- "SweetAlert",
- "i18nService",
- "uiGridConstants",
- "uiGridGroupingConstants",
- "Restangular",
- "api_user_data",
- 'api_bpm_data',
- function (
- $rootScope,
- $scope,
- $state,
- $timeout,
- $interval,
- $modal,
- SweetAlert,
- i18nService,
- uiGridConstants,
- uiGridGroupingConstants,
- Restangular,
- api_user_data,
- api_bpm_data
- ) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = "zh-cn";
- i18nService.setCurrentLang($scope.lang);
- var loginUser = $rootScope.user;
- $scope.xinzeng = false;
- $scope.shanchu = false;
- $scope.bianji = false;
- for (var i = 0; i < loginUser.menu.length; i++) {
- if (loginUser.menu[i].link == "responsibilityDept_add") {
- $scope.xinzeng = true;
- }
- if (loginUser.menu[i].link == "responsibilityDept_del") {
- $scope.shanchu = true;
- }
- if (loginUser.menu[i].link == "responsibilityDept_edit") {
- $scope.bianji = true;
- }
- }
- $scope.gridOptions = {};
- $scope.gridOptions.data = "myData";
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowTemplate =
- '<div ng-dblclick="grid.appScope.onDblClick(row)" ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" ui-grid-one-bind-id-grid="rowRenderIndex + \'-\' + col.uid + \'-cell\'" class="ui-grid-cell" ng-class="{ \'ui-grid-row-header-cell\': col.isRowHeader }" role="{{col.isRowHeader ? \'rowheader\' : \'gridcell\'}}" ui-grid-cell></div>';
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [
- {
- name: "item",
- displayName: "序号",
- width: 50,
- enableFiltering: false,
- },
- {
- name: "category.mutiCategory",
- displayName: "故障现象",
- width: "20%",
- enableFiltering: false,
- },
- {
- name: "consumableDTOSName",
- displayName: "耗材信息",
- width: "40%",
- enableFiltering: false,
- },
- {
- name: "操作",
- cellTemplate:
- '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
- // '<a ng-click="grid.appScope.saveData(row.entity)" tooltip="编辑" tooltip-placement="right">' +
- // '<i class="fa fa-pencil-square-o"></i></a>'+
- '<a ng-click="grid.appScope.saveData(row.entity)" ng-show="grid.appScope.bianji" class="bianjifont">编辑</a>' +
- "</div></div>",
- enableFiltering: false,
- },
- ];
- $scope.transferDept = function (data) {
- if (data) {
- return data;
- } else {
- return "无";
- }
- };
- //树形图
- // 将故障现象搜索结果返回的数据整理成children模式
- function transform(nodes) {
- var treeConverter = {
- result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
- attributeName: 'id', //节点唯一标识符
- needFind: true, //是否查询节点在result中已经存在,为了优化效率
- transform: function (node) { //转化递归函数,参数:一个待插入节点
- if (node.parent != null) { //该节点有父节点
- var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
- if (this.needFind) {
- for (var i = 0; i < newNode.children.length; i++) { //查找要插入的node子节点是否在newNode这个父节点中存在
- if (newNode.children[i][this.attributeName] === node[this.attributeName]) {
- return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
- }
- }
- }
- this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
- // delete node.parent; //删除该节点的parent属性,如果有的话
- node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
- newNode.children.push(node); //将该node节点push进newNode的子节点数组中
- return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
- } else if (node.parent == null) { //该叶节点没有父节点,即为根节点
- // delete node.parent; //删除该节点的parent属性,如果有的话
- if (this.result == null) { //根节点不存在
- node.children = []; //给该节点增加children:[]属性
- return this.result = node; //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
- } else {
- node.children = [];
- // 顶级去重
- for (var i = 0; i < this.result.children.length; i++) {
- if (this.result.children[i][this.attributeName] === node[this.attributeName]) {
- return this.result.children[i];
- }
- }
- this.result.children.push(node)
- return node // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
- }
- }
- },
- getWhole: function (nodes, attributeName) { //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
- var _node = {};
- _node.children = [];
- this.result = _node; //重置根节点
- this.attributeName = attributeName == null ? 'id' : attributeName; //唯一标识符默认为“id”
- nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
- nodes.forEach(item => { //循环调用转化方法
- this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
- this.transform(item);
- })
- return this.result; //返回根节点
- }
- }
- var result = treeConverter.getWhole(nodes); //调用
- return result;
- }
- function selectItem(pmodel, childrens) {
- if (angular.isArray(pmodel)) {
- angular.forEach(pmodel, function (index) {
- if (index && index.id) {
- angular.forEach(childrens, function (item) {
- if (item.id == index.id) {
- item.selected = true;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- }
- });
- } else {
- if (pmodel && pmodel.id) {
- angular.forEach(childrens, function (item, index) {
- if (item.id == pmodel.id) {
- item.selected = true;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- }
- }
- }
- $scope.saveData = function (selectdata) {
- console.log(selectdata);
- var modalInstance = $modal.open({
- templateUrl: "assets/views/system/tpl/faultConsumableschange.html",
- controller: function ($rootScope, $scope, scope, $modalInstance, api_user_data,api_bpm_data) {
- selectdata.category.selected = true;
- $scope.deptdata = {
- id: selectdata.id,
- consumableIds: selectdata.consumableDTOS || [],
- category: selectdata.category
- };
- $scope.categoryList = [];
- $scope.title = "故障耗材修改";
- // 耗材列表模糊搜索
- $scope.searchConsumable = function (key = "") {
- var deptData = {
- idx: 0,
- sum: 10,
- consumable: {
- keyWord: key,
- showZero: true,
- },
- };
- // 当前所属院区或责任科室
- if($rootScope.user.duty){
- deptData.consumable.dutyDTO = $rootScope.user.duty;
- }else if($rootScope.user.branch){
- }
- api_user_data
- .fetchDataList("consumable", deptData)
- .then(function (data) {
- var ids = $scope.deptdata.consumableIds.map(v=>v.id);
- $scope.consumableList = data.list.filter(v=>!ids.includes(v.id));
- });
- };
- // --------------------
- $scope.select_treedata = [];
- $rootScope.bala1 = $scope.try_async_load = function (s, fn) {
- if (s) {
- var filterKeyword = s.filterKeyword;
- }
- var postData = {
- idx: 0,
- sum: 9999,
- incidentcategory: {
- selectType: "pinyin_qs",
- "hierarchyQuery":"two",
- "categoryConsumable":1,
- }
- };
- if (filterKeyword) {
- postData.incidentcategory.category = filterKeyword;
- }
- // 当前所属院区或责任科室
- if($rootScope.user.duty){
- postData.incidentcategory.duty = $rootScope.user.duty.id;
- }else if($rootScope.user.branch){
- postData.incidentcategory.branch = $rootScope.user.branch.id;
- }
- $scope.my_data = [];
- $scope.doing_async = true;
- api_bpm_data
- .fetchDataList("incidentcategory", postData)
- .then(function (response) {
- if (response.status == 200) {
- var data = response.list;
- if (filterKeyword) {
- data.forEach((e) => {
- e.isExpanded = true;
- });
- var li = transform(data).children;
- console.log(li);
- fn(li);
- return;
- } else {
- var objects = [];
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- object.parent = data[i].parent;
- object.category = data[i].category;
- object.isExpanded = true;
- objects.push(object);
- }
- $scope.my_data = convertParentToChildList(objects);
- $scope.select_treedata = angular.copy($scope.my_data);
- }
- if ($scope.my_data.length > 0) {
- $scope.doing_async = false;
- }
- selectItem(selectdata.category,$scope.select_treedata);
- $scope.deptdata.category = selectdata.category;
- console.log($scope.deptdata, selectdata.category)
- console.log($scope.select_treedata)
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error",
- });
- }
- });
- };
- $scope.try_async_load();
- // --------------------
- $scope.cancel = function () {
- $modalInstance.dismiss("cancel");
- };
- // 保存
- $scope.savercode = function (deptdata) {
- if (
- deptdata &&
- deptdata.consumableIds &&
- deptdata.category
- ) {
- var fildata = {
- incidentCategoryConsumable: {
- id: deptdata.id,
- deleteFlag: 0,
- consumableIds: deptdata.consumableIds.map(v => v.id).toString(),
- category: deptdata.category,
- },
- };
- fildata.incidentCategoryConsumable = Object.assign({}, selectdata, fildata.incidentCategoryConsumable)
- api_user_data
- .addData("incidentCategoryConsumable", fildata)
- .then(function (response) {
- if (response) {
- if (response.status == 200) {
- SweetAlert.swal(
- {
- title: "修改成功!",
- type: "success",
- },
- function () {
- scope.refreshData("expand-right", scope.fileData);
- }
- );
- } else {
- SweetAlert.swal(
- {
- title: "修改失败!",
- text: response.msg,
- type: "error",
- },
- function () {
- scope.refreshData("expand-right", scope.fileData);
- }
- );
- }
- $modalInstance.close();
- } else {
- SweetAlert.swal(
- {
- title: "修改失败!",
- type: "error",
- },
- function () {
- scope.refreshData("expand-right", scope.fileData);
- }
- );
- }
- });
- } else {
- SweetAlert.swal(
- {
- title: "修改失败!",
- text: "请填写必填项!",
- type: "error",
- confirmButtonColor: "#DD6B55",
- },
- function () {}
- );
- }
- };
- },
- resolve: {
- scope: function () {
- return $scope;
- },
- },
- });
- };
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parent === "undefined" || datum.parent == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- return list;
- }
- $scope.addData = function () {
- var modalInstance = $modal.open({
- templateUrl: "assets/views/system/tpl/faultConsumableschange.html",
- controller: function ($rootScope, $scope, scope, $modalInstance, api_user_data,api_bpm_data) {
- $scope.deptdata = {
- consumableIds: [],
- category: "",
- };
- $scope.title = "故障耗材新增";
- // 耗材列表模糊搜索
- $scope.searchConsumable = function (key = "") {
- var deptData = {
- idx: 0,
- sum: 10,
- consumable: {
- keyWord: key,
- showZero: true,
- },
- };
- // 当前所属院区或责任科室
- if($rootScope.user.duty){
- deptData.consumable.dutyDTO = $rootScope.user.duty;
- }else if($rootScope.user.branch){
- }
- api_user_data
- .fetchDataList("consumable", deptData)
- .then(function (data) {
- var ids = $scope.deptdata.consumableIds.map(v=>v.id);
- $scope.consumableList = data.list.filter(v=>!ids.includes(v.id));
- });
- };
- // --------------------
- $scope.select_treedata = [];
- $rootScope.bala1 = $scope.try_async_load = function (s, fn) {
- if (s) {
- var filterKeyword = s.filterKeyword;
- }
- var postData = {
- idx: 0,
- sum: 9999,
- incidentcategory: {
- selectType: "pinyin_qs",
- "hierarchyQuery":"two",
- "categoryConsumable":1,
- }
- };
- if (filterKeyword) {
- postData.incidentcategory.category = filterKeyword;
- }
- // 当前所属院区或责任科室
- if($rootScope.user.duty){
- postData.incidentcategory.duty = $rootScope.user.duty.id;
- }else if($rootScope.user.branch){
- postData.incidentcategory.branch = $rootScope.user.branch.id;
- }
- $scope.my_data = [];
- $scope.doing_async = true;
- api_bpm_data
- .fetchDataList("incidentcategory", postData)
- .then(function (response) {
- if (response.status == 200) {
- var data = response.list;
- if (filterKeyword) {
- data.forEach((e) => {
- e.isExpanded = true;
- });
- var li = transform(data).children;
- console.log(li);
- fn(li);
- return;
- } else {
- var objects = [];
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- object.parent = data[i].parent;
- object.category = data[i].category;
- object.isExpanded = true;
- objects.push(object);
- }
- $scope.my_data = convertParentToChildList(objects);
- $scope.select_treedata = angular.copy($scope.my_data);
- }
- if ($scope.my_data.length > 0) {
- $scope.doing_async = false;
- }
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error",
- });
- }
- });
- };
- $scope.try_async_load();
- // --------------------
- $scope.cancel = function () {
- $modalInstance.dismiss("cancel");
- };
- // 保存
- $scope.savercode = function (deptdata) {
- if (
- deptdata &&
- deptdata.consumableIds &&
- deptdata.category
- ) {
- var selectedItem = deptdata;
- if (selectedItem.consumableIds && selectedItem.category) {
- var fildata = {
- incidentCategoryConsumable: {
- consumableIds: selectedItem.consumableIds.map(v => v.id).toString(),
- category: selectedItem.category,
- },
- };
- // 当前所属院区或责任科室
- if($rootScope.user.duty){
- fildata.incidentCategoryConsumable.duty = $rootScope.user.duty.id;
- }else if($rootScope.user.branch){
- fildata.incidentCategoryConsumable.branch = $rootScope.user.branch.id;
- }
- api_user_data
- .addData("incidentCategoryConsumable", fildata)
- .then(function (response) {
- if (response) {
- if (response.status == 200) {
- $modalInstance.close();
- SweetAlert.swal(
- {
- title: "新增成功!",
- type: "success",
- },
- function () {
- scope.refreshData("expand-right", scope.fileData);
- }
- );
- } else {
- SweetAlert.swal({
- title: "新增失败!",
- text: response.msg,
- type: "error",
- });
- }
- }
- });
- } else {
- SweetAlert.swal(
- {
- title: "新增失败!",
- text: "请填写必填项!",
- type: "error",
- confirmButtonColor: "#DD6B55",
- },
- function () {}
- );
- }
- } else {
- SweetAlert.swal(
- {
- title: "新增失败!",
- text: "请填写必填项!",
- type: "error",
- confirmButtonColor: "#DD6B55",
- },
- function () {}
- );
- }
- };
- },
- resolve: {
- scope: function(){
- return $scope;
- }
- },
- });
- };
- $scope.removeData = function () {
- var modalInstance = $modal.open({
- // templateUrl: 'assets/views/delete.html',
- templateUrl: "assets/views/incident/tpl/acceptTask.tpl.html",
- controller: function ($scope, scope, $modalInstance, api_bpm_data) {
- var rmvList = [];
- $scope.title = "故障耗材删除";
- $scope.connect = "确定要删除此故障耗材?";
- rmvList.push(scope.selected.items);
- $scope.ok = function () {
- $modalInstance.close(rmvList);
- // }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss("cancel");
- };
- },
- size: "sm",
- resolve: {
- scope: function () {
- return $scope;
- },
- },
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- if (selectedItem.length > 0) {
- console.log(selectedItem);
- api_user_data
- .rmvData("incidentCategoryConsumable", [selectedItem[0].id])
- .then(function (response) {
- if (response.status == 200) {
- SweetAlert.swal(
- {
- title: "删除成功!",
- type: "success",
- confirmButtonColor: "#007AFF",
- },
- function () {
- $scope.myData = _.reject($scope.myData, function (o) {
- return _.includes(selectedItem, o.id);
- });
- $scope.selected = {
- items: [],
- };
- $scope.gridOptions.totalItems =
- $scope.gridOptions.totalItems - selectedItem.length;
- $scope.gridApi.grid.selection.selectedCount = 0;
- $scope.refreshData("expand-right", $scope.fileData);
- }
- );
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error",
- });
- }
- });
- }
- }
- });
- };
- $scope.selected = {
- items: [],
- };
- $scope.editted = {
- items: [],
- };
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- // gridApi.edit.on.afterCellEdit($scope,function(rowEntity, colDef, newValue, oldValue){
- // // console.log(rowEntity);
- // });
- gridApi.pagination.on.paginationChanged(
- $scope,
- function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.fileData.idx = newPage - 1;
- $scope.fileData.sum = pageSize;
- defaultFilterData = filtersData;
- $scope.refreshData("expand-right", $scope.fileData);
- }
- );
- gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
- scope.grid.appScope.selected.items = scope.entity;
- });
- };
- var defaultFilterData = {
- idx: 0,
- sum: 10,
- incidentCategoryConsumable: {},
- };
- $scope.memoryfilterData = {
- idx: 0,
- sum: 10,
- incidentCategoryConsumable: {},
- };
- $scope.fileData = {
- idx: 0,
- sum: 10,
- incidentCategoryConsumable: {},
- };
- $scope.ldloading = {};
- $scope.refreshData = function (style, filterData) {
- $scope.selected.items = {};
- $scope.ldloading[style.replace("-", "_")] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myData = [];
- $scope.selected = { items: [] };
- if ($scope.gridApi) {
- $scope.gridApi.grid.selection.selectedCount = 0;
- }
- // 当前所属院区或责任科室
- if($rootScope.user.duty){
- filterData.incidentCategoryConsumable.duty = $rootScope.user.duty.id;
- }else if($rootScope.user.branch){
- filterData.incidentCategoryConsumable.branch = $rootScope.user.branch.id;
- }
- api_user_data.fetchDataList("incidentCategoryConsumable", filterData).then(
- function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
- $scope.myData[i]["consumableDTOSName"] = $scope.myData[i]["consumableDTOS"].map(v => v.name).join(',');
- }
- $scope.ldloading[style.replace("-", "_")] = false;
- },
- function () {
- $scope.ldloading[style.replace("-", "_")] = false;
- }
- );
- };
- $scope.refreshData2 = function (style, filterData) {
- $scope.selected.items = {};
- $scope.ldloading[style.replace("-", "_")] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myData = [];
- $scope.selected = { items: [] };
- if ($scope.gridApi) {
- $scope.gridApi.grid.selection.selectedCount = 0;
- }
- filterData = angular.copy(filterData);
- // 当前所属院区或责任科室
- if($rootScope.user.duty){
- filterData.incidentCategoryConsumable.duty = $rootScope.user.duty.id;
- }else if($rootScope.user.branch){
- filterData.incidentCategoryConsumable.branch = $rootScope.user.branch.id;
- }
- api_user_data.fetchDataList("incidentCategoryConsumable", filterData).then(
- function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
- $scope.myData[i]["consumableDTOSName"] = $scope.myData[i]["consumableDTOS"].map(v => v.name).join(',');
- }
- $scope.ldloading[style.replace("-", "_")] = false;
- },
- function () {
- $scope.ldloading[style.replace("-", "_")] = false;
- }
- );
- };
- // 搜索
- $scope.searchData = function () {
- $scope.refreshData("expand-right", $scope.fileData);
- };
- // 清空
- $scope.clean = function () {
- delete $scope.fileData.incidentCategoryConsumable.consumableIds;
- delete $scope.fileData.incidentCategoryConsumable.category;
- $scope.getCategoryData();
- $scope.refreshData("expand-right", $scope.fileData);
- };
- // 获取院区下拉
- $scope.model = {};
- // --------------------
- $scope.select_treedata = [];
- $rootScope.bala1 = $scope.try_async_load = function (s, fn) {
- if (s) {
- var filterKeyword = s.filterKeyword;
- }
- var postData = {
- idx: 0,
- sum: 9999,
- incidentcategory: {
- selectType: "pinyin_qs",
- "hierarchyQuery":"two",
- "categoryConsumable":1,
- }
- };
- if (filterKeyword) {
- postData.incidentcategory.category = filterKeyword;
- }
- // 当前所属院区或责任科室
- if($rootScope.user.duty){
- postData.incidentcategory.duty = $rootScope.user.duty.id;
- }else if($rootScope.user.branch){
- postData.incidentcategory.branch = $rootScope.user.branch.id;
- }
- $scope.my_data = [];
- $scope.doing_async = true;
- api_bpm_data
- .fetchDataList("incidentcategory", postData)
- .then(function (response) {
- if (response.status == 200) {
- var data = response.list;
- if (filterKeyword) {
- data.forEach((e) => {
- e.isExpanded = true;
- });
- var li = transform(data).children;
- console.log(li);
- fn(li);
- return;
- } else {
- var objects = [];
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- object.parent = data[i].parent;
- object.category = data[i].category;
- object.isExpanded = true;
- objects.push(object);
- }
- $scope.my_data = convertParentToChildList(objects);
- $scope.select_treedata = angular.copy($scope.my_data);
- }
- if ($scope.my_data.length > 0) {
- $scope.doing_async = false;
- }
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error",
- });
- }
- });
- };
- // $scope.try_async_load();
- // --------------------
- $scope.refreshData("expand-right", $scope.fileData);
- $scope.timer = $interval(function () {
- $scope.refreshData2("expand-right", $scope.fileData);
- }, $rootScope.refreshTime);
- $scope.$on("$destroy", function () {
- $interval.cancel($scope.timer);
- });
- },
- ]);
|