index.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <style>
  2. .table-body {
  3. padding: 20px;
  4. background-color: #fff;
  5. }
  6. .input-item {
  7. display: inline-block;
  8. width: 250px;
  9. margin: 0 0 20px;
  10. }
  11. .input-item .el-input__inner {
  12. border-right: 0;
  13. }
  14. .input-item .el-input__inner:hover {
  15. border: 1px solid #dcdfe6;
  16. border-right: 0;
  17. outline: 0;
  18. }
  19. .input-item .el-input__inner:focus {
  20. border: 1px solid #dcdfe6;
  21. border-right: 0;
  22. outline: 0;
  23. }
  24. .input-item .el-input-group__append {
  25. background-color: #fff;
  26. border-left: 0;
  27. width: 10%;
  28. padding: 0;
  29. }
  30. .input-item .el-input-group__append .el-button {
  31. padding: 0;
  32. }
  33. .input-item .el-input-group__append .el-button {
  34. margin: 0;
  35. }
  36. .table-body .el-button {
  37. padding: 0 !important;
  38. border: 0;
  39. margin: 0 5px;
  40. }
  41. .form-body {
  42. background-color: #fff;
  43. margin-bottom: 20px;
  44. }
  45. .el-tabs__header {
  46. background-color: #fff;
  47. }
  48. .el-tabs__item {
  49. width: 100px;
  50. text-align: center;
  51. }
  52. .el-table th>.cell {
  53. color: #333;
  54. font-weight: bold;
  55. font-size: 14px;
  56. }
  57. .el-table__footer-wrapper,
  58. .el-table__header-wrapper {
  59. border-bottom: 1.4px solid #D6D6D6;
  60. }
  61. </style>
  62. <div id="app" v-cloak>
  63. <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  64. <div slot="header">
  65. <div>
  66. <span>课程分类</span>
  67. <div style="float: right;">
  68. <el-button type="primary" size="small" style="padding: 9px 15px !important;" @click="storage(0)">添加分类
  69. </el-button>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="table-body">
  74. <div style="margin-bottom: 15px;" flex>
  75. <div flex>
  76. <div flex="cross:center" class="input-search">
  77. <!-- <div style="flex-shrink: 0;">分类名称:</div> -->
  78. <el-input @keyup.enter.native="search" size="small" placeholder="请输入分类名称" v-model="searchData.keyword" @clear="search"></el-input>
  79. </div>
  80. <!-- <div flex="cross:center" class="input-search">
  81. <div class="input-item-name">状态:</div>
  82. <div>
  83. <el-select v-model="searchData.status" placeholder="请选择" size="small">
  84. <el-option label="全部" :value="0"></el-option>
  85. <el-option v-for="(item,index) in status_text" :key="index" :label="item" :value="index">{{item}}
  86. </el-option>
  87. </el-select>
  88. </div>
  89. </div> -->
  90. </div>
  91. <div>
  92. <el-button type="primary" size="small" @click="search" style="padding: 9px 15px !important;">搜索</el-button>
  93. <el-button type="warning" @click="clereSearch" v-if="searchData.keyword || searchData.start_time || searchData.end_time" style="padding: 9px 15px !important;">清除搜索条件</el-button>
  94. </div>
  95. </div>
  96. <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
  97. <!-- <el-table-column label="ID" prop="id" width="80">
  98. <template slot-scope="scope">
  99. <div size="small">{{scope.row.id}}</div>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="商城ID" prop="mall_id">
  103. <template slot-scope="scope">
  104. <div size="small">{{scope.row.mall_id}}</div>
  105. </template>
  106. </el-table-column> -->
  107. <el-table-column label="分类ID" prop="id" min-width="80" align="center">
  108. <template slot-scope="scope">
  109. <div size="small">{{scope.row.id}}</div>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="分类名称" prop="cname" min-width="80" align="center">
  113. <template slot-scope="scope">
  114. <div size="small">{{scope.row.cname}}</div>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="分类 LOGO " prop="logo" min-width="80" align="center">
  118. <template slot-scope="scope">
  119. <div size="small">
  120. <!-- <img :src=scope.row.logo alt=""> -->
  121. <com-image width='50px' height='50px' :src=scope.row.logo></com-image>
  122. </div>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="排序" prop="sort" min-width="80" align="center">
  126. <template slot-scope="scope">
  127. <div size="small">{{scope.row.sort}}</div>
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="是否导航" width="120" align="center">
  131. <template slot-scope="scope">
  132. <el-switch :active-value="1" :inactive-value="0" @change="switchNavicat(scope.row)" v-model="scope.row.is_navicat">
  133. </el-switch>
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="创建时间" prop="created_at" min-width="100" align="center">
  137. <template slot-scope="scope">
  138. <div size="small">{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="操作" min-width="100" align="center">
  142. <template slot-scope="scope">
  143. <el-button type="text" size="mini" @click="storage(scope.row.id)" style="width:56px;height: 24px;">编辑</el-button>
  144. <el-button circle type="text" size="mini" @click="cateDelete(scope.row.id, scope.$index)">删除 </el-button>
  145. </template>
  146. </el-table-column>
  147. </el-table>
  148. <div style="text-align: right;margin: 20px 0;">
  149. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  150. </div>
  151. </div>
  152. </el-card>
  153. </div>
  154. <script>
  155. const app = new Vue({
  156. el: '#app',
  157. data() {
  158. return {
  159. list: [],
  160. searchData: {
  161. keyword: '',
  162. },
  163. listLoading: false,
  164. page: 1,
  165. pageCount: 0,
  166. };
  167. },
  168. methods: {
  169. search() {
  170. this.page = 1;
  171. this.getList();
  172. },
  173. clereSearch() {
  174. this.searchData.keyword = '';
  175. this.getList();
  176. },
  177. pagination(currentPage) {
  178. let self = this;
  179. self.page = currentPage;
  180. self.getList();
  181. },
  182. getList() {
  183. let self = this;
  184. self.listLoading = true;
  185. request({
  186. params: {
  187. r: 'course/default/categorys',
  188. page: self.page,
  189. ...this.searchData
  190. },
  191. method: 'get',
  192. }).then(e => {
  193. self.listLoading = false;
  194. self.list = e.data.data.list;
  195. self.pageCount = e.data.data.page_count;
  196. }).catch(e => {
  197. console.log(e);
  198. });
  199. },
  200. // 编辑/新建
  201. storage(id) {
  202. navigateTo({
  203. r: 'course/category/edit',
  204. id: id,
  205. });
  206. },
  207. cateDelete(id, index) {
  208. let self = this;
  209. self.$confirm('是否删除课程分类?', '提示', {
  210. confirmButtonText: '确定',
  211. cancelButtonText: '取消',
  212. type: 'warning'
  213. }).then(() => {
  214. self.listLoading = true;
  215. // console.log(id,'1111')
  216. request({
  217. params: {
  218. r: 'course/category/delete',
  219. },
  220. method: 'post',
  221. data: {
  222. id: id,
  223. }
  224. }).then(e => {
  225. self.listLoading = false;
  226. if (e.data.code === 0) {
  227. self.$message.success(e.data.msg);
  228. self.list.splice(index, 1);
  229. } else {
  230. self.$message.error(e.data.msg);
  231. }
  232. }).catch(e => {
  233. console.log(e);
  234. });
  235. }).catch(() => {
  236. self.$message.info('已取消删除')
  237. });
  238. },
  239. switchNavicat(row_data) {
  240. // console.log(is_navicat, row_data.is_navicat);
  241. this.listLoading = true;
  242. request({
  243. method: 'post',
  244. params: {
  245. r: 'course/category/switch-navicat',
  246. },
  247. data: {
  248. id: row_data.id,
  249. is_navicat: row_data.is_navicat,
  250. },
  251. }).then(e => {
  252. this.listLoading = false;
  253. if (e.data.code === 0) {
  254. this.$message.success(e.data.msg);
  255. } else {
  256. this.$message.error(e.data.msg);
  257. }
  258. }).catch(e => {});
  259. }
  260. },
  261. mounted: function() {
  262. this.getList();
  263. }
  264. });
  265. </script>