| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- define([ 'app/app' ], function(app) {
- //品牌审批
- app.register.controller('StoreApplicationCtrl', ['$scope', '$anchorScroll', '$location', '$modal', 'BaseService', 'SessionService', 'toaster', 'ngTableParams', 'StoreInfo', '$state', function ($scope, $anchorScroll, $location, $modal, BaseService, SessionService, toaster, ngTableParams, StoreInfo, $state) {
- // 店铺类型常量
- $scope.storeType = {
- AGENCY: {
- name: 'AGENCY',
- message: '代理商'
- },
- DISTRIBUTION: {
- name: 'DISTRIBUTION',
- message: '经销商'
- },
- ORIGINAL_FACTORY: {
- name: 'ORIGINAL_FACTORY',
- message: '原厂'
- }
- };
- // 开店申请的审核类型
- $scope.authType = {
- PREPARE: {
- name: 'PREPARE',
- message: '待审核'
- },
- PASS: {
- name: 'PASS',
- message: '已通过'
- },
- UNPASS: {
- name: 'UNPASS',
- message: '未通过'
- }
- };
- $scope.ngPageInfo = {
- page : 1,
- count : 10,
- sorting : {
- createTime: 'DESC'
- }
- };
- // 保存查询店铺申请的状态
- $scope.status = $scope.authType.PREPARE.name;
- // 保存查询店铺类型的状态
- $scope.type = 'ALL_TYPE';
- // 保存店铺搜索类型
- $scope.search = 'STORE_NAME';
- // 保存店铺搜索类型所传参数
- $scope.searchParams = 'authPage';
- $scope.showSearch = false
- /**
- * 切换Tab
- *
- * @param tab tab标签
- * @param type TAB类型
- */
- $scope.switchTab = function (tab, type) {
- if (type === 'status') {
- $scope.status = tab;
- if ($scope.type !== 'ALL_TYPE') {
- $scope.type = 'ALL_TYPE';
- }
- }
- if (type === 'type') {
- $scope.type = tab;
- }
- $scope.refreshTableData();
- };
- $scope.isShowSearch = function (flag) {
- $scope.showSearch = flag
- };
- /**
- * 切换搜索类型
- *
- * @param type 店铺类型
- *
- */
- $scope.placeValue = $scope.search === 'STORE_NAME' ? '请输入公司名称' : '请输入审核人姓名';
- $scope.switchSearch = function (type, flag) {
- if (type === 'STORE_NAME') {
- $scope.search = 'STORE_NAME';
- $scope.searchParams = 'authPage';
- }
- if (type === 'AUDITOR') {
- $scope.search = 'AUDITOR';
- $scope.searchParams = 'authorPage';
- }
- $scope.showSearch = flag
- $scope.placeValue = $scope.search === 'STORE_NAME' ? '请输入公司名称' : '请输入审核人姓名';
- };
- $scope.applicationTableParams = new ngTableParams($scope.ngPageInfo, {
- total : 0,
- counts: [5, 10, 25, 50, 100],
- getData : function($defer, params) {
- $scope.loading = true;
- var param = BaseService.parseParams(params.url());
- param.status = $scope.status === 'ALL' ? null : $scope.status;
- param.type = $scope.type === 'ALL_TYPE' ? null : $scope.type;
- param.keyword = $scope.keyword && $scope.keyword !== '' ? $scope.keyword : null;
- param.operate = $scope.searchParams;
- StoreInfo.pageStoreApplications(param, function (data) {
- console.log(data);
- params.total(data.totalElements);
- if (data.content) {
- $defer.resolve(data.content);
- var date = new Date();
- console.log('TIMESTAMP', date.getTime());
- angular.forEach(data.content, function (application) {
- if (application.status === $scope.authType.PREPARE.name) {
- var time = date - application.createTime;
- // 计算相差天数
- var days = Math.floor(time / (24 * 3600 * 1000));
- // 计算相差小时数
- var leave1 = time % (24 * 3600 * 1000);
- var hours = Math.floor(leave1 / (3600 * 1000));
- application.time = {
- hour: hours,
- day: days
- };
- }
- })
- } else {
- $defer.resolve([]);
- }
- });
- }
- });
- $scope.changeShorting = function () {
- if($scope.ngPageInfo.sorting.createTime == 'DESC'){
- $scope.ngPageInfo.sorting.createTime = 'ASC';
- } else {
- $scope.ngPageInfo.sorting.createTime = 'DESC';
- }
- $scope.refreshTableData();
- };
- /**
- * 刷新表格数据
- */
- $scope.refreshTableData = function () {
- if ($scope.applicationTableParams.page() != 1) {
- $scope.applicationTableParams.page(1);
- }
- $scope.applicationTableParams.reload();
- };
- /**
- * 审核通过
- */
- $scope.auditSuccess = function (application) {
- var param = {
- uuid : application.uuid,
- status : 'PASS'
- };
- handlerApplication(param);
- };
- /**
- * 审核失败
- */
- $scope.auditFail = function (application) {
- var param = {
- uuid : application.uuid,
- status : 'UNPASS'
- };
- handlerApplication(param);
- };
- /**
- * 审核申请
- */
- var handlerApplication = function (param) {
- console.log(param);
- StoreInfo.handlerApply(param, null, function (data) {
- if (data.success) {
- if (data.data) {
- toaster.pop('success', "审核通过,店铺UUID:" + data.data);
- } else {
- toaster.pop('success', "审核不通过");
- }
- $scope.refreshTableData();
- } else {
- toaster.pop('error', data.message);
- }
- })
- };
- /**
- * 审核资质信息
- *
- * @param application 店铺申请信息
- */
- $scope.auditQualification = function (application) {
- if (application && application.uuid) {
- $state.go('store_qualification_auth', { applyUuid : application.uuid });
- } else {
- toaster.pop('error', '店铺审核信息不能为空');
- }
- }
- }]);
- });
|