index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <!-- 选品会员商品 -->
  2. <template>
  3. <div class="app-container">
  4. <!-- 查询和其他操作 -->
  5. <div class="filter-container">
  6. <el-select
  7. v-model="listQuery.shelveState" clearable size="mini" class="filter-item"
  8. style="width: 200px;"
  9. placeholder="请选择商品状态"
  10. >
  11. <el-option label="全部" value="" />
  12. <el-option label="已下架" :value="0" />
  13. <el-option label="已上架" :value="1" />
  14. <el-option label="待审核" :value="2" />
  15. <el-option label="审核失败" :value="3" />
  16. </el-select>
  17. <el-input
  18. v-model="listQuery.productId" clearable size="mini" class="filter-item"
  19. style="width: 200px;margin-left: 10px;" placeholder="请输入商品ID"
  20. />
  21. <el-input
  22. v-model="listQuery.productName" clearable size="mini" class="filter-item"
  23. style="width: 200px;margin-left: 10px;" placeholder="请输入商品名称"
  24. />
  25. <el-input
  26. v-model="listQuery.shopName" clearable size="mini" class="filter-item"
  27. style="width: 200px;margin-left: 10px;" placeholder="请输入商户名称"
  28. />
  29. <el-button
  30. size="mini" class="filter-item" type="primary" icon="el-icon-search"
  31. style="margin-left:10px;"
  32. @click="handleSearch"
  33. >
  34. 查找
  35. </el-button>
  36. <el-button size="mini" type="info" class="filter-item" @click="handleReset">
  37. 重置
  38. </el-button>
  39. <br />
  40. <el-button size="mini" type="primary" icon="el-icon-plus" @click="handleProductDataExport">
  41. 导出商品
  42. </el-button>
  43. </div>
  44. <!-- 查询结果 -->
  45. <div v-tableHeight>
  46. <el-table
  47. v-loading="listLoading" height="100%" element-loading-text="正在查询中。。。" :data="list"
  48. v-bind="{ stripe: true, size: 'small', border: true, fit: true, highlightCurrentRow: true }"
  49. >
  50. <el-table-column align="center" width="100" label="商品ID" prop="productId" fixed="left" />
  51. <el-table-column align="center" width="100" label="商品主图" prop="image">
  52. <template slot-scope="{ row }">
  53. <el-image
  54. v-if="row.image" lazy :src="common.seamingImgUrl(row.image)" style="width:40px; height:40px"
  55. fit="cover" :preview-src-list="[ common.seamingImgUrl(row.image) ]"
  56. />
  57. <span v-else>--</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column prop="productName" label="商品名称" width="180" />
  61. <el-table-column prop="shopName" label="商家名称" width="180" />
  62. <el-table-column prop="supplierName" label="供应商名称" width="180" />
  63. <el-table-column prop="classifyHierarchy" label="分类层级" width="180" />
  64. <el-table-column prop="sectionPrice" label="售价区间" show-overflow-tooltip />
  65. <!-- <el-table-column prop="memberSection" label="会员价" show-overflow-tooltip /> -->
  66. <el-table-column prop="stockNumber" label="库存" show-overflow-tooltip />
  67. <el-table-column prop="volume" label="实际销售" show-overflow-tooltip />
  68. <el-table-column prop="fictitiousNumber" label="虚拟销售" show-overflow-tooltip />
  69. <el-table-column align="center" width="150" label="创建时间" prop="createTime" />
  70. <el-table-column align="center" label="上架状态" prop="shelveState">
  71. <template slot-scope="{ row }">
  72. <el-tag v-if="row.shelveState === 0">已下架</el-tag>
  73. <el-tag v-else-if="row.shelveState === 1">已上架</el-tag>
  74. <el-tag v-else-if="row.shelveState === 2">待审核</el-tag>
  75. <el-tag v-else-if="row.shelveState === 3">审核失败</el-tag>
  76. <span v-else>--</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column align="center" label="操作" width="220" fixed="right" class-name="small-padding fixed-width">
  80. <template slot-scope="{ row }">
  81. <el-button v-if="row.shelveState === 1" type="text" @click="handleOffShelf(row)">
  82. 强制下架
  83. </el-button>
  84. <el-button
  85. v-if="row.shelveState === 1" type="text"
  86. @click="$refs.VirtualSales && $refs.VirtualSales.handleOpen(row)"
  87. >
  88. 虚拟销量
  89. </el-button>
  90. <el-button
  91. v-if="row.shelveState === 2" type="danger" size="mini"
  92. @click="$refs.ProductReview && $refs.ProductReview.handleOpen(row)"
  93. >
  94. 审核
  95. </el-button>
  96. <el-button type="warning" size="mini" @click="handleDetail(row)">
  97. 详情
  98. </el-button>
  99. <el-button
  100. v-if="row.shelveState === 1" type="danger" size="mini"
  101. @click="$refs.AddSelection && $refs.AddSelection.handleOpen(row)"
  102. >
  103. 加入选品
  104. </el-button>
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. </div>
  109. <div>
  110. <el-pagination
  111. :current-page="listQuery.page" :page-sizes="[10, 20, 50, 100]" :page-size="listQuery.pageSize"
  112. layout="total, sizes, prev, pager, next, jumper" :total="total"
  113. @size-change="(val) => ((listQuery.pageSize = val) && getList())"
  114. @current-change="(val) => ((listQuery.page = val) && getList())"
  115. />
  116. </div>
  117. <!-- 商品审核 -->
  118. <ProductReview ref="ProductReview" @success="getList" />
  119. <!-- 设置虚拟销量 -->
  120. <VirtualSales ref="VirtualSales" @success="getList" />
  121. <!-- 加入选品 -->
  122. <AddSelection ref="AddSelection" @success="getList" />
  123. <!-- 查看详情 -->
  124. <DetailModal ref="DetailModal" />
  125. </div>
  126. </template>
  127. <script>
  128. import {
  129. getClassifyGetAll,
  130. Forced,
  131. productExport
  132. } from '@/api/commodity'
  133. import ProductReview from '../../renovation/commoditySystem/components/ProductReview'
  134. import VirtualSales from '../../renovation/commoditySystem/components/VirtualSales'
  135. import AddSelection from '../../renovation/commoditySystem/components/AddSelection'
  136. import DetailModal from '../../renovation/commoditySystem/components/DetailModal'
  137. export default {
  138. name: 'SelectionMemberCommodity',
  139. components: {
  140. ProductReview,
  141. VirtualSales,
  142. AddSelection,
  143. DetailModal
  144. },
  145. data() {
  146. return {
  147. list: [],
  148. total: 0,
  149. listLoading: true,
  150. listQuery: {
  151. shelveState: '', // 商品状态 0-已下架 1-已上架 2-待审核 3-审核失败
  152. productName: '', // 商品名称
  153. productId: '', // 商品ID
  154. shopName: '', // 商户名称
  155. page: 1, // 当前页
  156. pageSize: 20,
  157. shopType: 4
  158. }
  159. }
  160. },
  161. created() {
  162. this.getList()
  163. },
  164. methods: {
  165. async getList() {
  166. this.listLoading = true
  167. try {
  168. const res = await getClassifyGetAll(this.listQuery)
  169. this.list = res.data.list
  170. this.total = res.data.total
  171. } finally {
  172. this.listLoading = false
  173. }
  174. },
  175. handleSearch() {
  176. this.listQuery.page = 1
  177. this.getList()
  178. },
  179. handleReset() {
  180. this.listQuery = { shelveState: '', productName: '', productId: '', shopName: '', page: 1, pageSize: 5 }
  181. this.getList()
  182. },
  183. handleDetail(row) {
  184. this.$refs.DetailModal && this.$refs.DetailModal.handleOpen(row)
  185. },
  186. handleOffShelf(row) {
  187. this.$confirm('确定下架此商品吗?')
  188. .then(async () => {
  189. await Forced({ productId: row.productId })
  190. this.$message({ message: '下架成功!', type: 'success' })
  191. this.handleSearch()
  192. })
  193. .catch(() => { })
  194. },
  195. // 导出商品
  196. async handleProductDataExport() {
  197. this.$message({
  198. message: '数据导出中,请勿重复操作!',
  199. type: 'success'
  200. })
  201. const res = await productExport(this.listQuery)
  202. if (!res) {
  203. return
  204. }
  205. const blob = new Blob([ res ], { type: 'application/vnd.ms-excel' })
  206. const fileName = '商品数据明细表.xls'
  207. if ('download' in document.createElement('a')) {
  208. // 非IE下载
  209. const elink = document.createElement('a')
  210. elink.download = fileName
  211. elink.style.display = 'none'
  212. elink.href = URL.createObjectURL(blob)
  213. document.body.appendChild(elink)
  214. elink.click()
  215. URL.revokeObjectURL(elink.href) // 释放URL 对象
  216. document.body.removeChild(elink)
  217. } else {
  218. // IE10+下载
  219. navigator.msSaveBlob(blob, fileName)
  220. }
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .app-container {
  227. padding: 20px;
  228. display: flex;
  229. flex-direction: column;
  230. .filter-container {
  231. .filter-item {
  232. display: inline-block;
  233. vertical-align: middle;
  234. margin-bottom: 10px;
  235. }
  236. }
  237. .small-padding {
  238. .cell {
  239. padding-left: 5px;
  240. padding-right: 5px;
  241. }
  242. }
  243. .fixed-width {
  244. .el-button--mini {
  245. padding: 7px 10px;
  246. }
  247. }
  248. }
  249. </style>