card.blade.php 40 KB

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