edituser.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <!--
  2. * @Author: your name
  3. * @Date: 2020-10-22 18:26:27
  4. * @LastEditTime: 2020-11-26 08:14:05
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: \vue-manage-system-master\src\views\system\users\popups\AddOrEdit.vue
  8. -->
  9. <template>
  10. <div class="alert-body__main_content">
  11. <zz-form :cols="formCols" :data="formData" :rules="formRules" :errors="formErrors" labelWidth="110" ref="form">
  12. <el-select slot="status" v-model="formData.enableState">
  13. <el-option v-for="(item, index) in allStatus" :key="index" :label="item.label" :value="item.id">{{ item.label }}</el-option>
  14. </el-select>
  15. <el-select slot="roleId" v-model="formData.roleId">
  16. <el-option v-for="(item, index) in allRoleId" :key="index" :label="item.roleName" :value="item.id">{{
  17. item.roleName
  18. }}</el-option>
  19. </el-select>
  20. <el-select slot="userType" v-model="formData.userType">
  21. <el-option v-for="(item, index) in allUserType" :key="index" :label="item.dictValue" :value="item.id">{{
  22. item.dictValue
  23. }}</el-option>
  24. </el-select>
  25. <select-tree
  26. :props="defaultProps"
  27. slot="companyOrgId"
  28. class="new-select-tree"
  29. selectTreeTitle='组织机构'
  30. width="320"
  31. treeWidth="320"
  32. :options="organListCompany"
  33. @selected="selectedcompanyOrgId"
  34. v-model="formData.companyOrgId"
  35. :labelModel="formData.companyOrgName"
  36. />
  37. <select-tree
  38. :props="defaultProps"
  39. slot="deptOrgId"
  40. class="new-select-tree"
  41. selectTreeTitle='组织机构'
  42. width="320"
  43. treeWidth="320"
  44. :options="organListdepartment"
  45. @selected="selecteddeptOrgId"
  46. v-model="formData.deptOrgId"
  47. />
  48. <div class="imgdis-div" slot="companylogo" v-show="formData.photo">
  49. <i class="el-icon-delete" @click="delformphoto"></i>
  50. <img :src="envConfig.baseImgApi + formData.photo" alt="" width="60" height="60" />
  51. <!-- <div class="tips"><img style="width:12px;height:12px;vertical-align: middle;" src="@assets/img/icon-warning.png"/><span>支持jpg,jpeg,gif,png,bmp格式的图片</span></div> -->
  52. </div>
  53. <el-upload
  54. v-show="!formData.photo"
  55. :headers="token"
  56. ref="uploaduserlogo"
  57. class="mini-upload"
  58. slot="companylogo"
  59. limit="1"
  60. action="/sc-user-center/user/addUserPhoto"
  61. list-type="picture-card"
  62. :on-success="uploadsuccess"
  63. :auto-upload="true"
  64. name="avatarfile"
  65. >
  66. <i slot="default" class="el-icon-plus"></i>
  67. <div slot="file" slot-scope="{ file }">
  68. <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
  69. <span class="el-upload-list__item-actions">
  70. <!-- <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
  71. <i class="el-icon-zoom-in"></i>
  72. </span> -->
  73. <!-- <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleDownload(file)">
  74. <i class="el-icon-download"></i>
  75. </span> -->
  76. <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
  77. <i class="el-icon-delete"></i>
  78. </span>
  79. </span>
  80. </div>
  81. <div class="tips"><img style="width:12px;height:12px;vertical-align: middle;" src="@assets/img/icon-warning.png"/><span>支持jpg,jpeg,gif,png,bmp格式的图片</span></div>
  82. </el-upload>
  83. <el-dialog :visible.sync="dialogVisible">
  84. <img width="100%" :src="dialogImageUrl" alt="" />
  85. </el-dialog>
  86. </zz-form>
  87. </div>
  88. </template>
  89. <script>
  90. import envConfig from '@/config';
  91. // import SelectTree from '@/components/common/SelectTree.vue';
  92. export default {
  93. props: ['params'],
  94. components: {
  95. // SelectTree
  96. },
  97. data() {
  98. return {
  99. token: {
  100. [localStorage.getItem('SC_token') && 'Authorization']: 'Bearer ' + localStorage.getItem('SC_token')
  101. },
  102. envConfig: envConfig,
  103. organList: [
  104. {
  105. id: 1,
  106. tenantId: 'string123',
  107. orgName: '公司',
  108. parentOrgId: 0,
  109. orgs: [{ id: 2, tenantId: 'string123', orgName: '部门', parentOrgId: 1, orgs: null, display: true }],
  110. display: true
  111. }
  112. ],
  113. organListCompany:[],
  114. organListdepartment:[],
  115. phoneNumber:'',
  116. defaultProps: {
  117. value: 'id', // 唯一标识
  118. label: 'orgName', // 标签显示
  119. children: 'orgs' // 子级
  120. },
  121. formData: {
  122. companyOrgId: '',
  123. companyOrgName: '',
  124. createBy: '',
  125. dateCreate: '',
  126. dateUpdate: '',
  127. deptOrgId: '',
  128. deptOrgName: '',
  129. email: '',
  130. enableState: '',
  131. id: '',
  132. phone: '',
  133. photo: '',
  134. remark: '',
  135. roleId: '',
  136. status: '',
  137. tenantId: '',
  138. updateBy: '',
  139. userGroupId: '',
  140. userTags: '',
  141. userType: '',
  142. username: ''
  143. },
  144. dialogImageUrl: '',
  145. dialogVisible: false,
  146. disabled: false,
  147. allStatus: [
  148. {
  149. id: '0',
  150. label: '停用'
  151. },
  152. {
  153. id: '1',
  154. label: '启用'
  155. }
  156. ],
  157. allRoleId: [],
  158. allUserType: [],
  159. formCols: [
  160. [
  161. {
  162. label: '用户名',
  163. prop: 'username',
  164. input: true
  165. },
  166. {
  167. label: '手机号码',
  168. prop: 'phone',
  169. input: true
  170. },
  171. {
  172. label: '头像',
  173. prop: 'photo',
  174. slot: 'companylogo'
  175. },
  176. {
  177. label: '邮箱',
  178. prop: 'email',
  179. input: true
  180. },
  181. {
  182. label: '备注',
  183. prop: 'remark',
  184. input: true
  185. }
  186. ]
  187. ],
  188. formRules: {
  189. companyOrgId: [this.$valid.selectRequired('所属公司')],
  190. // deptOrgId: [this.$valid.selectRequired('所属部门')],
  191. username: [this.$valid.inputRequired('用户名')],
  192. phone: [this.$valid.patternPhone()],
  193. enableState: [this.$valid.inputRequired('状态')]
  194. },
  195. formErrors: {}
  196. };
  197. },
  198. methods: {
  199. delformphoto() {
  200. this.formData.photo = '';
  201. this.$refs.uploaduserlogo.clearFiles();
  202. },
  203. getselectAll() {},
  204. submit() {
  205. new Promise((resolve) => {
  206. this.$refs.form.validate(resolve);
  207. }).then(() => {
  208. var loading = this.$loading();
  209. var posturl = '/sc-user-center/user/updateUserById';
  210. this.$http
  211. .post(posturl, this.formData)
  212. .then(({ status, data, msg }) => {
  213. loading.close();
  214. if (0 == status) {
  215. this.$message.success(msg);
  216. if(this.phoneNumber!==this.formData.phone){
  217. this.$alert('你的手机号已变更,需重新登录', '提示', {
  218. confirmButtonText: '确定',
  219. showClose:false,
  220. }).then(()=>{
  221. window.open('http://114.135.61.188:18093/login/login', '_self');
  222. window.relogin = false;
  223. localStorage.removeItem('SC_token');
  224. return;
  225. });
  226. }else{
  227. this.params.callback && this.params.callback();
  228. this.$emit('close');
  229. if(this.$route.path==='/userInfo'){
  230. this.$router.go(0);
  231. }
  232. }
  233. } else {
  234. this.$message.error(msg);
  235. }
  236. })
  237. .catch((err) => {
  238. loading.close();
  239. });
  240. });
  241. },
  242. handleRemove(file) {
  243. this.$refs.uploaduserlogo.clearFiles();
  244. },
  245. uploadsuccess(response, file, fileList) {
  246. if (0 === response.status) {
  247. this.formData.photo = response.data;
  248. }
  249. }
  250. },
  251. created() {
  252. this.getselectAll();
  253. // this.getcompanyTree();
  254. this.phoneNumber=this.params.data.phone;
  255. this.formData = this.params.data ? this.params.data : this.formData;
  256. this.organList = this.params.organList ? this.params.organList : this.organList;
  257. this.organListCompany = this.params.organListCompany ? this.params.organListCompany : this.organListCompany;
  258. this.organListdepartment = this.params.organListdepartment ? this.params.organListdepartment : this.organListdepartment;
  259. this.allRoleId = this.params.allRoleId ? this.params.allRoleId : this.allRoleId;
  260. this.allUserType = this.params.allUserType ? this.params.allUserType : this.allUserType;
  261. }
  262. };
  263. </script>
  264. <style lang='scss' scoped>
  265. </style>
  266. <style lang="scss">
  267. .mini-upload .el-upload-list--picture-card .el-upload-list__item {
  268. width: 60px;
  269. height: 60px;
  270. }
  271. .mini-upload .el-upload--picture-card {
  272. width: 60px;
  273. height: 60px;
  274. line-height: 60px;
  275. font-size: 14px;
  276. }
  277. .mini-upload .el-upload--picture-card i {
  278. font-size: 20px;
  279. }
  280. .imgdis-div {
  281. width: 60px;
  282. height: 60px;
  283. position: relative;
  284. }
  285. .imgdis-div i {
  286. display: none;
  287. position: absolute;
  288. top: 50%;
  289. left: 50%;
  290. transform: translate(-50%, -50%);
  291. }
  292. // .imgdis-div .notice{
  293. // display: contents;
  294. // font-size: 12px;
  295. // }
  296. .imgdis-div:hover i {
  297. display: block;
  298. }
  299. // .imgdis-div .tips{
  300. // position: absolute;
  301. // font-size: 0.12px;
  302. // font-family: MicrosoftYaHei;
  303. // color: #7D7F87;
  304. // top: 10px;
  305. // right: -261px;
  306. // }
  307. .el-upload .tips {
  308. position: absolute;
  309. top: 0;
  310. right: 0;
  311. font-size: 12px;
  312. color: #7D7F87;
  313. // font-size: 12px;
  314. // span{
  315. // position: absolute;
  316. // font-size: 12px;
  317. // font-family: MicrosoftYaHei;
  318. // color: #7D7F87;
  319. // top: 0px;
  320. // right: 0px;
  321. // }
  322. }
  323. </style>