Commit e3da77db authored by Damon's avatar Damon

feat: 完工备件页增加搜索

parent 62a8ef21
<template> <template>
<view class="u-flex det-wrap"> <view class="u-flex det-wrap">
<view class="search">
<u-search
:clearabled="true"
:action-style="searchStyle"
bg-color="#fff"
v-model="keyword"
@custom="searchParts"
@search="searchParts"
></u-search>
</view>
<view class="content" v-if="lists.length > 0"> <view class="content" v-if="lists.length > 0">
<scroll-view style="height: 100%;" scroll-y="true"> <scroll-view style="height: 100%;" scroll-y="true">
<select-parts <select-parts
...@@ -39,15 +50,16 @@ ...@@ -39,15 +50,16 @@
</template> </template>
<script> <script>
import selectParts from "@/components/select-parts/index" import selectParts from '@/components/select-parts/index'
import submitBar from "@/components/submit-bar/index" import submitBar from '@/components/submit-bar/index'
export default { export default {
components: { components: {
selectParts, selectParts,
submitBar submitBar,
}, },
data() { data() {
return { return {
keyword: '',
lists: [], lists: [],
workOrderId: null, workOrderId: null,
} }
...@@ -55,18 +67,33 @@ ...@@ -55,18 +67,33 @@
computed: { computed: {
// 配件数 // 配件数
partNum() { partNum() {
return this.lists.reduce((counter, { checked }) => checked ? counter += 1 : counter, 0) return this.lists.reduce(
(counter, { checked }) => (checked ? (counter += 1) : counter),
0
)
}, },
// 总数 // 总数
num() { num() {
return this.lists.reduce((counter, { checked, quantity }) => checked ? counter += quantity : counter, 0) return this.lists.reduce(
(counter, { checked, quantity }) =>
checked ? (counter += quantity) : counter,
0
)
}, },
// 全选状态 // 全选状态
allChecked() { allChecked() {
const count = this.lists.reduce((counter, { checked }) => !checked ? counter += 1 : counter, 0) const count = this.lists.reduce(
(counter, { checked }) => (!checked ? (counter += 1) : counter),
0
)
return count === 0 || false return count === 0 || false
},
searchStyle() {
return {
color: '#2272FF',
} }
}, },
},
onLoad(e) { onLoad(e) {
this.workOrderId = parseInt(e.workOrderId) this.workOrderId = parseInt(e.workOrderId)
this.categoryId = parseInt(e.categoryId) this.categoryId = parseInt(e.categoryId)
...@@ -75,10 +102,16 @@ ...@@ -75,10 +102,16 @@
}, },
methods: { methods: {
getReserve() { getReserve() {
this.$u.api.getMyReserve({'categoryId': this.categoryId, 'brandId': this.brandId}).then(res => { this.$u.api
.getMyReserve({
categoryId: this.categoryId,
brandId: this.brandId,
keyword: this.keyword,
})
.then((res) => {
if (res.code === 200) { if (res.code === 200) {
const data = res.data || [] const data = res.data || []
this.lists = data.map(v => { this.lists = data.map((v) => {
v.min = 1 v.min = 1
v.max = v.stock v.max = v.stock
v.checked = false v.checked = false
...@@ -90,6 +123,12 @@ ...@@ -90,6 +123,12 @@
} }
}) })
}, },
// 搜索配件
searchParts(val) {
this.keyword = val
this.lists = []
this.getReserve()
},
numChange(val, index) { numChange(val, index) {
this.$set(this.lists[index], 'quantity', val) this.$set(this.lists[index], 'quantity', val)
}, },
...@@ -97,42 +136,44 @@ ...@@ -97,42 +136,44 @@
this.$set(this.lists[index], 'checked', val) this.$set(this.lists[index], 'checked', val)
}, },
allSelect(value) { allSelect(value) {
const count = this.lists.filter(v => !v.checked).length const count = this.lists.filter((v) => !v.checked).length
this.lists.forEach(v => { this.lists.forEach((v) => {
this.$set(v, 'checked', count !== 0 || false) this.$set(v, 'checked', count !== 0 || false)
}) })
}, },
submit() { submit() {
const lists = this.lists.filter(v => v.checked).map(v => { const lists = this.lists
.filter((v) => v.checked)
.map((v) => {
return { return {
name: v.name, name: v.name,
part_id: v.skuId, part_id: v.skuId,
quantity: v.quantity, quantity: v.quantity,
max: v.max, max: v.max,
cost: v.cost || 0 cost: v.cost || 0,
} }
}) })
let pages = getCurrentPages(); let pages = getCurrentPages()
let prevPage = pages[pages.length - 2]; //上一个页面 let prevPage = pages[pages.length - 2] //上一个页面
prevPage.$vm.$refs['fileChildParts'][0].valChange(lists) prevPage.$vm.$refs['fileChildParts'][0].valChange(lists)
this.$u.route({ type: 'back' }) this.$u.route({ type: 'back' })
}, },
cancel() { cancel() {
let pages = getCurrentPages(); let pages = getCurrentPages()
let prevPage = pages[pages.length - 2]; //上一个页面 let prevPage = pages[pages.length - 2] //上一个页面
prevPage.$vm.$refs['fileChildParts'][0].valChange() prevPage.$vm.$refs['fileChildParts'][0].valChange()
this.$u.route({ type: 'back' }) this.$u.route({ type: 'back' })
}, },
qnFile(src) { qnFile(src) {
return process.uniEnv.qn_base_url + src return process.uniEnv.qn_base_url + src
} },
} },
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.det-wrap { .det-wrap {
flex-flow: column; flex-flow: column;
height: 100vh; height: 100vh;
.search { .search {
...@@ -149,7 +190,7 @@ ...@@ -149,7 +190,7 @@
} }
.bar { .bar {
width: 100%; width: 100%;
border-top: 1px solid #F4F5F7; border-top: 1px solid #f4f5f7;
padding: 0 20rpx; padding: 0 20rpx;
background: #fff; background: #fff;
} }
...@@ -159,5 +200,5 @@ ...@@ -159,5 +200,5 @@
font-size: 26rpx; font-size: 26rpx;
color: #aaa; color: #aaa;
} }
} }
</style> </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