list.blade.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. @extends('layouts.base')
  2. @section('title', '画册管理')
  3. @section('content')
  4. <link rel="stylesheet" href="{{static_url('css/public-number.css')}}">
  5. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}"/>
  6. {{--图片预览引用--}}
  7. <link rel="stylesheet" href="//at.alicdn.com/t/font_432132_fyuwx7v2noa.css" />
  8. <link rel="stylesheet" href="{{static_url('css/viewer.min.css')}}">
  9. <script type="text/javascript" src="{{static_url('js/viewer.min.js')}}"></script>
  10. {{--图片预览引用--}}
  11. <style xmlns:v-bind="http://www.w3.org/1999/xhtml">
  12. .rightlist #app .rightlist-head{padding:15px 0;line-height:50px;}
  13. .rightlist #app{margin-left:30px;}
  14. .rightlist-head-con{float:left;padding-right:20px;font-size:16px;color:#888;}
  15. .el-form-item__label{padding-right:30px;}
  16. .mouse-active{cursor:pointer;border:1px dotted #409EFF;border-radius: 4px;}
  17. /* 滑块选择小白点 */
  18. .el-switch.is-checked .el-switch__core::after {left: 100%;margin-left: -17px;}
  19. .el-switch__core::after {content: "";position: absolute;top: 1px;left: 1px;border-radius: 100%;transition: all .3s;width: 16px;height: 16px;background-color: #fff;}
  20. .draw-picture{width:60px;height:66px;}
  21. .draw-goods{width:60px;height:60px;float:left;}
  22. .draw-goods-wrap{display:flex;align-items: center;}
  23. .el-icon-edit{font-size:16px;padding:0 15px;color:#409EFF;cursor: pointer;}
  24. .edit-i{display:none;}
  25. .el-table_1_column_1:hover .edit-i{font-weight:900;padding:0;margin:0;display:inline-block;}
  26. .el-form-item {
  27. margin-bottom: 0 !important;
  28. }
  29. </style>
  30. <link rel="stylesheet" href="//at.alicdn.com/t/font_913727_zrmdutznqpd.css">
  31. <div id="app" v-loading="all_loading" >
  32. <template>
  33. <el-container>
  34. <el-header height="auto">
  35. <div class="">
  36. <h4 class="card-title">画册管理--图片管理</h4>
  37. <div style="font-weight:600;padding-left:30px;">
  38. <div>画册名称:[[picture.picture_name]]</div>
  39. <div>创建时间:[[picture.created_at]]</div>
  40. <div>画册图片数量:[[picture.count]]</div>
  41. <el-button type="primary" icon="el-icon-plus" @click="openUpload('thumb_more','1','more')">添加图片</el-button>
  42. <el-button type="primary" icon="el-icon-plus" @click="batchSave()">保存设置</el-button>
  43. </div>
  44. </el-header>
  45. {{--表格start--}}
  46. <el-main>
  47. <template>
  48. <el-table :data="list">
  49. <el-table-column label="排序" align="center">
  50. <template slot-scope="scope">
  51. <el-input v-model="scope.row.ranking"></el-input>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="画册图片名称" align="center">
  55. <template slot-scope="scope">
  56. <el-input v-model="scope.row.picture_name"></el-input>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="画册图片" align="center">
  60. <template slot-scope="scope">
  61. <div id="tp_name_0">
  62. <image style="width: 70px; height: 70px" v-if="scope.row.change_image" :src="scope.row.change_image"></image>
  63. </div>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="图片商品" align="center">
  67. <template slot-scope="scope">
  68. <el-form ref="form" :model="form" v-loading="loading">
  69. <el-form-item prop="goods_id">
  70. <div @click="openGoods(scope)" v-if="!scope.row.has_one_goods.thumb">
  71. <i class="el-icon-plus" style="font-size:20px"></i>
  72. </div>
  73. <div style="text-align:center;" v-if="scope.row.has_one_goods" :id=`pic_show_${scope.$index}`>
  74. <div style="position: relative">
  75. <image style="width: 60px; height: 60px" :src="scope.row.has_one_goods.thumb" v-if="scope.row.has_one_goods.thumb" @click="openGoods(scope)"></image>
  76. <a href="#" title="删除" v-if="scope.row.has_one_goods&&scope.row.has_one_goods.thumb" style="position: absolute;top: -14px;"><i class="el-icon-close" @click="clearGoods(scope)"></i></a>
  77. </div>
  78. <div style="font-size: 13px;line-height: 17px;font-weight: 500;">[[scope.row.has_one_goods.title]]</div>
  79. </div>
  80. </el-form-item>
  81. </el-form>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="操作" align="center">
  85. <template slot-scope="scope">
  86. <i class="el-icon-edit" title="编辑" style="font-size:28px;color:#606266" @click="editActivity(scope)"></i>
  87. <i class="el-icon-delete" title="删除" style="font-size:28px;color:#606266;cursor: pointer;" @click="del(scope.row.id)"></i>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. </template>
  92. </el-main>
  93. <upload-multimedia-img :upload-show="uploadShow" :type="type" :name="chooseImgName" :sel-Num="selNum" @replace="changeProp" @sure="sureImg"></upload-multimedia-img>
  94. {{--表格end--}}
  95. <!--弹框选择-->
  96. <el-dialog :visible.sync="goods_show" width="60%" center title="选择商品">
  97. <div>
  98. <div style="display: flex">
  99. <el-input v-model="search_goods.title" placeholder="商品标题" style="width: 300px"></el-input>
  100. <el-button type="primary" @click="searchGoods(1)">搜索</el-button>
  101. </div>
  102. <el-table :data="goods_list" style="width: 100%;height:500px;overflow:auto" id="goods-list">
  103. <el-table-column label="商品ID" align="center" width="auto">
  104. <template slot-scope="scope">
  105. [[ scope.row.id ]]
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="商品" width="auto">
  109. <template slot-scope="scope">
  110. <div style="display:flex;align-items: center">
  111. <div style="margin-right:10px">
  112. <el-image :src="scope.row.thumb" style="width:50px;height:50px"></el-image>
  113. <div style="color:#333;font-weight:500">[[scope.row.title]]</div>
  114. </div>
  115. </div>
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="商品" width="auto">
  119. <template slot-scope="scope">
  120. <el-button type="primary" icon="el-icon-plus" @click="selectSure(scope)">选择</el-button>
  121. </template>
  122. </el-table-column>
  123. </el-table>
  124. <!-- 分页 -->
  125. <div v-show="goods_total>1">
  126. <el-row>
  127. <el-col align="right">
  128. <el-pagination
  129. layout="prev, pager, next,jumper"
  130. @current-change="searchGoods"
  131. :total="goods_total"
  132. :page-size="goods_per_page"
  133. :current-page="goods_current_page"
  134. background
  135. v-loading="loading">
  136. </el-pagination>
  137. </el-col>
  138. </el-row>
  139. </div>
  140. </div>
  141. <span slot="footer" class="dialog-footer">
  142. <el-button @click="cancelDialog">取 消</el-button>
  143. </span>
  144. </el-dialog>
  145. <el-footer>
  146. <el-pagination
  147. layout="prev, pager, next"
  148. @current-change="currentChange"
  149. :current-page.sync="current_page"
  150. :total="page_total"
  151. :page-size="page_size"
  152. background v-loading="loading">
  153. </el-pagination>
  154. </el-footer>
  155. </el-container>
  156. </template>
  157. </div>
  158. @include('public.admin.pop')
  159. @include('public.admin.program')
  160. @include('public.admin.uploadMultimediaImg')
  161. <script>
  162. var app = new Vue({
  163. el: '#app',
  164. delimiters: ['[[', ']]'],
  165. data() {
  166. let pageList = {!! $pageList ?: '{}'!!};
  167. let id = {!! $id ?: '{}'!!};
  168. let picture = {!! $picture ?: '{}'!!};
  169. return {
  170. id:id,
  171. picture:picture,
  172. form : {},
  173. change_ranking:'',
  174. loading : false,
  175. all_loading:false,
  176. searchParams: {
  177. 'id' : '',
  178. 'name' : '',
  179. 'create_time' : '',
  180. },
  181. list : pageList.data,
  182. current_page : pageList.current_page,
  183. page_total : pageList.total,
  184. page_size : pageList.per_page,
  185. uploadShow:false,
  186. type:'',
  187. selNum:'',
  188. chooseImgName:'',
  189. goods_show: false,
  190. search_goods:{},
  191. goods_list: [],
  192. select_id_list: [],
  193. select_goods_list: [],
  194. sure_select_list: [],
  195. goods_current_page:1,
  196. goods_total:1,
  197. goods_per_page:1,
  198. line_index:'',
  199. }
  200. },
  201. mounted () {
  202. this.$nextTick(() => {
  203. let tp_name_0 = new Viewer(document.getElementById('tp_name_0'), {
  204. url: 'src'
  205. });
  206. });
  207. },
  208. methods: {
  209. statusChange(index,row,id) {
  210. this.loading = true;
  211. this.$http.post('{!! yzWebFullUrl('plugin.picture-album.admin.controllers.activity-whell.change-status') !!}',{id:id,status:row.status}).then(function (response) {
  212. if (response.data.result){
  213. if(row.status){
  214. this.$message({message: '开启成功',type: 'success'});
  215. }
  216. else {
  217. this.$message({message: '关闭成功',type: 'success'});
  218. }
  219. } else {
  220. this.$message({message: response.data.msg,type: 'error'});
  221. if (this.list[index].status==1){
  222. this.list[index].status = 0;
  223. }
  224. else{
  225. this.list[index].status = 1;
  226. }
  227. }
  228. this.loading = false;
  229. },function (response) {
  230. this.$message({message: response.data.msg,type: 'error'});
  231. if (this.list[index].status==1){
  232. this.list[index].status = 0;
  233. } else{
  234. this.list[index].status = 1;
  235. }
  236. this.loading = false;
  237. });
  238. },
  239. del(id) {
  240. this.$confirm('是否删除', '提示', {
  241. confirmButtonText: '确定',
  242. cancelButtonText: '取消',
  243. type: 'warning'
  244. }).then(() => {
  245. this.$http.post('{!! yzWebFullUrl('plugin.picture-album.admin.controllers.activity-wheel.del') !!}',{id:id}).then(function (response) {
  246. if (response.data.result) {
  247. this.$message({
  248. type: 'success',
  249. message: '删除成功!'
  250. });
  251. this.currentChange(1);
  252. }
  253. });
  254. }).catch(() => {
  255. this.$message({
  256. type: 'info',
  257. message: '已取消删除'
  258. });
  259. });
  260. },
  261. addActivity(){
  262. window.location.href = "{!! yzWebUrl('plugin.picture-album.admin.controllers.activity-wheel.save-wheel' ,['id' => $id ]) !!}";
  263. },
  264. editActivity(scope){
  265. url = "{!! yzWebUrl('plugin.picture-album.admin.controllers.activity-wheel.add-wheel') !!}";
  266. url += "&pic_id="+scope.row.id+"&p_id="+scope.row.p_id;
  267. window.location.href = url;
  268. },
  269. copy(row,index) {
  270. that = this;
  271. let Url = that.$refs['copy'+index];
  272. Url.select(); // 选择对象
  273. document.execCommand("Copy",false);
  274. that.$message({message:"复制成功!",type:"success"});
  275. },
  276. // 编辑排序
  277. editRanking(index, type) {
  278. let that = this;
  279. that.change_ranking = '';
  280. that.change_ranking = that.list[index].ranking;
  281. },
  282. // 确认修改
  283. confirmChange(id, type) {
  284. let that = this;
  285. let value = '';
  286. if (type == 'ranking') {
  287. value = that.change_ranking;
  288. if (!(/^\d+$/.test(that.change_ranking))) {
  289. that.$message.error('请输入正确数字');
  290. return false;
  291. }
  292. }
  293. let json = {
  294. id: id,
  295. ranking:that.change_ranking
  296. };
  297. that.all_loading = true;
  298. that.$http.post("{!! yzWebFullUrl('plugin.picture-album.admin.controllers.activity-wheel.ranking') !!}", json).then(response => {
  299. if (response.data.result == 1) {
  300. that.$message.success('操作成功!');
  301. if (document.all) {
  302. document.getElementById('app').click();
  303. } else {// 其它浏览器
  304. var e = document.createEvent('MouseEvents')
  305. e.initEvent('click', true, true)
  306. document.getElementById('app').dispatchEvent(e)
  307. }
  308. that.all_loading = false;
  309. that.currentChange(1);
  310. } else {
  311. that.$message.error(response.data.msg);
  312. }
  313. that.all_loading = false;
  314. }), function (res) {
  315. console.log(res);
  316. that.all_loading = false;
  317. };
  318. },
  319. currentChange(val) {
  320. let that = this;
  321. this.loading = true;
  322. this.$http.post('{!! yzWebFullUrl('plugin.picture-album.admin.controllers.activity-wheel.search') !!}',{id:that.id,page:val}).then(function (response) {
  323. if (response.data.result){
  324. let datas = response.data.data;
  325. this.page_total = datas.total;
  326. this.list = datas.data;
  327. this.page_size = datas.per_page;
  328. this.current_page = datas.current_page;
  329. window.scrollTo({
  330. top: 0,
  331. behavior: "smooth"
  332. });
  333. }
  334. else {
  335. this.$message({message: response.data.msg,type: 'error'});
  336. }
  337. this.loading = false;
  338. },function (response) {
  339. this.loading = false;
  340. this.$message({message: response.data.msg,type: 'error'});
  341. }
  342. );
  343. },
  344. openUpload(str,type,sel) {
  345. this.chooseImgName = str;
  346. this.uploadShow = true;
  347. this.type = type;
  348. this.selNum = sel
  349. },
  350. changeProp(val) {
  351. if (val == true) {
  352. this.uploadShow = false;
  353. } else {
  354. this.uploadShow = true;
  355. }
  356. },
  357. sureImg(name,uploadShow,fileList) {
  358. if (fileList.length <= 0) {
  359. return;
  360. }
  361. let json = {
  362. id : this.id,
  363. list : fileList,
  364. };
  365. this.$http.post('{!! yzWebFullUrl('plugin.picture-album.admin.controllers.activity-wheel.savePic') !!}',json).then(function (response) {
  366. if (response.data.result){
  367. location.reload();
  368. } else {
  369. this.$message({message: response.data.msg,type: 'error'});
  370. }
  371. this.loading = false;
  372. },function (response) {
  373. this.loading = false;
  374. this.$message({message: response.data.msg,type: 'error'});
  375. }
  376. );
  377. },
  378. batchSave() {
  379. let json = {
  380. list : this.list,
  381. };
  382. this.$http.post('{!! yzWebFullUrl('plugin.picture-album.admin.controllers.activity-wheel.batchSave') !!}',json).then(function (response) {
  383. if (response.data.result){
  384. this.$message({message: response.data.msg,type: 'success'});
  385. location.reload();
  386. } else {
  387. this.$message({message: response.data.msg,type: 'error'});
  388. }
  389. this.loading = false;
  390. },function (response) {
  391. this.loading = false;
  392. this.$message({message: response.data.msg,type: 'error'});
  393. }
  394. );
  395. },
  396. openGoods(scope) {
  397. this.line_index = scope.$index;
  398. this.goods_show = true;
  399. },
  400. clearGoods(scope) {
  401. let id = 'pic_show_'+scope.$index;
  402. document.getElementById(id).style.display='none';
  403. this.list[scope.$index].goods_id = 0;
  404. this.list[scope.$index].has_one_goods.thumb = '';
  405. this.list[scope.$index].has_one_goods.title = ''
  406. },
  407. cancelDialog() {
  408. this.goods_show = false;
  409. },
  410. searchGoods(val) {
  411. let json = {
  412. kwd:this.search_goods.title,
  413. page:val
  414. };
  415. let loading = this.$loading({target:document.querySelector("#goods-list"),background: 'rgba(0, 0, 0, 0)'});
  416. this.$http.post("{!! yzWebUrl('plugin.picture-album.admin.controllers.activity-wheel.getGoods') !!}",json).then(response => {
  417. if (response.data.result) {
  418. let list = response.data.data.list;
  419. this.goods_list = list.data;
  420. this.goods_current_page = list.current_page;
  421. this.goods_per_page = list.per_page;
  422. this.goods_total = list.total;
  423. this.loading = false;
  424. }
  425. else {
  426. this.$message.error(response.data.msg)
  427. }
  428. loading.close();
  429. }, response => {
  430. console.log(response);
  431. loading.close();
  432. });
  433. },
  434. selectSure(scope) {
  435. console.log(scope)
  436. let id = 'pic_show_'+this.line_index;
  437. document.getElementById(id).style.display='block';
  438. this.list[this.line_index].goods_id = scope.row.id;
  439. this.list[this.line_index].has_one_goods.thumb = scope.row.thumb;
  440. this.list[this.line_index].has_one_goods.title = scope.row.title;
  441. this.goods_show = false;
  442. },
  443. },
  444. });
  445. </script>
  446. @endsection