plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

419 lines
14 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="user-add-or-update">
  3. <el-dialog
  4. width="530px"
  5. :title="!dataForm.id ? buttons.add :buttons.edit"
  6. :close-on-click-modal="false"
  7. :visible.sync="visible"
  8. @close="closeDataDialog">
  9. <!-- 取消 :rules="dataRule"-->
  10. <el-form :inline="true" :model="dataForm" label-position="top" ref="dataForm"
  11. @keyup.enter.native="dataFormSubmit()"
  12. label-width="80px">
  13. <el-form>
  14. <el-form-item :label="buttons.username||'用户账号'" prop="userName">
  15. <el-input v-model="dataForm.userName" style="width: 150px;" placeholder="登录帐号"></el-input>
  16. </el-form-item>
  17. <el-form-item :label="buttons.password||'密码'" prop="password" :class="{ 'is-required': !dataForm.id }">
  18. <el-input v-model="dataForm.password" style="width: 150px;" type="password" ></el-input>
  19. </el-form-item>
  20. <el-form-item :label="buttons.comfirmPassword||'确认密码'" prop="comfirmPassword" :class="{ 'is-required': !dataForm.id }">
  21. <el-input v-model="dataForm.comfirmPassword" style="width: 150px;" type="password"
  22. ></el-input>
  23. </el-form-item>
  24. </el-form>
  25. <el-form>
  26. <el-form-item :label="buttons.userDisplay||'用户名'" prop="email">
  27. <el-input v-model="dataForm.userDisplay" style="width: 150px;" ></el-input>
  28. </el-form-item>
  29. <el-form-item :label="buttons.email||'邮箱'" prop="email">
  30. <el-input v-model="dataForm.email" style="width: 150px;" ></el-input>
  31. </el-form-item>
  32. <el-form-item :label="buttons.mobile||'手机号'" prop="mobile">
  33. <el-input v-model="dataForm.mobile" style="width: 150px;" placeholder="手机号"></el-input>
  34. </el-form-item>
  35. </el-form>
  36. <el-form>
  37. <el-form-item :label="'工厂'">
  38. <el-select v-model="dataForm.siteID" clearable style="width: 150px;" placeholder="请选择" @change="getBUDepartmentPostList">
  39. <el-option
  40. :label="i.siteID + '-' + i.siteName"
  41. :value="i.siteID"
  42. v-for="i in siteList "
  43. :key="i.siteID">
  44. </el-option>
  45. </el-select>
  46. </el-form-item>
  47. <!-- <el-form-item >-->
  48. <!-- <span slot="label" style="" @click="getBaseList(18)"><a herf="#">{{buttons.site||'工厂'}}</a></span>-->
  49. <!-- <el-input v-model="dataForm.site" style="width: 150px;" placeholder="工厂"></el-input>-->
  50. <!-- </el-form-item>-->
  51. <!-- <el-form-item :label="buttons.language||'语言'" prop="languageDefault">-->
  52. <!-- <el-select filterable v-model="dataForm.languageDefault" clearable style="width: 150px;">-->
  53. <!-- <el-option :label="item.languageName" :value="item.languageCode" v-for="(item,index) in languageList "-->
  54. <!-- :key="index"></el-option>-->
  55. <!-- </el-select>-->
  56. <!-- </el-form-item>-->
  57. <el-form-item :label="'BU'">
  58. <el-select v-model="dataForm.buNo" clearable style="width: 150px;" placeholder="请选择">
  59. <el-option
  60. :label="i.buNo + '-' + i.buDesc"
  61. :value="i.buNo"
  62. v-for="i in buList "
  63. :key="i.buNo">
  64. </el-option>
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item :label="buttons.department||'部门'" prop="department">
  68. <el-select v-model="dataForm.departmentNo" clearable style="width: 150px;" placeholder="请选择">
  69. <el-option
  70. :label="i.departmentNo + '-' + i.departmentName"
  71. :value="i.departmentNo"
  72. v-for="i in departmentList "
  73. :key="i.departmentNo">
  74. </el-option>
  75. </el-select>
  76. </el-form-item>
  77. </el-form>
  78. <el-form>
  79. <el-form-item :label="buttons.post||'岗位'" prop="post">
  80. <el-select v-model="dataForm.postNo" clearable style="width: 150px;" placeholder="请选择">
  81. <el-option
  82. :label="i.postNo + '-' + i.postName"
  83. :value="i.postNo"
  84. v-for="i in postList "
  85. :key="i.postNo">
  86. </el-option>
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item label="角色" size="mini" prop="roleIdList">
  90. <el-checkbox-group v-model="dataForm.roleIdList">
  91. <el-checkbox v-for="role in roleList" :key="role.roleId" :label="role.roleId">{{
  92. role.roleName
  93. }}
  94. </el-checkbox>
  95. </el-checkbox-group>
  96. </el-form-item>
  97. <el-form-item label="状态" size="mini" prop="status">
  98. <el-radio-group v-model="dataForm.status">
  99. <el-radio :label="0">{{buttons.disable||'禁用'}}</el-radio>
  100. <el-radio :label="1">{{buttons.normal||'正常'}}</el-radio>
  101. </el-radio-group>
  102. </el-form-item>
  103. </el-form>
  104. </el-form>
  105. <span slot="footer" class="dialog-footer">
  106. <el-button type="primary" @click="dataFormSubmit()">{{buttons.submit||'确定'}}</el-button>
  107. <el-button type="primary" @click="visible = false">{{buttons.close||'取消'}}</el-button>
  108. </span>
  109. </el-dialog>
  110. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  111. </div>
  112. </template>
  113. <script>
  114. import Chooselist from '@/views/modules/common/Chooselist'
  115. import {getFactory} from "@/api/factory";
  116. import {searchSysLanguage} from "@/api/sysLanguage.js"
  117. import {
  118. searchFunctionButtonList,
  119. } from "@/api/sysLanguage.js"
  120. import {getBUList, getDepartmentList, getPostList, getSiteList} from '../../../api/base/site'
  121. export default {
  122. components: {
  123. Chooselist
  124. },
  125. data() {
  126. return {
  127. tagNo:'',
  128. visible: false,
  129. roleList: [],
  130. factorys: [],
  131. languageList: [],
  132. siteList:[],
  133. buList:[],
  134. departmentList:[],
  135. postList:[],
  136. dataForm: {
  137. id: 0,
  138. userName: '',
  139. password: '',
  140. comfirmPassword: '',
  141. languageDefault: '',
  142. salt: '',
  143. email: '',
  144. mobile: '',
  145. buNo: '',
  146. buDesc: '',
  147. department:'',
  148. departmentNo:'',
  149. departmentName:'',
  150. post:'',
  151. postNo:'',
  152. postName:'',
  153. roleIdList: [],
  154. status: 1,
  155. site: '',
  156. siteID: '',
  157. bu:'',
  158. siteName:'',
  159. userDisplay: ''
  160. },
  161. buttons: {
  162. add: '添加',
  163. edit: '编辑',
  164. username: '用户账号',
  165. userDisplay: '用户名',
  166. email: '邮箱',
  167. mobile: '手机号',
  168. bu:'BU',
  169. department:'部门',
  170. post:'岗位',
  171. status: '状态',
  172. disable: '禁用',
  173. normal: '正常',
  174. password:'密码',
  175. comfirmPassword:'确认密码',
  176. submit: '确定',
  177. close: '取消',
  178. siteID: '工厂',
  179. siteName:'工厂名称',
  180. language: '语言',
  181. },
  182. }
  183. },
  184. methods: {
  185. getSiteList () {
  186. getSiteList().then(({data}) => {
  187. this.siteList = data.rows
  188. // let list = data.rows.map(item=>{
  189. // return {
  190. // site:item.siteID,
  191. // siteName:item.siteName
  192. // }
  193. // })
  194. // console.log(list)
  195. })
  196. },
  197. getBUDepartmentPostList () {
  198. let tempData ={
  199. site:this.dataForm.siteID
  200. }
  201. this.dataForm.buNo = ''
  202. this.dataForm.buDesc = ''
  203. this.dataForm.departmentNo = ''
  204. this.dataForm.departmentName = ''
  205. this.dataForm.postNo = ''
  206. this.dataForm.postName = ''
  207. getBUList(tempData).then(({data}) => {
  208. this.buList = data.rows
  209. this.dataForm.buDesc = data.rows.buDesc
  210. })
  211. getDepartmentList(tempData).then(({data}) => {
  212. this.departmentList = data.rows
  213. this.dataForm.departmentName = data.rows.departmentName
  214. })
  215. getPostList(tempData).then(({data}) => {
  216. this.postList = data.rows
  217. this.dataForm.postName = data.rows.postName
  218. })
  219. },
  220. getBDPList () {
  221. let tempData ={
  222. site:this.dataForm.siteID
  223. }
  224. getBUList(tempData).then(({data}) => {
  225. this.buList = data.rows
  226. this.dataForm.buDesc = data.rows.buDesc
  227. })
  228. getDepartmentList(tempData).then(({data}) => {
  229. this.departmentList = data.rows
  230. this.dataForm.departmentName = data.rows.departmentName
  231. })
  232. getPostList(tempData).then(({data}) => {
  233. this.postList = data.rows
  234. this.dataForm.postName = data.rows.postName
  235. })
  236. },
  237. getFunctionButtonList() {
  238. let queryButton = {
  239. functionId: this.$route.meta.menuId,
  240. tableId: '*',
  241. languageCode: this.$i18n.locale,
  242. objectType: 'button'
  243. }
  244. searchFunctionButtonList(queryButton).then(({data}) => {
  245. if (data.code == 0 && data.data) {
  246. this.buttons = data.data
  247. }
  248. })
  249. },
  250. getBaseData(val){
  251. if (this.tagNo === 18){
  252. this.dataForm.site = val.SiteID
  253. }
  254. },
  255. // 获取基础数据列表
  256. getBaseList(val){
  257. this.tagNo = val
  258. this.$nextTick(() => {
  259. let strVal = "";
  260. if (val === 18){
  261. strVal = this.dataForm.site
  262. }
  263. this.$refs.baseList.init(val,strVal)
  264. })
  265. },
  266. // 获取多语言列表
  267. getLanguageList() {
  268. let queryLanguage = { languageCode: this.$i18n.locale}
  269. searchSysLanguage(queryLanguage).then(({data}) => {
  270. this.languageList = data.rows
  271. })
  272. },
  273. init(id) {
  274. this.dataForm.id = id || 0
  275. // this.factoryList();
  276. this.getLanguageList();
  277. this.$http({
  278. url: this.$http.adornUrl('/sys/role/select'),
  279. method: 'get',
  280. params: this.$http.adornParams()
  281. }).then(({data}) => {
  282. this.roleList = data && data.code === 0 ? data.list : []
  283. }).then(() => {
  284. this.visible = true
  285. this.$nextTick(() => {
  286. this.$refs['dataForm'].resetFields()
  287. })
  288. }).then(() => {
  289. if (this.dataForm.id) {
  290. this.$http({
  291. url: this.$http.adornUrl(`/sys/user/info/${this.dataForm.id}`),
  292. method: 'get',
  293. params: this.$http.adornParams()
  294. }).then(({data}) => {
  295. if (data && data.code === 0) {
  296. this.dataForm.userName = data.user.username
  297. this.dataForm.salt = data.user.salt
  298. this.dataForm.email = data.user.email
  299. this.dataForm.mobile = data.user.mobile
  300. this.dataForm.roleIdList = data.user.roleIdList
  301. this.dataForm.status = data.user.status
  302. this.dataForm.languageDefault = data.user.languageDefault
  303. this.dataForm.userDisplay = data.user.userDisplay
  304. this.dataForm.siteID = data.user.site
  305. this.dataForm.buNo = data.user.buNo
  306. this.dataForm.buDesc = data.user.buDesc
  307. this.dataForm.department = data.user.department
  308. this.dataForm.departmentNo = data.user.departmentNo
  309. this.dataForm.departmentName = data.user.departmentName
  310. this.dataForm.post = data.user.post
  311. this.dataForm.postNo = data.user.postNo
  312. this.getBDPList()
  313. }
  314. })
  315. } else {
  316. this.dataForm = {
  317. buNo: '',
  318. buDesc: '',
  319. userName: '',
  320. password: '',
  321. comfirmPassword: '',
  322. languageDefault: '',
  323. salt: '',
  324. email: '',
  325. mobile: '',
  326. bu:'',
  327. department:'',
  328. departmentNo:'',
  329. departmentName:'',
  330. post:'',
  331. postNo:'',
  332. postName:'',
  333. roleIdList: [],
  334. status: 1,
  335. site: '',
  336. siteID: '',
  337. siteName:'',
  338. userDisplay: ''
  339. }
  340. }
  341. })
  342. },
  343. // 表单提交
  344. dataFormSubmit() {
  345. this.$refs['dataForm'].validate((valid) => {
  346. if (valid) {
  347. this.$http({
  348. url: this.$http.adornUrl(`/sys/user/${!this.dataForm.id ? 'save' : 'update'}`),
  349. method: 'post',
  350. data: this.$http.adornData({
  351. 'userId': this.dataForm.id || undefined,
  352. 'username': this.dataForm.userName,
  353. 'password': this.dataForm.password,
  354. 'salt': this.dataForm.salt,
  355. 'email': this.dataForm.email,
  356. 'mobile': this.dataForm.mobile,
  357. 'status': this.dataForm.status,
  358. 'roleIdList': this.dataForm.roleIdList,
  359. 'languageDefault': this.dataForm.languageDefault,
  360. 'site': this.dataForm.siteID,
  361. 'userDisplay': this.dataForm.userDisplay,
  362. 'buNo': this.dataForm.buNo,
  363. 'departmentNo': this.dataForm.departmentNo,
  364. 'postNo': this.dataForm.postNo,
  365. })
  366. }).then(({data}) => {
  367. if (data && data.code === 0) {
  368. this.$message.success( '操作成功')
  369. this.visible = false
  370. this.$emit('refreshDataList')
  371. } else {
  372. this.$message.error(data.msg)
  373. }
  374. })
  375. }
  376. })
  377. },
  378. // 关闭弹窗
  379. closeDataDialog() {
  380. this.dataForm = {
  381. buNo: '',
  382. buDesc: '',
  383. userName: '',
  384. password: '',
  385. comfirmPassword: '',
  386. languageDefault: '',
  387. salt: '',
  388. email: '',
  389. mobile: '',
  390. bu:'',
  391. department:'',
  392. departmentNo:'',
  393. departmentName:'',
  394. post:'',
  395. postNo:'',
  396. postName:'',
  397. roleIdList: [],
  398. status: 1,
  399. site: '',
  400. siteID: '',
  401. siteName:'',
  402. userDisplay: ''
  403. }
  404. }
  405. },
  406. created() {
  407. this.getFunctionButtonList()
  408. this.getSiteList()
  409. }
  410. }
  411. </script>
  412. <style lang="scss" scoped>
  413. </style>