Commit 22df53af by 李伟康

feat(dailyNewspaper): 新增日报功能并优化入口组件

- 在Entrance组件中调整方法调用顺序并添加异常处理
- 重构日报参数构建逻辑,动态处理报告记录ID参数
- 实现日报提交功能,新增必填字段验证机制
- 优化谈判明细详情页面的数据展示结构
- 更新日报编辑页面的事件绑定和延时设置
- 新增日期时间选择组件支持精确到分钟的时间选择
- 完善各类日报模板的参数传递和事件处理机制
1 parent 1f605298
...@@ -47,9 +47,9 @@ export default { ...@@ -47,9 +47,9 @@ export default {
} }
}, },
created () { created () {
this.getEntranceList()
// 组件创建时请求工资申诉入口权限 // 组件创建时请求工资申诉入口权限
this.fetchWageAppealEntrance() this.fetchWageAppealEntrance()
this.getEntranceList()
}, },
computed: { computed: {
...@@ -185,6 +185,7 @@ export default { ...@@ -185,6 +185,7 @@ export default {
noInterception: true noInterception: true
}, },
] ]
try {
let userInfo = uni.$storage.get('userInfo'), let userInfo = uni.$storage.get('userInfo'),
{ sceneType, shopMerchantId } = userInfo, { sceneType, shopMerchantId } = userInfo,
newReport = await this.isNewVersionNeed(shopMerchantId) newReport = await this.isNewVersionNeed(shopMerchantId)
...@@ -202,6 +203,9 @@ export default { ...@@ -202,6 +203,9 @@ export default {
list = list.filter(e => e.name !== 'WageAppeal') list = list.filter(e => e.name !== 'WageAppeal')
} }
this.entranceList = list this.entranceList = list
} catch (error) {
console.log(error)
}
} }
} }
} }
......
...@@ -4,26 +4,21 @@ ...@@ -4,26 +4,21 @@
</view> </view>
<template v-if="loadComplete"> <template v-if="loadComplete">
<template v-if="list.length"> <template v-if="list.length">
<view class="list-box"> <template v-for="(item, index) in list">
<view class="list-title">{{ }}</view> <view
<view > class="list-box"
:key="index"
>
<view class="list-title">{{ item.label }}</view>
<Table <Table
:columns="columns" :columns="item.columns"
:data="list" :data="item.dataList"
tableStyle="padding-right:32rpx" tableStyle="padding-right:32rpx"
/> />
</view>
<view class="list-title">{{ }}</view>
<view >
<Table
:columns="columns"
:data="list"
tableStyle="padding-right:32rpx"
/>
</view>
</view> </view>
</template> </template>
</template>
<nothing v-else /> <nothing v-else />
</template> </template>
...@@ -36,62 +31,66 @@ import Nothing from '../components/Nothing' ...@@ -36,62 +31,66 @@ import Nothing from '../components/Nothing'
export default { export default {
components: { Table, Nothing }, components: { Table, Nothing },
name: 'detail', name: 'detail',
props: {
templateData: {
type: Array,
default: () => []
}
},
data () { data () {
return { return {
columns: [
{ title: '数据1' },
{ title: '数据2' },
{ title: '数据3' },
{ title: '数据4' },
{ title: '数据5' },
{ title: '数据6' },
{ title: '数据7' },
{ title: '数据8' },
{ title: '数据9' },
{ title: '数据10' },
{ title: '数据11' },
{ title: '数据12' },
{ title: '数据13' },
{ title: '数据14' },
{ title: '数据15' },
{ title: '数据16' },
{ title: '数据17' },
{ title: '数据18' },
{ title: '数据19' },
{ title: '数据20' },
],
loadComplete: false, loadComplete: false,
list: [ list: []
{ }
rowHeader: '交车日期',
data: ['XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX']
},
{
rowHeader: '部门',
data: ['3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3']
},
{
rowHeader: '推荐人',
data: ['5', '5', '5', '1', '5', '5', '4', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5']
},
{
rowHeader: '客户名称',
data: ['张三', '张三', '张三23423423234SCSDSDsdsd多少点', '张三', '张三', '张三', '张三', '张三', '张三', '张三', '张三', '张三', '张三', '张三', '张三', '张三', '张三', '张三', '张三', '张三']
}, },
watch: {
{ templateData: {
rowHeader: '客户电话', handler (newVal) {
data: ['12345678901', 'ddd', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', 123] if (newVal.length) this.formatData(newVal)
else {
this.list = []
this.loadComplete = true
} }
] },
immediate: true,
deep: true
} }
}, },
computed: { computed: {
}, },
mounted () { mounted () {
this.loadComplete = true
}, },
methods: { methods: {
formatData (list) {
console.log(list)
list.map(item => {
let columns = [],
dataList = [],
values = {}
if (item.children && item.children.length) {
item.children.map((child, index) => {
child.map(k => {
if (!values[k.key]) values[k.key] = []
values[k.key].push(k.value)
})
columns.push({ title: `数据${index + 1}` })
})
let rowData = item.children[0] || []
rowData.map(row => {
dataList.push({
rowHeader: row.label,
data: values[row.key]
})
})
}
item.columns = columns
item.dataList = dataList
})
this.list = list
this.loadComplete = true
}
} }
} }
</script> </script>
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<Footer> <Footer>
<view <view
class="btn" class="btn"
@click="$emit('saveReport',list)" @click="$emit('submitReport',list)"
>保存</view> >保存</view>
</Footer> </Footer>
</view> </view>
...@@ -92,7 +92,7 @@ export default { ...@@ -92,7 +92,7 @@ export default {
this.list = utils.deepClone(val) this.list = utils.deepClone(val)
setTimeout(() => { setTimeout(() => {
this.loadComplete = true this.loadComplete = true
}, 100) }, 200)
}, },
immediate: true, immediate: true,
deep: true deep: true
......
<template> <template>
<view class="report-content "> <view class="report-content ">
<template v-if="!isToday"> <template v-if="!isToday">
<Detail /> <Detail :templateData="templateData" />
</template> </template>
<template v-else> <template v-else>
<Edit <Edit
:templateData="templateData" :templateData="templateData"
@saveReport="saveReport" @submitReport="submitReport"
/> />
</template> </template>
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</view> </view>
<view class="footer"> <view class="footer">
<Footer> <Footer>
<view class="btn">保存</view> <view class="btn" @click="$emit('submitReport',list)">保存</view>
</Footer> </Footer>
</view> </view>
</template> </template>
...@@ -94,7 +94,7 @@ export default { ...@@ -94,7 +94,7 @@ export default {
this.list = utils.deepClone(val) this.list = utils.deepClone(val)
setTimeout(() => { setTimeout(() => {
this.loadComplete = true this.loadComplete = true
}, 100) }, 200)
}, },
immediate: true, immediate: true,
deep: true deep: true
......
<template> <template>
<view class="report-content "> <view class="report-content ">
<template v-if="!isToday"> <template v-if="!isToday">
<Detail /> <Detail :templateData="templateData"/>
</template> </template>
<template v-else> <template v-else>
<Edit :templateData="templateData" /> <Edit
:templateData="templateData"
@submitReport="submitReport"
/>
</template> </template>
</view> </view>
......
...@@ -69,8 +69,8 @@ ...@@ -69,8 +69,8 @@
<view class="footer"> <view class="footer">
<Footer> <Footer>
<view class="btn default-btn" @click="$emit('showNegotiationList')">查看洽谈明细表汇总</view> <view class="btn default-btn" @click="$emit('showNegotiationList')">查看洽谈明细表汇总</view>
<view class="btn default-btn" @click="$emit('saveReport')">保存</view> <view class="btn default-btn" @click="$emit('saveReport',list)">保存</view>
<view class="btn" @click="$emit('submitReport')">提交</view> <view class="btn" @click="$emit('submitReport',list)">提交</view>
</Footer> </Footer>
</view> </view>
</template> </template>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view class="report-content "> <view class="report-content ">
<view :class="['report-component',{'opacity':showNegotiationList}]"> <view :class="['report-component',{'opacity':showNegotiationList}]">
<template v-if="!isToday"> <template v-if="!isToday">
<Detail /> <Detail :templateData="templateData" />
</template> </template>
<template v-else> <template v-else>
<Edit <Edit
......
<template>
<view class="date-list">
<picker-view class="picker picker_max" :value="dateValues" indicator-class="indicator" @change="changeDate">
<picker-view-column>
<template v-for="(item, index) in days">
<view class="view" :key="index">{{ item }}</view>
</template>
</picker-view-column>
</picker-view>
<picker-view class="picker" :value="hourValues" indicator-class="indicator" @change="changeHour">
<picker-view-column>
<template v-for="(item, index) in hours">
<view class="view" :key="index">{{ item }}</view>
</template>
</picker-view-column>
</picker-view>
<picker-view class="picker" :value="minuteValues" indicator-class="indicator" @change="changeMinutes">
<picker-view-column>
<template v-for="(item, index) in minutes">
<view class="view" :key="index">{{ item }}</view>
</template>
</picker-view-column>
</picker-view>
</view>
</template>
<script type="text/ecmascript-6">
import dayjs from 'dayjs'
export default {
name: 'DateTime',
inject: ['userInfo'],
data () {
return {
hours: [],
days: [],
minutes: [],
dateValues: [],
hourValues: [],
minuteValues: [],
loading: true
}
},
props: {
},
mounted () {
this.initDate()
},
methods: {
initDate () {
this.dateValues = []
this.hourValues = []
this.minuteValues = []
const today = new Date()
this.getDateList('2019/01/01', new Date(today.getFullYear(), today.getMonth(), today.getDate()))
},
getDateList (starDay, endDay) {
const arr = [];
const dates = [];
// 设置两个日期UTC时间
const db = new Date(starDay);
const de = new Date(endDay);
// 获取两个日期GTM时间
const s = db.getTime() - 24 * 60 * 60 * 1000;
const d = de.getTime() - 24 * 60 * 60 * 1000;
// 获取到两个日期之间的每一天的毫秒数
for (let i = s; i <= d;) {
i = i + 24 * 60 * 60 * 1000;
arr.push(parseInt(String(i)));
}
// 获取每一天的时间 YY-MM-DD
for (const j in arr) {
const time = new Date(arr[j]);
const year = time.getFullYear();
const mouth = time.getMonth() + 1 >= 10 ? time.getMonth() + 1 : '0' + (time.getMonth() + 1);
const day = time.getDate() >= 10 ? time.getDate() : '0' + time.getDate();
const YYMMDD = year + '/' + mouth + '/' + day;
dates.push(YYMMDD);
}
this.getHourList(dates)
},
getHourList (days) {
const hours = [], today = new Date();
for (let hour = 0; hour < today.getHours() + 1; hour++) {
hours.push(hour.toString().padStart(2, '0'));
}
this.getMinuteList(days, hours)
},
getMinuteList (days, hours) {
const minutes = [];
const today = new Date()
for (let minute = 0; minute < today.getMinutes() + 1; minute++) {
minutes.push(minute.toString().padStart(2, '0'));
}
// 设置默认时间
let { dateValues, hourValues, minuteValues } = this
const HOUR_STR = today.getHours().toString().padStart(2, '0')
const MUNTUE_STR = today.getMinutes().toString().padStart(2, '0')
// const defalutHIndex = hours.indexOf(HOUR_STR)
// const defalutMIndex = minutes.indexOf(MUNTUE_STR)
dateValues.push(days.length + 1)
hourValues.push(hours.length + 1)
minuteValues.push(minutes.length + 1)
this.currentDate = dayjs().format('YYYY/MM/DD')
this.currentHour = HOUR_STR
this.currentMinute = MUNTUE_STR
this.hours = hours
this.days = days
this.minutes = minutes
this.dateValues = dateValues
this.hourValues = hourValues
this.minuteValues = minuteValues
this.loading = false
setTimeout(() => {
this.minuteValues = minuteValues
this.loading = false
}, 100)
this.$emit('onComplete')
},
changeDate (e) {
const { days } = this
const { value } = e.detail
const index = value[0]
this.currentDate = days[index]
// 选择过去时间需要重新初始化时分
const today = dayjs().format('YYYY/MM/DD')
const timeType = this.currentDate != today ? 1 : 0
this.getAllTimeOrPartTime(timeType)
},
changeHour (e) {
const { hours, days, dateValues } = this
const { value } = e.detail
const index = value[0]
this.currentHour = hours[index]
// 处理当前天切换别的小时,别的分不能选后面分到60的问题
// const dayIndex = dateValues[0]
// this.currentDate = days[dayIndex]
const today = dayjs().format('YYYY/MM/DD')
const timeType = this.currentDate != today ? 1 : 0
this.getAllTimeOrPartTimeMinute(timeType)
},
changeMinutes (e) {
const { minutes } = this
const { value } = e.detail
const index = value[0]
this.currentMinute = minutes[index]
},
getAllTimeOrPartTime (type) {
const today = new Date()
const hours = [], minutes = [], hour_len = type == 1 ? 24 : today.getHours() + 1, minute_len = type == 1 ? 60 : today.getMinutes() + 1;
for (let hour = 0; hour < hour_len; hour++) {
hours.push(hour.toString().padStart(2, '0'));
}
for (let minute = 0; minute < minute_len; minute++) {
minutes.push(minute.toString().padStart(2, '0'));
}
this.hours = hours
this.minutes = minutes
},
getAllTimeOrPartTimeMinute (type) {
const today = new Date()
const currentHour = today.getHours()
const timeType = this.currentHour != currentHour ? 1 : 0
const minutes = [], minute_len = type == 1 || timeType == 1 ? 60 : today.getMinutes() + 1;
for (let minute = 0; minute < minute_len; minute++) {
minutes.push(minute.toString().padStart(2, '0'));
}
this.minutes = minutes
},
getResult () {
let str = ''
str = this.currentDate + ' ' + this.currentHour + ':' + this.currentMinute
// + ":00"
const result = dayjs(str).format('YYYY-MM-DD HH:mm')
return result
}
}
}
</script>
<style scoped lang="scss">
.date-list {
height: 100%;
display: grid;
grid-template-columns: repeat(3, 1fr);
.picker {
height: 100%;
text-align: center;
.view {
display: flex;
align-items: center;
justify-content: center;
font-size: toRpx(32);
height: toRpx(72);
}
}
/deep/.indicator {
height: toRpx(72);
}
}
</style>
...@@ -62,6 +62,16 @@ const componentConfig = { ...@@ -62,6 +62,16 @@ const componentConfig = {
noData: false, noData: false,
hideSearch: true hideSearch: true
}, },
5:{
name: 'DateTime',
title: '选择日期时间',
placeholder: '选择日期时间',
idKey: ['date'],
cacheData: [],
loadComplete: false,
searchValue: '',
noData: false
}
} }
export default { componentConfig } export default { componentConfig }
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
clearDate clearDate
:startDate="startDate" :startDate="startDate"
:endDate="endDate" :endDate="endDate"
:title="title"
/> />
</view> </view>
</template> </template>
...@@ -95,7 +96,7 @@ import config from './config' ...@@ -95,7 +96,7 @@ import config from './config'
import EmployeeList from './components/EmployeeList.vue' import EmployeeList from './components/EmployeeList.vue'
import CarModelList from './components/CarModelList.vue' import CarModelList from './components/CarModelList.vue'
import OrderList from './components/OrderList.vue' import OrderList from './components/OrderList.vue'
import DateTime from './components/DateTime.vue'
import dayjs from 'dayjs'; import dayjs from 'dayjs';
export default { export default {
...@@ -104,6 +105,7 @@ export default { ...@@ -104,6 +105,7 @@ export default {
EmployeeList, EmployeeList,
CarModelList, CarModelList,
OrderList, OrderList,
DateTime,
}, },
name: '', name: '',
props: { props: {
...@@ -194,8 +196,8 @@ export default { ...@@ -194,8 +196,8 @@ export default {
this.dataKey = data.key this.dataKey = data.key
this.popupType = popupType this.popupType = popupType
this.itemIndex = index this.itemIndex = index
/**6 日历弹窗 */
if (popupType == 5) { if (popupType == 6) {
this.calendarData = data.value || dayjs().format('YYYY-MM-DD') this.calendarData = data.value || dayjs().format('YYYY-MM-DD')
this.$refs.calendar.open() this.$refs.calendar.open()
return return
...@@ -238,7 +240,11 @@ export default { ...@@ -238,7 +240,11 @@ export default {
}, },
confirm (autoClose) { confirm (autoClose) {
try { try {
let { chooseContent, popupType, componentObject, itemIndex } = this let { chooseContent, popupType, componentObject, itemIndex } = this
if (popupType == 5) {
chooseContent = this.componentRef().getResult()
}
if (chooseContent != null) { if (chooseContent != null) {
if (Array.isArray(chooseContent) && !chooseContent.length && componentObject[popupType].nullTips) throw componentObject[popupType].nullTips if (Array.isArray(chooseContent) && !chooseContent.length && componentObject[popupType].nullTips) throw componentObject[popupType].nullTips
this.$emit('onConfirm', { this.$emit('onConfirm', {
......
...@@ -128,7 +128,6 @@ export default { ...@@ -128,7 +128,6 @@ export default {
* @param parent 父级数据 * @param parent 父级数据
*/ */
open (data, c_index, index, parent) { open (data, c_index, index, parent) {
console.log(data, c_index, index, parent)
this.data = utils.deepClone(data) || {} this.data = utils.deepClone(data) || {}
this.c_index = c_index || 0 this.c_index = c_index || 0
this.index = index || 0 this.index = index || 0
...@@ -180,9 +179,7 @@ export default { ...@@ -180,9 +179,7 @@ export default {
this.$set(this.data[index], 'value', val) this.$set(this.data[index], 'value', val)
}, },
onSelect (val, index) { onSelect (val, index) {
this.$set(this.data[index], 'value', val) this.$set(this.data[index], 'value', val)
console.log(this.data[index])
}, },
openSelect (item, type, index) { openSelect (item, type, index) {
this.currentItem = item this.currentItem = item
...@@ -196,7 +193,7 @@ export default { ...@@ -196,7 +193,7 @@ export default {
popupType, popupType,
itemIndex itemIndex
}) { }) {
if (popupType == 5) { if (popupType == 6 || popupType == 5) {
this.$set(this.data[itemIndex], 'value', chooseContent) this.$set(this.data[itemIndex], 'value', chooseContent)
} else if (popupType == 3) { } else if (popupType == 3) {
const { vehicleBrandName, vehicleSubBrandName, vehicleSeriesName, vehicleShapeName } = chooseContent const { vehicleBrandName, vehicleSubBrandName, vehicleSeriesName, vehicleShapeName } = chooseContent
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
</template> </template>
</template> </template>
<template v-else-if="item.type == 'datetime'"> <template v-else-if="['date', 'datetime'].includes(item.type)">
<view <view
:class="['select flex', { 'placeholderStyle': !item.value }]" :class="['select flex', { 'placeholderStyle': !item.value }]"
@click="select" @click="select"
...@@ -168,9 +168,9 @@ export default { ...@@ -168,9 +168,9 @@ export default {
let { item } = this, let { item } = this,
popupType = { popupType = {
multipleSelect: 1, multipleSelect: 1,
carBrandSelect: 3,
datetime: 5, datetime: 5,
carBrandSelect: 3 date: 6
}[item.type] || 0 }[item.type] || 0
return popupType return popupType
}, },
...@@ -190,9 +190,10 @@ export default { ...@@ -190,9 +190,10 @@ export default {
}, },
select (e) { select (e) {
let { item, popupType } = this let { item, popupType } = this
if (item.optionsKey || item.type == 'datetime' || item.type == 'carBrandSelect') { if (item.optionsKey || ['date', 'datetime', 'carBrandSelect'].includes(item.type)) {
if (item.optionsKey == 'storeStaffList') popupType = 2 if (item.optionsKey == 'storeStaffList') popupType = 2
if(item.optionsKey == 'orderList') popupType = 4 if (item.optionsKey == 'orderList') popupType = 4
this.$emit('openSelect', item, popupType) this.$emit('openSelect', item, popupType)
} else { } else {
this.$emit('onSelect', item.options[e.detail.value].value) this.$emit('onSelect', item.options[e.detail.value].value)
......
...@@ -20,17 +20,18 @@ export default { ...@@ -20,17 +20,18 @@ export default {
}, },
reportParams () { reportParams () {
let { shopMerchantId, shopMerchantName, uuid, name } = this.userInfo, let { shopMerchantId, shopMerchantName, uuid, name } = this.userInfo,
{ currentDate, templateType,dailyReportRecordId } = this { currentDate, templateType, dailyReportRecordId } = this,
return { params = {
merchantId: shopMerchantId, merchantId: shopMerchantId,
merchantName: shopMerchantName, merchantName: shopMerchantName,
reportDate: currentDate, reportDate: currentDate,
staffUuid: uuid, staffUuid: uuid,
staffName: name, staffName: name,
dailyReportSource: 2,//1:生意助手员工版小程序,2:平板电脑 dailyReportSource: 2,//1:生意助手员工版小程序,2:平板电脑
templateType: templateType(), templateType: templateType()
dailyReportRecordId: dailyReportRecordId()
} }
if (dailyReportRecordId()) params.dailyReportRecordId = dailyReportRecordId()
return params
}, },
}, },
watch: { watch: {
...@@ -40,30 +41,38 @@ export default { ...@@ -40,30 +41,38 @@ export default {
try { try {
let { reportParams } = this let { reportParams } = this
console.log('保存日报', reportParams) console.log('保存日报', reportParams)
reportParams.jsonContent = JSON.stringify(list)
const data = await uni.$api.dailyTemplateApi.saveDraft(reportParams)
console.log(data)
} catch (error) {
uni.showToast({ title: error, icon: 'none' })
}
},
async submitReport (list) {
try {
let { reportParams } = this
console.log('提交日报', reportParams)
console.log(list) console.log(list)
list.map(e => { list.map(e => {
if (e.children && e.children.length) e.children.map((c, cIndex) => { if (e.children && e.children.length) e.children.map((c, cIndex) => {
let isArray = Array.isArray(c) let isArray = Array.isArray(c)
if (isArray) { if (isArray) {
c.map(i => { c.map(i => {
// if(i.required && (i.value == null || i.value == undefined)) throw `${e.label}第${cIndex+1}项${i.label}不能为空` if(i.required && (i.value == null || i.value == undefined)) throw `${e.label}第${cIndex+1}项${i.label}不能为空`
}) })
} else { } else {
if(c.required && (c.value == null || c.value == undefined)) throw `${e.label}${c.label}不能为空`
} }
}) })
}) })
reportParams.jsonContent = JSON.stringify(list) reportParams.jsonContent = JSON.stringify(list)
const data = await uni.$api.dailyTemplateApi.saveDraft(reportParams) const data = await uni.$api.dailyTemplateApi.submitReport(reportParams)
console.log(data) console.log(data)
} catch (error) { } catch (error) {
uni.showToast({ title: error, icon: 'none' }) uni.showToast({ title: error, icon: 'none' })
} }
},
submitReport () {
console.log('提交日报')
}, },
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!