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.
515 lines
11 KiB
515 lines
11 KiB
<template>
|
|
<view class="addRecord">
|
|
<navbar title="创建工单" :isCenter="true" :back="true" :toIndex="false"></navbar>
|
|
<view style="border-top:1px solid #EAEAEA;padding:25rpx">
|
|
<u--form
|
|
labelPosition="left"
|
|
:model="form"
|
|
:borderBottom="true"
|
|
:rules="rules"
|
|
ref="uForm"
|
|
labelWidth="150"
|
|
|
|
>
|
|
<u-form-item
|
|
:borderBottom="true"
|
|
label="条形码编码:"
|
|
prop="barcode"
|
|
|
|
ref="item1"
|
|
>
|
|
<u--input
|
|
placeholder="请输入内容"
|
|
border="none"
|
|
|
|
v-model="form.barcode"
|
|
></u--input>
|
|
</u-form-item>
|
|
<u-form-item
|
|
:borderBottom="true"
|
|
label="代理商编码:"
|
|
prop="agent_number"
|
|
|
|
ref="item2"
|
|
>
|
|
<u--input
|
|
placeholder="请输入内容"
|
|
border="none"
|
|
:disabled="true"
|
|
v-model="form.agent_number"
|
|
></u--input>
|
|
</u-form-item>
|
|
<u-form-item
|
|
:borderBottom="true"
|
|
label="代理商:"
|
|
prop="agent_company_name"
|
|
|
|
ref="item2"
|
|
>
|
|
<u--input
|
|
placeholder="请输入内容"
|
|
border="none"
|
|
:disabled="true"
|
|
v-model="form.agent_company_name"
|
|
></u--input>
|
|
</u-form-item>
|
|
<u-form-item
|
|
label="产品类型:"
|
|
prop="product_type_name"
|
|
@click="setClickItem(1)"
|
|
ref="item3"
|
|
:borderBottom="true"
|
|
>
|
|
<view class="selectStyle">
|
|
<u--input
|
|
v-model="form.product_type_name"
|
|
disabled
|
|
disabledColor="#ffffff"
|
|
placeholder="请选择"
|
|
border="none"
|
|
></u--input>
|
|
<u-icon
|
|
slot="right"
|
|
name="arrow-down"
|
|
></u-icon>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item
|
|
label="产品型号:"
|
|
prop="product_pattern_name"
|
|
@click="setClickItem(2)"
|
|
ref="item4"
|
|
:disabled="form.product_type?false:true"
|
|
:borderBottom="true"
|
|
>
|
|
<view class="selectStyle">
|
|
<u--input
|
|
v-model="form.product_pattern_name"
|
|
disabled
|
|
disabledColor="#ffffff"
|
|
placeholder="请选择"
|
|
border="none"
|
|
></u--input>
|
|
<u-icon
|
|
slot="right"
|
|
name="arrow-down"
|
|
></u-icon>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item
|
|
label="系统类型:"
|
|
prop="pressure_type_name"
|
|
@click="setClickItem(3)"
|
|
ref="item5"
|
|
:borderBottom="true"
|
|
>
|
|
<view class="selectStyle">
|
|
<u--input
|
|
v-model="form.pressure_type_name"
|
|
disabled
|
|
disabledColor="#ffffff"
|
|
placeholder="请选择"
|
|
border="none"
|
|
></u--input>
|
|
<u-icon
|
|
slot="right"
|
|
name="arrow-down"
|
|
></u-icon>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item
|
|
:borderBottom="true"
|
|
label="产品数量:"
|
|
prop="product_num_old"
|
|
@click="setClickItem(4)"
|
|
:disabled="true"
|
|
ref="item2"
|
|
>
|
|
<u--input
|
|
v-model="form.product_num_old"
|
|
disabled
|
|
disabledColor="#ffffff"
|
|
placeholder="请选择"
|
|
border="none"
|
|
></u--input>
|
|
<u-icon
|
|
slot="right"
|
|
name="arrow-down"
|
|
></u-icon>
|
|
<!-- <u--input
|
|
placeholder="请输入数量"
|
|
border="none"
|
|
v-model="form.product_num"
|
|
></u--input> -->
|
|
</u-form-item>
|
|
<u-form-item
|
|
:borderBottom="true"
|
|
label="代理商定位地址:"
|
|
prop="agent_address"
|
|
:disabled="true"
|
|
ref="item1"
|
|
>
|
|
|
|
<u--input
|
|
placeholder="代理商定位"
|
|
border="none"
|
|
suffixIconStyle="color: #909399"
|
|
v-model="form.agent_address"
|
|
></u--input>
|
|
|
|
</u-form-item>
|
|
<u-form-item
|
|
:borderBottom="true"
|
|
label="条形码编码2:"
|
|
prop="barcode2"
|
|
@click="getCode(2)"
|
|
|
|
ref="item1"
|
|
>
|
|
|
|
<u--input
|
|
placeholder="点击扫码录入"
|
|
suffixIcon="scan"
|
|
border="none"
|
|
suffixIconStyle="color: #909399"
|
|
v-model="form.barcode2"
|
|
></u--input>
|
|
<!-- <u--input
|
|
placeholder="点击扫码录入"
|
|
border="surround"
|
|
|
|
>
|
|
<view class="inputDesc" slot="suffix" >
|
|
<image src="../../static/saoyis.png" mode="" class="icon"></image>
|
|
|
|
</view>
|
|
</u--input> -->
|
|
</u-form-item>
|
|
|
|
<u-form-item
|
|
:borderBottom="true"
|
|
label="条形码编码3:"
|
|
prop="barcode3"
|
|
|
|
@click="getCode(3)"
|
|
ref="item1"
|
|
>
|
|
<u--input
|
|
placeholder="点击扫码录入"
|
|
suffixIcon="scan"
|
|
border="none"
|
|
|
|
suffixIconStyle="color: #909399"
|
|
v-model="form.barcode3"
|
|
></u--input>
|
|
</u-form-item>
|
|
</u--form>
|
|
<view class="btn" @click="addLogHandle">
|
|
保存
|
|
</view>
|
|
</view>
|
|
<u-action-sheet
|
|
:show="showoption"
|
|
:actions="actions"
|
|
@close="showoption = false"
|
|
@select="selectHandle"
|
|
>
|
|
</u-action-sheet>
|
|
<u-toast ref="uToast"></u-toast>
|
|
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import navbar from '@/components/navbar.vue'
|
|
import {getProType,addOrderHandle,getSetting} from '@/common/api.js'
|
|
import {getAgentInfo} from '@/common/auth.js'
|
|
export default {
|
|
onBackPress(e) {
|
|
// 这里可以自定义返回逻辑,比如下面跳转其他页面
|
|
uni.switchTab({
|
|
url: '/pages/index/index'
|
|
});
|
|
// return true 表示禁止默认返回
|
|
return true
|
|
},
|
|
components:{navbar},
|
|
data() {
|
|
return {
|
|
form:{
|
|
barcode:'',
|
|
barcode2:'',
|
|
barcode3:'',
|
|
agent_number:'',
|
|
agent_company_name:'',
|
|
product_type:null,
|
|
product_type_name:'',
|
|
product_pattern:null,
|
|
product_pattern_name:'',
|
|
product_num:null,
|
|
product_num_old:null,
|
|
pressure_type:null,
|
|
pressure_type_name:'',
|
|
agent_address:""
|
|
},
|
|
typeList:[],
|
|
actions:[],
|
|
rules: {
|
|
'barcode': {
|
|
type: 'string',
|
|
required: true,
|
|
message: '请填写条形码编码',
|
|
trigger: ['blur', 'change']
|
|
},
|
|
'agent_company_name': {
|
|
type: 'string',
|
|
required: true,
|
|
message: '请填写代理商',
|
|
trigger: ['blur', 'change']
|
|
},
|
|
'agent_number':{
|
|
required: true,
|
|
message: '请填写代理商编码',
|
|
trigger: ['blur', 'change']
|
|
},
|
|
'product_type_name': {
|
|
required: true,
|
|
message: '请选择产品类型',
|
|
trigger: ['blur', 'change']
|
|
},
|
|
'product_pattern_name': {
|
|
required: true,
|
|
message: '请选择产品型号',
|
|
trigger: ['blur', 'change']
|
|
},
|
|
'product_num': {
|
|
required: true,
|
|
message: '请填写产品数量',
|
|
trigger: ['blur', 'change']
|
|
},
|
|
'pressure_type_name':{
|
|
required: true,
|
|
message: '请填写系统类型',
|
|
trigger: ['blur', 'change']
|
|
}
|
|
|
|
},
|
|
showoption: false,
|
|
typeIndex:null,
|
|
pressure_type_list:[],
|
|
numList:[],
|
|
}
|
|
},
|
|
onLoad(option) {
|
|
|
|
this.form.barcode = option.barcode;
|
|
|
|
this.getProType()
|
|
this.getSetting()
|
|
this.getPosition()
|
|
},
|
|
onShow() {
|
|
let agentInfo = getAgentInfo();
|
|
console.log(agentInfo,"缓存中取出")
|
|
this.form.agent_number= agentInfo.number;
|
|
this.form.agent_company_name= agentInfo.name
|
|
},
|
|
onUnload: function () {
|
|
uni.reLaunch({
|
|
url: '../index/index', //指定url
|
|
})
|
|
},
|
|
methods: {
|
|
getPosition(){
|
|
console.log("=====")
|
|
uni.getFuzzyLocation({
|
|
type: 'wgs84',
|
|
success:(res)=> {
|
|
const latitude = res.latitude
|
|
const longitude = res.longitude
|
|
console.log(res,"iiiii");
|
|
this.getLocationInfo(longitude,latitude)
|
|
}
|
|
})
|
|
},
|
|
//逆坐标解析
|
|
async getLocationInfo(longitude,latitude) {
|
|
console.log(longitude,latitude);
|
|
uni.request({
|
|
url: `https://restapi.amap.com/v3/geocode/regeo?location=${longitude},${latitude}&key=${this.MAP_KEY}`,
|
|
success:(res)=> {
|
|
console.log(res);
|
|
if(res.data.status=="1"){
|
|
this.form.agent_address =
|
|
res.data.regeocode.addressComponent.country+
|
|
res.data.regeocode.addressComponent.province+
|
|
res.data.regeocode.addressComponent.district+
|
|
res.data.regeocode.addressComponent.township
|
|
}
|
|
}
|
|
});
|
|
|
|
},
|
|
//获取产品类型和型号
|
|
getProType(){
|
|
getProType({custom: { auth: true }}).then(res=>{
|
|
console.log(res,"99999")
|
|
this.typeList=res.data;
|
|
this.actions = this.typeList
|
|
})
|
|
},
|
|
getSetting(){
|
|
getSetting().then(res=>{
|
|
for(let i in res.data.pressure_type){
|
|
this.pressure_type_list.push({name:res.data.pressure_type[i]})
|
|
}
|
|
for(let i in res.data.product_num){
|
|
this.numList.push({name:res.data.product_num[i]})
|
|
}
|
|
})
|
|
},
|
|
getCode(val){
|
|
console.log(val,"====")
|
|
uni.scanCode({
|
|
success:(res)=> {
|
|
console.log(res,"成功")
|
|
if(res.result){
|
|
if(val==2){
|
|
this.form.barcode2 = res.result
|
|
}else{
|
|
this.form.barcode3 = res.result
|
|
}
|
|
|
|
}
|
|
},
|
|
fail:(res)=> { // 取消操作后的回调 跳转到小程序首页
|
|
uni.switchTab({
|
|
url:'/pages/index/index'
|
|
})
|
|
console.log(res,"失败")
|
|
}
|
|
});
|
|
},
|
|
setClickItem(val){
|
|
this.typeIndex = val;
|
|
if(val==1){
|
|
this.actions = this.typeList
|
|
}else if(val==2){
|
|
let arr = this.typeList.filter(item=>{
|
|
return item.id==this.form.product_type
|
|
})
|
|
this.actions = arr[0].children;
|
|
}else if(val==3){
|
|
this.actions = this.pressure_type_list
|
|
}else{
|
|
this.actions = this.numList
|
|
}
|
|
this.showoption = true;
|
|
},
|
|
selectHandle(val){
|
|
console.log(val)
|
|
if(this.typeIndex==1){
|
|
let arr = this.typeList.filter(item=>{
|
|
return item.id==val.id
|
|
})
|
|
this.form.product_type = val.id;
|
|
this.form.product_type_name = val.name
|
|
this.form.product_pattern = null;
|
|
this.form.product_pattern_name = '';
|
|
this.showoption = false;
|
|
this.actions = arr[0].children;
|
|
}
|
|
if(this.typeIndex==2){
|
|
this.form.product_pattern = val.id;
|
|
this.form.product_pattern_name = val.name;
|
|
this.showoption = false;
|
|
}
|
|
if(this.typeIndex==3){
|
|
this.form.pressure_type = val.id;
|
|
this.form.pressure_type_name = val.name;
|
|
this.showoption = false;
|
|
}
|
|
if(this.typeIndex==4){
|
|
console.log(val.name)
|
|
this.form.product_num_old = val.name
|
|
if(val.name=="3及以上"){
|
|
this.form.product_num = 3
|
|
}else{
|
|
this.form.product_num = val.name
|
|
}
|
|
this.showoption = false;
|
|
}
|
|
|
|
},
|
|
addLogHandle(){
|
|
this.$refs.uForm.validate().then(res => {
|
|
// uni.$u.toast('校验通过')
|
|
addOrderHandle(this.form).then(res=>{
|
|
console.log(res)
|
|
uni.$u.toast(res.msg);
|
|
uni.switchTab({
|
|
url:'/pages/index/index'
|
|
})
|
|
}).catch(res=>{
|
|
uni.$u.toast(res.msg);
|
|
// setTimeout(()=>{
|
|
// uni.switchTab({
|
|
// url:'/pages/index/index'
|
|
// })
|
|
// },2000)
|
|
|
|
})
|
|
}).catch(errors => {
|
|
uni.$u.toast('校验失败')
|
|
})
|
|
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
/deep/.u-form-item__body{
|
|
flex-direction: column !important;
|
|
}
|
|
.inputDesc{
|
|
.icon{
|
|
width:44rpx;
|
|
height:44rpx;
|
|
}
|
|
}
|
|
.addRecord{
|
|
min-height: calc(100vh);
|
|
background-color: #ffffff;
|
|
|
|
}
|
|
.btn{
|
|
line-height: 98rpx;
|
|
height: 98rpx;
|
|
background: #8EC31F;
|
|
border-radius: 10px;
|
|
// margin:0 24rpx;
|
|
text-align: center;
|
|
font-size: 30rpx;
|
|
font-family: Alibaba PuHuiTi;
|
|
font-weight: 400;
|
|
color: #FFFFFF;
|
|
margin-top:80rpx;
|
|
}
|
|
.selectStyle{
|
|
display: flex;
|
|
// padding: 30rpx;
|
|
background: #FFFFFF;
|
|
// border: 1px solid #E5E7EA;
|
|
border-radius: 10rpx;
|
|
}
|
|
/deep/.u-form-item__body__left__content__label{
|
|
margin-bottom:33rpx;
|
|
}
|
|
/deep/.u-form-item__body__right__message{
|
|
margin-left:0 !important;
|
|
}
|
|
/deep/.u-input{
|
|
background:#ffffff !important;
|
|
}
|
|
</style>
|
|
|