提交 c211ce90 authored 作者: lidongxu's avatar lidongxu

feat(categoryinformation): 新增:勤策移动端_售点稽查品类信息完成接口对接

上级 ea401052
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="mobile-page-container"> <div class="mobile-page-container">
<!-- 类型选择 --> <!-- 类型选择 -->
<div class="category-select"> <div class="category-select">
<van-field label-width="4rem" <van-field label-width="150px"
label-position="left" label-position="left"
label="品类选择:" label="品类选择:"
:model-value="selectedTypeObj.label" :model-value="selectedTypeObj.label"
...@@ -20,10 +20,11 @@ ...@@ -20,10 +20,11 @@
<van-field v-model="selectedTypeObj.price" <van-field v-model="selectedTypeObj.price"
type="number" type="number"
:label="selectedTypeObj.label + ' 价格:'" :label="selectedTypeObj.label + ' 价格:'"
label-width="4rem" label-width="150px"
placeholder="请输入价格" placeholder="请输入价格"
clearable clearable
class="search-input" /> class="search-input"
@change="handlePriceChange" />
</div> </div>
<!-- 品类信息 --> <!-- 品类信息 -->
<div class="table-container"> <div class="table-container">
...@@ -47,7 +48,9 @@ ...@@ -47,7 +48,9 @@
<template #input> <template #input>
<el-date-picker v-model="obj.value" <el-date-picker v-model="obj.value"
type="month" type="month"
placeholder="选择月份" /> value-format="YYYY-MM"
placeholder="选择月份"
@change="handleTasteChange(index)" />
</template> </template>
</van-field> </van-field>
</div> </div>
...@@ -58,13 +61,22 @@ ...@@ -58,13 +61,22 @@
</template> </template>
<script setup> <script setup>
import { createInspectionTaskDetailAPI } from '@/api'
const props = defineProps({ const props = defineProps({
form: { form: {
type: Object, type: Object,
default: () => { } default: () => { }
} }
}) })
const nowRstdId = ref('') // 当前品类任务部分 ID
// 品类型 // 品类型
// 后台用的英文字段,和我们的 label 名字做映射
const typeMap = {
' 虎皮凤爪 210g': {
priceKey: 'priceHp210',
tasteDateKey: 'kwYmHp210Map'
}
}
const typeOptions = ref([ const typeOptions = ref([
{ {
label: ' 虎皮凤爪 210g', value: ' 虎皮凤爪 210g', price: '', taste: [ label: ' 虎皮凤爪 210g', value: ' 虎皮凤爪 210g', price: '', taste: [
...@@ -258,27 +270,63 @@ const typeOptions = ref([ ...@@ -258,27 +270,63 @@ const typeOptions = ref([
const selectedTypeObj = ref(typeOptions.value[0]) const selectedTypeObj = ref(typeOptions.value[0])
// 创建任务 // 创建任务
const createTask = () => { const createTask = async () => {
displayGroup.value.push({ const { data } = await createInspectionTaskDetailAPI({
type: selectedTypeObj.value.value, taskDetail: {
taste: selectedTypeObj.value.taste.map(item => ({ rstId: props.form.rstId,
name: item.name, detailName: '品类信息'
value: '' }
})) })
displayGroup.value.push(data)
}
// 价格改变
const handlePriceChange = async () => {
const res = await createInspectionTaskDetailAPI({
taskDetail: {
rstId: props.form.rstId,
rstdId: nowRstdId.value,
detailName: '品类信息',
priceHp210: selectedTypeObj.value.price * 1
}
})
showNotify({ type: 'success', message: '价格,保存成功' })
}
// 口味生产日期设置
const handleTasteChange = async (index) => {
console.log(selectedTypeObj.value)
const prop = typeMap[selectedTypeObj.value.label].tasteDateKey
await createInspectionTaskDetailAPI({
taskDetail: {
rstId: props.form.rstId,
rstdId: nowRstdId.value,
detailName: '品类信息',
[prop]: selectedTypeObj.value.taste.reduce((acc, item) => {
acc[item.name] = item.value;
return acc;
}, {})
}
}) })
} }
const init = () => { const init = () => {
if (props.form.detailMap) { if (props.form.detailMap) {
if (props.form.detailMap['品类信息']) { if (props.form.detailMap['品类信息']) {
checkProperty(props.form.detailMap['品类信息']) // 回显
displayGroup.value = props.form.detailMap['品类信息'] || [] nowRstdId.value = props.form.detailMap['品类信息'][0].rstdId // 详情ID
const priceProp = typeMap[selectedTypeObj.value.label].priceKey // 设置价格
selectedTypeObj.value.price = props.form.detailMap['品类信息'][0][priceProp]
const tasteProp = typeMap[selectedTypeObj.value.label].tasteDateKey // 设置口味日期
const targetTasteObj = props.form.detailMap['品类信息'][0][tasteProp]
if (targetTasteObj) {
selectedTypeObj.value.taste.forEach(item => {
item.value = targetTasteObj[item.name] // 取出日期
})
}
return return
} }
} }
// 没传递则自己至少新建 1 个
if (displayGroup.value.length === 0) {
createTask()
}
} }
defineExpose({ defineExpose({
init init
...@@ -288,7 +336,7 @@ defineExpose({ ...@@ -288,7 +336,7 @@ defineExpose({
<style lang="scss" <style lang="scss"
scoped> scoped>
.mobile-page-container { .mobile-page-container {
padding: 10px; padding: .2667rem;
background-color: #fff; background-color: #fff;
// 类型选择 // 类型选择
...@@ -298,35 +346,35 @@ defineExpose({ ...@@ -298,35 +346,35 @@ defineExpose({
.van-cell { .van-cell {
padding: 0; padding: 0;
align-items: center; align-items: center;
// font-size: 14px; // font-size: .3733rem;
// font-weight: 900; // font-weight: 900;
.el-select { .el-select {
width: 150px; width: 4rem;
} }
} }
.search-input { .search-input {
margin-top: 10px; margin-top: .2667rem;
} }
} }
// 表格容器 // 表格容器
.table-container { .table-container {
margin-top: 10px; margin-top: .2667rem;
} }
.custom-table { .custom-table {
width: 100%; width: 100%;
border: 1px solid #ccc; border: .0267rem solid #ccc;
border-collapse: collapse; // 模拟表格边框合并 border-collapse: collapse; // 模拟表格边框合并
.table-row { .table-row {
display: flex; display: flex;
width: 100%; width: 100%;
height: 44px; height: 1.1733rem;
&.header-row { &.header-row {
background-color: #e5e5e5; background-color: #e5e5e5;
...@@ -349,9 +397,9 @@ defineExpose({ ...@@ -349,9 +397,9 @@ defineExpose({
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border-right: 1px solid #ccc; border-right: .0267rem solid #ccc;
border-bottom: 1px solid #ccc; border-bottom: .0267rem solid #ccc;
font-size: 14px; font-size: .3733rem;
color: #333; color: #333;
&:last-child { &:last-child {
...@@ -359,14 +407,14 @@ defineExpose({ ...@@ -359,14 +407,14 @@ defineExpose({
} }
&.first-column { &.first-column {
width: 120px; width: 3.2rem;
font-weight: 500; font-weight: 500;
} }
&.second-column { &.second-column {
background: white; background: white;
flex: 1; flex: 1;
padding: 0 8px; padding: 0 .2133rem;
} }
} }
...@@ -375,7 +423,7 @@ defineExpose({ ...@@ -375,7 +423,7 @@ defineExpose({
width: 100%; width: 100%;
height: 100%; height: 100%;
text-align: center; text-align: center;
font-size: 14px; font-size: .3733rem;
padding: 0; padding: 0;
::v-deep(.van-cell__value) { ::v-deep(.van-cell__value) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论