index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <el-dialog :title="title" :visible.sync="dialogVisible" width="45%" @close="handleClose" id="messageDialog">
  3. <el-row>
  4. <formItems :type="'Floor'" ref="formItems"></formItems>
  5. </el-row>
  6. <span slot="footer" class="dialog-footer">
  7. <el-button size="small" @click="dialogVisible=false">取消</el-button>
  8. <el-button size="small" type="primary" @click="confirm">确认</el-button>
  9. </span>
  10. </el-dialog>
  11. </template>
  12. <script>
  13. import {manageCreateFloor, manageUpdateFloor} from "@/api/scan/request";
  14. import formItems from "@/components/ready/buildfloor/formItems";
  15. import tools from "@/utils/buildfloor/tools";
  16. export default {
  17. props: {
  18. title: {
  19. default: '提示'
  20. },
  21. type: {
  22. default: 'Floor'
  23. },
  24. curBuildId: {
  25. default: ''
  26. },
  27. curFloorId: {
  28. default: ''
  29. }
  30. },
  31. components: {
  32. formItems
  33. },
  34. data() {
  35. return {
  36. dialogVisible: false, //弹窗显示与隐藏
  37. floorData: {}
  38. };
  39. },
  40. methods: {
  41. showDialog(data) {
  42. this.floorData = data || {};
  43. this.floorData = tools.desFormatData(this.floorData)
  44. this.timeoutSetVal()
  45. this.dialogVisible = true;
  46. },
  47. timeoutSetVal() {
  48. setTimeout(() => {
  49. if (this.$refs.formItems) {
  50. this.$refs.formItems.form = this.floorData
  51. } else {
  52. this.timeoutSetVal()
  53. }
  54. }, 500)
  55. },
  56. handleClose() { },
  57. //创建
  58. confirm() {
  59. this.$refs.formItems.submitForm(this.save)
  60. },
  61. save() {
  62. let form = this.$refs.formItems.form
  63. let newform = tools.formatData(form)
  64. newform.BuildID = this.curBuildId
  65. let Param = {
  66. Content: [newform]
  67. }
  68. if (newform.FloorID) {
  69. manageUpdateFloor(Param, res => {
  70. this.$message.success('更新成功')
  71. this.$emit('refresh')
  72. this.dialogVisible = false;
  73. })
  74. } else {
  75. manageCreateFloor(Param, res => {
  76. this.$message.success('创建成功')
  77. this.$emit('refresh')
  78. this.dialogVisible = false;
  79. })
  80. }
  81. }
  82. },
  83. mounted() { },
  84. created() { }
  85. };
  86. </script>
  87. <style lang="scss" scoped>
  88. #messageDialog {
  89. /deep/ .el-dialog__body {
  90. height: 420px;
  91. overflow: auto;
  92. }
  93. .el-form-item {
  94. /deep/ label.el-form-item__label {
  95. font-size: 12px;
  96. }
  97. }
  98. /deep/ .FloorTypeSelect .el-form-item__content {
  99. width: 200px;
  100. }
  101. }
  102. </style>