card.blade.php 40 KB

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