index.blade.php 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. @extends('layouts.base')
  2. @section('title', "商品列表")
  3. @section('content')
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods.css')}}"/>
  5. <div id="qrcode" ref="qrcode" style="display:none;"></div>
  6. <div class="rightlist">
  7. <div id="app" v-cloak v-loading="all_loading">
  8. <template>
  9. <div class="second-list">
  10. <div class="third-list">
  11. <div class="form-list">
  12. <el-form :inline="true" :model="search_form" ref="search_form" style="margin-left:10px;">
  13. <el-row>
  14. <el-form-item label="" prop="">
  15. <el-select v-model="search_form.status" placeholder="请选择商品状态" clearable>
  16. <el-option v-for="item in status_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="" prop="">
  20. <el-select v-model="search_form.sell_stock" placeholder="请选择售中库存" clearable>
  21. <el-option v-for="item in sell_stock_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-select v-model="search_form.id_v1" placeholder="请选择一级分类" clearable @change="changeV1()">
  26. <el-option v-for="item in category_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-select v-model="search_form.id_v2" placeholder="请选择二级分类" clearable @change="changeV2()">
  31. <el-option v-for="item in category_list_v2" :key="item.id" :label="item.name" :value="item.id"></el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item>
  35. <el-select v-model="search_form.id_v3" placeholder="请选择三级分类" clearable v-if="catlevel==3">
  36. <el-option v-for="item in category_list_v3" :key="item.id" :label="item.name" :value="item.id"></el-option>
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="" prop="">
  40. <el-select v-model="search_form.brand_id" placeholder="请选择品牌" clearable remote filterable :remote-method="getBrandData">
  41. <el-option v-for="item in brands_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item label="" prop="keyword">
  45. <el-input v-model="search_form.keyword" placeholder="请输入商品ID或关键字"></el-input>
  46. </el-form-item>
  47. <el-form-item label="" prop="filtering">
  48. <el-input v-model="search_form.filtering_name" placeholder="请输入商品标签关键字"></el-input>
  49. </el-form-item>
  50. <el-form-item label="价格区间" prop="">
  51. <el-input v-model="search_form.min_price" placeholder="最低价" style="width:150px;"></el-input>
  52. <el-input v-model="search_form.max_price" placeholder="最高价" style="width:150px;"></el-input>
  53. </el-form-item>
  54. <el-form-item label="利润率" prop="">
  55. <el-input v-model="search_form.min_ratio" placeholder="最低" style="width:150px;"></el-input>
  56. <el-input v-model="search_form.max_ratio" placeholder="最高" style="width:150px;"></el-input>
  57. </el-form-item>
  58. <el-form-item label="" prop="">
  59. <el-select v-model="search_form.page_size" placeholder="每页条数" clearable>
  60. <el-option v-for="item in page_size" :key="item.id" :label="item.name" :value="item.id"></el-option>
  61. </el-select>
  62. </el-form-item>
  63. <el-form-item label="商品类型" prop="leader_name">
  64. <el-checkbox v-model.number="search_form.is_new" :true-label="1" :false-label="0">新品</el-checkbox>
  65. <el-checkbox v-model.number="search_form.is_hot" :true-label="1" :false-label="0">热卖</el-checkbox>
  66. <el-checkbox v-model.number="search_form.is_recommand" :true-label="1" :false-label="0">推荐</el-checkbox>
  67. <el-checkbox v-model.number="search_form.is_discount" :true-label="1" :false-label="0">促销</el-checkbox>
  68. </el-form-item>
  69. <a href="#">
  70. <el-button type="primary" icon="el-icon-search" @click="search(1)">搜索</el-button>
  71. </a>
  72. </el-col>
  73. </el-row>
  74. </el-form>
  75. </div>
  76. <div class="table-list">
  77. <div style="margin-left:10px;">
  78. <el-checkbox v-model.number="is_all_choose" :true-label="1" :false-label="0" @change="allChoose">[[is_all_choose==1?'全不选':'全选']]</el-checkbox>
  79. <el-button size="small" @click="batchPutAway(1)">批量上架</el-button>
  80. <el-button size="small" @click="batchPutAway(0)">批量下架</el-button>
  81. <el-button size="small" @click="batchDestroy">批量删除</el-button>
  82. <el-button size="small" @click="batchUpdate">批量更新</el-button>
  83. <el-button size="small" @click="openCategory">批量修改分类</el-button>
  84. <el-button size="small" @click="UpdateJob">一键更新</el-button>
  85. </div>
  86. <div>
  87. @section('search')
  88. <template>
  89. <!-- 表格start -->
  90. <el-table :data="goods_list" style="width: 100%" :class="table_loading==true?'loading-height':''" v-loading="table_loading">
  91. <el-table-column prop="id" label="选择" width="60" align="center">
  92. <template slot-scope="scope">
  93. <el-checkbox v-model.number="scope.row.is_choose" :true-label="1" :false-label="0" @change="oneChange(scope.row)"></el-checkbox>
  94. </template>
  95. </el-table-column>
  96. <el-table-column prop="id" label="ID" width="70" align="center"></el-table-column>
  97. </el-table-column>
  98. <el-table-column prop="mid_id" label="中台ID" width="90" align="center">
  99. <template slot-scope="scope">
  100. [[scope.row.jd_goods_id]]
  101. </template>
  102. </el-table-column> <el-table-column prop="member_name" label="排序" max-width="70" align="center">
  103. <template slot-scope="scope">
  104. <el-popover class="item" placement="top" effect="light">
  105. <div style="text-align:center;">
  106. <el-input v-model="change_sort" size="small" style="width:100px;"></el-input>
  107. <el-button size="small" @click="confirmChangeSort(scope.row.id)">确定</el-button>
  108. </div>
  109. <a slot="reference" >
  110. <i class="el-icon-edit edit-i" title="点击编辑排序" @click="editTitle(scope.$index,'sort')"></i>
  111. </a>
  112. </el-popover>
  113. [[scope.row.display_order]]
  114. </template>
  115. </el-table-column>
  116. <el-table-column prop="total" label="商品" width="60" align="center">
  117. <template slot-scope="scope">
  118. <img :src="scope.row.thumb" style="width:50px;height:50px;">
  119. </template>
  120. </el-table-column>
  121. <el-table-column prop="down_time" label="" min-width="180" align="left" class="edit-cell">
  122. <template slot-scope="scope">
  123. <el-popover class="item" placement="top" effect="light">
  124. <div style="text-align:center;">
  125. <div style="text-align:left;margin-bottom:10px;font-weight:900">修改商品标题</div>
  126. <el-input v-model="change_title" style="width:400px" size="small"></el-input>
  127. <el-button size="small" @click="confirmChange(scope.row.id,'title')">确定</el-button>
  128. </div>
  129. <a slot="reference">
  130. <i class="el-icon-edit edit-i" title="点击编辑" @click="editTitle(scope.$index,'title')"></i>
  131. </a>
  132. </el-popover>
  133. [[scope.row.title]]
  134. </template>
  135. </el-table-column>
  136. <el-table-column prop="member_num" label="价格" max-width="80" align="center">
  137. <template slot-scope="scope">
  138. <el-popover class="item" placement="top" effect="light" :disabled="scope.row.has_option==1">
  139. <div style="text-align:center;">
  140. <el-input v-model="change_price" size="small" style="width:100px;"></el-input>
  141. <el-button size="small" @click="confirmChange(scope.row.id,'price')">确定</el-button>
  142. </div>
  143. <a slot="reference" >
  144. <i class="el-icon-edit edit-i" :title="scope.row.has_option==1?'多规格不支持快速修改':'点击编辑'" @click="editTitle(scope.$index,'price')"></i>
  145. </a>
  146. </el-popover>
  147. ¥[[scope.row.price]]
  148. </template>
  149. </el-table-column>
  150. <el-table-column prop="member_num" label="成本价" width="80" align="center">
  151. <template slot-scope="scope">
  152. ¥[[scope.row.cost_price]]
  153. </template>
  154. </el-table-column>
  155. <el-table-column prop="member_num" label="利润率" width="80" align="center">
  156. <template slot-scope="scope">
  157. [[((scope.row.price - scope.row.cost_price)* 100 /scope.row.cost_price).toFixed(2)]]%
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="库存" align="center" max-width="80">
  161. <template slot-scope="scope">
  162. <el-popover class="item" placement="top" effect="light" :disabled="scope.row.has_option==1">
  163. <div style="text-align:center;">
  164. <el-input v-model="change_stock" size="small" style="width:100px;"></el-input>
  165. <el-button size="small" @click="confirmChange(scope.row.id,'stock')">确定</el-button>
  166. </div>
  167. <a slot="reference" >
  168. <i class="el-icon-edit edit-i" :title="scope.row.has_option==1?'多规格不支持快速修改':'点击编辑'" @click="editTitle(scope.$index,'stock')"></i>
  169. </a>
  170. </el-popover>
  171. [[scope.row.stock]]
  172. </template>
  173. </el-table-column>
  174. <el-table-column prop="real_sales" label="销量" width="70" align="center">
  175. <template slot-scope="scope">
  176. [[scope.row.show_sales]]
  177. </template>
  178. </el-table-column>
  179. <el-table-column label="状态" prop="status_message" align="center">
  180. <template slot-scope="scope">
  181. [[scope.row.status?'上架':'下架']]
  182. <el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" @change="putAway(scope.row.id,scope.$index)"></el-switch>
  183. </template>
  184. </el-table-column>
  185. <el-table-column label="操作" width="300" align="center">
  186. <template slot-scope="scope">
  187. <div class="table-option">
  188. <el-popover class="item" placement="left" effect="light"
  189. trigger="hover">
  190. <div style="text-align:center;">
  191. <img :src="smallImg" alt=""
  192. style="margin:10px;width:150px;height:150px;">
  193. </div>
  194. <a slot="reference" @mouseover="SmallCode(scope.$index)" :href="'{{ yzWebFullUrl('goods.goods.generate-small-code', array('id' => '')) }}'+[[scope.row.id]]">小程序</a>
  195. </el-popover>&nbsp;&nbsp;
  196. <el-popover class="item" placement="left" effect="light" trigger="hover">
  197. <div style="text-align:center;">
  198. <img :src="img" alt="" style="margin:10px;width:100px;height:100px;">
  199. </div>
  200. <a slot="reference" @mouseover="listCode(scope.$index)">推广链接</a>
  201. </el-popover>&nbsp;&nbsp;
  202. <a target="_blank" :href="'{{ yzWebFullUrl('plugin.jd-supply.admin.shop-goods.edit', array('id' => '')) }}'+[[scope.row.id]]" target="_blank">
  203. 编辑
  204. </a>&nbsp;&nbsp;
  205. <a @click="delOne(scope.row.id)">
  206. 删除
  207. </a>&nbsp;&nbsp;
  208. <a @click="copyList(scope.row.id)">
  209. 复制链接
  210. </a>
  211. <a :href="'{{ yzWebFullUrl('plugin.jd-supply.admin.shop-goods.update-jd-goods', array('id' => '')) }}'+[[scope.row.id]]">
  212. 更新商品
  213. </a>
  214. <div>
  215. <input v-model="scope.row.link" :ref="'list'+scope.row.id" style="position:absolute;opacity:0;height:1px;" />
  216. </div>
  217. </div>
  218. <div>
  219. <el-checkbox border size="mini" v-model.number="scope.row.is_new" :true-label="1" :false-label="0" @change="setProperty(scope.row.id,scope.$index,'is_new')">新品</el-checkbox>
  220. <el-checkbox border size="mini" v-model.number="scope.row.is_hot" :true-label="1" :false-label="0" @change="setProperty(scope.row.id,scope.$index,'is_hot')">热卖</el-checkbox>
  221. <el-checkbox border size="mini" v-model.number="scope.row.is_recommand" :true-label="1" :false-label="0" @change="setProperty(scope.row.id,scope.$index,'is_recommand')">推荐</el-checkbox>
  222. <el-checkbox border size="mini" v-model.number="scope.row.is_discount" :true-label="1" :false-label="0" @change="setProperty(scope.row.id,scope.$index,'is_discount')">促销</el-checkbox>
  223. </div>
  224. </template>
  225. </el-table-column>
  226. </el-table>
  227. <!-- 表格end -->
  228. </template>
  229. @show
  230. </div>
  231. </div>
  232. </div>
  233. <el-dialog :visible.sync="category_show" width="60%" center title="选择分类">
  234. <div style="height:500px">
  235. <el-select v-model="batch_v1" placeholder="请选择一级分类" clearable @change="batchChangeV1($event)" :style="{width:catlevel==3?'33%':'48%'}">
  236. <el-option v-for="(item,index) in batch_category" :key="item.id" :label="item.name" :value="item.id"></el-option>
  237. </el-select>
  238. <el-select v-model="batch_v2" placeholder="请选择二级分类" clearable @change="batchChangeV2($event)" :style="{width:catlevel==3?'33%':'48%'}">
  239. <el-option v-for="item in batch_category_v2" :key="item.id" :label="item.name" :value="item.id"></el-option>
  240. </el-select>
  241. <el-select v-model="batch_v3" placeholder="请选择三级分类" clearable v-if="catlevel==3" style="width:33%">
  242. <el-option v-for="item in batch_category_v3" :key="item.id" :label="item.name" :value="item.id"></el-option>
  243. </el-select>
  244. </div>
  245. <span slot="footer" class="dialog-footer">
  246. <el-button @click="category_show = false">取 消</el-button>
  247. <el-button type="primary" @click="batchCategory">确 定 </el-button>
  248. </span>
  249. </el-dialog>
  250. <!-- 分页 -->
  251. <div class="vue-page" v-show="total>1">
  252. <el-row>
  253. <el-col align="right">
  254. <el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total" :page-size="per_size" :current-page="current_page" background v-loading="loading"></el-pagination>
  255. </el-col>
  256. </el-row>
  257. </div>
  258. </div>
  259. </template>
  260. </div>
  261. </div>
  262. <script src="{{resource_get('static/js/qrcode.min.js')}}"></script>
  263. <script>
  264. var app = new Vue({
  265. el:"#app",
  266. delimiters: ['[[', ']]'],
  267. data() {
  268. return{
  269. id:"",
  270. img:"",//二维码
  271. smallImg:"",//小程序二维码
  272. catlevel:0,//是否显示三级分类
  273. is_all_choose:0,//是否全选
  274. goods_list:[],//商品列表
  275. change_title:"",//修改标题弹框赋值
  276. change_price:"",//修改价格弹框赋值
  277. change_stock:"",//修改库存弹框赋值
  278. change_sort:"",//修改排序弹框赋值
  279. all_loading:false,
  280. status_list:[
  281. {id:'',name:'全部状态'},
  282. {id:0,name:'下架'},
  283. {id:1,name:'上架'},
  284. ],
  285. page_size:[
  286. {id:'',name:''},
  287. {id:20,name:'20条'},
  288. {id:50,name:'50条'},
  289. {id:100,name:'100条'},
  290. ],
  291. sell_stock_list:[
  292. {id:'',name:'全部'},
  293. {id:0,name:'售罄'},
  294. {id:1,name:'出售中'},
  295. ],
  296. brands_list:[],//品牌名称
  297. category_list:[],
  298. category_list_v2:[],
  299. category_list_v3:[],
  300. search_form:{
  301. id_v1:'',
  302. id_v2:'',
  303. id_v3:''
  304. },
  305. form:{},
  306. level_list:[],
  307. loading:false,
  308. table_loading:false,
  309. rules:{},
  310. //分页
  311. total:0,
  312. per_size:0,
  313. current_page:0,
  314. rules:{},
  315. //批量修改分类
  316. batch_category:[],
  317. batch_category_v2:[],
  318. batch_category_v3:[],
  319. batch_v1:'',
  320. batch_v2:'',
  321. batch_v3:'',
  322. category_show:false,
  323. }
  324. },
  325. created() {
  326. this.getData();
  327. },
  328. methods: {
  329. getData() {
  330. var that = this;
  331. that.table_loading = true;
  332. that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.goods-list') !!}").then(response => {
  333. console.log(response);
  334. if(response.data.result==1){
  335. that.goods_list = response.data.data.list.data;
  336. let arr =[];
  337. that.goods_list.forEach((item,index) => {
  338. item.title = that.escapeHTML(item.title)
  339. arr.push(Object.assign({},item,{is_choose:0}))//是否选中
  340. });
  341. that.goods_list=arr;
  342. that.total = response.data.data.list.total;
  343. that.current_page = response.data.data.list.current_page;
  344. that.per_size = response.data.data.list.per_page;
  345. // that.brands_list = response.data.data.brands;
  346. that.category_list = response.data.data.catetory;
  347. that.catlevel = response.data.data.cat_level;
  348. console.log(that.goods_list);
  349. }
  350. else{
  351. that.$message.error(response.data.msg);
  352. }
  353. that.table_loading = false;
  354. }),function(res){
  355. console.log(res);
  356. that.table_loading = false;
  357. };
  358. },
  359. // 一级分类改变
  360. changeV1(){
  361. let that = this;
  362. this.search_form.id_v2 = "";
  363. this.search_form.id_v3 = "";
  364. this.category_list_v2 = [];
  365. this.category_list_v3 = [];
  366. that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.get-parent-category') !!}",{level:2,parent_id:this.search_form.id_v1}).then(response => {
  367. if (response.data.result == 1) {
  368. this.category_list_v2 = response.data.data;
  369. } else {
  370. that.$message.error(response.data.msg);
  371. }
  372. }), function (res) {
  373. //console.log(res);
  374. };
  375. this.category_list.find(item => {
  376. if (item.id == this.search_form.id_v1) {
  377. this.category_list_v2 = item.childrens;
  378. }
  379. });
  380. },
  381. // 二级分类改变
  382. changeV2(){
  383. let that = this;
  384. this.search_form.id_v3 = "";
  385. this.category_list_v3 = [];
  386. if(this.catlevel==3) {
  387. that.$http.post("{!! yzWebFullUrl('goods.category.get-categorys-json') !!}",{level:3,parent_id:this.search_form.id_v2}).then(response => {
  388. if (response.data.result == 1) {
  389. this.category_list_v3 = response.data.data;
  390. } else {
  391. that.$message.error(response.data.msg);
  392. }
  393. }), function (res) {
  394. //console.log(res);
  395. };
  396. }
  397. },
  398. getBrandData(keyword) {
  399. if(keyword=="") {
  400. return;
  401. }
  402. let that = this;
  403. that.$http.post("{!! yzWebFullUrl('goods.brand.search-brand') !!}",{keyword:keyword}).then(response => {
  404. if (response.data.result == 1) {
  405. this.brands_list = response.data.data;
  406. } else {
  407. that.$message.error(response.data.msg);
  408. }
  409. }), function (res) {
  410. //console.log(res);
  411. };
  412. },
  413. // 搜索、分页
  414. search(page) {
  415. var that = this;
  416. console.log(that.search_form)
  417. // 商品类型
  418. let product_attr = [];
  419. if(that.search_form.is_new == 1){
  420. product_attr.push('is_new')
  421. }
  422. if(that.search_form.is_hot == 1){
  423. product_attr.push('is_hot')
  424. }
  425. if(that.search_form.is_recommand == 1){
  426. product_attr.push('is_recommand')
  427. }
  428. if(that.search_form.is_discount == 1){
  429. product_attr.push('is_discount')
  430. }
  431. let json = {
  432. page:page,
  433. search:{
  434. keyword:that.search_form.keyword,
  435. status:that.search_form.status,
  436. sell_stock:that.search_form.sell_stock,
  437. brand_id:that.search_form.brand_id,
  438. min_price:that.search_form.min_price,
  439. max_price:that.search_form.max_price,
  440. min_ratio:that.search_form.min_ratio,
  441. max_ratio:that.search_form.max_ratio,
  442. product_attr:product_attr,//商品类型
  443. page_size:that.search_form.page_size,//商品类型
  444. filtering_name: that.search_form.filtering_name,
  445. },
  446. category:{
  447. parentid:that.search_form.id_v1,
  448. childid:that.search_form.id_v2,
  449. thirdid:that.search_form.id_v3,
  450. }
  451. };
  452. that.table_loading = true;
  453. that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.goods-search') !!}",json).then(response => {
  454. console.log(response);
  455. if(response.data.result==1){
  456. let arr = [];
  457. that.goods_list = response.data.data.data;
  458. that.goods_list.forEach((item,index) => {
  459. item.title = that.escapeHTML(item.title)
  460. arr.push(Object.assign({},item,{is_choose:0}))//是否选中
  461. });
  462. that.goods_list=arr;
  463. that.total = response.data.data.total;
  464. that.current_page = response.data.data.current_page;
  465. that.per_size = response.data.data.per_page;
  466. }
  467. else{
  468. that.$message.error(response.data.msg);
  469. }
  470. that.table_loading = false;
  471. }),function(res){
  472. console.log(res);
  473. that.table_loading = false;
  474. };
  475. },
  476. qrcodeScan (url) {//生成二维码
  477. let qrcode = new QRCode('qrcode', {
  478. width: 100, // 二维码宽度
  479. height: 100, // 二维码高度
  480. render: 'image',
  481. text: url
  482. });
  483. var data = $("canvas")[$("canvas").length-1].toDataURL().replace("image/png", "image/octet-stream;");
  484. console.log(data)
  485. this.img = data;
  486. },
  487. // 活动二维码
  488. listCode(index) {
  489. this.qrcodeScan(this.goods_list[index].link);
  490. },
  491. // 小程序二维码
  492. SmallCode(index) {
  493. this.smallImg = this.goods_list[index].small_link;
  494. },
  495. // 复制活动链接
  496. copyList(index) {
  497. that = this;
  498. let Url = that.$refs['list'+index];
  499. console.log(Url)
  500. Url.select(); // 选择对象
  501. document.execCommand("Copy",false);
  502. that.$message({message:"复制成功!",type:"success"});
  503. },
  504. // 单个选择
  505. oneChange(item) {
  506. let that = this;
  507. let is_all = 0;
  508. that.goods_list.some((item,index) => {
  509. if(item.is_choose == 1) {
  510. is_all = 1;
  511. }
  512. else {
  513. is_all = 0;
  514. return true;
  515. }
  516. })
  517. that.is_all_choose = is_all;
  518. },
  519. // 全选
  520. allChoose() {
  521. let that = this;
  522. let status = 0;
  523. if(that.is_all_choose == 1){
  524. status = 1;
  525. }
  526. else{
  527. status = 0;
  528. }
  529. that.goods_list.forEach((item,index) => {
  530. item.is_choose = status;
  531. })
  532. },
  533. // 上架、下架
  534. putAway(id,index) {
  535. var that = this;
  536. that.table_loading = true;
  537. let data = that.goods_list[index].status;
  538. let json = {id:id,type:'status',data:data};
  539. that.$http.post("{!! yzWebFullUrl('goods.goods.setPutaway') !!}",json).then(response => {
  540. console.log(response);
  541. if(response.data.result==1){
  542. that.$message.success('操作成功!');
  543. }
  544. else{
  545. that.$message.error(response.data.msg);
  546. that.goods_list[index].is_choose == 1 ? 0 : 1;
  547. }
  548. that.table_loading = false;
  549. }),function(res){
  550. console.log(res);
  551. that.table_loading = false;
  552. };
  553. },
  554. openCategory() {
  555. this.category_show = true;
  556. if(this.batch_category.length==0) {
  557. this.getBatchCategory();
  558. }
  559. },
  560. getBatchCategory() {
  561. var that = this;
  562. that.$http.post("{!! yzWebFullUrl('goods.category.get-all-shop-category') !!}", {}).then(response => {
  563. console.log(response);
  564. if (response.data.result == 1) {
  565. this.batch_category = response.data.data.list;
  566. } else {
  567. that.$message.error(response.data.msg);
  568. }
  569. }), function (res) {
  570. console.log(res);
  571. };
  572. },
  573. batchCategory() {
  574. let that = this;
  575. let json = {
  576. level_1:this.batch_v1,
  577. level_2:this.batch_v2,
  578. goods_id_arr:[],
  579. };
  580. if(!json.level_1) {
  581. this.$message.error('请选择一级分类')
  582. return;
  583. }
  584. if(!json.level_2) {
  585. this.$message.error('请选择二级分类')
  586. return;
  587. }
  588. that.goods_list.forEach((item, index) => {
  589. if (item.is_choose == 1) {
  590. json.goods_id_arr.push(item.id);
  591. }
  592. })
  593. if(this.catlevel == 3) {
  594. json.level_3 = this.batch_v3
  595. if(!json.level_3) {
  596. this.$message.error('请选择三级分类')
  597. return;
  598. }
  599. }
  600. that.$http.post("{!! yzWebFullUrl('goods.category.change-many-goods-category') !!}", json).then(response => {
  601. console.log(response);
  602. if (response.data.result == 1) {
  603. that.$message.success('操作成功!');
  604. that.is_all_choose = 0;
  605. that.search(1);
  606. this.category_show = false;
  607. } else {
  608. that.$message.error(response.data.msg);
  609. }
  610. }), function (res) {
  611. console.log(res);
  612. };
  613. },
  614. batchChangeV1(val) {
  615. console.log(val)
  616. this.batch_category_v2 = [];
  617. this.batch_category_v3 = [];
  618. this.batch_v2 = '';
  619. this.batch_v3 = '';
  620. let obj = this.batch_category.find((item,index) => {
  621. return item.id == val
  622. })
  623. this.batch_category_v2 = obj?obj.has_many_children:[]
  624. },
  625. batchChangeV2(val) {
  626. if(this.catlevel!=3) {
  627. return
  628. }
  629. this.batch_category_v3 = [];
  630. this.batch_v3 = '';
  631. let obj = this.batch_category_v2.find((item,index) => {
  632. return item.id == val
  633. })
  634. this.batch_category_v3 = obj?obj.has_many_children:[]
  635. },
  636. // 批量上架、下架
  637. batchPutAway(data) {
  638. var that = this;
  639. that.table_loading = true;
  640. let ids = [];
  641. that.goods_list.forEach((item,index) => {
  642. if(item.is_choose == 1){
  643. ids.push(item.id);
  644. }
  645. })
  646. let json = {data:data,ids:ids}
  647. that.$http.post("{!! yzWebFullUrl('goods.goods.batchSetProperty') !!}",json).then(response => {
  648. console.log(response);
  649. if(response.data.result==1){
  650. that.$message.success('操作成功!');
  651. that.is_all_choose = 0;
  652. that.search(1);
  653. }
  654. else{
  655. that.$message.error(response.data.msg);
  656. }
  657. that.table_loading = false;
  658. }),function(res){
  659. console.log(res);
  660. that.table_loading = false;
  661. };
  662. },
  663. // 单个删除
  664. delOne(id) {
  665. var that = this;
  666. that.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  667. that.table_loading = true;
  668. that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.delete') !!}",{id:id}).then(response => {
  669. console.log(response);
  670. if(response.data.result==1){
  671. that.$message.success("删除成功!");
  672. that.search(1);
  673. }
  674. else{
  675. that.$message.error(response.data);
  676. }
  677. that.table_loading = false;
  678. }),function(res){
  679. console.log(res);
  680. that.table_loading = false;
  681. };
  682. }).catch(() => {
  683. this.$message({type: 'info',message: '已取消修改'});
  684. });
  685. },
  686. // 一键更新
  687. UpdateJob() {
  688. var that = this;
  689. let job_num = 0;
  690. that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.update-job-nums') !!}").then(response => {
  691. if(response.data.result==1){
  692. job_num = response.data.data.nums;
  693. let job = Math.ceil(this.total / 20);
  694. console.log(job);
  695. that.$confirm('一键更新所有聚合供应链商品。该操作将产生'+job+'条队列。可能造成商城其他队列延迟执行,队列堵塞等情况,建议开启多个队列运行,请谨慎操作(每条队列所需时间约等于批量更新20条商品所需时间,当前约有'+job_num +'条队列等待执行)', '提示', {confirmButtonText: '确定更新',cancelButtonText: '取消',type: 'warning'}).then(() => {
  696. that.table_loading = true;
  697. that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.update-job') !!}").then(response => {
  698. console.log(response);
  699. if(response.data.result==1){
  700. that.$message.success('队列生成成功!');
  701. that.is_all_choose = 0;
  702. that.search(1);
  703. }
  704. else{
  705. that.$message.error(response.data.msg);
  706. }
  707. that.table_loading = false;
  708. }),function(res){
  709. console.log(res);
  710. that.table_loading = false;
  711. };
  712. }).catch(() => {
  713. this.$message({type: 'info',message: '已取消'});
  714. });
  715. }
  716. }),function(res){
  717. console.log(res);
  718. };
  719. },
  720. // 批量删除
  721. batchDestroy() {
  722. var that = this;
  723. that.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  724. that.table_loading = true;
  725. let ids = [];
  726. that.goods_list.forEach((item,index) => {
  727. if(item.is_choose == 1){
  728. ids.push(item.id);
  729. }
  730. })
  731. let json = {ids:ids}
  732. that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.batch-delete') !!}",json).then(response => {
  733. console.log(response);
  734. if(response.data.result==1){
  735. that.$message.success('操作成功!');
  736. that.is_all_choose = 0;
  737. that.search(1);
  738. }
  739. else{
  740. that.$message.error(response.data.msg);
  741. }
  742. that.table_loading = false;
  743. }),function(res){
  744. console.log(res);
  745. that.table_loading = false;
  746. };
  747. }).catch(() => {
  748. this.$message({type: 'info',message: '已取消修改'});
  749. });
  750. },
  751. // 批量更新
  752. batchUpdate() {
  753. var that = this;
  754. that.$confirm('确定更新吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  755. that.table_loading = true;
  756. let ids = [];
  757. that.goods_list.forEach((item,index) => {
  758. if(item.is_choose == 1){
  759. ids.push(item.id);
  760. }
  761. })
  762. let json = {ids:ids}
  763. that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.batchUpdate') !!}",json).then(response => {
  764. console.log(response);
  765. if(response.data.result==1){
  766. that.$message.success(response.data.msg);
  767. that.is_all_choose = 0;
  768. that.search(1);
  769. }
  770. else{
  771. that.$message.error(response.data.msg);
  772. }
  773. that.table_loading = false;
  774. }),function(res){
  775. console.log(res);
  776. that.table_loading = false;
  777. };
  778. }).catch(() => {
  779. this.$message({type: 'info',message: '已取消修改'});
  780. });
  781. },
  782. // 新品、热卖、推荐、促销、
  783. setProperty(id,index,type) {
  784. var that = this;
  785. that.table_loading = true;
  786. console.log(that.goods_list[index][type])
  787. let data = that.goods_list[index][type];
  788. let json = {id:id,type:type,data:data};
  789. that.$http.post("{!! yzWebFullUrl('goods.goods.setProperty') !!}",json).then(response => {
  790. console.log(response);
  791. if(response.data.result==1){
  792. that.$message.success('操作成功!');
  793. }
  794. else{
  795. that.$message.error(response.data.msg);
  796. that.goods_list[index][type] == 1 ? 0 : 1;
  797. }
  798. that.table_loading = false;
  799. }),function(res){
  800. console.log(res);
  801. that.table_loading = false;
  802. };
  803. },
  804. // 编辑商品标题
  805. editTitle(index,type) {
  806. let that = this;
  807. if(type == 'title') {
  808. that.change_title = "";
  809. that.change_title = that.goods_list[index].title;
  810. }
  811. if(type == 'price') {
  812. if(that.goods_list[index].has_option == 1) {
  813. that.$message.error('多规格不支持快速修改');
  814. return false;
  815. }
  816. that.change_price = "";
  817. that.change_price = that.goods_list[index].price;
  818. }
  819. if(type == 'stock') {
  820. if(that.goods_list[index].has_option == 1) {
  821. that.$message.error('多规格不支持快速修改');
  822. return false;
  823. }
  824. that.change_stock = "";
  825. that.change_stock = that.goods_list[index].stock;
  826. }
  827. if(type == 'sort') {
  828. that.change_sort = "";
  829. that.change_sort = that.goods_list[index].display_order;
  830. }
  831. },
  832. // 确认修改标题、价格、库存
  833. confirmChange(id,type) {
  834. let that = this;
  835. let value = '';
  836. if(type == 'title'){
  837. value = that.change_title;
  838. if(that.change_title == ''){
  839. that.$message.error('标题不能为空');
  840. return false;
  841. }
  842. }
  843. if(type == 'price'){
  844. value = that.change_price;
  845. if(!(/^\d+(\.\d+)?$/.test(that.change_price))){
  846. that.$message.error('请输入正确价格');
  847. return false;
  848. }
  849. }
  850. if(type == 'stock'){
  851. value = that.change_stock;
  852. if(!(/^\d+$/.test(that.change_stock))){
  853. that.$message.error('请输入正确数字');
  854. return false;
  855. }
  856. }
  857. let json = {
  858. id:id,
  859. type:type,
  860. value:value,
  861. };
  862. that.table_loading = true;
  863. that.$http.post("{!! yzWebFullUrl('goods.goods.change') !!}",json).then(response => {
  864. console.log(response);
  865. if(response.data.result==1){
  866. that.$message.success('操作成功!');
  867. if (document.all) {
  868. document.getElementById('app').click();
  869. }
  870. else {// 其它浏览器
  871. var e = document.createEvent('MouseEvents')
  872. e.initEvent('click', true, true)
  873. document.getElementById('app').dispatchEvent(e)
  874. }
  875. that.search(1);
  876. }
  877. else{
  878. that.$message.error(response.data.msg);
  879. }
  880. that.table_loading = false;
  881. }),function(res){
  882. console.log(res);
  883. that.table_loading = false;
  884. };
  885. },
  886. // 确认修改排序
  887. confirmChangeSort(id) {
  888. let that = this;
  889. if(!(/^\d+$/.test(that.change_sort))){
  890. that.$message.error('请输入正确数字');
  891. return false;
  892. }
  893. that.table_loading = true;
  894. let json = {id:id,value:that.change_sort};
  895. that.$http.post("{!! yzWebFullUrl('goods.goods.displayorder') !!}",json).then(response => {
  896. console.log(response);
  897. if(response.data.result==1){
  898. that.$message.success('操作成功!');
  899. // that.$refs.search_form.click();
  900. if (document.all) {
  901. document.getElementById('app').click();
  902. }
  903. else {// 其它浏览器
  904. var e = document.createEvent('MouseEvents')
  905. e.initEvent('click', true, true)
  906. document.getElementById('app').dispatchEvent(e)
  907. }
  908. that.search(1);
  909. }
  910. else{
  911. that.$message.error(response.data.msg);
  912. }
  913. that.table_loading = false;
  914. }),function(res){
  915. console.log(res);
  916. that.table_loading = false;
  917. };
  918. },
  919. // 字符转义
  920. escapeHTML(a) {
  921. a = "" + a;
  922. return a.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&apos;/g, "'");;
  923. },
  924. },
  925. })
  926. </script>
  927. @endsection