settingForm.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div class="setting-form">
  3. <div class="setting-form__wrapper">
  4. <FormTitle icon="gas-pump" title="工作面参数" />
  5. <BasicForm :model="model" :schemas="workSurfaceFormSchema" @register="regWSForm" @submit="submitHandler">
  6. <template #input="{ model: m, field, schema }">
  7. <ListItem class="w-100%" v-model:value="m[field]" type="input" :label="schema.label" bordered :label-width="200" />
  8. </template>
  9. </BasicForm>
  10. </div>
  11. <div class="setting-form__wrapper">
  12. <FormTitle icon="pump" title="抽采单元参数" />
  13. <BasicForm :model="model" :schemas="extractionUnitFormSchema" @register="regEUForm" @submit="submitHandler">
  14. <template #input="{ model: m, field, schema }">
  15. <ListItem class="w-100%" v-model:value="m[field]" type="input" :label="schema.label" bordered :label-width="200" />
  16. </template>
  17. </BasicForm>
  18. </div>
  19. <div class="setting-form__wrapper">
  20. <FormTitle icon="water-pump" title="计算参数" />
  21. <BasicForm :model="model" :schemas="calculationFormSchema" @register="regCCForm" @submit="submitHandler">
  22. <!-- <template #radio="{ model: m, field, schema }">
  23. <ListItem class="w-100%">
  24. <template #label>
  25. <Switch v-model:checked="m[field]" size="small" />
  26. <span class="ml-10px">{{ schema.label }}</span>
  27. </template>
  28. </ListItem>
  29. </template> -->
  30. <template #input="{ model: m, field, schema }">
  31. <ListItem class="w-100%" v-model:value="m[field]" type="input" :label="schema.label" bordered :label-width="200" />
  32. </template>
  33. </BasicForm>
  34. </div>
  35. <div class="text-right">
  36. <!-- <Button class="mr-10px setting-form__button" type="primary" ghost @click="cancel">取消</Button> -->
  37. <Button class="mr-10px setting-form__button" type="primary" ghost @click="calculate">计算</Button>
  38. <Button class="mr-10px setting-form__button" type="primary" ghost @click="submit">提交</Button>
  39. </div>
  40. </div>
  41. </template>
  42. <script lang="ts" setup>
  43. import { Button } from 'ant-design-vue';
  44. import ListItem from '@/views/vent/gas/components/list/listItem.vue';
  45. import FormTitle from '@/views/vent/gas/components/form/formTitle.vue';
  46. import { useForm, BasicForm } from '/@/components/Form';
  47. import { workSurfaceFormSchema, extractionUnitFormSchema, calculationFormSchema } from '../gasPumpSetting.data';
  48. import { ref } from 'vue';
  49. const props = defineProps<{ model: Record<string, any> }>();
  50. const emit = defineEmits(['submit', 'calculate', 'cancel']);
  51. const defaultFormProp = {
  52. //注册表单列
  53. showActionButtonGroup: false,
  54. labelCol: { span: 0 },
  55. wrapperCol: { span: 24 },
  56. baseColProps: {
  57. flex: '16.6667%',
  58. },
  59. };
  60. const formData = ref<Record<string, any>>({});
  61. const [regWSForm, { submit: submitWSForm }] = useForm(defaultFormProp);
  62. const [regEUForm, { submit: submitEUForm }] = useForm(defaultFormProp);
  63. const [regCCForm, { submit: submitCCForm }] = useForm(defaultFormProp);
  64. function submitHandler(v) {
  65. formData.value = {
  66. ...formData.value,
  67. ...v,
  68. };
  69. }
  70. // function cancel() {
  71. // emit('cancel');
  72. // }
  73. function calculate() {
  74. Promise.all([submitWSForm(), submitEUForm()]).then(() => {
  75. emit('calculate', { ...props.model, ...formData.value });
  76. });
  77. }
  78. function submit() {
  79. Promise.all([submitWSForm(), submitEUForm(), submitCCForm()]).then(() => {
  80. emit('submit', { ...props.model, ...formData.value });
  81. });
  82. }
  83. </script>
  84. <style lang="less" scoped>
  85. @import '@/design/vent/color.less';
  86. .setting-form {
  87. padding: 0 20px;
  88. }
  89. .setting-form__wrapper {
  90. color: #fff;
  91. border-top: 3px solid @vent-gas-primary-text;
  92. background-color: @vent-gas-primary-trasparent-bg;
  93. padding: 10px 10px 0 10px;
  94. margin-bottom: 10px;
  95. }
  96. .setting-form__button {
  97. color: @vent-gas-primary-text;
  98. border-color: @vent-gas-primary-text;
  99. background-color: transparent !important;
  100. }
  101. </style>