Commit e3da77db authored by Damon's avatar Damon

feat: 完工备件页增加搜索

parent 62a8ef21
<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">
<scroll-view style="height: 100%;" scroll-y="true">
<select-parts
v-for="(item, index) in lists"
v-for="(item, index) in lists"
:key="index"
:info="item"
:show-checked="true"
......@@ -23,7 +34,7 @@
</view>
<view class="bar" v-if="lists.length > 0">
<submit-bar
<submit-bar
:partNum="partNum"
:num="num"
:btnStatus="partNum > 0"
......@@ -35,50 +46,72 @@
@cancel="cancel"
/>
</view>
</view>
</view>
</template>
<script>
import selectParts from "@/components/select-parts/index"
import submitBar from "@/components/submit-bar/index"
export default {
components: {
selectParts,
submitBar
import selectParts from '@/components/select-parts/index'
import submitBar from '@/components/submit-bar/index'
export default {
components: {
selectParts,
submitBar,
},
data() {
return {
keyword: '',
lists: [],
workOrderId: null,
}
},
computed: {
// 配件数
partNum() {
return this.lists.reduce(
(counter, { checked }) => (checked ? (counter += 1) : counter),
0
)
},
data() {
return {
lists: [],
workOrderId: null,
}
// 总数
num() {
return this.lists.reduce(
(counter, { checked, quantity }) =>
checked ? (counter += quantity) : counter,
0
)
},
computed: {
// 配件数
partNum() {
return this.lists.reduce((counter, { checked }) => checked ? counter += 1 : counter, 0)
},
// 总数
num() {
return this.lists.reduce((counter, { checked, quantity }) => checked ? counter += quantity : counter, 0)
},
// 全选状态
allChecked() {
const count = this.lists.reduce((counter, { checked }) => !checked ? counter += 1 : counter, 0)
return count === 0 || false
}
// 全选状态
allChecked() {
const count = this.lists.reduce(
(counter, { checked }) => (!checked ? (counter += 1) : counter),
0
)
return count === 0 || false
},
onLoad(e) {
this.workOrderId = parseInt(e.workOrderId)
this.categoryId = parseInt(e.categoryId)
this.brandId = parseInt(e.brandId)
this.getReserve()
searchStyle() {
return {
color: '#2272FF',
}
},
methods: {
getReserve() {
this.$u.api.getMyReserve({'categoryId': this.categoryId, 'brandId': this.brandId}).then(res => {
},
onLoad(e) {
this.workOrderId = parseInt(e.workOrderId)
this.categoryId = parseInt(e.categoryId)
this.brandId = parseInt(e.brandId)
this.getReserve()
},
methods: {
getReserve() {
this.$u.api
.getMyReserve({
categoryId: this.categoryId,
brandId: this.brandId,
keyword: this.keyword,
})
.then((res) => {
if (res.code === 200) {
const data = res.data || []
this.lists = data.map(v => {
this.lists = data.map((v) => {
v.min = 1
v.max = v.stock
v.checked = false
......@@ -89,75 +122,83 @@
})
}
})
},
numChange(val, index) {
this.$set(this.lists[index], 'quantity', val)
},
selectChange(val, index) {
this.$set(this.lists[index], 'checked', val)
},
allSelect(value) {
const count = this.lists.filter(v => !v.checked).length
this.lists.forEach(v => {
this.$set(v, 'checked', count !== 0 || false)
})
},
submit() {
const lists = this.lists.filter(v => v.checked).map(v => {
},
// 搜索配件
searchParts(val) {
this.keyword = val
this.lists = []
this.getReserve()
},
numChange(val, index) {
this.$set(this.lists[index], 'quantity', val)
},
selectChange(val, index) {
this.$set(this.lists[index], 'checked', val)
},
allSelect(value) {
const count = this.lists.filter((v) => !v.checked).length
this.lists.forEach((v) => {
this.$set(v, 'checked', count !== 0 || false)
})
},
submit() {
const lists = this.lists
.filter((v) => v.checked)
.map((v) => {
return {
name: v.name,
part_id: v.skuId,
quantity: v.quantity,
max: v.max,
cost: v.cost || 0
cost: v.cost || 0,
}
})
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; //上一个页面
prevPage.$vm.$refs['fileChildParts'][0].valChange(lists)
this.$u.route({ type: 'back' })
},
cancel() {
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; //上一个页面
prevPage.$vm.$refs['fileChildParts'][0].valChange()
this.$u.route({ type: 'back' })
},
qnFile(src) {
return process.uniEnv.qn_base_url + src
}
}
}
let pages = getCurrentPages()
let prevPage = pages[pages.length - 2] //上一个页面
prevPage.$vm.$refs['fileChildParts'][0].valChange(lists)
this.$u.route({ type: 'back' })
},
cancel() {
let pages = getCurrentPages()
let prevPage = pages[pages.length - 2] //上一个页面
prevPage.$vm.$refs['fileChildParts'][0].valChange()
this.$u.route({ type: 'back' })
},
qnFile(src) {
return process.uniEnv.qn_base_url + src
},
},
}
</script>
<style lang="scss" scoped>
.det-wrap {
flex-flow: column;
height: 100vh;
.search {
width: 100%;
padding: 30rpx;
}
.content {
background: #fff;
border-radius: 30rpx 30rpx 0 0;
padding: 10rpx 10rpx 0 10rpx;
width: 100%;
flex: 1;
overflow-y: auto;
}
.bar {
width: 100%;
border-top: 1px solid #F4F5F7;
padding: 0 20rpx;
background: #fff;
}
.empty {
flex: 1;
justify-content: center;
font-size: 26rpx;
color: #aaa;
}
.det-wrap {
flex-flow: column;
height: 100vh;
.search {
width: 100%;
padding: 30rpx;
}
.content {
background: #fff;
border-radius: 30rpx 30rpx 0 0;
padding: 10rpx 10rpx 0 10rpx;
width: 100%;
flex: 1;
overflow-y: auto;
}
.bar {
width: 100%;
border-top: 1px solid #f4f5f7;
padding: 0 20rpx;
background: #fff;
}
.empty {
flex: 1;
justify-content: center;
font-size: 26rpx;
color: #aaa;
}
}
</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