index.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <style>
  2. .label{
  3. margin-right: 10px;
  4. }
  5. .table-body {
  6. padding: 20px;
  7. background-color: #fff;
  8. }
  9. .input-item {
  10. display: inline-block;
  11. width: 250px;
  12. margin: 0 0 20px;
  13. }
  14. .input-item .el-input__inner {
  15. border-right: 0;
  16. }
  17. .input-item .el-input__inner:hover {
  18. border: 1px solid #dcdfe6;
  19. border-right: 0;
  20. outline: 0;
  21. }
  22. .input-item .el-input__inner:focus {
  23. border: 1px solid #dcdfe6;
  24. border-right: 0;
  25. outline: 0;
  26. }
  27. .input-item .el-input-group__append {
  28. background-color: #fff;
  29. border-left: 0;
  30. width: 10%;
  31. padding: 0;
  32. }
  33. .input-item .el-input-group__append .el-button {
  34. padding: 0;
  35. }
  36. .input-item .el-input-group__append .el-button {
  37. margin: 0;
  38. }
  39. .table-body .el-button {
  40. padding: 0 !important;
  41. border: 0;
  42. margin: 0 5px;
  43. }
  44. .el-table th > .cell {
  45. color: #333;
  46. font-weight: bold;
  47. font-size: 14px;
  48. }
  49. .el-table__footer-wrapper, .el-table__header-wrapper {
  50. border-bottom: 1.4px solid #D6D6D6;
  51. }
  52. .el-button--primary2 {
  53. color: #FFF;
  54. background-color: #03C5FF;
  55. border-color: #03C5FF;
  56. }
  57. /*头像样式 start*/
  58. .default-avatar{
  59. width: 50px;
  60. height: 50px;
  61. border-radius: 50%;
  62. }
  63. .user_img{
  64. position: relative;
  65. margin-right: 8px;
  66. height: 50px;
  67. width: 50px;
  68. }
  69. .el-table_1_column_3 .cell { /*-2 表示在第二行*/
  70. display: flex;
  71. }
  72. /*头像样式 end*/
  73. </style>
  74. <div id="app" v-cloak>
  75. <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  76. <div slot="header">
  77. <div>
  78. <span>证书管理</span>
  79. </div>
  80. </template>
  81. </div>
  82. <div class="table-body">
  83. <el-button class="el-button--primary2" style="padding: 9px 15px!important; float: right;" type="primary"
  84. @click="handle('add')" size="small">添加证书
  85. </el-button>
  86. <div size="small" :inline="true" flex="dir:left cross:center" style="margin-bottom: 12px;">
  87. <div class="item-box" flex="dir:left cross:center" style="margin-left: 10px;">
  88. <div class="label">支付时间: </div>
  89. <el-date-picker
  90. size="small"
  91. v-model="search.create_time"
  92. type="datetimerange"
  93. value-format="yyyy-MM-dd HH:mm:ss"
  94. range-separator="至"
  95. start-placeholder="开始日期"
  96. end-placeholder="结束日期">
  97. </el-date-picker>
  98. </div>
  99. <div class="item-box" flex="dir:left cross:center" style="margin-right: 20px; margin-left: 20px;">
  100. <div class="label">证书名称: </div>
  101. <el-input size="small" style="width: 210px" v-model="search.name" placeholder="请输入证书名称"></el-input>
  102. </div>
  103. <div class="item-box" flex="dir:left cross:center">
  104. <el-button type="primary" style="padding: 9px 15px!important;" @click="searchs">搜索
  105. </el-button>
  106. <el-button type="danger" style="padding: 12px 34px !important;" size="small" @click="resetSearch" v-if="show_clear_search_btn">清除条件</el-button>
  107. </div>
  108. </div>
  109. <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
  110. <el-table-column prop="id" label="ID" min-width="80" align="center"></el-table-column>
  111. <el-table-column label="证书名称" align="center">
  112. <template slot-scope="scope">
  113. {{scope.row.name}}
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="下载次数" width="80" align="center">
  117. <template slot-scope="scope">
  118. {{scope.row.download_num}}
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="状态" align="center">
  122. <template slot-scope="scope">
  123. <el-switch active-value="1" inactive-value="0" @change="handle('enable',scope.row)"
  124. v-model="scope.row.status + ''">
  125. </el-switch>
  126. </template>
  127. </el-table-column>
  128. <el-table-column prop="scope" label="创建时间">
  129. <template slot-scope="scope">
  130. {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  131. </template>
  132. </el-table-column>
  133. <el-table-column
  134. label="操作"
  135. min-width="180"
  136. align="center">
  137. <template slot-scope="scope">
  138. <el-button circle size="mini" type="text" @click="handle('edit',scope.row)">
  139. 编辑
  140. </el-button>
  141. <el-button circle size="mini" type="text" @click="handle('delete',scope.row)">
  142. 删除
  143. </el-button>
  144. </template>
  145. </el-table-column>
  146. </el-table>
  147. <div style="text-align: right;margin: 20px 0;">
  148. <el-pagination v-if="pagination" :page-size="pagination.pageSize"
  149. style="display: inline-block;float: right;" background @current-change="pageChange"
  150. layout="prev, pager, next" :total="pagination.total_count">
  151. </el-pagination>
  152. </div>
  153. </div>
  154. </el-card>
  155. </div>
  156. <script>
  157. const app = new Vue({
  158. el: '#app',
  159. data() {
  160. return {
  161. list: [],
  162. listLoading: false,
  163. pagination:null,
  164. page: 1,
  165. pageCount: 0,
  166. search: {
  167. name:'',
  168. create_time:'',
  169. },
  170. };
  171. },
  172. computed: {
  173. show_clear_search_btn: function() {
  174. return !isEmpty(this.search.name)
  175. || !isEmpty(this.search.create_time)
  176. }
  177. },
  178. methods: {
  179. resetSearch(){
  180. this.search = {
  181. name:'',
  182. create_time:'',
  183. }
  184. },
  185. searchs() {
  186. this.page = 1;
  187. this.getList();
  188. },
  189. pageChange(currentPage) {
  190. let self = this;
  191. self.page = currentPage; //console.log(currentPage,999999);
  192. self.getList();
  193. },
  194. getList() {
  195. let self = this;
  196. self.listLoading = true;
  197. request({
  198. params: {
  199. r: 'certificate/default/index',
  200. page: self.page,
  201. name: this.search.name,
  202. create_time: this.search.create_time,
  203. },
  204. method: 'get',
  205. }).then(e => {
  206. self.listLoading = false;
  207. self.list = e.data.data.list;
  208. this.pagination = e.data.data.pagination;
  209. this.pagination.pageSize = e.data.data.page_size;
  210. this.pagination.total_count = e.data.data.count;
  211. }).catch(e => {
  212. console.log(e);
  213. });
  214. },
  215. handle(type,data = null){
  216. switch (type) {
  217. case 'delete':// 删除
  218. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.send({id: data.id,status:-1,type:'1'});})
  219. break;
  220. case 'enable':
  221. var status = 0;
  222. if(data.status=='0') status = 1;
  223. this.send({id: data.id,status: status,type:'1'});
  224. break;
  225. case 'edit':
  226. navigateTo({
  227. r: 'certificate/default/edit',
  228. id: data.id,
  229. });
  230. break;
  231. case 'add':
  232. navigateTo({
  233. r: 'certificate/default/edit',
  234. });
  235. break;
  236. }
  237. },
  238. send(data){
  239. let self = this;
  240. self.btnLoading = true;
  241. request({
  242. params: {
  243. r: 'certificate/default/edit',
  244. },
  245. method: 'post',
  246. data:data,
  247. }).then(e => {
  248. this.dialogAddgsVisible = false;
  249. this.btnLoading = false;
  250. if (e.data.code == 0) {
  251. self.$message.success(e.data.msg);
  252. self.getList();
  253. } else {
  254. self.$message.error(e.data.msg);
  255. }
  256. }).catch(e => {
  257. console.log(e);
  258. });
  259. },
  260. },
  261. mounted: function () {
  262. this.getList();
  263. }
  264. });
  265. </script>