index.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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: 11:37
  9. */
  10. use common\helpers\ComponentHelper;
  11. ComponentHelper::loadComponentView('com-dialog-select');
  12. ?>
  13. <div id="app" v-cloak>
  14. <el-card shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  15. <div slot="header">
  16. <span>商品列表</span>
  17. </div>
  18. <div class="table-body">
  19. <el-form size="small" :inline="true" flex="dir:left cross:center">
  20. <div class="flex-bew">
  21. <div flex>
  22. <el-button size="small" type="primary" style="padding: 9px 15px !important;height:32px" @click="delGoods">
  23. 批量删除
  24. </el-button>
  25. <com-dialog-select ref="goodsSelect" v-model="cForm.goods_id" :multiple="true" url="blind-box/default/goods-list"
  26. @selected="selectGoodsWarehouse">
  27. <el-button size="medium" type="primary" style="padding: 9px 15px !important;">选择商品</el-button>
  28. </com-dialog-select>
  29. </div>
  30. <div flex>
  31. <div class="item-box" flex="dir:left cross:center">
  32. <div class="label">关键字:</div>
  33. <el-input size="small" style="width: 200px" v-model="search.name" placeholder="请输入关键字"></el-input>
  34. </div>
  35. <div class="item-box" flex="dir:left cross:center">
  36. <div class="label">状态:</div>
  37. <el-select v-model="search.status" placeholder="请选择" clearable>
  38. <el-option
  39. label="上架"
  40. value="1">
  41. </el-option>
  42. <el-option
  43. label="下架"
  44. value="0">
  45. </el-option>
  46. </el-select>
  47. </div>
  48. <div class="item-box" flex="dir:left cross:center">
  49. <div class="label">选择时间:</div>
  50. <el-date-picker style="margin-top: 1px;" size="small" @change="changeTime" v-model="time" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期" clearable end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"></el-date-picker>
  51. </div>
  52. <div class="item-box" flex="dir:left cross:center">
  53. <el-button size="small" type="primary" style="padding: 9px 15px !important;" @click="searchs">
  54. <i class="el-icon-search"></i>
  55. 搜索
  56. </el-button>
  57. </div>
  58. </div>
  59. </div>
  60. </el-form>
  61. <el-tabs v-model="activeName" @tab-click="handleClick">
  62. <el-table :data="list" stripe v-loading="loading" size="small" style="margin-bottom: 15px;"
  63. @selection-change="handleSelectionChange">
  64. <el-table-column type="selection"></el-table-column>
  65. <el-table-column prop="id" label="ID"></el-table-column>
  66. <el-table-column label="商品名称" prop="goods_name" align="center" width="250" class-name="goods-name"></el-table-column>
  67. <el-table-column label="分类" prop="cate_name" min-width="160" align="center"></el-table-column>
  68. <el-table-column label="贡献值" prop="contribution" min-width="160" align="center"></el-table-column>
  69. <el-table-column label="利润值" prop="profit" min-width="160" align="center"></el-table-column>
  70. <el-table-column label="状态" prop="status" align="center">
  71. <template slot-scope="scope">
  72. <div>{{scope.row.status == 1 ? '上架':'下架'}}</div>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="类型" prop="goods_type" align="center">
  76. <template slot-scope="scope">
  77. <div>{{scope.row.goods_type == 1 ? '实物商品':(scope.row.goods_type == 2 ? '虚拟商品' : '预约商品')}}</div>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="添加时间" prop="created_at" min-width="160" align="center">
  81. <template slot-scope="scope">
  82. <div>{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
  83. </template>
  84. </el-table-column>
  85. <el-table-column
  86. fixed="right"
  87. label="操作"
  88. align="center"
  89. width="300">
  90. <template slot-scope="scope">
  91. <el-button type="text" @click="editGoods('edit',scope.row)">编辑</el-button>
  92. <el-button type="text" @click="handleSelectionChange(scope.row,'row')">删除</el-button>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. </el-tabs>
  97. <!-- 分页器 -->
  98. <div flex="box:last cross:center">
  99. <div></div>
  100. <div>
  101. <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
  102. style="display: inline-block;float: right;" background @current-change="pageChange"
  103. layout="prev, pager, next" :total="pagination.totalCount">
  104. </el-pagination>
  105. </div>
  106. </div>
  107. </div>
  108. </el-card>
  109. <el-dialog title="商品设置" :visible.sync="editGoodsDialog" width="500px">
  110. <div>
  111. <el-form :model="setting" size="small" label-width="150px">
  112. <el-form-item label="贡献值">
  113. <el-radio-group v-model="setting.contribution_percent">
  114. <el-radio :label="1">
  115. 百分比
  116. </el-radio>
  117. <el-radio :label="0">
  118. 固定值
  119. </el-radio>
  120. </el-radio-group>
  121. <el-input maxlength="20" v-model="setting.contribution" placeholder="请输入"></el-input>
  122. </el-form-item>
  123. <el-form-item label="利润值">
  124. <el-radio-group v-model="setting.profit_percent">
  125. <el-radio :label="1">
  126. 百分比
  127. </el-radio>
  128. <el-radio :label="0">
  129. 固定值
  130. </el-radio>
  131. </el-radio-group>
  132. <el-input maxlength="20" v-model="setting.profit" placeholder="请输入"></el-input>
  133. </el-form-item>
  134. <el-form-item label="分类">
  135. <el-select v-model="setting.cate_id" placeholder="请选择" clearable>
  136. <el-option
  137. v-for="(item,index) in cateList"
  138. :key="item.id"
  139. :label="item.name"
  140. :value="item.id">
  141. </el-option>
  142. </el-select>
  143. </el-form-item>
  144. </el-form>
  145. </div>
  146. <span slot="footer" class="dialog-footer">
  147. <el-button @click="editGoodsDialog = false" type="default" size="small" >取消</el-button>
  148. <el-button type="primary" :loading="loading" style="margin-bottom: 10px;" size="small" @click="editGoodsComfirm">确定</el-button>
  149. </span>
  150. </el-dialog>
  151. </div>
  152. <script>
  153. const app = new Vue({
  154. el: '#app',
  155. data: {
  156. addType:'',
  157. cForm:{
  158. goods_id:[]
  159. },
  160. cateList:[],//分类列表
  161. page:1,
  162. limit:50,
  163. time:[], //本地存时间,请求时不发送
  164. search: {
  165. name : '',
  166. status:null,
  167. start:'',
  168. end:''
  169. },
  170. time:'',
  171. loading: false,
  172. activeName: '-1',
  173. list: [], //列表数据
  174. pagination: null,
  175. choose_list:[],
  176. cateForm:{
  177. id:0,
  178. name:'',
  179. status:0
  180. },
  181. setting:{
  182. id:0,
  183. contribution:0,
  184. contribution_percent:0,
  185. profit_percent:0,
  186. profit:0,
  187. cate_id:null
  188. },
  189. editGoodsDialog:false
  190. },
  191. mounted() {
  192. // 获取列表首页数据
  193. this.loadData(this.page,this.search); //获取列表数据
  194. this.getCateList()
  195. },
  196. methods: {
  197. selectGoodsWarehouse(val){
  198. //添加商品
  199. console.log('goods-id',val)
  200. //弹出选择框
  201. this.editGoodsDialog = true
  202. this.cForm = val
  203. // val.forEach(item =>{
  204. // console.log(5555555555,item.id)
  205. // this.cForm.goods_id.push(item.id)
  206. // })
  207. console.log('this.cForm',this.cForm.goods_id)
  208. this.addType = 'add'
  209. },
  210. chooseAll(){
  211. this.$refs.goodsSelect.chooseAll()
  212. },
  213. clearGoods(){
  214. this.$refs.goodsSelect.clear()
  215. },
  216. changeTime(e){
  217. if(e == null){
  218. this.search.start = ''
  219. this.search.end = ''
  220. }else{
  221. this.search.start = e[0]
  222. this.search.end = e[1]
  223. }
  224. console.log('选择时间',e)
  225. },
  226. getCateList(){
  227. this.loading = true;
  228. request({
  229. method: 'get',
  230. params: {
  231. r: 'blind-box/cate/index',
  232. page: this.page,
  233. limit:this.limit,
  234. status:1
  235. },
  236. }).then(e => {
  237. this.loading = false;
  238. if (e.data.code === 0) {
  239. this.cateList = e.data.data.list;
  240. } else {
  241. this.$message.error(e.data.msg);
  242. }
  243. }).catch(e => {
  244. });
  245. },
  246. loadData(page,others) {
  247. this.loading = true;
  248. console.log(666,this.search);
  249. request({
  250. method: 'get',
  251. params: {
  252. r: 'blind-box/goods/index',
  253. page: page,
  254. limit:this.limit,
  255. ...others, //其他搜索字段
  256. },
  257. }).then(e => {
  258. this.loading = false;
  259. if (e.data.code === 0) {
  260. this.list = e.data.data.list;
  261. console.log('this.list',this.list)
  262. this.pagination = e.data.data.pagination;
  263. } else {
  264. this.$message.error(e.data.msg);
  265. }
  266. }).catch(e => {
  267. });
  268. },
  269. pageChange(page) {
  270. this.page = page;
  271. this.loadData(this.page,this.search);
  272. },
  273. handleClick(tab, event) {
  274. this.page = 1;
  275. this.search.status = this.activeName;
  276. this.loadData(this.page,this.search)
  277. },
  278. handleSelectionChange(val,type) {
  279. console.log('val',val,type)
  280. let self = this;
  281. if(type == 'row'){
  282. self.choose_list.push(val.id)
  283. self.delGoods()
  284. }else{
  285. self.choose_list = [];
  286. val.forEach(function (item) {
  287. self.choose_list.push(item.id);
  288. })
  289. }
  290. },
  291. searchs() {
  292. this.page = 1;
  293. this.loadData(this.page,this.search);
  294. },
  295. editGoods(type,row){
  296. this.setting.contribution = row.contribution
  297. this.setting.contribution_percent = row.contribution_percent
  298. this.setting.profit_percent = row.profit_percent
  299. this.setting.profit = row.profit
  300. if(row.cate_id == 0){
  301. row.cate_id = null
  302. }
  303. this.setting.cate_id = row.cate_id
  304. this.setting.id = row.id
  305. this.editGoodsDialog = true
  306. },
  307. addGoods(){
  308. console.log('添加商品的id',this.cForm.goods_id)
  309. let goods_id = []
  310. this.cForm.forEach((item)=>{
  311. goods_id.push(item.id)
  312. })
  313. this.loading = true
  314. request({
  315. method: 'post',
  316. params: {
  317. r: 'blind-box/goods/add',
  318. },
  319. data: {
  320. goods_id:goods_id,
  321. ...this.setting
  322. }
  323. }).then(e => {
  324. this.loading = false;
  325. if (e.data.code === 0) {
  326. this.$message.success(e.data.msg);
  327. this.page = 1;
  328. this.loadData();
  329. this.editGoodsDialog = false
  330. } else {
  331. this.$message.error(e.data.msg);
  332. }
  333. }).catch(e => {
  334. });
  335. },
  336. editGoodsComfirm(row){
  337. console.log('addType',this.addType)
  338. if(this.addType == 'add'){
  339. this.addGoods()
  340. }else{
  341. this.loading = true
  342. request({
  343. method: 'post',
  344. params: {
  345. r: 'blind-box/goods/edit',
  346. },
  347. data: {
  348. id:row.id,
  349. ...this.setting
  350. }
  351. }).then(e => {
  352. this.loading = false;
  353. if (e.data.code === 0) {
  354. this.loading = false
  355. this.$message.success(e.data.msg);
  356. this.page = 1;
  357. this.loadData();
  358. this.editGoodsDialog = false
  359. } else {
  360. this.$message.error(e.data.msg);
  361. }
  362. }).catch(e => {
  363. });
  364. }
  365. },
  366. delGoods(){ //批量删除
  367. console.log(this.choose_list)
  368. if(this.choose_list.length == 0){
  369. this.$message.error('请选择商品')
  370. }else{
  371. this.$confirm('是否确定删除商品?', '提示', {
  372. confirmButtonText: '确定',
  373. cancelButtonText: '取消',
  374. type: 'warning'
  375. }).then(() => {
  376. this.loading = true;
  377. request({
  378. params: {
  379. r: 'blind-box/goods/del',
  380. },
  381. method: 'post',
  382. data: {
  383. id: this.choose_list,
  384. }
  385. }).then(e => {
  386. let res = e.data;
  387. this.loading = false;
  388. if (res.code === 0) {
  389. this.$message.success(res.msg);
  390. this.loadData();
  391. } else {
  392. this.$message.error(res.msg);
  393. }
  394. }).catch(e => {});
  395. }).catch(() => {
  396. this.$message({
  397. type: 'info',
  398. message: '系统错误'
  399. });
  400. });
  401. }
  402. }
  403. }
  404. });
  405. </script>
  406. <style>
  407. .el-tabs__header {
  408. font-size: 16px;
  409. }
  410. .table-body {
  411. padding: 20px;
  412. background-color: #fff;
  413. }
  414. .table-body .el-button {
  415. padding: 0 !important;
  416. border: 0;
  417. margin: 0 5px;
  418. }
  419. .input-item {
  420. width: 250px;
  421. margin: 0 0 20px;
  422. display: inline-block;
  423. }
  424. .input-item .el-input__inner {
  425. border-right: 0;
  426. }
  427. .input-item .el-input__inner:hover {
  428. border: 1px solid #dcdfe6;
  429. border-right: 0;
  430. outline: 0;
  431. }
  432. .input-item .el-input__inner:focus {
  433. border: 1px solid #dcdfe6;
  434. border-right: 0;
  435. outline: 0;
  436. }
  437. .input-item .el-input-group__append {
  438. background-color: #fff;
  439. border-left: 0;
  440. width: 10%;
  441. padding: 0;
  442. }
  443. .input-item .el-input-group__append .el-button {
  444. padding: 0;
  445. }
  446. .input-item .el-input-group__append .el-button {
  447. margin: 0;
  448. }
  449. .batch {
  450. margin: 0 0 20px;
  451. display: inline-block;
  452. }
  453. .batch .el-button {
  454. padding: 9px 15px !important;
  455. }
  456. .item-box{
  457. margin-right: 20px;
  458. }
  459. .item-box .label{
  460. margin-right: 8px;
  461. }
  462. .form-nickname{
  463. width: 180px;
  464. white-space:nowrap;
  465. overflow:hidden;
  466. text-overflow:ellipsis;
  467. }
  468. .index-video-url{
  469. width: 300px;
  470. }
  471. .index-video-url video{
  472. width: 100%;
  473. }
  474. .index-related-info{
  475. width: 500px;
  476. }
  477. .video-top{
  478. width: 100%;
  479. display: flex;
  480. align-items: flex-start;
  481. box-sizing: border-box;
  482. padding: 20px;
  483. /* opacity: .5; */
  484. background-color: #FFFFFF;
  485. }
  486. .video-top .top-right{
  487. line-height: 26px;
  488. }
  489. .video-top .top-right .top-title{
  490. font-size: 18px;
  491. white-space:nowrap;
  492. overflow:hidden;
  493. text-overflow:ellipsis;
  494. width: 360px;
  495. }
  496. .video-top .top-right .wrapper{
  497. display: flex;
  498. /* align-items: flex-start; */
  499. }
  500. .video-top .top-right .wrapper .to-copy{
  501. /* color: #03C5FF; */
  502. margin-left: 20px;
  503. }
  504. .video-top .top-right .detail-price{
  505. color: #BC0100;
  506. font-size: 18px;
  507. font-family: Microsoft YaHei;
  508. font-weight: bold;
  509. }
  510. /* .atooltip {
  511. background: #FFFFFF !important;
  512. border: none !important;
  513. } */
  514. .el-table th>.cell{
  515. color: #333;
  516. font-weight: bold;
  517. font-size: 14px;
  518. }
  519. .el-table__footer-wrapper, .el-table__header-wrapper{
  520. border-bottom: 1.4px solid #D6D6D6;
  521. }
  522. .award-money{
  523. color: #BC0100;
  524. }
  525. .flex-bew{
  526. display:flex;
  527. justify-content: space-between;
  528. width:100%;
  529. }
  530. .goods-name .cell{
  531. width: 250px;
  532. word-break: break-all;
  533. text-overflow: ellipsis;
  534. display: -webkit-box;
  535. -webkit-box-orient: vertical;
  536. -webkit-line-clamp: 2; /* 这里是超出几行省略 */
  537. overflow: hidden;
  538. }
  539. </style>