table.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <scTable ref="table" :apiObj="list.apiObj" :params="searchKey" @selectionChange="selectionChange" row-key="id">
  3. <el-table-column type="selection" width="50" fixed="left"></el-table-column>
  4. <el-table-column label="商品ID" width="180" fixed="left" prop="goods_id">
  5. <template #default="scope">
  6. {{ scope.row.goods_id?scope.row.goods_id:'审核中' }}
  7. </template>
  8. </el-table-column>
  9. <el-table-column label="商品类型" prop="types" width="100"></el-table-column>
  10. <el-table-column label="商品信息" width="340" prop="name">
  11. <template #default="scope">
  12. <div class="goods-img">
  13. <div class="img">
  14. <el-image
  15. style="width: 54px; height: 54px"
  16. :src="scope.row.image_list[0].url"
  17. :zoom-rate="1.2"
  18. :max-scale="7"
  19. :min-scale="0.2"
  20. :preview-src-list="[scope.row.image_list[0].url]"
  21. preview-teleported
  22. z-index="999"
  23. fit="cover"></el-image>
  24. </div>
  25. <div class="name">
  26. <span>{{ scope.row.product_name }}</span>
  27. <span class="dec">商品编码:{{ scope.row.product_id }}</span>
  28. </div>
  29. </div>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="价格" width="200" prop="id">
  33. <template #default="scope">
  34. <div class="price">{{ $TOOL.moneyFormat(scope.row.price) }}</div>
  35. <div class="goods-price">
  36. <div class="del">{{ $TOOL.moneyFormat(scope.row.line_price) }}</div>
  37. <span>{{ $TOOL.disFormat(scope.row.price,scope.row.line_price) }}折</span></div>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="剩余库存" prop="category_id" width="120">
  41. <template #default="scope">
  42. <span v-if="scope.row.limit_use_rule==1">{{ scope.row.use_num_per_consume }}</span>
  43. <span v-else>不限</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="状态" prop="enable" width="120" align="center">
  47. <template #default="scope">
  48. <div class="status-success" v-if="scope.row.status==1"><sc-status-indicator type="success"></sc-status-indicator> 正常</div>
  49. <div class="status-danger" v-if="scope.row.status==2"><sc-status-indicator type="danger"></sc-status-indicator> 禁用</div>
  50. <div class="status-danger" v-if="scope.row.status==0"><sc-status-indicator type="danger"></sc-status-indicator> 审核中</div>
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="创建时间" prop="create_at" width="180"></el-table-column>
  54. <el-table-column label="操作" width="180" align="left" fixed="right">
  55. <template #default="scope">
  56. <el-button-group>
  57. <el-button size="warning" text @click="table_life(scope.row)">来客下架</el-button>
  58. </el-button-group>
  59. <el-button-group>
  60. <el-button size="small" text @click="table_view(scope.row)">编辑</el-button>
  61. <el-button type="danger" text size="small" @click="table_del(scope.row)">删除</el-button>
  62. </el-button-group>
  63. </template>
  64. </el-table-column>
  65. </scTable>
  66. <formMain ref="formMain" @success="handleSuccess"></formMain>
  67. </template>
  68. <script>
  69. import formMain from './form';
  70. export default {
  71. components: {
  72. formMain
  73. },
  74. data(){
  75. return {
  76. list: {
  77. apiObj: this.$API.merGoods.list
  78. },
  79. dataSelect:[],
  80. dataSelectFull:[],
  81. searchKey:{}
  82. }
  83. },
  84. methods: {
  85. table_auth(data){
  86. this.$nextTick(() => {
  87. this.$refs.comboMain.open("edit").setData(data)
  88. })
  89. },
  90. table_life(data){
  91. this.$confirm(`来客下架成功后,在小程序中将不展示该商品,同时也将无法二次上架`, '提示', {
  92. type: 'warning'
  93. }).then(async ()=>{
  94. var resp = await this.$API.merGoods.off.post({"id":data.id});
  95. if (resp.code == 0) {
  96. return this.$message.error(resp.msg);
  97. }
  98. this.$message.success(resp.msg);
  99. this.$emit("success");
  100. }).catch(()=>{})
  101. },
  102. table_view(data){
  103. this.$router.push({path:"/merchant/goods/edit",query:{"product_id":data.product_id,"id":data.id,"spm":(new Date()).getTime()}})
  104. },
  105. table_del(data){
  106. this.$confirm(`删除店铺后,所有有关该店铺的门店、订单等信息都将删除,不可恢复,确定要执行删除吗`, '提示', {
  107. type: 'warning'
  108. }).then(async ()=>{
  109. var resp = await this.$API.shop.del.post({"id":data.id});
  110. if (resp.code == 0) {
  111. return this.$message.error(resp.msg);
  112. }
  113. this.$message.success(resp.msg);
  114. this.$emit("success");
  115. }).catch(()=>{})
  116. },
  117. refresh(){
  118. this.$refs.table.refresh()
  119. },
  120. upData(data){
  121. this.$refs.table.upData(data)
  122. },
  123. handleSuccess(){
  124. this.$refs.table.refresh()
  125. },
  126. sortChange(event){
  127. if (event.order) {
  128. var data = {
  129. "field":event.prop,
  130. "order":event.order
  131. }
  132. this.$refs.table.upData(data)
  133. } else {
  134. this.$refs.table.reload(this.searchKey)
  135. }
  136. return ;
  137. },
  138. selectionChange(event){
  139. this.dataSelect = [];
  140. var arr = [];
  141. var arrCompany = [];
  142. event.forEach(function(val,index){
  143. arr[index] = val.id;
  144. arrCompany[index] = val;
  145. });
  146. this.dataSelectFull = arrCompany;
  147. this.dataSelect = arr;
  148. this.$emit("success",this.dataSelect);
  149. this.$emit("successFull",this.dataSelectFull);
  150. },
  151. table_passwd(row){
  152. this.$nextTick(() => {
  153. this.$refs.userPasswd.open("edit").setData(row)
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style>
  160. .goods-img{display: flex;gap: 5px;}
  161. .goods-img .name span{display: block;}
  162. .goods-img .name span.dec{color: #999;font-size: 12px;}
  163. .goods-price,.price{display: flex;align-items: center;gap: 5px;font-size: 14px;}
  164. .goods-price .del{text-decoration: line-through;}
  165. .goods-price span{background-color: #fff !important;
  166. border: 1px solid #d3d9e0 !important;
  167. border-radius: 4px;
  168. box-sizing: border-box;
  169. color: #6c737a !important;
  170. display: inline-flex;
  171. flex: none;
  172. font-size: 12px;
  173. line-height: 18px !important;
  174. padding: 1px 6px !important;text-decoration: none;}
  175. </style>