Commit 3d802c98 by 李伟康

refactor(dailyReport): 重构日报组件数据处理逻辑

- 优化 Entrance.vue 组件代码格式和入口列表配置
- 更新日报提交逻辑,统一使用 requestJson 替代 fieldDataList 和 subformDataList
- 重构 subform.js 文件,完善动态表单处理逻辑和字段值序列化
- 添加新的驻店日报入口并调整现有入口的场景类型配置
- 优化组件样式布局和事件处理机制
1 parent becb0109
......@@ -3,12 +3,7 @@
<template v-if="entranceList.length">
<view class="entrance-container">
<view :class="['entrance-list', `entrance-list-${type}`]">
<view
class="entrance-item"
v-for="(item, index) in entranceList"
:key="index"
@click="handleClick(item)"
>
<view class="entrance-item" v-for="(item, index) in entranceList" :key="index" @click="handleClick(item)">
<view :class="['sprite-icon', `icon-${item.icon}`]"></view>
<view class="entrance-name">{{ item.label }}</view>
</view>
......@@ -17,10 +12,7 @@
</template>
<template v-else>
<view class="developing flex">
<image
class="developing-icon"
src="../assets/images/common/developing.webp"
/>
<image class="developing-icon" src="../assets/images/common/developing.webp" />
功能开发中
</view>
</template>
......@@ -37,7 +29,7 @@ export default {
default: 0
}
},
data () {
data() {
return {
// 工资申诉入口是否允许显示
wageAppealAllowed: false,
......@@ -46,7 +38,7 @@ export default {
entranceList: []
}
},
created () {
created() {
// 组件创建时请求工资申诉入口权限
this.fetchWageAppealEntrance()
this.getEntranceList()
......@@ -56,7 +48,7 @@ export default {
},
methods: {
// 请求工资申诉入口权限,并设置显示开关
async fetchWageAppealEntrance () {
async fetchWageAppealEntrance() {
try {
this.loadingEntrance = true
const userInfo = uni.$storage.get('userInfo') || {}
......@@ -84,14 +76,14 @@ export default {
this.loadingEntrance = false
}
},
handleClick (item) {
handleClick(item) {
// 这里可以根据实际需求进行跳转或功能处理
this.$emit('entranceClick', item)
},
isNewVersionNeed (merchantId) {
isNewVersionNeed(merchantId) {
return uni.$api.dailyTemplateApi.isNewVersionNeed({ merchantId })
},
async getEntranceList () {
async getEntranceList() {
let entranceList = [
{
icon: 'daily-report',
......@@ -169,6 +161,14 @@ export default {
noInterception: true
},
{
icon: 'daily-report',
label: '驻店日报-新',
name: 'staffDailyReport',
page: '/pages/common/dailyNewspaper/index',
eventCode: 'staff_daily_report_page',
noInterception: true
},
{
icon: 'store-daily-report',
label: '门店日报',
name: 'storeDailyReport',
......@@ -190,11 +190,8 @@ export default {
{ sceneType, shopMerchantId } = userInfo,
newReport = await this.isNewVersionNeed(shopMerchantId)
if (newReport && sceneType != 7) {
entranceList[0].name = 'staffDailyReport'
entranceList[0].page = '/pages/common/dailyNewspaper/index'
entranceList[0].eventCode = 'staff_daily_report_page'
entranceList.map(e => {
if (['storeDailyReport', 'NegotiationDetail'].includes(e.name)) e.sceneType = [0, 1]
if (['staffDailyReport', 'storeDailyReport', 'NegotiationDetail'].includes(e.name)) e.sceneType = [0, 1]
})
}
// 先根据场景过滤
......@@ -225,9 +222,11 @@ export default {
display: grid;
row-gap: toRpx(30);
column-gap: toRpx(68);
&.entrance-list-0 {
grid-template-columns: repeat(5, 1fr);
}
&.entrance-list-1 {
grid-template-columns: repeat(4, 1fr);
}
......@@ -241,15 +240,18 @@ export default {
justify-content: center;
font-size: toRpx(28);
color: #333;
.entrance-name {
margin-top: toRpx(8);
}
}
.developing {
height: 100%;
flex-direction: column;
color: #999999;
font-size: toRpx(20);
&-icon {
width: toRpx(344);
height: toRpx(208);
......
......@@ -6,12 +6,10 @@
<template v-if="loadComplete">
<template v-if="list.length">
<view class="daily-report-container">
<template v-for="(i,index) in list">
<template v-for="(i, index) in list">
<view
:class="['list-item',{'block':['group','divider','textarea'].includes(i.type)},{'list-box':i.type == 'group'}]"
:key="index"
v-if="itemShow(i)"
>
:class="['list-item', { 'block': ['group', 'divider', 'textarea'].includes(i.type) }, { 'list-box': i.type == 'group' }]"
:key="index" v-if="itemShow(i)">
<template v-if="i.type != 'group'">
<template v-if="i.type == 'divider'">
<view class="divider flex">
......@@ -19,13 +17,8 @@
</view>
</template>
<template v-else>
<FormItem
:formItem="i"
:rules="i.rules"
@onSelect="onSelect($event, index)"
@onInput="onInput($event, index)"
:disabled="itemDisabled(i)"
/>
<FormItem :formItem="i" :rules="i.rules" @onSelect="onSelect($event, index)"
@onInput="onInput($event, index)" :disabled="itemDisabled(i)" />
</template>
</template>
<template v-else>
......@@ -33,16 +26,10 @@
{{ i.label }}
</view>
<template v-if="i.children.length">
<template v-for="(c,c_index) in i.children">
<FormItem
class="form-item"
:formItem="c"
:key="c_index"
:rules="i.childrenRules[c.key]"
@onSelect="onSelect($event,index, c_index)"
@onInput="onInput($event, index, c_index)"
:disabled="itemDisabled(c)"
/>
<template v-for="(c, c_index) in i.children">
<FormItem class="form-item" :formItem="c" :key="c_index" :rules="i.childrenRules[c.key]"
@onSelect="onSelect($event, index, c_index)" @onInput="onInput($event, index, c_index)"
:disabled="itemDisabled(c)" />
</template>
</template>
</template>
......@@ -51,20 +38,13 @@
</view>
<view class="footer">
<Footer>
<view
class="btn"
@click="$emit('submitReport',list)"
>保存</view>
<view class="btn" @click="$emit('submitReport', list)">保存</view>
</Footer>
</view>
</template>
<nothing v-else />
</template>
<EditForm
ref="editForm"
@onDel="delItem"
@onConfirm="confirm"
/>
<EditForm ref="editForm" @onDel="delItem" @onConfirm="confirm" />
</view>
</template>
......@@ -84,7 +64,7 @@ export default {
default: () => []
}
},
data () {
data() {
return {
loadComplete: false,
list: []
......@@ -92,7 +72,7 @@ export default {
},
watch: {
templateData: {
handler (val) {
handler(val) {
this.loadComplete = false
this.list = utils.deepClone(val)
setTimeout(() => {
......@@ -103,10 +83,10 @@ export default {
deep: true
}
},
mounted () {
mounted() {
},
methods: {
itemShow (i) {
itemShow(i) {
if (i.rules) {
let { keys, result } = i.rules,
{ list } = this
......@@ -121,6 +101,14 @@ export default {
})
let show = func(...value)
i.show = show
if (!i.show) {
if (i.type == 'group') i.children.map(c => {
if (c.value != null) c.value = null
})
else {
if (i.value) i.value = null
}
}
return show
} else {
i.show = true
......@@ -131,14 +119,14 @@ export default {
return true
}
},
handleRowClick (row, rowIndex, index) {
handleRowClick(row, rowIndex, index) {
let parent = this.list[index]
this.$refs.editForm.open(row, rowIndex, index, parent)
},
delItem (c_index, index) {
delItem(c_index, index) {
this.list[index].children.splice(c_index, 1)
},
addItem (index) {
addItem(index) {
let { templateData } = this
this.list[index].children.push(templateData[index].children[0])
let data = this.list[index].children[this.list[index].children.length - 1],
......@@ -146,18 +134,18 @@ export default {
parent = this.list[index]
this.$refs.editForm.open(data, c_index, index, parent)
},
confirm (data, c_index, index) {
confirm(data, c_index, index) {
this.$set(this.list[index].children, c_index, utils.deepClone(data))
},
onInput (val, index, c_index = -1) {
onInput(val, index, c_index = -1) {
if (c_index == -1) this.$set(this.list[index], 'value', val)
else this.$set(this.list[index].children[c_index], 'value', val)
},
onSelect (val, index, c_index = -1) {
onSelect(val, index, c_index = -1) {
if (c_index == -1) this.$set(this.list[index], 'value', val)
else this.$set(this.list[index].children[c_index], 'value', val)
},
itemDisabled (i) {
itemDisabled(i) {
let disabled = i.disabled
if (i.disabledFun) {
let { keys, result } = i.disabledFun,
......@@ -182,6 +170,7 @@ export default {
.daily-report {
height: 100%;
position: relative;
&-container {
height: calc(100% - #{toRpx(256)});
padding: 0 48rpx;
......@@ -191,23 +180,28 @@ export default {
flex-wrap: wrap;
gap: 24rpx 32rpx;
align-content: start;
.list-item,
.form-item {
width: calc((100% - 32rpx) / 2);
}
.block {
width: 100%;
}
.divider {
color: #999999;
font-size: 24rpx;
line-height: 32rpx;
position: relative;
justify-content: center;
.text {
position: relative;
padding: 0 24rpx;
}
&::before,
&:after {
content: '';
......@@ -218,19 +212,23 @@ export default {
width: calc(50% - #{toRpx(72)});
height: 0;
}
&::before {
left: 0;
}
&::after {
right: 0;
}
}
.list-box {
width: 100%;
border-radius: 32rpx;
display: flex;
flex-wrap: wrap;
gap: 24rpx 32rpx;
.list-title {
color: #333333;
width: 100%;
......@@ -240,10 +238,12 @@ export default {
padding: 8rpx 32rpx 0 0;
}
}
.no-child {
padding-bottom: 0;
}
}
&-box {
position: absolute;
width: calc(100% - #{toRpx(96)});
......@@ -255,6 +255,7 @@ export default {
transform: translateX(-50%);
padding: 0 0 32rpx 32rpx;
overflow-x: auto;
.list-title {
font-size: 32rpx;
font-weight: 600;
......@@ -266,6 +267,7 @@ export default {
background: #fff;
}
}
.footer {
height: 136rpx;
......
<template>
<view class="order-list">
<template v-for="(i, index) in listData">
<view
:key="index"
@click="choose(i)"
:class="['item flex', { active: checkActive(i) }]"
>
<view :key="index" @click="choose(i)" :class="['item flex', { active: checkActive(i) }]">
<view class="sprite-icon icon-tag-checked"></view>
{{ i.orderCode }}
</view>
......@@ -19,57 +15,55 @@ export default {
mixins: [popupmixin],
name: 'OrderList',
inject: ['userInfo'],
data () {
data() {
return {
}
},
computed: {
idKey () {
idKey() {
let { params: { idKey }, sceneType } = this
return Array.isArray(idKey) ? idKey[sceneType] : idKey
}
},
mounted () {
mounted() {
},
methods: {
async getList (searchValue, search) {
async getList(searchValue, search) {
const { userInfo, params, data, reqParams } = this,
{ cacheData } = params
this.currentId = ''
// if (!search && cacheData && cacheData.length) {
// this.initData(cacheData)
// this.initData(cacheData)
// return
// }
this.componentLoading(params)
console.log(data)
const { shopMerchantId, uuid } = userInfo,
apiParams = {
merchantId: shopMerchantId,
merchantId:shopMerchantId,
sellerUserId: uuid,
...reqParams
}
const res = await uni.$api.dailyTemplateApi.getGoodsOrderList(apiParams)
this.updateParams(params, res || [])
},
initData (list) {
console.log(list)
const { data, data: { key } } = this
if (data[key]) {
this.currentId = data[key]
initData(list) {
const { data: { value } } = this
if (value) {
this.currentId = value
let item = list.find(i => i.orderCode == this.currentId)
this.$emit('choose', item)
}
this.list = list
this.$emit('onComplete')
},
choose (i) {
choose(i) {
this.currentId = i.orderCode
this.$emit('choose', i)
},
checkActive (i) {
let { currentId, data: { key }, data } = this
return currentId ? i.orderCode == currentId : i.orderCode == data[key]
checkActive(i) {
let { currentId, data: { value } } = this
return currentId ? i.orderCode == currentId : i.orderCode == value
}
}
}
......@@ -81,6 +75,7 @@ export default {
grid-template-columns: repeat(4, 1fr);
gap: toRpx(32);
margin: 0 toRpx(48);
.item {
justify-content: center;
height: toRpx(72);
......@@ -90,6 +85,7 @@ export default {
position: relative;
color: #333333;
font-size: toRpx(32);
.sprite-icon {
display: none;
position: absolute;
......@@ -97,10 +93,12 @@ export default {
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
......
<template>
<view class="form-popup">
<uni-popup
ref="popup"
type="right"
:is-mask-click="false"
animation
>
<uni-popup ref="popup" type="right" :is-mask-click="false" animation>
<view class="box">
<view class="popup-title flex">
第{{ c_index + 1 }}行
<view
class="popup-close flex"
@click="close"
>
<uni-icons
type="closeempty"
size="16"
></uni-icons>
<view class="popup-close flex" @click="close">
<uni-icons type="closeempty" size="16"></uni-icons>
</view>
</view>
<view class="popup-content">
<view class="form-box">
<template v-for="(item,ind) in data">
<FormItem
class="form-item"
:key="ind"
:formItem="item"
:rules="rules(item)"
v-if="itemShow(item)"
@onSelect="onSelect($event, ind)"
@onInput="onInput($event, ind)"
@openSelect="openSelect(...arguments, ind)"
@onScanSuccess="onScanSuccess($event, ind)"
/>
<template v-for="(item, ind) in data">
<FormItem class="form-item" :key="ind" :formItem="item" :rules="rules(item)" v-if="itemShow(item)"
@onSelect="onSelect($event, ind)" @onInput="onInput($event, ind)"
@openSelect="openSelect(...arguments, ind)" @onScanSuccess="onScanSuccess($event, ind)" />
</template>
</view>
</view>
<view class="popup-footer flex">
<view
class="del flex"
@click="del"
>
<view class="del flex" @click="del">
<view class="sprite-icon icon-blue-delete"></view>
</view>
<view
class="popup-btn popup-cancel"
@click="close"
>{{ cancelText }}</view>
<view
class="popup-btn popup-confirm"
@click="confirm"
>{{ confirmText }}</view>
<view class="popup-btn popup-cancel" @click="close">{{ cancelText }}</view>
<view class="popup-btn popup-confirm" @click="confirm">{{ confirmText }}</view>
</view>
</view>
</uni-popup>
<DailyPopup
ref="dailyPopup"
@onConfirm="onPopupConfirm"
:startDate="startDate"
:endDate="endDate"
/>
<DailyPopup ref="dailyPopup" @onConfirm="onPopupConfirm" :startDate="startDate" :endDate="endDate" />
</view>
</template>
......@@ -83,7 +50,7 @@ export default {
default: '确定'
}
},
data () {
data() {
return {
carBrandData: [],
data: {},
......@@ -94,7 +61,7 @@ export default {
}
},
computed: {
startDate () {
startDate() {
let childrenRules = this.parent.childrenRules,
item = this.currentItem
if (childrenRules && item.key) {
......@@ -102,7 +69,7 @@ export default {
return rules?.minDate ? dayjs(eval(rules.minDate)).format('YYYY-MM-DD') : '2020-01-01'
}
},
endDate () {
endDate() {
let childrenRules = this.parent.childrenRules,
item = this.currentItem
if (childrenRules && item.key) {
......@@ -111,10 +78,10 @@ export default {
}
},
},
mounted () {
mounted() {
},
methods: {
rules (item) {
rules(item) {
let rules = this.parent.childrenRules
if (rules) {
return rules[item.key] || null
......@@ -127,32 +94,32 @@ export default {
* @param index 父级index
* @param parent 父级数据
*/
open (data, c_index, index, parent) {
open(data, c_index, index, parent) {
this.data = utils.deepClone(data) || {}
this.c_index = c_index || 0
this.index = index || 0
this.parent = utils.deepClone(parent) || {}
this.$refs.popup.open()
},
del () {
del() {
this.$emit('onDel', this.c_index, this.index)
this.close()
},
cancel () {
cancel() {
this.$emit('onCancel')
},
close () {
close() {
this.data = {}
this.c_index = 0
this.index = 0
this.parent = {}
this.$refs.popup.close()
},
confirm () {
confirm() {
this.$emit('onConfirm', utils.deepClone(this.data), this.c_index, this.index)
this.close()
},
itemShow (item) {
itemShow(item) {
let { parent } = this,
childrenShowRules = parent.childrenShowRules || null
if (childrenShowRules) {
......@@ -169,6 +136,7 @@ export default {
})
let show = func(...value)
item.show = show
if (!item.show && item.value) item.value = null
return show
} else {
item.show = true
......@@ -179,25 +147,29 @@ export default {
return true
}
},
onInput (val, index) {
onInput(val, index) {
this.$set(this.data[index], 'value', val)
},
onSelect (val, index) {
onSelect(val, index) {
this.$set(this.data[index], 'value', val)
},
openSelect (item, type, index) {
openSelect(item, type, index) {
let list = this.data || []
this.currentItem = item
this.$refs.dailyPopup.open(item, type, index, list)
},
onScanSuccess (val, index) {
onScanSuccess(val, index) {
this.$set(this.data[index], 'value', val)
},
onPopupConfirm ({
onPopupConfirm({
chooseContent,
popupType,
itemIndex
}) {
/** 根据 popupType 处理数据
* 5: 日期时间选择
* 6: 日历
*/
if (popupType == 6 || popupType == 5) {
this.$set(this.data[itemIndex], 'value', chooseContent)
} else if (popupType == 3) {
......@@ -213,6 +185,7 @@ export default {
keys.map((key, index) => {
let ind = this.data.findIndex(i => i.key == key),
val = chooseContent[resultKeys[index]]
console.log(chooseContent[resultKeys[index]])
this.$set(this.data[ind], 'value', val != null ? val : '-')
})
}
......@@ -221,6 +194,13 @@ export default {
this.$set(this.data[itemIndex], 'value', chooseContent.staffName)
this.$set(this.data[itemIndex], this.data[itemIndex].key, chooseContent.uuid)
}
let clearkeys = this.data[itemIndex].clearkeys
if (clearkeys) {
clearkeys.map(key => {
let ind = this.data.findIndex(i => i.key == key)
this.$set(this.data[ind], 'value', null)
})
}
}
......@@ -234,6 +214,7 @@ export default {
height: 100vh;
border-radius: 32rpx 0 0 32rpx;
background-color: #fff;
.popup-title {
height: 112rpx;
position: relative;
......@@ -242,6 +223,7 @@ export default {
font-size: 36rpx;
font-weight: 500;
line-height: 48rpx;
.popup-close {
position: absolute;
height: 100%;
......@@ -252,34 +234,41 @@ export default {
color: #1a1a1a;
}
}
.popup-content {
height: calc(100vh - 272rpx);
overflow-y: auto;
box-sizing: border-box;
padding: 16rpx 0;
.form-box {
margin: 0 48rpx;
padding: 32rpx;
border-radius: 24rpx;
background: #94c2ff33;
.form-item {
margin-bottom: 16rpx;
&:last-child {
margin-bottom: 0;
}
}
}
}
.popup-footer {
padding: 16rpx 0 64rpx 0;
justify-content: center;
gap: 0 32rpx;
margin: 0 48rpx;
.del {
border-radius: 64rpx;
background: #2c66f71a;
padding: 20rpx 32rpx;
}
.popup-btn {
display: flex;
align-items: center;
......@@ -292,6 +281,7 @@ export default {
font-size: 32rpx;
font-weight: 500;
}
.popup-confirm {
color: #fff;
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
......
......@@ -9,7 +9,8 @@
</view>
<view :class="['item-content flex', { 'disabled': disabled }]">
<template v-if="item.disabled || disabled">
<view :class="['select flex']">{{ item.value }}
<view :class="['select flex']">
<text class="text-hide">{{ item.value }}</text>
</view>
</template>
<template v-else>
......
......@@ -47,7 +47,7 @@ export default {
let { reportParams } = this,
list = utils.deepClone(res)
let jsonContent = JSON.stringify(list)
let { fieldDataList, subformDataList } = buildAppNormalizedListsFromJsonContent(jsonContent)
let requestJson = buildAppNormalizedListsFromJsonContent(jsonContent)
list.map(e => {
let childrenValue = []
if (e.children && e.children.length) e.children.map((c, cIndex) => {
......@@ -71,8 +71,7 @@ export default {
if (e.type == 'subform') delete e.children
})
reportParams.jsonContent = JSON.stringify(list)
reportParams.fieldDataList = fieldDataList
reportParams.subformDataList = subformDataList
reportParams.requestJson = JSON.stringify(requestJson)
console.log(reportParams)
const data = await uni.$api.dailyTemplateApi.saveDraft(reportParams)
uni.hideLoading()
......@@ -122,7 +121,7 @@ export default {
list = utils.deepClone(res)
console.log('提交日报', list)
let jsonContent = JSON.stringify(list)
let { fieldDataList, subformDataList } = buildAppNormalizedListsFromJsonContent(jsonContent)
let requestJson = buildAppNormalizedListsFromJsonContent(jsonContent)
list.map(e => {
let childrenValue = []
if (e.children && e.children.length) e.children.map((c, cIndex) => {
......@@ -172,8 +171,7 @@ export default {
})
console.log('提交日报', list)
reportParams.jsonContent = JSON.stringify(list)
reportParams.fieldDataList = fieldDataList
reportParams.subformDataList = subformDataList
reportParams.requestJson = JSON.stringify(requestJson)
console.log(reportParams)
uni.hideLoading()
this.$emit('submitReport', reportParams)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!