index.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. @extends('layouts.base')
  2. @section('content')
  3. @section('title', trans('商品列表'))
  4. <style>
  5. [v-cloak]{
  6. display:none;
  7. }
  8. </style>
  9. <div class="w1200 ">
  10. <link rel="stylesheet" type="text/css" href="{{static_url('css/font-awesome.min.css')}}">
  11. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/goods.css')}}"/>
  12. <div id="goods-index" class=" rightlist ">
  13. <div class="right-titpos">
  14. <ul class="add-snav">
  15. <li class="active"><a href="{{yzWebFullUrl('plugin.jd-supply.admin.goods-import.index')}}">商品列表</a></li>
  16. <li class="active"><a href="{{yzWebFullUrl('plugin.jd-supply.admin.label-import.index')}}">标签导入</a></li>
  17. </ul>
  18. </div>
  19. <div class="right-addbox">
  20. <div id="app" >
  21. <div class="panel panel-default">
  22. <div class="panel-body table-responsive">
  23. <div v-cloak v-loading="loading">
  24. <el-table :data="list" style="width: 100%" max-height="600" v-loading="all_loading" tooltip-effect="dark">
  25. <el-table-column prop="id" label="ID" width="80" align="center"></el-table-column>
  26. <el-table-column prop="name" label="标签名称" max-width="100" align="center"></el-table-column>
  27. <el-table-column prop="options_count" label="标签个数" max-width="100" align="center"></el-table-column>
  28. <el-table-column label="操作" width="300" align="center">
  29. <template slot-scope="scope">
  30. <el-button @click.native="openImport(scope.row.id)">一键导入</el-button>
  31. <el-col v-if="scope.row.import_status == 0">未导入</el-col>
  32. <el-col v-else-if="scope.row.import_status == 1">导入中,总进度约[[scope.row.import_process]]%</el-col>
  33. <el-col v-else>已导入</el-col>
  34. </template>
  35. </el-table-column>
  36. </el-table>
  37. <div class="vue-page" v-show="total>1">
  38. <el-row>
  39. <el-col align="right">
  40. <el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total"
  41. :page-size="per_size" :current-page="current_page" background
  42. v-loading="loading"></el-pagination>
  43. </el-col>
  44. </el-row>
  45. </div>
  46. <!-- 表格end -->
  47. </div>
  48. </div>
  49. <div class='panel-footer'>
  50. <input name="submit" type="button" @click="confirm()" :disabled="is_import_disabled" class="btn btn-success" value="导入商品">
  51. </div>
  52. </div>
  53. <el-dialog :visible.sync="import_show" width="750px" title="选择导入分类">
  54. <div style="height:100px;overflow:auto" id="cancel-send">
  55. <el-form label-width="15%">
  56. <el-select v-model="category_form.id_v1" placeholder="请选择一级分类" clearable @change="changeV1()">
  57. <el-option v-for="item in category_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  58. </el-select>
  59. <el-select v-model="category_form.id_v2" placeholder="请选择二级分类" clearable @change="changeV2()">
  60. <el-option v-for="item in category_list_v2" :key="item.id" :label="item.name" :value="item.id"></el-option>
  61. </el-select>
  62. <el-select v-model="category_form.id_v3" placeholder="请选择三级分类" clearable v-if="category_level == 3">
  63. <el-option v-for="item in category_list_v3" :key="item.id" :label="item.name" :value="item.id"></el-option>
  64. </el-select>
  65. </el-form>
  66. <el-col v-if="create_category == 1" style="color: red">已开启自动匹配分类,如不选择导入分类则自动匹配或创建分类!(阿里商品不支持)</el-col>
  67. </div>
  68. <span slot="footer" class="dialog-footer">
  69. <el-button @click="import_show = false">取 消</el-button>
  70. <el-button type="primary" @click="confirm">确认导入</el-button>
  71. </span>
  72. </el-dialog>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <script>
  78. var app = new Vue({
  79. el:"#app",
  80. delimiters: ['[[', ']]'],
  81. directives: {
  82. 'el-select-loadmore': {
  83. bind(el, binding) {
  84. // 获取element-ui定义好的scroll盒子
  85. const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap');
  86. SELECTWRAP_DOM.addEventListener('scroll', function () {
  87. /**
  88. * scrollHeight 获取元素内容高度(只读)
  89. * scrollTop 获取或者设置元素的偏移值,常用于, 计算滚动条的位置, 当一个元素的容器没有产生垂直方向的滚动条, 那它的scrollTop的值默认为0.
  90. * clientHeight 读取元素的可见高度(只读)
  91. * 如果元素滚动到底, 下面等式返回true, 没有则返回false:
  92. * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
  93. */
  94. const condition = this.scrollHeight - this.scrollTop <= this.clientHeight;
  95. if (condition) {
  96. binding.value();
  97. }
  98. });
  99. }
  100. }
  101. },
  102. data() {
  103. let category_level = {!! $category_level !!};
  104. let create_category = {!! $create_category !!};
  105. return{
  106. loading:false,
  107. all_loading:false,
  108. page_number: 1, //每页显示条数
  109. import_show:false,
  110. list: [],
  111. category_page: {
  112. pageIndex: 1,
  113. pageSize: 20,
  114. },
  115. category_form:{
  116. id_v1:"",
  117. id_v2:"",
  118. id_v3:"",
  119. fid_v1:"",
  120. fid_v2:"",
  121. },
  122. is_import_disabled : false,
  123. category_level:category_level,//分类等级
  124. create_category:create_category,//分类等级
  125. category_list:[],
  126. category_list_v2:[],
  127. category_list_v3:[],
  128. selectionGoodsIds: [],
  129. //分页
  130. total: 0,
  131. per_size: 0,
  132. current_page: 0,
  133. }
  134. },
  135. created() {
  136. this.getGoodsList('{}');
  137. this.getCategoryList('{}');
  138. },
  139. methods: {
  140. openImport(id) {
  141. console.log(id);
  142. this.label_id = id;
  143. this.import_show = true;
  144. },
  145. // 获得标签列表
  146. getGoodsList(json) {
  147. var that = this;
  148. that.all_loading = true;
  149. that.$http.post('{!! yzWebFullUrl('plugin.jd-supply.admin.label-import.get-label-list') !!}',json).then(response => {
  150. console.log(response);
  151. if(response.data.result==1){
  152. console.log(response);
  153. that.list = response.data.data.data;
  154. that.current_page = response.data.data.current_page;
  155. that.per_size = 10;
  156. that.total = response.data.data.total;
  157. that.all_loading = false;
  158. } else{
  159. that.$message.error(response.data.msg);
  160. that.all_loading = false;
  161. }
  162. }),function(res){
  163. console.log(res);
  164. that.all_loading = false;
  165. };
  166. },
  167. getCategoryList(json) {
  168. var that = this;
  169. that.all_loading = true;
  170. that.$http.post('{!! yzWebFullUrl('plugin.jd-supply.admin.label-import.get-category-list') !!}',json).then(response => {
  171. console.log(response);
  172. if(response.data.result==1){
  173. console.log(response);
  174. that.category_list = response.data.data.cate;
  175. that.all_loading = false;
  176. } else{
  177. that.$message.error(response.data.msg);
  178. that.all_loading = false;
  179. }
  180. }),function(res){
  181. console.log(res);
  182. that.all_loading = false;
  183. };
  184. },
  185. // 一级分类改变
  186. changeV1(){
  187. this.category_form.id_v2 = "";
  188. this.category_form.id_v3 = "";
  189. this.category_list_v2 = [];
  190. this.category_list_v3 = [];
  191. this.category_list.find(item => {
  192. if(item.id == this.category_form.id_v1) {
  193. this.category_list_v2 = item.childrens;
  194. }
  195. });
  196. },
  197. // 二级分类改变
  198. changeV2(){
  199. this.category_form.id_v3 = "";
  200. this.category_list_v3 = [];
  201. if(this.category_level==3) {
  202. this.category_list_v2.find(item => {
  203. if(item.id == this.category_form.id_v2) {
  204. this.category_list_v3 = item.childrens;
  205. }
  206. })
  207. }
  208. },
  209. search(page) {
  210. this.getGoodsList({page:page});
  211. },
  212. //导入商品
  213. confirm()
  214. {
  215. var that = this;
  216. var arr = {
  217. 'parentid': [],
  218. 'childid':[],
  219. 'thirdid':[],
  220. };
  221. arr.parentid.push(this.category_form.id_v1);
  222. arr.childid.push(this.category_form.id_v2);
  223. if(this.category_form.id_v3){
  224. arr.thirdid.push(this.category_form.id_v3);
  225. }
  226. let json = {category:arr,id:this.label_id};
  227. that.is_import_disabled = true;
  228. that.all_loading = true;
  229. that.$http.post('{!! yzWebFullUrl('plugin.jd-supply.admin.label-import.select') !!}',json).then(response => {
  230. console.log(response);
  231. that.is_import_disabled = true;
  232. that.all_loading = false;
  233. if(response.data.result==1) {
  234. that.$message.success(response.data.msg);
  235. this.import_show = false;
  236. this.search(this.current_page);
  237. } else{
  238. that.$message.error(response.data.msg);
  239. that.is_import_disabled = false;
  240. }
  241. }),function(res){
  242. console.log(res);
  243. that.is_import_disabled = true;
  244. that.all_loading = false;
  245. };
  246. }
  247. },
  248. })
  249. </script>
  250. @endsection('content')