name_edit.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <view class="real-name">
  3. <u-form :model="form" ref="uForm" label-width='130'>
  4. <view class="posotion">
  5. <view class="star">
  6. *
  7. </view>
  8. <u-form-item label="学号">
  9. <u-input v-model="form.account" />
  10. </u-form-item>
  11. </view>
  12. <view class="posotion">
  13. <view class="star">
  14. *
  15. </view>
  16. <u-form-item label="姓名">
  17. <u-input v-model="form.name" />
  18. </u-form-item>
  19. </view>
  20. <view class="posotion">
  21. <view class="star">
  22. *
  23. </view>
  24. <u-form-item label="班级">
  25. <u-input v-model="form.class" />
  26. </u-form-item>
  27. </view>
  28. <!-- <view class="posotion">
  29. <view class="star">
  30. *
  31. </view>
  32. <u-form-item label="角色">
  33. <u-radio-group v-model="form.role">
  34. <u-radio v-for="(item, index) in role_list" :key="item.id" :name="item.id">
  35. {{item.name}}
  36. </u-radio>
  37. </u-radio-group>
  38. </u-form-item>
  39. </view>
  40. <view class="posotion">
  41. <view class="star">
  42. *
  43. </view>
  44. <u-form-item label="状态">
  45. <u-radio-group v-model="form.status">
  46. <u-radio :name="1">
  47. 正常
  48. </u-radio>
  49. <u-radio :name="0">
  50. 禁用
  51. </u-radio>
  52. </u-radio-group>
  53. </u-form-item>
  54. </view> -->
  55. <u-form-item label="性别">
  56. <u-radio-group v-model="form.sex">
  57. <u-radio v-for="(item, index) in list_sex" :key="item.id" :name="item.label">
  58. {{item.name}}
  59. </u-radio>
  60. </u-radio-group>
  61. </u-form-item>
  62. <u-form-item label="上传头像">
  63. <u-upload :action="action" max-count="1" :file-list="fileList" :form-data='imageDate'
  64. @on-success='uploadSuccess'></u-upload>
  65. </u-form-item>
  66. <u-form-item label="联系电话">
  67. <u-input v-model="form.mobile" placeholder="请输入联系电话" />
  68. </u-form-item>
  69. <u-form-item label="电子邮箱">
  70. <u-input v-model="form.email" placeholder="请输入电子邮箱" />
  71. </u-form-item>
  72. <u-form-item label="籍贯">
  73. <u-input v-model="form.native_place" placeholder="请填写籍贯" />
  74. </u-form-item>
  75. </u-form>
  76. <button class="buttom" @click="save()">保存</button>
  77. </view>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. show: false,
  84. form: {
  85. status: 1,
  86. sex: 0,
  87. role: 0,
  88. account: '',
  89. class: '',
  90. organization_id: '',
  91. headimg: ''
  92. },
  93. input_name: '',
  94. action: '', //封面图上传地址
  95. imageDate: {
  96. file_type: 'img',
  97. type: 'headimg'
  98. }, //上传图片携带参数
  99. fileList: [],
  100. uploadImage: '',
  101. role_list: [{
  102. id: 0,
  103. name: '成员'
  104. }, {
  105. id: 2,
  106. name: '负责人'
  107. }],
  108. list_sex: [
  109. {
  110. name: '男',
  111. label: 1
  112. },
  113. {
  114. name: '女',
  115. label: 2
  116. },
  117. ],
  118. rules: {
  119. account: [{
  120. required: true,
  121. message: '请输入学号',
  122. trigger: 'blur'
  123. }],
  124. name: [{
  125. required: true,
  126. message: '请输入姓名',
  127. trigger: 'blur'
  128. }],
  129. class: [{
  130. required: true,
  131. message: '请输入班级',
  132. trigger: 'blur'
  133. }],
  134. role: [{
  135. required: true,
  136. message: '请选择角色',
  137. trigger: 'change'
  138. }],
  139. status: [{
  140. required: true,
  141. message: '请选择状态',
  142. trigger: 'change'
  143. }],
  144. organization_id: [{
  145. required: true,
  146. message: '请选择组织',
  147. trigger: 'change'
  148. }],
  149. },
  150. mode: 'date',
  151. organization_list:[],//组织列表
  152. }
  153. },
  154. onLoad(options) {
  155. },
  156. onShow() {
  157. this.action = '/api/common/upload'
  158. this.form=this.$store.state.vuex_user
  159. },
  160. methods: {
  161. //获取用户信息
  162. //保存
  163. save() {
  164. console.log(!this.form.role)
  165. if (!this.form.account) {
  166. uni.showToast({
  167. title: '请输入账号',
  168. icon: 'none'
  169. })
  170. return
  171. }
  172. if (!this.form.name) {
  173. uni.showToast({
  174. title: '请输入姓名',
  175. icon: 'none'
  176. })
  177. return
  178. }
  179. if (!this.form.class) {
  180. uni.showToast({
  181. title: '请选择班级',
  182. icon: 'none'
  183. })
  184. return
  185. }
  186. if (this.form.role==null) {
  187. uni.showToast({
  188. title: '请选择角色',
  189. icon: 'none'
  190. })
  191. return
  192. }
  193. if (!this.form.organization_id) {
  194. uni.showToast({
  195. title: '请选择组织',
  196. icon: 'none'
  197. })
  198. return
  199. }
  200. this.$u.post('/page/update-people-info',this.form).then(res=>{
  201. console.log(res,'pppp')
  202. uni.showToast({
  203. title:res.message,
  204. icon:'none'
  205. })
  206. this.$u.vuex('vuex_user',this.form);
  207. setTimeout(function(){
  208. uni.navigateBack()
  209. },1000)
  210. })
  211. },
  212. //上传成功
  213. uploadSuccess(data) {
  214. console.log(data, '上传成功')
  215. this.form.headimg = data.data.url
  216. this.uploadImage = data.data.url
  217. },
  218. radioGroupChange(e) {
  219. console.log(e);
  220. this.form.sex = e
  221. },
  222. //保存修改
  223. // mentor() {
  224. // let id = this.$store.state.vuex_user.type_id
  225. // this.$u.put('/mentor/student/' + id, this.form).then(res => {
  226. // if (res.code == 200) {
  227. // console.log(res, 'pppp')
  228. // uni.showToast({
  229. // title: res.message,
  230. // icon: 'none'
  231. // })
  232. // setTimeout(function() {
  233. // uni.switchTab({
  234. // url: './tea_index'
  235. // })
  236. // }, 1500)
  237. // }
  238. // })
  239. // },
  240. //重新上传
  241. reload() {
  242. this.image_edit = 0
  243. console.log('---------')
  244. this.fileList = [],
  245. this.uploadImage = ''
  246. },
  247. //修改出生日期
  248. goDay() {
  249. this.calendar_show = true
  250. },
  251. change_date(e) {
  252. console.log(e, 11111)
  253. this.form.date = e.result
  254. },
  255. goEdit(name, item) {
  256. if (this.uploadImage) {
  257. this.fileList.push({
  258. url: this.uploadImage
  259. })
  260. }
  261. this.show = true
  262. this.item = item
  263. this.input_name = name
  264. this.textarea = ''
  265. this.value = ''
  266. switch (item) {
  267. case 1:
  268. this.value = this.form.truename
  269. break
  270. case 2:
  271. break
  272. case 3:
  273. this.value = this.form.class
  274. break
  275. case 4:
  276. this.value = this.form.email
  277. break
  278. case 5:
  279. this.value = this.form.account
  280. break
  281. case 6:
  282. this.value = this.form.mobile
  283. break
  284. case 9:
  285. this.textarea = this.form.demand
  286. break
  287. case 10:
  288. this.sex = this.form.sex
  289. break
  290. }
  291. },
  292. complate() {
  293. let item = this.item
  294. switch (item) {
  295. case 1:
  296. this.form.truename = this.value
  297. break
  298. case 2:
  299. break
  300. case 3:
  301. this.form.class = this.value
  302. break
  303. case 4:
  304. this.form.email = this.value
  305. break
  306. case 5:
  307. this.form.account = this.value
  308. break
  309. case 6:
  310. this.form.mobile = this.value
  311. break
  312. case 9:
  313. this.form.demand = this.textarea
  314. break
  315. case 10:
  316. this.form.sex = this.value
  317. break
  318. }
  319. this.show = !this.show
  320. },
  321. //保存编辑
  322. // save() {
  323. // this.$u.post('/mentor/student', this.form).then(res => {
  324. // console.log(res, 'oopp')
  325. // })
  326. // }
  327. }
  328. }
  329. </script>
  330. <style lang="scss" scoped>
  331. .upload_image {
  332. width: 90%;
  333. margin: 0 auto;
  334. }
  335. .complate,
  336. .complate1 {
  337. width: 50%;
  338. margin: 0 auto;
  339. margin-top: 20%;
  340. line-height: 44px;
  341. text-align: center;
  342. height: 44px;
  343. background: #3B7653;
  344. opacity: 1;
  345. border-radius: 24px;
  346. font-size: 18px;
  347. font-family: PingFang SC;
  348. font-weight: 500;
  349. color: #FFFFFF;
  350. opacity: 1;
  351. }
  352. .complate1 {
  353. margin-top: 30px;
  354. }
  355. .real-name {
  356. padding: 0 16px;
  357. padding-bottom: 40px;
  358. .name_item {
  359. margin-top: 20px !important;
  360. }
  361. .posotion {
  362. position: relative;
  363. padding-left: 10px;
  364. .star {
  365. position: absolute;
  366. left: 0;
  367. top: 20px;
  368. color: red;
  369. }
  370. }
  371. .item {
  372. display: flex;
  373. align-items: center;
  374. justify-content: space-between;
  375. height: 46px;
  376. line-height: 46px;
  377. position: relative;
  378. padding-left: 10px;
  379. // margin-top: 10px;
  380. .star {
  381. position: absolute;
  382. top: 0px;
  383. left: 0;
  384. color: red;
  385. }
  386. .label {
  387. flex: 0 0 30%;
  388. font-size: 16px;
  389. font-family: PingFang SC;
  390. font-weight: bold;
  391. line-height: 20px;
  392. color: #282828;
  393. opacity: 1;
  394. }
  395. .right {
  396. // flex: 1;
  397. font-size: 13px;
  398. font-family: PingFang SC;
  399. font-weight: 400;
  400. line-height: 20px;
  401. color: #282828;
  402. opacity: 0.42;
  403. text-align: right;
  404. height: 20px;
  405. // overflow: hidden;
  406. display: flex;
  407. align-items: center;
  408. text {
  409. display: inline-block;
  410. width: 200px;
  411. height: 20px;
  412. line-height: 20px;
  413. overflow: hidden;
  414. white-space: nowrap;
  415. text-overflow: ellipsis;
  416. }
  417. }
  418. }
  419. .form {
  420. position: relative;
  421. .back {
  422. position: absolute;
  423. left: 10px;
  424. top: 0px;
  425. width: 30px;
  426. height: 44px;
  427. line-height: 44px;
  428. text-align: center;
  429. z-index: 9999;
  430. // background: #18B566;
  431. }
  432. .title {
  433. padding: 0 20px;
  434. height: 40px;
  435. line-height: 40px;
  436. }
  437. .input {
  438. margin: 0 20px;
  439. height: 40px;
  440. line-height: 40px;
  441. border-bottom: solid 1px rgba(175, 175, 175, .2);
  442. }
  443. }
  444. .item1 {
  445. .dec {
  446. font-size: 13px;
  447. font-family: PingFang SC;
  448. font-weight: 400;
  449. line-height: 20px;
  450. color: #AFAFAF;
  451. opacity: 1;
  452. padding-bottom: 10px;
  453. border-bottom: solid 1px rgba(175, 175, 175, .2);
  454. }
  455. }
  456. .buttom {
  457. width: 229px;
  458. height: 56px;
  459. line-height: 56px;
  460. background: #79573D;
  461. text-align: center;
  462. border-radius: 28px;
  463. margin: 0 auto;
  464. margin-top: 50px;
  465. font-size: 18px;
  466. font-family: PingFang SC;
  467. font-weight: bold;
  468. color: #fff;
  469. opacity: 1;
  470. }
  471. }
  472. </style>