You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
3.2 KiB
151 lines
3.2 KiB
9 months ago
|
<template>
|
||
|
<view class="add">
|
||
|
<!-- 客户信息 -->
|
||
|
<view class="main">
|
||
|
<u--form labelPosition="left" labelAlign="center" :model="form" ref="form1">
|
||
|
<u-form-item label="公司名称" prop="name" labelWidth="auto" borderBottom ref="item1">
|
||
|
<u--input v-model="form.name" border="none" placeholder="请输入公司名称"></u--input>
|
||
|
</u-form-item>
|
||
|
|
||
|
<u-form-item label="联系人" prop="user" labelWidth="auto" borderBottom>
|
||
|
<u--input v-model="form.user" border="none" placeholder="请输入联系人">
|
||
|
</u--input>
|
||
|
</u-form-item>
|
||
|
<u-form-item label="手机" prop="phone" labelWidth="auto" borderBottom ref="item1" >
|
||
|
<u--input v-model="form.phone" border="none" placeholder="请输入手机号码"></u--input>
|
||
|
</u-form-item>
|
||
|
<u-form-item label="地址" prop="address" labelWidth="auto" borderBottom ref="item1">
|
||
|
<u--textarea v-model="form.address" placeholder="请输入公司地址" confirmType="done"></u--textarea>
|
||
|
</u-form-item>
|
||
|
</u--form>
|
||
|
|
||
|
</view>
|
||
|
<view class="submit">
|
||
|
<u-button type="primary" @click="submit" text="添 加 客 户"></u-button>
|
||
|
</view>
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
|
||
|
data() {
|
||
|
return {
|
||
|
form: {
|
||
|
id: null,
|
||
|
name: null,
|
||
|
user: null,
|
||
|
phone: null,
|
||
|
address: null,
|
||
|
},
|
||
|
|
||
|
|
||
|
}
|
||
|
},
|
||
|
|
||
|
onLoad: function(options) {
|
||
|
|
||
|
},
|
||
|
|
||
|
created() {},
|
||
|
filters: {},
|
||
|
|
||
|
methods: {
|
||
|
submit(){
|
||
|
if(this.form.id){
|
||
|
// 修改
|
||
|
this.updateCustomer();
|
||
|
}else{
|
||
|
this.addCustomer();
|
||
|
}
|
||
|
},
|
||
|
// 添加客户信息
|
||
|
async addCustomer() {
|
||
|
let flag = true;
|
||
|
const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
|
||
|
if(!reg.test(this.form.phone)){
|
||
|
return uni.showToast({
|
||
|
title: '手机号格式有误',
|
||
|
icon: 'error'
|
||
|
})
|
||
|
}
|
||
|
if(this.form.name==null || this.form.name=='' ){
|
||
|
flag = false;
|
||
|
}
|
||
|
if(this.form.user == null || this.form.user==''){
|
||
|
flag = false;
|
||
|
}
|
||
|
if(this.form.address == null || this.form.address==''){
|
||
|
flag = false;
|
||
|
}
|
||
|
if(!flag) return uni.showToast({
|
||
|
title: '请补充客户内容',
|
||
|
icon: 'error'
|
||
|
})
|
||
|
const {
|
||
|
data: res
|
||
|
} = await this.$http('/app/addCustomer', this.form)
|
||
|
if (res.code == 0) {
|
||
|
uni.showToast({
|
||
|
title: '添加客户成功',
|
||
|
icon: 'success'
|
||
|
});
|
||
|
this.reset();
|
||
|
// 设备添加完成返回 设备列表页面
|
||
|
wx.switchTab({
|
||
|
url: 'customer',
|
||
|
})
|
||
|
}else{
|
||
|
// 添加失败
|
||
|
uni.showToast({
|
||
|
title: "添加客户失败",
|
||
|
icon: 'error'
|
||
|
})
|
||
|
}
|
||
|
|
||
|
},
|
||
|
// 修改客户信息
|
||
|
async updateCustomer() {
|
||
|
},
|
||
|
reset() {
|
||
|
this.form = {
|
||
|
id: null,
|
||
|
name: null,
|
||
|
user: null,
|
||
|
phone: null,
|
||
|
address: null,
|
||
|
}
|
||
|
},
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style lang="scss">
|
||
|
.submit {
|
||
|
margin: 1vh 2.667vw;
|
||
|
}
|
||
|
|
||
|
.add {
|
||
|
background: #f6f6f6;
|
||
|
padding: 2.667vw;
|
||
|
height: 95vh;
|
||
|
|
||
|
.main {
|
||
|
background: #ffffff;
|
||
|
margin-bottom: 2.667vw;
|
||
|
padding: 2vw;
|
||
|
border-radius: 8px;
|
||
|
|
||
|
.u-form-item__body__right {
|
||
|
padding-left: 20vw;
|
||
|
}
|
||
|
|
||
|
.u-button {
|
||
|
border: none !important;
|
||
|
padding: 0 !important;
|
||
|
justify-content: flex-start;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</style>
|