perAdd.vue 3.7 KB

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