addModel.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <a-button type="primary" @click="handleClick" style="margin-left: 10px">
  3. <template #icon>
  4. <icon-plus />
  5. </template>
  6. </a-button>
  7. <a-modal v-model:visible="visible" title="添加模式"
  8. @before-open="handleOpened"
  9. @cancel="handleCancel"
  10. :footer="false"
  11. title-align="start"
  12. width="600px"
  13. >
  14. <a-form ref="formRef" :rules="rules" :model="form" @submit="handleSubmit" :style="{width:'90%',margin:'0 auto'}" layout="vertical" >
  15. <a-form-item field="name" label="模型类型">
  16. <a-select v-model="form.section" placeholder="请选择">
  17. <a-option value="section one">Section One</a-option>
  18. <a-option value="section two">Section Two</a-option>
  19. <a-option value="section three">Section Three</a-option>
  20. </a-select>
  21. </a-form-item>
  22. <a-form-item field="name" label="模型名称">
  23. <a-input v-model="form.name" placeholder="请输入名称"/>
  24. </a-form-item>
  25. <a-form-item field="section" label="模型图片">
  26. <a-space direction="vertical" :style="{ width: '100%' }">
  27. <a-upload
  28. action="/"
  29. :fileList="file ? [file] : []"
  30. :show-file-list="false"
  31. @change="onChange"
  32. @progress="onProgress"
  33. >
  34. <template #upload-button>
  35. <div
  36. :class="`arco-upload-list-item${
  37. file && file.status === 'error' ? ' arco-upload-list-item-error' : ''
  38. }`"
  39. >
  40. <div
  41. class="arco-upload-list-picture custom-upload-avatar"
  42. v-if="file && file.url"
  43. >
  44. <img :src="file.url" />
  45. <div class="arco-upload-list-picture-mask">
  46. <IconEdit />
  47. </div>
  48. <a-progress
  49. v-if="file.status === 'uploading' && file.percent < 100"
  50. :percent="file.percent"
  51. type="circle"
  52. size="mini"
  53. :style="{
  54. position: 'absolute',
  55. left: '50%',
  56. top: '50%',
  57. transform: 'translateX(-50%) translateY(-50%)',
  58. }"
  59. />
  60. </div>
  61. <div class="arco-upload-picture-card" v-else>
  62. <div class="arco-upload-picture-card-text">
  63. <IconPlus />
  64. <div style="margin-top: 10px; font-weight: 600">上传</div>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. </a-upload>
  70. </a-space>
  71. </a-form-item>
  72. <a-form-item field="name" label="基础Url">
  73. <a-input v-model="form.name" placeholder="请输入名称"/>
  74. </a-form-item>
  75. <a-form-item field="raptor" label="是否支持 Vision">
  76. <a-switch v-model="form.raptor" />
  77. </a-form-item>
  78. <a-form-item>
  79. <div style="width: 100%;text-align: right">
  80. <a-button @click="visible = false">取消</a-button>
  81. <a-button style="margin-left: 10px" type="primary" html-type="submit">确定</a-button>
  82. </div>
  83. </a-form-item>
  84. </a-form>
  85. </a-modal>
  86. </template>
  87. <script lang="ts" setup>
  88. import { onMounted ,onBeforeMount, reactive, ref } from "vue";
  89. const visible = ref(false);
  90. const loading = ref(false);
  91. const form = reactive({
  92. size: "medium",
  93. name: "",
  94. age: undefined,
  95. section: "0",
  96. province: "haidian",
  97. options: [],
  98. date: "",
  99. time: "",
  100. radio: "radio one",
  101. slider: 5,
  102. score: 5,
  103. switch: false,
  104. multiSelect: ["section one"],
  105. treeSelect: "",
  106. raptor: false,
  107. prompt: '请总结以下段落。 小心数字,不要编造。 段落如下:\n' +
  108. ' {cluster_content}\n' +
  109. '以上就是你需要总结的内容。',
  110. });
  111. const formRef = ref(null);
  112. const rules = {
  113. name: [
  114. {
  115. required: true,
  116. message:'名称不允许为空',
  117. },
  118. ],
  119. }
  120. const handleSubmit = ({values, errors}) => {
  121. console.log('values:', values, '\nerrors:', errors)
  122. }
  123. const handleClick = () => {
  124. visible.value = true;
  125. };
  126. const handleBeforeOk = (done) => {
  127. formRef.value.validate().then(res => {
  128. console.log('form:', form)
  129. if (!form.name) {
  130. done(false)
  131. }else {
  132. console.log('请求数据');
  133. }
  134. })
  135. };
  136. const handleCancel = () => {
  137. visible.value = false;
  138. }
  139. const handleOpened =(el) => {
  140. Object.assign(form,{
  141. name: '',// 用户名
  142. nameJoin: '',// 昵称
  143. post: '',// 岗位
  144. txt: '',// 备注
  145. });
  146. formRef.value.resetFields();
  147. }
  148. const file = ref();
  149. const onChange = (_, currentFile) => {
  150. file.value = {
  151. ...currentFile,
  152. // url: URL.createObjectURL(currentFile.file),
  153. };
  154. };
  155. const onProgress = (currentFile) => {
  156. file.value = currentFile;
  157. };
  158. onBeforeMount(()=>{
  159. })
  160. onMounted(()=>{
  161. })
  162. </script>
  163. <script lang="ts">
  164. export default {
  165. name: 'add',
  166. methods: {
  167. }
  168. };
  169. </script>