| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- "use strict";
- angular.module('app.business')
- //盘点单
- .controller("deviceCheckCtrl", function ($scope, $http, $state, $rootScope, deviceCheckService, $filter, $stateParams, APP_CONFIG) {
- // 获取列表数据
- $scope.pageInfo = {pageNum: 1, pageSize: 10};
- $scope.search = {pdNum: "", starttime: "", endtime: ""};
- $scope.loadPdNum = function () {
- deviceCheckService.getCheckListNoPage().then(function (data) {
- $scope.pdNum = data;
- $scope.loadData();
- }, function (data) {
- console.log(data);
- });
- }
- $scope.loadData = function () {
- deviceCheckService.getPageInfoDevice($scope.pageInfo.pageNum, $scope.pageInfo.pageSize, $scope.search.pdNum, $scope.search.starttime, $scope.search.endtime).then(function (data) {
- $scope.pageInfo = data;
- }, function (data) {
- console.log(data);
- });
- }
- // $scope.loadData();
- $scope.loadPdNum();
- //清空
- $scope.clean = function () {
- $scope.search = {pdNum: "", starttime: "", endtime: ""};
- $scope.loadData();
- }
- //新增
- $scope.showCheck = function () {
- $state.go('app.basic.device.checkAdd');
- }
- // 翻页
- $scope.goPage = function (pageNum) {
- $scope.pageInfo.pageNum = pageNum;
- $scope.loadData();
- }
- //根据仓房ID删除数据
- $scope.remove = function (houseId, checkNumber) {
- if (confirm("确定删除该条数据?")) {
- deviceCheckService.remove(houseId, checkNumber).then(function (data) {
- $scope.loadPdNum();
- }, function (data) {
- console.log(data);
- });
- }
- }
- //修改
- $scope.loadDataById = function (checkNumber, type) {
- $state.go("app.basic.device.checkEdit", {checkNumber: checkNumber, isNotEdit: type});
- }
- // 翻页
- $scope.goPage = function(pageNum) {
- if ($scope.pageInfo.pageNum != pageNum && pageNum > 0) {
- $scope.pageInfo.pageNum = pageNum;
- $scope.loadData();
- }
- }
- })
- .controller("deviceCheckAddCtrl", function ($scope, $http, $state, $rootScope, $filter, deviceCheckService, equipmentEquipmentPoolService, $stateParams, APP_CONFIG, enumService, deviceStorageService) {
- // 获取存放位置
- $scope.equipment = function () {
- equipmentEquipmentPoolService.getPageInfo(null, null, null).then(function (data) {
- $scope.equipmentEquipmentPool = data.list;
- }, function (data) {
- console.log(data);
- });
- }
- $scope.equipment();
- /* $scope.dateTimes = function (number, type) {
- var date = new Date();
- date.setDate(date.getDate() - number);//获取number天后的日期
- var years = date.getFullYear();
- var month = date.getMonth() + 1;//获取当前月份的日期
- var strDate = date.getDate();
- if (month >= 1 && month <= 9) {
- month = "0" + month;
- }
- if (strDate >= 0 && strDate <= 9) {
- strDate = "0" + strDate;
- }
- if (type == 0) return years + month + strDate;
- if (type == 1) return years + "-" + month + "-" + strDate + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
- };*/
- $scope.pddTitleName = "新增盘点单";
- $scope.deviceCheck = {};
- $scope.reallyCount = 0;//默认实际数量
- $scope.reason = '无';//默认原因为空
- $scope.deviceCheck.depotId = -1;//仓房d
- $scope.deviceCheck.deviceType = "";//盘点种类
- // $scope.deviceCheck.checkDate = $scope.dateTimes(0, 1);
- var pddh;//自动生成的盘点单号-20180104003
- //根据盘点时间,获取当天盘点单号
- $scope.getCount = function () {
- $scope.deviceList = {};
- if ($scope.deviceCheck.checkNumber != undefined) {
- deviceStorageService.getBySbCode($scope.deviceCheck.checkNumber).then(function (data) {//data = 2;
- $scope.deviceList = data;
- }, function (data) {
- console.log(data);
- });
- }
- }
- $scope.changePdzl = function () {
- if (null == $scope.deviceCheck.deviceType || $scope.deviceCheck.deviceType == 'undefined') {
- $scope.deviceCheck.deviceType = "";
- }
- deviceCheckService.changePdzl($scope.deviceCheck.deviceType[0].name).then(function (data) {
- $scope.allSbcode = data;
- }, function (data) {
- console.log(data);
- });
- }
- $scope.back = function () {
- $state.go("app.basic.device.deviceCheckList");
- }
- var validator = $("#deviceCheck-form").validate();
- $scope.pd = {};
- $scope.check = {reallyCount: "", reason: ""};
- $scope.saveData = function () {
- if (validator.form()) {
- var ins = {};
- // ins.device_type = $scope.deviceCheck.deviceType;//盘点种类
- //ins.check_date = $scope.deviceCheck.checkDate;//时间
- // ins.check_date = $filter('date')($scope.deviceCheck.checkDate, "yyyy-MM-dd HH:mm:ss");//时间
- // ins.depot_id = $scope.deviceCheck.depotId;//仓房id
- ins.device_name = $scope.deviceCheck.deviceType[0].name;//器材名称
- ins.check_number = $scope.deviceCheck.checkNumber;//盘点单号
- ins.store_count = $scope.deviceList.sbsl;//库存数量
- ins.really_count = $scope.check.reallyCount;//实际库存数量
- ins.check_result = $scope.deviceList.checkResult;//盘点情况
- ins.reason = $scope.check.reason;//原因描述
- ins.org_id = $rootScope.userInfo.orgId;
- ins.check_person = $scope.deviceCheck.checkPerson;//负责人
- ins.model = $scope.deviceList.sbggxh; //规格型号
- // 提交表单
- $http({
- method: 'POST',
- url: APP_CONFIG.deviceUrl + '/deviceCheck/save',
- data: {
- deviceCheckJson: angular.toJson(ins),
- type: "add"
- }
- }).then(function successCallback(response) {
- if (response.data.status == "success") {
- alert("保存成功!");
- $state.go('app.basic.device.deviceCheckList');
- } else {
- alert("保存失败!");
- }
- }, function errorCallback(response) {
- // 请求失败执行代码
- });
- }
- };
- // 显示设备器材详情页
- $scope.changeDeviceType = function () {
- if ($scope.dSbxxsjy.ssfl === '1') { // 显示设备编辑
- // 显示设备 ShowQCType
- $scope.ShowQCType = true;
- // 显示器材 ShowSBType
- $scope.ShowSBType = false;
- $scope.getDeviceName('', '5476');
- } else if ($scope.dSbxxsjy.ssfl === '3') { // 显示器材编辑
- $scope.ShowQCType = false;
- $scope.ShowSBType = true;
- $scope.getDeviceName('', '5475');
- } else { // 默认显示设备编辑
- $scope.ShowQCType = true;
- $scope.ShowSBType = false;
- $scope.getDeviceName('', '5476');
- }
- };
- //树形下拉框获取器材设备名称
- $scope.getDeviceName = function (deviceName, deviceType) {
- enumService.getTreeListByTypeId(deviceName, deviceType).then(function (data) {
- $scope.deviceNameTreeData = data;
- }, function (data) {
- console.log(data);
- })
- };
- })
- .controller("deviceCheckEditCtrl", function ($scope, $http, $state, $filter, $rootScope, deviceCheckService, equipmentEquipmentPoolService, $stateParams, APP_CONFIG) {
- // 获取存放位置
- $scope.equipment = function () {
- equipmentEquipmentPoolService.getPageInfo(null, null, null).then(function (data) {
- $scope.equipmentEquipmentPool = data.list;
- }, function (data) {
- console.log(data);
- });
- }
- $scope.equipment();
- $scope.dateTimes = function (number, type) {
- var date = new Date();
- date.setDate(date.getDate() - number);//获取number天后的日期
- var years = date.getFullYear();
- var month = date.getMonth() + 1;//获取当前月份的日期
- var strDate = date.getDate();
- if (month >= 1 && month <= 9) {
- month = "0" + month;
- }
- if (strDate >= 0 && strDate <= 9) {
- strDate = "0" + strDate;
- }
- if (type == 0) return years + month + strDate;
- if (type == 1) return years + "-" + month + "-" + strDate + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
- };
- $scope.back = function () {
- $state.go("app.basic.device.deviceCheckList");
- }
- $scope.deviceCheck = {};
- $scope.deviceCheck.depotId = -1;//仓房d
- var pddh;//自动生成的盘点单号-20180104003
- //根据盘点时间,获取当天盘点单号
- $scope.getCount = function () {
- deviceCheckService.getCount($scope.deviceCheck.depotId).then(function (data) {//data = 2;
- pddh = $scope.deviceCheck.checkNumber = $scope.dateTimes(0, 0) + "00" + (data * 1 + 1);
- if ($scope.deviceCheck.depotId == null || $scope.deviceCheck.depotId == 'undefined') {
- $scope.deviceCheck.depotId = -1;
- }
- $scope.deviceCheck.checkNumber = $scope.deviceCheck.depotId + "-" + $scope.deviceCheck.deviceType + "-" + pddh;
- }, function (data) {
- console.log(data);
- });
- }
- // $scope.getCount();
- deviceCheckService.loadDataById($stateParams.checkNumber).then(function (data) {
- $scope.deviceList = data[0];
- if ($stateParams.isNotEdit == "1") {
- $scope.pddTitleName = "盘点单详情";
- $scope.isNotEdit = true;
- }
- else {
- $scope.pddTitleName = "修改盘点单";
- $scope.isNotEdit = false;
- }
- }, function (data) {
- console.log(data);
- });
- $scope.saveData = function () {
- var ins = {};
- ins.device_name = $scope.deviceList.deviceName;//器材名称
- ins.check_number = $scope.deviceList.checkNumber;//盘点单号
- ins.store_count = $scope.deviceList.storeCount;//库存数量
- ins.really_count = $scope.deviceList.reallyCount;//实际库存数量
- ins.check_result = $scope.deviceList.checkResult;//盘点情况
- ins.reason = $scope.deviceList.reason;//原因描述
- ins.org_id = $rootScope.userInfo.orgId;
- ins.check_person = $scope.deviceList.checkPerson;//负责人
- ins.model = $scope.deviceList.model; //规格型号
- // 提交表单
- $http({
- method: 'POST',
- url: APP_CONFIG.deviceUrl + '/deviceCheck/save',
- data: {
- deviceCheckJson: angular.toJson(ins),
- type: "edit"
- }
- }).then(function successCallback(response) {
- if (response.data.status == "success") {
- alert("保存成功!");
- $state.go('app.basic.device.deviceCheckList');
- } else {
- alert("保存失败!");
- }
- }, function errorCallback(response) {
- // 请求失败执行代码
- });
- }
- })
|