perAdd.vue 3.5 KB

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