teamAdd.vue 9.1 KB

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