From 1a0c0fc8b02415e919e17c0b6ffbf99d08dec8f5 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 07 四月 2023 17:40:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 management/guns-admin/src/main/webapp/static/modular/system/tCommercial/tCommercial.js |  152 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 123 insertions(+), 29 deletions(-)

diff --git a/management/guns-admin/src/main/webapp/static/modular/system/tCommercial/tCommercial.js b/management/guns-admin/src/main/webapp/static/modular/system/tCommercial/tCommercial.js
index 8209a62..2c5dda3 100644
--- a/management/guns-admin/src/main/webapp/static/modular/system/tCommercial/tCommercial.js
+++ b/management/guns-admin/src/main/webapp/static/modular/system/tCommercial/tCommercial.js
@@ -14,21 +14,73 @@
 TCommercial.initColumn = function () {
     return [
         {field: 'selectItem', radio: true},
-            {title: '主键', field: 'id', visible: true, align: 'center', valign: 'middle'},
-            {title: '类型(1=弹窗广告,2=底部广告)', field: 'type', visible: true, align: 'center', valign: 'middle'},
-            {title: '名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
-            {title: '广告地址', field: 'url', visible: true, align: 'center', valign: 'middle'},
-            {title: '设备(1=小程序,2=司机端)', field: 'device', visible: true, align: 'center', valign: 'middle'},
-            {title: '是否跳转(0=否,1=是)', field: 'isJump', visible: true, align: 'center', valign: 'middle'},
-            {title: '跳转类型(1=内部跳转,2=外部跳转)', field: 'jumpType', visible: true, align: 'center', valign: 'middle'},
-            {title: '跳转连接', field: 'jumpUrl', visible: true, align: 'center', valign: 'middle'},
-            {title: '富文本', field: 'html', visible: true, align: 'center', valign: 'middle'},
-            {title: '排序', field: 'sort', visible: true, align: 'center', valign: 'middle'},
-            {title: '状态(1=正常,2=冻结,3=删除)', field: 'status', visible: true, align: 'center', valign: 'middle'},
-            {title: '添加时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
-            {title: '添加人员id', field: 'createUserId', visible: true, align: 'center', valign: 'middle'},
-            {title: '更新时间', field: 'updateTime', visible: true, align: 'center', valign: 'middle'},
-            {title: '更新人员id', field: 'updateUserId', visible: true, align: 'center', valign: 'middle'}
+            {title: '主键', field: 'id', visible: false, align: 'center', valign: 'middle'},
+        {title: '添加时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
+        {title: '广告图名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
+        {title: '广告类型', field: 'type', visible: true, align: 'center', valign: 'middle',
+            formatter: function (value, row) {
+                if (row.type === 1){
+                    return '<span>弹窗广告</span>'
+                }else if(row.type === 2){
+                    return '<span>底部广告</span>'
+                }
+            }
+        },
+        {title: '广告图图片', field: 'url', visible: true, align: 'center', valign: 'middle'},
+        {title: '端口(设备)', field: 'device', visible: true, align: 'center', valign: 'middle',
+                formatter: function (value, row) {
+                    if (row.device === 1){
+                        return '<span>小程序</span>'
+                    }else if(row.device === 2){
+                        return '<span>司机端</span>'
+                    }
+                }
+            },
+        {title: '是否跳转', field: 'isJump', visible: true, align: 'center', valign: 'middle',
+                formatter: function (value, row) {
+                    if (row.isJump === 0){
+                        return '<span>否</span>'
+                    }else if(row.isJump === 1){
+                        return '<span>是</span>'
+                    }
+                }
+            },
+        {title: '跳转类型', field: 'jumpType', visible: true, align: 'center', valign: 'middle',
+                formatter: function (value, row) {
+                    if (row.jumpType === 1){
+                        return '<span>内部跳转</span>'
+                    }else if(row.jumpType === 2){
+                        return '<span>外部跳转</span>'
+                    }
+                }
+            },
+        {title: '跳转内容', field: 'jumpUrl', visible: true, align: 'center', valign: 'middle'},
+        {title: '状态', field: 'onOffLine', visible: true, align: 'center', valign: 'middle',
+            formatter: function (value, row) {
+                if (row.onOffLine === 1){
+                    return '<span>已上线</span>'
+                }else if(row.onOffLine === 2){
+                    return '<span>已下线</span>'
+                }
+            }
+        },
+        {title: '富文本', field: 'html', visible: false, align: 'center', valign: 'middle'},
+        {title: '排序', field: 'sort', visible: false, align: 'center', valign: 'middle'},
+        {title: '状态(1=正常,2=冻结,3=删除)', field: 'status', visible: false, align: 'center', valign: 'middle'},
+            {title: '添加人员id', field: 'createUserId', visible: false, align: 'center', valign: 'middle'},
+            {title: '更新时间', field: 'updateTime', visible: false, align: 'center', valign: 'middle'},
+            {title: '更新人员id', field: 'updateUserId', visible: false, align: 'center', valign: 'middle'},
+        {title: '操作', visible: true, align: 'center', valign: 'middle',width:150,
+            formatter: function (value, row) {
+                if (row.onOffLine === 1){
+                    return '<a href="#" onclick="TCommercial.offLineState('+row.id+')" style="color:red">下线</a>' +'&nbsp;' +
+                        '<a href="#" onclick="TCommercial.delete('+row.id+','+row.onOffLine+')" style="color:red">删除</a>'
+                }else if(row.onOffLine === 2){
+                    return '<a href="#" onclick="TCommercial.onLineState('+row.id+')" style="color:blue">上线</a>' +'&nbsp;' +
+                        '<a href="#" onclick="TCommercial.delete('+row.id+','+row.onOffLine+')" style="color:red">删除</a>'
+                }
+            }
+        }
     ];
 };
 
@@ -53,7 +105,7 @@
     var index = layer.open({
         type: 2,
         title: '添加',
-        area: ['800px', '420px'], //宽高
+        area: ['100%', '100%'], //宽高
         fix: false, //不固定
         maxmin: true,
         content: Feng.ctxPath + '/tCommercial/tCommercial_add'
@@ -64,12 +116,12 @@
 /**
  * 打开查看详情
  */
-TCommercial.openTCommercialDetail = function () {
-    if (this.check()) {
+TCommercial.openTCommercialDetail = function (id) {
+    if(this.check()){
         var index = layer.open({
             type: 2,
             title: '详情',
-            area: ['800px', '420px'], //宽高
+            area: ['100%', '100%'], //宽高
             fix: false, //不固定
             maxmin: true,
             content: Feng.ctxPath + '/tCommercial/tCommercial_update/' + TCommercial.seItem.id
@@ -81,19 +133,61 @@
 /**
  * 删除
  */
-TCommercial.delete = function () {
-    if (this.check()) {
-        var ajax = new $ax(Feng.ctxPath + "/tCommercial/delete", function (data) {
-            Feng.success("删除成功!");
-            TCommercial.table.refresh();
-        }, function (data) {
-            Feng.error("删除失败!" + data.responseJSON.message + "!");
-        });
-        ajax.set("tCommercialId",this.seItem.id);
-        ajax.start();
+TCommercial.delete = function (id,onOffLine) {
+    if(1 == onOffLine){
+        Feng.error("已上线广告不可删除!");
+        return;
     }
+    var ajax = new $ax(Feng.ctxPath + "/tCommercial/delete", function (data) {
+        Feng.success("删除成功!");
+        TCommercial.table.refresh();
+    }, function (data) {
+        Feng.error("删除失败!" + data.responseJSON.message + "!");
+    });
+    ajax.set("tCommercialId",id);
+    ajax.start();
 };
 
+
+/**
+ * 上线
+ */
+TCommercial.onLineState = function (id) {
+    var ajax = new $ax(Feng.ctxPath + "/tCommercial/onLine", function (data) {
+        if(500 == data.code){
+            Feng.error(data.message)
+            return;
+        }else {
+            Feng.success("上线成功!");
+            TCommercial.table.refresh();
+        }
+    }, function (data) {
+        Feng.error("上线失败!" + data.responseJSON.message + "!");
+    });
+    ajax.set("tCommercialId",id);
+    ajax.start();
+};
+
+/**
+ * 下线
+ */
+TCommercial.offLineState = function (id) {
+    var ajax = new $ax(Feng.ctxPath + "/tCommercial/offLine", function (data) {
+        if(500 == data.code){
+            Feng.error(data.message)
+            return;
+        }else {
+            Feng.success("下线成功!");
+            TCommercial.table.refresh();
+        }
+    }, function (data) {
+        Feng.error("下线失败!" + data.responseJSON.message + "!");
+    });
+    ajax.set("tCommercialId",id);
+    ajax.start();
+};
+
+
 /**
  * 查询列表
  */

--
Gitblit v1.7.1