sell.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <div class='deviceSell'>
  3. <div class='plr15 ptb20 c-333 c-f14 bgc-fff c-border-b flex f_y_c f_x_s'>
  4. <div>当前售货状态:<span>{{status? '在售' : '停售'}}</span></div>
  5. <van-switch @change="switchSell" inactive-color='#ccc' active-color='#17b3ec' v-model="status" />
  6. </div>
  7. </div>
  8. </template>
  9. <script>
  10. import medicineAbinetApi from '@/api/api-medicineAbinet'
  11. export default{
  12. name: 'deviceSell',
  13. data(){
  14. return {
  15. status: this.$route.query.status==1,
  16. }
  17. },
  18. created(){
  19. },
  20. methods:{
  21. switchSell(flag){
  22. this.$dialog.confirm({
  23. title: '',
  24. message: '确认进行该操作?',
  25. })
  26. .then(() => {
  27. this.$loading('保存中')
  28. var p = {
  29. deviceId: this.$route.query.id,
  30. saleStatus: flag? 1 : 2
  31. }
  32. medicineAbinetApi
  33. .updateSaleStatus(p)
  34. .then(res => {
  35. this.$emitRefreshPage('deviceDetail')
  36. this.$emitRefreshPage('deviceIndex')
  37. this.$toast('操作成功')
  38. })
  39. .catch(err=>{
  40. console.error(err)
  41. })
  42. })
  43. .catch(err=>{
  44. this.status = !flag
  45. })
  46. },
  47. }
  48. }
  49. </script>
  50. <style scoped lang='scss'>
  51. .deviceSell{
  52. }
  53. </style>