Commit 4a214a0d authored by Facius's avatar Facius

Merge branch 'dev' of https://git.banshouhui.com/lijundan/self-support into dev

parents e586886f 19fcf432
let partsApiFun = function(vm){
let partsApiFun = function (vm) {
// 接口公共前缀
const prefix = '/wxh-worker-rest/rest/'
const coverage = '/wxh-worker-rest/rest/coverage/'
const coverage = '/wxh-worker-rest/rest/coverage/'
const parts = '/wxh-worker-rest/rest/parts/'
const base = '/wxh-worker-rest/rest/base/'
const formType = {'content-type': 'application/x-www-form-urlencoded'}
/**
* 配件申请单-查询网点地址信息
*/
let getSiteAddress = async () => await vm.$u.get(coverage + vm.vuex_token + '/getSiteAddress');
/**
* 配件申请单-修改网点地址信息
*/
let updateAddress = async (params = {}) => await vm.$u.post(coverage + vm.vuex_token + '/updateSiteAddress', params, formType);
/**
* 配件过滤-品类列表
*/
......@@ -17,24 +22,31 @@ let partsApiFun = function(vm){
* 配件过滤-品牌列表
*/
let getBrandList = async (params = {}) => await vm.$u.get(base + vm.vuex_token + '/allow/brand/list', params);
/**
* 查询配件列表
*/
/**
* 查询配件列表
*/
let getPartsList = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/parts', params);
/**
* 查询自己的备件仓
* 配件申请单-创建申请单/使用备件
*/
let applyParts = async (params = {}) => await vm.$u.post(parts + vm.vuex_token + '/orders', params)
/**
* 查询自己的备件仓
*/
let getMyReserve = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/items/reserve', params);
const partsApi = {
getSiteAddress,
updateAddress,
getCategoryList,
getBrandList,
getPartsList,
applyParts,
getMyReserve
}
return partsApi
}
module.exports = {
module.exports = {
partsApiFun
}
\ No newline at end of file
......@@ -30,7 +30,7 @@ export default {
info: {
type: Object,
default() {
return {name: '', mobile: '', address: ''};
return {name: '', mobile: '', address: '', region: []};
}
},
isDefault: {
......@@ -73,8 +73,13 @@ export default {
let address = this.info && this.info.address;
if (this.$u.test.isEmpty(address)) {
return '--';
} else {
}
let region = this.info && this.info.region;
let regionStr = region.join('');
if(this.$u.test.contains(address, regionStr)) {
return address;
} else {
return regionStr + address;
}
}
},
......
......@@ -535,7 +535,16 @@
"navigationBarTitleText": "配件选择"
}
}
]
,{
"path" : "nodes",
"style" :
{
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#FFFFFF",
"enablePullDownRefresh": false
}
}
]
}
],
"preloadRule": {
......
......@@ -31,7 +31,7 @@
<view class="list-view">
<view v-for="(group, ind) in items" :key="ind" class="group-view">
<u-cell-group :border="false">
<view v-for="(item, index) in group" :key="index.pathName">
<view v-for="(item, index) in group" :key="index">
<u-cell-item :value="item.value" :border-bottom="false" @click="handleClick(item.pathName)">
<image slot="icon" :src="qnFile(item.icon)" :style="item.imageStyle"></image>
<view slot="title" class="item-title">{{item.title}}</view>
......
......@@ -8,7 +8,7 @@
</view>
<view class="item">
<view class="left">电话号码</view>
<input :disabled="mobileStatus" v-model="mobile" type="text" placeholder-class="line" placeholder="请填写收货人手机号" />
<input :disabled="mobileStatus" v-model="mobile" type="text" @blur="verifyMobile" placeholder-class="line" placeholder="请填写收货人手机号" />
</view>
<view class="item">
......@@ -29,7 +29,8 @@
></u-field>
</view>
<view class="bottom">
<button class="btn, bottom-btn" @click="show = true"><text class="button-text">保存</text></button>
<button class="btn, bottom-btn" v-if="siteType=='select'" @click="$u.throttle(commitSite, 500)"><text class="button-text">提交</text></button>
<button class="btn, bottom-btn" v-else @click="show = true"><text class="button-text">保存</text></button>
<!-- <view class="default">
<view class="left">
<view class="set">设置默认地址</view>
......@@ -101,7 +102,6 @@ export default {
if (!this.vuex_token) {
this.$u.route({ url: 'pages/login/index' });
}
debugger
if (e) {
if (e.type === 'add') {
this.title = '新增地址';
......@@ -120,13 +120,19 @@ export default {
if(e.mobile) {
this.mobile = decodeURIComponent(e.mobile);
}
if(e.address) {
this.address = decodeURIComponent(e.address);
}
if(e.region) {
let regionStr = decodeURIComponent(e.region);
this.region = regionStr.split('-')
}
if(e.address) {
let address = decodeURIComponent(e.address);
let region = this.region.join('')
if(this.$u.test.contains(address, region)) {
this.address = address.replace(region, '')
} else {
this.address = address
}
}
}
},
onShow() {
......@@ -138,34 +144,44 @@ export default {
this.nameStatus = false;
this.mobileStatus = false;
} else if (this.siteType == 'edit') {
let address = '';
if (this.$u.test.isEmpty(this.siteInfo)) {
if (this.$u.test.isEmpty(this.name)
|| this.$u.test.isEmpty(this.mobile)) {
const callback = (vm, res) => {
this.settled = res.record;
if (this.loading) {
this.name = this.settled.id_card_name;
this.mobile = this.settled.mobile;
this.address = this.settled.address;
this.geocoding();
}
this.loading = this.$u.test.isEmpty(this.settled);
this.name = this.settled.id_card_name;
this.mobile = this.settled.mobile;
};
if (this.vuex_settled && this.vuex_settled.record) {
callback(this, this.vuex_settled);
} else {
getApp().getBaseInfo(this, callback);
}
} else {
if (this.loading) {
this.loading = false;
this.name = this.siteInfo.name;
this.mobile = this.siteInfo.mobile;
this.address = this.siteInfo.address;
this.geocoding();
}
}
if (this.$u.test.isEmpty(this.region)
|| this.$u.test.isEmpty(this.address)) {
}
}
},
loadMineAddress() {
this.$u.api.getSiteAddress().then((res) => {
if(res.code == 200 && res.data) {
this.region = [
res.data.provinceName,
res.data.cityName,
res.data.districtName
]
let address = res.data.address
const regionStr = this.region.join('')
if(this.$u.test.contains(address, regionStr)) {
this.address = address.replace(regionStr, '')
} else {
this.address = address
}
}
})
},
showRegionPicker() {
this.showPicker = true;
},
......@@ -234,23 +250,54 @@ export default {
});
},
verifyMobile() {
if(this.$u.test.isEmpty(this.mobile)) {
this.$u.toast('电话号码不能为空')
return false
} else if(!this.$u.test.mobile(this.mobile)) {
this.$u.toast('电话号码格式错误')
return false
}
return true
},
validateForm() {
if(this.$u.test.isEmpty(this.name)) {
this.$u.toast('收货人姓名不能为空')
return false
}
if(!this.verifyMobile()) {
return false
}
if(this.$u.test.isEmpty(this.region)) {
this.$u.toast('所在地区不能为空')
return false
}
if(this.$u.test.isEmpty(this.address)) {
this.$u.toast('详细地址不能为空')
return false
}
return true
},
async submitForm() {
if(!this.validateForm()) {
return false
}
if (this.siteType === 'add') {
} else if (this.siteType === 'select') {
this.commitSite()
} else if (this.siteType === 'edit') {
if (this.$u.test.isEmpty(this.siteInfo)) {
let params = {
type: this.type,
updateFlag: true,
provinceName: this.region[0],
cityName: this.region[1],
districtName: this.region[2],
address: this.region.join("") + this.address
};
let res = await this.$u.api.syncAddress(params);
const callback = (vm, res) => {
let res = await this.$u.api.updateAddress(params);
if (res && res.code == 200) {
this.$u.route({ type: 'back' });
this.show = false
};
if (res && res.code == 200) {
getApp().getBaseInfo(this, callback);
}
} else {
......@@ -258,6 +305,9 @@ export default {
}
},
commitSite() {
if(!this.validateForm()) {
return false
}
// 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
var pages = getCurrentPages();
var prevPage = pages[pages.length - 2]; //上一个页面
......
......@@ -2,7 +2,7 @@
<view class="address-wrap">
<w-navbar title="收货地址"></w-navbar>
<view class="body" v-if="hasAdderss">
<w-address @editSite="toAddSite" :info="address" :is-default="true" />
<w-address @editSite="toAddSite" :info="addressInfo" :is-default="true" />
</view>
</view>
</template>
......@@ -15,6 +15,8 @@ export default {
background: {
backgroundColor: 'none'
},
address: '',
region: [],
siteList: []
};
},
......@@ -26,13 +28,17 @@ export default {
return this.vuex_settled && this.vuex_settled.record || null
},
hasAdderss() {
return this.settled && this.settled.address && this.settled.id_card_name
return this.settled && this.address && this.settled.id_card_name
},
address() {
settledName() {
return this.settled.id_card_name || this.settled.nickname || this.settled.name
},
addressInfo() {
return {
name: this.settled.id_card_name || this.settled.nickname || this.settled.name,
name: this.settledName,
mobile: this.settled.mobile,
address: this.settled.address
address: this.address,
region: this.region || [],
}
}
},
......@@ -43,20 +49,38 @@ export default {
if(!this.vuex_token) {
this.$u.route({url: 'pages/login/index'})
} else if(!this.settled) {
this.getData();
app.getBaseInfo(this);
}
this.getData();
},
methods: {
getData() {
let self = this
app.getBaseInfo(self);
this.getMineSite()
},
getMineSite() {
this.$u.api.getSiteAddress().then((res) => {
if(res.code == 200 && res.data) {
this.address = res.data.address
this.region = [
res.data.provinceName,
res.data.cityName,
res.data.districtName
]
}
})
},
toAddSite(title){
const info = this.addressInfo
const region = this.region.join('-')
this.$u.route({
url: 'pages/mine/address/addSite',
// params: {
// title: title
// }
params: {
type: 'edit',
name: info.name,
mobile: info.mobile,
region: region,
address: info.address
}
})
}
}
......
......@@ -6,8 +6,9 @@
<view class="title" v-if="isEmptyParts">配件信息</view>
<view class="u-flex u-row-between title" v-else>
<view>选择配件</view>
<u-icon name="arrow-right" size="24" color="#2272FF" @click="$u.throttle(addParts, 500)"
label="添加配件" label-pos="left" label-color="#2272FF" label-size="26"/>
<u-icon name="arrow-right" size="24" color="#2272FF"
@click="$u.throttle(addParts, 500)" label="添加配件"
label-pos="left" label-color="#2272FF" label-size="26"/>
</view>
<view class="body">
<view v-if="isEmptyParts" class="u-flex-col u-col-center list">
......@@ -30,14 +31,13 @@
</view>
<view class="card address">
<view class="title">收件信息</view>
<view class="subsection u-flex u-row-center">
<view class="subsection">
<u-subsection
:list="siteTypes" :current="curType"
:bold="false" font-size="26" height="76"
active-color="#FFFFFF" inactive-color="#333333"
bg-color="#FFFFFF" button-color="#2272FF"
@change="typeChange"
></u-subsection>
@change="typeChange" />
</view>
<view class="body">
<w-address :info="addressInfo" @editSite="editSite" />
......@@ -45,7 +45,9 @@
</view>
</view>
<view class="bottom">
<u-button shape="circle" :disabled="disabled" :hair-line="false" :custom-style="customStyle" hover-class="none">提交</u-button>
<u-button shape="circle" :disabled="isEmptyParts"
:hair-line="false" :custom-style="customStyle"
hover-class="none" @click="submitParts">提交</u-button>
</view>
</view>
</template>
......@@ -59,6 +61,7 @@ export default {
data() {
return {
orderId: 0,
applyType: 0,
order: {},
parts: [],
disabled: false,
......@@ -93,16 +96,21 @@ export default {
},
onLoad(e) {
this.orderId = e && Number(e.orderId) || 0
this.applyType = e && Number(e.applyType) || 0
this.initData()
},
methods: {
initData() {
this.loadMineAddress()
this.loadOrderInfo()
this.parts = [
{name: '正泰漏保', num: 2},
{name: '电缆VJV3*10', num: 1},
{name: '挚达系统广汽充电桩', num: 0},
{name: '空开盒子', num: 100}
]
},
loadMineAddress() {
this.mine.address = "广东省深圳市宝安区宝城67区留芳路6号庭威产业园3栋10C"
this.mine.region = ['广东省', '深圳市', '宝安区']
this.$u.api.getSiteAddress().then((res) => {
if(res.code == 200 && res.data) {
this.mine.address = res.data.address
......@@ -126,40 +134,22 @@ export default {
},
initCustomer() {
if(this.$u.test.isEmpty(this.order)) {
this.customer = {}
this.customer = {name: '', mobile: '', address: '', region: []}
} else {
// this.mine.name = this.order.maintainWorkerName
// this.mine.mobile = this.order.maintainWorkerPhone
this.mine.name = '王先生'
this.mine.mobile = '13045861456'
const region = [
this.order.contactProvinceText,
this.order.contactCityText,
this.order.contactCommunityText,
]
let address = region.join("") + (this.order.contactStreetText || '') + this.order.contactAddress
this.mine.name = this.order.maintainWorkerName
this.mine.mobile = this.order.maintainWorkerPhone
this.customer = {
name: this.order.contactName,
mobile: this.order.contactPhone,
address: address,
region: region,
code: [
this.order.contactProvince,
this.order.contactCity,
this.order.contactCommunity,
]
address: this.order.contactAddress,
region: [
this.order.contactProvinceText,
this.order.contactCityText,
this.order.contactCommunityText,
],
}
}
},
loadParts() {
this.parts = [
{name: '正泰漏保', num: 2},
{name: '电缆VJV3*10', num: 1},
{name: '挚达系统广汽充电桩', num: 0},
{name: '空开盒子', num: 100}
]
},
qnFile(src) {
return process.uniEnv.qn_base_url + src
},
......@@ -167,23 +157,15 @@ export default {
this.curType = index
},
editSite() {
let region = this.addressInfo.region.join('')
let address = this.addressInfo.address
if(this.$u.test.contains(address, region)) {
address = address.replace(region, '')
}
let params = {
type: 'select',
name: this.addressInfo.name,
mobile: this.addressInfo.mobile,
address: address,
region: this.addressInfo.region.join('-'),
code: this.addressInfo.code && this.addressInfo.code.join('-'),
};
console.log("editSite", params)
this.$u.route({
url: "pages/mine/address/addSite",
params: params
params: {
type: 'select',
name: this.addressInfo.name,
mobile: this.addressInfo.mobile,
address: this.addressInfo.address,
region: this.addressInfo.region.join('-'),
}
})
},
updateSite(site) {
......@@ -198,6 +180,60 @@ export default {
url: "pages/parts/addParts"
})
},
updateParts(parts) {
if(this.$u.test.isEmpty(parts)) {
this.parts = []
} else {
this.parts = parts
}
},
/**
* workOrderId 工单ID,保内申请时必须指定
* applyType 申请类型:0 保内,1 备件,2 购买,10 使用备件
* remark 申请备注
* parts 申请的配件明细,JSON 格式,指定多条要申请的配件信息,
* 数组中的每个对象需要 part_id(配件ID)和 quantity(申请数量)两个字段。
* 如果没有选择明细,请保持空。此时必须填写备注
* barcode 产品条码
* measures 服务措施
* name 收件人姓名
* phoneNumber 收件人电话号码
* province 收件地址:省
* city 收件地址:市
* district 收件地址:区
* street 收件地址:街道
* address 收件详细地址
* images 申请图片文件、可以传多张
*/
submitParts() {
const address = this.addressInfo
let params = {
workOrderId: this.orderId,
applyType: this.applyType,
remark: this.remark,
parts: JSON.stringty(parts),
barcode: this.order.barcode,
measures: this.order.measures,
name: address.name,
phoneNumber: address.mobile,
province: address.region[0],
city: address.region[1],
district: address.region[2],
address: address.address,
}
this.$u.api.applyParts(params).then((res) => {
if (res.code == 200) {
this.$u.route({
url: "pages/parts/nodes"
})
} else {
console.log(res.message, "配件申请失败!");
}
});
this.$u.route({
url: "pages/parts/nodes"
})
}
}
};
</script>
......@@ -259,20 +295,18 @@ export default {
}
.address {
.subsection {
padding-top: -6rpx;
padding-bottom: 34rpx;
border-bottom: 2rpx solid #F4F5F7;
// /deep/ .u-subsection {
// width: 372rpx;
// .u-item-bg {
// border-radius: 32rpx !important;
// }
// }
margin: -6rpx 0 34rpx 0;
padding: 0 129rpx;
/deep/ .u-subsection {
.u-item-bg {
border-radius: 32rpx !important;
}
}
}
.body {
border-top: 2rpx solid #F4F5F7;
padding-top: 10rpx;
padding-bottom: 52rpx;
}
}
}
......@@ -281,6 +315,10 @@ export default {
left: 76rpx;
right: 76rpx;
bottom: 68rpx;
/deep/ button[disabled]:not([type]) {
background-color: #D1D4D4 !important;
}
}
}
</style>
<template>
<view class="u-flex-col u-col-center node-wrap">
<u-gap height="200"></u-gap>
<u-image width="224rpx" height="224rpx" :src="qnFile(nodeInfo.icon)"></u-image>
<view class="title">{{nodeInfo.title}}</view>
<view v-show="isReturn" class="return">
<u-divider color="#F4F5F7" half-width="345" margin-top="30" :use-slot="false"></u-divider>
<view class="return-title u-text-center">返件编号</view>
<view class="u-flex u-row-between return-row">
<view class="return-no">{{returnNo}}</view>
<view class="vertical-bar"></view>
<button class="copy-btn" @tap="copyText" :data-text="returnNo">复制</button>
</view>
</view>
<view class="message">{{nodeInfo.message}}</view>
<u-gap v-show="isParts" height="192"></u-gap>
<u-gap v-show="isReturn" height="160"></u-gap>
<button class="back-btn" @click="goBack">{{nodeInfo.btnTxt}}</button>
</view>
</template>
<script>
export default {
data() {
return {
curType: 0,
returnNo: 'RT20210610000001',
nodes: [
{
type: 'parts',
icon: 'successful.png',
title: '您的配件申请已提交成功',
message: '工作人员正在加紧审核中',
btnTxt: '我知道了'
},
{
type: 'return',
icon: 'successful.png',
title: '您的返件信息已提交成功',
message: '请将返件编号复制发给唯修汇对接人',
btnTxt: '我知道了'
}
]
}
},
computed: {
nodeInfo() {
return this.nodes[this.curType]
},
isReturn() {
return this.nodes[this.curType].type == 'return'
},
isParts() {
return this.nodes[this.curType].type == 'parts'
}
},
methods: {
qnFile(src) {
return process.uniEnv.qn_base_url + src
},
goBack() {
this.$u.route({type:'back'})
},
copyText(e) {
console.log(e)
uni.setClipboardData({
data: e.currentTarget.dataset.text,
success: function (res) {
uni.getClipboardData({
success: function (res) {
uni.showToast({
title: '复制成功'
})
}
})
}
})
},
}
}
</script>
<style lang="scss" scoped>
.node-wrap {
width: 750rpx;
height: 100vh;
overflow: auto;
background-color: #FFFFFF;
.title {
font-size: 40rpx;
font-weight: bold;
color: #2272FF;
line-height: 40rpx;
margin-bottom: 30rpx;
}
.return {
.return-title {
margin-top: 60rpx;
font-size: 40rpx;
font-weight: bold;
color: #333333;
}
.return-row {
margin: 52rpx 38rpx;
.return-no {
font-size: 40rpx;
font-weight: 500;
color: #2272FF;
line-height: 60rpx;
}
.vertical-bar {
width: 4rpx;
height: 60rpx;
background: #F4F5F7;
}
.copy-btn {
width: 120rpx;
height: 48rpx;
border-radius: 24rpx;
border: 2rpx solid #999999;
font-size: 26rpx;
font-weight: 400;
color: #999999;
line-height: 48rpx;
margin: 0;
}
}
}
.message {
font-size: 26rpx;
font-weight: 400;
color: #999999;
line-height: 26rpx;
}
.back-btn {
width: 400rpx;
height: 104rpx;
background: #2272FF;
border-radius: 52rpx;
font-size: 32rpx;
font-weight: 600;
color: #FFFFFF;
line-height: 104rpx;
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment