index.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. <?php
  2. use common\helpers\AddonHelper;
  3. use common\helpers\ComponentHelper;
  4. ComponentHelper::loadComponentView('com-export-dialog');
  5. if (!empty($pay_success_jump_component)) {
  6. ComponentHelper::loadComponentView(
  7. 'pay-success-select-jump-url',
  8. AddonHelper::getAddonRootPath('PaySuccessJump') . 'backend/views/components'
  9. );
  10. }
  11. ?>
  12. <style>
  13. </style>
  14. <div id="app" v-cloak>
  15. <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  16. <div slot="header">
  17. <span>商品列表</span>
  18. <div style="float: right; margin: -5px 0">
  19. <el-button type="primary" size="small" @click="handle('edit')">添加商品</el-button>
  20. <!-- <el-button v-if="synchronize_goods_dialog > 0" type="primary" size="small" @click="syncGoods">同步商品</el-button>
  21. <el-button class="all_button" type="primary" size="small" @click="importGoods" >批量导入</el-button>
  22. <com-export-dialog
  23. style="float: right;margin-left: 10px;"
  24. :field_list='export_list'
  25. :action_url="export_url"
  26. :params="search_data">
  27. </com-export-dialog> -->
  28. <!-- <com-export-dialog-->
  29. <!-- style="float: right;margin-left: 10px;"-->
  30. <!-- :field_list='export_list'-->
  31. <!-- :action_url="export_url"-->
  32. <!-- :params="search_data">-->
  33. <!-- </com-export-dialog>-->
  34. </div>
  35. </div>
  36. <div class="table-body">
  37. <el-tabs v-model="activeName" @tab-click="handleClick">
  38. <el-tab-pane v-for="item in tabs" :key="item.value" :label="item.name" :name="item.value">
  39. <el-form :inline="true" :model="search_data" size="small" class="demo-form-inline">
  40. <!-- <el-form-item>
  41. <el-button size="small" @click="$refs.cats.openDialog()">分类筛选</el-button>
  42. <el-button size="small" v-if="search_data.cats && search_data.cats.length > 0" type="danger" @click="clearCat">清除分类</el-button>
  43. </el-form-item> -->
  44. <el-form-item>
  45. <el-date-picker style="margin-top: 1px;" size="small" @change="changeTime"
  46. v-model="datetime" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss"
  47. range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
  48. :default-time="['00:00:00', '23:59:59']"></el-date-picker>
  49. </el-form-item>
  50. <el-form-item label="">
  51. <el-input size="small" placeholder="请输入商品名称"
  52. v-model="search_data.goods_name"></el-input>
  53. </el-form-item>
  54. <el-form-item label="">
  55. <el-input size="small" placeholder="请输入商品ID精准搜索"
  56. v-model="search_data.goods_id"></el-input>
  57. </el-form-item>
  58. <!-- <el-form-item label="">
  59. <el-select size="small" v-model="search_data.goods_type" placeholder="请选择商品类型" style="width: 100%;" clearable>
  60. <el-option label="实体商品" :value="1"></el-option>
  61. <el-option label="虚拟商品" :value="2"></el-option>
  62. <el-option label="预约商品" :value="3"></el-option>
  63. </el-select>
  64. </el-form-item> -->
  65. <el-form-item>
  66. <el-button type="primary" @click="search">搜索</el-button>
  67. <el-button type="primary" @click="multipleOff">批量下架</el-button>
  68. <el-button type="primary" @click="multipleOn">批量上架</el-button>
  69. <el-button type="danger" @click="clearSearch" v-if="show_clear_search_btn">清除条件
  70. </el-button>
  71. </el-form-item>
  72. </el-form>
  73. <el-table v-loading="listLoading" :data="list" stripe style="width: 100%" @sort-change="sortChange"
  74. @selection-change="handleSelectionChange">
  75. <el-table-column v-if="item.value=='all'" type="selection" align="center"
  76. :selectable="checkSelectable"></el-table-column>
  77. <el-table-column label="ID" prop="id" align="center"></el-table-column>
  78. <el-table-column label="商品名称" min-width="200" prop="goods_name" align="center">
  79. <template slot-scope="scope">
  80. <div flex="cross:center">
  81. <div style="margin-right: 10px;">
  82. <el-image style="width: 50px; height: 50px;border-radius: 5px;"
  83. :src="scope.row.cover_pic"></el-image>
  84. </div>
  85. <div v-if="goods_name_id != scope.row.id">
  86. <el-tooltip class="item" effect="dark" content="商品名称" placement="top">
  87. <span>{{scope.row.goods_name}}</span>
  88. </el-tooltip>
  89. <el-button class="edit-sort" type="text" @click="edit(scope.row,'goods_name')">
  90. <img src="resources/img/mall/order/edit.png" alt="">
  91. </el-button>
  92. </div>
  93. <div style="display: flex;align-items: center" v-else>
  94. <el-input style="min-width: 70px" size="mini" class="change"
  95. v-model="goods_name" autocomplete="off"></el-input>
  96. <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px"
  97. icon="el-icon-error" circle
  98. @click="cancelEdit('goods_name')"></el-button>
  99. <el-button class="change-success" type="text"
  100. style="margin-left: 0;color: #67C23A;padding: 0 5px"
  101. icon="el-icon-success" circle
  102. @click="handle('goods_name',scope.row)">
  103. </el-button>
  104. </div>
  105. </div>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="分类" align="center">
  109. <template slot-scope="scope">
  110. <div class="goods-cat">
  111. <el-tag v-if="scope.row.cats && scope.row.cats.length > 0" size="mini">
  112. {{scope.row.cats[0].name}}
  113. </el-tag>
  114. <el-tooltip v-if="scope.row.cats && scope.row.cats.length > 1" placement="top">
  115. <div slot="content">
  116. <span v-for="item in scope.row.cats"
  117. :key="item.id">{{item.name}}&nbsp;</span>
  118. </div>
  119. <span>...</span>
  120. </el-tooltip>
  121. </div>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="售价" prop="price" align="center" sortable="false">
  125. <template slot-scope="scope">
  126. <div size="small">{{scope.row.price}}</div>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="库存" prop="stock" align="center" sortable="false">
  130. <template slot-scope="scope">
  131. <div size="small" style="color: red;" v-if="scope.row.stock<=scope.row.stock_warning">
  132. {{scope.row.stock}}
  133. </div>
  134. <div size="small" v-else>{{scope.row.stock}}</div>
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="商品标签" prop="label_name" align="center" sortable="false"
  138. min-width="100">
  139. <template slot-scope="scope">
  140. <div size="small">{{scope.row.label_name}}</div>
  141. </template>
  142. </el-table-column>
  143. <el-table-column label="最高盈利" prop="max_income" align="center" sortable="false"
  144. min-width="100">
  145. <template slot-scope="scope">
  146. <div size="small">{{scope.row.max_income}}</div>
  147. </template>
  148. </el-table-column>
  149. <el-table-column label="状态" prop="is_on_sale" align="center">
  150. <template slot-scope="scope">
  151. <el-switch
  152. v-model="scope.row.is_on_sale"
  153. :active-value="1"
  154. :inactive-value="0"
  155. @change="handle('is_on_sale', scope.row)"
  156. >
  157. </el-switch>
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="来源" prop="goods_source" align="center">
  161. <template slot-scope="scope">
  162. <el-tag size="mini" :type="scope.row.goods_source == '' ? 'success' : 'danger'">
  163. {{scope.row.goods_source == '' ? '自营' : '供应链'}}
  164. </el-tag>
  165. </template>
  166. </el-table-column>
  167. <el-table-column label="创建时间" width="160" prop="created_at" align="center">
  168. <template slot-scope="scope">
  169. <div size="small">{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
  170. </template>
  171. </el-table-column>
  172. <el-table-column label="操作" min-width="300" align="center">
  173. <template slot-scope="scope">
  174. <template>
  175. <el-button type="text" @click="handle('ship',scope.row)">编辑</el-button>
  176. <el-button type="text" @click="handle('moveGoods',scope.row)">申请调货</el-button>
  177. <el-button type="text" @click="handle('destroy',scope.row)">删除</el-button>
  178. </template>
  179. </template>
  180. </el-table-column>
  181. </el-table>
  182. <div style="text-align: right;margin: 20px 0;">
  183. <el-pagination @current-change="pagination" background layout="prev, pager, next"
  184. :page-count="pageCount"></el-pagination>
  185. </div>
  186. </el-tab-pane>
  187. </el-tabs>
  188. </div>
  189. </el-card>
  190. <el-dialog title="调货申请" :visible.sync="moveGoodsDialog" width="50%" v-if="moveGoodsForm.length>0">
  191. <el-form ref="moveGoodsForm" label-width="80px">
  192. <el-table :data="moveGoodsForm" v-if="moveGoodsForm.length>0">
  193. <el-table-column label="商品规格ID">
  194. <template slot-scope="scope">
  195. <span>{{scope.row.attr_id}}</span>
  196. </template>
  197. </el-table-column>
  198. <el-table-column label="商品名称">
  199. <template slot-scope="scope">
  200. <span>{{scope.row.name}}</span>
  201. </template>
  202. </el-table-column>
  203. <el-table-column label="当前库存">
  204. <template slot-scope="scope">
  205. <span>{{scope.row.stock}}</span>
  206. </template>
  207. </el-table-column>
  208. <el-table-column label="调货中的数量">
  209. <template slot-scope="scope">
  210. <span>{{scope.row.apply_num}}</span>
  211. </template>
  212. </el-table-column>
  213. <el-table-column label="调货数量">
  214. <template slot-scope="scope">
  215. <el-input-number size="small" :min="0" v-model="scope.row.move_num"></el-input-number>
  216. </template>
  217. </el-table-column>
  218. </el-table>
  219. <div style="text-align: center;margin-top: 20px">
  220. <el-button size="small" @click="moveGoodsDialog = false">取消</el-button>
  221. <el-button size="small" type="primary" @click="handle('moveGoodsSubmit')">确定</el-button>
  222. </div>
  223. </el-form>
  224. </el-dialog>
  225. <el-dialog title="编辑商品" width="300px" :visible.sync="goodsEditVisible" append-to-body>
  226. <el-form :inline="true" size="small" label-width="200px">
  227. <el-form-item label="配送方式">
  228. <el-checkbox-group v-model="goodsEdit.freight_type">
  229. <el-checkbox v-for="(item,index) in freight_type" :key="item" :label="item">
  230. {{freight_type_name[item]}}
  231. </el-checkbox>
  232. </el-checkbox-group>
  233. </el-form-item>
  234. </el-form>
  235. <span slot="footer" class="dialog-footer">
  236. <el-button @click="goodsEditVisible = false" type="default" size="small">取消</el-button>
  237. <el-button type="primary" :loading="btnLoading" style="margin-bottom: 10px;" size="small"
  238. @click="handle('saveShip',goodsEdit)">保存</el-button>
  239. </span>
  240. </el-dialog>
  241. </div>
  242. <script>
  243. const app = new Vue({
  244. el: '#app',
  245. props: {
  246. import_store_goods_url: {
  247. type: String,
  248. default: 'store/client/goods/import-store-goods'
  249. },
  250. },
  251. data() {
  252. return {
  253. goodsEditVisible: false,
  254. goodsEdit: {},
  255. goods_name: '',
  256. goods_id: '',
  257. tabs: [{
  258. name: '全部',
  259. value: 'all'
  260. },
  261. {
  262. name: '销售中',
  263. value: 'onsale'
  264. },
  265. {
  266. name: '下架中',
  267. value: 'offline'
  268. },
  269. {
  270. name: '售罄',
  271. value: 'sell-out'
  272. },
  273. ],
  274. activeName: 'all',
  275. list: [],
  276. listLoading: false,
  277. page: 1,
  278. pageCount: 0,
  279. mch_id: 0, // 这个地方不知道要怎么获取
  280. searchCats: [],
  281. datetime: [],
  282. search_data: { // 筛选条件
  283. type: null,
  284. cats: [],
  285. start: null,
  286. end: null,
  287. goods_id: null,
  288. goods_name: null,
  289. goods_type: null,
  290. },
  291. sort: 0,
  292. sort_id: 0,
  293. goods_name_id: 0,
  294. export_url: 'store/client/goods/export-excel',
  295. export_list: {},
  296. group_buy_active_arr: {},
  297. selectedGoodIds: [],
  298. pay_success_jump: 0,
  299. paySuccessSelectJumpUrlDialogVisible: false,
  300. currentItem: {},
  301. synchronize_goods_dialog: 0,
  302. syncGoods2Store: false,
  303. syncGoods2StoreLoading: false,
  304. mchGoodsList: [],
  305. mchGoodsPageCount: 0,
  306. mchGoodsPage: 1,
  307. selectedRowIds: [],
  308. mchGoodsSearch: {
  309. name: '',
  310. goods_id: '',
  311. mch_id: '',
  312. mall_id: '',
  313. cats: []
  314. },
  315. btnLoading: false,
  316. mchList: [],
  317. mallList: [],
  318. sign: '',
  319. moveGoodsDialog: false,
  320. moveGoodsForm: [],
  321. freight_type: [1, 2, 3],
  322. freight_type_name: ['','快递物流', '同城配送', '上门自提'],
  323. };
  324. },
  325. mounted: function () {
  326. this.getList();
  327. },
  328. computed: {
  329. show_clear_search_btn: function () {
  330. return !isEmpty(this.search_data.cats) || !isEmpty(this.search_data.start) ||
  331. !isEmpty(this.search_data.end) || !isEmpty(this.search_data.goods_id) ||
  332. !isEmpty(this.search_data.goods_name);
  333. }
  334. },
  335. created() {
  336. this.sign = getQuery('sign')
  337. },
  338. methods: {
  339. showMoveGoods(row) {
  340. this.moveGoodsDialog = true
  341. this.moveGoodsForm = []
  342. let self = this;
  343. self.goods_id = row.goods_id
  344. request({
  345. params: {
  346. r: 'happiness/client/goods/move-stock',
  347. goods_id: row.goods_id
  348. },
  349. method: 'get',
  350. }).then(e => {
  351. if (e.data.code == 0) {
  352. let data = e.data.data
  353. if (data.length > 0) {
  354. data.forEach(function (item) {
  355. self.moveGoodsForm.push({
  356. attr_id: item.attr.id,
  357. name: item.attr.name,
  358. move_num: item.move_num,
  359. stock: item.stock,
  360. apply_num: item.apply_num
  361. })
  362. })
  363. }
  364. } else {
  365. self.$message.error(e.data.msg);
  366. }
  367. }).catch(e => {
  368. console.log(e);
  369. });
  370. },
  371. submitMoveGoods() {
  372. let self = this;
  373. request({
  374. params: {
  375. r: 'happiness/client/goods/move-stock',
  376. },
  377. method: 'post',
  378. data: {
  379. attr: self.moveGoodsForm,
  380. goods_id: self.goods_id
  381. }
  382. }).then(e => {
  383. if (e.data.code == 0) {
  384. self.moveGoodsForm = e.data.data
  385. self.moveGoodsDialog = false
  386. self.$message.success(e.data.msg);
  387. } else {
  388. self.$message.error(e.data.msg);
  389. }
  390. }).catch(e => {
  391. console.log(e);
  392. });
  393. },
  394. importGoods() { //数据导入
  395. navigateTo({
  396. r: this.import_store_goods_url,
  397. page: this.page
  398. });
  399. },
  400. selectCat(arr) {
  401. this.search_data.cats = [];
  402. arr.forEach(it => this.search_data.cats.push(it.id))
  403. this.getList()
  404. },
  405. clearCat() { // 清除分类
  406. this.search_data.cats = []
  407. this.getList()
  408. },
  409. changeTime(e) {
  410. // console.log(e)
  411. this.search_data.start = e[0]
  412. this.search_data.end = e[1]
  413. },
  414. handleClick(res) { //标签页切换
  415. if (this.search_data.status == this.activeName) return;
  416. this.search_data.type = this.activeName;
  417. this.getList();
  418. },
  419. sortChange(row) {
  420. if (row.prop) {
  421. this.search_data.sort_field = row.prop;
  422. this.search_data.sort_type = row.order == "descending" ? 'desc' : 'asc';
  423. } else {
  424. this.search_data.sort_prop = null;
  425. this.search_data.sort_type = null;
  426. }
  427. this.getList();
  428. },
  429. search() {
  430. this.page = 1;
  431. this.getList();
  432. },
  433. clearSearch() {
  434. this.search_data.cats = [];
  435. this.search_data.start = null;
  436. this.search_data.end = null;
  437. this.search_data.goods_id = null;
  438. this.search_data.goods_name = null;
  439. this.datetime = [];
  440. this.getList();
  441. },
  442. handle(type, data = null) {
  443. let id = data ? parseInt(data.id) : '';
  444. switch (type) {
  445. case 'edit':
  446. let params = {
  447. r: 'happiness/client/goods/edit'
  448. };
  449. if (id) params = Object.assign(params, {
  450. id: id,
  451. });
  452. navigateTo(params);
  453. break;
  454. case 'destroy':
  455. param = {
  456. id: data.id,
  457. type
  458. };
  459. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {
  460. type: 'warning'
  461. }).then(() => {
  462. this.send(param)
  463. })
  464. break;
  465. case 'is_on_sale':
  466. param = {
  467. id: id,
  468. is_on_sale: data.is_on_sale,
  469. type
  470. };
  471. operate_type = data.is_on_sale == 0 ? '下架' : '上架';
  472. this.$confirm('是否' + operate_type + '该商品?', '警告', {
  473. type: 'warning'
  474. }).then(() => {
  475. this.send(param)
  476. })
  477. break;
  478. case 'moveGoods':
  479. this.showMoveGoods(data)
  480. break;
  481. case 'moveGoodsSubmit':
  482. this.submitMoveGoods()
  483. break;
  484. case 'ship':
  485. request({
  486. params: {
  487. r: 'happiness/client/goods/ship',
  488. id: id
  489. },
  490. method: 'get',
  491. }).then(e => {
  492. if (e.data.code == 0) {
  493. this.freight_type = e.data.data
  494. this.goodsEdit = {
  495. id: id,
  496. freight_type: data.freight_type,
  497. }
  498. this.goodsEditVisible = true
  499. }
  500. })
  501. break;
  502. case 'saveShip':
  503. this.btnLoading = true
  504. this.ship(this.goodsEdit)
  505. break;
  506. }
  507. this.cancelEdit(type);
  508. },
  509. ship(params) {
  510. let self = this;
  511. request({
  512. params: {
  513. r: 'happiness/client/goods/ship'
  514. },
  515. method: 'post',
  516. data: params
  517. }).then(e => {
  518. if (e.data.code == 0) {
  519. self.$message.success(e.data.msg);
  520. self.getList();
  521. this.btnLoading=false
  522. this.goodsEditVisible = false
  523. } else {
  524. self.$message.error(e.data.msg);
  525. this.btnLoading=false
  526. }
  527. }).catch(e => {
  528. console.log(e);
  529. });
  530. },
  531. send(params) {
  532. let self = this;
  533. request({
  534. params: {
  535. r: 'happiness/client/goods/index',
  536. },
  537. method: 'post',
  538. data: params
  539. }).then(e => {
  540. if (e.data.code == 0) {
  541. self.$message.success(e.data.msg);
  542. self.getList();
  543. } else {
  544. self.$message.error(e.data.msg);
  545. }
  546. }).catch(e => {
  547. console.log(e);
  548. });
  549. },
  550. edit(row, type) {
  551. switch (type) {
  552. case 'sort':
  553. this.sort = row.sort;
  554. this.sort_id = row.id;
  555. break;
  556. case 'goods_name':
  557. this.goods_name_id = row.id;
  558. this.goods_name = row.goods_name;
  559. break;
  560. }
  561. },
  562. cancelEdit(type) {
  563. switch (type) {
  564. case 'sort':
  565. this.sort = 0;
  566. this.sort_id = 0;
  567. break;
  568. case 'goods_name':
  569. this.goods_name = '';
  570. this.goods_name_id = 0;
  571. break;
  572. }
  573. },
  574. searchClick() {
  575. this.page = 1;
  576. this.getList();
  577. },
  578. pagination(currentPage) {
  579. let self = this;
  580. self.page = currentPage;
  581. self.getList();
  582. },
  583. // 获取商品列表
  584. getList() {
  585. let self = this;
  586. let basic_params = {
  587. r: 'happiness/client/goods/index',
  588. page: self.page,
  589. };
  590. params = Object.assign(basic_params, this.search_data);
  591. if (self.listLoading == false) {
  592. self.listLoading = true;
  593. request({
  594. params: params,
  595. method: 'get',
  596. }).then(e => {
  597. self.listLoading = false;
  598. if (e.data.code == 0) {
  599. self.list = e.data.data.list;
  600. self.group_buy_active_arr = e.data.data.group_buy_active_arr;
  601. self.pageCount = e.data.data.page_count;
  602. self.pay_success_jump = e.data.data.pay_success_jump;
  603. this.export_list = e.data.data.export_list;
  604. this.synchronize_goods_dialog = e.data.data.synchronize_goods_dialog
  605. } else {
  606. self.$message.error(e.data.msg);
  607. }
  608. }).catch(e => {
  609. self.$message.error(e.data.msg);
  610. self.listLoading = false;
  611. });
  612. }
  613. },
  614. // 批量下架商品
  615. multipleOff() {
  616. let self = this;
  617. if (!self.selectedGoodIds.length) {
  618. self.$message.error('请先选择要下架的商品');
  619. return false;
  620. }
  621. self.listLoading = true;
  622. self.$confirm('是否确认下架所选中商品', '警告', {
  623. confirmButtonText: '确定',
  624. cancelButtonText: '取消',
  625. type: 'warning'
  626. }).then(() => {
  627. request({
  628. params: {
  629. r: 'happiness/client/goods/mutiple-off',
  630. },
  631. method: 'post',
  632. data: {
  633. good_ids: self.selectedGoodIds,
  634. }
  635. }).then(e => {
  636. self.listLoading = false;
  637. if (e.data.code == 0) {
  638. self.$message.success('操作成功');
  639. self.getList();
  640. } else {
  641. self.$message.error(e.data.msg);
  642. return false;
  643. }
  644. }).catch(e => {
  645. self.listLoading = false;
  646. console.log(e);
  647. self.$message.error('网络错误');
  648. return false;
  649. });
  650. }).catch(() => {
  651. self.listLoading = false;
  652. console.log('已取消操作');
  653. return false;
  654. });
  655. },
  656. multipleOn() {
  657. let self = this;
  658. if (!self.selectedGoodIds.length) {
  659. self.$message.error('请先选择要上架的商品');
  660. return false;
  661. }
  662. self.listLoading = true;
  663. self.$confirm('是否确认上架所选中商品', '警告', {
  664. confirmButtonText: '确定',
  665. cancelButtonText: '取消',
  666. type: 'warning'
  667. }).then(() => {
  668. request({
  669. params: {
  670. r: 'happiness/client/goods/mutiple-on',
  671. },
  672. method: 'post',
  673. data: {
  674. good_ids: self.selectedGoodIds,
  675. }
  676. }).then(e => {
  677. self.listLoading = false;
  678. if (e.data.code == 0) {
  679. self.$message.success('操作成功');
  680. self.getList();
  681. } else {
  682. self.$message.error(e.data.msg);
  683. return false;
  684. }
  685. }).catch(e => {
  686. self.listLoading = false;
  687. console.log(e);
  688. self.$message.error('网络错误');
  689. return false;
  690. });
  691. }).catch(() => {
  692. self.listLoading = false;
  693. console.log('已取消操作');
  694. return false;
  695. });
  696. },
  697. // 批量下架选中
  698. handleSelectionChange(val) {
  699. if (val.length) {
  700. this.selectedGoodIds = val.map((e) => {
  701. if (e.can_change_status == true) {
  702. return e.id;
  703. }
  704. });
  705. } else {
  706. this.selectedGoodIds = [];
  707. }
  708. },
  709. hidePaySuccessSelectJumpUrlDialogVisible() {
  710. this.paySuccessSelectJumpUrlDialogVisible = false
  711. },
  712. onChangeJumpUrl(goods) {
  713. this.currentItem = goods
  714. this.paySuccessSelectJumpUrlDialogVisible = true
  715. },
  716. syncGoods() {
  717. this.syncGoods2Store = true;
  718. this.getMallList()
  719. this.getMchGoodsList();
  720. },
  721. getMallList() {
  722. let _this = this;
  723. let basic_params = {
  724. r: 'happiness/client/goods/get-mall-list',
  725. };
  726. params = Object.assign(basic_params, {});
  727. request({
  728. params: params,
  729. method: 'get',
  730. }).then(e => {
  731. if (e.data.code == 0) {
  732. _this.mallList = e.data.data;
  733. } else {
  734. _this.$message.error(e.data.data.msg);
  735. }
  736. }).catch(e => {
  737. _this.$message.error(e.data.data.msg);
  738. _this.syncGoods2StoreLoading = false;
  739. });
  740. },
  741. getMchGoodsList() {
  742. let _this = this;
  743. let basic_params = {
  744. r: 'happiness/client/goods/sync-goods-list',
  745. page: this.mchGoodsPage,
  746. limit: 15,
  747. ..._this.mchGoodsSearch
  748. };
  749. params = Object.assign(basic_params, {});
  750. if (_this.syncGoods2StoreLoading == false) {
  751. _this.syncGoods2StoreLoading = true;
  752. request({
  753. params: params,
  754. method: 'get',
  755. }).then(e => {
  756. _this.syncGoods2StoreLoading = false;
  757. if (e.data.code == 0) {
  758. _this.mchGoodsList = e.data.data.list;
  759. _this.mchGoodsPageCount = e.data.data.page_count;
  760. } else {
  761. _this.$message.error(e.data.data.msg);
  762. }
  763. }).catch(e => {
  764. _this.$message.error(e.data.data.msg);
  765. _this.syncGoods2StoreLoading = false;
  766. });
  767. }
  768. },
  769. searchMchGoods() {
  770. this.mchGoodsPage = 1
  771. this.getMchGoodsList()
  772. },
  773. getRowKey(row) {
  774. return row.id;
  775. },
  776. handleSelectAll() {
  777. let _this = this
  778. _this.mchGoodsList.map(function (item, index) {
  779. _this.selectedRowIds.push(item.id)
  780. })
  781. },
  782. handleSyncSelect(selection, row) {
  783. this.selectedRowIds.push(row.id)
  784. },
  785. mchGoodsPagination(currentPage) {
  786. this.mchGoodsPage = currentPage;
  787. this.getMchGoodsList();
  788. },
  789. confirmSyncGoods() {
  790. let _this = this
  791. if (_this.selectedRowIds.length <= 0) {
  792. _this.$message.error('请选择需要同步的商品');
  793. return
  794. }
  795. _this.$confirm('确定要同步这些商品到门店?', '警告', {
  796. type: 'warning'
  797. }).then(() => {
  798. this.btnLoading = true;
  799. request({
  800. params: {
  801. r: 'happiness/client/goods/sync-goods-store'
  802. },
  803. method: 'post',
  804. data: {
  805. selected_goods_ids: this.selectedRowIds,
  806. }
  807. }).then(res => {
  808. if (res.data.code == 0) {
  809. _this.$message.success(res.data.msg);
  810. _this.syncGoods2Store = false;
  811. _this.btnLoading = false;
  812. } else {
  813. _this.$message.error(res.data.msg);
  814. }
  815. }).catch(err => {
  816. console.info(err);
  817. _this.syncGoods2Store = false;
  818. _this.btnLoading = false;
  819. })
  820. })
  821. },
  822. selectMallCat(arr) {
  823. this.mchGoodsSearch.cats = [];
  824. arr.forEach(it => this.mchGoodsSearch.cats.push(it.id))
  825. this.getMchGoodsList()
  826. },
  827. clearMallCat() { // 清除分类
  828. this.mchGoodsSearch.cats = []
  829. this.getMchGoodsList()
  830. },
  831. checkSelectable(row) {
  832. if (row.supplier_type != 4 && row.can_change_status == true) {
  833. return true;
  834. } else {
  835. return false;
  836. }
  837. },
  838. }
  839. });
  840. </script>