AccountGroupForm.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <seller-base :show="false">
  3. <view class="div container">
  4. <view class="div common-header-wrap">
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar :title="getTitle" class="common-header" left-icon="back" @clickLeft="goBack">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view class="div main-content">
  14. <flex-line class="field-line" :show-border="true"><text class="span field-name">组名称</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="seller_group_name" /></view></flex-line>
  15. <view class="div" @click="showPopup('menuVisible')">
  16. <flex-line :is-link="true" :show-border="true"><text class="span line-name">操作权限</text></flex-line>
  17. </view>
  18. <view class="div" @click="showPopup('smtVisible')">
  19. <flex-line :is-link="true" :show-border="true"><text class="span line-name">消息接收权限</text></flex-line>
  20. </view>
  21. <view class="div pt-10 pb-10"><view class="div common-btn ds-button-large" @click="submit">保存</view></view>
  22. </view>
  23. <uni-popup background-color="#fff" ref="menuVisible" type="right" >
  24. <view :style="'width:'+screenWidth+'px'" class="common-popup-wrapper">
  25. <view class="div common-header-wrap">
  26. <view :style="'height:'+navHeight+'px'"></view>
  27. <view class="common-header-holder"></view>
  28. <view class="common-header-fixed">
  29. <title-header />
  30. <uni-nav-bar title="操作权限" class="common-header" left-icon="back" @clickLeft="hidePopup('menuVisible')">
  31. </uni-nav-bar>
  32. </view>
  33. </view>
  34. <view class="scroll-view div common-popup-content">
  35. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" scroll-y="true">
  36. <checkbox-group @change="checkboxChange2">
  37. <view class="div" v-for="(item,index) in menu_options" :key="index">
  38. <view>{{item.text}}</view>
  39. <view>
  40. <label v-for="(item,i) in item.options" :key="i">
  41. <checkbox :value="item.value" :checked="menu.indexOf(item.value)>-1">
  42. </checkbox>
  43. {{item.label}}
  44. </label>
  45. </view>
  46. </view>
  47. </checkbox-group>
  48. </scroll-view>
  49. </view>
  50. </view>
  51. </uni-popup>
  52. <uni-popup background-color="#fff" ref="smtVisible" type="right" >
  53. <view :style="'width:'+screenWidth+'px'" class="common-popup-wrapper">
  54. <view class="div common-header-wrap">
  55. <view :style="'height:'+navHeight+'px'"></view>
  56. <view class="common-header-holder"></view>
  57. <view class="common-header-fixed">
  58. <title-header />
  59. <uni-nav-bar title="消息接收权限" class="common-header" left-icon="back" @clickLeft="hidePopup('smtVisible')">
  60. </uni-nav-bar>
  61. </view>
  62. </view>
  63. <view class="scroll-view div common-popup-content">
  64. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" scroll-y="true">
  65. <checkbox-group @change="checkboxChange1">
  66. <label v-for="(item,index) in smt_options" :key="index">
  67. <checkbox :value="item.value" :checked="smt.indexOf(item.value)>-1"></checkbox>
  68. {{item.label}}
  69. </label>
  70. </checkbox-group>
  71. </scroll-view>
  72. </view>
  73. </view>
  74. </uni-popup>
  75. </view>
  76. </seller-base>
  77. </template>
  78. <script>
  79. import {getFontSize} from '@/util/common'
  80. import TitleHeader from '../../TitleHeader'
  81. import SellerBase from '../SellerBase'
  82. import { getCommonData, getAccountGroupInfo, editAccountGroup } from '../../../api/sellerAccountGroup'
  83. import flexLine from '../../flexLine'
  84. export default {
  85. components:{
  86. TitleHeader,
  87. SellerBase,
  88. flexLine,
  89. },
  90. computed:{
  91. fontSize(){
  92. return getFontSize()
  93. },
  94. isAddMode () {
  95. let mode = this.action
  96. // add: 添加地址,edit: 编辑地址
  97. if (mode === 'add') {
  98. return true
  99. } else {
  100. return false
  101. }
  102. },
  103. getTitle () {
  104. if (this.isAddMode) {
  105. return '新增帐号组'
  106. } else {
  107. return '修改帐号组'
  108. }
  109. }
  110. },
  111. data(){
  112. return {
  113. navHeight: 0,
  114. screenWidth:0,
  115. screenHeight:0,
  116. seller_group_name: '',
  117. menuVisible: false,
  118. smtVisible: false,
  119. group_id: 0,
  120. smt_options: [],
  121. menu_options: [],
  122. smt: [],
  123. menu: [],
  124. action:''
  125. }
  126. },
  127. onLoad: function (option) {
  128. getCommonData().then(res => {
  129. let temp = res.result.smt_list
  130. for (var i in temp) {
  131. let item = temp[i]
  132. this.smt_options.push({
  133. label: item.storemt_name,
  134. value: item.storemt_code
  135. })
  136. }
  137. let menu_list = res.result.seller_menu
  138. for (var i in menu_list) {
  139. let item = menu_list[i]
  140. // this.menu[i] = []
  141. let temp = []
  142. for (var j in item.submenu) {
  143. let menu = item.submenu[j]
  144. temp.push({
  145. label: menu.text,
  146. value: menu.controller
  147. })
  148. }
  149. this.menu_options.push({
  150. key: i,
  151. text: item.text,
  152. options: temp
  153. })
  154. }
  155. }).catch(function (error) {
  156. uni.showToast({icon:'none',title: error.message})
  157. })
  158. this.action = option.action
  159. if (this.action!='add') {
  160. this.group_id = option.group_id
  161. getAccountGroupInfo(this.group_id).then(res => {
  162. this.seller_group_name = res.result.group_name
  163. this.menu = res.result.group_limits
  164. this.smt = res.result.smt_limits
  165. }).catch(function (error) {
  166. uni.showToast({icon:'none',title: error.message})
  167. })
  168. }
  169. },
  170. mounted(){
  171. // #ifdef MP-WEIXIN
  172. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  173. // #endif
  174. this.screenWidth=uni.getSystemInfoSync().screenWidth
  175. this.screenHeight=uni.getSystemInfoSync().screenHeight
  176. },
  177. methods:{
  178. checkboxChange1(event){
  179. this.smt=event.detail.value
  180. },
  181. checkboxChange2(event){
  182. this.menu=event.detail.value
  183. },
  184. showPopup(id){
  185. this.$refs[id].open()
  186. },
  187. hidePopup(id){
  188. this.$refs[id].close()
  189. },
  190. goBack () {
  191. uni.navigateBack({delta:1})
  192. },
  193. submit () {
  194. if (!this.seller_group_name) {
  195. uni.showToast({icon:'none',title: '请填写组名称'})
  196. return
  197. }
  198. uni.showLoading({ title: '加载中' })
  199. editAccountGroup(this.group_id, this.seller_group_name, this.menu, this.smt).then(
  200. (response) => {
  201. uni.navigateBack({delta:1})
  202. }, (error) => {
  203. uni.hideLoading()
  204. uni.showToast({icon:'none',title: error.message})
  205. })
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. .main-content{background: #fff;padding:0 $pageSpace}
  212. .right-arrow{transform: rotate(-90deg);color:#ddd;font-size:$fontSize;display: inline-block;}
  213. .input-wrap{position: relative;
  214. .i{position: absolute;right:0;top:0;line-height: 2.4rem;display: block;width:2rem;text-align: center;font-size:$h1}
  215. }
  216. .scroll-view-wrapper{display: flex;flex-direction: column;}
  217. .scroll-view{flex:1}
  218. </style>