Showing
3 changed files
with
127 additions
and
1 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-06-17 14:54:29 | 2 | * @Date: 2022-06-17 14:54:29 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-11-17 10:41:39 | 4 | + * @LastEditTime: 2022-11-17 14:42:30 |
| 5 | * @FilePath: /data-table/src/api/form.js | 5 | * @FilePath: /data-table/src/api/form.js |
| 6 | * @Description: 表单接口 | 6 | * @Description: 表单接口 |
| 7 | */ | 7 | */ |
| 8 | import { fn, fetch } from '@/api/fn'; | 8 | import { fn, fetch } from '@/api/fn'; |
| 9 | 9 | ||
| 10 | const Api = { | 10 | const Api = { |
| 11 | + FORM_ADD: '/srv/?a=add_form', | ||
| 11 | FORM_QUERY: '/srv/?a=query_form', | 12 | FORM_QUERY: '/srv/?a=query_form', |
| 12 | } | 13 | } |
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * @description: 新增表单 | ||
| 17 | + * @param: client_id 主体客户id | ||
| 18 | + * @param: name 表单名称 | ||
| 19 | + * @param: note 表单描述 | ||
| 20 | + */ | ||
| 21 | +export const addFormAPI = (params) => fn(fetch.post(Api.FORM_ADD, params)); | ||
| 22 | + | ||
| 13 | /** | 23 | /** |
| 14 | * @description: 查询表单 | 24 | * @description: 查询表单 |
| 15 | * @param: client_id 主体客户id | 25 | * @param: client_id 主体客户id | ... | ... |
src/router/routes/modules/setForm/index.js
0 → 100644
| 1 | +/* | ||
| 2 | + * @Date: 2022-11-17 14:46:43 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-11-17 14:47:46 | ||
| 5 | + * @FilePath: /data-table/src/router/routes/modules/setForm/index.js | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | + */ | ||
| 8 | +const index = [{ | ||
| 9 | + path: '/addForm', | ||
| 10 | + name: '首页', | ||
| 11 | + component: () => import('@/views/setForm/addForm.vue'), | ||
| 12 | + meta: { | ||
| 13 | + title: '新增表单', | ||
| 14 | + name: 'addFormPage' | ||
| 15 | + }, | ||
| 16 | + children: [] | ||
| 17 | +}] | ||
| 18 | + | ||
| 19 | +export default index; |
src/views/setForm/addForm.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + * @Date: 2022-11-17 14:38:04 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-11-17 15:42:23 | ||
| 5 | + * @FilePath: /data-table/src/views/setForm/addForm.vue | ||
| 6 | + * @Description: 添加表单 | ||
| 7 | +--> | ||
| 8 | +<template> | ||
| 9 | + <div class="add-form"> | ||
| 10 | + <van-nav-bar title="添加表单" /> | ||
| 11 | + <van-form @submit="onSubmit" style="margin-top: 1rem"> | ||
| 12 | + <van-cell-group inset> | ||
| 13 | + <van-field | ||
| 14 | + v-model="client" | ||
| 15 | + name="client" | ||
| 16 | + is-link | ||
| 17 | + readonly | ||
| 18 | + label="主体客户" | ||
| 19 | + placeholder="主体客户" | ||
| 20 | + @click="showPicker = true" | ||
| 21 | + required | ||
| 22 | + :rules="[{ required: true, message: '请填写主体客户' }]" | ||
| 23 | + /> | ||
| 24 | + <van-field | ||
| 25 | + v-model="name" | ||
| 26 | + name="name" | ||
| 27 | + label="表单名称" | ||
| 28 | + placeholder="表单名称" | ||
| 29 | + required | ||
| 30 | + :rules="[{ required: true, message: '请填写表单名称' }]" | ||
| 31 | + /> | ||
| 32 | + <van-field v-model="note" name="note" label="表单描述" placeholder="表单描述" /> | ||
| 33 | + </van-cell-group> | ||
| 34 | + <div style="margin: 16px"> | ||
| 35 | + <van-button round block type="primary" native-type="submit">确认</van-button> | ||
| 36 | + </div> | ||
| 37 | + </van-form> | ||
| 38 | + </div> | ||
| 39 | + | ||
| 40 | + <van-popup v-model:show="showPicker" round position="bottom"> | ||
| 41 | + <van-picker :columns="columns" @cancel="showPicker = false" @confirm="onConfirm" /> | ||
| 42 | + </van-popup> | ||
| 43 | +</template> | ||
| 44 | + | ||
| 45 | +<script setup> | ||
| 46 | +import { ref } from "vue"; | ||
| 47 | +import { useRoute, useRouter } from "vue-router"; | ||
| 48 | +import { addFormAPI } from "@/api/form.js"; | ||
| 49 | +import { showSuccessToast, showFailToast } from "vant"; | ||
| 50 | +import { | ||
| 51 | + Cookies, | ||
| 52 | + $, | ||
| 53 | + _, | ||
| 54 | + axios, | ||
| 55 | + storeToRefs, | ||
| 56 | + mainStore, | ||
| 57 | + Toast, | ||
| 58 | + useTitle, | ||
| 59 | +} from "@/utils/generatePackage.js"; | ||
| 60 | +//import { } from '@/utils/generateModules.js' | ||
| 61 | +//import { } from '@/utils/generateIcons.js' | ||
| 62 | +//import { } from '@/composables' | ||
| 63 | +const $route = useRoute(); | ||
| 64 | +const $router = useRouter(); | ||
| 65 | +useTitle($route.meta.title); | ||
| 66 | + | ||
| 67 | +const client = ref(""); | ||
| 68 | +const client_id = ref(""); | ||
| 69 | +const name = ref(""); | ||
| 70 | +const note = ref(""); | ||
| 71 | + | ||
| 72 | +const columns = [ | ||
| 73 | + { text: "弥陀", value: 120463 }, | ||
| 74 | + { text: "观宗", value: 81661 }, | ||
| 75 | +]; | ||
| 76 | +const result = ref(""); | ||
| 77 | +const showPicker = ref(false); | ||
| 78 | + | ||
| 79 | +const onConfirm = ({ selectedOptions }) => { | ||
| 80 | + showPicker.value = false; | ||
| 81 | + client.value = selectedOptions[0].text; | ||
| 82 | + client_id.value = selectedOptions[0].value; | ||
| 83 | +}; | ||
| 84 | + | ||
| 85 | +const onSubmit = async (values) => { | ||
| 86 | + const result = await addFormAPI({ | ||
| 87 | + client_id: client_id.value, | ||
| 88 | + name: values.name, | ||
| 89 | + note: values.note, | ||
| 90 | + }); | ||
| 91 | + if (result.code) { | ||
| 92 | + showSuccessToast("新增成功"); | ||
| 93 | + } | ||
| 94 | +}; | ||
| 95 | +</script> | ||
| 96 | + | ||
| 97 | +<style lang="less" scoped></style> |
-
Please register or login to post a comment