priceSetting.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="page-body">
  3. <view class="scroll-list">
  4. <view
  5. class="check-order-list"
  6. v-for="(item,index) in list"
  7. :key="item.id"
  8. >
  9. <view class="flex align_center justify_between">
  10. <view class="u-name">
  11. <text style="margin-right: 0.5rem;">{{item.userName}}</text>
  12. </view>
  13. <view class="u-mobile">
  14. <text v-if="item.isManager == 1">门店负责人 / </text>
  15. <text v-else>{{item.roleName?item.roleName + '/':''}}</text>
  16. {{item.phone}}
  17. </view>
  18. </view>
  19. <view class="price-item">
  20. <u-checkbox-group>
  21. <u-checkbox
  22. @change="(e)=>priceChange(e,item)"
  23. v-for="(priceItem, priceIndex) in item.priceTypeList" :key="priceItem.id"
  24. v-model="priceItem.checked"
  25. :name="priceItem.val"
  26. >{{priceItem.name}}</u-checkbox>
  27. </u-checkbox-group>
  28. </view>
  29. <view class="price-show-list flex align_center" v-if="item.priceTypeList.length == 2&&item.showListPrice">
  30. <text>列表显示</text>
  31. <view>
  32. <u-radio-group v-model="item.showListPriceVal" @change="(e)=>priceShowChange(e,item)">
  33. <u-radio
  34. v-for="(priceItem, priceIndex) in priceShowType" :key="priceItem.id"
  35. :name="priceItem.code"
  36. >
  37. {{priceItem.dispName}}
  38. </u-radio>
  39. </u-radio-group>
  40. </view>
  41. </view>
  42. </view>
  43. <view style="padding:0 30upx 30upx;">
  44. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  45. <u-loadmore v-if="(total>=list.length&&list.length)||status=='loading'" :status="status" />
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import {searchEmployee, delEmployee } from '@/api/employee'
  52. import { queryQplsConfig, queryShelfUserParam, updateShelfUserParam } from '@/api/shelf.js'
  53. import moment from 'moment'
  54. export default{
  55. name:'personnel',
  56. data(){
  57. return{
  58. status: 'loading',
  59. noDataText: '暂无数据',
  60. // 查询条件
  61. list: [],
  62. total: 0,
  63. shelfSn: null,
  64. priceType:[{
  65. val: 'PURCHASES_PRICE',
  66. name: '进货价',
  67. show: false,
  68. checked: false
  69. },
  70. {
  71. val: 'CAR_OWNER_PRICE',
  72. name: '车主价',
  73. show: false,
  74. checked: false
  75. }],
  76. priceShowType:[]
  77. }
  78. },
  79. computed:{
  80. hasShelf(){
  81. return this.$store.state.vuex_storeShelf
  82. },
  83. configPrice(){
  84. return this.$store.state.vuex_configPrice
  85. }
  86. },
  87. onLoad() {
  88. this.shelfSn = this.hasShelf.shelfSn
  89. this.priceShowType = this.$store.state.vuex_priceTypeList
  90. this.getPriceCofig()
  91. },
  92. onShow() {
  93. this.getRow()
  94. },
  95. methods:{
  96. // 获取价格配置
  97. getPriceCofig(){
  98. this.priceType[0].show = this.configPrice.shelf_cost_show == '1' || this.configPrice.non_shelf_cost_show == '1'
  99. this.priceType[1].show = this.configPrice.shelf_price_show == '1' || this.configPrice.non_shelf_price_show == '1'
  100. },
  101. priceChange(e,item){
  102. console.log(e,item)
  103. const row = item.storeParamList.find(k => k.paramCode == e.name)
  104. this.updateData({id:row.id,paramValue:e.value?'1':'0'})
  105. },
  106. priceShowChange(e,item){
  107. console.log(e,item)
  108. const row = item.storeParamList.find(k => k.paramCode == 'PRICE_SHOW_TYPE')
  109. this.updateData({id:row.id,paramValue:e})
  110. },
  111. // 修改数据
  112. updateData(params){
  113. uni.showLoading({
  114. title:'正在修改...'
  115. })
  116. updateShelfUserParam(params).then(res => {
  117. if(res.status == 200){
  118. this.getRow()
  119. }
  120. uni.hideLoading()
  121. })
  122. },
  123. // 格式化数据
  124. formatData(){
  125. this.list.map(item => {
  126. const a = item.storeParamList
  127. const pst = a.find(b=>b.paramCode=='PRICE_SHOW_TYPE') // 列表显示价格值
  128. item.showListPriceVal = pst?pst.paramValue:''
  129. const cop = a.find(b=>b.paramCode=='CAR_OWNER_PRICE') // 车主价值
  130. item.carPriceVal = cop?cop.paramValue:''
  131. const pp = a.find(b=>b.paramCode=='PURCHASES_PRICE') // 进货价值
  132. item.ppPriceVal = pp?pp.paramValue:''
  133. item.priceTypeList = JSON.parse(JSON.stringify(this.priceType.filter(item => item.show)))
  134. // 赋值
  135. item.priceTypeList.map(key => {
  136. key.id = item.userId + '-' + key.val
  137. // 车主价
  138. if(key.val == 'CAR_OWNER_PRICE'){
  139. key.checked = item.carPriceVal == '1'
  140. }
  141. // 进货价
  142. if(key.val == 'PURCHASES_PRICE'){
  143. key.checked = item.ppPriceVal == '1'
  144. }
  145. })
  146. // 列表显示价格一行是否显示
  147. const showListPrice = item.priceTypeList.filter(item => item.checked)
  148. item.showListPrice = showListPrice.length == 2
  149. })
  150. this.list.splice()
  151. console.log(this.list)
  152. },
  153. // 查询列表
  154. getRow () {
  155. let _this = this
  156. this.status = "loading"
  157. queryShelfUserParam({shelfSn: this.shelfSn}).then(res => {
  158. if (res.code == 200 || res.status == 204 || res.status == 200) {
  159. _this.list = res.data || []
  160. _this.total = res.data.length
  161. } else {
  162. _this.list = []
  163. _this.total = 0
  164. _this.noDataText = res.message
  165. }
  166. _this.formatData()
  167. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  168. })
  169. },
  170. }
  171. }
  172. </script>
  173. <style lang="less">
  174. .page-body{
  175. height: 100vh;
  176. padding:0;
  177. .scroll-list{
  178. height: 100vh;
  179. overflow: auto;
  180. .check-order-list{
  181. background: #ffffff;
  182. padding: 10upx 20upx;
  183. margin: 25rpx;
  184. border-radius: 20upx;
  185. box-shadow: 1px 1px 3px #EEEEEE;
  186. > view{
  187. padding: 0.8rem 0.5rem;
  188. .u-name{
  189. font-size: 32rpx;
  190. }
  191. .u-mobile{
  192. color: #999;
  193. }
  194. }
  195. }
  196. .price-item{
  197. border-top: 1rpx solid #eee;
  198. padding-left: 5%;
  199. }
  200. .price-show-list{
  201. margin-left: 5%;
  202. border-top: 1rpx solid #eee;
  203. >view{
  204. padding:0 20rpx;
  205. }
  206. }
  207. }
  208. .footer{
  209. padding: 0.6rem;
  210. background: #ffffff;
  211. }
  212. }
  213. </style>