Browse Source

格式化代码与修改接口调用

feature/yujt_analysis_pc
yujt 5 years ago
parent
commit
6a9960f6ca
  1. 84
      src/views/modules/property/propertyproject-add-or-update.vue
  2. 34
      src/views/modules/property/propertyproject.vue

84
src/views/modules/property/propertyproject-add-or-update.vue

@ -38,10 +38,10 @@
</template> </template>
<script> <script>
import debounce from 'lodash/debounce' import debounce from 'lodash/debounce'
export default { export default {
data() { data () {
return { return {
visible: false, visible: false,
loading: true, loading: true,
@ -53,61 +53,37 @@
propertyName: '', propertyName: '',
propertyTel: '', propertyTel: '',
propertyManager: '', propertyManager: '',
propertyAddress: '', propertyAddress: ''
revision: '',
delFlag: '',
parentDeptIds: '',
parentDeptNames: '',
allDeptIds: '',
allDeptNames: ''
}, },
options: [] options: []
} }
}, },
computed: { computed: {
dataRule() { dataRule () {
return { return {
projectName: [ projectName: [
{required: true, message: this.$t('validate.required'), trigger: 'blur'} { required: true, message: this.$t('validate.required'), trigger: 'blur' }
], ],
propertyName: [ propertyName: [
{required: true, message: this.$t('validate.required'), trigger: 'blur'} { required: true, message: this.$t('validate.required'), trigger: 'blur' }
], ],
propertyTel: [ propertyTel: [
{required: true, message: this.$t('validate.required'), trigger: 'blur'} { required: true, message: this.$t('validate.required'), trigger: 'blur' }
], ],
propertyManager: [ propertyManager: [
{required: true, message: this.$t('validate.required'), trigger: 'blur'} { required: true, message: this.$t('validate.required'), trigger: 'blur' }
], ],
propertyAddress: [ propertyAddress: [
{required: true, message: this.$t('validate.required'), trigger: 'blur'} { required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
revision: [
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
],
delFlag: [
{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'}
],
allDeptIds: [
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
],
allDeptNames: [
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
] ]
} }
} }
}, },
methods: { methods: {
init() { init () {
// //
this.getByLoginUser(); this.getByLoginUser()
this.visible = true; this.visible = true
this.$nextTick(() => { this.$nextTick(() => {
this.$refs['dataForm'].resetFields() this.$refs['dataForm'].resetFields()
if (this.dataForm.id) { if (this.dataForm.id) {
@ -115,47 +91,47 @@
} }
}) })
}, },
getByLoginUser() { getByLoginUser () {
this.$http this.$http
.get(`/sys/user/deptOptions/getDeptAuthByUser`) .get(`/sys/user/deptOptions/getBusinessDeptByUser`)
.then(({data: res}) => { .then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
this.loading = false; this.loading = false
this.options = res.data.options this.options = res.data.options
}) })
.catch(() => { .catch(() => {
this.loading = false; this.loading = false
}) })
}, },
handleChange(value) { handleChange (value) {
this.dataForm.gridId = value.slice(-1).shift(); this.dataForm.gridId = value.slice(-1).shift()
}, },
// //
getInfo() { getInfo () {
this.$http.get(`/property/project/${this.dataForm.id}`).then(({data: res}) => { this.$http.get(`/property/project/${this.dataForm.id}`).then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
this.dataForm = { this.dataForm = {
...this.dataForm, ...this.dataForm,
...res.data ...res.data
}; }
this.dataForm.allDeptIds = res.data.allDeptIds.split(",").slice(1); this.dataForm.allDeptIds = res.data.allDeptIds.split(',').slice(1)
this.loading = false; this.loading = false
}).catch(() => { }).catch(() => {
this.loading = false; this.loading = false
}) })
}, },
// //
dataFormSubmitHandle: debounce(function () { dataFormSubmitHandle: debounce(function () {
this.dataForm.allDeptNames = this.$refs['grid'].inputValue; this.dataForm.allDeptNames = this.$refs['grid'].inputValue
this.$refs['dataForm'].validate((valid) => { this.$refs['dataForm'].validate((valid) => {
if (!valid) { if (!valid) {
return false return false
} }
this.$http[!this.dataForm.id ? 'post' : 'put']('/property/project/', this.dataForm).then(({data: res}) => { this.$http[!this.dataForm.id ? 'post' : 'put']('/property/project/', this.dataForm).then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
@ -171,7 +147,7 @@
}).catch(() => { }).catch(() => {
}) })
}) })
}, 1000, {'leading': true, 'trailing': false}) }, 1000, { 'leading': true, 'trailing': false })
}
} }
}
</script> </script>

34
src/views/modules/property/propertyproject.vue

@ -69,12 +69,12 @@
</template> </template>
<script> <script>
import mixinViewModule from '@/mixins/view-module' import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './propertyproject-add-or-update' import AddOrUpdate from './propertyproject-add-or-update'
export default { export default {
mixins: [mixinViewModule], mixins: [mixinViewModule],
data() { data () {
return { return {
mixinViewModuleOptions: { mixinViewModuleOptions: {
getDataListURL: '/property/project/page', getDataListURL: '/property/project/page',
@ -85,7 +85,7 @@
dataForm: { dataForm: {
id: '', id: '',
gridId: '', gridId: '',
projectName: '', projectName: ''
}, },
options: [], options: [],
deleteId: '' deleteId: ''
@ -94,15 +94,15 @@
components: { components: {
AddOrUpdate AddOrUpdate
}, },
mounted() { mounted () {
// //
this.getByLoginUser(); this.getByLoginUser()
}, },
methods: { methods: {
getByLoginUser() { getByLoginUser () {
this.$http this.$http
.get(`/sys/user/deptOptions/getDeptAuthByUser`) .get(`/sys/user/deptOptions/getBusinessDeptByUser`)
.then(({data: res}) => { .then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
@ -111,19 +111,19 @@
.catch(() => { .catch(() => {
}) })
}, },
handleChange(value) { handleChange (value) {
this.dataForm.gridId = value.slice(-1).shift(); this.dataForm.gridId = value.slice(-1).shift()
}, },
beforeDeleteHandle(id) { beforeDeleteHandle (id) {
this.$confirm("确定解散物业项目群?", this.$t('prompt.title'), { this.$confirm('删除物业项目将会解散物业项目群,是否继续操作?', this.$t('prompt.title'), {
confirmButtonText: this.$t('confirm'), confirmButtonText: this.$t('confirm'),
cancelButtonText: this.$t('cancel'), cancelButtonText: this.$t('cancel'),
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.deleteId = id; this.deleteId = id
this.deleteHandle(this.deleteId); this.deleteHandle(this.deleteId)
}) })
},
} }
} }
}
</script> </script>

Loading…
Cancel
Save