limit.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <div>
  3. <use-table ref="tbl"></use-table>
  4. <div class="container_status dflex_vertical_c">
  5. <div class="item_interval" v-for="(item, i) in stateDatas" :key="i">
  6. <el-button class="badge_txt" :class="{ active: item.cnt == req.state }" size="small" @click="cutSta(item)">{{ item.name }}</el-button>
  7. <!-- <v-countup class="badge" start-value="0" :end-value="item.cnt"></v-countup> -->
  8. </div>
  9. </div>
  10. <div class="container padding_b_0">
  11. <div class="dflex_wrap">
  12. <div class="dflex_vertical_c margin_r_40 margin_b_20">
  13. <div class="search_name">商品名称:</div>
  14. <el-input v-model="req.name" placeholder="请输入" @input="loadData" class="search_input"></el-input>
  15. </div>
  16. <el-button size="mini" class="search_btn margin_b_20 margin_r_40" @click="loadData">搜索</el-button>
  17. </div>
  18. </div>
  19. <div class="container use-table">
  20. <div class="dflex_sb margin_b_15">
  21. <div></div>
  22. <el-button class="add_btn pos_r padding0" icon="iconfont iconxinzeng" @click="toAdd">新增</el-button>
  23. </div>
  24. <el-table :height="tblHeight" :data="tableDatas" highlight-current-row>
  25. <!-- <el-table-column label="排序" width="200" align="center">
  26. <template slot-scope="scope">
  27. <el-input-number size="small" :min="1" v-model="scope.row.sort" @change="sortChange(scope.row)" @blur="sortChange(scope.row)"></el-input-number>
  28. </template>
  29. </el-table-column> -->
  30. <el-table-column label="商品" width="330" align="center">
  31. <template slot-scope="scope">
  32. <div class="dflex_vertical_c">
  33. <el-image v-if="scope.row.imgs.search(',')==(-1)" style="width: 100px;height: 80px;" :src="scope.row.imgs || require('static/img/noimage.png')" :preview-src-list="scope.row.imgs" fit="contain"></el-image>
  34. <el-image v-else style="width: 100px;height: 80px;" :src="((scope.row.imgs).substring(0, ((scope.row.imgs).indexOf(',')))) || require('static/img/noimage.png')" :preview-src-list="scope.row.imgs" fit="contain"></el-image>
  35. <div class="left_just margin_l_10">
  36. <div class="ellipsis">{{ scope.row.name }}</div>
  37. </div>
  38. </div>
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="价格" align="center">
  42. <template slot-scope="scope">
  43. <div class="price">{{ scope.row.price}}</div>
  44. <div class="m_price">{{ scope.row.marketPrice}}</div>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="状态" align="center">
  48. <template slot-scope="scope">
  49. <template v-if="scope.row.state==0">下架</template>
  50. <template v-if="scope.row.state==1">在售</template>
  51. <template v-if="scope.row.state==2">待审核</template>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="数据统计" align="left" width="150">
  55. <template slot-scope="scope">
  56. <div class="left_just">
  57. <div>已售数:{{ scope.row.saleCnt }}</div>
  58. <div>访问数:{{ scope.row.visitCnt }}</div>
  59. <div>收藏数:{{ scope.row.collectCnt }}</div>
  60. <!-- <div>分享数:{{ scope.row.shareCnt }}</div> -->
  61. </div>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="限时精选" align="center">
  65. <template slot-scope="scope">
  66. <el-tooltip :content="scope.row.limited == '1' ? '点击取消限时精选' : '点击启用限时精选'" placement="top" :hide-after="1000" :enterable="false" effect="light">
  67. <el-switch
  68. v-model="scope.row.limited"
  69. active-color="#ff6a6c"
  70. inactive-color="#bbb"
  71. active-value="1"
  72. inactive-value="0"
  73. @change="limitedChange(scope.row)"
  74. ></el-switch>
  75. </el-tooltip>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="标签" width="220" align="center">
  79. <template slot-scope="scope">
  80. <div class="left_just">
  81. <el-tag effect="plain" class="margin_t_5 margin_r_5" type="info" v-for="(item, i) in scope.row.goodsServiceTags" :key="i">{{ item.tagName }}</el-tag>
  82. </div>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <el-pagination
  87. :current-page="req.page"
  88. :page-sizes="[10, 20, 30, 50, 100]"
  89. :page-size="req.rows"
  90. layout="total, sizes, prev, pager, next, jumper"
  91. :total="tableTotal"
  92. @size-change="sizeChange"
  93. @current-change="currentChange"
  94. ></el-pagination>
  95. <popupsGoods ref="child" @choiceGoods="choiceGoods"></popupsGoods>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. import vCountup from 'vue-countupjs';
  101. import popupsGoods from '@/components/popups_goods';
  102. // import useTable from '../../components/use-table/use-table.vue'
  103. const __name = 'usemall-goods';
  104. export default {
  105. components: {
  106. vCountup,
  107. popupsGoods,
  108. // useTable
  109. },
  110. data() {
  111. return {
  112. state1: 1,//0下架 1在售 2 待审核
  113. stateObj: {
  114. 待审核: '2',
  115. 销售中: '1',
  116. 已下架: '0',
  117. 全部: ''
  118. },
  119. stateDatas: [],
  120. req: {
  121. limited: 1,
  122. page: 1,
  123. rows: 10,
  124. orderby: 'sort asc',
  125. name: '',
  126. state: ''
  127. },
  128. tblHeight: 0,
  129. tableDatas: [],
  130. tableTotal: 0,
  131. };
  132. },
  133. methods: {
  134. loadData(e) {
  135. var _self=this
  136. _self.stateDatas = [];
  137. for (let key in _self.stateObj) {
  138. _self.stateDatas.push({
  139. name: key,
  140. cnt: _self.stateObj[key]
  141. });
  142. }
  143. _self.$axios.get("/goods/admin/list",
  144. {
  145. params:{
  146. 'curPage':_self.req.page,
  147. 'pageSize':_self.req.rows,
  148. 'goodsName':e,//商品名称搜索
  149. 'state':_self.req.state,//商品状态0下架 1在售 2 待审核
  150. 'limited':1,//是否限时精选;0否1是
  151. },
  152. headers:{
  153. 'Mall-Token': uni.getStorageSync("token")
  154. }
  155. }).then(response => {
  156. let res = response
  157. if (res.success) {
  158. // if (res.data.list && res.data.list.state) {
  159. // _self.stateDatas = res.data.list.state
  160. // }
  161. res.data.list.forEach(row => {
  162. // row.imgs = [row.imgs];
  163. // row.limited = row.limited + '';
  164. });
  165. _self.tableDatas = res.data.list;
  166. _self.tableTotal = res.data.totalCount;
  167. } else {
  168. }
  169. }).catch(res =>{
  170. });
  171. // this.$db[__name]
  172. // .where({ limited: 1 })
  173. // .whereif(this.req.state && this.req.state != '全部', { state: this.req.state })
  174. // .whereif(this.req.name, { name: new RegExp(this.req.name) })
  175. // .withgroup({ field: 'state', obj: this.stateObj })
  176. // .totable(this.req)
  177. // .then(res => {
  178. // if (res.code == 200) {
  179. // if (res.datas.group && res.datas.group.datas) {
  180. // this.stateDatas = res.datas.group.datas;
  181. // }
  182. // res.datas.rows.forEach(row => {
  183. // row.imgs = [row.img];
  184. // row.limited = row.limited + '';
  185. // });
  186. // this.tableDatas = res.datas.rows;
  187. // this.tableTotal = res.datas.total;
  188. // }
  189. // });
  190. },
  191. toAdd() {
  192. this.$refs.child.show({
  193. limited: 0
  194. });
  195. },
  196. choiceGoods(datas) {
  197. let ids = datas.map(x => x.id);
  198. if (ids && ids.length > 0) {
  199. // this.$db[__name]
  200. // .where(`in(id, ${JSON.stringify(ids)})`)
  201. // .update('', { limited: 1 })
  202. // .then(res => {
  203. // if (res.code == 200) this.loadData();
  204. // });
  205. }
  206. },
  207. limitedChange(row) {
  208. if(row.limited=='1'){
  209. var type=1
  210. }else if(row.limited=='0'){
  211. var type=0
  212. }
  213. this.$axios.put("/goods/admin/hot-limited-change",
  214. {
  215. "action": "2",//1热门推荐、2限时精选
  216. "goodIds": [row.id],
  217. "type": type//1新增、0取消
  218. },
  219. {
  220. headers:{
  221. 'Mall-Token': uni.getStorageSync("token")
  222. }
  223. }).then(response => {
  224. let res = response
  225. if (res.success) {
  226. this.loadData();
  227. } else {
  228. }
  229. }).catch(res =>{
  230. });
  231. // this.$db[__name].update(row.id, { limited: parseInt(row.limited) }).then(res => {
  232. // if (res.code == 200) this.loadData();
  233. // });
  234. },
  235. sortChange(row) {
  236. if (row.sort == '') {
  237. return;
  238. }
  239. this.$axios.put("/goods/admin/sort/"+row.id,
  240. {
  241. "sort":row.sort
  242. },
  243. {
  244. headers:{
  245. 'Mall-Token': uni.getStorageSync("token")
  246. }
  247. }).then(response => {
  248. let res = response
  249. if (res.success) {
  250. this.loadData();
  251. } else {
  252. }
  253. }).catch(res =>{
  254. });
  255. // this.$db[__name].update(row._id, { sort: row.sort }).then(res => {
  256. // if (res.code == 200) this.loadData();
  257. // });
  258. },
  259. cutSta(item) {
  260. this.state1 = item.cnt;
  261. this.req.state = item.cnt;
  262. this.loadData();
  263. },
  264. sizeChange(size) {
  265. this.req.rows = size;
  266. this.loadData();
  267. },
  268. currentChange(current) {
  269. this.req.page = current;
  270. this.loadData();
  271. }
  272. },
  273. created() {
  274. this.loadData();
  275. },
  276. updated() {
  277. if (!this.tblHeight) {
  278. this.tblHeight = this.$refs.tbl.tblHeight;
  279. }
  280. }
  281. };
  282. </script>
  283. <style></style>