index.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. $diyPath = dirname(__DIR__) . '/components';
  4. ComponentHelper::loadComponentView('upgrade-bag-edit', $diyPath);
  5. ?>
  6. <div id="app" v-cloak>
  7. <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  8. <div slot="header">
  9. <div>
  10. <span>升级礼包</span>
  11. </div>
  12. </div>
  13. <div class="table-body">
  14. <div style="margin-bottom: 20px;">
  15. <el-button type="primary" style="padding: 9px 15px !important;" @click="editClick(0)" size="small">添加礼包方案</el-button>
  16. </div>
  17. <el-table stripe :data="list" v-loading="listLoading" style="width: 100%">
  18. <el-table-column
  19. align="center"
  20. prop="id"
  21. label="id"
  22. min-width="70">
  23. </el-table-column>
  24. <el-table-column
  25. align="center"
  26. prop="name"
  27. label="礼包名称"
  28. min-width="150">
  29. </el-table-column>
  30. <el-table-column
  31. align="center"
  32. min-width="400"
  33. label="升级商品">
  34. <template slot-scope="scope">
  35. <el-table :data="scope.row.goods_list" border style="width: 100%">
  36. <el-table-column prop="id" label="商品id" align="center"></el-table-column>
  37. <el-table-column prop="name,cover_pic" label="商品名称" >
  38. <template slot-scope="scope">
  39. <div flex="box:first">
  40. <div style="padding-right: 10px;">
  41. <com-image mode="aspectFill" :src="scope.row.cover_pic"></com-image>
  42. </div>
  43. <div flex="cross:top cross:center">
  44. {{scope.row.name}}
  45. </div>
  46. </div>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. </template>
  51. </el-table-column>
  52. <el-table-column
  53. align="center"
  54. min-width="400"
  55. label="赠送商品">
  56. <template slot-scope="scope">
  57. <el-table :data="scope.row.give_goods_list" border style="width: 100%">
  58. <el-table-column prop="id" label="商品id" align="center"></el-table-column>
  59. <el-table-column prop="name,cover_pic" label="商品名称" >
  60. <template slot-scope="scope">
  61. <div flex="box:first">
  62. <div style="padding-right: 10px;">
  63. <com-image mode="aspectFill" :src="scope.row.cover_pic"></com-image>
  64. </div>
  65. <div flex="cross:top cross:center">
  66. {{scope.row.name}}
  67. </div>
  68. </div>
  69. </template>
  70. </el-table-column>
  71. <el-table-column prop="num" label="数量" align="center"></el-table-column>
  72. </el-table>
  73. </template>
  74. </el-table-column>
  75. <el-table-column
  76. align="center"
  77. prop="level_name"
  78. label="升级等级"
  79. min-width="180">
  80. <template slot-scope="scope">
  81. <el-tag>{{scope.row.level_name}}</el-tag>
  82. </template>
  83. </el-table-column>
  84. <el-table-column
  85. align="center"
  86. label="状态"
  87. min-width="100"
  88. align="center"
  89. >
  90. <template slot-scope="scope">
  91. <el-switch
  92. v-model="scope.row.status"
  93. :active-value="1"
  94. :inactive-value="0"
  95. @change="((val)=>{switchFun(val,scope.row.id)})">
  96. </el-switch>
  97. </template>
  98. </el-table-column>
  99. <el-table-column
  100. align="center"
  101. label="操作"
  102. min-width="150"
  103. align="center"
  104. >
  105. <template slot-scope="scope">
  106. <el-button circle size="mini" type="text" @click="editClick(scope.row.id)">
  107. <el-tooltip class="item" effect="dark" content="编辑" placement="top">
  108. <img src="resources/img/mall/edit.png" alt="">
  109. </el-tooltip>
  110. </el-button>
  111. <el-button circle size="mini" type="text" @click="bagDelete(scope.row.id, scope.$index)">
  112. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  113. <img src="resources/img/mall/del.png" alt="">
  114. </el-tooltip>
  115. </el-button>
  116. </template>
  117. </el-table-column>
  118. </el-table>
  119. <div style="text-align: right;margin: 20px 0;">
  120. <el-pagination
  121. @current-change="pagination"
  122. background
  123. layout="prev, pager, next"
  124. :page-count="pageCount">
  125. </el-pagination>
  126. </div>
  127. </div>
  128. </el-card>
  129. <upgrade-bag-edit v-model="edit.show" :edit_row="edit" @refresdatafun="getList"></upgrade-bag-edit>
  130. </div>
  131. <script>
  132. const app = new Vue({
  133. el: '#app',
  134. data() {
  135. return {
  136. edit: {
  137. show: false,
  138. id: 0,
  139. },
  140. list: [],
  141. listLoading: false,
  142. page: 1,
  143. pageCount: 0,
  144. };
  145. },
  146. mounted: function () {
  147. this.getList();
  148. },
  149. methods: {
  150. search() {
  151. this.page = 1;
  152. this.getList();
  153. },
  154. pagination(currentPage) {
  155. let self = this;
  156. self.page = currentPage;
  157. self.getList();
  158. },
  159. getList() {
  160. let self = this;
  161. self.listLoading = true;
  162. //console.log('请求前的page='+self.page)
  163. request({
  164. params: {
  165. r: 'cloud-stock/gift-bag/index',//升级礼包列表
  166. page: self.page,
  167. limit:10
  168. },
  169. method: 'get',
  170. }).then(e => {
  171. if(e.data.code == 0){
  172. self.listLoading = false;
  173. self.list = e.data.data.list;
  174. self.pageCount = e.data.data.page_count;
  175. }
  176. }).catch(e => {
  177. console.log(e);
  178. });
  179. },
  180. editClick(id) {
  181. if (id) {
  182. this.edit.id = id;
  183. this.edit.show = true;
  184. this.edit.title = "编辑升级礼包"
  185. } else {
  186. this.edit.id = 0;
  187. this.edit.show = true;
  188. this.edit.title = "添加升级礼包"
  189. }
  190. },
  191. bagDelete(id, index) {
  192. let self = this;
  193. self.$confirm('是否确认删除该升级礼包?', '提示', {
  194. confirmButtonText: '确定',
  195. cancelButtonText: '取消',
  196. type: 'warning'
  197. }).then(() => {
  198. self.listLoading = true;
  199. request({
  200. params: {
  201. r: 'cloud-stock/gift-bag/del',
  202. id: id,
  203. },
  204. }).then(e => {
  205. self.listLoading = false;
  206. if (e.data.code === 0) {
  207. self.$message.success(e.data.msg);
  208. self.list.splice(index, 1);
  209. } else {
  210. self.$message.error(e.data.msg);
  211. }
  212. }).catch(e => {
  213. console.log(e);
  214. });
  215. }).catch(() => {
  216. self.$message.info('已取消删除')
  217. });
  218. },
  219. switchFun(val,id){
  220. this.listLoading = true;
  221. request({
  222. params: {
  223. r: 'cloud-stock/gift-bag/update-status'
  224. },
  225. method: 'post',
  226. data:{
  227. status:val,
  228. id:id
  229. }
  230. }).then(e => {
  231. this.listLoading = false;
  232. if (e.data.code == 0) {
  233. this.$message.success('更改状态成功');
  234. } else {
  235. this.$message.error(e.data.msg);
  236. }
  237. }).catch(e => {
  238. this.$message.error(e.data.msg);
  239. this.listLoading = false;
  240. });
  241. }
  242. }
  243. });
  244. </script>
  245. <style>
  246. .table-body {
  247. padding: 20px;
  248. background-color: #fff;
  249. }
  250. .input-item {
  251. display: inline-block;
  252. width: 250px;
  253. margin: 0 0 20px;
  254. }
  255. .input-item .el-input__inner {
  256. border-right: 0;
  257. }
  258. .input-item .el-input__inner:hover {
  259. border: 1px solid #dcdfe6;
  260. border-right: 0;
  261. outline: 0;
  262. }
  263. .input-item .el-input__inner:focus {
  264. border: 1px solid #dcdfe6;
  265. border-right: 0;
  266. outline: 0;
  267. }
  268. .input-item .el-input-group__append {
  269. background-color: #fff;
  270. border-left: 0;
  271. width: 10%;
  272. padding: 0;
  273. }
  274. .input-item .el-input-group__append .el-button {
  275. padding: 0;
  276. }
  277. .input-item .el-input-group__append .el-button {
  278. margin: 0;
  279. }
  280. .table-body .el-button {
  281. padding: 0 !important;
  282. border: 0;
  283. margin: 0 5px;
  284. }
  285. .el-table thead{
  286. font-size: 14px;
  287. color: #333;
  288. }
  289. </style>