goods.blade.php 45 KB

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