index.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <com-list-page :crumbs="crumbs" id="application">
  2. <com-list-table
  3. ref="table"
  4. :api-params="apiParams"
  5. :search-list="searchList"
  6. @set-action-name="setActionName"
  7. :tabs="tabs"
  8. >
  9. <el-table-column prop="goods_id" label="商品ID" width="100" align="center"></el-table-column>
  10. <el-table-column label="商品">
  11. <template slot-scope="scope">
  12. <div flex="box:first">
  13. <div style="padding-right: 10px;" v-if="scope.row.goods">
  14. <com-image mode="aspectFill" :src="scope.row.goods.cover_pic"></com-image>
  15. </div>
  16. <div>
  17. <div v-if="scope.row.goods">
  18. {{scope.row.goods.goods_name}}
  19. </div>
  20. <div>
  21. <span style="color:red;margin-right: 10px;">
  22. 最低价:¥{{scope.row.min_price}}
  23. </span>
  24. <span>
  25. 库存:{{scope.row.stock}}
  26. </span>
  27. </div>
  28. </div>
  29. </div>
  30. </template>
  31. </el-table-column>
  32. <el-table-column prop="title" label="砍价活动名称" align="center"></el-table-column>
  33. <el-table-column prop="begin_time,end_time" label="活动时间" width="300" align="center">
  34. <template slot-scope="scope">
  35. <div>{{scope.row.begin_time|dateTimeFormat('Y-m-d H:i:s')}} ~ {{scope.row.end_time|dateTimeFormat('Y-m-d H:i:s')}}</div>
  36. </template>
  37. </el-table-column>
  38. <el-table-column prop="active_status" label="状态" width="150" align="center">
  39. <template slot-scope="scope">
  40. <el-tag effect="dark" size="small" type="info" v-if="scope.row.active_status == 0">未开始</el-tag>
  41. <el-tag effect="dark" size="small" type="success" v-if="scope.row.active_status == 1">活动中</el-tag>
  42. <el-tag effect="dark" size="small" type="warning" v-if="scope.row.active_status == 2">已结束</el-tag>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="操作" align="right">
  46. <template slot-scope="scope">
  47. <el-button @click="edit(scope.row.id)" type="text" size="mini">编辑</el-button>
  48. <el-button v-if="scope.row.status==1" @click="update(scope.row)" type="text" size="mini">失效</el-button>
  49. <el-button v-if="scope.row.status==0||scope.row.active_status==2" @click="update(scope.row)" type="text" size="mini">删除</el-button>
  50. </template>
  51. </el-table-column>
  52. <template slot="header-left">
  53. <el-button
  54. type="primary"
  55. size="mini"
  56. icon="el-icon-plus"
  57. @click="edit(0)"
  58. >添加活动</el-button>
  59. </template>
  60. </com-list-table>
  61. </com-list-page>
  62. <script>
  63. const application = new Vue({
  64. el: '#application',
  65. data: {
  66. crumbs: [
  67. {
  68. title: '砍价',
  69. },
  70. {
  71. title: '砍价活动',
  72. }
  73. ],
  74. searchList: [
  75. {
  76. key: 'goods_name',
  77. title: '商品名称',
  78. type: 'text',
  79. },
  80. ],
  81. tabs: [
  82. {
  83. label: '全部',
  84. name: 'all',
  85. },
  86. {
  87. label: '未开始',
  88. name: '0',
  89. },
  90. {
  91. label: '活动中',
  92. name: '1',
  93. },
  94. {
  95. label: '已结束',
  96. name: '2',
  97. },
  98. ],
  99. apiParams: {
  100. r: 'bargain/default/index',
  101. },
  102. btnLoad: false,
  103. },
  104. methods: {
  105. setActionName(e) {
  106. this.apiParams = {r: 'bargain/default/index'}
  107. e != 'all' && (this.apiParams = Object.assign({...this.apiParams}, {
  108. active_status: e
  109. }))
  110. this.$nextTick(function() {
  111. this.$refs.table.handleSearch();
  112. })
  113. },
  114. edit(id) {
  115. navigateTo({
  116. r: 'bargain/default/edit',
  117. id: id
  118. })
  119. },
  120. update(row) {
  121. if (row.status == 0) {
  122. this.$confirm('此操作将删除该砍价商品, 是否继续?', '提示', {
  123. confirmButtonText: '确定',
  124. cancelButtonText: '取消',
  125. type: 'warning'
  126. }).then(() => {
  127. this.delGoods(row.id);
  128. }).catch(() => {
  129. this.$message({
  130. type: 'info',
  131. message: '已取消'
  132. });
  133. });
  134. }
  135. if (row.status == 1) {
  136. this.$confirm('此操作将使该砍价活动失效, 是否继续?', '提示', {
  137. confirmButtonText: '确定',
  138. cancelButtonText: '取消',
  139. type: 'warning'
  140. }).then(() => {
  141. this.invalidGoods(row.id);
  142. }).catch(() => {
  143. this.$message({
  144. type: 'info',
  145. message: '已取消'
  146. });
  147. });
  148. }
  149. },
  150. delGoods(id) {
  151. this.loading = true;
  152. request({
  153. params: {
  154. r: 'bargain/default/del',
  155. id: id
  156. },
  157. method: 'get',
  158. }).then(e => {
  159. let res = e.data;
  160. this.listLoading = false;
  161. if (res.code === 0) {
  162. this.$message.success(res.msg);
  163. this.$nextTick(function() {
  164. this.$refs.table.handleSearch();
  165. })
  166. } else {
  167. this.$message.error(res.msg);
  168. }
  169. }).catch(e => {});
  170. },
  171. invalidGoods(id) {
  172. this.loading = true;
  173. request({
  174. params: {
  175. r: 'bargain/default/invalid',
  176. id: id
  177. },
  178. method: 'get',
  179. }).then(e => {
  180. let res = e.data;
  181. this.listLoading = false;
  182. if (res.code === 0) {
  183. this.$message.success(res.msg);
  184. this.loadData();
  185. } else {
  186. this.$message.error(res.msg);
  187. }
  188. }).catch(e => {});
  189. },
  190. formatEffectiveTime(value) {
  191. var h = parseInt(value / 60);
  192. var m = value % 60;
  193. return h + '小时' + m + '分';
  194. },
  195. }
  196. })
  197. </script>