userInfo.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view class="">
  3. <form @submit="sub">
  4. <view class="body">
  5. <input class="input" style="display:none;" name="id" :value=id />
  6. 归属人:<input class="input" name="name" placeholder="员工姓名,如:李小明" :value=name />
  7. </view>
  8. <view class="body">
  9. 登录名:<input class="input" name="userName" placeholder="如:lxm" :value=username />
  10. </view>
  11. <view v-if="flag=='add'" class="body">
  12. 登录密码:<input class="input" password name="password" />
  13. </view>
  14. <view v-if="flag=='add'" class="body">
  15. 确认密码:<input class="input" password name="password1" />
  16. </view>
  17. <view class="uni-form-item uni-column">
  18. <view class="title">权限选择</view>
  19. <radio-group name="level">
  20. <label class="radio">
  21. <radio class="radio" value="1" :checked="1==level" /><text>录入</text>
  22. </label>
  23. </br>
  24. <label class="radio">
  25. <radio class="radio" value="2" :checked="2==level" /><text>录入,查询,修改</text>
  26. </label>
  27. </br>
  28. <label class="radio">
  29. <radio class="radio" value="3" :checked="3==level" /><text>添加用户,修改权限及包含1和2</text>
  30. </label>
  31. </radio-group>
  32. </view>
  33. <view class="">
  34. <button type="primary" formType="submit" class="button">
  35. <p v-if="flag=='add'" class="p">添加</p>
  36. <p v-if="flag=='update'" class="p">提交</p>
  37. <p v-if="flag=='delete'" class="p">删除</p>
  38. </button>
  39. </view>
  40. <!-- <view v-if="flag=='update'" class="">
  41. <button type="primary" formType="submit" class="button">
  42. <p class="p">提交</p>
  43. </button>
  44. </view>
  45. <view v-if="flag=='delete'" class="">
  46. <button type="primary" formType="submit" class="button">
  47. <p class="p">删除</p>
  48. </button>
  49. </view> -->
  50. </form>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. mapState,
  56. mapActions,
  57. mapMutations
  58. } from 'vuex'
  59. export default {
  60. data() {
  61. return {
  62. id: '',
  63. name: '',
  64. username: "",
  65. flag: "",
  66. flagUser: "",
  67. level: '',
  68. parm: {
  69. name: null,
  70. id: null
  71. },
  72. };
  73. },
  74. onPullDownRefresh() {},
  75. onShow() {
  76. var token = uni.getStorageSync("token");
  77. if (token.length > 1) {
  78. var name = uni.getStorageSync("name");
  79. this.flag = uni.getStorageSync("flag");
  80. if (this.flag != "add") {
  81. var flagUser = uni.getStorageSync("flagUser");
  82. this.flagUser = flagUser;
  83. this.name = flagUser.name;
  84. this.username = flagUser.userName;
  85. this.level = flagUser.level;
  86. this.id = flagUser.id;
  87. }
  88. } else {
  89. uni.reLaunch({
  90. url: '../Login/Login',
  91. });
  92. }
  93. },
  94. onLoad() {
  95. },
  96. methods: {
  97. // ...mapActions('chart', ['updata']),
  98. sub(event) {
  99. var serverUrl = this.serverurl;
  100. const {
  101. value: user
  102. } = event.detail;
  103. var password = user.password;
  104. var password1 = user.password1;
  105. if (password != password1) {
  106. uni.showModal({
  107. title: '提示',
  108. content: '两次输入密码不一致',
  109. });
  110. return null;
  111. }
  112. //url=add,delete....
  113. var url = uni.getStorageSync("flag");
  114. if (url == 'add') {
  115. this.$store.dispatch(url, user).then(_ => {
  116. uni.showModal({
  117. title: '提示',
  118. content: _.message,
  119. });
  120. });
  121. } else {
  122. var token = uni.getStorageSync("token");
  123. uni.request({
  124. url: serverUrl + "/TUser/"+url,
  125. method: "POST",
  126. data:{
  127. "id":user.id,
  128. "name":user.name,
  129. "level":user.level
  130. },
  131. header: {
  132. 'token': token
  133. },
  134. success: (Result) => {
  135. var res = Result;
  136. uni.showModal({
  137. title: '提示',
  138. content: res.data.message,
  139. });
  140. }
  141. });
  142. }
  143. },
  144. }
  145. }
  146. </script>
  147. <style>
  148. .body {
  149. background-color: #FFFFFF;
  150. padding: 20upx 20upx 20upx 20upx;
  151. display: flex;
  152. flex-direction: row;
  153. justify-content: flex-start;
  154. }
  155. .input {
  156. /* padding: 10upx 20upx 10upx 0upx; */
  157. padding-left: 20upx;
  158. padding-top: 10upx;
  159. background-color: #FFFFFF;
  160. width: 500upx;
  161. height: 50upx;
  162. box-shadow: 0upx 0upx 20upx #D3D3D3;
  163. border-radius: 5upx;
  164. }
  165. .button {
  166. margin: auto;
  167. width: 60%;
  168. height: 100upx;
  169. }
  170. .p {
  171. /* #ifdef H5 */
  172. top: -13%;
  173. /* #endif */
  174. width: 80upx;
  175. height: 60upx;
  176. font-size: 40upx;
  177. padding-top: 6upx;
  178. /* #ifndef H5 */
  179. padding-top: 10upx;
  180. /* #endif */
  181. position: absolute;
  182. /* 水平居中 */
  183. left: 50%;
  184. -webkit-transform: translateX(-50%);
  185. transform: translateX(-50%);
  186. }
  187. .radio {
  188. padding-top: 20upx;
  189. padding-left: 30upx;
  190. }
  191. </style>