addUserDialog.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <el-dialog :visible.sync="isAddUserDialogShow" :close-on-click-modal="false" :modal-append-to-body='false' class="add-user-dialog-wrap"
  3. @close="$emit('close')" center width="986px" v-dialogDrag>
  4. <div slot="title" style="display:flex;alignItems:center;">
  5. <img :src="userForm.title==$t('SystemManage.DepartManage.user_add_btn')?$icons.add:$icons.edit"
  6. style="color:#fff;width:16px;height:16px;marginRight:5px;">
  7. <span style="fontSize:16px;">{{userForm.title}}</span>
  8. </div>
  9. <el-form @submit.native.prevent :model="userForm" :rules="userRule" ref="userForm" label-width="160px"
  10. class="demo-ruleForm" style="marginTop:15px;">
  11. <el-form-item :label="$t('SystemManage.DepartManage.user_login_accout')" prop="account">
  12. <el-input v-model="userForm.account" :placeholder="$t('SystemManage.DepartManage.user_add_placeholder01')" :disabled="userForm.disabledForm" clearable>
  13. </el-input>
  14. </el-form-item>
  15. <el-form-item :label="$t('SystemManage.DepartManage.user_login_pwd')" prop="pwd" v-if="userForm.title == $t('SystemManage.DepartManage.user_add_btn')">
  16. <el-input v-model.trim="userForm.pwd" :placeholder="$t('SystemManage.DepartManage.user_add_placeholder02')"
  17. :type="userForm.title == $t('SystemManage.DepartManage.user_add_btn') ? 'text' : 'password' " clearable></el-input>
  18. </el-form-item>
  19. <el-form-item :label="$t('SystemManage.DepartManage.user_table_name')" prop="name">
  20. <el-input v-model="userForm.name" :placeholder="$t('SystemManage.DepartManage.user_add_placeholder03')" clearable>
  21. </el-input>
  22. </el-form-item>
  23. <el-form-item :label="$t('SystemManage.DepartManage.user_table_mobile')" prop="mobile" class="mobile-input-item">
  24. <el-input v-model.trim="userForm.mobile" :placeholder="$t('SystemManage.DepartManage.user_add_placeholder04')" clearable class="mobile-input">
  25. </el-input>
  26. <el-select v-model="userForm.areacode" class="mobile-select" placeholder="请选择">
  27. <el-option v-for="item in areaCode" :key="item.Value"
  28. :label="item.Name" :value="item.Value" />
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item label="用户类型" prop="IsLdap">
  32. <el-select v-model="userForm.IsLdap" placeholder="请选择用户类型">
  33. <el-option label="系统用户" :value="0"></el-option>
  34. <el-option label="域用户" :value="1"></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item :label="$t('SystemManage.DepartManage.user_depart')" prop="depart" v-if="userForm.title == $t('SystemManage.DepartManage.user_add_btn')">
  38. <el-cascader :options="departArr" v-model="userForm.depart" :props="form_departProp"
  39. :placeholder="$t('SystemManage.DepartManage.user_add_placeholder05')" :disabled="userForm.disabledForm" clearable>
  40. </el-cascader>
  41. </el-form-item>
  42. <el-form-item :label="$t('SystemManage.DepartManage.user_email')" prop="email">
  43. <el-input v-model="userForm.email" :placeholder="$t('SystemManage.DepartManage.user_add_placeholder06')"></el-input>
  44. </el-form-item>
  45. <el-form-item :label="$t('SystemManage.DepartManage.user_table_employee_id')" prop="employeeNumber">
  46. <el-input :disabled="hasEmployeeNo" v-model="userForm.employeeNumber" :placeholder="$t('SystemManage.DepartManage.user_add_placeholder07')"></el-input>
  47. </el-form-item>
  48. <el-form-item :label="$t('SystemManage.DepartManage.user_role')" prop="role">
  49. <el-select v-model="userForm.role" :placeholder="$t('SystemManage.DepartManage.user_role')" :disabled="userForm.disabledForm" @change="roleChange">
  50. <el-option v-for="item in roleArr" :key="item.RoleId" :label="item.RoleName" :value="item.RoleId">
  51. </el-option>
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item :label="$t('SystemManage.DepartManage.user_table_direct')" prop="direct" v-permission="permissionBtn.sysDepartPermission.sysDepart_saveUser_researchGroup">
  55. <el-cascader collapse-tags :show-all-levels="false" :options="researchGroup" v-model="userForm.direct"
  56. :props="form_directProp" :placeholder="$t('SystemManage.DepartManage.user_add_placeholder08')" clearable></el-cascader>
  57. </el-form-item>
  58. <el-form-item :label="$t('SystemManage.DepartManage.user_table_position')" prop="post">
  59. <el-input v-model="userForm.post" :placeholder="$t('SystemManage.DepartManage.user_add_placeholder09')" clearable>
  60. </el-input>
  61. </el-form-item>
  62. <el-form-item :label="$t('SystemManage.DepartManage.user_table_address')" prop="city"
  63. :rules="[2,6,18].includes(userForm.role)?{ required: true, message: '工作地点不能为空', trigger: 'change' }:{}">
  64. <search-dist-picker
  65. :provinceInfo="userForm.province"
  66. :cityInfo="userForm.city"
  67. @selected="selectRegion"/>
  68. </el-form-item>
  69. <el-form-item :label="$t('SystemManage.DepartManage.user_table_status')" prop="status">
  70. <el-radio-group v-model="userForm.status" :disabled="userForm.disabledStatus">
  71. <el-radio :label="1">{{$t('SystemManage.DepartManage.user_table_status_open')}}</el-radio>
  72. <el-radio :label="0">{{$t('SystemManage.DepartManage.user_table_status_ban')}}</el-radio>
  73. </el-radio-group>
  74. </el-form-item>
  75. </el-form>
  76. <div style="display:flex;justify-content:center;margin:0 0 26px;">
  77. <el-button type="primary" style="width:80px;marginRight:24px;" @click="$emit('save')">{{$t('Dialog.confirm_save_btn')}}</el-button>
  78. <el-button style="width:80px;" @click="$emit('close')">{{$t('Dialog.cancel_btn')}}</el-button>
  79. </div>
  80. </el-dialog>
  81. </template>
  82. <script>
  83. import searchDistPicker from '@/components/searchDistPicker.vue';
  84. import {patternEmail,isMobileNo,checkPassWord} from '@/utils/commonOptions';
  85. export default {
  86. props: {
  87. isAddUserDialogShow: {
  88. type: Boolean,
  89. default: false,
  90. },
  91. userForm: {
  92. type: Object,
  93. default: () => {
  94. return {}
  95. }
  96. },
  97. roleArr:{
  98. type:Array,
  99. default:()=>{return []}
  100. },
  101. departArr:{
  102. type:Array,
  103. default:()=>{return []}
  104. },
  105. hasEmployeeNo:{
  106. type:Boolean,
  107. default:false
  108. },
  109. researchGroup:{
  110. type:Array,
  111. default:()=>{return []}
  112. },
  113. areaCode:{
  114. type:Array,
  115. default:()=>{return []}
  116. }
  117. },
  118. components:{searchDistPicker},
  119. computed:{
  120. userRule() {
  121. return {
  122. account:[{required: true, message: this.$t('SystemManage.DepartManage.use_add_valid_msg01'), trigger: 'blur'}],
  123. pwd:[
  124. {
  125. validator:(rule,value,callback)=>{
  126. if(this.userForm.IsLdap==1){
  127. callback()
  128. return
  129. }else{
  130. if(value===''){
  131. callback(new Error(this.$t('SystemManage.DepartManage.use_add_valid_msg02')))
  132. }
  133. if(!checkPassWord(value)){
  134. callback(new Error('密码要求8位及以上,包含数字、大写字母、小写字母、特殊字符中的三个类型'))
  135. }else{
  136. callback()
  137. }
  138. }
  139. }
  140. }
  141. ],
  142. name:[{ required: true, message: this.$t('SystemManage.DepartManage.use_add_valid_msg04'), trigger: 'blur' }],
  143. mobile:[{ validator: (rule, value, callback) => {
  144. if (value === ''&&!this.userForm.email) {
  145. callback(new Error(this.$t('SystemManage.DepartManage.use_add_valid_msg05')));
  146. }else if(value&&this.userForm.areacode==='86'&&!isMobileNo(value)) {
  147. callback(new Error(this.$t('SystemManage.DepartManage.use_add_valid_msg06')));
  148. } else if(this.userForm.areacode!=='86'&&isNaN(value.trim())){
  149. callback(new Error(this.$t('SystemManage.DepartManage.use_add_valid_msg06')));
  150. }else {
  151. callback();
  152. }
  153. }, trigger: 'blur'}],
  154. email:[{ validator: (rule, value, callback) => {
  155. if (value === ''&&!this.userForm.mobile) {
  156. callback(new Error(this.$t('SystemManage.DepartManage.use_add_valid_msg05')));
  157. }else if(value&&!patternEmail.test(value)) {
  158. callback(new Error(this.$t('SystemManage.DepartManage.use_add_valid_msg07')));
  159. } else {
  160. callback();
  161. }
  162. }, trigger: 'blur'}],
  163. depart:[{ required: true, message: this.$t('SystemManage.DepartManage.use_add_valid_msg08'), trigger: 'change' }],
  164. // employeeNumber:[{validator:(rule,value,callback)=>{
  165. // if(!value){
  166. // callback()
  167. // return
  168. // }
  169. // // 取消空格
  170. // let tempValue = parseInt(value.replaceAll(' ',''))
  171. // if(!tempValue || value.replaceAll(' ','').length!=4){
  172. // callback(new Error(this.$t('SystemManage.DepartManage.use_add_valid_msg09')))
  173. // }else{
  174. // callback()
  175. // }
  176. // },trigger:'blur'}],
  177. role:[{ required: true, message: this.$t('SystemManage.DepartManage.use_add_valid_msg10'), trigger: 'change' }],
  178. }
  179. },
  180. },
  181. data() {
  182. return {
  183. // userRule: {
  184. // account:[{required: true, message: '登录账号不能为空', trigger: 'blur'}],
  185. // pwd:[{validator:(rule,value,callback)=>{
  186. // if(value===''){
  187. // callback(new Error('请输入新密码'))
  188. // }
  189. // if(!checkPassWord(value)){
  190. // callback(new Error('密码要求8位及以上,包含数字、大写字母、小写字母、特殊字符中的三个类型'))
  191. // }else{
  192. // callback()
  193. // }
  194. // }}],
  195. // name:[{ required: true, message: '姓名不能为空', trigger: 'blur' }],
  196. // mobile:[{ validator: (rule, value, callback) => {
  197. // if (value === ''&&!this.userForm.email) {
  198. // callback(new Error('手机号码和邮箱至少填一个'));
  199. // }else if(value&&this.userForm.areacode==='86'&&!isMobileNo(value)) {
  200. // callback(new Error('请输入正确的手机号格式'));
  201. // } else if(this.userForm.areacode!=='86'&&isNaN(value.trim())){
  202. // callback(new Error('请输入正确的手机号格式'));
  203. // }else {
  204. // callback();
  205. // }
  206. // }, trigger: 'blur'}],
  207. // email:[{ validator: (rule, value, callback) => {
  208. // if (value === ''&&!this.userForm.mobile) {
  209. // callback(new Error('手机号码和邮箱至少填一个'));
  210. // }else if(value&&!patternEmail.test(value)) {
  211. // callback(new Error('请输入正确的邮箱格式'));
  212. // } else {
  213. // callback();
  214. // }
  215. // }, trigger: 'blur'}],
  216. // depart:[{ required: true, message: '部门分组不能为空', trigger: 'change' }],
  217. // employeeNumber:[{validator:(rule,value,callback)=>{
  218. // if(!value){
  219. // callback()
  220. // return
  221. // }
  222. // // 取消空格
  223. // let tempValue = parseInt(value.replaceAll(' ',''))
  224. // if(!tempValue || value.replaceAll(' ','').length!=4){
  225. // callback(new Error('请输入四位数字'))
  226. // }else{
  227. // callback()
  228. // }
  229. // },trigger:'blur'}],
  230. // role:[{ required: true, message: '角色不能为空', trigger: 'change' }],
  231. // },
  232. form_departProp:{
  233. value:'DepartmentId',
  234. label:'DepartmentName',
  235. children:'Child',
  236. checkStrictly:true
  237. },//部门分组选择配置
  238. form_directProp: {
  239. value:'tag_id',
  240. label:'tag_name',
  241. children:'tags',
  242. multiple: true
  243. }, //研究方向选择配置
  244. };
  245. },
  246. methods: {
  247. selectRegion(data){
  248. this.$emit('selectRegion',data)
  249. },
  250. roleChange(value){
  251. if([2,6,18].includes(value)) return
  252. this.$refs.userForm && this.$refs.userForm.clearValidate(['city'])
  253. },
  254. },
  255. };
  256. </script>
  257. <style lang="scss">
  258. .add-user-dialog-wrap{
  259. .select-dist-picker{
  260. .el-select{
  261. width:145px;
  262. }
  263. }
  264. .mobile-input-item{
  265. position:relative;
  266. .mobile-select{
  267. position:absolute;
  268. top:0;
  269. left:0;
  270. width:115px !important;
  271. }
  272. .mobile-input{
  273. .el-input__inner{
  274. padding-left: 125px !important;
  275. }
  276. }
  277. }
  278. }
  279. </style>
  280. <style scoped lang="scss">
  281. .add-user-dialog-wrap{
  282. .demo-ruleForm{
  283. display: flex;
  284. flex-wrap: wrap;
  285. gap:0 10px;
  286. .el-form-item{
  287. .el-input,.el-cascader,.el-select{
  288. width:300px;
  289. }
  290. }
  291. }
  292. }
  293. </style>