teamAdd.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <view>
  3. <u-navbar title="成员信息" title-color="#101010">
  4. </u-navbar>
  5. <view class="list">
  6. <view class="item">
  7. <view class="name">
  8. 头像
  9. </view>
  10. <view class="value">
  11. <view class="goto " @click="uploadPhoto">
  12. <view class="photo">
  13. <img class="img" :src="addInfo.image" v-if="addInfo.image" alt="">
  14. </view>
  15. <u-icon name="arrow-right" style="margin-left: 8rpx;" size="24" color="#BBBBBB"></u-icon>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="item">
  20. <view class="name">
  21. <span>*</span>成员姓名
  22. </view>
  23. <view class="value">
  24. <u-input v-model="addInfo.name" placeholder="请输入成员姓名"></u-input>
  25. </view>
  26. </view>
  27. <view class="item">
  28. <view class="name">
  29. <span>*</span>登录手机号
  30. </view>
  31. <view class="value">
  32. <u-input v-model="addInfo.phone" placeholder="请输入登录手机号"></u-input>
  33. </view>
  34. </view>
  35. <view class="item">
  36. <view class="name">
  37. 登录密码
  38. </view>
  39. <view class="value">
  40. <u-input placeholder="不填写默认123456" v-model="addInfo.password"></u-input>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="list">
  45. <u-radio-group v-model="roleId">
  46. <view class="radiolist">
  47. <view class="radioitem" v-for="(item, index) in codeList">
  48. <u-radio :key="index" :name="item.value">
  49. {{item.name}}
  50. </u-radio>
  51. </view>
  52. </view>
  53. </u-radio-group>
  54. </view>
  55. <view class="floating-button">
  56. <view class="button" @click="submit">
  57. 提交
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import * as API from '@/apis/pagejs/pagesTeam.js'
  64. export default {
  65. data() {
  66. return {
  67. id:"",
  68. codeList: [],
  69. roleId: "",
  70. addInfo: {
  71. image: "",
  72. roleName: "XJ"
  73. }
  74. };
  75. },
  76. onLoad(op) {
  77. if(op.id){
  78. this.id=op.id
  79. this.getInfo()
  80. }
  81. this.findByCatalogName({
  82. catalogName: '巡检角色'
  83. }, "codeList")
  84. },
  85. methods: {
  86. del() {
  87. uni.showModal({
  88. title:"提示",
  89. content: "请确认是否删除用户",
  90. success: (res1) => {
  91. if (res1.confirm) {
  92. this.delApi()
  93. } else if (res1.cancel) {
  94. //('用户点击取消');
  95. }
  96. }
  97. })
  98. },
  99. delApi() {
  100. API.delUser({
  101. id:this.id
  102. }).then((res) => {
  103. uni.showModal({
  104. title: '提示',
  105. showCancel: false,
  106. content: "操作成功",
  107. success: res1 => {
  108. if (res1.confirm) {
  109. uni.navigateBack()
  110. } else if (res1.cancel) {
  111. //('用户点击取消');
  112. }
  113. }
  114. })
  115. }).catch(error => {
  116. uni.hideLoading();
  117. uni.showToast({
  118. title: error,
  119. icon: "none"
  120. })
  121. })
  122. },
  123. getInfo() {
  124. API.teamUser({
  125. id:this.id
  126. }).then((res) => {
  127. var info=res.data.user
  128. this.addInfo.id=info.id
  129. this.addInfo.image=info.image
  130. this.addInfo.name=info.name
  131. this.addInfo.phone=info.phone
  132. this.addInfo.roleId=info.role
  133. this.roleId=info.role
  134. //this.addInfo.id=info.id
  135. }).catch(error => {
  136. uni.hideLoading();
  137. uni.showToast({
  138. title: error,
  139. icon: "none"
  140. })
  141. })
  142. },
  143. findByCatalogName(obj, listName) {
  144. API.findByCatalogName(obj).then((res) => {
  145. var arr = res.data.dataDictionaryList
  146. this[listName] = arr
  147. }).catch(error => {
  148. uni.hideLoading();
  149. uni.showToast({
  150. title: error,
  151. icon: "none"
  152. })
  153. })
  154. },
  155. uploadPhoto() {
  156. let _self = this;
  157. const crop = {
  158. quality: 100,
  159. width: 600,
  160. height: 600,
  161. resize: true
  162. };
  163. // 上传图片
  164. uni.chooseImage({
  165. count: 1,
  166. crop,
  167. success: async (res) => {
  168. //(res);
  169. let tempFile = res.tempFiles[0];
  170. var filePath = res.tempFilePaths[0]
  171. let fileData = await new Promise((callback) => {
  172. uni.navigateTo({
  173. url: '/pages/myTab/cropImage?path=' + filePath +
  174. `&options=${JSON.stringify(crop)}`,
  175. animationType: "fade-in",
  176. events: {
  177. success: url => {
  178. callback(url)
  179. }
  180. }
  181. });
  182. })
  183. this.saveRecordConfirmMethod(fileData);
  184. }
  185. });
  186. },
  187. saveRecordConfirmMethod(fileData) {
  188. var token = this.jphelp.getToken()
  189. uni.uploadFile({
  190. url: process.jphelp.BASE_URL + "uploadPicture", //仅为示例,非真实的接口地址
  191. filePath: fileData,
  192. header: {
  193. 'Authorization': token,
  194. //'Content-Type': 'multipart/form-data',
  195. 'X-Requested-With': 'XMLHttpRequest',
  196. // 'content-type': 'multipart/form-data'
  197. },
  198. name: 'photoFile',
  199. formData: {
  200. subFolder: "headimg"
  201. },
  202. success: (uploadFileRes) => {
  203. var obj = JSON.parse(uploadFileRes.data)
  204. //.log(obj);
  205. //this.src = obj.data;
  206. this.addInfo.image = obj.data;
  207. this.$forceUpdate()
  208. //this.updatePersonInformation();
  209. // uni.hideLoading();
  210. }
  211. });
  212. },
  213. submit() {
  214. if (!this.addInfo.name) {
  215. uni.showToast({
  216. title: "请输入成员姓名"
  217. })
  218. return
  219. }
  220. if (!this.addInfo.phone) {
  221. uni.showToast({
  222. title: "请输入登录手机号"
  223. })
  224. return
  225. }
  226. if (!this.roleId) {
  227. uni.showToast({
  228. title: "请选择成员角色"
  229. })
  230. return
  231. }
  232. this.addInfo.roleId=this.roleId
  233. uni.showLoading({
  234. title: "加载中",
  235. mask: true,
  236. })
  237. API.adduser(this.addInfo).then((res) => {
  238. uni.showModal({
  239. title: '提示',
  240. showCancel: false,
  241. content: "操作成功",
  242. success: res1 => {
  243. if (res1.confirm) {
  244. uni.navigateBack()
  245. } else if (res1.cancel) {
  246. //('用户点击取消');
  247. }
  248. }
  249. })
  250. uni.hideLoading();
  251. }).catch(error => {
  252. uni.hideLoading();
  253. uni.showToast({
  254. title: error,
  255. icon: "none"
  256. })
  257. })
  258. },
  259. }
  260. }
  261. </script>
  262. <style lang="scss">
  263. .jpmain {
  264. padding-bottom: 120rpx;
  265. }
  266. .list {
  267. background-color: rgba(255, 255, 255, 1);
  268. margin: 20rpx 0;
  269. .item:not(:last-child) {
  270. border-bottom: 2rpx solid rgba(232, 232, 232, 1);
  271. }
  272. .item {
  273. padding: 24rpx;
  274. display: flex;
  275. align-items: center;
  276. justify-content: space-between;
  277. .name {
  278. width: 40%;
  279. font-size: 32rpx;
  280. color: #777777;
  281. span {
  282. color: red
  283. }
  284. white-space: pre;
  285. }
  286. .value {
  287. font-size: 32rpx;
  288. width: 60%;
  289. display: flex;
  290. justify-content: space-between;
  291. input::placeholder {
  292. color: #AAAAAA;
  293. }
  294. .img {
  295. width: 40rpx;
  296. height: 40rpx;
  297. }
  298. .textarea {
  299. background-color: rgba(241, 242, 245, 1);
  300. width: 100%;
  301. border-radius: 8rpx;
  302. }
  303. }
  304. }
  305. .item-plus {
  306. flex-direction: column;
  307. .value,
  308. .name {
  309. width: 100%;
  310. }
  311. .name {
  312. padding-bottom: 32rpx;
  313. }
  314. }
  315. }
  316. .floating-button {
  317. z-index: 999;
  318. position: fixed;
  319. bottom: 0;
  320. width: 100%;
  321. display: flex;
  322. height: 120rpx;
  323. justify-content: center;
  324. background-color: rgba(255, 255, 255, 1);
  325. .button {
  326. margin-top: 24rpx;
  327. border-radius: 50px;
  328. height: 80rpx;
  329. width: 80%;
  330. display: flex;
  331. align-items: center;
  332. justify-content: center;
  333. padding: 12rpx;
  334. background-color: rgba(22, 119, 255, 1);
  335. color: rgba(255, 255, 255, 1);
  336. font-size: 36rpx;
  337. }
  338. }
  339. .goto {
  340. display: flex;
  341. align-items: center;
  342. color: rgba(119, 119, 119, 1);
  343. width: 100%;
  344. justify-content: space-between;
  345. .photo {
  346. border-radius: 50px;
  347. background-color: rgba(229, 229, 229, 1);
  348. height: 80rpx;
  349. width: 80rpx;
  350. overflow: hidden;
  351. .img {
  352. width: 100% !important;
  353. height: 100% !important;
  354. }
  355. }
  356. }
  357. .radiolist{
  358. .radioitem{
  359. padding: 24rpx;
  360. display: flex;
  361. width: 300%;
  362. align-items: center;
  363. justify-content: space-between;
  364. }
  365. .radioitem:not(:last-child) {
  366. border-bottom: 2rpx solid rgba(232, 232, 232, 1);
  367. }
  368. }
  369. .rightslot{
  370. margin-right: 16rpx;
  371. color: red;
  372. }
  373. </style>