123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <template>
- <el-dialog
- :title="!dataForm.id ? '新增' : '修改'"
- :close-on-click-modal="false"
- :visible.sync="visible"
- width="600px">
- <el-form
- :rules="dataRule"
- :model="dataForm"
- ref="dataForm"
- @keyup.enter.native="dataFormSubmit()"
- label-width="80px"
- size="mini"
- style="margin-left: 20px;width: 500px">
- <el-form-item label="岗位名称" prop="jobName">
- <el-input v-model="dataForm.jobName"></el-input>
- </el-form-item>
- <el-form-item label="岗位代码" prop="jobCode">
- <el-input v-model="dataForm.jobCode"></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button size="mini" @click="visible = false">关闭</el-button>
- <el-button size="mini" type="primary" @click="dataFormSubmit()">确定</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- export default {
- data () {
- return {
- visible: false,
- dataForm: {
- id: undefined,
- jobName: '',
- jobCode: ''
- },
- dataRule: {
- jobName: [
- { required: true, message: '岗位名称不能为空', trigger: 'blur' },
- { min: 1, max: 10, message: '长度在 1 到 10 个字符之间', trigger: ['blur', 'change'] }
- ],
- jobCode: [
- { required: true, message: '岗位代码不能为空', trigger: 'blur' },
- { type: 'string' , message: '以GW开头,后接三位数字', pattern: /^GW[0-9]{3}$/ }
- ]
- }
- }
- },
- methods: {
- init (id) {
- this.visible = true
- this.$nextTick(() => {
- this.$refs['dataForm'].resetFields()
- })
- this.dataForm.id = id || undefined
- if (this.dataForm.id) {
- this.$http({
- url: this.$http.adornUrl(`/sys/job/info/${this.dataForm.id}`),
- method: 'get',
- params: this.$http.adornParams()
- }).then(({data}) => {
- console.log(data);
- if (data && data.code === 0) {
- this.dataForm.jobName = data.job.jobName
- this.dataForm.jobCode = data.job.jobCode
- }
- })
- }
- // this.$http({
- // url: this.$http.adornUrl('/sys/job/select'),
- // method: 'get',
- // params: this.$http.adornParams()
- // }).then(({data}) => {
- // this.roleList = data && data.code === 0 ? data.list : []
- // }).then(() => {
- // this.visible = true
- // this.$nextTick(() => {
- // this.$refs['dataForm'].resetFields()
- // })
- // }).then(() => {
- // if (this.dataForm.id) {
- // this.$http({
- // url: this.$http.adornUrl(`/sys/user/info/${this.dataForm.id}`),
- // method: 'get',
- // params: this.$http.adornParams()
- // }).then(({data}) => {
- // if (data && data.code === 0) {
- // this.dataForm.userName = data.user.username
- // this.dataForm.salt = data.user.salt
- // this.dataForm.email = data.user.email
- // this.dataForm.mobile = data.user.mobile
- // this.dataForm.roleIdList = data.user.roleIdList
- // this.dataForm.status = data.user.status
- // }
- // })
- // }
- // })
- },
- // 表单提交
- dataFormSubmit () {
- this.$refs['dataForm'].validate((valid) => {
- if (valid) {
- this.$http({
- url: this.$http.adornUrl(`/sys/job/${!this.dataForm.id ? 'save' : 'update'}`),
- method: 'post',
- data: this.$http.adornData({
- 'id': this.dataForm.id || undefined,
- 'jobCode': this.dataForm.jobCode,
- 'jobName': this.dataForm.jobName
- })
- }).then(({data}) => {
- if (data && data.code === 0) {
- this.visible = false
- this.$emit('refreshDataList')
- this.$message({
- message: '操作成功',
- type: 'success',
- duration: 1500,
- // onClose: () => {
- // this.visible = false
- // this.$emit('refreshDataList')
- // }
- })
- } else {
- this.$message.error(data.msg)
- }
- })
- }
- })
- }
- }
- }
- </script>
|