extend-index.blade.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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="rightlist-head">
  11. <div style="margin-left:10px;font-size:16px;display:inline-block">
  12. 商品列表
  13. </div>
  14. <a href="{{yzWebUrl('plugin.electricity-bill-pro.backend.goods.create')}}">
  15. <el-button icon="el-icon-plus" type="primary" size="small">发布商品</el-button>
  16. </a>
  17. </div>
  18. <div class="third-list">
  19. <div class="form-list">
  20. <el-form :inline="true" :model="search_form" ref="search_form" style="margin-left:10px;">
  21. <el-row>
  22. <el-form-item label="" prop="">
  23. <el-select v-model="search_form.status" placeholder="请选择商品状态" clearable>
  24. <el-option v-for="item in status_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="" prop="">
  28. <el-select v-model="search_form.sell_stock" placeholder="请选择售中库存" clearable>
  29. <el-option v-for="item in sell_stock_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-select v-model="search_form.id_v1" placeholder="请选择一级分类" clearable @change="changeV1()">
  34. <el-option v-for="item in category_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item>
  38. <el-select v-model="search_form.id_v2" placeholder="请选择二级分类" clearable @change="changeV2()">
  39. <el-option v-for="item in category_list_v2" :key="item.id" :label="item.name" :value="item.id"></el-option>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item>
  43. <el-select v-model="search_form.id_v3" placeholder="请选择三级分类" clearable v-if="catlevel==3">
  44. <el-option v-for="item in category_list_v3" :key="item.id" :label="item.name" :value="item.id"></el-option>
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="" prop="">
  48. <el-select v-model="search_form.brand_id" placeholder="请选择品牌" clearable>
  49. <el-option v-for="item in brands_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item label="" prop="keyword">
  53. <el-input v-model="search_form.keyword" placeholder="请输入商品ID或关键字"></el-input>
  54. </el-form-item>
  55. <el-form-item label="价格区间" prop="">
  56. <el-input v-model="search_form.min_price" placeholder="最低价" style="width:150px;"></el-input>
  57. <el-input v-model="search_form.max_price" placeholder="最高价" style="width:150px;"></el-input>
  58. </el-form-item>
  59. <el-form-item label="商品类型" prop="leader_name">
  60. <el-checkbox v-model.number="search_form.is_new" :true-label="1" :false-label="0">新品</el-checkbox>
  61. <el-checkbox v-model.number="search_form.is_hot" :true-label="1" :false-label="0">热卖</el-checkbox>
  62. <el-checkbox v-model.number="search_form.is_recommand" :true-label="1" :false-label="0">推荐</el-checkbox>
  63. <el-checkbox v-model.number="search_form.is_discount" :true-label="1" :false-label="0">促销</el-checkbox>
  64. </el-form-item>
  65. <a href="#">
  66. <el-button type="primary" icon="el-icon-search" @click="search(1)">搜索</el-button>
  67. </a>
  68. </el-col>
  69. </el-row>
  70. </el-form>
  71. </div>
  72. <div class="table-list">
  73. <div style="margin-left:10px;">
  74. <el-checkbox v-model.number="is_all_choose" :true-label="1" :false-label="0" @change="allChoose">[[is_all_choose==1?'全不选':'全选']]</el-checkbox>
  75. <el-button size="small" @click="batchPutAway(1)">批量上架</el-button>
  76. <el-button size="small" @click="batchPutAway(0)">批量下架</el-button>
  77. <el-button size="small" @click="batchDestroy">批量删除</el-button>
  78. </div>
  79. <div>
  80. <template>
  81. <!-- 表格start -->
  82. <el-table :data="goods_list" style="width: 100%" :class="table_loading==true?'loading-height':''" v-loading="table_loading">
  83. <el-table-column prop="id" label="选择" width="60" align="center">
  84. <template slot-scope="scope">
  85. <el-checkbox v-model.number="scope.row.is_choose" :true-label="1" :false-label="0" @change="oneChange(scope.row)"></el-checkbox>
  86. </template>
  87. </el-table-column>
  88. <el-table-column prop="id" label="ID" width="70" align="center"></el-table-column>
  89. </el-table-column>
  90. <el-table-column prop="member_name" label="排序" max-width="80" align="center">
  91. <template slot-scope="scope">
  92. <el-popover class="item" placement="top" effect="light">
  93. <div style="text-align:center;">
  94. <el-input v-model="change_sort" size="small" style="width:100px;"></el-input>
  95. <el-button size="small" @click="confirmChangeSort(scope.row.id)">确定</el-button>
  96. </div>
  97. <a slot="reference" >
  98. <i class="el-icon-edit edit-i" title="点击编辑排序" @click="editTitle(scope.$index,'sort')"></i>
  99. </a>
  100. </el-popover>
  101. [[scope.row.display_order]]
  102. </template>
  103. </el-table-column>
  104. <el-table-column prop="total" label="商品" width="60" align="center">
  105. <template slot-scope="scope">
  106. <img :src="scope.row.thumb" style="width:50px;height:50px;">
  107. </template>
  108. </el-table-column>
  109. <el-table-column prop="down_time" label="" min-width="180" align="left" class="edit-cell">
  110. <template slot-scope="scope">
  111. <el-popover class="item" placement="top" effect="light">
  112. <div style="text-align:center;">
  113. <div style="text-align:left;margin-bottom:10px;font-weight:900">修改商品标题</div>
  114. <el-input v-model="change_title" style="width:400px" size="small"></el-input>
  115. <el-button size="small" @click="confirmChange(scope.row.id,'title')">确定</el-button>
  116. </div>
  117. <a slot="reference">
  118. <i class="el-icon-edit edit-i" title="点击编辑" @click="editTitle(scope.$index,'title')"></i>
  119. </a>
  120. </el-popover>
  121. [[scope.row.title]]
  122. </template>
  123. </el-table-column>
  124. <el-table-column prop="member_num" label="价格" max-width="80" align="center">
  125. <template slot-scope="scope">
  126. <el-popover class="item" placement="top" effect="light" :disabled="scope.row.has_option==1">
  127. <div style="text-align:center;">
  128. <el-input v-model="change_price" size="small" style="width:100px;"></el-input>
  129. <el-button size="small" @click="confirmChange(scope.row.id,'price')">确定</el-button>
  130. </div>
  131. <a slot="reference" >
  132. <i class="el-icon-edit edit-i" :title="scope.row.has_option==1?'多规格不支持快速修改':'点击编辑'" @click="editTitle(scope.$index,'price')"></i>
  133. </a>
  134. </el-popover>
  135. ¥[[scope.row.price]]
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="库存" align="center" max-width="80">
  139. <template slot-scope="scope">
  140. <el-popover class="item" placement="top" effect="light" :disabled="scope.row.has_option==1">
  141. <div style="text-align:center;">
  142. <el-input v-model="change_stock" size="small" style="width:100px;"></el-input>
  143. <el-button size="small" @click="confirmChange(scope.row.id,'stock')">确定</el-button>
  144. </div>
  145. <a slot="reference" >
  146. <i class="el-icon-edit edit-i" :title="scope.row.has_option==1?'多规格不支持快速修改':'点击编辑'" @click="editTitle(scope.$index,'stock')"></i>
  147. </a>
  148. </el-popover>
  149. [[scope.row.stock]]
  150. </template>
  151. </el-table-column>
  152. <el-table-column prop="real_sales" label="销量" width="70" align="center"></el-table-column>
  153. <el-table-column label="状态" prop="status_message" align="center">
  154. <template slot-scope="scope">
  155. [[scope.row.status?'上架':'下架']]
  156. <el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" @change="putAway(scope.row.id,scope.$index)"></el-switch>
  157. </template>
  158. </el-table-column>
  159. <el-table-column label="操作" width="300" align="center">
  160. <template slot-scope="scope">
  161. <div class="table-option">
  162. <el-popover class="item" placement="left" effect="light"
  163. trigger="hover">
  164. <div style="text-align:center;">
  165. <img :src="smallImg" alt=""
  166. style="margin:10px;width:100px;height:100px;">
  167. </div>
  168. <a slot="reference" @mouseover="SmallCode(scope.$index)" :href="'{{ yzWebFullUrl('goods.goods.generate-small-code', array('id' => '')) }}'+[[scope.row.id]]">小程序</a>
  169. </el-popover>&nbsp;&nbsp;
  170. <el-popover class="item" placement="left" effect="light" trigger="hover">
  171. <div style="text-align:center;">
  172. <img :src="img" alt="" style="margin:10px;width:100px;height:100px;">
  173. </div>
  174. <a slot="reference" @mouseover="listCode(scope.$index)">推广链接</a>
  175. </el-popover>&nbsp;&nbsp;
  176. <a :href="'{{ yzWebFullUrl('plugin.electricity-bill-pro.backend.goods.copy', array('id' => '')) }}'+[[scope.row.id]]">
  177. 复制商品
  178. </a>
  179. &nbsp;&nbsp;
  180. <a :href="'{{ yzWebFullUrl('plugin.electricity-bill-pro.backend.goods.edit', array('id' => '')) }}'+[[scope.row.id]]">
  181. 编辑
  182. </a>&nbsp;&nbsp;
  183. <a @click="delOne(scope.row.id)">
  184. 删除
  185. </a>&nbsp;&nbsp;
  186. <a @click="copyList(scope.row.id)">
  187. 复制链接
  188. </a>
  189. <div>
  190. <input v-model="scope.row.link" :ref="'list'+scope.row.id" style="position:absolute;opacity:0;height:1px;" />
  191. </div>
  192. </div>
  193. <div>
  194. <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>
  195. <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>
  196. <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>
  197. <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>
  198. </div>
  199. </template>
  200. </el-table-column>
  201. </el-table>
  202. <!-- 表格end -->
  203. </template>
  204. </div>
  205. </div>
  206. </div>
  207. <!-- 分页 -->
  208. <div class="vue-page" v-show="total>1">
  209. <el-row>
  210. <el-col align="right">
  211. <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>
  212. </el-col>
  213. </el-row>
  214. </div>
  215. </div>
  216. </template>
  217. </div>
  218. <script src="{{resource_get('static/js/qrcode.min.js')}}"></script>
  219. <script>
  220. var app = new Vue({
  221. el:"#app",
  222. delimiters: ['[[', ']]'],
  223. data() {
  224. return{
  225. id:"",
  226. img:"",//二维码
  227. smallImg:"",//小程序二维码
  228. catlevel:0,//是否显示三级分类
  229. is_all_choose:0,//是否全选
  230. goods_list:[],//商品列表
  231. change_title:"",//修改标题弹框赋值
  232. change_price:"",//修改价格弹框赋值
  233. change_stock:"",//修改库存弹框赋值
  234. change_sort:"",//修改排序弹框赋值
  235. all_loading:false,
  236. status_list:[
  237. {id:'',name:'全部状态'},
  238. {id:0,name:'下架'},
  239. {id:1,name:'上架'},
  240. ],
  241. sell_stock_list:[
  242. {id:'',name:'全部'},
  243. {id:0,name:'售罄'},
  244. {id:1,name:'出售中'},
  245. ],
  246. brands_list:[],//品牌名称
  247. category_list:[],
  248. category_list_v2:[],
  249. category_list_v3:[],
  250. search_form:{
  251. id_v1:'',
  252. id_v2:'',
  253. id_v3:''
  254. },
  255. form:{},
  256. level_list:[],
  257. loading:false,
  258. table_loading:false,
  259. rules:{},
  260. //分页
  261. total:0,
  262. per_size:0,
  263. current_page:0,
  264. rules:{},
  265. }
  266. },
  267. created() {
  268. let that = this;
  269. this.getData();
  270. document.onkeydown = function(){
  271. if(window.event.keyCode == 13)
  272. that.search(1);
  273. }
  274. },
  275. methods: {
  276. getData() {
  277. var that = this;
  278. that.table_loading = true;
  279. that.$http.post("{!! yzWebFullUrl('plugin.electricity-bill-pro.backend.goods.goods-list') !!}").then(response => {
  280. console.log(response);
  281. if(response.data.result==1){
  282. that.goods_list = response.data.data.list.data;
  283. let arr =[];
  284. that.goods_list.forEach((item,index) => {
  285. item.title = that.escapeHTML(item.title)
  286. arr.push(Object.assign({},item,{is_choose:0}))//是否选中
  287. });
  288. that.goods_list=arr;
  289. that.total = response.data.data.list.total;
  290. that.current_page = response.data.data.list.current_page;
  291. that.per_size = response.data.data.list.per_page;
  292. that.brands_list = response.data.data.brands;
  293. that.category_list = response.data.data.catetory_menus.ids;
  294. that.catlevel = response.data.data.catetory_menus.catlevel;
  295. console.log(that.goods_list);
  296. }
  297. else{
  298. that.$message.error(response.data.msg);
  299. }
  300. that.table_loading = false;
  301. }),function(res){
  302. console.log(res);
  303. that.table_loading = false;
  304. };
  305. },
  306. // 一级分类改变
  307. changeV1(){
  308. this.search_form.id_v2 = "";
  309. this.search_form.id_v3 = "";
  310. this.category_list_v2 = [];
  311. this.category_list_v3 = [];
  312. this.category_list.find(item => {
  313. if(item.id == this.search_form.id_v1) {
  314. this.category_list_v2 = item.childrens;
  315. }
  316. });
  317. },
  318. // 二级分类改变
  319. changeV2(){
  320. this.search_form.id_v3 = "";
  321. this.category_list_v3 = [];
  322. if(this.catlevel==3) {
  323. this.category_list_v2.find(item => {
  324. if(item.id == this.search_form.id_v2) {
  325. this.category_list_v3 = item.childrens;
  326. }
  327. })
  328. }
  329. },
  330. // 搜索、分页
  331. search(page) {
  332. var that = this;
  333. console.log(that.search_form)
  334. // 商品类型
  335. let product_attr = [];
  336. if(that.search_form.is_new == 1){
  337. product_attr.push('is_new')
  338. }
  339. if(that.search_form.is_hot == 1){
  340. product_attr.push('is_hot')
  341. }
  342. if(that.search_form.is_recommand == 1){
  343. product_attr.push('is_recommand')
  344. }
  345. if(that.search_form.is_discount == 1){
  346. product_attr.push('is_discount')
  347. }
  348. let json = {
  349. page:page,
  350. search:{
  351. keyword:that.search_form.keyword,
  352. status:that.search_form.status,
  353. sell_stock:that.search_form.sell_stock,
  354. brand_id:that.search_form.brand_id,
  355. min_price:that.search_form.min_price,
  356. max_price:that.search_form.max_price,
  357. product_attr:product_attr,//商品类型
  358. },
  359. category:{
  360. parentid:that.search_form.id_v1,
  361. childid:that.search_form.id_v2,
  362. thirdid:that.search_form.id_v3,
  363. }
  364. };
  365. that.table_loading = true;
  366. that.$http.post("{!! yzWebFullUrl('plugin.electricity-bill-pro.backend.goods.goods-search') !!}",json).then(response => {
  367. console.log(response);
  368. if(response.data.result==1){
  369. let arr = [];
  370. that.goods_list = response.data.data.data;
  371. that.goods_list.forEach((item,index) => {
  372. item.title = that.escapeHTML(item.title)
  373. arr.push(Object.assign({},item,{is_choose:0}))//是否选中
  374. });
  375. that.goods_list=arr;
  376. that.total = response.data.data.total;
  377. that.current_page = response.data.data.current_page;
  378. that.per_size = response.data.data.per_page;
  379. }
  380. else{
  381. that.$message.error(response.data.msg);
  382. }
  383. that.table_loading = false;
  384. }),function(res){
  385. console.log(res);
  386. that.table_loading = false;
  387. };
  388. },
  389. qrcodeScan (url) {//生成二维码
  390. let qrcode = new QRCode('qrcode', {
  391. width: 100, // 二维码宽度
  392. height: 100, // 二维码高度
  393. render: 'image',
  394. text: url
  395. });
  396. var data = $("canvas")[$("canvas").length-1].toDataURL().replace("image/png", "image/octet-stream;");
  397. console.log(data)
  398. this.img = data;
  399. },
  400. // 活动二维码
  401. listCode(index) {
  402. this.qrcodeScan(this.goods_list[index].link);
  403. },
  404. // 小程序二维码
  405. SmallCode(index) {
  406. this.smallImg = this.goods_list[index].small_link;
  407. },
  408. // 复制活动链接
  409. copyList(index) {
  410. that = this;
  411. let Url = that.$refs['list'+index];
  412. console.log(Url)
  413. Url.select(); // 选择对象
  414. document.execCommand("Copy",false);
  415. that.$message({message:"复制成功!",type:"success"});
  416. },
  417. // 单个选择
  418. oneChange(item) {
  419. let that = this;
  420. let is_all = 0;
  421. that.goods_list.some((item,index) => {
  422. if(item.is_choose == 1) {
  423. is_all = 1;
  424. }
  425. else {
  426. is_all = 0;
  427. return true;
  428. }
  429. })
  430. that.is_all_choose = is_all;
  431. },
  432. // 全选
  433. allChoose() {
  434. let that = this;
  435. let status = 0;
  436. if(that.is_all_choose == 1){
  437. status = 1;
  438. }
  439. else{
  440. status = 0;
  441. }
  442. that.goods_list.forEach((item,index) => {
  443. item.is_choose = status;
  444. })
  445. },
  446. // 上架、下架
  447. putAway(id,index) {
  448. var that = this;
  449. that.table_loading = true;
  450. let data = that.goods_list[index].status;
  451. let json = {id:id,type:'status',data:data};
  452. that.$http.post("{!! yzWebFullUrl('goods.goods.setPutaway') !!}",json).then(response => {
  453. console.log(response);
  454. if(response.data.result==1){
  455. that.$message.success('操作成功!');
  456. }
  457. else{
  458. that.$message.error(response.data.msg);
  459. that.goods_list[index].is_choose == 1 ? 0 : 1;
  460. }
  461. that.table_loading = false;
  462. }),function(res){
  463. console.log(res);
  464. that.table_loading = false;
  465. };
  466. },
  467. // 批量上架、下架
  468. batchPutAway(data) {
  469. var that = this;
  470. that.table_loading = true;
  471. let ids = [];
  472. that.goods_list.forEach((item,index) => {
  473. if(item.is_choose == 1){
  474. ids.push(item.id);
  475. }
  476. })
  477. let json = {data:data,ids:ids}
  478. that.$http.post("{!! yzWebFullUrl('goods.goods.batchSetProperty') !!}",json).then(response => {
  479. console.log(response);
  480. if(response.data.result==1){
  481. that.$message.success('操作成功!');
  482. that.is_all_choose = 0;
  483. that.search(1);
  484. }
  485. else{
  486. that.$message.error(response.data.msg);
  487. }
  488. that.table_loading = false;
  489. }),function(res){
  490. console.log(res);
  491. that.table_loading = false;
  492. };
  493. },
  494. // 单个删除
  495. delOne(id) {
  496. var that = this;
  497. that.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  498. that.table_loading = true;
  499. that.$http.post("{!! yzWebFullUrl('plugin.electricity-bill-pro.backend.goods.destroy') !!}",{id:id}).then(response => {
  500. console.log(response);
  501. if(response.data.result==1){
  502. that.$message.success("删除成功!");
  503. that.search(1);
  504. }
  505. else{
  506. that.$message.error(response.data);
  507. }
  508. that.table_loading = false;
  509. }),function(res){
  510. console.log(res);
  511. that.table_loading = false;
  512. };
  513. }).catch(() => {
  514. this.$message({type: 'info',message: '已取消修改'});
  515. });
  516. },
  517. // 批量删除
  518. batchDestroy() {
  519. var that = this;
  520. that.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  521. that.table_loading = true;
  522. let ids = [];
  523. that.goods_list.forEach((item,index) => {
  524. if(item.is_choose == 1){
  525. ids.push(item.id);
  526. }
  527. })
  528. let json = {ids:ids}
  529. that.$http.post("{!! yzWebFullUrl('goods.goods.batchDestroy') !!}",json).then(response => {
  530. console.log(response);
  531. if(response.data.result==1){
  532. that.$message.success('操作成功!');
  533. that.is_all_choose = 0;
  534. that.search(1);
  535. }
  536. else{
  537. that.$message.error(response.data.msg);
  538. }
  539. that.table_loading = false;
  540. }),function(res){
  541. console.log(res);
  542. that.table_loading = false;
  543. };
  544. }).catch(() => {
  545. this.$message({type: 'info',message: '已取消修改'});
  546. });
  547. },
  548. // 新品、热卖、推荐、促销、
  549. setProperty(id,index,type) {
  550. var that = this;
  551. that.table_loading = true;
  552. console.log(that.goods_list[index][type])
  553. let data = that.goods_list[index][type];
  554. let json = {id:id,type:type,data:data};
  555. that.$http.post("{!! yzWebFullUrl('goods.goods.setProperty') !!}",json).then(response => {
  556. console.log(response);
  557. if(response.data.result==1){
  558. that.$message.success('操作成功!');
  559. }
  560. else{
  561. that.$message.error(response.data.msg);
  562. that.goods_list[index][type] == 1 ? 0 : 1;
  563. }
  564. that.table_loading = false;
  565. }),function(res){
  566. console.log(res);
  567. that.table_loading = false;
  568. };
  569. },
  570. // 编辑商品标题
  571. editTitle(index,type) {
  572. let that = this;
  573. if(type == 'title') {
  574. that.change_title = "";
  575. that.change_title = that.goods_list[index].title;
  576. }
  577. if(type == 'price') {
  578. if(that.goods_list[index].has_option == 1) {
  579. that.$message.error('多规格不支持快速修改');
  580. return false;
  581. }
  582. that.change_price = "";
  583. that.change_price = that.goods_list[index].price;
  584. }
  585. if(type == 'stock') {
  586. if(that.goods_list[index].has_option == 1) {
  587. that.$message.error('多规格不支持快速修改');
  588. return false;
  589. }
  590. that.change_stock = "";
  591. that.change_stock = that.goods_list[index].stock;
  592. }
  593. if(type == 'sort') {
  594. that.change_sort = "";
  595. that.change_sort = that.goods_list[index].display_order;
  596. }
  597. },
  598. // 确认修改标题、价格、库存
  599. confirmChange(id,type) {
  600. let that = this;
  601. let value = '';
  602. if(type == 'title'){
  603. value = that.change_title;
  604. if(that.change_title == ''){
  605. that.$message.error('标题不能为空');
  606. return false;
  607. }
  608. }
  609. if(type == 'price'){
  610. value = that.change_price;
  611. if(!(/^\d+(\.\d+)?$/.test(that.change_price))){
  612. that.$message.error('请输入正确价格');
  613. return false;
  614. }
  615. }
  616. if(type == 'stock'){
  617. value = that.change_stock;
  618. if(!(/^\d+$/.test(that.change_stock))){
  619. that.$message.error('请输入正确数字');
  620. return false;
  621. }
  622. }
  623. let json = {
  624. id:id,
  625. type:type,
  626. value:value,
  627. };
  628. that.table_loading = true;
  629. that.$http.post("{!! yzWebFullUrl('goods.goods.change') !!}",json).then(response => {
  630. console.log(response);
  631. if(response.data.result==1){
  632. that.$message.success('操作成功!');
  633. if (document.all) {
  634. document.getElementById('app').click();
  635. }
  636. else {// 其它浏览器
  637. var e = document.createEvent('MouseEvents')
  638. e.initEvent('click', true, true)
  639. document.getElementById('app').dispatchEvent(e)
  640. }
  641. that.search(1);
  642. }
  643. else{
  644. that.$message.error(response.data.msg);
  645. }
  646. that.table_loading = false;
  647. }),function(res){
  648. console.log(res);
  649. that.table_loading = false;
  650. };
  651. },
  652. // 确认修改排序
  653. confirmChangeSort(id) {
  654. let that = this;
  655. if(!(/^\d+$/.test(that.change_sort))){
  656. that.$message.error('请输入正确数字');
  657. return false;
  658. }
  659. that.table_loading = true;
  660. let json = {id:id,value:that.change_sort};
  661. that.$http.post("{!! yzWebFullUrl('goods.goods.displayorder') !!}",json).then(response => {
  662. console.log(response);
  663. if(response.data.result==1){
  664. that.$message.success('操作成功!');
  665. // that.$refs.search_form.click();
  666. if (document.all) {
  667. document.getElementById('app').click();
  668. }
  669. else {// 其它浏览器
  670. var e = document.createEvent('MouseEvents')
  671. e.initEvent('click', true, true)
  672. document.getElementById('app').dispatchEvent(e)
  673. }
  674. that.search(1);
  675. }
  676. else{
  677. that.$message.error(response.data.msg);
  678. }
  679. that.table_loading = false;
  680. }),function(res){
  681. console.log(res);
  682. that.table_loading = false;
  683. };
  684. },
  685. // 字符转义
  686. escapeHTML(a) {
  687. a = "" + a;
  688. return a.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&apos;/g, "'");;
  689. },
  690. },
  691. })
  692. </script>
  693. @endsection