Browse Source

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

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

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

@ -38,140 +38,116 @@
</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: '',
propertyName: '',
propertyTel: '',
propertyManager: '',
propertyAddress: '',
revision: '',
delFlag: '',
parentDeptIds: '',
parentDeptNames: '',
allDeptIds: '',
allDeptNames: ''
},
options: []
}
},
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'}
],
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: {
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/getDeptAuthByUser`)
.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;
})
},
handleChange(value) {
this.dataForm.gridId = value.slice(-1).shift();
},
//
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: '',
propertyName: '',
propertyTel: '',
propertyManager: '',
propertyAddress: ''
},
options: []
}
},
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.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.getInfo()
}
})
},
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
})
},
handleChange (value) {
this.dataForm.gridId = value.slice(-1).shift()
},
//
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>

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

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

Loading…
Cancel
Save