feat: param verification
This commit is contained in:
+3
-31
@@ -5,7 +5,6 @@ import (
|
|||||||
"crm/response"
|
"crm/response"
|
||||||
"crm/service"
|
"crm/service"
|
||||||
"log"
|
"log"
|
||||||
"regexp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -30,10 +29,6 @@ func (u *UserApi) Register(context *gin.Context) {
|
|||||||
log.Printf("[error]UserApi:Register:%s", err)
|
log.Printf("[error]UserApi:Register:%s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !verifyEmailFormat(param.Email) {
|
|
||||||
response.Result(response.ErrCodeEmailFormatInvalid, nil, context)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
errCode := u.userService.Register(¶m)
|
errCode := u.userService.Register(¶m)
|
||||||
response.Result(errCode, nil, context)
|
response.Result(errCode, nil, context)
|
||||||
}
|
}
|
||||||
@@ -45,10 +40,6 @@ func (u *UserApi) Login(context *gin.Context) {
|
|||||||
response.Result(response.ErrCodeParamInvalid, nil, context)
|
response.Result(response.ErrCodeParamInvalid, nil, context)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !verifyEmailFormat(param.Email) {
|
|
||||||
response.Result(response.ErrCodeEmailFormatInvalid, nil, context)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userInfo, errCode := u.userService.Login(¶m)
|
userInfo, errCode := u.userService.Login(¶m)
|
||||||
if userInfo == nil {
|
if userInfo == nil {
|
||||||
response.Result(errCode, nil, context)
|
response.Result(errCode, nil, context)
|
||||||
@@ -59,26 +50,18 @@ func (u *UserApi) Login(context *gin.Context) {
|
|||||||
|
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
func (u *UserApi) GetVerifyCode(context *gin.Context) {
|
func (u *UserApi) GetVerifyCode(context *gin.Context) {
|
||||||
email := context.Query("email")
|
var param models.UserVerifyCodeParam
|
||||||
if email == "" {
|
if err := context.ShouldBind(¶m); err != nil {
|
||||||
response.Result(response.ErrCodeParamInvalid, nil, context)
|
response.Result(response.ErrCodeParamInvalid, nil, context)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !verifyEmailFormat(email) {
|
errCode := u.userService.GetVerifyCode(param.Email)
|
||||||
response.Result(response.ErrCodeEmailFormatInvalid, nil, context)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
errCode := u.userService.GetVerifyCode(email)
|
|
||||||
response.Result(errCode, nil, context)
|
response.Result(errCode, nil, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 忘记密码
|
// 忘记密码
|
||||||
func (u *UserApi) ForgotPass(context *gin.Context) {
|
func (u *UserApi) ForgotPass(context *gin.Context) {
|
||||||
var param models.UserPassParam
|
var param models.UserPassParam
|
||||||
if verifyEmailFormat(param.Email) {
|
|
||||||
response.Result(response.ErrCodeEmailFormatInvalid, nil, context)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := context.ShouldBind(¶m); err != nil {
|
if err := context.ShouldBind(¶m); err != nil {
|
||||||
response.Result(response.ErrCodeParamInvalid, nil, context)
|
response.Result(response.ErrCodeParamInvalid, nil, context)
|
||||||
return
|
return
|
||||||
@@ -90,10 +73,6 @@ func (u *UserApi) ForgotPass(context *gin.Context) {
|
|||||||
// 修改邮箱
|
// 修改邮箱
|
||||||
func (u *UserApi) UpdateMail(context *gin.Context) {
|
func (u *UserApi) UpdateMail(context *gin.Context) {
|
||||||
var param models.UserMailParam
|
var param models.UserMailParam
|
||||||
if verifyEmailFormat(param.Email) && verifyEmailFormat(param.NewEmail) {
|
|
||||||
response.Result(response.ErrCodeEmailFormatInvalid, nil, context)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := context.ShouldBind(¶m); err != nil {
|
if err := context.ShouldBind(¶m); err != nil {
|
||||||
response.Result(response.ErrCodeParamInvalid, nil, context)
|
response.Result(response.ErrCodeParamInvalid, nil, context)
|
||||||
return
|
return
|
||||||
@@ -148,10 +127,3 @@ func (u *UserApi) Buy(context *gin.Context) {
|
|||||||
versionInfo, errCode := u.userService.Buy(int64(uid))
|
versionInfo, errCode := u.userService.Buy(int64(uid))
|
||||||
response.Result(errCode, versionInfo, context)
|
response.Result(errCode, versionInfo, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 邮箱格式校验
|
|
||||||
func verifyEmailFormat(email string) bool {
|
|
||||||
pattern := `\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*`
|
|
||||||
reg := regexp.MustCompile(pattern)
|
|
||||||
return reg.MatchString(email)
|
|
||||||
}
|
|
||||||
|
|||||||
+41
-41
@@ -21,63 +21,63 @@ type Contract struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ContractCreateParam struct {
|
type ContractCreateParam struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name" binding:"required"`
|
||||||
Amount float64 `json:"amount,omitempty"`
|
Amount float64 `json:"amount" binding:"required,gt=0"`
|
||||||
BeginTime string `json:"beginTime,omitempty"`
|
BeginTime string `json:"beginTime" binding:"-"`
|
||||||
OverTime string `json:"overTime,omitempty"`
|
OverTime string `json:"overTime" binding:"-"`
|
||||||
Remarks string `json:"remarks,omitempty"`
|
Remarks string `json:"remarks" binding:"-"`
|
||||||
Cid int64 `json:"cid,omitempty"`
|
Cid int64 `json:"cid" binding:"required,gt=0"`
|
||||||
Productlist *Productlist `json:"productlist,omitempty"`
|
Productlist *Productlist `json:"productlist"`
|
||||||
Status int `json:"status,omitempty"`
|
Status int `json:"status" binding:"required,oneof=1 2"`
|
||||||
Creator int64 `json:"creator,omitempty"`
|
Creator int64 `json:"creator,omitempty" binding:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContractUpdateParam struct {
|
type ContractUpdateParam struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id" binding:"required,gt=0"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name" binding:"required"`
|
||||||
Amount float64 `json:"amount,omitempty"`
|
Amount float64 `json:"amount" binding:"required,gt=0"`
|
||||||
BeginTime string `json:"beginTime,omitempty"`
|
BeginTime string `json:"beginTime" binding:"-"`
|
||||||
OverTime string `json:"overTime,omitempty"`
|
OverTime string `json:"overTime" binding:"-"`
|
||||||
Remarks string `json:"remarks,omitempty"`
|
Remarks string `json:"remarks" binding:"-"`
|
||||||
Cid int64 `json:"cid,omitempty"`
|
Cid int64 `json:"cid" binding:"required,gt=0"`
|
||||||
Productlist *Productlist `json:"productlist,omitempty"`
|
Productlist *Productlist `json:"productlist"`
|
||||||
Status int `json:"status,omitempty"`
|
Status int `json:"status" binding:"required,oneof=1 2"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContractDeleteParam struct {
|
type ContractDeleteParam struct {
|
||||||
Ids []int64 `json:"ids,omitempty"`
|
Ids []int64 `json:"ids" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContractQueryParam struct {
|
type ContractQueryParam struct {
|
||||||
Id int64 `form:"id,omitempty"`
|
Id int64 `form:"id" binding:"omitempty,gt=0"`
|
||||||
Name string `form:"name,omitempty"`
|
Name string `form:"name" binding:"-"`
|
||||||
Creator int64 `form:"creator,omitempty"`
|
Creator int64 `form:"creator,omitempty" binding:"-"`
|
||||||
Page Page
|
Page Page
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContractList struct {
|
type ContractList struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name"`
|
||||||
Amount float64 `json:"amount,omitempty"`
|
Amount float64 `json:"amount"`
|
||||||
BeginTime string `json:"beginTime,omitempty"`
|
BeginTime string `json:"beginTime"`
|
||||||
OverTime string `json:"overTime,omitempty"`
|
OverTime string `json:"overTime"`
|
||||||
Remarks string `json:"remarks,omitempty"`
|
Remarks string `json:"remarks"`
|
||||||
Cname string `json:"cname,omitempty"`
|
Cname string `json:"cname"`
|
||||||
Status int `json:"status,omitempty"`
|
Status int `json:"status"`
|
||||||
Created int64 `json:"created,omitempty"`
|
Created int64 `json:"created"`
|
||||||
Updated int64 `json:"updated,omitempty"`
|
Updated int64 `json:"updated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContractInfo struct {
|
type ContractInfo struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name"`
|
||||||
Cid int64 `json:"cid,omitempty"`
|
Cid int64 `json:"cid"`
|
||||||
Amount float64 `json:"amount,omitempty"`
|
Amount float64 `json:"amount"`
|
||||||
BeginTime string `json:"beginTime,omitempty"`
|
BeginTime string `json:"beginTime"`
|
||||||
OverTime string `json:"overTime,omitempty"`
|
OverTime string `json:"overTime"`
|
||||||
Remarks string `json:"remarks,omitempty"`
|
Remarks string `json:"remarks"`
|
||||||
Productlist *Productlist `json:"productlist,omitempty"`
|
Productlist *Productlist `json:"productlist"`
|
||||||
Status int `json:"status,omitempty"`
|
Status int `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Products struct {
|
type Products struct {
|
||||||
|
|||||||
+27
-27
@@ -18,42 +18,42 @@ type Customer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CustomerCreateParam struct {
|
type CustomerCreateParam struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name" binding:"required"`
|
||||||
Source string `json:"source,omitempty"`
|
Source string `json:"source" binding:"-"`
|
||||||
Phone string `json:"phone,omitempty"`
|
Phone string `json:"phone" binding:"omitempty,len=11"`
|
||||||
Email string `json:"email,omitempty"`
|
Email string `json:"email" binding:"omitempty,email"`
|
||||||
Industry string `json:"industry,omitempty"`
|
Industry string `json:"industry" binding:"-"`
|
||||||
Level string `json:"level,omitempty"`
|
Level string `json:"level" binding:"-"`
|
||||||
Remarks string `json:"remarks,omitempty"`
|
Remarks string `json:"remarks" binding:"-"`
|
||||||
Region string `json:"region,omitempty"`
|
Region string `json:"region" binding:"-"`
|
||||||
Address string `json:"address,omitempty"`
|
Address string `json:"address" binding:"-"`
|
||||||
Status int `json:"status,omitempty"`
|
Status int `json:"status" binding:"-"`
|
||||||
Creator int64 `json:"creator,omitempty"`
|
Creator int64 `json:"creator,omitempty" binding:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CustomerUpdateParam struct {
|
type CustomerUpdateParam struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id" binding:"required"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name" binding:"-"`
|
||||||
Source string `json:"source,omitempty"`
|
Source string `json:"source" binding:"-"`
|
||||||
Phone string `json:"phone,omitempty"`
|
Phone string `json:"phone" binding:"omitempty,len=11"`
|
||||||
Email string `json:"email,omitempty"`
|
Email string `json:"email" binding:"omitempty,email"`
|
||||||
Industry string `json:"industry,omitempty"`
|
Industry string `json:"industry" binding:"-"`
|
||||||
Level string `json:"level,omitempty"`
|
Level string `json:"level" binding:"-"`
|
||||||
Remarks string `json:"remarks,omitempty"`
|
Remarks string `json:"remarks" binding:"-"`
|
||||||
Region string `json:"region,omitempty"`
|
Region string `json:"region" binding:"-"`
|
||||||
Address string `json:"address,omitempty"`
|
Address string `json:"address" binding:"-"`
|
||||||
Status int `json:"status,omitempty"`
|
Status int `json:"status" binding:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CustomerDeleteParam struct {
|
type CustomerDeleteParam struct {
|
||||||
Ids []int64 `json:"ids,omitempty"`
|
Ids []int64 `json:"ids" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CustomerQueryParam struct {
|
type CustomerQueryParam struct {
|
||||||
Id int64 `form:"id,omitempty"`
|
Id int64 `form:"id" binding:"omitempty,gt=0"`
|
||||||
Name string `form:"name,omitempty"`
|
Name string `form:"name" binding:"-"`
|
||||||
Phone string `form:"phone,omitempty"`
|
Phone string `form:"phone" binding:"omitempty,len=11"`
|
||||||
Creator int64 `form:"creator"`
|
Creator int64 `form:"creator,omitempty" binding:"-"`
|
||||||
Page Page
|
Page Page
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-23
@@ -15,38 +15,38 @@ type Product struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ProductCreateParam struct {
|
type ProductCreateParam struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name" binding:"required"`
|
||||||
Type int `json:"type,omitempty"`
|
Type int `json:"type" binding:"required,len=1"`
|
||||||
Unit string `json:"unit,omitempty"`
|
Unit string `json:"unit" binding:"-"`
|
||||||
Code string `json:"code,omitempty"`
|
Code string `json:"code" binding:"-"`
|
||||||
Price float64 `json:"price,omitempty"`
|
Price float64 `json:"price" binding:"required,gt=0"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description" binding:"-"`
|
||||||
Status int `json:"status,omitempty"`
|
Status int `json:"status" binding:"required,oneof=1 2"`
|
||||||
Creator int64 `json:"creator,omitempty"`
|
Creator int64 `json:"creator,omitempty" binding:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProductUpdateParam struct {
|
type ProductUpdateParam struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id" binding:"required,gt=0"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name" binding:"required"`
|
||||||
Type int `json:"type,omitempty"`
|
Type int `json:"type" binding:"required,len=1"`
|
||||||
Unit string `json:"unit,omitempty"`
|
Unit string `json:"unit" binding:"-"`
|
||||||
Code string `json:"code,omitempty"`
|
Code string `json:"code" binding:"-"`
|
||||||
Price float64 `json:"price,omitempty"`
|
Price float64 `json:"price" binding:"required,gt=0"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description" binding:"-"`
|
||||||
Status int `json:"status,omitempty"`
|
Status int `json:"status" binding:"required,oneof=1 2"`
|
||||||
Creator int64 `json:"creator,omitempty"`
|
Creator int64 `json:"creator,omitempty" binding:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProductDeleteParam struct {
|
type ProductDeleteParam struct {
|
||||||
Ids []int64 `json:"ids,omitempty"`
|
Ids []int64 `json:"ids" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProductQueryParam struct {
|
type ProductQueryParam struct {
|
||||||
Id int64 `form:"id,omitempty"`
|
Id int64 `form:"id" binding:"omitempty,gt=0"`
|
||||||
Ids []int64 `form:"ids,omitempty"`
|
Ids []int64 `form:"ids" json:"ids" binding:"-"`
|
||||||
Name string `form:"name,omitempty"`
|
Name string `form:"name" binding:"-"`
|
||||||
Status int `form:"status,omitempty"`
|
Status int `form:"status" binding:"omitempty,oneof=1 2"`
|
||||||
Creator int64 `form:"creator,omitempty"`
|
Creator int64 `form:"creator,omitempty" binding:"-"`
|
||||||
Page Page
|
Page Page
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
-21
@@ -13,39 +13,36 @@ type User struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UserCreateParam struct {
|
type UserCreateParam struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email" binding:"required,email"`
|
||||||
Code string `json:"code"`
|
Code string `json:"code" binding:"required,len=6"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password" binding:"required"`
|
||||||
}
|
|
||||||
|
|
||||||
type UserUpdateParam struct {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Password string `json:"password"`
|
|
||||||
Status int `json:"status"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserDeleteParam struct {
|
type UserDeleteParam struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id,omitempty" binding:"-"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email" binding:"required,email"`
|
||||||
Code string `json:"code"`
|
Code string `json:"code" binding:"required,len=6"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserLoginParam struct {
|
type UserLoginParam struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email" binding:"required,email"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserVerifyCodeParam struct {
|
||||||
|
Email string `form:"email" binding:"required,email"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserPassParam struct {
|
type UserPassParam struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email" binding:"required,email"`
|
||||||
Code string `json:"code"`
|
Code string `json:"code" binding:"required,len=6"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserMailParam struct {
|
type UserMailParam struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email" binding:"required,email"`
|
||||||
Code string `json:"code"`
|
Code string `json:"code" binding:"required,len=6"`
|
||||||
NewEmail string `json:"newEmail"`
|
NewEmail string `json:"newEmail" binding:"required,email"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserInfo struct {
|
type UserInfo struct {
|
||||||
|
|||||||
+29
-18
@@ -33,7 +33,7 @@
|
|||||||
<a-modal v-model:visible="visible" :title="title" @ok="onSave" @cancel="onCancel" cancelText="取消" okText="保存"
|
<a-modal v-model:visible="visible" :title="title" @ok="onSave" @cancel="onCancel" cancelText="取消" okText="保存"
|
||||||
width="800px" style="top: 80px">
|
width="800px" style="top: 80px">
|
||||||
<div style="height: 55vh;overflow-y: scroll;padding: 0 15px;">
|
<div style="height: 55vh;overflow-y: scroll;padding: 0 15px;">
|
||||||
<a-form ref="modalFormRef" :model="contract" layout="vertical" name="contract">
|
<a-form ref="contractFormRef" :model="contract" layout="vertical" name="contract" :rules="rules">
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="合同编号" name="id">
|
<a-form-item label="合同编号" name="id">
|
||||||
@@ -41,21 +41,21 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="合同名称" name="name" :rules="[{ required: true, message: '请输入合同名称' }]">
|
<a-form-item label="合同名称" name="name">
|
||||||
<a-input v-model:value="contract.name" />
|
<a-input v-model:value="contract.name" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="客户名称" name="cid" :rules="[{ required: true, message: '请选择客户' }]">
|
<a-form-item label="客户名称" name="cid">
|
||||||
<a-select v-model:value="contract.cid" style="width: 100%" placeholder="请选择"
|
<a-select v-model:value="contract.cid" style="width: 100%" placeholder="请选择"
|
||||||
:fieldNames="{ label: 'name', value: 'id' }" :options="data.customerOption"
|
:fieldNames="{ label: 'name', value: 'id' }" :options="data.customerOption"
|
||||||
@focus="getCustomerOption" @change="changeCustomerOption"></a-select>
|
@focus="getCustomerOption" @change="changeCustomerOption"></a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="合同金额" name="amount" :rules="[{ required: true, message: '请输入合同金额' }]">
|
<a-form-item label="合同金额" name="amount">
|
||||||
<a-input-number v-model:value="contract.amount" style="width: 100%" />
|
<a-input-number v-model:value="contract.amount" style="width: 100%" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
</a-row>
|
</a-row>
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="合同状态" name="status" :rules="[{ required: true, message: '请选择合同状态' }]">
|
<a-form-item label="合同状态" name="status">
|
||||||
<a-select v-model:value="contract.status" placeholder="请选择">
|
<a-select v-model:value="contract.status" placeholder="请选择">
|
||||||
<a-select-option :value="1">已生效</a-select-option>
|
<a-select-option :value="1">已生效</a-select-option>
|
||||||
<a-select-option :value="2">未生效</a-select-option>
|
<a-select-option :value="2">未生效</a-select-option>
|
||||||
@@ -321,6 +321,14 @@ export default {
|
|||||||
width: 150,
|
width: 150,
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
// 表单校验
|
||||||
|
const rules = {
|
||||||
|
name: [{ required: true, message: '请输入合同名称', trigger: 'blur' }],
|
||||||
|
cid: [{ required: true, message: '请选择客户', trigger: 'blur' }],
|
||||||
|
amount: [{ required: true, message: '请输入合同金额', trigger: 'blur' }],
|
||||||
|
status: [{ required: true, message: '请选择合同状态' }]
|
||||||
|
};
|
||||||
|
|
||||||
// 合同属性
|
// 合同属性
|
||||||
let contract = reactive({
|
let contract = reactive({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
@@ -358,21 +366,20 @@ export default {
|
|||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const disabled = ref(true)
|
const disabled = ref(true)
|
||||||
const operation = ref(0);
|
const operation = ref(0);
|
||||||
const modalFormRef = ref();
|
const contractFormRef = ref();
|
||||||
const keyWord = ref('')
|
const keyWord = ref('')
|
||||||
const productListVisible = ref(false);
|
const productListVisible = ref(false);
|
||||||
|
|
||||||
// 点击新建合同
|
// 点击新建合同
|
||||||
const onCreate = () => {
|
const onCreate = () => {
|
||||||
title.value = '新建合同'
|
title.value = '新建合同'
|
||||||
visible.value = true
|
|
||||||
operation.value = 1
|
operation.value = 1
|
||||||
|
visible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击编辑合同
|
// 点击编辑合同
|
||||||
const onEdit = (row) => {
|
const onEdit = (row) => {
|
||||||
title.value = '编辑合同'
|
title.value = '编辑合同'
|
||||||
visible.value = true
|
|
||||||
operation.value = 2
|
operation.value = 2
|
||||||
getCustomerOption()
|
getCustomerOption()
|
||||||
let param = { id: row.id }
|
let param = { id: row.id }
|
||||||
@@ -389,18 +396,14 @@ export default {
|
|||||||
contract.status = p.status
|
contract.status = p.status
|
||||||
contract.productlist = p.productlist
|
contract.productlist = p.productlist
|
||||||
data.addedProductList = p.productlist
|
data.addedProductList = p.productlist
|
||||||
if (data.addedProductList.length > 0) {
|
|
||||||
for (let i = 0; i < data.addedProductList.length; i++) {
|
|
||||||
data.defaultSelectedIds.push(data.addedProductList[i].id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
visible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击保存合同
|
// 点击保存合同
|
||||||
const onSave = () => {
|
const onSave = () => {
|
||||||
modalFormRef.value.validateFields().then(() => {
|
contractFormRef.value.validateFields().then(() => {
|
||||||
if (operation.value == 1) {
|
if (operation.value == 1) {
|
||||||
let param = {
|
let param = {
|
||||||
name: contract.name,
|
name: contract.name,
|
||||||
@@ -440,7 +443,7 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
modalFormRef.value.resetFields()
|
contractFormRef.value.resetFields()
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -501,7 +504,6 @@ export default {
|
|||||||
|
|
||||||
// 点击添加产品
|
// 点击添加产品
|
||||||
const onAddProduct = () => {
|
const onAddProduct = () => {
|
||||||
productListVisible.value = true
|
|
||||||
let param = {
|
let param = {
|
||||||
pageNum: pagination.current,
|
pageNum: pagination.current,
|
||||||
pageSize: pagination.pageSize
|
pageSize: pagination.pageSize
|
||||||
@@ -512,6 +514,13 @@ export default {
|
|||||||
data.productList = res.data.data.list
|
data.productList = res.data.data.list
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
data.defaultSelectedIds = []
|
||||||
|
if (data.addedProductList.length > 0) {
|
||||||
|
for (let i = 0; i < data.addedProductList.length; i++) {
|
||||||
|
data.defaultSelectedIds[i] = data.addedProductList[i].id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
productListVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分页查询产品列表
|
// 分页查询产品列表
|
||||||
@@ -595,7 +604,8 @@ export default {
|
|||||||
|
|
||||||
// 点击合同取消按钮
|
// 点击合同取消按钮
|
||||||
const onCancel = () => {
|
const onCancel = () => {
|
||||||
modalFormRef.value.resetFields()
|
contractFormRef.value.resetFields()
|
||||||
|
data.addedProductList = []
|
||||||
visible.value = false
|
visible.value = false
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -610,6 +620,7 @@ export default {
|
|||||||
columns,
|
columns,
|
||||||
productColumns,
|
productColumns,
|
||||||
productListColumns,
|
productListColumns,
|
||||||
|
rules,
|
||||||
data,
|
data,
|
||||||
onSelectedConteactIds,
|
onSelectedConteactIds,
|
||||||
onSelectedProductIds,
|
onSelectedProductIds,
|
||||||
@@ -622,7 +633,7 @@ export default {
|
|||||||
operation,
|
operation,
|
||||||
onCreate,
|
onCreate,
|
||||||
onEdit,
|
onEdit,
|
||||||
modalFormRef,
|
contractFormRef,
|
||||||
onSave,
|
onSave,
|
||||||
onCancel,
|
onCancel,
|
||||||
onDelete,
|
onDelete,
|
||||||
|
|||||||
+27
-10
@@ -34,10 +34,10 @@
|
|||||||
<a-modal v-model:visible="visible" :title="title" @ok="onSave" @cancel="onCancel" cancelText="取消" okText="保存"
|
<a-modal v-model:visible="visible" :title="title" @ok="onSave" @cancel="onCancel" cancelText="取消" okText="保存"
|
||||||
width="800px" style="top: 80px;">
|
width="800px" style="top: 80px;">
|
||||||
<div style="height: 55vh;overflow-y: scroll;padding: 0 15px;">
|
<div style="height: 55vh;overflow-y: scroll;padding: 0 15px;">
|
||||||
<a-form ref="modalFormRef" :model="customer" layout="vertical" name="customer">
|
<a-form ref="customerFormRef" :model="customer" layout="vertical" name="customer" :rules="rules">
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="客户名称" name="name" :rules="[{ required: true, message: '请输入客户名称' }]">
|
<a-form-item label="客户名称" name="name">
|
||||||
<a-input v-model:value="customer.name" />
|
<a-input v-model:value="customer.name" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
@@ -188,6 +188,21 @@ export default {
|
|||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
// 表单校验
|
||||||
|
const rules = {
|
||||||
|
name: [{ required: true, message: '请输入客户名称', trigger: 'blur' }],
|
||||||
|
phone: [{
|
||||||
|
pattern: /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/,
|
||||||
|
message: '手机格式不正确',
|
||||||
|
trigger: 'blur',
|
||||||
|
}],
|
||||||
|
email: [{
|
||||||
|
pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,
|
||||||
|
message: '邮箱格式不正确',
|
||||||
|
trigger: 'blur',
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
customerList: [],
|
customerList: [],
|
||||||
selectedIds: []
|
selectedIds: []
|
||||||
@@ -240,20 +255,19 @@ export default {
|
|||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const disabled = ref(true)
|
const disabled = ref(true)
|
||||||
const operation = ref(0);
|
const operation = ref(0);
|
||||||
const modalFormRef = ref();
|
const customerFormRef = ref();
|
||||||
const keyWord = ref('')
|
const keyWord = ref('')
|
||||||
|
|
||||||
// 点击新建客户
|
// 点击新建客户
|
||||||
const onCreate = () => {
|
const onCreate = () => {
|
||||||
title.value = '新建客户'
|
title.value = '新建客户'
|
||||||
visible.value = true
|
|
||||||
operation.value = 1
|
operation.value = 1
|
||||||
|
visible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击客户名称
|
// 点击客户名称
|
||||||
const onEdit = (row) => {
|
const onEdit = (row) => {
|
||||||
title.value = '编辑客户'
|
title.value = '编辑客户'
|
||||||
visible.value = true
|
|
||||||
operation.value = 2
|
operation.value = 2
|
||||||
let param = { id: row.id }
|
let param = { id: row.id }
|
||||||
queryCustomerInfo(param).then((res) => {
|
queryCustomerInfo(param).then((res) => {
|
||||||
@@ -273,13 +287,15 @@ export default {
|
|||||||
customer.status = p.status
|
customer.status = p.status
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
visible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击保存客户
|
// 点击保存客户
|
||||||
const onSave = () => {
|
const onSave = () => {
|
||||||
console.log("zzz123")
|
customerFormRef.value.validateFields().then(() => {
|
||||||
modalFormRef.value.validateFields().then(() => {
|
if (customer.region !== undefined) {
|
||||||
customer.region = customer.region.toString()
|
customer.region = customer.region.toString()
|
||||||
|
}
|
||||||
if (operation.value == 1) {
|
if (operation.value == 1) {
|
||||||
createCustomer(customer).then((res) => {
|
createCustomer(customer).then((res) => {
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
@@ -296,7 +312,7 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
modalFormRef.value.resetFields()
|
customerFormRef.value.resetFields()
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -352,7 +368,7 @@ export default {
|
|||||||
|
|
||||||
// 点击取消按钮
|
// 点击取消按钮
|
||||||
const onCancel = () => {
|
const onCancel = () => {
|
||||||
modalFormRef.value.resetFields()
|
customerFormRef.value.resetFields()
|
||||||
visible.value = false
|
visible.value = false
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -365,6 +381,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
columns,
|
columns,
|
||||||
|
rules,
|
||||||
onSearch,
|
onSearch,
|
||||||
visible,
|
visible,
|
||||||
disabled,
|
disabled,
|
||||||
@@ -377,7 +394,7 @@ export default {
|
|||||||
onCustomers,
|
onCustomers,
|
||||||
onCreate,
|
onCreate,
|
||||||
onEdit,
|
onEdit,
|
||||||
modalFormRef,
|
customerFormRef,
|
||||||
onSave,
|
onSave,
|
||||||
onCancel,
|
onCancel,
|
||||||
onDelete,
|
onDelete,
|
||||||
|
|||||||
+31
-7
@@ -64,17 +64,17 @@
|
|||||||
<!-- 修改邮箱弹出框 -->
|
<!-- 修改邮箱弹出框 -->
|
||||||
<a-modal v-model:visible="visible" title="修改邮箱" @ok="onSave" @cancel="onCancel" cancelText="取消" okText="保存"
|
<a-modal v-model:visible="visible" title="修改邮箱" @ok="onSave" @cancel="onCancel" cancelText="取消" okText="保存"
|
||||||
width="450px" style="top: 120px">
|
width="450px" style="top: 120px">
|
||||||
<a-form :model="user" layout="vertical" @finish="onSubmit">
|
<a-form :model="user" layout="vertical" @finish="onSubmit" :rules="rules">
|
||||||
<a-form-item name="email" :rules="[{ required: true, message: '请输入邮箱!' }]">
|
<a-form-item name="email">
|
||||||
<a-input v-model:value="user.email" size="large" placeholder="邮箱" disabled />
|
<a-input v-model:value="user.email" size="large" placeholder="邮箱" disabled />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="code" :rules="[{ required: true, message: '请输入验证码!' }]">
|
<a-form-item name="code">
|
||||||
<a-input v-model:value="user.code" size="large" style="width: 55%;" placeholder="验证码" />
|
<a-input v-model:value="user.code" size="large" style="width: 55%;" placeholder="验证码" />
|
||||||
<a-button @click="onGetCode" size="large" style="width: 40%;float: right;" :loading="loading"
|
<a-button @click="onGetCode" size="large" style="width: 40%;float: right;" :loading="loading"
|
||||||
:disabled="disabled">
|
:disabled="disabled">
|
||||||
{{ buttonText }}</a-button>
|
{{ buttonText }}</a-button>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="newEmail" :rules="[{ required: true, message: '请输入新邮箱!' }]">
|
<a-form-item name="newEmail">
|
||||||
<a-input v-model:value="user.newEmail" size="large" placeholder="新邮箱" />
|
<a-input v-model:value="user.newEmail" size="large" placeholder="新邮箱" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
@@ -82,11 +82,11 @@
|
|||||||
<!-- 注销账号弹出框 -->
|
<!-- 注销账号弹出框 -->
|
||||||
<a-modal v-model:visible="delUserVisible" title="注销账号" @ok="onConfirm" @cancel="onCancel" cancelText="取消"
|
<a-modal v-model:visible="delUserVisible" title="注销账号" @ok="onConfirm" @cancel="onCancel" cancelText="取消"
|
||||||
okText="注销" width="450px" style="top: 120px">
|
okText="注销" width="450px" style="top: 120px">
|
||||||
<a-form :model="user" layout="vertical" @finish="onSubmit">
|
<a-form :model="user" layout="vertical" @finish="onSubmit" :rules="rules">
|
||||||
<a-form-item name="email" :rules="[{ required: true, message: '请输入邮箱!' }]">
|
<a-form-item name="email">
|
||||||
<a-input v-model:value="user.email" size="large" placeholder="邮箱" disabled />
|
<a-input v-model:value="user.email" size="large" placeholder="邮箱" disabled />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="code" :rules="[{ required: true, message: '请输入验证码!' }]">
|
<a-form-item name="code">
|
||||||
<a-input v-model:value="user.code" size="large" style="width: 55%;" placeholder="验证码" />
|
<a-input v-model:value="user.code" size="large" style="width: 55%;" placeholder="验证码" />
|
||||||
<a-button @click="onGetCode" size="large" style="width: 40%;float: right;" :loading="loading"
|
<a-button @click="onGetCode" size="large" style="width: 40%;float: right;" :loading="loading"
|
||||||
:disabled="disabled">
|
:disabled="disabled">
|
||||||
@@ -162,6 +162,29 @@ export default {
|
|||||||
name: "订阅"
|
name: "订阅"
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
// 表单校验
|
||||||
|
const rules = {
|
||||||
|
email: [{
|
||||||
|
required: true,
|
||||||
|
message: '请输入邮箱!',
|
||||||
|
trigger: 'blur',
|
||||||
|
}, {
|
||||||
|
pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,
|
||||||
|
message: '邮箱格式不正确',
|
||||||
|
trigger: 'blur',
|
||||||
|
}],
|
||||||
|
code: [{ required: true, message: '请输入验证码!' }],
|
||||||
|
newEmail: [{
|
||||||
|
required: true,
|
||||||
|
message: '请输入邮箱!',
|
||||||
|
trigger: 'blur',
|
||||||
|
}, {
|
||||||
|
pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,
|
||||||
|
message: '邮箱格式不正确',
|
||||||
|
trigger: 'blur',
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
|
||||||
const selectedKeys = ref(['dashboard'])
|
const selectedKeys = ref(['dashboard'])
|
||||||
const collapsed = ref(false)
|
const collapsed = ref(false)
|
||||||
|
|
||||||
@@ -283,6 +306,7 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
menuItem,
|
menuItem,
|
||||||
|
rules,
|
||||||
selectedKeys,
|
selectedKeys,
|
||||||
collapsed,
|
collapsed,
|
||||||
user,
|
user,
|
||||||
|
|||||||
+27
-6
@@ -1,17 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-form :model="formData" layout="vertical" @finish="onSubmit">
|
<a-form ref="passFormRef" :model="formData" layout="vertical" @finish="onSubmit" :rules="rules">
|
||||||
<a-form-item name="email" :rules="[{ required: true, message: '请输入邮箱!' }]">
|
<a-form-item name="email">
|
||||||
<a-input v-model:value="formData.email" size="large" placeholder="邮箱" />
|
<a-input v-model:value="formData.email" size="large" placeholder="邮箱" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="code" :rules="[{ required: true, message: '请输入验证码!' }]">
|
<a-form-item name="code">
|
||||||
<a-input v-model:value="formData.code" size="large" style="width: 55%;" placeholder="验证码" />
|
<a-input v-model:value="formData.code" size="large" style="width: 55%;" placeholder="验证码" />
|
||||||
<a-button @click="onGetCode" size="large" :disabled="disabled" :loading="loading" style="width: 40%;float: right;">
|
<a-button @click="onGetCode" size="large" :disabled="disabled" :loading="loading"
|
||||||
|
style="width: 40%;float: right;">
|
||||||
{{ buttonText }}</a-button>
|
{{ buttonText }}</a-button>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="password1" :rules="[{ required: true, message: '请输入密码!' }]">
|
<a-form-item name="password1">
|
||||||
<a-input-password v-model:value="formData.password1" size="large" placeholder="密码" />
|
<a-input-password v-model:value="formData.password1" size="large" placeholder="密码" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="password2" :rules="[{ required: true, message: '请输入密码!' }]">
|
<a-form-item name="password2">
|
||||||
<a-input-password v-model:value="formData.password2" size="large" placeholder="确认密码" />
|
<a-input-password v-model:value="formData.password2" size="large" placeholder="确认密码" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
@@ -39,11 +40,28 @@ export default {
|
|||||||
password2: '',
|
password2: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 表单校验
|
||||||
|
const rules = {
|
||||||
|
email: [{
|
||||||
|
required: true,
|
||||||
|
message: '请输入邮箱!'
|
||||||
|
}, {
|
||||||
|
pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,
|
||||||
|
message: '邮箱格式不正确',
|
||||||
|
trigger: 'blur',
|
||||||
|
}],
|
||||||
|
code: [{ required: true, message: '请输入验证码!' }],
|
||||||
|
password1: [{ required: true, message: '请输入密码!' }],
|
||||||
|
password2: [{ required: true, message: '请输入密码!' }],
|
||||||
|
};
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const disabled = ref(false)
|
const disabled = ref(false)
|
||||||
|
const passFormRef = ref()
|
||||||
const buttonText = ref('获取验证码')
|
const buttonText = ref('获取验证码')
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
|
passFormRef.value.validateFields().then(() => {
|
||||||
let param = {
|
let param = {
|
||||||
email: formData.email,
|
email: formData.email,
|
||||||
code: formData.code,
|
code: formData.code,
|
||||||
@@ -58,6 +76,7 @@ export default {
|
|||||||
message.error('验证码错误');
|
message.error('验证码错误');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
@@ -90,6 +109,8 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
formData,
|
formData,
|
||||||
|
rules,
|
||||||
|
passFormRef,
|
||||||
loading,
|
loading,
|
||||||
disabled,
|
disabled,
|
||||||
buttonText,
|
buttonText,
|
||||||
|
|||||||
+23
-15
@@ -34,17 +34,15 @@
|
|||||||
<!-- 新建、编辑产品 -->
|
<!-- 新建、编辑产品 -->
|
||||||
<a-modal v-model:visible="visible" :title="title" @ok="onSave" @cancel="onCancel" cancelText="取消" okText="保存"
|
<a-modal v-model:visible="visible" :title="title" @ok="onSave" @cancel="onCancel" cancelText="取消" okText="保存"
|
||||||
width="800px" style="top: 80px">
|
width="800px" style="top: 80px">
|
||||||
<a-form ref="productForm" :model="product" layout="vertical" name="product">
|
<a-form ref="productFormRef" :model="product" layout="vertical" name="product" :rules="rules">
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="产品名称" name="name" :rules="[{ required: true, message: '请输入产品名称' }]">
|
<a-form-item label="产品名称" name="name">
|
||||||
<a-input v-model:value="product.name" />
|
<a-input v-model:value="product.name" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="产品类型" name="type" :rules="[{
|
<a-form-item label="产品类型" name="type">
|
||||||
required: true, message: '请选择产品类型',
|
|
||||||
}]">
|
|
||||||
<a-select v-model:value="product.type" placeholder="请选择">
|
<a-select v-model:value="product.type" placeholder="请选择">
|
||||||
<a-select-option :value="1">默认</a-select-option>
|
<a-select-option :value="1">默认</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
@@ -67,19 +65,19 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="产品编码" name="code" :rules="[{ required: true, message: '请输入产品编码' }]">
|
<a-form-item label="产品编码" name="code">
|
||||||
<a-input v-model:value="product.code" />
|
<a-input v-model:value="product.code" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="价格" name="price" :rules="[{ required: true, message: '请输入产品价格' }]">
|
<a-form-item label="价格" name="price">
|
||||||
<a-input-number v-model:value="product.price" style="width: 100%" />
|
<a-input-number v-model:value="product.price" style="width: 100%" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="是否上下架" name="status" :rules="[{ required: true, message: '请选择是否上下架' }]">
|
<a-form-item label="是否上下架" name="status">
|
||||||
<a-select v-model:value="product.status" placeholder="请选择">
|
<a-select v-model:value="product.status" placeholder="请选择">
|
||||||
<a-select-option :value="1">上架</a-select-option>
|
<a-select-option :value="1">上架</a-select-option>
|
||||||
<a-select-option :value="2">下架</a-select-option>
|
<a-select-option :value="2">下架</a-select-option>
|
||||||
@@ -161,6 +159,15 @@ export default {
|
|||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
// 表单校验
|
||||||
|
const rules = {
|
||||||
|
name: [{ required: true, message: '请输入产品名称', trigger: 'blur' }],
|
||||||
|
type: [{ required: true, message: '请选择产品类型' }],
|
||||||
|
code: [{ pattern: /^\d+$/, message: '产品编码格式不正确', trigger: 'blur' }],
|
||||||
|
price: [{ required: true, message: '请输入产品价格' }],
|
||||||
|
status: [{ required: true, message: '请选择是否上下架' }]
|
||||||
|
};
|
||||||
|
|
||||||
// 产品属性
|
// 产品属性
|
||||||
let product = reactive({
|
let product = reactive({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
@@ -190,7 +197,7 @@ export default {
|
|||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const disabled = ref(true)
|
const disabled = ref(true)
|
||||||
const operation = ref(0);
|
const operation = ref(0);
|
||||||
const productForm = ref();
|
const productFormRef = ref();
|
||||||
const keyWord = ref('')
|
const keyWord = ref('')
|
||||||
|
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
@@ -218,14 +225,13 @@ export default {
|
|||||||
// 点击新建产品
|
// 点击新建产品
|
||||||
const onCreate = () => {
|
const onCreate = () => {
|
||||||
title.value = '新建产品'
|
title.value = '新建产品'
|
||||||
visible.value = true
|
|
||||||
operation.value = 1
|
operation.value = 1
|
||||||
|
visible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击产品名称
|
// 点击产品名称
|
||||||
const onEdit = (row) => {
|
const onEdit = (row) => {
|
||||||
title.value = '编辑产品'
|
title.value = '编辑产品'
|
||||||
visible.value = true
|
|
||||||
operation.value = 2
|
operation.value = 2
|
||||||
let param = { id: row.id }
|
let param = { id: row.id }
|
||||||
queryProductInfo(param).then((res) => {
|
queryProductInfo(param).then((res) => {
|
||||||
@@ -241,11 +247,12 @@ export default {
|
|||||||
product.description = p.description
|
product.description = p.description
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
visible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击保存产品
|
// 点击保存产品
|
||||||
const onSave = () => {
|
const onSave = () => {
|
||||||
productForm.value.validateFields().then(() => {
|
productFormRef.value.validateFields().then(() => {
|
||||||
if (operation.value == 1) {
|
if (operation.value == 1) {
|
||||||
createProduct(product).then((res) => {
|
createProduct(product).then((res) => {
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
@@ -262,7 +269,7 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
productForm.value.resetFields()
|
productFormRef.value.resetFields()
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -313,12 +320,13 @@ export default {
|
|||||||
|
|
||||||
// 点击取消按钮
|
// 点击取消按钮
|
||||||
const onCancel = () => {
|
const onCancel = () => {
|
||||||
productForm.value.resetFields()
|
productFormRef.value.resetFields()
|
||||||
visible.value = false
|
visible.value = false
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
columns,
|
columns,
|
||||||
|
rules,
|
||||||
data,
|
data,
|
||||||
onSelectChange,
|
onSelectChange,
|
||||||
onSearch,
|
onSearch,
|
||||||
@@ -330,7 +338,7 @@ export default {
|
|||||||
onProducts,
|
onProducts,
|
||||||
onCreate,
|
onCreate,
|
||||||
onEdit,
|
onEdit,
|
||||||
productForm,
|
productFormRef,
|
||||||
onSave,
|
onSave,
|
||||||
onCancel,
|
onCancel,
|
||||||
onDelete,
|
onDelete,
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-form :model="formData" layout="vertical" @finish="onRegister">
|
<a-form ref="registerFormRef" :model="formData" layout="vertical" @finish="onRegister" :rules="rules">
|
||||||
<a-form-item name="email" :rules="[{ required: true, message: '请输入邮箱!' }]">
|
<a-form-item name="email">
|
||||||
<a-input v-model:value="formData.email" size="large" placeholder="邮箱">
|
<a-input v-model:value="formData.email" size="large" placeholder="邮箱" />
|
||||||
</a-input>
|
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="code" :rules="[{ required: true, message: '请输入验证码!' }]">
|
<a-form-item name="code">
|
||||||
<a-input v-model:value="formData.code" size="large" style="width: 55%;" placeholder="验证码" />
|
<a-input v-model:value="formData.code" size="large" style="width: 55%;" placeholder="验证码" />
|
||||||
<a-button @click="onGetCode" size="large" style="width: 40%;float: right;" :loading="loading" :disabled="disabled">
|
<a-button @click="onGetCode" size="large" style="width: 40%;float: right;" :loading="loading"
|
||||||
|
:disabled="disabled">
|
||||||
{{ buttonText }}</a-button>
|
{{ buttonText }}</a-button>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="password1" :rules="[{ required: true, message: '请输入密码!' }]">
|
<a-form-item name="password1">
|
||||||
<a-input-password v-model:value="formData.password1" size="large" placeholder="密码" />
|
<a-input-password v-model:value="formData.password1" size="large" placeholder="密码" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="password2" :rules="[{ required: true, message: '请输入密码!' }]">
|
<a-form-item name="password2">
|
||||||
<a-input-password v-model:value="formData.password2" size="large" placeholder="确认密码" />
|
<a-input-password v-model:value="formData.password2" size="large" placeholder="确认密码" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
@@ -40,13 +40,31 @@ export default {
|
|||||||
password2: '',
|
password2: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 表单校验
|
||||||
|
const rules = {
|
||||||
|
email: [{
|
||||||
|
required: true,
|
||||||
|
message: '请输入邮箱!',
|
||||||
|
trigger: 'blur',
|
||||||
|
}, {
|
||||||
|
pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,
|
||||||
|
message: '邮箱格式不正确',
|
||||||
|
trigger: 'blur',
|
||||||
|
}],
|
||||||
|
code: [{ required: true, message: '请输入验证码!' }],
|
||||||
|
password1: [{ required: true, message: '请输入密码!' }],
|
||||||
|
password2: [{ required: true, message: '请输入密码!' }],
|
||||||
|
};
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const disabled = ref(false)
|
const disabled = ref(false)
|
||||||
|
const registerFormRef = ref()
|
||||||
const buttonText = ref('获取验证码')
|
const buttonText = ref('获取验证码')
|
||||||
|
|
||||||
const onRegister = () => {
|
const onRegister = () => {
|
||||||
|
registerFormRef.value.validateFields().then(() => {
|
||||||
if (formData.password1 != formData.password2) {
|
if (formData.password1 != formData.password2) {
|
||||||
message.info('密码不一致');
|
message.warn('密码不一致');
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let param = {
|
let param = {
|
||||||
@@ -66,6 +84,7 @@ export default {
|
|||||||
message.error('验证码错误');
|
message.error('验证码错误');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
@@ -98,6 +117,8 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
formData,
|
formData,
|
||||||
|
rules,
|
||||||
|
registerFormRef,
|
||||||
loading,
|
loading,
|
||||||
disabled,
|
disabled,
|
||||||
buttonText,
|
buttonText,
|
||||||
|
|||||||
Reference in New Issue
Block a user