index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <div class="wrapper">
  3. <el-tabs v-model="searchForm.type" @tab-click="handleClick">
  4. <el-tab-pane :label="'上架('+type1Count+')'" name="1"></el-tab-pane>
  5. <el-tab-pane :label="'下架('+type2Count+')'" name="2"></el-tab-pane>
  6. <el-tab-pane :label="'审核列表('+type3Count+')'" name="3"></el-tab-pane>
  7. </el-tabs>
  8. <div class="serach flex row space-between">
  9. <el-button class="blackbtn" icon="el-icon-plus" @click="addGoods">新增商品</el-button>
  10. <div class="flex row">
  11. <el-input v-model="searchForm.searchName" placeholder="请输入商品名称/ID" clearable></el-input>
  12. <el-button class="btn_search blackbtn" icon="el-icon-search" @click="search">查询</el-button>
  13. </div>
  14. </div>
  15. <e-table class="table" ref="eTable" :tableHeadConfig="tableHeadConfig" :tableLoadData="tableLoadData"
  16. :pageShow="true" :total="searchForm.total" :currentPage="searchForm.page" :pageSize="searchForm.pageSize"
  17. @getPageList="getPageList" @changeSort="changeSort">
  18. <template v-slot:operation="slotData">
  19. <div class="operationDiv">
  20. <el-button type="text" @click="toEdit(slotData.data.row)" v-if="searchForm.type!='3'">
  21. {{searchForm.type=='1'?'下架':'上架'}}</el-button>
  22. <el-button type="text" @click="toView(slotData.data.row)">查看</el-button>
  23. <el-button type="text" @click="copy(slotData.data.row)">复制</el-button>
  24. </div>
  25. </template>
  26. </e-table>
  27. </div>
  28. </template>
  29. <script>
  30. import eTable from '@/components/base-table'
  31. import {
  32. list,
  33. changeStatus,
  34. getCountByType,
  35. detail,
  36. authDetail
  37. } from '@/api/goods'
  38. import store from '@/store/index'
  39. export default {
  40. name: "goods",
  41. components: {
  42. eTable
  43. },
  44. data() {
  45. return {
  46. type1Count: 0,
  47. type2Count: 0,
  48. type3Count: 0,
  49. searchForm: {
  50. searchName: '',
  51. total: 0,
  52. page: 1,
  53. pageSize: 10,
  54. type: '1',
  55. sortField: '',
  56. sortOrder: ''
  57. },
  58. tableHeadConfig: [{
  59. label: '商品名称',
  60. prop: 'title',
  61. isShow: true,
  62. },
  63. {
  64. label: '商品ID',
  65. prop: 'out_product_id',
  66. isShow: true,
  67. },
  68. {
  69. label: '价格',
  70. prop: 'sale_price',
  71. isShow: true,
  72. sortable: true,
  73. width: 120,
  74. },
  75. {
  76. label: '库存',
  77. prop: 'stock_num',
  78. isShow: true,
  79. sortable: true,
  80. width: 120,
  81. },
  82. {
  83. label: '审核状态',
  84. prop: 'status_name',
  85. isShow: true,
  86. },
  87. {
  88. label: '创建时间',
  89. prop: 'create_time',
  90. isShow: true,
  91. sortable: true
  92. },
  93. {
  94. label: '上架时间',
  95. prop: 'stand_down_time',
  96. isShow: true,
  97. },
  98. {
  99. label: '操作',
  100. columnType: 'operation',
  101. slotName: 'operation',
  102. width: 200,
  103. isShow: true,
  104. }
  105. ],
  106. tableLoadData: [],
  107. };
  108. },
  109. created() {},
  110. methods: {
  111. getPageList(pageRequest) {
  112. if (pageRequest) {
  113. this.searchForm.page = pageRequest.pageIndex;
  114. this.searchForm.pageSize = pageRequest.pageSize;
  115. this.searchForm.sortField=''
  116. this.searchForm.sortOrder =''
  117. if(pageRequest.order){
  118. this.searchForm.sortField = pageRequest.sort;
  119. this.searchForm.sortOrder = pageRequest.order
  120. }
  121. }
  122. list(this.searchForm).then(res => {
  123. this.searchForm.total = res.data.totalCount
  124. this.tableLoadData = res.data.list
  125. })
  126. this.getCount()
  127. },
  128. addGoods() { // 新增商品
  129. this.$router.push({
  130. name: "addGoods",
  131. params: {
  132. isNew:true
  133. }
  134. });
  135. },
  136. handleClick(tab, event) {
  137. if(this.searchForm.type==1){
  138. this.tableHeadConfig[6].isShow=true
  139. this.tableHeadConfig[6].label='上架时间'
  140. }else if(this.searchForm.type==2){
  141. this.tableHeadConfig[6].isShow=true
  142. this.tableHeadConfig[6].label='下架时间'
  143. }else{
  144. this.tableHeadConfig[6].isShow=false
  145. }
  146. this.searchForm.searchName = ''
  147. this.searchForm.page = 1
  148. this.getPageList()
  149. },
  150. copy(row) {
  151. if(this.searchForm.type==1 || this.searchForm.type==2){
  152. detail({outProductId: row.out_product_id}).then(res => {
  153. this.copyToAdd(res)
  154. })
  155. }else{
  156. authDetail({outProductId: row.out_product_id}).then(res => {
  157. this.copyToAdd(res)
  158. })
  159. }
  160. },
  161. copyToAdd(res) {
  162. let params = {}
  163. params.commodity_id = res.data.commodity_id
  164. params.title = res.data.title
  165. params.out_product_id = res.data?.auditInfo?.out_product_id
  166. params.brand_id=res.data.has_brand==0?'-1':res.data.has_brand
  167. params.third=res.data.third_cat_audit==0?res.data.third_cat_id:''
  168. params.stock_num = res.data.stock_num
  169. params.sale_price = res.data.sale_price
  170. params.market_price = res.data.market_price
  171. params.path = res.data.path
  172. params.third_cat_id =res.data.third_cat_audit==0?'-1':res.data.third_cat_id
  173. params.goodsList = [{url: res.data.thumb_img}]
  174. params.goodszizhiList = []
  175. if (res.data.qualificationImgs.length > 0) {
  176. res.data.qualificationImgs.forEach(element => {
  177. params.goodszizhiList.push({
  178. url: element
  179. })
  180. });
  181. }
  182. this.$router.push({
  183. name: "addGoods",
  184. params: {
  185. isNew: true,
  186. data:JSON.stringify(params)
  187. }
  188. });
  189. },
  190. toView(row) {
  191. this.$router.push({
  192. name: "goodsDetail",
  193. params: {
  194. outProductId: row.out_product_id
  195. }
  196. });
  197. },
  198. toEdit(row) {
  199. this.$confirm('确定' + (this.searchForm.type == '1' ? '下架?' : '上架?'), '提示', {
  200. confirmButtonText: '确定',
  201. cancelButtonText: '取消',
  202. type: 'warning'
  203. }).then(() => {
  204. changeStatus({
  205. commodityId: row.commodity_id,
  206. editStatus: this.searchForm.type == '1' ? 11 : 5
  207. }).then(res => {
  208. this.$message.success((this.searchForm.type == '1' ? '下架' : '上架') + '成功');
  209. this.searchForm.searchName = ''
  210. this.searchForm.page = 1
  211. this.getPageList()
  212. })
  213. }).catch(() => {});
  214. },
  215. search() {
  216. this.searchForm.page = 1
  217. this.getPageList()
  218. },
  219. getCount() {
  220. getCountByType().then(res => {
  221. res.data.forEach(element => {
  222. if (element.type == 1) {
  223. this.type1Count = element.count
  224. }
  225. if (element.type == 2) {
  226. this.type2Count = element.count
  227. }
  228. if (element.type == 3) {
  229. this.type3Count = element.count
  230. }
  231. });
  232. })
  233. },
  234. initPage(){
  235. if(this.$route.params.checking){
  236. this.searchForm.type='3'
  237. this.getPageList()
  238. }
  239. }
  240. },
  241. activated() {
  242. this.getPageList()
  243. this.initPage()
  244. },
  245. mounted() {
  246. }
  247. };
  248. </script>
  249. <style lang="less" scoped>
  250. .wrapper{
  251. .btn_search {
  252. width: 150px;
  253. margin-left: 10px;
  254. }
  255. .serach {
  256. width: 100%;
  257. margin-bottom: 10px;
  258. }
  259. }
  260. </style>