departForm.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div class="hui-flex hui-dialog">
  3. <div class="hui-flex-box hui-dialog-content">
  4. <el-form :model="departmentForm" label-position="top">
  5. <el-form-item label="资产名称">
  6. <el-input type="text" v-model="departmentForm.name"></el-input>
  7. </el-form-item>
  8. <el-form-item label="资产描述">
  9. <el-input type="text" v-model="departmentForm.remark"></el-input>
  10. </el-form-item>
  11. </el-form>
  12. </div>
  13. <div class="hui-dialog-submit">
  14. <el-button size="medium" @click="$emit('callback')">取 消</el-button>
  15. <el-button size="medium" type="primary" @click="submit" :loading="loading">保 存</el-button>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import {
  21. insertDeviceDepartment,
  22. updateDeviceDepartment
  23. } from '@/httpApi/property'
  24. export default {
  25. props: ['isUpdate', 'part'],
  26. data() {
  27. return {
  28. departmentForm: {
  29. name: '',
  30. remark: '',
  31. operateOrganizationId: '',
  32. parentId: -1,
  33. isp: 0
  34. },
  35. departmentRuler: {},
  36. loading: false
  37. }
  38. },
  39. created() {
  40. if (this.isUpdate) {
  41. this.departmentForm = JSON.parse(JSON.stringify(this.part));
  42. } else {
  43. this.departmentForm['operateOrganizationId'] = this.$store.getters.organization.id;
  44. this.departmentForm['parentId'] = this.part.id || -1;
  45. this.departmentForm['projectId'] = this.$store.getters.project.id;
  46. }
  47. },
  48. methods: {
  49. submit() {
  50. this.loading = true;
  51. if (this.isUpdate) {
  52. updateDeviceDepartment(this.departmentForm).then(this.successFunc)
  53. } else {
  54. insertDeviceDepartment(this.departmentForm).then(this.successFunc)
  55. }
  56. },
  57. successFunc(res) {
  58. this.loading = false;
  59. if (res.state) {
  60. this.$message.success('操作成功');
  61. this.$emit('callback', 'init');
  62. }
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss"></style>