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.

152 lines
3.4 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-item label="备注信息" prop="remark" labelWidth="auto" borderBottom ref="item1">
<u--textarea v-model="form.remark" 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,
remark: 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/addSupplier', this.form)
if (res.code == 0) {
uni.showToast({
title: '添加供应商成功',
icon: 'success'
});
this.reset();
// 设备添加完成返回 设备列表页面
wx.switchTab({
url: 'supplierList',
})
}else{
// 添加失败
uni.showToast({
title: "添加供应商失败",
icon: 'error'
})
}
},
async updateCustomer() {
},
reset() {
this.form = {
id: null,
name: null,
user: null,
phone: null,
address: null,
remark: 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>