You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.3 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <script setup lang="ts">
  2. import { add, update } from 'apis/point'
  3. import FtDialog from 'components/common/FTDialog/index.vue'
  4. import { FtMessage } from 'libs/message'
  5. import { onMounted, ref } from 'vue'
  6. const props = defineProps({
  7. formData: {
  8. type: Object,
  9. default: () => ({}),
  10. },
  11. })
  12. const emits = defineEmits(['ok', 'cancel'])
  13. onMounted(() => {
  14. if (props.formData.id) {
  15. form.value = { ...props.formData }
  16. }
  17. })
  18. const form = ref({})
  19. const rules = {
  20. pointName: [{ required: true, message: '请输入坐标名称', trigger: 'blur' }],
  21. x: [{ required: true, message: '请输入x', trigger: 'blur' }],
  22. y: [{ required: true, message: '请输入y', trigger: 'blur' }],
  23. z: [{ required: true, message: '请输入z', trigger: 'blur' }],
  24. }
  25. const formRef = ref()
  26. const okLoading = ref(false)
  27. const okHandle = () => {
  28. formRef.value.validate(async (valid: any) => {
  29. if (!valid) {
  30. return
  31. }
  32. okLoading.value = true
  33. // TODO 调用保存接口
  34. if (form.value.id) {
  35. await update(form.value)
  36. }
  37. else {
  38. await add(form.value)
  39. }
  40. setTimeout(() => {
  41. okLoading.value = false
  42. FtMessage.success('保存成功')
  43. emits('ok')
  44. }, 300)
  45. })
  46. }
  47. const cancel = () => {
  48. emits('cancel')
  49. }
  50. </script>
  51. <template>
  52. <FtDialog visible :title="form.id ? '编辑坐标' : '新增坐标'" width="40%" @ok="okHandle" @cancel="cancel">
  53. <el-form ref="formRef" label-width="120" :model="form" :rules="rules">
  54. <el-form-item label="坐标名称" prop="pointName">
  55. <el-input v-model="form.pointName" placeholder="" />
  56. </el-form-item>
  57. <el-form-item label="x" prop="x">
  58. <el-input v-model="form.x" type="number" placeholder="" />
  59. </el-form-item>
  60. <el-form-item label="y" prop="y">
  61. <el-input v-model="form.y" type="number" placeholder="" />
  62. </el-form-item>
  63. <el-form-item label="z" prop="z">
  64. <el-input v-model="form.z" type="number" placeholder="" />
  65. </el-form-item>
  66. </el-form>
  67. </FtDialog>
  68. </template>
  69. <style scoped lang="scss">
  70. .el-select {
  71. width: 80%;
  72. }
  73. .el-input {
  74. width: 80%;
  75. }
  76. .unit-text {
  77. font-size: 40px;
  78. color: #0349A8;
  79. font-weight: 500;
  80. margin-left: 20px;
  81. }
  82. .select-box {
  83. display: flex;
  84. margin: 40px;
  85. }
  86. .route-img {
  87. display: flex;
  88. img {
  89. width: 70px;
  90. }
  91. }
  92. </style>