Handy_Cao 2 år sedan
förälder
incheckning
5bd2986e5a

+ 87 - 0
src/packages/pc/views/account/address/components/new/index.vue

@@ -0,0 +1,87 @@
+<!-- 账户管理-收货地址管理-编辑 -->
+<template>
+    <app-drawer title='新增地址' :width="880" v-model:show="show" :loading="loading"
+        :refresh="refresh">
+        <el-form ref="formRef" class="el-form--horizontal" label-width="100px" :model="formData" :rules="formRules">
+            <el-form-item label="收货人" prop="ReceiverName">
+                <el-input placeholder="请输入" v-model="formData.ReceiverName" />
+            </el-form-item>
+            <el-form-item label="证件类型" prop="CardTypeID">
+                <el-select v-model="formData.CardTypeID">
+                    <el-option :label="item.label" :value="item.value" v-for="(item, index) in certificateTypeList"
+                        :key="index" />
+                </el-select>
+            </el-form-item>
+            <el-form-item label="联系电话" prop="PhoneNum">
+                <el-input placeholder="请输入" v-model="formData.PhoneNum" />
+            </el-form-item>
+            <el-form-item label="证件号码" prop="CardNum">
+                <el-input placeholder="请输入" v-model="formData.CardNum" />
+            </el-form-item>
+            <el-form-item class="el-form-item--row" label="收货地址" prop="area">
+                <app-region class="el-form-item--col" v-model:province="formData.ProvinceID"
+                    v-model:city="formData.CityID" v-model:district="formData.DistrictID" />
+            </el-form-item>
+            <el-form-item class="el-form-item--row" prop="Address">
+                <el-input placeholder="请输入" v-model="formData.Address" />
+            </el-form-item>
+        </el-form>
+        <template #footer>
+            <el-button type="info" @click="onCancel(false)">取消</el-button>
+            <el-button type="primary" @click="onSubmit">提交</el-button>
+        </template>
+    </app-drawer>
+</template>
+
+<script lang="ts" setup>
+import { ref } from 'vue'
+import { ElMessage } from 'element-plus'
+import type { FormInstance, FormRules } from 'element-plus'
+import { useAddressForm } from '@/business/user/address'
+import AppDrawer from '@pc/components/base/drawer/index.vue'
+import AppRegion from '@pc/components/base/region/index.vue'
+
+const { loading, formData, certificateTypeList, addOrUpdate } = useAddressForm()
+const show = ref(true)
+const refresh = ref(false)
+const formRef = ref<FormInstance>()
+
+const formRules: FormRules = {
+    ReceiverName: [{ required: true, message: '请输入收货人', trigger: 'blur' }],
+    CardTypeID: [{ required: true, message: '请选择证件类型' }],
+    PhoneNum: [{ required: true, message: '请输入联系电话', trigger: 'blur' }],
+    CardNum: [{ required: true, message: '请输入证件号码', trigger: 'blur' }],
+    Address: [{ required: true, message: '请输入详细地址', trigger: 'blur' }],
+    area: [
+        {
+            required: true,
+            validator: (rule, value, callback) => {
+                const ids = [10, 18, 34] // 香港、台湾、澳门没有市区选择
+                if ((formData.ProvinceID && formData.CityID && formData.DistrictID) || ids.includes(formData.ProvinceID ?? 0)) {
+                    callback()
+                } else {
+                    callback(new Error('请选择收货地区'))
+                }
+            }
+        }
+    ],
+}
+
+const onCancel = (isRefresh = false) => {
+    show.value = false
+    refresh.value = isRefresh
+}
+
+const onSubmit = () => {
+    formRef.value?.validate((valid) => {
+        if (valid) {
+            addOrUpdate().then(() => {
+                ElMessage.success('提交成功')
+                onCancel(true)
+            }).catch((err) => {
+                ElMessage.error('提交失败:' + err)
+            })
+        }
+    })
+}
+</script>

+ 2 - 1
src/packages/pc/views/account/address/index.vue

@@ -45,6 +45,7 @@ const componentMap = new Map<string, unknown>([
     ['edit', defineAsyncComponent(() => import('./components/edit/index.vue'))],
     ['default', defineAsyncComponent(() => import('./components/default/index.vue'))],
     ['delete', defineAsyncComponent(() => import('./components/delete/index.vue'))],
+    ['new', defineAsyncComponent(() => import('./components/new/index.vue'))],
 ])
 
 const { rowKey, expandKeys, selectedRow, rowClick } = useComposeTable<Model.UserReceiveInfoRsp>({ rowKey: 'autoid' })
