index.php 38 KB

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