| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- layui.use(['table', 'jquery', 'madmin', 'mhttp', 'layer', 'form', 'common'], function () {
- let table = layui.table;
- let $ = layui.jquery;
- let admin = layui.madmin;
- let layer = layui.layer;
- let form = layui.form;
- let common = layui.common;
- let mhttp = layui.mhttp;
- admin.getConfig();
- getStorageServersConfig();
- //搜索条件
- let name = GetQueryString('name') ?? null;
- let app_uid = GetQueryString('app_uid') ?? null;
- $('.name').val(name);
- $('.app_uid').val(app_uid);
- let cols = [
- [
- {
- title: 'UID',
- field: 'uid',
- align: 'center',
- },
- {
- title: 'ICON',
- field: 'icon_url',
- align: 'center',
- toolbar: '#app-icon'
- },
- {
- title: '应用名称',
- field: 'name',
- align: 'center',
- },
- {
- title: '隐藏状态',
- field: 'status',
- align: 'center',
- toolbar: '#app-status'
- },
- {
- title: '排序',
- field: 'squad',
- align: 'center'
- },
- {
- title: '版本(A|I)',
- align: 'center',
- toolbar: '#app-version-android-ios'
- },
- {
- title: '打包开关(A|I)',
- align: 'center',
- toolbar: '#app-enable-android-ios'
- },
- {
- title: '地址(安卓|苹果)',
- align: 'center',
- toolbar: '#app-dow-url-android-ios'
- },
- {
- title: '更新时间',
- field: 'updated_at',
- align: 'center'
- },
- {
- title: '操作',
- align: 'center',
- fixed: 'right',
- toolbar: '#app-bar'
- }
- ]
- ];
- let search = httpRequestPostData({
- name: name,
- uid: app_uid,
- });
- table.render({
- elem: '#app-table',
- method: 'POST',
- request: {
- pageName: 'page',
- limitName: 'page_size'
- },
- async: false,
- headers: {
- "AUTH-TOKEN": localStorage.getItem('XSRF-TOKEN') ?? ''
- },
- contentType: 'application/json',
- where: search,
- url: getMyApiUrl('/app/lists'),
- limit: 20,
- limits: [20, 30, 40, 50, 80, 100],
- parseData: function (res) {
- return httpRequestPagesParseData(res);
- },
- response: {
- "statusCode": 200,
- },
- done: function (data, page, total) {
- var intCode = parseInt(data.code);
- if (intCode === 403) {
- cbRespnseRedirectLogin(data);
- } else if (intCode === 401) {
- // 仅仅是过期了,这里可以有其他逻辑补偿.
- // 暂时跳到登陆页面
- cbRespnse401(data);
- }
- onloadRender();
- },
- error: function (obj, message) {
- cbRespnseReloadPage(obj, message);
- },
- page: true,
- cols: cols,
- skin: 'line',
- toolbar: '#app-toolbar',
- defaultToolbar: [{
- title: '刷新',
- layEvent: 'refresh',
- icon: 'layui-icon-refresh',
- }, 'filter', 'print', 'exports']
- });
- table.on('toolbar(app-table)', function (obj) {
- if (obj.event === 'add') {
- window.add();
- } else if (obj.event === 'refresh') {
- window.refresh();
- }
- });
- window.add = function () {
- layer.open({
- id: 'app_create',
- type: 2,
- title: '添加',
- shade: 0.1,
- offset: '20px',
- area: ['410px', '600px'],
- maxWidth: 500,
- maxHeight: 600,
- scrollbar: true,
- content: 'app_create.html',
- });
- }
- // 表单内
- table.on('tool(app-table)', function (obj) {
- if (obj.event === 'remove') {
- window.remove(obj);
- } else if (obj.event === 'edit') {
- window.edit(obj);
- }
- });
- window.edit = function (obj) {
- layer.open({
- id: 'app-edit',
- type: 2,
- title: '修改',
- shade: 0.1,
- offset: '20px',
- area: ['410px', '600px'],
- maxWidth: 500,
- maxHeight: 600,
- scrollbar: true,
- content: 'app_edit.html?app_uid=' + obj.data.uid,
- });
- }
- // 状态修改
- form.on('switch(app-status-edit)', function (obj) {
- let status = layer.load();
- let postData = {
- uid: this.value
- };
- let ret = mhttp.ajax({
- url: '/app/edit/status',
- data: postData,
- });
- ret.then((data) => {
- layer.close(status);
- if (data.code === 200) {
- layer.msg(data.message, {icon: 1, time: 1000});
- } else {
- layer.msg(data.message, {icon: 2, time: 1000});
- }
- });
- });
- form.on('switch(android-enable-edit)', function (obj) {
- let android = layer.load();
- let postData = {
- uid: this.value
- };
- let ret = mhttp.ajax({
- url: '/app/edit/android/enable',
- data: postData,
- });
- ret.then((data) => {
- layer.close(android);
- if (data.code === 200) {
- layer.msg(data.message, {icon: 1, time: 1000});
- } else {
- layer.msg(data.message, {icon: 2, time: 1000});
- }
- });
- });
- form.on('switch(ios-enable-edit)', function (obj) {
- let ios = layer.load();
- let postData = {
- uid: this.value
- };
- let ret = mhttp.ajax({
- url: '/app/edit/ios/enable',
- data: postData,
- });
- ret.then((data) => {
- layer.close(ios);
- if (data.code === 200) {
- layer.msg(data.message, {icon: 1, time: 1000});
- } else {
- layer.msg(data.message, {icon: 2, time: 1000});
- }
- });
- });
- window.refresh = function (param) {
- table.reload('app-table');
- }
- })
|