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.

91 lines
1.7 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
  1. <script setup lang="ts">
  2. import { add, update } from 'apis/matrix'
  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. name: [
  21. { required: true, message: '请输入基质名称', trigger: 'blur' },
  22. ],
  23. }
  24. const formRef = ref()
  25. const okLoading = ref(false)
  26. const okHandle = () => {
  27. formRef.value.validate(async (valid: any) => {
  28. if (!valid) {
  29. return
  30. }
  31. okLoading.value = true
  32. // TODO 调用保存接口
  33. if (form.value.id) {
  34. await update(form.value)
  35. }
  36. else {
  37. await add(form.value)
  38. }
  39. setTimeout(() => {
  40. okLoading.value = false
  41. FtMessage.success('保存成功')
  42. emits('ok')
  43. }, 300)
  44. })
  45. }
  46. const cancel = () => {
  47. emits('cancel')
  48. }
  49. </script>
  50. <template>
  51. <FtDialog visible :title="form.id ? '编辑工艺' : '新增工艺'" width="40%" @ok="okHandle" @cancel="cancel">
  52. <el-form ref="formRef" label-width="120" :model="form" :rules="rules">
  53. <el-form-item label="工艺名称">
  54. <el-input v-model="form.name" placeholder="" />
  55. </el-form-item>
  56. </el-form>
  57. </FtDialog>
  58. </template>
  59. <style scoped lang="scss">
  60. .el-select {
  61. width: 80%;
  62. }
  63. .el-input {
  64. width: 80%;
  65. }
  66. .unit-text {
  67. font-size: 40px;
  68. color: #0349A8;
  69. font-weight: 500;
  70. margin-left: 20px;
  71. }
  72. .select-box {
  73. display: flex;
  74. margin: 40px;
  75. }
  76. .route-img {
  77. display: flex;
  78. img {
  79. width: 70px;
  80. }
  81. }
  82. </style>