addEmployee.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view class="container">
  3. <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
  4. :placeholder="true" title="人员管理"></u-navbar>
  5. <view class="content">
  6. <view class="list">
  7. <u-cell-group :border="false">
  8. <u-cell title="登录名">
  9. <input slot="value" placeholder="请输入登录名" type="text" v-model="params.account"
  10. class="u-slot-value"></input>
  11. </u-cell>
  12. <u-cell title="姓名">
  13. <input slot="value" placeholder="请输入姓名" type="text" v-model="params.name"
  14. class="u-slot-value"></input>
  15. </u-cell>
  16. <u-cell title="手机号">
  17. <input slot="value" placeholder="请输入手机号" type="number" v-model="params.tel"
  18. class="u-slot-value"></input>
  19. </u-cell>
  20. <u-cell title="邮箱">
  21. <input slot="value" placeholder="请输入邮箱" type="" v-model="params.mail"
  22. class="u-slot-value"></input>
  23. </u-cell>
  24. <u-cell title="密码">
  25. <input slot="value" placeholder="请输入密码" type="password" v-model="params.password"
  26. class="u-slot-value"></input>
  27. </u-cell>
  28. <u-cell title="角色" :isLink="true" @click="popShow=true">
  29. <text slot="value">{{roleName}}</text>
  30. </u-cell>
  31. <u-cell title="备注" :border="false">
  32. <input slot="value" placeholder="请输入备注" type="" v-model="params.remark"
  33. class="u-slot-value"></input>
  34. </u-cell>
  35. </u-cell-group>
  36. </view>
  37. <view style="color: red;line-height: 60rpx;text-align: right;padding-right: 20rpx;">
  38. {{err}}
  39. </view>
  40. <view class="btn safe-bottom">
  41. <xbutton round="82rpx" size="large" @click="submit">创建</xbutton>
  42. </view>
  43. </view>
  44. <xpopup :show="popShow" @close="popClose" @confirm="popSubmit" :showBtn="true" title="选择角色">
  45. <view class="pop-content flex">
  46. <!-- 多选 -->
  47. <view class="u-page__tag-item" v-for="(item, index) in roleList" :key="item.name">
  48. <u-tag :text="item.name" :plain="!item.checked" type="warning" :name="index" @click="checkboxClick">
  49. </u-tag>
  50. </view>
  51. </view>
  52. </xpopup>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. save,
  58. roleList
  59. } from "@/api/system/employee.js"
  60. export default {
  61. data() {
  62. return {
  63. params: {
  64. "name": "",
  65. "tel": "",
  66. "mail": "",
  67. "password": "",
  68. "roleIds": "",
  69. "account": "",
  70. "remark":""
  71. },
  72. roleName: '',
  73. popShow: false,
  74. roleList: [],
  75. err: ''
  76. }
  77. },
  78. onLoad(o) {
  79. this.getRoleList()
  80. },
  81. methods: {
  82. getRoleList() {
  83. roleList({
  84. page: {
  85. current: 1,
  86. size: 10000
  87. },
  88. sysId: uni.getStorageSync('sysId')
  89. }).then(res => {
  90. let data = res.data.records;
  91. if (data.length > 0) {
  92. let newData = data.map(i => {
  93. return {
  94. id: i.id,
  95. name: i.name,
  96. checked: false
  97. }
  98. })
  99. this.roleList = newData;
  100. } else {
  101. this.roleList = [];
  102. }
  103. })
  104. },
  105. //弹框提交
  106. submit() {
  107. save(this.params).then(res => {
  108. this.$modal.msg('保存成功')
  109. this.$tab.navigateBack()
  110. this.err = ''
  111. }).catch(err => {
  112. if (err.length > 15) {
  113. this.err = '请重试!'
  114. } else {
  115. this.err = err.substr(0, 12)
  116. }
  117. })
  118. },
  119. //滚动到底加载更多
  120. onReachBottom() {
  121. if (this.noMore) return
  122. this.page++
  123. this.getPointList()
  124. },
  125. //禁用
  126. stop() {
  127. this.popShow = true
  128. },
  129. //弹框关闭
  130. popClose() {
  131. this.popShow = false
  132. },
  133. //弹框提交
  134. popSubmit() {
  135. this.popClose()
  136. let nameVal = []
  137. let idVal = []
  138. this.roleList.forEach(i => {
  139. if (i.checked) {
  140. nameVal.push(i.name)
  141. idVal.push(i.id)
  142. }
  143. })
  144. this.roleName = nameVal.join(',')
  145. this.params.roleIds = idVal
  146. },
  147. checkboxClick(name) {
  148. this.roleList[name].checked = !this.roleList[name].checked
  149. }
  150. }
  151. }
  152. </script>
  153. <style lang="scss" scoped>
  154. .container {
  155. overflow: hidden;
  156. .content {
  157. padding: 0rpx 13rpx 12rpx;
  158. overflow: hidden;
  159. .list {
  160. width: 100%;
  161. margin-top: 24rpx;
  162. background-color: #fff;
  163. padding: 0rpx 30rpx;
  164. border-radius: 12rpx;
  165. input {
  166. text-align: right;
  167. }
  168. /deep/ .u-cell__body {
  169. padding: 30rpx 6rpx;
  170. }
  171. }
  172. }
  173. }
  174. .empty {
  175. margin-top: 40%;
  176. }
  177. .btn {
  178. width: 100%;
  179. position: fixed;
  180. left: 0;
  181. padding: 0 24rpx;
  182. }
  183. .popup-content {
  184. padding: 36rpx 24rpx;
  185. display: flex;
  186. flex-flow: row nowrap;
  187. justify-content: flex-start;
  188. align-items: center;
  189. input {
  190. border: 1rpx solid #999;
  191. border-radius: 6rpx;
  192. width: 530rpx;
  193. padding: 0 24rpx;
  194. }
  195. &.edit-point {
  196. flex-direction: column;
  197. align-items: flex-start;
  198. .edit-point-item {
  199. width: 100%;
  200. padding-left: 170rpx;
  201. position: relative;
  202. &+.edit-point-item {
  203. margin-top: 12rpx;
  204. }
  205. >view:nth-child(1) {
  206. position: absolute;
  207. left: 0;
  208. top: 50%;
  209. transform: translateY(-50%);
  210. }
  211. }
  212. }
  213. }
  214. .del-popup-content {
  215. padding: 36rpx 24rpx;
  216. text-align: center;
  217. font-size: 32rpx;
  218. }
  219. .pop-content {
  220. padding: 24rpx;
  221. .u-page__tag-item {
  222. margin-right: 24rpx;
  223. }
  224. }
  225. </style>