step1.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>{$title|default=''} - {$powered|default=''}</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  7. <link href="https://www.layuicdn.com/layui-v2.5.6/css/layui.css" rel="stylesheet">
  8. <script src="https://www.layuicdn.com/layui/layui.js"></script>
  9. <script src="https://cdn.bootcss.com/vue/2.6.11/vue.min.js"></script>
  10. <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
  11. <script src="https://cdn.bootcss.com/axios/0.19.2/axios.min.js"></script>
  12. <style>
  13. body {
  14. background-color: #f3f3f4;
  15. margin-top: 10px;
  16. }
  17. .centered {
  18. text-align: center;
  19. }
  20. .centered button {
  21. width: 200px;
  22. height: 60px;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <div class="layui-fluid">
  28. <div class="layui-row layui-col-space15" id="app" v-cloak="">
  29. <div class="layui-card">
  30. <div class="centered">
  31. <div class="layui-progress">
  32. <div class="layui-progress-bar layui-bg-blue" lay-percent="100%"></div>
  33. </div>
  34. </div>
  35. <div class="layui-card-header">升级系统</div>
  36. <div class="layui-card-body">
  37. <div class="layui-row">
  38. <p style="font-size: 18px;">版本更迭: <span style="color: red">{$version_now} - {$version_new}</span></p>
  39. <div class="layui-form-item" style="margin-top: 10px">
  40. <label class="layui-form-label" style="font-size: 18px;padding-left: 0;">表前缀</label>
  41. <div class="layui-input-block">
  42. <input type="text" style="width: 10%" v-model="prefix" name="title" lay-verify="title"
  43. autocomplete="off" placeholder="请输入表前缀" class="layui-input">
  44. </div>
  45. </div>
  46. </div>
  47. <div class="centered">
  48. <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" v-if="isUpgrade && executeIng">
  49. 正在升级中
  50. </button>
  51. <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" v-if="isUpgrade && !executeIng"
  52. @click="startUpgrade">立即升级
  53. </button>
  54. <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" v-else-if="isUpgrade == false">无需升级</button>
  55. </div>
  56. </div>
  57. <div class="layui-card-body">
  58. <div class="layui-form">
  59. <table class="layui-table">
  60. <thead>
  61. <tr>
  62. <th>表名</th>
  63. <th>执行状态</th>
  64. <th width="40%">错误原因</th>
  65. <th>执行时间</th>
  66. <th width="12%">操作</th>
  67. </tr>
  68. </thead>
  69. <tbody>
  70. <tr v-for="(item,index) in upgradeData">
  71. <td>{{item.table}}</td>
  72. <td>{{item.status ? '执行成功':'执行失败'}}</td>
  73. <td>{{item.error}}</td>
  74. <td>{{item.add_time}}</td>
  75. <td>无操作</td>
  76. </tr>
  77. </tbody>
  78. </table>
  79. </div>
  80. <div class="layui-form">
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. <script type="text/javascript" charset="utf-8">
  87. var isUpgrade = <?=$isUpgrade ? 'true' : 'false'?>;
  88. new Vue({
  89. el: '#app',
  90. data: {
  91. sleep: 0,
  92. prefix: 'eb_',
  93. upgradeData: [],
  94. isUpgrade: isUpgrade,
  95. executeIng: false,
  96. page: 1,
  97. },
  98. methods: {
  99. startUpgrade: function () {
  100. var that = this;
  101. if (!that.prefix) {
  102. return that.showMsg('请填写表前缀');
  103. }
  104. this.requestGet('upgrade', {
  105. sleep: this.sleep,
  106. prefix: this.prefix,
  107. page: this.page
  108. }).then(function (res) {
  109. if (res.data.sleep !== -1) {
  110. if (res.data.page) {
  111. that.page = res.data.page;
  112. }
  113. that.sleep = res.data.sleep;
  114. that.upgradeData.push(res.data);
  115. that.executeIng = true;
  116. setTimeout(function () {
  117. that.startUpgrade();
  118. }, 100);
  119. } else {
  120. that.isUpgrade = false;
  121. that.nextAction = true;
  122. that.executeIng = false;
  123. return that.showMsg('执行完毕');
  124. }
  125. }).catch(function (res) {
  126. return that.showMsg(res.msg);
  127. });
  128. },
  129. requestGet: function (url, data) {
  130. var params = Object.keys(data).map(function (key) {
  131. return key + '=' + data[key];
  132. }).join('&');
  133. return new Promise(function (resolve, reject) {
  134. axios.get(url + (params ? '?' + params : '')).then(function (res) {
  135. if (res.status == 200) {
  136. resolve(res.data)
  137. } else {
  138. reject(res.data);
  139. }
  140. }).catch(function (err) {
  141. reject({msg: err})
  142. });
  143. })
  144. },
  145. showMsg: function (msg, success) {
  146. layui.use(['layer'], function () {
  147. layui.layer.msg(msg, success);
  148. });
  149. },
  150. }
  151. })
  152. </script>
  153. </body>
  154. </html>