123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <template>
- <div id="detail">
- <van-row>
- <van-col span="24" class="main animate__animated animate__backInRight">
- <van-col span="24" class="one">
- <van-form @submit="toSave" label-width="2em">
- <van-cell-group>
- <van-field
- v-model="form.title"
- name="title"
- type="textarea"
- rows="1"
- autosize
- label="标题"
- placeholder="请输入文件标题"
- :rules="[{ required: true, message: '请输入文件标题' }]"
- />
- <van-field name="file" label="文件">
- <template #input>
- <vUpload :file="form.file"></vUpload>
- </template>
- </van-field>
- <van-field name="files" label="文件2">
- <template #input>
- <vUpload :file="form.files"></vUpload>
- </template>
- </van-field>
- </van-cell-group>
- <div class="btn">
- <van-button type="primary" size="small" native-type="submit"> 提交保存 </van-button>
- </div>
- </van-form>
- </van-col>
- </van-col>
- </van-row>
- </div>
- </template>
- <script setup lang="ts">
- // 基础
- import type { Ref } from 'vue';
- // reactive, ref, onMounted
- import { onMounted, ref } from 'vue';
- import { useRoute } from 'vue-router';
- import { showToast } from 'vant';
- // 接口
- import { PolicyfileStore } from '@common/src/stores/basic/policyfile';
- import type { IQueryResult } from '@/util/types.util';
- const polAxios = PolicyfileStore();
- // 路由
- const route = useRoute();
- const id: Ref<any> = ref('');
- // 表单
- const form: Ref<any> = ref({ file: [], files: [] });
- // 请求
- onMounted(async () => {
- id.value = route.query.id;
- await search();
- });
- const search = async () => {
- if (id.value) {
- let res: IQueryResult = await polAxios.fetch(id.value);
- if (res.errcode == '0') {
- form.value = res.data;
- }
- }
- };
- // 保存
- const toSave = async (e) => {
- let res: IQueryResult;
- console.log(e);
- // if (id.value) res = await polAxios.update({ ...e, _id: id.value });
- // else res = await polAxios.create(e);
- // if (res.errcode == '0') {
- // showToast({ message: '信息删除成功', type: 'success', duration: 500 });
- // toBack();
- // } else {
- // showToast({ message: `${res.errmsg}`, type: 'fail', duration: 500 });
- // }
- };
- // 返回;
- const toBack = () => {
- window.history.go(-1);
- };
- </script>
- <style scoped lang="scss">
- .main {
- .one {
- .btn {
- text-align: center;
- margin: 10px 0;
- }
- }
- }
- </style>
|