2025-06-27 10:04:22 +08:00

447 lines
14 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

app.controller('PlanCheckCtrl', ['$scope', 'RWDZ', 'JCDW', '$uibModal', '$state', '$stateParams','$http','$sessionStorage', 'Upload', 'mainUrl', 'wyOdataNodeService', 'stConfig', function ($scope, RWDZ, JCDW, $uibModal, $state, $stateParams,$http,$sessionStorage,Upload, mainUrl, wyOdataNodeService, stConfig) {
$scope.YSSS = false;
$scope.TorF = false;
if ($stateParams.id == 0) {
$scope.YorN = false;
$scope.BiaoTi="计划任务查看"
} else if ($stateParams.id == 1) {
$scope.YorN = true;
$scope.BiaoTi = "计划任务选择"
}
$scope.SPDL = "食品大类";
/**************************************************************************************/
//通过STMATETable 分页显示数据
//以下的参数每个控制器都要有一份
$scope.tableState = []; //这个参数后面会让每次访问服务器后进行同步返回的值赋值,作为中间值使用
$scope.selectList = []; //这个参数会让每次选中或者没有选中的条目直接暴露在这个值里面
if ($sessionStorage.user.type == 4 || $sessionStorage.user.type == 5) {
$scope.searchSql = "JCDW eq '" + $sessionStorage.user.name + "'";
$scope.YSSS = true;
} else {
$scope.searchSql = '';
} //这个参数是自己组合相关的复杂查询条件
$scope.isShow = false; //这个参数主要进行页面加载的loading显示的directive的值得操作
$scope.itemsOptions = [5, 10, 20, 50, 100, 200]; //这个参数进行分页页面上面的每页多少条的设置
$scope.curpageNumber = 10; //这个参数传递当前的每页多少条的数据
//任何动作都会触发服务端的接口
$scope.getService = function (tableState, ctrl) {
$scope.tableState = tableState;
if (!$scope.tableState.pagination.number) {
$scope.tableState.pagination.number = $scope.curpageNumber;
}
$scope.isShow = true;
// console.log($scope.searchSql+"aaa");
wyOdataNodeService.getData(pubserver, 'RWDZ_DB', $scope.tableState, $scope.searchSql).then(function (data) {
$scope.displayed = data;
console.log(data);
//当前页面的ID号数组
$scope.isShow = false;
$scope.ids = Enumerable.From($scope.displayed).Select(function (x) { return x.id }).ToArray();
$scope.myttt = tableState.count;
$scope.$broadcast('checkini');
//console.log($scope.ids);
});
};
//模板的分页选择触发操作
$scope.setPageNumber = function (pageNo) {
// alert("1")
$scope.getService($scope.tableState);
}
//查询参数的调用
$scope.search = function () {
$scope.searchSql = [$scope.sql];
$scope.getA($scope.tableState);
//约定成数字的按照前后
//日期按照前后
//字符串的模糊查询
//var sql = '$filter=EventDateTime eq DateTime'2010-12-21T10:10:19.390625';
//日期参考如下:
//(EventDateTime eq DateTime'2010-12-21T10:10:19.390625' ) and (BusinessUnitCode eq '2')
//var dT=dd ge 12 and dd le 33
}
//任务数合计
RWDZ.getAllSelect({ $filter: $scope.searchSql, $select: "JCRWHJ" }, function (data) {
var dd = Enumerable.From(data.value).Select("$.JCRWHJ").Sum();
$scope.myttt2 = dd;
})
// //任务定制库
//RWDZ.get(function (data) {
// $scope.myData = data.value;
// //首先判断是否是检测机构如果是检测机构的话那么就只显示检测机构的数据
// switch ($sessionStorage.user.type) {
// case 4:
// case 5:
// $scope.myData = Enumerable.From($scope.myData).Where("$.JCDW.indexOf('" + $sessionStorage.user.name + "')>-1").ToArray();
// break;
// default:
// }
// $scope.myttt = $scope.myData.length;
// var dd = Enumerable.From($scope.myData).Select("$.JCRWHJ").Sum();
// $scope.myttt2 = dd;
//});
RWDZ.getAll({ $filter: "JCDW eq '农业部水产品质量检验测试中心(上海)'" }, function (data) {
angular.forEach(data.value, function (data1) {
data1.JCDW = "农业部水产品质量监督检验测试中心(上海)";
RWDZ.update({ id: data1.id }, { JCDW: data1.JCDW }, function (data2) {
console.log(angular.toJson(data2));
})
})
})
//检测机构
JCDW.get(function (data) {
$scope.JCDWdata = data.value;
})
//任务来源
$scope.RELYdata = [
{ name: "国家食品药品监督管理总局", PY: "GJZJ" },
{ name: "上海市食品药品监督管理局", PY: "SHZJ" }
];
//检验频次
$scope.JYPCdata = [
{ name: "月", PY: "MONTH" },
{ name: "季度", PY: "QUARTER" },
{ name: "半年", PY: "BYEAR" },
{ name: "年", PY: "YEAR" },
]
//任务性质
$scope.RWXZdata = [
{ name: "常规监测", PY: "CGJC" },
{ name: "专项监测", PY: "ZXJC" },
{ name: "应急监测", PY: "YJJC" },
{ name: "能力验证", PY: "NLYZ" },
];
//转换时间格式
$scope.formatDate = function (day) {
var cc = new Date(day);
var y = cc.getFullYear();
var m = cc.getMonth() + 1;
var d = cc.getDate();
if (m < 10) {
m = "0" + m;
}
if (d < 10) {
d = "0" + d;
}
return aa = y + "/" + m + "/" + d;
}
/***********************************查询刷新的方法********************************/
$scope.Cha = function () {
$scope.selectList = [];
if ($sessionStorage.user.type == 4 || $sessionStorage.user.type == 5) {
$scope.searchSql = "JCDW eq '" + $sessionStorage.user.name + "' and ";
} else {
$scope.searchSql = '';
}
//第一步获取当前数据
//任务编号
var rwbh = $scope.rwbh;
//检测机构
var jcjg = $scope.jcjg;
//任务来源
var rwly = $scope.rwly;
//任务频次
var jypc = $scope.jypc
//任务性质
var rwxz = $scope.rwxz;
//选择食品类型
var splb = $scope.SPDL;
//食品类别关键字
var gjz = $scope.GJZ;
//任务开始执行时间
var ypkssj=$scope.ypkssj;
//任务结束执行时间
var ypjssj = $scope.ypjssj;
//如果任务编号不为空
if (rwbh != undefined && rwbh != '') {
$scope.searchSql = $scope.searchSql + "indexof(RWBH,'" + rwbh + "') ge 0 and ";
}
//检车机构不为空
if (jcjg != undefined) {
$scope.searchSql = $scope.searchSql + "JCDW eq '" + jcjg.JCJGMC + "' and ";
}
//恩任务来源不为空
if (rwly != undefined) {
$scope.searchSql = $scope.searchSql + "RWLY eq '" + rwly.name + "' and ";
}
//任务频次不为空
if (jypc != undefined) {
$scope.searchSql = $scope.searchSql + "JYPC eq '" + jypc.name + "' and ";
}
//任务性质不为空
if (rwxz != undefined) {
$scope.searchSql = $scope.searchSql + "RWXZ eq '" + rwxz.name + "' and ";
}
//如果选择的食品类别不为空
if (splb != undefined) {
switch (splb) {
case "食品大类":
//zdata = Enumerable.From(zdata).Where(function (x) { return x.SPDL == splb}).ToArray();
if (gjz != undefined && gjz !='') {
$scope.searchSql = $scope.searchSql + "indexof(SPDL,'" + rebh + "') ge 0 and ";
}
break;
case "食品亚类":
//zdata = Enumerable.From(zdata).Where(function (x) { return x.SPYL == splb }).ToArray();
if (gjz != undefined && gjz != '') {
$scope.searchSql = $scope.searchSql + "indexof(SPYL,'" + gjz + "') ge 0 and ";
}
break;
case "食品品种":
//zdata = Enumerable.From(zdata).Where(function (x) { return x.SPPZ == splb }).ToArray();
if (gjz != undefined && gjz != '') {
$scope.searchSql = $scope.searchSql + "indexof(SPPZ,'" + gjz + "') ge 0 and ";
}
break;
case "食品小类":
//zdata = Enumerable.From(zdata).Where(function (x) { return x.SPXL == splb }).ToArray();
if (gjz != undefined && gjz != '') {
$scope.searchSql = $scope.searchSql + "indexof(SPXL,'" + gjz + "') ge 0 and ";
}
break;
default:
}
}
//开始时间结束时间不为空
if (ypkssj != undefined) {
var Ktime = $scope.formatDate(ypkssj);
$scope.searchSql = $scope.searchSql + "YPKSSJ ge '" + Ktime + "' and ";
}
//结束时间不为空
if (ypjssj != undefined) {
var Jtime = $scope.formatDate(ypjssj);
// console.log(Jtime);
$scope.searchSql = $scope.searchSql + "YPJSSJ le '" + Jtime + "' and ";
}
$scope.searchSql = $scope.searchSql.substring(0, $scope.searchSql.length - 4);
$scope.getService($scope.tableState, $scope.searchSql);
//增加日志20211109
addlog("计划任务查看", "查询[" + $scope.searchSql + "]")
RWDZ.getAllSelect({ $filter: $scope.searchSql, $select:"JCRWHJ" }, function (data) {
var dd = Enumerable.From(data.value).Select("$.JCRWHJ").Sum();
$scope.myttt2 = dd;
})
}
/**************************查看 详细信息**************************/
$scope.items = 0;
$scope.open = function (id) {
$scope.items = id;
var modalInstance = $uibModal.open({
animation: true,
backdrop: false, // 不让点击背景关闭系统
templateUrl: 'app/model1/modalRWDZ.html',
controller: 'modalRWCKCtrl',
size: 'lg',
//windowTopClass:'dialog'
resolve: {
items: function () {
return $scope.items;
}
}
});
modalInstance.result.then(
function (nclose) {
$scope.returnData = nclose
},
function (ndismiss) { $scope.returnData = ndismiss }
)
}
//勾选的方法
$scope.dianji = function () {
// console.log($scope.selectList);
if ($scope.selectList.length > 0) {
$scope.TorF = true;
} else { $scope.TorF = false }
}
//点击确定
var cc = '';
$scope.Ok = function () {
RWDZ.getOne({ id: $scope.selectList[0] }, function (data) {
// alert(angular.toJson(data));
cc = data.RWBH;
// alert(cc);
$state.go('app.SampleRegister', { id: cc });
});
}
//点击返回
$scope.Return = function () {
$state.go('app.SampleRegister', { id: 0 });
}
}])
/*********************************这是查看信息**********************************************/
app.controller('modalRWCKCtrl', ['$scope','RWDZ', '$uibModalInstance', 'items','JCDW',function ($scope, RWDZ, $uibModalInstance, items,JCDW) {
$scope.JCDWdata = [];
//检测机构
JCDW.get(function (data) {
//$scope.JCDWdata1 = data.value;
angular.forEach(data.value, function (data1) {
$scope.JCDWdata.push(data1.JCJGMC);
})
// $scope.jcjg = data.value[0];
console.log($scope.JCDWdata);
})
//任务来源
$scope.RELYdata = [
"国家食品药品监督管理总局", "上海市食品药品监督管理局", ];
//检验频次
$scope.JYPCdata = ["月", "季度", "半年", "年", ]
//任务性质
$scope.RWXZdata = ["常规监测", "专项监测", "应急监测", "能力验证",
];
//风险等级
$scope.FXDJdata = ["I类(上海)", "II类(上海)", "III类(上海)", "高(国家)", "较高(国家)", "一般(国家)",
];
RWDZ.getOne({ id: items }, function (data) {
$scope.IsChange = false;
$scope.IsSave = false;
$scope.rwbh = data.RWBH;
var aa = {
JCJGMC: data.JCDW,
};
//alert(data.JCDW);
$scope.jcjg = data.JCDW;
$scope.ypkssj = new Date(data.YPKSSJ);
$scope.ypjssj = new Date(data.YPJSSJ);
$scope.jypc = data.JYPC;
$scope.jhlrsj = new Date(data.JHLRRQ);
//alert(data.RWLY);
$scope.rwly = data.RWLY;
$scope.rwxz = data.RWXZ;
$scope.fxdj = data.FXDJ;
$scope.spdl = data.SPDL;
$scope.spyl = data.SPYL;
$scope.sppz = data.SPPZ;
$scope.spxl = data.SPXL;
$scope.schjrws = data.SCHJRWS;
$scope.cyhjrws = data.CYHJRWS;
$scope.lthjrws = data.LTHJRWS;
$scope.jcrwhj = data.JCRWHJ;
$scope.jcxm = [];
angular.forEach(data.JCXM, function (data) {
$scope.jcxm += data.roleName + "";
})
$scope.bz = data.BZ;
$scope.zt = data.ZT;
});
//点击返回
$scope.Cancel = function () {
$uibModalInstance.dismiss("界面直接退出");
}
}]);