goods.blade.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  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. <style>
  6. .el-table .cell{
  7. white-space:pre-line;
  8. }
  9. </style>
  10. <div id="qrcode" ref="qrcode" style="display:none;"></div>
  11. <div class="rightlist">
  12. <div id="app" v-cloak v-loading="all_loading">
  13. <template>
  14. <div class="second-list">
  15. <div class="third-list">
  16. <div class="form-list">
  17. <el-form :inline="true" :model="search_form" ref="search_form" style="margin-left:10px;">
  18. <el-row>
  19. <el-form-item label="" prop="">
  20. <el-select v-model="search_form.middleground_configuration_id" placeholder="请选择供应链" clearable remote filterable >
  21. <el-option v-for="item in middleground_configuration" :key="item.id" :label="item.title" :value="item.id"></el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-select v-model="search_form.cate_v1" placeholder="请选择一级分类" clearable @change="changeV1()" filterable>
  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.cate_v2" placeholder="请选择二级分类" clearable @change="changeV2()" filterable>
  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.cate_v3" placeholder="请选择三级分类" clearable filterable>
  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>
  40. <el-select v-model="search_form.status" placeholder="请选择上下架" clearable>
  41. <el-option v-for="item in status_list" :key="item.id" :label="item.label" :value="item.id"></el-option>
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item label="" prop="goods_name">
  45. <el-input v-model="search_form.goods_name" placeholder="请输入商品名称"></el-input>
  46. </el-form-item>
  47. <el-form-item label="价格区间" prop="">
  48. <el-input v-model="search_form.min_price" placeholder="最低价" style="width:150px;"></el-input>
  49. <el-input v-model="search_form.max_price" placeholder="最高价" style="width:150px;"></el-input>
  50. </el-form-item>
  51. <el-form-item label="" prop="">
  52. <el-select v-model="search_form.page_size" placeholder="每页条数" clearable>
  53. <el-option v-for="item in page_size" :key="item.id" :label="item.name" :value="item.id"></el-option>
  54. </el-select>
  55. </el-form-item>
  56. <a href="#">
  57. <el-button type="primary" icon="el-icon-search" @click="getData(1)">搜索</el-button>
  58. </a>
  59. </el-col>
  60. </el-row>
  61. </el-form>
  62. </div>
  63. <div class="table-list">
  64. <div style="margin-left:10px;">
  65. <el-checkbox v-model.number="is_all_choose" :true-label="1" :false-label="0" @change="allChoose">[[is_all_choose==1?'全不选':'全选']]</el-checkbox>
  66. <el-button size="small" @click="batchStatusOn()">批量上架</el-button>
  67. <el-button size="small" @click="batchStatusOff()">批量下架</el-button>
  68. <el-button size="small" @click="batchDestroy">批量删除</el-button>
  69. <el-button size="small" @click="batchUpdate">批量更新</el-button>
  70. <el-button size="small" @click="batchUpdateStock">一键更新</el-button>
  71. <el-button size="small" @click="batchUpdateStockStay">一键更新所有待更新的商品</el-button>
  72. </div>
  73. <div>
  74. @section('search')
  75. <template>
  76. <!-- 表格start -->
  77. <el-table :data="goods_list" style="width: 100%" :class="table_loading==true?'loading-height':''" v-loading="table_loading">
  78. <el-table-column prop="id" label="选择" width="60" align="center">
  79. <template slot-scope="scope">
  80. <el-checkbox v-model.number="scope.row.is_choose" :true-label="1" :false-label="0" @change="oneChange(scope.row)"></el-checkbox>
  81. </template>
  82. </el-table-column>
  83. <el-table-column prop="cloud.goods_id" label="本地ID" width="90" align="center">
  84. <template slot-scope="scope">
  85. [[scope.row.cloud.goods_id?scope.row.cloud.goods_id:0]]
  86. </template>
  87. </el-table-column>
  88. <el-table-column prop="goodsId" label="第三方ID" width="90" align="center">
  89. <template slot-scope="scope">
  90. [[scope.row.id]]
  91. </template>
  92. </el-table-column>
  93. </el-table-column>
  94. <el-table-column prop="total" label="商品" width="60" align="center">
  95. <template slot-scope="scope">
  96. <img :src="scope.row.image_url" style="width:50px;height:50px;">
  97. </template>
  98. </el-table-column>
  99. <el-table-column prop="down_time" label="" min-width="180" align="left" class="edit-cell">
  100. <template slot-scope="scope" >
  101. <p v-if="scope.row.is_cloud == 1"> <a :href="'{{ yzWebFullUrl('plugin.yz-supply.admin.shop-goods.edit', array('id' => '')) }}'+[[scope.row.cloud.goods_id]]">
  102. [[scope.row.title]]
  103. </a>
  104. </p>
  105. <p v-else>
  106. [[scope.row.title]]
  107. </p>
  108. </template>
  109. </el-table-column>
  110. <el-table-column prop="member_num" v-bind:label="'中台商品零售价\n本地原价'" width="150" align="center">
  111. <template slot-scope="scope">
  112. ¥[[scope.row.origin_price]]<br>
  113. ¥[[scope.row.goods.market_price?scope.row.goods.market_price:0.00]]
  114. </template>
  115. </el-table-column>
  116. <el-table-column prop="member_num" v-bind:label="'中台商品指导价\n本地现价'" width="150" align="center">
  117. <template slot-scope="scope">
  118. ¥[[scope.row.guide_price]]<br>
  119. ¥[[scope.row.goods.price?scope.row.goods.price:0.00]]
  120. </template>
  121. </el-table-column>
  122. <el-table-column prop="member_num" v-bind:label="'中台商品成本价\n本地成本价'" width="150" align="center">
  123. <template slot-scope="scope">
  124. ¥[[scope.row.cost_price]]<br>
  125. ¥[[scope.row.goods.cost_price?scope.row.goods.cost_price:0.00]]
  126. </template>
  127. </el-table-column>
  128. <el-table-column prop="member_num" label="物流费" width="80" align="center">
  129. <template slot-scope="scope">
  130. ¥[[scope.row.freight]]
  131. </template>
  132. </el-table-column>
  133. <el-table-column prop="member_num" label="运费模板ID" width="80" align="center">
  134. <template slot-scope="scope">
  135. [[scope.row.freight_template_id]]
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="库存" align="center" max-width="80">
  139. <template slot-scope="scope">
  140. [[scope.row.stock]]
  141. </template>
  142. </el-table-column>
  143. <el-table-column prop="real_sales" label="销量" width="70" align="center">
  144. <template slot-scope="scope">
  145. [[scope.row.sales]]
  146. </template>
  147. </el-table-column>
  148. <el-table-column v-bind:label="'云仓状态\n本地状态'" prop="status_message" align="center">
  149. <template slot-scope="scope">
  150. [[scope.row.is_display?'上架':'下架']]<br>
  151. <p v-if="scope.row.goods.status==0 && scope.row.is_cloud == 1">下架</p>
  152. <p v-if="scope.row.goods.status=='1' && scope.row.is_cloud == 1">上架</p>
  153. <p v-if="scope.row.goods.status==null && scope.row.is_cloud == 1">失效</p>
  154. <p v-if="scope.row.is_cloud == 2" style="color:#ff3a3a;">非云仓推送至中台的商品</p>
  155. </template>
  156. </el-table-column>
  157. <el-table-column label="操作" width="300" align="center">
  158. <template slot-scope="scope">
  159. <div class="table-option">
  160. <a @click="statusOn(scope.row.id)">
  161. 上架
  162. </a>
  163. <a @click="statusOff(scope.row.id)">
  164. 下架
  165. </a>
  166. <a v-if="scope.row.is_cloud == 1" @click="update(scope.row)">
  167. 更新商品 <div v-if="scope.row.cloud.is_update == 1" style="color: #ff3a3a;">待更新</div>
  168. </a>
  169. <a @click="delOne(scope.row.id)">
  170. 删除
  171. </a>
  172. <div>
  173. <input v-model="scope.row.link" :ref="'list'+scope.row.id" style="position:absolute;opacity:0;height:1px;" />
  174. </div>
  175. </div>
  176. </template>
  177. </el-table-column>
  178. </el-table>
  179. <!-- 表格end -->
  180. </template>
  181. @show
  182. </div>
  183. </div>
  184. </div>
  185. <!-- 分页 -->
  186. <div class="vue-page">
  187. <el-row>
  188. <el-col align="right">
  189. <el-pagination layout="prev, pager, next,jumper" @current-change="getData" :total="total" :page-size="per_size" :current-page="current_page" background v-loading="loading"></el-pagination>
  190. </el-col>
  191. </el-row>
  192. </div>
  193. </div>
  194. </template>
  195. </div>
  196. </div>
  197. <script src="{{resource_get('static/js/qrcode.min.js')}}"></script>
  198. <script>
  199. var app = new Vue({
  200. el:"#app",
  201. delimiters: ['[[', ']]'],
  202. data() {
  203. return{
  204. id:"",
  205. img:"",//二维码
  206. catlevel:0,//是否显示三级分类
  207. is_all_choose:0,//是否全选
  208. goods_list:[],//商品列表
  209. change_title:"",//修改标题弹框赋值
  210. change_price:"",//修改价格弹框赋值
  211. change_stock:"",//修改库存弹框赋值
  212. change_sort:"",//修改排序弹框赋值
  213. middleground_configuration:[],//中台供应链数组
  214. all_loading:false,
  215. page_size:[
  216. {id:'',name:''},
  217. {id:20,name:'20条'},
  218. {id:50,name:'50条'},
  219. ],
  220. status_list:[
  221. {id:0,label:'全部'},
  222. {id:1,label:'上架'},
  223. {id:2,label:'下架'},
  224. {id:3,label:'售罄'},
  225. ],
  226. category_list:[],
  227. category_list_v2:[],
  228. category_list_v3:[],
  229. search_form:{
  230. middleground_configuration_id:0,
  231. cate_v1:'',
  232. cate_v2:'',
  233. cate_v3:'',
  234. status:0,
  235. },
  236. form:{},
  237. level_list:[],
  238. loading:false,
  239. table_loading:false,
  240. rules:{},
  241. //分页
  242. total:0,
  243. per_size:0,
  244. current_page:0,
  245. rules:{},
  246. }
  247. },
  248. created() {
  249. this.getMiddlegroundConfiguration();
  250. },
  251. methods: {
  252. getMiddlegroundConfiguration(){
  253. this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.middleground-configuration.get-middleground-configurations') !!}').then(function (response) {
  254. if (response.data.result) {
  255. this.middleground_configuration = response.data.data;
  256. this.search_form.middleground_configuration_id = this.middleground_configuration[0].id;
  257. this.getData(1);
  258. this.getThirdCategory()
  259. } else {
  260. this.$message({message: response.data.msg, type: 'error'});
  261. }
  262. }, function (response) {
  263. this.$message({message: response.data.msg, type: 'error'});
  264. })
  265. },
  266. getData(page) {
  267. var that = this;
  268. let json = {
  269. page:page,
  270. search:{
  271. third_goods_id:that.search_form.third_goods_id,
  272. goods_name:that.search_form.goods_name,
  273. min_price:that.search_form.min_price,
  274. max_price:that.search_form.max_price,
  275. page_size:that.search_form.page_size,
  276. cate_v1:that.search_form.cate_v1,
  277. cate_v2:that.search_form.cate_v2,
  278. cate_v3:that.search_form.cate_v3,
  279. status:that.search_form.status,
  280. },
  281. middleground_configuration_id:this.search_form.middleground_configuration_id
  282. };
  283. that.table_loading = true;
  284. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-goods.goods-list') !!}",json).then(response => {
  285. console.log(response.data.data);
  286. if(response.data.result==1){
  287. that.goods_list = response.data.data.list.data;
  288. let arr =[];
  289. that.goods_list.forEach((item,index) => {
  290. item.title = that.escapeHTML(item.title)
  291. item.goods_id = item.cloud.goods_id
  292. arr.push(Object.assign({},item,{is_choose:0}))//是否选中
  293. });
  294. that.goods_list=arr;
  295. that.total = response.data.data.total;
  296. that.per_size = response.data.data.page_size;
  297. that.current_page = response.data.data.page;
  298. console.log(that.goods_list);
  299. }
  300. else{
  301. that.$message.error(response.data.msg);
  302. }
  303. that.table_loading = false;
  304. }),function(res){
  305. console.log(res);
  306. that.table_loading = false;
  307. };
  308. },
  309. // 获取第三方分类、
  310. getThirdCategory(parent_id,level){
  311. this.$http.post('{!!yzWebFullUrl('plugin.yz-supply.admin.goods-import.getChildrenCategory')!!}', {
  312. 'parent_id': parent_id,
  313. 'middleground_configuration_id':this.search_form.middleground_configuration_id
  314. }).then(res => {
  315. if (res.data.result == '1') {
  316. switch (level) {
  317. case 1:
  318. this.category_list = res.data.data;
  319. break;
  320. case 2:
  321. this.category_list_v2 = res.data.data;
  322. break;
  323. case 3:
  324. this.category_list_v3 = res.data.data;
  325. break;
  326. default:
  327. this.category_list = res.data.data;
  328. break;
  329. }
  330. } else {
  331. this.$message({
  332. type: 'error',
  333. message: res.data.msg
  334. })
  335. }
  336. })
  337. },
  338. // 一级分类改变
  339. changeV1() {
  340. this.search_form.cate_v2 = "";
  341. this.search_form.cate_v3 = "";
  342. this.category_list_v2 = [];
  343. this.category_list_v3 = [];
  344. this.getThirdCategory(this.search_form.cate_v1,2)
  345. },
  346. // 二级分类改变
  347. changeV2() {
  348. this.search_form.cate_v3 = "";
  349. this.category_list_v3 = [];
  350. this.getThirdCategory(this.search_form.cate_v2,3)
  351. },
  352. // 单个选择
  353. oneChange(item) {
  354. let that = this;
  355. let is_all = 0;
  356. that.goods_list.some((item,index) => {
  357. if(item.is_choose == 1) {
  358. is_all = 1;
  359. }
  360. else {
  361. is_all = 0;
  362. return true;
  363. }
  364. })
  365. that.is_all_choose = is_all;
  366. },
  367. // 全选
  368. allChoose() {
  369. let that = this;
  370. let status = 0;
  371. if(that.is_all_choose == 1){
  372. status = 1;
  373. }
  374. else{
  375. status = 0;
  376. }
  377. that.goods_list.forEach((item,index) => {
  378. item.is_choose = status;
  379. })
  380. },
  381. // 批量上架
  382. batchStatusOn() {
  383. var that = this;
  384. that.$confirm('确定上架吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  385. that.table_loading = true;
  386. let ids = [];
  387. that.goods_list.forEach((item,index) => {
  388. if(item.is_choose == 1){
  389. ids.push(item.id);
  390. }
  391. })
  392. let json = {ids:ids,'middleground_configuration_id':this.search_form.middleground_configuration_id}
  393. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-goods.batch-on-shelf') !!}",json).then(response => {
  394. console.log(response);
  395. if(response.data.result==1){
  396. that.$message.success(response.data.msg);
  397. that.is_all_choose = 0;
  398. that.getData(1);
  399. }
  400. else{
  401. that.$message.error(response.data.msg);
  402. }
  403. that.table_loading = false;
  404. }),function(res){
  405. console.log(res);
  406. that.table_loading = false;
  407. };
  408. }).catch(() => {
  409. this.$message({type: 'info',message: '已取消'});
  410. });
  411. },
  412. // 批量下架
  413. batchStatusOff() {
  414. var that = this;
  415. that.$confirm('确定下架吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  416. that.table_loading = true;
  417. let ids = [];
  418. that.goods_list.forEach((item,index) => {
  419. if(item.is_choose == 1){
  420. ids.push(item.id);
  421. }
  422. })
  423. let json = {ids:ids,'middleground_configuration_id':this.search_form.middleground_configuration_id}
  424. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-goods.batch-off-shelf') !!}",json).then(response => {
  425. console.log(response);
  426. if(response.data.result==1){
  427. that.$message.success(response.data.msg);
  428. that.is_all_choose = 0;
  429. that.getData(that.current_page);
  430. }
  431. else{
  432. that.$message.error(response.data.msg);
  433. }
  434. that.table_loading = false;
  435. }),function(res){
  436. console.log(res);
  437. that.table_loading = false;
  438. };
  439. }).catch(() => {
  440. this.$message({type: 'info',message: '已取消'});
  441. });
  442. },
  443. //上架
  444. statusOn(id) {
  445. var that = this;
  446. that.$confirm('确定上架吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  447. that.table_loading = true;
  448. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-goods.on-shelf') !!}",{id:id,'middleground_configuration_id':this.search_form.middleground_configuration_id}).then(response => {
  449. console.log(response);
  450. if(response.data.result==1){
  451. that.$message.success("上架提交成功!");
  452. that.getData(that.current_page);
  453. }
  454. else{
  455. that.$message.error(response.data.msg);
  456. }
  457. that.table_loading = false;
  458. }),function(res){
  459. console.log(res);
  460. that.table_loading = false;
  461. };
  462. }).catch(() => {
  463. this.$message({type: 'info',message: '已取消'});
  464. });
  465. },
  466. //下架
  467. statusOff(id) {
  468. var that = this;
  469. that.$confirm('确定下架吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  470. that.table_loading = true;
  471. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-goods.off-shelf') !!}",{id:id,'middleground_configuration_id':this.search_form.middleground_configuration_id}).then(response => {
  472. console.log(response);
  473. if(response.data.result==1){
  474. that.$message.success("下架成功!");
  475. that.getData(that.current_page);
  476. }
  477. else{
  478. that.$message.error(response.data.msg);
  479. }
  480. that.table_loading = false;
  481. }),function(res){
  482. console.log(res);
  483. that.table_loading = false;
  484. };
  485. }).catch(() => {
  486. this.$message({type: 'info',message: '已取消'});
  487. });
  488. },
  489. //上架
  490. update(goods) {
  491. var that = this;
  492. let json = {
  493. goodsId:goods.id,
  494. category1_id:goods.category1_id,
  495. category2_id:goods.category2_id,
  496. category3_id:goods.category3_id,
  497. freight:goods.freight,
  498. freight_template_id:goods.freight_template_id,
  499. freight_type:goods.freight_type,
  500. }
  501. that.$confirm('确定更新吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  502. that.table_loading = true;
  503. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-goods.update') !!}",{goods:json,'middleground_configuration_id':this.search_form.middleground_configuration_id}).then(response => {
  504. if(response.data.result==1){
  505. that.$message.success("更新成功!");
  506. that.getData(that.current_page);
  507. }
  508. else{
  509. that.$message.error(response.data.msg);
  510. }
  511. that.table_loading = false;
  512. }),function(res){
  513. console.log(res);
  514. that.table_loading = false;
  515. };
  516. }).catch(() => {
  517. this.$message({type: 'info',message: '已取消'});
  518. });
  519. },
  520. // 单个删除
  521. delOne(id) {
  522. var that = this;
  523. that.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  524. that.table_loading = true;
  525. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-goods.delete') !!}",{id:id,'middleground_configuration_id':this.search_form.middleground_configuration_id}).then(response => {
  526. console.log(response);
  527. if(response.data.result==1){
  528. that.$message.success("删除成功!");
  529. that.getData(that.current_page);
  530. }
  531. else{
  532. that.$message.error(response.data.msg);
  533. }
  534. that.table_loading = false;
  535. }),function(res){
  536. console.log(res);
  537. that.table_loading = false;
  538. };
  539. }).catch(() => {
  540. this.$message({type: 'info',message: '已取消'});
  541. });
  542. },
  543. // 批量删除
  544. batchDestroy() {
  545. var that = this;
  546. that.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  547. that.table_loading = true;
  548. let ids = [];
  549. that.goods_list.forEach((item,index) => {
  550. if(item.is_choose == 1){
  551. ids.push(item.id);
  552. }
  553. })
  554. let json = {ids:ids,'middleground_configuration_id':this.search_form.middleground_configuration_id}
  555. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-goods.batch-delete') !!}",json).then(response => {
  556. console.log(response);
  557. if(response.data.result==1){
  558. that.$message.success('操作成功!');
  559. that.is_all_choose = 0;
  560. that.getData(that.current_page);
  561. }
  562. else{
  563. that.$message.error(response.data.msg);
  564. }
  565. that.table_loading = false;
  566. }),function(res){
  567. console.log(res);
  568. that.table_loading = false;
  569. };
  570. }).catch(() => {
  571. this.$message({type: 'info',message: '已取消修改'});
  572. });
  573. },
  574. // 批量更新
  575. batchUpdate() {
  576. var that = this;
  577. that.$confirm('确定更新吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  578. that.table_loading = true;
  579. let search = [];
  580. that.goods_list.forEach((item,index) => {
  581. if(item.is_choose == 1){
  582. let json = {
  583. goodsId:item.id,
  584. category1_id:item.category1_id,
  585. category2_id:item.category2_id,
  586. category3_id:item.category3_id,
  587. freight:item.freight,
  588. freight_template_id:item.freight_template_id,
  589. freight_type:item.freight_type,
  590. }
  591. search.push(json);
  592. }
  593. })
  594. console.log(search);
  595. let json = {data:search}
  596. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-goods.batch-update') !!}",json).then(response => {
  597. console.log(response);
  598. if(response.data.result==1){
  599. that.$message.success(response.data.msg);
  600. that.is_all_choose = 0;
  601. that.getData(that.current_page);
  602. }
  603. else{
  604. that.$message.error(response.data.msg);
  605. }
  606. that.table_loading = false;
  607. }),function(res){
  608. console.log(res);
  609. that.table_loading = false;
  610. };
  611. }).catch(() => {
  612. this.$message({type: 'info',message: '已取消修改'});
  613. });
  614. },
  615. batchUpdateStock() {
  616. var that = this;
  617. let job_num = 0;
  618. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.shop-goods.update-job-nums') !!}").then(response => {
  619. if(response.data.result==1){
  620. job_num = response.data.data.nums;
  621. let job = Math.ceil(this.total / 20);
  622. console.log(job);
  623. that.$confirm('一键更新所有推送到中台商品。该操作将产生'+job+'条队列。可能造成商城其他队列延迟执行,队列堵塞等情况,建议开启多个队列运行,请谨慎操作(每条队列所需时间约等于批量更新20条商品所需时间,当前约有'+job_num +'条队列等待执行)', '提示', {confirmButtonText: '确定更新',cancelButtonText: '取消',type: 'warning'}).then(() => {
  624. that.table_loading = true;
  625. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-goods.update-stock') !!}").then(response => {
  626. console.log(response);
  627. if(response.data.result==1){
  628. that.$message.success('队列生成成功!');
  629. that.is_all_choose = 0;
  630. // that.search(1);
  631. }
  632. else{
  633. that.$message.error(response.data.msg);
  634. }
  635. that.table_loading = false;
  636. }),function(res){
  637. console.log(res);
  638. that.table_loading = false;
  639. };
  640. }).catch(() => {
  641. this.$message({type: 'info',message: '已取消'});
  642. });
  643. }
  644. }),function(res){
  645. console.log(res);
  646. };
  647. },
  648. batchUpdateStockStay(){
  649. var that = this;
  650. let job_num = 0;
  651. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.shop-goods.update-job-nums') !!}").then(response => {
  652. if(response.data.result==1){
  653. job_num = response.data.data.nums;
  654. let job = Math.ceil(this.total / 20);
  655. console.log(job);
  656. that.$confirm('一键更新所有待更新的商品。该操作将产生队列。可能造成商城其他队列延迟执行,队列堵塞等情况,建议开启多个队列运行,请谨慎操作(每条队列所需时间约等于批量更新20条商品所需时间,当前约有'+job_num +'条队列等待执行)', '提示', {confirmButtonText: '确定更新',cancelButtonText: '取消',type: 'warning'}).then(() => {
  657. that.table_loading = true;
  658. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-goods.batch-update-stay') !!}").then(response => {
  659. console.log(response);
  660. if(response.data.result==1){
  661. that.$message.success('队列生成成功!');
  662. that.is_all_choose = 0;
  663. // that.search(1);
  664. }
  665. else{
  666. that.$message.error(response.data.msg);
  667. }
  668. that.table_loading = false;
  669. }),function(res){
  670. console.log(res);
  671. that.table_loading = false;
  672. };
  673. }).catch(() => {
  674. this.$message({type: 'info',message: '已取消'});
  675. });
  676. }
  677. }),function(res){
  678. console.log(res);
  679. };
  680. },
  681. // 字符转义
  682. escapeHTML(a) {
  683. a = "" + a;
  684. return a.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&apos;/g, "'");;
  685. },
  686. },
  687. })
  688. </script>
  689. @endsection