|
|
@ -45,138 +45,138 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import debounce from 'lodash/debounce' |
|
|
|
import debounce from 'lodash/debounce' |
|
|
|
|
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
visible: false, |
|
|
|
loading: true, |
|
|
|
dataForm: { |
|
|
|
id: '', |
|
|
|
gridId: '', |
|
|
|
grid: '', |
|
|
|
projectName: '', |
|
|
|
propertyId: '', |
|
|
|
propertyName: '', |
|
|
|
propertyTel: '', |
|
|
|
propertyManager: '', |
|
|
|
propertyAddress: '' |
|
|
|
}, |
|
|
|
options: [], |
|
|
|
propertyList: [] |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
dataRule() { |
|
|
|
return { |
|
|
|
projectName: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
propertyName: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
propertyTel: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
propertyManager: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
], |
|
|
|
propertyAddress: [ |
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
init() { |
|
|
|
// 获取下拉菜单 |
|
|
|
this.getByLoginUser(); |
|
|
|
this.getPropertyList(); |
|
|
|
this.visible = true; |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs['dataForm'].resetFields(); |
|
|
|
if (this.dataForm.id) { |
|
|
|
this.getInfo() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 获取用物业列表 |
|
|
|
getPropertyList() { |
|
|
|
this.$http.get(`/property/property/dict`).then(({data: res}) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
} |
|
|
|
this.propertyList = res.data |
|
|
|
}).catch(() => { |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 获取网格 |
|
|
|
getByLoginUser() { |
|
|
|
this.$http |
|
|
|
.get(`/sys/user/deptOptions/getBusinessDeptByUser`) |
|
|
|
.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 |
|
|
|
}) |
|
|
|
}, |
|
|
|
deptHandleChange(value) { |
|
|
|
this.dataForm.gridId = value.slice(-1).shift(); |
|
|
|
}, |
|
|
|
propertyHandleChange(value) { |
|
|
|
console.log(value) |
|
|
|
let obj = this.propertyList.find((item) => { |
|
|
|
return item.dictValue === value; |
|
|
|
}); |
|
|
|
console.log(obj.dictName) |
|
|
|
this.dataForm.propertyName = obj.dictName; |
|
|
|
}, |
|
|
|
// 获取信息 |
|
|
|
getInfo() { |
|
|
|
this.$http.get(`/property/project/${this.dataForm.id}`).then(({data: res}) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
} |
|
|
|
this.dataForm = { |
|
|
|
...this.dataForm, |
|
|
|
...res.data |
|
|
|
} |
|
|
|
this.dataForm.allDeptIds = res.data.allDeptIds.split(',').slice(1) |
|
|
|
this.loading = false |
|
|
|
}).catch(() => { |
|
|
|
this.loading = false |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 表单提交 |
|
|
|
dataFormSubmitHandle: debounce(function () { |
|
|
|
this.dataForm.allDeptNames = this.$refs['grid'].inputValue; |
|
|
|
this.$refs['dataForm'].validate((valid) => { |
|
|
|
if (!valid) { |
|
|
|
return false |
|
|
|
} |
|
|
|
this.$http[!this.dataForm.id ? 'post' : 'put']('/property/project/', 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, |
|
|
|
loading: true, |
|
|
|
dataForm: { |
|
|
|
id: '', |
|
|
|
gridId: '', |
|
|
|
grid: '', |
|
|
|
projectName: '', |
|
|
|
propertyId: '', |
|
|
|
propertyName: '', |
|
|
|
propertyTel: '', |
|
|
|
propertyManager: '', |
|
|
|
propertyAddress: '' |
|
|
|
}, |
|
|
|
options: [], |
|
|
|
propertyList: [] |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
dataRule () { |
|
|
|
return { |
|
|
|
projectName: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
propertyName: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
propertyTel: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
propertyManager: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
propertyAddress: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
init () { |
|
|
|
// 获取下拉菜单 |
|
|
|
this.getByLoginUser() |
|
|
|
this.getPropertyList() |
|
|
|
this.visible = true |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs['dataForm'].resetFields() |
|
|
|
if (this.dataForm.id) { |
|
|
|
this.getInfo() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 获取用物业列表 |
|
|
|
getPropertyList () { |
|
|
|
this.$http.get(`/property/property/dict`).then(({ data: res }) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
} |
|
|
|
this.propertyList = res.data |
|
|
|
}).catch(() => { |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 获取网格 |
|
|
|
getByLoginUser () { |
|
|
|
this.$http |
|
|
|
.get(`/sys/user/deptOptions/getBusinessDeptByUser`) |
|
|
|
.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 |
|
|
|
}) |
|
|
|
}, |
|
|
|
deptHandleChange (value) { |
|
|
|
this.dataForm.gridId = value.slice(-1).shift() |
|
|
|
}, |
|
|
|
propertyHandleChange (value) { |
|
|
|
console.log(value) |
|
|
|
let obj = this.propertyList.find((item) => { |
|
|
|
return item.dictValue === value |
|
|
|
}) |
|
|
|
console.log(obj.dictName) |
|
|
|
this.dataForm.propertyName = obj.dictName |
|
|
|
}, |
|
|
|
// 获取信息 |
|
|
|
getInfo () { |
|
|
|
this.$http.get(`/property/project/${this.dataForm.id}`).then(({ data: res }) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
} |
|
|
|
this.dataForm = { |
|
|
|
...this.dataForm, |
|
|
|
...res.data |
|
|
|
} |
|
|
|
this.dataForm.allDeptIds = res.data.allDeptIds.split(',').slice(1) |
|
|
|
this.loading = false |
|
|
|
}).catch(() => { |
|
|
|
this.loading = false |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 表单提交 |
|
|
|
dataFormSubmitHandle: debounce(function () { |
|
|
|
this.dataForm.allDeptNames = this.$refs['grid'].inputValue |
|
|
|
this.$refs['dataForm'].validate((valid) => { |
|
|
|
if (!valid) { |
|
|
|
return false |
|
|
|
} |
|
|
|
this.$http[!this.dataForm.id ? 'post' : 'put']('/property/project/', 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> |
|
|
|