@@ -65,6 +66,6 @@ const tableColumns = shallowRef<Model.TableColumn[]>([
 ])
 
 filterOptons.buttonList = [
-    { lable: '新增地址', className: 'el-button--primary', onClick: () => openComponent('edit') },
+    { lable: '新增地址', className: 'el-button--primary', onClick: () => openComponent('new') },
 ]
 </script>

+ 75 - 0
src/packages/pc/views/account/receipt/components/new/index.vue

@@ -0,0 +1,75 @@
+<!-- 账户管理-发票信息管理-编辑 -->
+<template>
+    <app-drawer title='新增发票' :width="460" v-model:show="show" :loading="loading"
+        :refresh="refresh">
+        <el-form ref="formRef" class="el-form--vertical" label-width="100px" :model="formData" :rules="formRules">
+            <el-form-item label="发票类型" prop="ReceiptType">
+                <el-radio-group v-model="formData.ReceiptType">
+                    <el-radio :label="1">个人</el-radio>
+                    <el-radio :label="2">企业</el-radio>
+                </el-radio-group>
+            </el-form-item>
+            <el-form-item label="发票抬头" prop="UserName">
+                <el-input placeholder="请输入" v-model="formData.UserName" />
+            </el-form-item>
+            <template v-if="formData.ReceiptType === 2">
+                <el-form-item label="税号" prop="TaxpayerID">
+                    <el-input placeholder="请输入" v-model="formData.TaxpayerID" />
+                </el-form-item>
+                <el-form-item label="开户银行" prop="ReceiptBank">
+                    <el-input placeholder="请输入" v-model="formData.ReceiptBank" />
+                </el-form-item>
+                <el-form-item label="银行账号" prop="ReceiptAccount">
+                    <el-input placeholder="请输入" v-model="formData.ReceiptAccount" />
+                </el-form-item>
+                <el-form-item label="企业地址" prop="Address">
+                    <el-input placeholder="请输入" v-model="formData.Address" />
+                </el-form-item>
+                <el-form-item label="企业电话" prop="ContactInfo">
+                    <el-input placeholder="请输入" v-model="formData.ContactInfo" />
+                </el-form-item>
+            </template>
+        </el-form>
+        <template #footer>
+            <el-button type="info" @click="onCancel(false)">取消</el-button>
+            <el-button type="primary" @click="onSubmit">提交</el-button>
+        </template>
+    </app-drawer>
+</template>
+
+<script lang="ts" setup>
+import { ref } from 'vue'
+import { ElMessage } from 'element-plus'
+import type { FormInstance, FormRules } from 'element-plus'
+import { useInvoiceForm } from '@/business/user/invoice'
+import AppDrawer from '@pc/components/base/drawer/index.vue'
+
+const { loading, formData, addOrUpdate } = useInvoiceForm()
+const show = ref(true)
+const refresh = ref(false)
+const formRef = ref<FormInstance>()
+
+const formRules: FormRules = {
+    ReceiptType: [{ required: true, message: '请选择发票类型' }],
+    UserName: [{ required: true, message: '请输入发票抬头', trigger: 'blur' }],
+    TaxpayerID: [{ required: true, message: '请输入税号', trigger: 'blur' }],
+}
+
+const onCancel = (isRefresh = false) => {
+    show.value = false
+    refresh.value = isRefresh
+}
+
+const onSubmit = () => {
+    formRef.value?.validate((valid) => {
+        if (valid) {
+            addOrUpdate().then(() => {
+                ElMessage.success('提交成功')
+                onCancel(true)
+            }).catch((err) => {
+                ElMessage.error('提交失败:' + err)
+            })
+        }
+    })
+}
+</script>

+ 2 - 1
src/packages/pc/views/account/receipt/index.vue

@@ -34,6 +34,7 @@ import AppFilter from '@pc/components/base/table-filter/index.vue'
 
 const componentMap = new Map<string, unknown>([
     ['edit', defineAsyncComponent(() => import('./components/edit/index.vue'))],
+    ['new', defineAsyncComponent(() => import('./components/new/index.vue'))],
     ['delete', defineAsyncComponent(() => import('./components/delete/index.vue'))],
 ])
 
@@ -56,6 +57,6 @@ const tableColumns = shallowRef<Model.TableColumn[]>([
 ])
 
 filterOptons.buttonList = [
-    { lable: '新增发票', className: 'el-button--primary', onClick: () => openComponent('edit') },
+    { lable: '新增发票', className: 'el-button--primary', onClick: () => openComponent('new') },
 ]
 </script>