|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<view class="">
|
|
|
- <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back" title="新增需求"
|
|
|
- @clickLeft="back">
|
|
|
+ <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back"
|
|
|
+ :title="title" @clickLeft="back">
|
|
|
</uni-nav-bar>
|
|
|
<u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection>
|
|
|
<u-cell-group v-show="current == 0">
|
|
|
@@ -14,50 +14,52 @@
|
|
|
</u-cell>
|
|
|
<u-cell title="需求名称" arrow-direction="down">
|
|
|
<view slot="value" style="display: flex;align-items: center;width: 100%;">
|
|
|
- <u--input style="flex:1" placeholder="请输入" border="surround" v-model="form.name">
|
|
|
+ <u--input style="flex:1" :disabled="!isDisable" placeholder="请输入" border="surround"
|
|
|
+ v-model="form.name">
|
|
|
</u--input>
|
|
|
</view>
|
|
|
</u-cell>
|
|
|
<u-cell title="客户名称" arrow-direction="down">
|
|
|
<view slot="value" style="display: flex;align-items: center;width: 100%;">
|
|
|
- <u--input style="flex:1" placeholder="请选择" border="surround" @click.native="selectContactShow"
|
|
|
- v-model="form.contactName">
|
|
|
+ <u--input :disabled="!isDisable" style="flex:1" placeholder="请选择" border="surround"
|
|
|
+ @click.native="selectContactShow" v-model="form.contactName">
|
|
|
</u--input>
|
|
|
</view>
|
|
|
</u-cell>
|
|
|
<u-cell title="发货单" arrow-direction="down">
|
|
|
<view slot="value" style="display: flex;align-items: center;width: 100%;">
|
|
|
- <u--input style="flex:1" placeholder="请选择" border="surround" @click.native="invoiceDialogOpen"
|
|
|
- v-model="form.orderCode">
|
|
|
+ <u--input :disabled="!isDisable" style="flex:1" placeholder="请选择" border="surround"
|
|
|
+ @click.native="invoiceDialogOpen" v-model="form.orderCode">
|
|
|
</u--input>
|
|
|
</view>
|
|
|
</u-cell>
|
|
|
<u-cell title="报修地址" arrow-direction="down">
|
|
|
<view slot="value" style="display: flex;align-items: center;width: 100%;">
|
|
|
- <u--input style="flex:1" placeholder="请输入" border="surround" v-model="form.contactAddress">
|
|
|
+ <u--input :disabled="!isDisable" style="flex:1" placeholder="请输入" border="surround"
|
|
|
+ v-model="form.contactAddress">
|
|
|
</u--input>
|
|
|
</view>
|
|
|
</u-cell>
|
|
|
<u-cell title="故障等级" arrow-direction="down">
|
|
|
- <uni-data-picker v-model="form.faultLevel" slot="value" placeholder="请选择" :localdata="fault_level"
|
|
|
- @change="sourceCodeOnchange">
|
|
|
+ <uni-data-picker :readonly="!isDisable" v-model="form.faultLevel" slot="value" placeholder="请选择"
|
|
|
+ :localdata="fault_level" @change="sourceCodeOnchange">
|
|
|
</uni-data-picker>
|
|
|
</u-cell>
|
|
|
<u-cell title="期望解决时间" arrow-direction="down">
|
|
|
- <uni-datetime-picker type="date" slot="value" v-model="form.expectedTime">
|
|
|
+ <uni-datetime-picker :disabled="!isDisable" type="date" slot="value" v-model="form.expectedTime">
|
|
|
</uni-datetime-picker>
|
|
|
</u-cell>
|
|
|
<u-cell title="报修人" arrow-direction="down">
|
|
|
<view slot="value" style="display: flex;align-items: center;width: 100%;">
|
|
|
- <u--input style="flex:1" placeholder="请输入" border="surround" v-model="form.repairName">
|
|
|
+ <u--input style="flex:1" placeholder="请输入" disabled border="surround" v-model="createUserName">
|
|
|
</u--input>
|
|
|
</view>
|
|
|
</u-cell>
|
|
|
</u-cell-group>
|
|
|
- <AfterSales ref="salesRef" v-show="current == 1" :itemList="form.tableList" />
|
|
|
+ <AfterSales ref="salesRef" :type="type" v-show="current == 1" :itemList="form.productDetail" />
|
|
|
<!-- 联系人 -->
|
|
|
- <ContactList ref="contactRef" v-show="current == 2" :itemList="form.contactInfoVOS" />
|
|
|
- <view class="footerButton">
|
|
|
+ <ContactList ref="contactRef" :type="type" v-show="current == 2" :itemList="form.contactInfoVOS" />
|
|
|
+ <view class="footerButton" v-if="isDisable">
|
|
|
<u-button type="default" text="返回" @click="back"></u-button>
|
|
|
<u-button type="primary" @click="save" text="保存"></u-button>
|
|
|
</view>
|
|
|
@@ -73,7 +75,9 @@
|
|
|
contactDetail
|
|
|
} from '@/api/saleManage/contact/index.js'
|
|
|
import {
|
|
|
- saveSalesDemand
|
|
|
+ saveSalesDemand,
|
|
|
+ updateSalesDemand,
|
|
|
+ getSalesDemandById
|
|
|
} from '@/api/salesServiceManagement/demandList/index.js'
|
|
|
import AfterSales from './components/AfterSales.vue'
|
|
|
import ContactList from './components/contactList.vue'
|
|
|
@@ -82,38 +86,55 @@
|
|
|
AfterSales,
|
|
|
ContactList
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ isDisable() {
|
|
|
+ let flag = this.type != 'view'
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
form: {
|
|
|
code: '',
|
|
|
name: '',
|
|
|
contactName: '',
|
|
|
- repairName: '',
|
|
|
expectedTime: '',
|
|
|
faultLevel: '',
|
|
|
contactAddress: '',
|
|
|
orderCode: '',
|
|
|
+ productDetail: [],
|
|
|
+ contactInfoVOS: [],
|
|
|
+ contactCode: '',
|
|
|
},
|
|
|
+ createUserName: '',
|
|
|
list: ['基本信息', '售后对象', '联系人'],
|
|
|
current: 0,
|
|
|
- fault_level: []
|
|
|
+ fault_level: [],
|
|
|
+ title: '新增需求',
|
|
|
+ type: 'add'
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- this.getByCode();
|
|
|
- const userInfo = uni.getStorageSync('userInfo');
|
|
|
- this.$set(this.form, 'repairName', userInfo.name);
|
|
|
+
|
|
|
},
|
|
|
- onLoad(data) {
|
|
|
+ onLoad(params) {
|
|
|
+ this.type = params.type;
|
|
|
+ if (params.id) {
|
|
|
+ this.title = params.type == 'view' ? '需求详情' : '修改需求'
|
|
|
+ this.getDetails(params.id);
|
|
|
+ } else {
|
|
|
+ const userInfo = uni.getStorageSync('userInfo');
|
|
|
+ this.createUserName = userInfo.name;
|
|
|
+ this.getByCode();
|
|
|
+ }
|
|
|
// 客户数据
|
|
|
uni.$off('setSelectList')
|
|
|
uni.$on('setSelectList', (data) => {
|
|
|
if (data && data.length > 0) {
|
|
|
let res = data[0]
|
|
|
- console.log(res, 'res')
|
|
|
this.$set(this.form, 'contactId', res.id);
|
|
|
this.$set(this.form, 'contactName', res.name);
|
|
|
- this.contactDetail(res.id);
|
|
|
+ this.contactDetail(res.id)
|
|
|
// this.$forceUpdate();
|
|
|
}
|
|
|
})
|
|
|
@@ -128,7 +149,7 @@
|
|
|
(el) =>
|
|
|
(el.measureQuantity = el.measureQuantity ? el.measureQuantity : 1)
|
|
|
);
|
|
|
- this.$set(this.form, 'tableList', list);
|
|
|
+ this.$set(this.form, 'productDetail', list);
|
|
|
})
|
|
|
},
|
|
|
onUnload() {
|
|
|
@@ -139,6 +160,36 @@
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 查询详情
|
|
|
+ async getDetails(id) {
|
|
|
+ this.getByCode();
|
|
|
+ const res = await getSalesDemandById(id);
|
|
|
+ // this.form.tableList = res.productDetail;
|
|
|
+ // this.form.contactInfoVOS = res.contactInfoVOS;
|
|
|
+ // this.form.code = res.code;
|
|
|
+ // this.form.contactName = res.contactName;
|
|
|
+ // this.form.contactCode = res.contactCode;
|
|
|
+ // this.form.contactId = res.contactId;
|
|
|
+ // this.form.contactAddress = res.contactAddress;
|
|
|
+ // this.form.expectedTime = res.expectedTime;
|
|
|
+ // this.createUserName = res.createUserName;
|
|
|
+ // this.form.orderCode = res.orderCode;
|
|
|
+ // this.form.orderId = res.orderId;
|
|
|
+ // this.form.name = res.name;
|
|
|
+ // this.form.createUserId = res.createUserId;
|
|
|
+ // this.form.id = res.id;
|
|
|
+ // this.form.processInstanceId = res.processInstanceId;
|
|
|
+ let data = JSON.parse(JSON.stringify(res));
|
|
|
+ this.form = data;
|
|
|
+ this.createUserName = data.createUserName;
|
|
|
+ let obj = this.fault_level.find(el => el.value == res.faultLevel)
|
|
|
+ this.sourceCodeOnchange({
|
|
|
+ "detail": {
|
|
|
+ "value": [obj]
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
sectionChange(index) {
|
|
|
this.current = index;
|
|
|
},
|
|
|
@@ -148,11 +199,11 @@
|
|
|
})
|
|
|
},
|
|
|
//客户回调
|
|
|
- async contactDetail(id, type) {
|
|
|
- if (!id) {
|
|
|
- this.contractInfo = {};
|
|
|
- return;
|
|
|
- }
|
|
|
+ async contactDetail(id) {
|
|
|
+ // if (!id) {
|
|
|
+ // this.contractInfo = {};
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
let {
|
|
|
base,
|
|
|
other,
|
|
|
@@ -168,7 +219,7 @@
|
|
|
}
|
|
|
// this.$set(this.form, 'contractInfo', base);
|
|
|
this.form.contactCode = base.code;
|
|
|
- if (type != 'init') {
|
|
|
+ if (this.type != 'view') {
|
|
|
this.$set(this.form, 'contactAddress', addressName);
|
|
|
this.$set(
|
|
|
this.form,
|
|
|
@@ -183,13 +234,13 @@
|
|
|
// 清空发货单的数据 *** 初次进来不清空
|
|
|
this.$set(this.form, 'orderCode', '');
|
|
|
this.$set(this.form, 'orderId', '');
|
|
|
- this.$set(this.form, 'tableList', []);
|
|
|
+ this.$set(this.form, 'productDetail', []);
|
|
|
}
|
|
|
},
|
|
|
sourceCodeOnchange(e) {
|
|
|
const value = e.detail.value;
|
|
|
this.form.faultLevel = value[0].value;
|
|
|
- console.log(value, '赋值')
|
|
|
+ console.log(e, '赋值')
|
|
|
// this.form.sourceCode = value.map(item => item.value).toString()
|
|
|
// this.form.sourceName = value.map(item => item.text).toString()
|
|
|
},
|
|
|
@@ -219,9 +270,7 @@
|
|
|
},
|
|
|
save() {
|
|
|
let data = JSON.parse(JSON.stringify(this.form));
|
|
|
- delete data.tableList;
|
|
|
- delete data.code;
|
|
|
- console.log(data, 'form ---')
|
|
|
+ delete data.productDetail;
|
|
|
try {
|
|
|
if (!data.name) {
|
|
|
this.$refs.uToast.show({
|
|
|
@@ -271,16 +320,26 @@
|
|
|
data.contactInfoVOS = contactInfoVOS;
|
|
|
// 售后对象数据
|
|
|
let productDetail = this.$refs.salesRef.getTabData();
|
|
|
- data.productDetail = productDetail;
|
|
|
- uni.showLoading({
|
|
|
- title: '加载中'
|
|
|
- })
|
|
|
- console.log(data, 'data');
|
|
|
- saveSalesDemand(data).then((res) => {
|
|
|
+ data.productDetail = productDetail.map((item) => {
|
|
|
+ item['produceTime'] = item['produceTime'] || null;
|
|
|
+ return item;
|
|
|
+ }),
|
|
|
+
|
|
|
+ uni.showLoading({
|
|
|
+ title: '加载中'
|
|
|
+ })
|
|
|
+
|
|
|
+ let requestname =
|
|
|
+ this.type === 'add' ? saveSalesDemand : updateSalesDemand;
|
|
|
+ requestname(data).then((res) => {
|
|
|
uni.hideLoading()
|
|
|
this.back()
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功",
|
|
|
+ })
|
|
|
}).catch((e) => {
|
|
|
- console.log(e,'报错了')
|
|
|
+ console.log(e, '报错了')
|
|
|
uni.hideLoading()
|
|
|
})
|
|
|
} catch (error) {
|