perAdd.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="perAppWrapper">
  3. <form action="">
  4. <view style="height:30rpx"></view>
  5. <view class="form-item selectBox">
  6. <view class="title">
  7. <text class="necessary">*</text>
  8. 联系方式:
  9. </view>
  10. <!-- <select name="" id="" v-model="phone" clearable>
  11. <option value="0">请选择</option>
  12. <option :value="item.phone" v-for="(item,index) in phoneListData" :key="index">{{item.phone}}
  13. </option>
  14. </select>
  15. <text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text> -->
  16. <view class="example-body">
  17. <uni-combox :candidates="candidates" placeholder="请选择" v-model="phone"></uni-combox>
  18. </view>
  19. </view>
  20. <view class="form-item">
  21. <view class="title"><text class="necessary">*</text>姓名:</view>
  22. <input name="input" v-model="name"></input>
  23. </view>
  24. <view class="form-item selectBox">
  25. <view class="title">
  26. <text class="necessary">*</text>
  27. 所在单位:
  28. </view>
  29. <select name="" id="" v-model="company_code" clearable>
  30. <option value="">请选择</option>
  31. <option :value="item.owner_code" v-for="(item,index) in companyListData" :key="index"
  32. style="width:80%">{{item.owner_name}}</option>
  33. </select>
  34. <text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text>
  35. </view>
  36. <view class="form-item">
  37. <view class="title"><text class="necessary">*</text>角色权限:</view>
  38. <radio-group name="gender" @change="radioChange">
  39. <label class="margin-right">
  40. <radio value="1" checked /><text>管理员</text>
  41. </label>
  42. <label>
  43. <radio value="2" /><text>普通员工</text>
  44. </label>
  45. </radio-group>
  46. </view>
  47. <view class="btn-area submitBottomBtn padding-lr-sm">
  48. <button class="bg-blue round margin-top" @click="$noMultipleClicks(submit)">提 交 </button>
  49. </view>
  50. </form>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. noClick:true,
  58. companyListData: [],
  59. phoneListData: [],
  60. "phone": '',
  61. "company_code": "",
  62. "radioOne": "1",
  63. "power": "",
  64. "name":"",
  65. "candidates": [],
  66. city:''
  67. }
  68. },
  69. onLoad: function(option) {
  70. this.getSiteList();
  71. this.getPhoneList()
  72. },
  73. methods: {
  74. async submit() {
  75. //提交验证
  76. if (!this.phone) {
  77. uni.showToast({
  78. title: "请选择联系方式",
  79. icon: "none"
  80. });
  81. return
  82. }
  83. if (!this.name.replace(/^\s*/g,'')) {
  84. uni.showToast({
  85. title: "请输入姓名",
  86. icon: "none"
  87. });
  88. return
  89. }
  90. if (!this.company_code) {
  91. uni.showToast({
  92. title: "请选择所在单位",
  93. icon: "none"
  94. });
  95. return
  96. }
  97. let res = await this.addAuthority({
  98. "phone": this.phone,
  99. "name": this.name,
  100. "power": this.radioOne,
  101. "company_code": this.company_code
  102. })
  103. if (!res.data.flag) {
  104. uni.showToast({
  105. title: "添加失败",
  106. icon: "none"
  107. });
  108. } else {
  109. // uni.showToast({
  110. // title: "添加成功",
  111. // });
  112. setTimeout(() => {
  113. uni.navigateTo({
  114. url: '/pages/accountManage/success/success',
  115. });
  116. }, 1000);
  117. }
  118. },
  119. //手机号码下拉请求数据
  120. async getPhoneList() {
  121. const res = await this.$myRequest({
  122. url: 'PermissionBinding/getphoneList',
  123. })
  124. this.phoneListData = res.data.data;
  125. this.phoneListData.forEach(e => {
  126. this.candidates.push(e.phone)
  127. })
  128. console.log(this.candidates)
  129. },
  130. //单位下拉请求数据
  131. async getSiteList() {
  132. const res = await this.$myRequest({
  133. url: 'Index/getCompanyList',
  134. })
  135. this.companyListData = res.data.data;
  136. },
  137. radioChange(e) {
  138. console.log('type:' + e.detail.value);
  139. this.radioOne = e.detail.value;
  140. },
  141. addAuthority(params = {}) {
  142. return this.$myRequest({
  143. url: 'PermissionBinding/setPermissionBinding',
  144. data: params
  145. })
  146. },
  147. formReset: function(e) {
  148. console.log('清空数据')
  149. }
  150. }
  151. }
  152. </script>
  153. <style lang="scss">
  154. .example-body{
  155. margin:0!important;
  156. width: calc(100% - 104px);
  157. z-index:10000
  158. }
  159. .uni-combox{
  160. padding:0 10px 0 0!important
  161. }
  162. </style>