Commit 041f5d9e authored by Facius's avatar Facius

feat: 创建维修账单

parent af61fda6
Pipeline #2889 canceled with stages
......@@ -8,11 +8,11 @@
<view class="title-view">
<view>{{ info.id }}</view>
<view class="status-view"
><text :style="'color:' + statusSetting[info.settleState].color">{{
statusSetting[info.settleState].text
><text :style="'color:' + statusSetting[info.settleState.code].color">{{
statusSetting[info.settleState.code].text
}}</text
>·<text :style="'color:' + statusSetting[info.sendStatus].color">{{
statusSetting[info.sendStatus].text
>·<text :style="'color:' + statusSetting[info.sendStatus.code].color">{{
statusSetting[info.sendStatus.code].text
}}</text></view
>
</view>
......
......@@ -27,7 +27,7 @@
<view class="item-view">
<view class="label-view">数量</view>
<view class="value-view">
<u-number-box color="#cccccc" size="28" v-model="number" bg-color="#ffffff"></u-number-box>
<u-number-box min="1" color="#cccccc" size="28" v-model="number" bg-color="#ffffff"></u-number-box>
</view>
</view>
<view class="line-view"></view>
......@@ -40,7 +40,7 @@
:clearable="false"
:custom-style="customStyle"
:placeholder-style="placeholderStyle"
v-model="price"
v-model="unitPrice"
placeholder="填写单价费用"
/>
</view>
......@@ -54,7 +54,7 @@
:clearable="false"
:custom-style="customStyle"
:placeholder-style="placeholderStyle"
v-model="all"
v-model="total"
placeholder="填写总价费用"
/>
</view>
......@@ -81,26 +81,28 @@ export default {
return {
name: '',
number: '',
price: '',
all: '',
unitPrice: '',
total: '',
}
},
watch: {
showDelete(val) {
console.log('------showDelete------', val)
},
name(value) {
this.handleChange('name', value)
this.handleChange({'name': value})
},
number(value) {
this.handleChange('number', value)
if (this.unitPrice && this.number) {
this.total = this.formatCount(Number(this.unitPrice) * Number(this.number))
}
this.handleChange({'number': value})
},
price(value) {
this.handleChange('price', value)
unitPrice(value) {
if (this.unitPrice && this.number) {
this.total = this.formatCount(Number(this.unitPrice) * Number(this.number))
}
this.handleChange({'unitPrice': value})
},
all(value) {
this.handleChange('all', value)
total(value) {
this.handleChange({'total': value})
},
},
computed: {
......@@ -117,19 +119,21 @@ export default {
},
created() {
this.name = this.defaultInfo.name
this.price = this.defaultInfo.price
this.unitPrice = this.formatCount(this.defaultInfo.unitPrice)
this.number = this.defaultInfo.number
this.all = this.defaultInfo.all
this.total = this.formatCount(this.defaultInfo.total)
},
methods: {
handleChange(key, value) {
this.$emit('change', { key: key, value: value })
handleChange(obj) {
this.$emit('change', obj)
},
handleClickDelete() {
console.log('(-----handleClickDelete-----)')
this.$emit('delete')
},
formatCount(count) {
return (Math.trunc((count || 0) * 100) / 100).toFixed(2)
},
},
}
</script>
......
......@@ -147,6 +147,7 @@
:custom-style="customConFirm"
@click="handleClickSure"
:disabled="!canConfirm"
:loading="buttonLoading"
>
<view class="confirm-view">确定</view>
</u-button>
......@@ -193,10 +194,7 @@ export default {
},
showDatePicker: false,
showTimePicker: false,
defaultTime: this.$u.timeFormat(
new Date().getTime(),
'yyyy-mm-dd hh:MM:ss'
),
buttonLoading: false,
}
},
computed: {
......@@ -305,18 +303,21 @@ export default {
},
onLoad(options) {
// 测试数据
options.billId = '9988'
options.billId = '1550685581418168320'
if (options && options.billId) {
this.billId = options.billId
this.repairDetail()
}
if (this.billId) {
this.repairDetail()
}
},
onReady() {
this.$refs.uForm.setRules(this.rules)
},
onUnload() {},
onShow() {},
onShow() {
},
methods: {
repairDetail() {
this.loading = true
......@@ -331,52 +332,52 @@ export default {
})
.catch((res) => {
this.loading = false
// 测试数据
this.setForm(res.data)
})
},
setForm(data) {
// 测试
var data = {
id: '8778788',
settleState: 'NO',
sendStatus: 'WAIT',
customer: {
name: '张三',
phone: '1231312313423',
},
repairTime: '2077-87-87 12:23:43',
actualAmount: '40',
receivableAmount: '80',
address: 'fdsafdsafdasfdafd发撒发大水范德萨范德萨范德萨发大水发',
remark: '维修格力牌柜机一台,更换压缩机收费800\nfdsadfsafdasfads',
attach: [
'http://reu2asz23.hn-bkt.clouddn.com/icon%2Fbeizhutu%403x.png',
'http://reu2asz23.hn-bkt.clouddn.com/icon/wuweixiuzhangdan@3x.png',
'http://reu2asz23.hn-bkt.clouddn.com/icon/wusousuojieguo@3x.png',
],
histories: [
{
createTime: '2099-98-76 09:09:87',
type: 'SETTLE',
},
{
createTime: '2099-98-76 09:09:87',
type: 'ENSURE',
},
{
createTime: '2099-98-76 09:09:87',
type: 'SEND',
},
{
createTime: '2099-98-76 09:09:87',
type: 'CREATE',
},
],
syncFlag: false,
}
// var data = {
// id: '8778788',
// settleState: 'NO',
// sendStatus: 'WAIT',
// customer: {
// name: '张三',
// phone: '1231312313423',
// },
// repairTime: '2022-07-07 12:23:43',
// actualAmount: '40',
// receivableAmount: '80',
// address: '详细地址:广东省深圳市',
// remark: '维修格力牌柜机一台,更换压缩机收费800\nfdsadfsafdasfads',
// attach: [
// 'http://reu2asz23.hn-bkt.clouddn.com/icon%2Fbeizhutu%403x.png',
// 'http://reu2asz23.hn-bkt.clouddn.com/icon/wuweixiuzhangdan@3x.png',
// 'http://reu2asz23.hn-bkt.clouddn.com/icon/wusousuojieguo@3x.png',
// ],
// histories: [
// {
// createTime: '2099-98-76 09:09:87',
// type: 'SETTLE',
// },
// {
// createTime: '2099-98-76 09:09:87',
// type: 'ENSURE',
// },
// {
// createTime: '2099-98-76 09:09:87',
// type: 'SEND',
// },
// {
// createTime: '2099-98-76 09:09:87',
// type: 'CREATE',
// },
// ],
// syncFlag: false,
// latitude: '22.55329',
// longitude: '113.88308'
// }
this.form = {
id: data.id,
customerName: data.customer.name,
customerPhone: data.customer.phone,
receivableAmount: data.receivableAmount,
......@@ -384,8 +385,8 @@ export default {
repairTime: data.repairTime,
partTime: data.partTime,
address: data.address,
latitude: '',
longitude: '',
latitude: data.latitude,
longitude: data.longitude,
remark: data.remark,
attach: data.attach,
}
......@@ -437,12 +438,24 @@ export default {
})
},
editeRepair() {
this.buttonLoading = true
editeRepair(this.form).then((res)=> {
if (res.code == 0) {
this.billId = res.data
this.toParticulars()
this.buttonLoading = false
}
}).catch((res)=> {
this.buttonLoading = false
})
},
toParticulars() {
this.$u.route({
url: 'pages/maintain-bill/particulars',
type: 'navigateTo',
params: {
billId: this.billId,
},
})
},
formatCount(count) {
......
......@@ -9,11 +9,11 @@
/>
<view class="content-view">
<view class="status-view"
><text :style="'color:' + statusSetting[info.settleState].color">{{
statusSetting[info.settleState].text
><text :style="'color:' + statusSetting[info.settleState.code].color">{{
statusSetting[info.settleState.code].text
}}</text
>·<text :style="'color:' + statusSetting[info.sendStatus].color">{{
statusSetting[info.sendStatus].text
>·<text :style="'color:' + statusSetting[info.sendStatus.code].color">{{
statusSetting[info.sendStatus.code].text
}}</text></view
>
<view class="info-view part-view">
......@@ -102,7 +102,12 @@
</view>
</view>
<view class="right-view">
<u-button :custom-style="customStatus" @click="handleClickStatus" :disabled="info.syncFlag" class="status-button">
<u-button
:custom-style="customStatus"
@click="handleClickStatus"
:disabled="info.syncFlag"
class="status-button"
>
<view
class="status-view"
:style="'color: ' + syncFlagSettings.color"
......@@ -168,7 +173,7 @@ export default {
return this.baseUrl + 'huishouye@3x.png'
},
isSure() {
return this.info.sendStatus == 'SURE'
return this.info.sendStatus.code == 'SURE'
},
// sendStatus WAIT:未发送;WAIT_SURE:未确定;SURE:已确定
// settleState NO:未结清;YES:已结清
......@@ -192,7 +197,7 @@ export default {
}
},
settleState() {
return this.info.settleState == 'YES'
return this.info.settleState.code == 'YES'
},
moneyKeys() {
var result =
......@@ -235,26 +240,26 @@ export default {
popInfos() {
return [
{
title: '删除提醒',
isSelect: true,
confirmText: '删除',
content: '确认删除账单吗?',
bottomTip: '同时删除关联的账单明细',
},
title: '删除提醒',
isSelect: true,
confirmText: '删除',
content: '确认删除账单吗?',
bottomTip: '同时删除关联的账单明细',
},
{
title: '操作提醒',
isSelect: false,
confirmText: '确定',
content: '确认将该账单标记为已结清?',
bottomTip: '',
},
{
title: '操作提醒',
isSelect: false,
confirmText: '确定',
content: '是否将该账单转入账单明细统计?',
bottomTip: '',
}
title: '操作提醒',
isSelect: false,
confirmText: '确定',
content: '确认将该账单标记为已结清?',
bottomTip: '',
},
{
title: '操作提醒',
isSelect: false,
confirmText: '确定',
content: '是否将该账单转入账单明细统计?',
bottomTip: '',
},
]
},
currentPopInfo() {
......@@ -295,7 +300,9 @@ export default {
height: '104rpx',
'border-radius': '16rpx',
width: this.isSure ? '372rpx' : '240rpx',
background: this.isSure ? '' : 'linear-gradient(100deg, transparent 32rpx, #02a074 0)',
background: this.isSure
? ''
: 'linear-gradient(100deg, transparent 32rpx, #02a074 0)',
}
},
// CREATE:创建账单;SEND:发送客户;ENSURE:客户确认;SETTLE:标记为已结清
......@@ -313,7 +320,7 @@ export default {
this.billId = options.billId
}
// 测试数据
this.billId = '8786788'
this.billId = '1550685581418168320'
uni.$on('maintain-bill-detail', (res) => {
this.repairDetail()
......@@ -340,50 +347,10 @@ export default {
if (res.data) {
this.info = res.data
}
this.loading = false
this.loading = false
})
.catch((res) => {
this.loading = false
// 测试数据
this.info = {
id: '8778788',
settleState: 'NO',
sendStatus: 'WAIT',
customer: {
name: '张三',
phone: '1231312313423',
},
repairTime: '2077-87-87 12:23:43',
actualAmount: '40',
receivableAmount: '80',
address: 'fdsafdsafdasfdafd发撒发大水范德萨范德萨范德萨发大水发',
remark: '维修格力牌柜机一台,更换压缩机收费800\nfdsadfsafdasfads',
attach: [
'http://reu2asz23.hn-bkt.clouddn.com/icon%2Fbeizhutu%403x.png',
'http://reu2asz23.hn-bkt.clouddn.com/icon/wuweixiuzhangdan@3x.png',
'http://reu2asz23.hn-bkt.clouddn.com/icon/wusousuojieguo@3x.png',
],
histories: [
{
createTime: '2099-98-76 09:09:87',
type: 'SETTLE',
},
{
createTime: '2099-98-76 09:09:87',
type: 'ENSURE',
},
{
createTime: '2099-98-76 09:09:87',
type: 'SEND',
},
{
createTime: '2099-98-76 09:09:87',
type: 'CREATE',
},
],
syncFlag: false,
}
})
},
......@@ -418,7 +385,6 @@ export default {
})
},
handleClickChange() {
console.log('--------handleClickChange---------')
this.$u.route({
url: 'pages/maintain-bill/create',
type: 'navigateTo',
......@@ -432,12 +398,11 @@ export default {
// 删除账单
} else if (this.current == 1) {
// 标记为已结清
} else if (this.current == 2) {
} else if (this.current == 2) {
// 同步账单
}
},
handleClickPreview(index) {
console.log('-------handleClickPreview-------', index, this.info.attach)
uni.previewImage({
urls: this.info.attach,
current: index,
......
......@@ -230,72 +230,72 @@ export default {
onlyDebt: this.onlyDebt,
})
.then((res) => {
// let data = res.data
let data = res.data
// 测试
let data = {
records: [
{
id: '878788',
settleState: 'YES',
sendStatus: 'WAIT',
customerName: '张三',
customerPhone: '14141241413',
repairTime: '2077-87-87 12:23:43',
actualAmount: '20',
receivableAmount: '80',
},
{
id: '8783788',
settleState: 'NO',
sendStatus: 'SURE',
customerName: '张三',
customerPhone: '14141241413',
repairTime: '2077-87-87 12:23:43',
actualAmount: '80',
receivableAmount: '80',
},
{
id: '8787488',
settleState: 'NO',
sendStatus: 'WAIT',
customerName: '张三',
customerPhone: '14141241413',
repairTime: '2077-87-87 12:23:43',
actualAmount: '20',
receivableAmount: '80',
},
{
id: '8785788',
settleState: 'YES',
sendStatus: 'SURE',
customerName: '张三',
customerPhone: '14141241413',
repairTime: '2077-87-87 12:23:43',
actualAmount: '80',
receivableAmount: '80',
},
{
id: '8786788',
settleState: 'YES',
sendStatus: 'WAIT_SURE',
customerName: '张三',
customerPhone: '14141241413',
repairTime: '2077-87-87 12:23:43',
actualAmount: '20',
receivableAmount: '80',
},
{
id: '8778788',
settleState: 'NO',
sendStatus: 'WAIT',
customerName: '张三',
customerPhone: '14141241413',
repairTime: '2077-87-87 12:23:43',
actualAmount: '80',
receivableAmount: '80',
},
],
}
// let data = {
// records: [
// {
// id: '878788',
// settleState: 'YES',
// sendStatus: 'WAIT',
// customerName: '张三',
// customerPhone: '14141241413',
// repairTime: '2077-87-87 12:23:43',
// actualAmount: '20',
// receivableAmount: '80',
// },
// {
// id: '8783788',
// settleState: 'NO',
// sendStatus: 'SURE',
// customerName: '张三',
// customerPhone: '14141241413',
// repairTime: '2077-87-87 12:23:43',
// actualAmount: '80',
// receivableAmount: '80',
// },
// {
// id: '8787488',
// settleState: 'NO',
// sendStatus: 'WAIT',
// customerName: '张三',
// customerPhone: '14141241413',
// repairTime: '2077-87-87 12:23:43',
// actualAmount: '20',
// receivableAmount: '80',
// },
// {
// id: '8785788',
// settleState: 'YES',
// sendStatus: 'SURE',
// customerName: '张三',
// customerPhone: '14141241413',
// repairTime: '2077-87-87 12:23:43',
// actualAmount: '80',
// receivableAmount: '80',
// },
// {
// id: '8786788',
// settleState: 'YES',
// sendStatus: 'WAIT_SURE',
// customerName: '张三',
// customerPhone: '14141241413',
// repairTime: '2077-87-87 12:23:43',
// actualAmount: '20',
// receivableAmount: '80',
// },
// {
// id: '8778788',
// settleState: 'NO',
// sendStatus: 'WAIT',
// customerName: '张三',
// customerPhone: '14141241413',
// repairTime: '2077-87-87 12:23:43',
// actualAmount: '80',
// receivableAmount: '80',
// },
// ],
// }
if (this.current == 1) {
this.records = []
}
......
......@@ -32,7 +32,7 @@
:clearable="false"
:custom-style="customStyle"
:placeholder-style="placeholderStyle"
v-model="price"
v-model="info.faultRecord.category"
placeholder="填写品牌名称"
/>
</view>
......@@ -42,11 +42,11 @@
<view class="label-view">型号</view>
<view class="value-view">
<u-input
type="digit"
type="text"
:clearable="false"
:custom-style="customStyle"
:placeholder-style="placeholderStyle"
v-model="all"
v-model="info.faultRecord.machineModel"
placeholder="填写型号名称"
/>
</view>
......@@ -61,7 +61,7 @@
:clearable="false"
:custom-style="customAreaStyle"
:placeholder-style="placeholderStyle"
v-model="form.phone"
v-model="info.faultRecord.symptom"
placeholder="填写故障现象详细信息"
/>
</view>
......@@ -76,14 +76,14 @@
:clearable="false"
:custom-style="customAreaStyle"
:placeholder-style="placeholderStyle"
v-model="form.phone"
v-model="info.faultRecord.repairResult"
placeholder="填写检修结果详细信息"
/>
</view>
</view>
</view>
<view class="list-view">
<view v-for="(item, index) in list" :key="index">
<view v-for="(item, index) in info.expenseDetails" :key="index">
<CellParticulars
:showDelete="showDeleteButton"
:defaultInfo="item"
......@@ -114,6 +114,7 @@
:custom-style="customConFirm"
@click="handleClickSure"
:disabled="!canConfirm"
:loading="buttonLoading"
>
<view class="confirm-view">保存</view>
</u-button>
......@@ -134,6 +135,7 @@
import NavbarRight from '@/components/navbar-right'
import CellParticulars from '@/components/cell-particular'
import PopNormal from '@/components/pop-normal'
import { repairDetail, editeRepair } from '@/api/maintain/index.js'
export default {
components: {
......@@ -143,19 +145,16 @@ export default {
},
data() {
return {
billId: '',
visible: false,
info: {},
list: [
{
name: 'a',
number: '1',
price: '2',
all: '3',
},
],
info: {
expenseDetails: [],
faultRecord: null,
},
showRecord: false,
canConfirm: false,
currentIndex: 0,
buttonLoading: false,
faultRecord: {}, // 存储临时值
}
},
computed: {
......@@ -177,7 +176,7 @@ export default {
}
},
showDeleteButton() {
return this.list.length > 1
return this.info.expenseDetails.length > 1
},
placeholderStyle() {
return 'color:#ccc;font-size:28rpx;font-weight: bold;'
......@@ -199,35 +198,113 @@ export default {
'border-radius': '16rpx',
}
},
canConfirm() {
for (var item of this.info.expenseDetails) {
for (var key of this.expenseDetailsKeys) {
if (!item[key]) {
return false
}
}
}
if (this.info.faultRecord) {
for (var key of this.faultRecordKeys) {
console.log(key, this.info.faultRecord[key])
if (!this.info.faultRecord[key]) {
return false
}
}
}
return true
},
expenseDetailsKeys() {
return ['name', 'number', 'unitPrice', 'total']
},
faultRecordKeys() {
return ['category', 'machineModel', 'repairResult', 'symptom']
},
},
onLoad(options) {
// 测试数据
options.billId = '1550685581418168320'
if (options && options.billId) {
this.billId = options.billId
}
if (this.billId) {
this.repairDetail()
}
},
onLoad(options) {},
onReady() {},
onUnload() {},
onShow() {},
onShow() {
},
methods: {
repairDetail() {
this.loading = true
repairDetail({
id: this.billId,
})
.then((res) => {
if (res.data) {
this.setInfo(res.data)
}
this.loading = false
})
.catch((res) => {
this.loading = false
})
},
setInfo(data) {
var array =
data.expenseDetails && data.expenseDetails.length > 0
? data.expenseDetails
: [{ repairRecordId: data.id }]
this.info = {
id: data.id,
expenseDetails: array,
faultRecord: data.faultRecord,
// 上一页的数据
customerName: data.customer.name,
customerPhone: data.customer.phone,
receivableAmount: data.receivableAmount,
actualAmount: data.actualAmount,
repairTime: data.repairTime,
partTime: data.partTime,
address: data.address,
latitude: data.latitude,
longitude: data.longitude,
remark: data.remark,
attach: data.attach,
}
this.faultRecord = data.faultRecord || {
category: '',
machineModel: '',
repairResult: '',
symptom: '',
repairRecordId: data.id,
}
this.showRecord = this.info.faultRecord != null
},
handleChangeShowRecord(event) {
this.showRecord = event.value
this.showRecord = event
this.info.faultRecord = this.showRecord ? this.faultRecord : null
},
handleChange(event, index) {
this.list[index][event.key] = event.value
for (var item of this.list) {
for (var key in item) {
if (!this.list[index][key]) {
this.canConfirm = false
return
}
}
}
this.canConfirm = true
this.$set(this.info.expenseDetails, index, {
...this.info.expenseDetails[index],
...event,
})
},
handleClickAdd() {
this.list = [
...this.list,
this.info.expenseDetails = [
...this.info.expenseDetails,
{
repairRecordId: this.billId,
name: '',
number: '',
price: '',
all: '',
number: '1',
unitPrice: '',
total: '',
},
]
},
......@@ -238,14 +315,40 @@ export default {
handleClickConfirm() {
this.list.splice(this.currentIndex, 1)
},
handleClickSkip(date) {},
handleClickSure() {},
editeRepair() {
this.buttonLoading = true
editeRepair(this.info)
.then((res) => {
if (res.code == 0) {
this.toDetailPage()
this.buttonLoading = false
}
})
.catch((res) => {
this.buttonLoading = false
})
},
toDetailPage() {
this.$u.route({
url: 'pages/maintain-bill/detail',
type: 'navigateTo',
params: {
billId: this.billId,
},
})
},
handleClickSkip(date) {
this.toDetailPage()
},
handleClickSure() {
this.editeRepair()
},
},
}
</script>
<style scoped lang="scss">
.maintain-particulars {
/deep/.u-number-input {
/deep/.u-number-input {
color: #333333 !important;
font-weight: bold;
}
......@@ -292,7 +395,7 @@ export default {
align-items: center;
font-size: 28rpx;
&.one-line {
padding: 8rpx 0;
padding: 8rpx 0;
}
.label-view {
color: #8d8d8d;
......
......@@ -310,6 +310,7 @@ export default {
type: 'switchTab',
})
},
init() {
this.loading = false
this.info = {
......
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