extend-index.blade.php 37 KB

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