perAdd.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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="formMess.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="formMess.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="formMess.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. formMess: {
  56. "phone": 0,
  57. "company_code": 0,
  58. "radioOne": "1",
  59. "power": "",
  60. },
  61. }
  62. },
  63. onLoad: function(option) {
  64. this.getSiteList();
  65. this.getPhoneList()
  66. },
  67. methods: {
  68. async submit() {
  69. //提交验证
  70. if (!this.formMess.phone) {
  71. uni.showToast({
  72. title: "请选择联系方式",
  73. icon: "none"
  74. });
  75. return
  76. }
  77. if (!this.formMess.name.replace(/^\s*/g,'')) {
  78. uni.showToast({
  79. title: "请输入姓名",
  80. icon: "none"
  81. });
  82. return
  83. }
  84. if (!this.formMess.company_code) {
  85. uni.showToast({
  86. title: "请选择所在单位",
  87. icon: "none"
  88. });
  89. return
  90. }
  91. let res = await this.addAuthority({
  92. "phone": this.formMess.phone,
  93. "name": this.formMess.name,
  94. "power": this.formMess.radioOne,
  95. "company_code": this.formMess.company_code
  96. })
  97. if (!res.data.flag) {
  98. uni.showToast({
  99. title: "添加失败",
  100. icon: "none"
  101. });
  102. } else {
  103. uni.showToast({
  104. title: "添加成功",
  105. });
  106. setTimeout(() => {
  107. uni.navigateTo({
  108. url: '/pages/accountManage/success/success',
  109. });
  110. }, 1000);
  111. }
  112. },
  113. //手机号码下拉请求数据
  114. async getPhoneList() {
  115. const res = await this.$myRequest({
  116. url: 'PermissionBinding/getphoneList',
  117. })
  118. this.phoneListData = res.data.data;
  119. },
  120. //单位下拉请求数据
  121. async getSiteList() {
  122. const res = await this.$myRequest({
  123. url: 'Index/getCompanyList',
  124. })
  125. this.companyListData = res.data.data;
  126. },
  127. radioChange(e) {
  128. console.log('type:' + e.detail.value);
  129. this.radioOne = e.detail.value;
  130. },
  131. addAuthority(params = {}) {
  132. return this.$myRequest({
  133. url: 'PermissionBinding/setPermissionBinding',
  134. data: params
  135. })
  136. },
  137. formReset: function(e) {
  138. console.log('清空数据')
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss">
  144. </style>