emis-app/components/buns-goodinfo-sheet/buns-goodinfo-sheet.vue
2024-05-10 09:25:24 +08:00

293 lines
8.5 KiB
Vue

<template>
<tpx-dialog :show="show" title="编辑货物信息" @onClose="handleCloseModal()">
<view style="position: relative;height: calc(70vh);">
<tpx-layout>
<template v-slot:body>
<view class="dt-block">
<view class="dt-tle">
<view class="com-section">热门物品</view>
</view>
<view class="dt-cont">
<view class="dt-block mt-10">
<tpx-tags v-model:value="checkedGoodId" type="single" :list="hotGoods" @onChange="handleChooseGood"></tpx-tags>
</view>
</view>
</view>
<view class="dt-block" style="margin-top: 50rpx;">
<view class="dt-tle">
<view class="com-section">物品信息</view>
<view>
<!-- <u-button custom-style="font-size: 28rpx;height: 56rpx;border-radius: 16rpx;" plain="true" type="primary">选择历史</u-button> -->
</view>
</view>
<view class="dt-cont">
<view class="edm-input-item">
<tpx-select v-model:value="checkedGoodId" v-model:resObject="goodsRes" :getListFun="getGoodsList" :transKeyVal="{valKey: 'goodsName',titleKey: 'goodsName'}"
mode="drop"
:searchParam="goodsSearchParam" @onChange="handleChooseGood"
>
<u-input placeholder="物品名称" v-model="modelInfo.goodsName" font-size="26"
custom-style="border-radius: 30rpx;padding: 10rpx 20rpx;"
placeholder-style="color: #999; "
></u-input>
</tpx-select>
</view>
<view class="edm-input-item">
<tpx-text-item label="物品数量">
<template v-slot:right>
<u-input placeholder="请填写" v-model="modelInfo.cargoQty" inputAlign="right" font-size="26"
custom-style="border:0;border-radius: 10rpx;padding: 14rpx 20rpx;"
placeholder-style="color: #999; " type="number"
>
<template #suffix>
<text class="font-26 clr-sub pl-10">件</text>
</template>
</u-input>
</template>
</tpx-text-item>
</view>
<view class="edm-input-item">
<tpx-text-item label="物品单价">
<template v-slot:right>
<u-input placeholder="请填写" v-model="modelInfo.price" inputAlign="right" font-size="26"
custom-style="border:0;border-radius: 10rpx;padding: 14rpx 20rpx;"
placeholder-style="color: #999; " type="number"
>
<template #suffix>
<text class="font-26 clr-sub pl-10">CNY</text>
</template>
</u-input>
</template>
</tpx-text-item>
</view>
<view class="edm-input-item">
<tpx-text-item label="原产地">
<template v-slot:right>
<u-input placeholder="请填写" v-model="modelInfo.nationArea" inputAlign="right" font-size="26"
custom-style="border:0;border-radius: 10rpx;padding: 14rpx 20rpx;"
placeholder-style="color: #999; "
></u-input>
</template>
</tpx-text-item>
</view>
</view>
</view>
<view class="dt-block" style="margin-top: 50rpx;">
<view class="dt-tle">
<view class="com-section grey">其他信息(按需填写)</view>
</view>
<view class="dt-cont">
<view class="edm-input-item">
<tpx-text-item label="品牌">
<template v-slot:right>
<u-input placeholder="请填写" v-model="modelInfo.brand" inputAlign="right" font-size="26"
custom-style="border:0;border-radius: 10rpx;padding: 14rpx 20rpx;"
placeholder-style="color: #999; "
></u-input>
</template>
</tpx-text-item>
</view>
<view class="edm-input-item">
<tpx-text-item label="材质">
<template v-slot:right>
<u-input placeholder="请填写" v-model="modelInfo.material" inputAlign="right" font-size="26"
custom-style="border:0;border-radius: 10rpx;padding: 14rpx 20rpx;"
placeholder-style="color: #999; "
></u-input>
</template>
</tpx-text-item>
</view>
<view class="edm-input-item">
<tpx-text-item label="用途">
<template v-slot:right>
<u-input placeholder="请填写" v-model="modelInfo.purpose" inputAlign="right" font-size="26"
custom-style="border:0;border-radius: 10rpx;padding: 14rpx 20rpx;"
placeholder-style="color: #999; "
></u-input>
</template>
</tpx-text-item>
</view>
<view class="edm-input-item">
<tpx-text-item label="成分">
<template v-slot:right>
<u-input placeholder="请填写" v-model="modelInfo.ingredients" inputAlign="right" font-size="26"
custom-style="border:0;border-radius: 10rpx;padding: 14rpx 20rpx;"
placeholder-style="color: #999; "
></u-input>
</template>
</tpx-text-item>
</view>
<view class="edm-input-item">
<tpx-text-item label="供应商">
<template v-slot:right>
<u-input placeholder="请填写" v-model="modelInfo.supplier" inputAlign="right" font-size="26"
custom-style="border:0;border-radius: 10rpx;padding: 14rpx 20rpx;"
placeholder-style="color: #999; "
></u-input>
</template>
</tpx-text-item>
</view>
<view class="edm-input-item" style="padding-top: 24rpx;padding-bottom: 24rpx;">
<tpx-text-item label="保存物品信息">
<template v-slot:right>
<u-switch v-model="modelInfo.isSave" activeValue="1" inactiveValue="0" active-color="#B12D29" size="34"></u-switch>
</template>
</tpx-text-item>
<u-row justify="between">
<text class="font-28 "></text>
<view>
</view>
</u-row>
</view>
</view>
</view>
</template>
<template v-slot:footer>
<view class="blcok-white-noradius" style="margin-top: 0;margin-bottom: 0;">
<u-button @click="handleSubmitValue()" type="primary" size="large" shape="circle"
custom-style="height:80rpx;font-size: 30rpx;"
>确认</u-button>
</view>
</template>
</tpx-layout>
</view>
</tpx-dialog>
</template>
<script>
import * as apiService from "@/common/api"
import { transListKeyTitle } from "@/common/util"
export default {
computed: {
dicData() {
return this.$store.getters.dicData
},
goodsSearchParam() {
return { goodsName: this.modelInfo.goodsName || '' }
}
},
watch: {
show: {
handler: function(cval, oval) {
if(cval) {
this.modelInfo = JSON.parse(JSON.stringify(this.value || {}))
this.initData()
}
}
}
},
props: {
show: {
default () {
return false
}
},
value: {
default () {
return {}
}
}
},
data() {
return {
modelInfo: {},
goodsRes: { list: [] },
checkedGoodId: '',
hotGoods: [
]
}
},
created() {
this.initData()
},
onHide() {
},
unmounted() {},
methods: {
getGoodsList: apiService.getGoodsList,
async initData() {
this.checkedGoodId = ''
let res = await apiService.getHotGoodsList({ customerCode: this.modelInfo.customerCode, pageSize: 5 })
let list = res.rows || []
// 截取前5个热门商品
list.splice(5, list.length - 5)
this.hotGoods = transListKeyTitle({ valKey: 'goodsCode',titleKey: 'goodsName', list })
},
handleCloseModal() {
this.$emit('update:show', false)
},
handleSubmitValue() {
this.$emit('onSure', this.modelInfo)
this.$emit('update:value', this.modelInfo)
this.handleCloseModal()
},
handleChooseGood(val) {
const item = this.goodsRes.list.filter(t=> t.val == val)[0]
this.modelInfo = {
...this.modelInfo,
...item
}
}
}
}
</script>
<style scoped lang="scss">
.shet-cont{
padding: 10rpx 0 30rpx 0;
}
.dt-block {
background-color: #FFF;
position: relative;
}
.dt-tle {
padding-bottom: 10rpx;
display: flex;
flex-direction: row;
justify-content: space-between;
.t1 {
font-size: 30rpx;
font-weight: 600;
}
.t2{
font-size: 30rpx;
}
}
.dt-cont{
}
.dt-item {
display: flex;
flex-direction: row;
margin-bottom: 20rpx;
justify-content: space-between;
}
.yditem{
padding: 20rpx 20rpx;
background-color: #F6F6F6;
border-radius: 10rpx;
margin-bottom: 20rpx;
}
.ydi-lab{
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.edm-input-item{
padding: 8rpx 0;
border-bottom: 2rpx solid #F6F6F6;
}
</style>