priceSetting.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="content">
  3. <u-cell-group>
  4. <u-cell-item title="显示价格">
  5. <u-switch slot="right-icon" @change="changeShowPrice" v-model="showPrice"></u-switch>
  6. </u-cell-item>
  7. <u-cell-item title="显示价格类型" v-if="showPrice" :value="priceTypeName||'请选择'" @click="showPriceType=true"></u-cell-item>
  8. <u-cell-item title="员工是否可见进货价" v-if="showPrice&&priceType == 'PURCHASES_PRICE'">
  9. <u-switch slot="right-icon" @change="changeShowJhPrice" v-model="showJhPrice"></u-switch>
  10. </u-cell-item>
  11. </u-cell-group>
  12. <!-- 价格类型列表 -->
  13. <u-action-sheet :list="priceTypeList" v-model="showPriceType" @click="clickAction"></u-action-sheet>
  14. </view>
  15. </template>
  16. <script>
  17. import { findPriceShow, savePriceShow } from '@/api/shelf'
  18. export default {
  19. data() {
  20. return {
  21. showPrice: false,
  22. showJhPrice: false,
  23. showPriceType: false,
  24. priceTypeList:[],
  25. priceType:'',
  26. priceTypeName:''
  27. }
  28. },
  29. onLoad() {
  30. this.priceTypeList = this.$store.state.vuex_priceTypeList
  31. this.priceTypeList.map(item => {
  32. item.text = item.dispName
  33. item.fontSize = 30
  34. })
  35. },
  36. onReady() {
  37. this.pageInit()
  38. },
  39. methods: {
  40. async pageInit(){
  41. await findPriceShow({paramCode:'PRICE_SHOW'}).then(res => {
  42. this.showPrice = res.data ? res.data.paramValue=='1' : false
  43. this.$store.state.vuex_showPrice[0] = this.showPrice
  44. })
  45. await findPriceShow({paramCode:'PRICE_SHOW_TYPE'}).then(res => {
  46. if(res.data&&res.data.paramValue){
  47. this.priceType = res.data.paramValue
  48. this.priceTypeName = this.priceTypeList.find(item => item.code == res.data.paramValue).dispName
  49. this.$store.state.vuex_showPrice[1] = this.priceType
  50. }
  51. })
  52. await findPriceShow({paramCode:'PRICE_SHOW_EMPLOYEE'}).then(res => {
  53. this.showJhPrice = res.data ? res.data.paramValue=='1' : false
  54. this.$store.state.vuex_showPrice[2] = this.showJhPrice
  55. })
  56. },
  57. savePrice(data,value){
  58. savePriceShow({
  59. paramCode:data,
  60. paramValue: value
  61. }).then(res => {
  62. if(res.status == 200){
  63. uni.showToast({
  64. icon:'none',
  65. title: res.message
  66. })
  67. }
  68. this.pageInit()
  69. })
  70. },
  71. changeShowPrice(v){
  72. this.savePrice('PRICE_SHOW',v?'1':'0')
  73. },
  74. clickAction(index){
  75. this.savePrice('PRICE_SHOW_TYPE',this.priceTypeList[index].code)
  76. },
  77. changeShowJhPrice(v){
  78. this.savePrice('PRICE_SHOW_EMPLOYEE',v?'1':'0')
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="less">
  84. .content{
  85. width: 100%;
  86. height: 100vh;
  87. }
  88. </style>