index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <?php
  2. /**
  3. * @link:http://www.goodmall.com/
  4. * @copyright: Copyright (c) 2022
  5. * 名片
  6. * Author: zcx
  7. * Date: 2022-09-14
  8. * Time: 15:48
  9. */
  10. ?>
  11. <div id="app" v-cloak>
  12. <el-card shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  13. <div slot="header">
  14. <span>分类管理</span>
  15. </div>
  16. <div class="table-body">
  17. <el-form size="small" :inline="true" flex="dir:left cross:center">
  18. <div class="flex-bew">
  19. <div>
  20. <el-button size="small" type="primary" style="padding: 9px 15px !important;" @click="delCate">
  21. <i class="el-icon-delete"></i>
  22. 批量删除
  23. </el-button>
  24. <el-button size="small" type="primary" style="padding: 9px 15px !important;" @click="CateDialog = true">
  25. <i class="el-icon-circle-plus-outline"></i>
  26. 添加分类
  27. </el-button>
  28. </div>
  29. <div flex>
  30. <div class="item-box" flex="dir:left cross:center">
  31. <div class="label">关键字:</div>
  32. <el-input size="small" style="width: 200px" v-model="search.name" placeholder="请输入关键字"></el-input>
  33. </div>
  34. <div class="item-box" flex="dir:left cross:center">
  35. <el-button size="small" type="primary" style="padding: 9px 15px !important;" @click="searchs">
  36. <i class="el-icon-search"></i>
  37. 搜索
  38. </el-button>
  39. </div>
  40. </div>
  41. </div>
  42. </el-form>
  43. <el-tabs v-model="activeName" @tab-click="handleClick">
  44. <el-table :data="list" stripe v-loading="loading" size="small" style="margin-bottom: 15px;"
  45. @selection-change="handleSelectionChange">
  46. <el-table-column type="selection"></el-table-column>
  47. <el-table-column prop="id" label="序号"></el-table-column>
  48. <el-table-column label="分类名称" prop="name" align="center" ></el-table-column>
  49. <el-table-column label="分类绑定商品数量" prop="goods_num" min-width="160" align="center"></el-table-column>
  50. <el-table-column label="状态" prop="status" align="center">
  51. <template slot-scope="scope">
  52. <div>{{scope.row.status == 1 ? '已启用':'未启用'}}</div>
  53. </template>
  54. </el-table-column>
  55. <el-table-column
  56. fixed="right"
  57. label="操作"
  58. align="center"
  59. width="300">
  60. <template slot-scope="scope">
  61. <el-button type="text" @click="editCate('edit',scope.row)">编辑</el-button>
  62. <el-button type="text" @click="handleSelectionChange(scope.row,'row')">删除</el-button>
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. </el-tabs>
  67. <!-- 分页器 -->
  68. <div flex="box:last cross:center">
  69. <div></div>
  70. <div>
  71. <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
  72. style="display: inline-block;float: right;" background @current-change="pageChange"
  73. layout="prev, pager, next" :total="pagination.totalCount">
  74. </el-pagination>
  75. </div>
  76. </div>
  77. </div>
  78. </el-card>
  79. <el-dialog title="分类管理" :visible.sync="CateDialog" width="500px">
  80. <div>
  81. <el-form :model="cateForm" size="small" label-width="150px">
  82. <el-form-item label="分类名称">
  83. <el-input
  84. size="small"
  85. v-model="cateForm.name"
  86. placeholder="请输入"
  87. >
  88. </el-input>
  89. </el-form-item>
  90. <el-form-item label="状态">
  91. <el-radio-group v-model="cateForm.status">
  92. <el-radio :label="0">
  93. 关闭
  94. </el-radio>
  95. <el-radio :label="1">
  96. 开启
  97. </el-radio>
  98. </el-radio-group>
  99. </el-form-item>
  100. </el-form>
  101. </div>
  102. <span slot="footer" class="dialog-footer">
  103. <el-button @click="CateDialog = false" type="default" size="small">取消</el-button>
  104. <el-button type="primary" :loading="loading" style="margin-bottom: 10px;" size="small" @click="addCate('add')">确定</el-button>
  105. </span>
  106. </el-dialog>
  107. </div>
  108. <script>
  109. const app = new Vue({
  110. el: '#app',
  111. data: {
  112. page:1,
  113. limit:20,
  114. time:[], //本地存时间,请求时不发送
  115. search: {
  116. name : '',
  117. },
  118. loading: false,
  119. activeName: '-1',
  120. list: [], //列表数据
  121. pagination: null,
  122. choose_list:[],
  123. cateForm:{
  124. id:0,
  125. name:'',
  126. status:0
  127. },
  128. CateDialog:false
  129. },
  130. mounted() {
  131. // 获取列表首页数据
  132. this.loadData(this.page,this.search); //获取列表数据
  133. },
  134. methods: {
  135. loadData(page,others) {
  136. this.loading = true;
  137. console.log(this.search);
  138. request({
  139. method: 'get',
  140. params: {
  141. r: 'blind-box/cate/index',
  142. page: page,
  143. limit:this.limit,
  144. ...others, //其他搜索字段
  145. },
  146. }).then(e => {
  147. this.loading = false;
  148. if (e.data.code === 0) {
  149. this.list = e.data.data.list;
  150. console.log('this.list',this.list)
  151. this.pagination = e.data.data.pagination;
  152. } else {
  153. this.$message.error(e.data.msg);
  154. }
  155. }).catch(e => {
  156. });
  157. },
  158. pageChange(page) {
  159. this.page = page;
  160. this.loadData(this.page,this.search);
  161. },
  162. handleClick(tab, event) {
  163. this.page = 1;
  164. this.search.status = this.activeName;
  165. this.loadData(this.page,this.search)
  166. },
  167. handleSelectionChange(val,type) {
  168. console.log('val',val,type)
  169. let self = this;
  170. if(type == 'row'){
  171. self.choose_list.push(val.id)
  172. self.delCate()
  173. }else{
  174. self.choose_list = [];
  175. val.forEach(function (item) {
  176. self.choose_list.push(item.id);
  177. })
  178. }
  179. },
  180. searchs() {
  181. this.page = 1;
  182. this.loadData(this.page,this.search);
  183. },
  184. editCate(type,row){
  185. this.cateForm.id = row.id
  186. this.cateForm.name = row.name
  187. this.cateForm.status = row.status
  188. this.CateDialog = true
  189. },
  190. addCate(type){
  191. if(this.cateForm.name == ''){
  192. this.$message.error('请输入分类名称');
  193. return false;
  194. }
  195. request({
  196. method: 'post',
  197. params: {
  198. r: 'blind-box/cate/edit',
  199. },
  200. data: {
  201. ...this.cateForm
  202. }
  203. }).then(e => {
  204. this.loading = false;
  205. if (e.data.code === 0) {
  206. this.$message.success(e.data.msg);
  207. this.page = 1;
  208. this.loadData();
  209. this.CateDialog = false
  210. } else {
  211. this.$message.error(e.data.msg);
  212. }
  213. }).catch(e => {
  214. });
  215. },
  216. delCate(){ //批量删除
  217. console.log(this.choose_list)
  218. if(this.choose_list.length == 0){
  219. this.$message.error('请选择分类')
  220. }else{
  221. this.$confirm('是否确定删除分类?', '提示', {
  222. confirmButtonText: '确定',
  223. cancelButtonText: '取消',
  224. type: 'warning'
  225. }).then(() => {
  226. this.loading = true;
  227. request({
  228. params: {
  229. r: 'blind-box/cate/del',
  230. },
  231. method: 'post',
  232. data: {
  233. id: this.choose_list,
  234. }
  235. }).then(e => {
  236. let res = e.data;
  237. this.loading = false;
  238. if (res.code === 0) {
  239. this.$message.success(res.msg);
  240. this.loadData();
  241. } else {
  242. this.$message.error(res.msg);
  243. }
  244. }).catch(e => {});
  245. }).catch(() => {
  246. this.$message({
  247. type: 'info',
  248. message: '系统错误'
  249. });
  250. });
  251. }
  252. }
  253. }
  254. });
  255. </script>
  256. <style>
  257. .el-tabs__header {
  258. font-size: 16px;
  259. }
  260. .table-body {
  261. padding: 20px;
  262. background-color: #fff;
  263. }
  264. .table-body .el-button {
  265. padding: 0 !important;
  266. border: 0;
  267. margin: 0 5px;
  268. }
  269. .input-item {
  270. width: 250px;
  271. margin: 0 0 20px;
  272. display: inline-block;
  273. }
  274. .input-item .el-input__inner {
  275. border-right: 0;
  276. }
  277. .input-item .el-input__inner:hover {
  278. border: 1px solid #dcdfe6;
  279. border-right: 0;
  280. outline: 0;
  281. }
  282. .input-item .el-input__inner:focus {
  283. border: 1px solid #dcdfe6;
  284. border-right: 0;
  285. outline: 0;
  286. }
  287. .input-item .el-input-group__append {
  288. background-color: #fff;
  289. border-left: 0;
  290. width: 10%;
  291. padding: 0;
  292. }
  293. .input-item .el-input-group__append .el-button {
  294. padding: 0;
  295. }
  296. .input-item .el-input-group__append .el-button {
  297. margin: 0;
  298. }
  299. .batch {
  300. margin: 0 0 20px;
  301. display: inline-block;
  302. }
  303. .batch .el-button {
  304. padding: 9px 15px !important;
  305. }
  306. .item-box{
  307. margin-right: 20px;
  308. }
  309. .item-box .label{
  310. margin-right: 8px;
  311. }
  312. .form-nickname{
  313. width: 180px;
  314. white-space:nowrap;
  315. overflow:hidden;
  316. text-overflow:ellipsis;
  317. }
  318. .index-video-url{
  319. width: 300px;
  320. }
  321. .index-video-url video{
  322. width: 100%;
  323. }
  324. .index-related-info{
  325. width: 500px;
  326. }
  327. .video-top{
  328. width: 100%;
  329. display: flex;
  330. align-items: flex-start;
  331. box-sizing: border-box;
  332. padding: 20px;
  333. /* opacity: .5; */
  334. background-color: #FFFFFF;
  335. }
  336. .video-top .top-right{
  337. line-height: 26px;
  338. }
  339. .video-top .top-right .top-title{
  340. font-size: 18px;
  341. white-space:nowrap;
  342. overflow:hidden;
  343. text-overflow:ellipsis;
  344. width: 360px;
  345. }
  346. .video-top .top-right .wrapper{
  347. display: flex;
  348. /* align-items: flex-start; */
  349. }
  350. .video-top .top-right .wrapper .to-copy{
  351. /* color: #03C5FF; */
  352. margin-left: 20px;
  353. }
  354. .video-top .top-right .detail-price{
  355. color: #BC0100;
  356. font-size: 18px;
  357. font-family: Microsoft YaHei;
  358. font-weight: bold;
  359. }
  360. /* .atooltip {
  361. background: #FFFFFF !important;
  362. border: none !important;
  363. } */
  364. .el-table th>.cell{
  365. color: #333;
  366. font-weight: bold;
  367. font-size: 14px;
  368. }
  369. .el-table__footer-wrapper, .el-table__header-wrapper{
  370. border-bottom: 1.4px solid #D6D6D6;
  371. }
  372. .award-money{
  373. color: #BC0100;
  374. }
  375. .flex-bew{
  376. display:flex;
  377. justify-content: space-between;
  378. width:100%;
  379. }
  380. </style>