priceSetting.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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,findPriceShowType,findPriceShowEmployee,savePriceShow,savePriceShowType,savePriceShowEmployee } 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. this.showPrice = this.$store.state.vuex_showPrice[0]
  39. this.priceType = this.$store.state.vuex_showPrice[1]
  40. this.priceTypeName = this.priceTypeList.find(item => item.code == this.priceType).dispName
  41. this.showJhPrice = this.$store.state.vuex_showPrice[2]
  42. },
  43. methods: {
  44. async pageInit(){
  45. await findPriceShow().then(res => {
  46. this.showPrice = res.data ? res.data.paramValue=='1' : false
  47. this.$store.state.vuex_showPrice[0] = this.showPrice
  48. })
  49. await findPriceShowType().then(res => {
  50. if(res.data&&res.data.paramValue){
  51. this.priceType = res.data.paramValue
  52. this.priceTypeName = this.priceTypeList.find(item => item.code == res.data.paramValue).dispName
  53. this.$store.state.vuex_showPrice[1] = this.priceType
  54. }
  55. })
  56. await findPriceShowEmployee().then(res => {
  57. this.showJhPrice = res.data ? res.data.paramValue=='1' : false
  58. this.$store.state.vuex_showPrice[2] = this.showJhPrice
  59. })
  60. },
  61. savePrice(data,value){
  62. let fun = savePriceShow
  63. if(data == 'PRICE_SHOW_TYPE'){
  64. fun = savePriceShowType
  65. }
  66. if(data == 'PRICE_SHOW_EMPLOYEE'){
  67. fun = savePriceShowEmployee
  68. }
  69. fun({
  70. paramValue: value
  71. }).then(res => {
  72. if(res.status == 200){
  73. uni.showToast({
  74. icon:'none',
  75. title: res.message
  76. })
  77. }
  78. this.pageInit()
  79. })
  80. },
  81. changeShowPrice(v){
  82. this.savePrice('PRICE_SHOW',v?'1':'0')
  83. },
  84. clickAction(index){
  85. this.savePrice('PRICE_SHOW_TYPE',this.priceTypeList[index].code)
  86. },
  87. changeShowJhPrice(v){
  88. this.savePrice('PRICE_SHOW_EMPLOYEE',v?'1':'0')
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="less">
  94. .content{
  95. width: 100%;
  96. height: 100vh;
  97. }
  98. </style>