com-goods-list.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. <?php
  2. $mchId = Yii::$app->admin->identity->mch_id;
  3. Yii::$app->loadComponentView('goods/com-search','@app/plugins/o2o_store/views/components/mall');
  4. ?>
  5. <style>
  6. .table-body {
  7. padding: 20px;
  8. background-color: #fff;
  9. }
  10. .com-goods-list .table-body .edit-sort-img {
  11. width: 14px;
  12. height: 14px;
  13. margin-left: 5px;
  14. cursor: pointer;
  15. }
  16. .com-goods-list .goods-cat .el-tag--mini {
  17. max-width: 60px;
  18. overflow: hidden;
  19. white-space: nowrap;
  20. text-overflow: ellipsis;
  21. }
  22. .com-goods-list .export-dialog .el-dialog {
  23. min-width: 350px;
  24. }
  25. .com-goods-list .export-dialog .el-dialog__body {
  26. padding: 20px 20px;
  27. }
  28. .com-goods-list .export-dialog .el-button--submit {
  29. color: #FFF;
  30. background-color: #409EFF;
  31. border-color: #409EFF;
  32. }
  33. </style>
  34. <template id="com-goods-list">
  35. <div class="com-goods-list">
  36. <el-card v-loading="listLoading" class="box-card" shadow="never" style="border:0"
  37. body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  38. <div slot="header">
  39. <span>商品列表</span>
  40. <div style="float: right; margin: -5px 0">
  41. <el-button v-if="isShowExportGoods" type="primary" size="small" @click="exportGoods">商品导出
  42. </el-button>
  43. <el-dialog
  44. flex="cross:center"
  45. class="export-dialog"
  46. :title="exportParams.is_show_download ? '下载' : '提示'"
  47. :visible.sync="exportDialogVisible"
  48. width="20%">
  49. <template v-if="!exportParams.is_show_download">
  50. <div flex="cross:center">
  51. <i style="color: #E6A23C;font-size: 20px;margin-right: 5px" class="el-icon-warning"></i>
  52. <span>选中{{choose_list.length == 0 ? '全部,共计'+ exportParams.goods_count +'件' : choose_list.length + '个'}}商品,是否确认导出</span>
  53. </div>
  54. <span slot="footer" class="dialog-footer">
  55. <el-button @click="exportDialogVisible = false" size="small">取 消</el-button>
  56. <el-button @click="exportGoodsData" size="small" type="primary">确定</el-button>
  57. </span>
  58. </template>
  59. <template v-else>
  60. <el-progress :text-inside="true" :stroke-width="18"
  61. :percentage="exportParams.percentage"></el-progress>
  62. <span slot="footer" class="dialog-footer">
  63. <!-- <el-button @click="download" v-if="exportParams.percentage == 100" size="small"-->
  64. <!-- type="primary">-->
  65. <!-- 点击下载-->
  66. <!-- </el-button>-->
  67. <form target="_blank" :action="exportParams.action_url" method="post">
  68. <div class="modal-body">
  69. <input name="_csrf" type="hidden" id="_csrf"
  70. value="<?= Yii::$app->request->csrfToken ?>">
  71. <input name="flag" value="EXPORT" type="hidden">
  72. <input name="is_download" :value="exportParams.is_download" type="hidden">
  73. </div>
  74. <div flex="dir:right" style="margin-top: 20px;">
  75. <button v-if="exportParams.percentage == 100" type="submit"
  76. class="el-button el-button--primary el-button--small">点击下载</button>
  77. </div>
  78. </form>
  79. </span>
  80. </template>
  81. </el-dialog>
  82. </div>
  83. </div>
  84. <div class="table-body">
  85. <com-search :tabs="tabs" :new-search="search" @to-search="toSearch"
  86. :new-active-name="newActiveName"></com-search>
  87. <el-table
  88. ref="multipleTable"
  89. :data="list"
  90. border
  91. style="width: 100%;margin-bottom: 15px"
  92. @selection-change="handleSelectionChange"
  93. @sort-change="sortChange">
  94. <el-table-column type="selection" align="center" width="60"></el-table-column>
  95. <el-table-column prop="id" label="ID" sortable="false"></el-table-column>
  96. <el-table-column prop="sort" label="所属门店">
  97. <template slot-scope="scope">
  98. <div flex="dir:left cross:center">
  99. <span>{{scope.row.store.name}}</span>
  100. </div>
  101. </template>
  102. </el-table-column>
  103. <slot name="column-col-first"></slot>
  104. <el-table-column label="分类">
  105. <template slot-scope="scope">
  106. <div class="goods-cat" v-if="!is_mch">
  107. <el-tag v-if="scope.row.cats && scope.row.cats.length > 0"
  108. size="mini">
  109. {{scope.row.cats[0].name}}
  110. </el-tag>
  111. <el-tooltip v-if="scope.row.cats && scope.row.cats.length > 1" placement="top">
  112. <div slot="content">
  113. <span v-for="item in scope.row.cats" :key="item.id">{{item.name}}&nbsp;</span>
  114. </div>
  115. <span>...</span>
  116. </el-tooltip>
  117. </div>
  118. <div class="goods-cat" v-if="is_mch">
  119. <el-tag v-if="scope.row.mchCats.length > 0" size="mini">
  120. {{scope.row.mchCats[0].name}}
  121. </el-tag>
  122. <el-tooltip v-if="scope.row.mchCats.length > 1" placement="top" effect="light">
  123. <div slot="content">
  124. <el-tag style="margin-right: 5px" size="mini"
  125. v-for="item in scope.row.mchCats" :key="item.id">
  126. {{item.name}}
  127. </el-tag>
  128. </div>
  129. <span>...</span>
  130. </el-tooltip>
  131. </div>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="商品名称" width="320">
  135. <template slot-scope="scope">
  136. <div flex="box:first">
  137. <div style="padding-right: 10px;">
  138. <com-image mode="aspectFill" :src="scope.row.goodsWarehouse.cover_pic"></com-image>
  139. </div>
  140. <div flex="cross:top cross:center">
  141. <div flex="dir:left">
  142. <el-tooltip class="item"
  143. effect="dark"
  144. placement="top">
  145. <template slot="content">
  146. <div style="width: 320px;">{{scope.row.goodsWarehouse.name}}</div>
  147. </template>
  148. <com-ellipsis :line="2">{{scope.row.goodsWarehouse.name}}</com-ellipsis>
  149. </el-tooltip>
  150. </div>
  151. </div>
  152. </div>
  153. </template>
  154. </el-table-column>
  155. <el-table-column prop="price" label="售价" sortable="false"></el-table-column>
  156. <el-table-column prop="goods_stock" label="库存" sortable="false">
  157. <template slot-scope="scope">
  158. <div v-if="scope.row.goods_stock > 0">{{scope.row.goods_stock}}</div>
  159. <div v-else style="color: red;">售罄</div>
  160. </template>
  161. </el-table-column>
  162. <el-table-column prop="virtual_sales" width="110" label="虚拟销量" sortable="false"></el-table-column>
  163. <el-table-column label="状态" width="100">
  164. <template slot-scope="scope">
  165. <el-tag size="small" type="success" v-if="scope.row.status == 1">销售中</el-tag>
  166. <el-tag size="small" type="info" v-if="scope.row.status == -1">待审核</el-tag>
  167. <el-tag size="small" type="warning" v-if="scope.row.status == 0">下架中</el-tag>
  168. <el-tag size="small" type="danger" v-if="scope.row.status == -2">被驳回</el-tag>
  169. </template>
  170. </el-table-column>
  171. <el-table-column prop="scope" width="180" label="添加时间">
  172. <template slot-scope="scope">
  173. {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  174. </template>
  175. </el-table-column>
  176. <el-table-column label="操作" width="300px" align="center">
  177. <template slot-scope="scope">
  178. <el-button @click="edit(scope.row)" type="text" circle size="mini">
  179. <el-tooltip class="item" effect="dark" content="详情" placement="top">
  180. <img src="statics/img/mall/order/add_remark.png" alt="">
  181. </el-tooltip>
  182. </el-button>
  183. <el-button v-if="scope.row.status == -1" circle size="mini" type="text" @click="storePass(scope.row, scope.$index)">
  184. <el-tooltip class="item" effect="dark" content="通过" placement="top">
  185. <img src="/plugins/o2o_store/assets/images/pass.png" alt="">
  186. </el-tooltip>
  187. </el-button>
  188. <el-button v-if="scope.row.status == -1" type="text" size="mini" circle style="margin-left: 10px;margin-top: 10px"
  189. @click.native="reject(scope.row, scope.$index)">
  190. <el-tooltip class="item" effect="dark" content="驳回" placement="top">
  191. <img src="/plugins/o2o_store/assets/images/reject.png" alt="">
  192. </el-tooltip>
  193. </el-button>
  194. </template>
  195. </el-table-column>
  196. </el-table>
  197. <!-- 这里就是el-table的分页数 -->
  198. <div flex="main:right cross:center" style="margin-top: 20px;">
  199. <div v-if="pageCount > 0">
  200. <el-pagination
  201. @current-change="pagination"
  202. background
  203. :current-page="current_page"
  204. layout="prev, pager, next"
  205. :page-count="pageCount">
  206. </el-pagination>
  207. </div>
  208. </div>
  209. </div>
  210. </el-card>
  211. </div>
  212. </template>
  213. <script>
  214. Vue.component('com-goods-list', {
  215. template: '#com-goods-list',
  216. props: {
  217. goods_url: {
  218. type: String,
  219. default: 'plugin/o2o_store/mall/goods/index'
  220. },
  221. edit_goods_url: {
  222. type: String,
  223. default: 'plugin/o2o_store/mall/goods/edit'
  224. },
  225. destroy_goods_url: {
  226. type: String,
  227. default: 'mall/goods/delete'
  228. },
  229. edit_goods_sort_url: {
  230. type: String,
  231. default: 'mall/goods/edit-sort'
  232. },
  233. edit_goods_status_url: {
  234. type: String,
  235. default: 'mall/goods/switch-status'
  236. },
  237. batch_update_status_url: {
  238. type: String,
  239. default: 'mall/goods/batch-update-status'
  240. },
  241. is_edit_goods_name: {
  242. type: Boolean,
  243. default: false
  244. },
  245. is_action: {
  246. type: Boolean,
  247. default: true
  248. },
  249. actionWitch: {
  250. type: Number,
  251. default: 180
  252. },
  253. is_add_goods: {
  254. type: Boolean,
  255. default: true
  256. },
  257. status_change_text: {
  258. type: String,
  259. default: '',
  260. },
  261. tabs: {
  262. type: Array,
  263. default: function () {
  264. return [
  265. {
  266. name: '全部',
  267. value: '-1'
  268. },
  269. {
  270. name: '销售中',
  271. value: '1'
  272. },
  273. {
  274. name: '下架中',
  275. value: '0'
  276. },
  277. {
  278. name: '售罄',
  279. value: '2'
  280. },
  281. ];
  282. }
  283. },
  284. /**
  285. * 批量设置参数
  286. * 具体参数看 com-batch 组件
  287. */
  288. batchList: Array,
  289. isShowSvip: true,// 批量设置超级会员卡是否显示
  290. isShowExpress: true, // 批量设置运费是否显示
  291. isShowIntegral: true,// 批量设置积分是否显示
  292. isShowBatchButton: true,//批量设置按钮是否显示
  293. isShowExportGoods: false,//商品导出按钮
  294. },
  295. data() {
  296. return {
  297. search: {
  298. keyword: '',
  299. store_name: '',
  300. status: '-1',
  301. sort_prop: '',
  302. sort_type: '',
  303. cats: [],
  304. date_start: null,
  305. date_end: null,
  306. },
  307. list: [],
  308. listLoading: false,
  309. page: 1,
  310. pageCount: 0,
  311. current_page: 1,
  312. is_mch: <?= $mchId > 0 ? 1 : 0 ?>,
  313. mchMallSetting: {},
  314. choose_list: [],
  315. btnLoading: false,
  316. sort: 0,
  317. id: 0,// 应该无用了
  318. sort_goods_id: 0,
  319. goodsId: 0,
  320. goodsName: '',
  321. // 分类筛选
  322. dialogVisible: false,
  323. dialogLoading: false,
  324. options: [],
  325. cats: [],
  326. children: [],
  327. third: [],
  328. mch_id: '<?= $mchId ?>',
  329. newActiveName: '-1',
  330. exportDialogVisible: false,
  331. // 商品导出参数
  332. exportParams: {
  333. page: 1,
  334. is_show_download: false,
  335. is_download: 0,
  336. percentage: 0,
  337. action_url: '<?= Yii::$app->urlManager->createUrl('plugin/o2o_store/mall/goods/export-goods-list') ?>',
  338. goods_count: 0,//商品总数
  339. }
  340. };
  341. },
  342. created() {
  343. let self = this;
  344. if (this.is_mch) {
  345. this.getMchMallSetting();
  346. }
  347. if (getQuery('page') > 1) {
  348. this.page = getQuery('page');
  349. }
  350. // 搜索条件从缓存中获取
  351. let search = this.getCookie('search');
  352. if (search) {
  353. let newSearch = JSON.parse(search);
  354. this.search.keyword = newSearch.keyword;
  355. this.search.store_name = newSearch.store_name;
  356. this.search.cats = newSearch.cats;
  357. this.search.date_start = newSearch.date_start;
  358. this.search.date_end = newSearch.date_end;
  359. self.tabs.forEach(function (item) {
  360. if (item.value == newSearch.status) {
  361. self.search.status = newSearch.status;
  362. self.newActiveName = newSearch.status;
  363. }
  364. })
  365. }
  366. this.getList();
  367. },
  368. methods: {
  369. reject(row, index) {
  370. let self = this;
  371. self.$confirm('驳回商品审核, 是否继续?', '提示', {
  372. confirmButtonText: '确定',
  373. cancelButtonText: '取消',
  374. type: 'warning'
  375. }).then(() => {
  376. self.listLoading = true;
  377. request({
  378. params: {
  379. r: 'plugin/o2o_store/mall/goods/reject',
  380. },
  381. method: 'post',
  382. data: {
  383. id: row.id,
  384. }
  385. }).then(e => {
  386. self.listLoading = false;
  387. if (e.data.code === 0) {
  388. self.$message.success(e.data.msg);
  389. self.getList();
  390. } else {
  391. self.$message.error(e.data.msg);
  392. }
  393. }).catch(e => {
  394. console.log(e);
  395. });
  396. }).catch(() => {
  397. self.$message.info('已取消删除')
  398. });
  399. },
  400. storePass(row, index) {
  401. let self = this;
  402. self.$confirm('通过商品审核, 是否继续?', '提示', {
  403. confirmButtonText: '确定',
  404. cancelButtonText: '取消',
  405. type: 'warning'
  406. }).then(() => {
  407. self.listLoading = true;
  408. request({
  409. params: {
  410. r: 'plugin/o2o_store/mall/goods/pass',
  411. },
  412. method: 'post',
  413. data: {
  414. id: row.id,
  415. }
  416. }).then(e => {
  417. self.listLoading = false;
  418. if (e.data.code === 0) {
  419. self.$message.success(e.data.msg);
  420. self.getList();
  421. } else {
  422. self.$message.error(e.data.msg);
  423. }
  424. }).catch(e => {
  425. console.log(e);
  426. });
  427. }).catch(() => {
  428. self.$message.info('已取消删除')
  429. });
  430. },
  431. editGoodsName(row) {
  432. this.goodsId = row.id;
  433. this.goodsName = row.goodsWarehouse.name;
  434. },
  435. changeGoodsName(row) {
  436. let self = this;
  437. request({
  438. params: {
  439. r: 'mall/goods/update-goods-name'
  440. },
  441. data: {
  442. goods_id: self.goodsId,
  443. goods_name: self.goodsName
  444. },
  445. method: 'post'
  446. }).then((e) => {
  447. if (e.data.code == 0) {
  448. self.goodsId = null;
  449. self.$message.success(e.data.msg);
  450. self.getList();
  451. }
  452. else {
  453. self.$message.error(e.data.msg);
  454. }
  455. }).catch((e) => {
  456. self.$message.error(e.data.msg);
  457. })
  458. ;
  459. },
  460. // 全选单前页
  461. handleSelectionChange(val) {
  462. let self = this;
  463. self.choose_list = [];
  464. val.forEach(function (item) {
  465. self.choose_list.push(item.id);
  466. })
  467. },
  468. pagination(currentPage) {
  469. let self = this;
  470. self.page = currentPage;
  471. self.getList();
  472. },
  473. getList() {
  474. let self = this;
  475. self.listLoading = true;
  476. self.saveSearch();
  477. request({
  478. params: {
  479. r: self.goods_url,
  480. page: self.page,
  481. search: self.search,
  482. },
  483. method: 'get',
  484. }).then(e => {
  485. self.listLoading = false;
  486. self.list = e.data.data.list;
  487. self.pageCount = e.data.data.pagination.page_count;
  488. self.current_page = e.data.data.pagination.current_page;
  489. self.exportParams.goods_count = e.data.data.goods_count;
  490. }).catch((e) => {
  491. console.log(e);
  492. })
  493. ;
  494. },
  495. edit(row) {
  496. if (row.id) {
  497. navigateTo({
  498. r: this.edit_goods_url,
  499. id: row.id,
  500. mch_id: row.mch_id,
  501. page: this.page,
  502. });
  503. this.saveSearch();
  504. } else {
  505. navigateTo({
  506. r: this.edit_goods_url,
  507. page: this.page
  508. });
  509. }
  510. },
  511. getCookie(cname) {
  512. let name = cname + "=";
  513. let decodedCookie = decodeURIComponent(document.cookie);
  514. let ca = decodedCookie.split(';');
  515. for (let i = 0; i < ca.length; i++) {
  516. let c = ca[i];
  517. while (c.charAt(0) == ' ') {
  518. c = c.substring(1);
  519. }
  520. if (c.indexOf(name) == 0) {
  521. return c.substring(name.length, c.length);
  522. }
  523. }
  524. return "";
  525. },
  526. saveSearch() {
  527. document.cookie = "search=" + JSON.stringify(this.search);
  528. },
  529. destroy(row, index) {
  530. let self = this;
  531. self.$confirm('删除该条数据, 是否继续?', '提示', {
  532. confirmButtonText: '确定',
  533. cancelButtonText: '取消',
  534. type: 'warning'
  535. }).then(() => {
  536. self.listLoading = true;
  537. request({
  538. params: {
  539. r: this.destroy_goods_url,
  540. },
  541. method: 'post',
  542. data: {
  543. id: row.id,
  544. }
  545. }).then(e => {
  546. self.listLoading = false;
  547. if (e.data.code === 0) {
  548. self.list.splice(index, 1);
  549. self.$message.success(e.data.msg);
  550. } else {
  551. self.$message.error(e.data.msg);
  552. }
  553. }).
  554. catch(e => {
  555. console.log(e);
  556. })
  557. ;
  558. }).catch(() => {
  559. self.$message.info('已取消删除')
  560. })
  561. ;
  562. },
  563. applyStatus(id) {
  564. let self = this;
  565. self.$confirm('申请上架, 是否继续?', '提示', {
  566. confirmButtonText: '确定',
  567. cancelButtonText: '取消',
  568. type: 'warning'
  569. }).then(() => {
  570. self.listLoading = true;
  571. request({
  572. params: {
  573. r: 'mall/goods/apply-status',
  574. },
  575. method: 'post',
  576. data: {
  577. id: id,
  578. }
  579. }).then(e => {
  580. self.listLoading = false;
  581. if (e.data.code === 0) {
  582. self.getList();
  583. self.$message.success(e.data.msg);
  584. } else {
  585. self.$message.error(e.data.msg);
  586. }
  587. }).
  588. catch(e => {
  589. console.log(e);
  590. })
  591. ;
  592. }).
  593. catch(() => {
  594. self.$message.info('已取消申请')
  595. })
  596. ;
  597. },
  598. // 商品上下架
  599. switchStatus(row) {
  600. let self = this;
  601. self.btnLoading = true;
  602. request({
  603. params: {
  604. r: this.edit_goods_status_url,
  605. },
  606. method: 'post',
  607. data: {
  608. status: row.status,
  609. id: row.id,
  610. mch_id: row.mch_id
  611. }
  612. }).then(e => {
  613. self.btnLoading = false;
  614. if (e.data.code === 0) {
  615. self.$message.success(e.data.msg);
  616. } else {
  617. self.$message.error(e.data.msg);
  618. }
  619. self.getList();
  620. }).
  621. catch(e => {
  622. console.log(e);
  623. })
  624. ;
  625. },
  626. getMchMallSetting() {
  627. let self = this;
  628. request({
  629. params: {
  630. r: 'mall/merchant/mch-setting',
  631. },
  632. method: 'get',
  633. }).then(e => {
  634. self.mchMallSetting = e.data.data.setting;
  635. }).
  636. catch(e => {
  637. console.log(e);
  638. })
  639. ;
  640. },
  641. toSearch(searchData) {
  642. this.page = 1;
  643. this.search = searchData;
  644. this.getList();
  645. },
  646. // 排序排列
  647. sortChange(row) {
  648. if (row.prop) {
  649. this.search.sort_prop = row.prop;
  650. this.search.sort_type = row.order == "descending" ? 0 : 1;
  651. } else {
  652. this.search.sort_prop = '';
  653. this.search.sort_type = '';
  654. }
  655. this.getList();
  656. },
  657. quit() {
  658. this.sort_goods_id = null;
  659. this.goodsId = null;
  660. },
  661. editSort(row) {
  662. this.sort_goods_id = row.id;
  663. this.sort = row.sort;
  664. if (this.is_mch) {
  665. this.sort = row.mchGoods.sort;
  666. }
  667. },
  668. changeSortSubmit(row) {
  669. let self = this;
  670. row.sort = self.sort;
  671. let route = self.edit_goods_sort_url;
  672. if (!row.sort || row.sort < 0) {
  673. self.$message.warning('排序值不能小于0')
  674. return;
  675. }
  676. if (this.is_mch) {
  677. route = 'plugin/merchant/mall/goods/edit-sort';
  678. row.mchGoods.sort = self.sort;
  679. }
  680. request({
  681. params: {
  682. r: route
  683. },
  684. method: 'post',
  685. data: {
  686. id: row.id,
  687. sort: row.sort,
  688. }
  689. }).then(e => {
  690. self.btnLoading = false;
  691. if (e.data.code === 0) {
  692. self.$message.success(e.data.msg);
  693. this.sort_goods_id = null;
  694. self.getList();
  695. } else {
  696. self.$message.error(e.data.msg);
  697. }
  698. }).
  699. catch(e => {
  700. self.$message.error(e.data.msg);
  701. self.btnLoading = false;
  702. })
  703. ;
  704. },
  705. getAllChecked(e) {
  706. this.$emit('get-all-checked', e)
  707. },
  708. // 商品导出
  709. exportGoods() {
  710. this.exportDialogVisible = true;
  711. this.exportParams = {
  712. page: 1,
  713. is_show_download: false,
  714. is_download: 0,
  715. percentage: 0,
  716. action_url: '<?= Yii::$app->urlManager->createUrl('plugin/o2o_store/mall/goods/export-goods-list') ?>',
  717. goods_count: 0,//商品总数
  718. }
  719. },
  720. exportGoodsData() {
  721. let self = this;
  722. self.exportParams.is_show_download = true;
  723. request({
  724. params: {
  725. r: 'plugin/o2o_store/mall/goods/export-goods-list',
  726. },
  727. data: {
  728. page: self.exportParams.page,
  729. search: JSON.stringify(self.search),
  730. flag: 'EXPORT',
  731. choose_list: self.choose_list,
  732. _csrf: '<?= Yii::$app->request->csrfToken ?>',
  733. is_download: self.exportParams.is_download,
  734. },
  735. method: 'post',
  736. }).then(e => {
  737. let data = e.data.data;
  738. if (e.data.code === 0) {
  739. self.exportParams.increase = 100 / data.pagination.page_count;
  740. self.exportParams.percentage += self.exportParams.increase;
  741. self.exportParams.percentage = parseFloat(self.exportParams.percentage.toFixed(2));
  742. if (data.pagination.current_page == data.pagination.page_count) {
  743. self.exportParams.percentage = 100;
  744. self.exportParams.is_download += data.export_goods.is_download;
  745. }
  746. if (data.pagination.current_page < data.pagination.page_count) {
  747. self.exportParams.page += 1;
  748. self.exportGoodsData();
  749. }
  750. }
  751. }).
  752. catch(e => {
  753. console.log(e);
  754. })
  755. ;
  756. },
  757. },
  758. });
  759. </script>