setInfo.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view class="detail-view">
  3. <u-form label-width="140" :model="add_form" ref="uForm">
  4. <view class="form-model-view">
  5. <u-form-item label-position="top" label="头像" prop="avatar">
  6. <upload :images="add_form.avatar ? [add_form.avatar] : []" @handleRemove="imgRemove"
  7. @uploadSuccess="uploadSuccess" />
  8. </u-form-item>
  9. <u-form-item required label="名称" prop="staffName">
  10. <u-input v-model="add_form.staffName" placeholder="请输入姓名" />
  11. </u-form-item>
  12. <!-- <u-form-item required label="UID" prop="staffName">
  13. <u-input v-model="add_form.staffName" placeholder="请输入姓名" />
  14. </u-form-item> -->
  15. <u-form-item label-position="top" label="简介" prop="info">
  16. <u-input v-model="add_form.info" type="textarea" placeholder="请输入简介" />
  17. </u-form-item>
  18. </view>
  19. </u-form>
  20. <view class="detail-bottom">
  21. <view class="handel-btn" @click="submit">提交</view>
  22. </view>
  23. <!-- <SelDeparment v-model="show_department" @confirm="departmentConfirm" @cancel="departmentCancel" />
  24. <RegionSel v-model="region_show" @confirm="regionConfirm" @cancel="regionCancel" />
  25. <u-picker @confirm="birthdayConfirm" mode="time" v-model="time_show"></u-picker> -->
  26. </view>
  27. </template>
  28. <script>
  29. import upload from '@/components/qiniu/QiniuUpload.vue';
  30. import SelDeparment from '@/components/SelDepartment.vue';
  31. import RegionSel from '@/components/region/RegionSel.vue';
  32. export default {
  33. components: {
  34. upload,
  35. SelDeparment,
  36. RegionSel
  37. },
  38. data() {
  39. return {
  40. region_show: false,
  41. time_show: false,
  42. show_department: false,
  43. shopData: '',
  44. staffData: '',
  45. reservoirData: '',
  46. customerTypeData: '',
  47. reservoir_name: '',
  48. shop_name: '',
  49. type_name: '',
  50. department_name: '',
  51. region_name: '',
  52. birthday: '',
  53. rules: {
  54. staffName: [{
  55. required: true,
  56. message: '请输入姓名',
  57. trigger: 'blur,change'
  58. }],
  59. avatar: [{
  60. required: true,
  61. message: '请上传头像',
  62. trigger: 'blur,change'
  63. }],
  64. info: [{
  65. required: true,
  66. message: '请输入简介',
  67. trigger: 'blur,change'
  68. }]
  69. },
  70. isEvidence: '', // 是否必填营业执照
  71. add_form: {
  72. staffName: '',
  73. info: '',
  74. avatar: ''
  75. },
  76. customer_id: ''
  77. };
  78. },
  79. watch: {
  80. // reservoirData(val) {
  81. // if (val) {
  82. // this.add_form.reservoirId = val.id;
  83. // this.reservoir_name = val.reservoirName;
  84. // }
  85. // },
  86. // shopData(val) {
  87. // if (val) {
  88. // this.add_form.shopId = val.id;
  89. // this.shop_name = val.name;
  90. // }
  91. // },
  92. // customerTypeData(val) {
  93. // if (val) {
  94. // this.add_form.type = val.id;
  95. // this.type_name = val.name;
  96. // this.isEvidence = val.isEvidence;
  97. // }
  98. // },
  99. // staffData(val) {
  100. // if (val) {
  101. // this.add_form.salesManId = val.id;
  102. // this.add_form.salesManCode = val.staffCode;
  103. // this.add_form.salesManName = val.staffName;
  104. // }
  105. // }
  106. },
  107. onLoad(options) {
  108. this.getUserInfo()
  109. },
  110. methods: {
  111. getUserInfo() {
  112. this.$u.api.getStaffInfo(this.$store.state.userInfo.staffId).then(({
  113. data
  114. }) => {
  115. console.log(data,'员工信息');
  116. this.add_form.info = data.info
  117. this.add_form.avatar = data.avatar
  118. this.add_form.departmentId = data.departmentId
  119. this.add_form.staffName = data.staffName
  120. this.add_form.roleId = data.roleId
  121. this.add_form.mobile = data.mobile
  122. this.add_form.email = data.email
  123. this.add_form.staffCode = data.staffCode
  124. this.add_form.sex = data.sex
  125. this.add_form.age = data.age / 1000
  126. this.add_form.education = data.education // 学历
  127. this.add_form.departmentPidPath = data.departmentPidPath // 添加部门id的数组
  128. this.add_form.rolePidPath = data.rolePidPath // 添加角色id的数组
  129. this.add_form.dataField = data.dataField
  130. // this.add_form.is_technician = data.is_technician
  131. // this.add_form.is_clock = data.is_clock
  132. })
  133. },
  134. // const params = {
  135. // departmentId: this.form.departmentId,
  136. // staffName: this.form.staffName,
  137. // roleId: this.form.roleId,
  138. // mobile: this.form.mobile,
  139. // email: this.form.email,
  140. // staffCode: this.form.staffCode,
  141. // sex: this.form.sex,
  142. // age: this.form.age / 1000,
  143. // education: this.form.education, // 学历
  144. // departmentPidPath: this.form.departmentPidPath, // 添加部门id的数组
  145. // rolePidPath: this.form.rolePidPath, // 添加角色id的数组
  146. // dataField: this.form.dataField,
  147. // };
  148. // if (this.id) {
  149. // target = await updateStaff(this.id, params);
  150. // } else {
  151. // target = await addStaff(params);
  152. // }
  153. // const data = target;
  154. submit() {
  155. this.$refs.uForm.validate(valid => {
  156. if (valid) {
  157. this.$u.api.setYgInfo(this.$store.state.userInfo.staffId, {
  158. ...this.add_form
  159. })
  160. .then(res => {
  161. let userInfo = this.$store.state.userInfo
  162. userInfo.name = this.add_form.staffName
  163. this.$store.commit('commit_userInfo', userInfo);
  164. this.$u.toast('修改成功');
  165. setTimeout(res => {
  166. uni.navigateBack();
  167. }, 1500);
  168. });
  169. }
  170. });
  171. },
  172. regionConfirm(val) {
  173. this.add_form.provinceCode = val[0].value;
  174. this.add_form.cityCode = val[1].value;
  175. this.add_form.districtCode = val[2].value;
  176. // 联系方式
  177. this.add_form.contact.provinceCode = val[0].value;
  178. this.add_form.contact.cityCode = val[1].value;
  179. this.add_form.contact.districtCode = val[2].value;
  180. let name = '';
  181. val.forEach(item => {
  182. name += item.label;
  183. });
  184. this.region_name = name;
  185. },
  186. regionCancel(val) {
  187. this.region_show = false;
  188. },
  189. departmentConfirm(val) {
  190. this.add_form.departmentId = val[val.length - 1].value;
  191. this.department_name = val[val.length - 1].label;
  192. this.add_form.salesManId = '';
  193. this.add_form.salesManCode = '';
  194. this.add_form.salesManName = '';
  195. },
  196. departmentCancel(val) {
  197. this.show_department = false;
  198. },
  199. openSel(key) {
  200. this[key] = true;
  201. },
  202. // 图片上传成功
  203. uploadSuccess(imgUrl) {
  204. this.add_form.avatar = imgUrl;
  205. },
  206. //移除图片
  207. imgRemove(arr) {
  208. this.add_form.extend.license = '';
  209. },
  210. birthdayConfirm(val) {
  211. this.add_form.birthday = val.timestamp;
  212. this.birthday = val.year + '-' + val.month + '-' + val.day;
  213. }
  214. },
  215. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  216. // onReady() {
  217. // this.$refs.uForm.setRules(this.rules);
  218. // }
  219. };
  220. </script>
  221. <style></style>