| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- myApp.controller("donate", ["$scope", "$http", "NgTableParams", function($scope, $http, NgTableParams) {
- window.hub.stop();
- var self = this;
- var source = [];
- $scope.loading();
- $scope.paginationConf = {
- currentPage: 1,
- itemsPerPage: 10,
- pagesLength: 25,
- perPageOptions: [1, 5, 10, 15, 20, 30, 40, 50, 100, 200],
- rememberPerPage: 'perPageItems',
- onChange: function() {
- self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
- }
- };
- this.GetPageData = function(page, size) {
- $scope.loading();
- $http.post("/donate/getpagedata", {
- page,
- size
- }).then(function(res) {
- $scope.paginationConf.totalItems = res.data.TotalCount;
- $("div[ng-table-pagination]").remove();
- self.tableParams = new NgTableParams({
- count: 50000
- }, {
- filterDelay: 0,
- dataset: res.data.Data
- });
- source = angular.copy(res.data.Data);
- $scope.loadingDone();
- });
- };
- self.del = function(row) {
- swal({
- title: "确认删除这条打赏记录吗?",
- text: row.NickName,
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- showLoaderOnConfirm: true,
- animation: true,
- allowOutsideClick: false
- }).then(function() {
- $scope.request("/donate/delete", {
- id: row.Id
- }, function(data) {
- window.notie.alert({
- type: 1,
- text: data.Message,
- time: 4
- });
- });
- _.remove(self.tableParams.settings().dataset, function(item) {
- return row === item;
- });
- self.tableParams.reload().then(function(data) {
- if (data.length === 0 && self.tableParams.total() > 0) {
- self.tableParams.page(self.tableParams.page() - 1);
- self.tableParams.reload();
- }
- });
- }, function() {
- }).catch(swal.noop);
- }
- $scope.save = function (row) {
- if (row==null) {
- row = {
- NickName: "",
- DonateTime: "",
- Amount: "",
- Email: "",
- QQorWechat: "",
- Via:""
- };
- }
- swal({
- title: '添加打赏记录',
- html: '<div class="input-group"><span class="input-group-addon">昵称: </span><input type="text" id="name" class="form-control input-lg" placeholder="请输入昵称" value="' + row.NickName+'"></div>' +
- '<div class="input-group"><span class="input-group-addon">打赏时间: </span><input id="date" type="text" class="form-control input-lg date datainp dateicon" readonly placeholder="请输入打赏时间" value="' + row.DonateTime +'"></div> ' +
- '<div class="input-group"><span class="input-group-addon">打赏金额: </span><input id="amount" type="text" class="form-control input-lg" placeholder="请输入金额" value="' + row.Amount +'"></div>' +
- '<div class="input-group"><span class="input-group-addon">打赏方式: </span><input id="via" type="text" class="form-control input-lg" placeholder="请输入打赏方式" value="' + row.Via +'"></div>' +
- '<div class="input-group"><span class="input-group-addon">Email: </span><input type="email" id="email" class="form-control input-lg" placeholder="请输入Email" value="' + row.Email +'"></div>' +
- '<div class="input-group"><span class="input-group-addon">QQ或微信: </span><input type="text" id="qq" class="form-control input-lg" placeholder="请输入QQ或微信" value="' + row.QQorWechat +'"></div>',
- showCloseButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- showLoaderOnConfirm: true,
- animation: true,
- allowOutsideClick: false,
- preConfirm: function () {
- return new Promise(function (resolve, reject) {
- row.NickName = $("#name").val();
- row.DonateTime = $("#date").val();
- row.Amount = $("#amount").val();
- row.Via = $("#via").val();
- row.Email = $("#email").val();
- row.QQorWechat = $("#qq").val();
- $http.post("/donate/save", row).then(function (res) {
- if (res.data.Success) {
- resolve(res.data);
- } else {
- reject(res.data.Message);
- }
- }, function (error) {
- reject("服务请求失败!");
- });
- });
- }
- }).then(function (result) {
- if (result) {
- if (result.Success) {
- swal(result.Message, "", "success");
- self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
- } else {
- swal(result.Message, "", "error");
- }
- }
- }).catch(swal.noop);
- $(".date").jeDate({
- isinitVal: true,
- format: "YYYY-MM-DD",
- okfun: function (elem) {
- $("#date").val(elem.val);
- }
- });
- }
- $scope.loadingDone();
- }]);
|