|
|
|
@ -47,179 +47,139 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import debounce from 'lodash/debounce' |
|
|
|
import Cookies from "js-cookie"; |
|
|
|
import debounce from 'lodash/debounce' |
|
|
|
import Cookies from 'js-cookie' |
|
|
|
|
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
visible: false, |
|
|
|
dataForm: { |
|
|
|
id: '', |
|
|
|
policeName: '', |
|
|
|
policeAvatar: '', |
|
|
|
policeTel: '', |
|
|
|
policeNo: '', |
|
|
|
deptName: '', |
|
|
|
deptId: '', |
|
|
|
displayFlag: '1', |
|
|
|
delFlag: '', |
|
|
|
revision: '', |
|
|
|
createdBy: '', |
|
|
|
createdTime: '', |
|
|
|
updatedBy: '', |
|
|
|
updatedTime: '', |
|
|
|
allDeptIds: '', |
|
|
|
allDeptNames: '', |
|
|
|
parentDeptIds: '', |
|
|
|
parentDeptNames: '' |
|
|
|
}, |
|
|
|
options: [], |
|
|
|
loading: false, |
|
|
|
uploadUrl: '', |
|
|
|
} |
|
|
|
}, |
|
|
|
created() { |
|
|
|
this.$nextTick(() => { |
|
|
|
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` |
|
|
|
}) |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
dataRule() { |
|
|
|
return { |
|
|
|
policeName: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
policeAvatar: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
policeTel: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
policeNo: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
deptName: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
deptId: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
displayFlag: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
delFlag: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
revision: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
createdBy: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
createdTime: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
updatedBy: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
updatedTime: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
allDeptIds: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
allDeptNames: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
parentDeptIds: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
parentDeptNames: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
init() { |
|
|
|
// 获取下拉菜单 |
|
|
|
this.getByLoginUser(); |
|
|
|
this.visible = true; |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs['dataForm'].resetFields() |
|
|
|
if (this.dataForm.id) { |
|
|
|
this.getInfo() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 获取部门 |
|
|
|
getByLoginUser() { |
|
|
|
this.$http |
|
|
|
.get(`/sys/user/deptOptions/getMiddleByLoginUser`) |
|
|
|
.then(({data: res}) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
} |
|
|
|
this.loading = false |
|
|
|
this.options = res.data.options |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
this.loading = false |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 获取信息 |
|
|
|
getInfo() { |
|
|
|
this.$http.get(`/property/police/${this.dataForm.id}`).then(({data: res}) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
} |
|
|
|
this.dataForm = { |
|
|
|
...this.dataForm, |
|
|
|
...res.data |
|
|
|
} |
|
|
|
}).catch(() => { |
|
|
|
}) |
|
|
|
}, |
|
|
|
deptHandleChange(value) { |
|
|
|
this.dataForm.deptId = value.slice(-1).shift(); |
|
|
|
}, |
|
|
|
handleAvatarActSuccess(res, file) { |
|
|
|
this.loading = false |
|
|
|
this.dataForm.policeAvatar = res.data.url |
|
|
|
}, |
|
|
|
beforeAvatarUpload(file) { |
|
|
|
this.loading = true |
|
|
|
}, |
|
|
|
handelError() { |
|
|
|
this.loading = false |
|
|
|
}, |
|
|
|
// 表单提交 |
|
|
|
dataFormSubmitHandle: debounce(function () { |
|
|
|
this.dataForm.deptName = this.$refs['grid'].inputValue; |
|
|
|
this.$refs['dataForm'].validate((valid) => { |
|
|
|
if (!valid) { |
|
|
|
return false |
|
|
|
} |
|
|
|
this.$http[!this.dataForm.id ? 'post' : 'put']('/property/police/', this.dataForm).then(({data: res}) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
} |
|
|
|
this.$message({ |
|
|
|
message: this.$t('prompt.success'), |
|
|
|
type: 'success', |
|
|
|
duration: 500, |
|
|
|
onClose: () => { |
|
|
|
this.visible = false |
|
|
|
this.$emit('refreshDataList') |
|
|
|
} |
|
|
|
}) |
|
|
|
}).catch(() => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, 1000, {'leading': true, 'trailing': false}) |
|
|
|
} |
|
|
|
export default { |
|
|
|
data () { |
|
|
|
return { |
|
|
|
visible: false, |
|
|
|
dataForm: { |
|
|
|
id: '', |
|
|
|
policeName: '', |
|
|
|
policeAvatar: '', |
|
|
|
policeTel: '', |
|
|
|
policeNo: '', |
|
|
|
deptName: '', |
|
|
|
deptId: '', |
|
|
|
displayFlag: '1' |
|
|
|
}, |
|
|
|
options: [], |
|
|
|
loading: false, |
|
|
|
uploadUrl: '' |
|
|
|
} |
|
|
|
}, |
|
|
|
created () { |
|
|
|
this.$nextTick(() => { |
|
|
|
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` |
|
|
|
}) |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
dataRule () { |
|
|
|
return { |
|
|
|
policeName: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
policeAvatar: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
policeTel: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
policeNo: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
deptName: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
deptId: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
displayFlag: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
init () { |
|
|
|
// 获取下拉菜单 |
|
|
|
this.getByLoginUser() |
|
|
|
this.visible = true |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs['dataForm'].resetFields() |
|
|
|
if (this.dataForm.id) { |
|
|
|
this.getInfo() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 获取部门 |
|
|
|
getByLoginUser () { |
|
|
|
this.$http |
|
|
|
.get(`/sys/user/deptOptions/getMiddleByLoginUser`) |
|
|
|
.then(({ data: res }) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
} |
|
|
|
this.loading = false |
|
|
|
this.options = res.data.options |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
this.loading = false |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 获取信息 |
|
|
|
getInfo () { |
|
|
|
this.$http.get(`/property/police/${this.dataForm.id}`).then(({ data: res }) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
} |
|
|
|
this.dataForm = { |
|
|
|
...this.dataForm, |
|
|
|
...res.data |
|
|
|
} |
|
|
|
}).catch(() => { |
|
|
|
}) |
|
|
|
}, |
|
|
|
deptHandleChange (value) { |
|
|
|
this.dataForm.deptId = value.slice(-1).shift() |
|
|
|
}, |
|
|
|
handleAvatarActSuccess (res, file) { |
|
|
|
this.loading = false |
|
|
|
this.dataForm.policeAvatar = res.data.url |
|
|
|
}, |
|
|
|
beforeAvatarUpload (file) { |
|
|
|
this.loading = true |
|
|
|
}, |
|
|
|
handelError () { |
|
|
|
this.loading = false |
|
|
|
}, |
|
|
|
// 表单提交 |
|
|
|
dataFormSubmitHandle: debounce(function () { |
|
|
|
this.dataForm.deptName = this.$refs['grid'].inputValue |
|
|
|
this.$refs['dataForm'].validate((valid) => { |
|
|
|
if (!valid) { |
|
|
|
return false |
|
|
|
} |
|
|
|
this.$http[!this.dataForm.id ? 'post' : 'put']('/property/police/', this.dataForm).then(({ data: res }) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
} |
|
|
|
this.$message({ |
|
|
|
message: this.$t('prompt.success'), |
|
|
|
type: 'success', |
|
|
|
duration: 500, |
|
|
|
onClose: () => { |
|
|
|
this.visible = false |
|
|
|
this.$emit('refreshDataList') |
|
|
|
} |
|
|
|
}) |
|
|
|
}).catch(() => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, 1000, { 'leading': true, 'trailing': false }) |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
<style scoped> |
|
|
|
.avatar-uploader .el-upload { |
|
|
|
@ -248,4 +208,4 @@ |
|
|
|
height: 178px; |
|
|
|
display: block; |
|
|
|
} |
|
|
|
</style> |
|
|
|
</style> |
|
|
|
|