Commit fa0474d9 by 张立顺

Merge branch 'SAAS+V5.8.2_zls' into SAAS+V5.8.2

2 parents f2141409 305fb80c
......@@ -477,3 +477,52 @@ export const rangePickerOptions_deliveryQuantity = {
return !isAllowed; // 不在允许范围则禁用
},
};
/**
* 根据 yyyy-MM 获取当月首尾日期
* @param {string} targetMonth
* @returns {{ startDate: string, endDate: string } | null}
*/
export function getMonthDateRange(targetMonth) {
if (!targetMonth) return null;
const [yearStr, monthStr] = targetMonth.split("-");
const year = parseInt(yearStr, 10);
const month = parseInt(monthStr, 10);
if (!year || !month) return null;
const startDate = `${yearStr}-${monthStr.padStart(2, "0")}-01`;
const lastDay = new Date(year, month, 0).getDate();
const endDate = `${yearStr}-${monthStr.padStart(2, "0")}-${String(lastDay).padStart(2, "0")}`;
return { startDate, endDate };
}
/**
* 店面配置-门店主机厂交付数导入
* 限制:当前日期>20号:仅允许选择当前月份;当前日期≤20号:允许选择当前月份和上个月
*/
export const rangePickerOptions_deliveryQuantity_import = {
disabledDate: (time) => {
const current = new Date();
const currentYear = current.getFullYear();
const currentMonth = current.getMonth();
const currentDay = current.getDate();
const allowedMonths = [];
if (currentDay > 20) {
allowedMonths.push({ year: currentYear, month: currentMonth });
} else {
allowedMonths.push(
{ year: currentYear, month: currentMonth },
currentMonth === 0
? { year: currentYear - 1, month: 11 }
: { year: currentYear, month: currentMonth - 1 },
);
}
const year = time.getFullYear();
const month = time.getMonth();
const isAllowed = allowedMonths.some(
m => m.year === year && m.month === month,
);
return !isAllowed;
},
};
......@@ -899,7 +899,7 @@ export default {
salesTypeList: [
{
confId: "0",
confLabel: "门店引流 - 售前",
confLabel: "销售端引流售前",
},
{
confId: "1",
......@@ -909,6 +909,10 @@ export default {
confId: "2",
confLabel: "自然到店",
},
{
confId: "3",
confLabel: "交付端引流售前",
},
],
productTypeList: [],
saleFlagList: [
......@@ -1075,13 +1079,14 @@ export default {
this.getOptionsList();
},
/** 客户来源:0 门店引流-售前 / 1 门店引流-售后 / 2 自然到店 */
/** 客户来源:0 销售端引流售前 / 1 门店引流-售后 / 2 自然到店 / 3 交付端引流售前 */
getSalesTypeLabel(v) {
if (v === null || v === undefined || v === "") return "-";
const map = {
0: "门店引流 - 售前",
0: "销售端引流 - 售前",
1: "门店引流 - 售后",
2: "自然到店",
3: "交付端引流 - 售前",
};
const n = Number(v);
return map[n] !== undefined ? map[n] : "-";
......
......@@ -528,14 +528,36 @@ export default {
...mapActions({ close: 'd2admin/page/close' }),
...mapActions('d2admin/base', ['get']),
...mapActions('d2admin/user', ['actionSetDownloadList']),
/** 与订单列表一致:0 门店引流-售前 / 1 门店引流-售后 / 2 自然到店 */
getSalesTypeLabel(v) {
if (v === null || v === undefined || v === '') return '-'
const map = {
0: '门店引流 - 售前',
1: '门店引流 - 售后',
2: '自然到店'
/** 轻改 sceneType=1;权益 sceneType=0,文案与权益列表保持一致 */
isLightChangeOrder() {
const sceneType = this.detail?.sceneType ?? this.getRouteDetailSceneType()
if (sceneType !== undefined && sceneType !== null && sceneType !== "") {
return Number(sceneType) === 1
}
return this.scene === "jpsj"
},
getRouteDetailSceneType() {
try {
const routerParams = JSON.parse(this.$route.query.detail || "{}")
return routerParams?.sceneType
} catch (e) {
return undefined
}
},
getSalesTypeLabel(v) {
if (v === null || v === undefined || v === "") return "-"
const map = this.isLightChangeOrder()
? {
0: "销售端引流 - 售前",
1: "门店引流 - 售后",
2: "自然到店",
3: "交付端引流 - 售前"
}
: {
0: "门店引流 - 售前",
1: "门店引流 - 售后",
2: "自然到店"
}
const n = Number(v)
return map[n] !== undefined ? map[n] : '-'
},
......
......@@ -70,7 +70,8 @@
format="yyyy-MM"
placeholder="选择月"
:picker-options="pickerOption"
class="sortInput">
class="sortInput"
@change="handleTargetMonthChange">
</el-date-picker>
</div>
<div v-else>
......@@ -79,6 +80,20 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="归属周期:"
:prop="operationType !='detail'?'periodRange':''">
<div v-if="operationType !='detail'">
<period-date-range v-model="formData.periodRange"
:target-month="formData.targetMonth" />
</div>
<div v-else>
{{ formData.periodDateStr || '-' }}
</div>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="交付数:"
:prop="operationType !='detail'?'targetValue':''">
<div v-if="operationType !='detail'">
......@@ -92,17 +107,12 @@
</div>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="录入时间:"
v-if="operationType!='add'">
{{ formData.createdDateShow }}
</el-form-item>
</el-col>
<el-col :span="12">
</el-col>
</el-row>
</el-form>
<div v-if="operationType!='add'">
......@@ -123,14 +133,18 @@
<script>
import { Util, deepClone } from '@/common/util'
import { limitPrice, rangePickerOptions_deliveryQuantity } from '@/common/format'
import { limitPrice, rangePickerOptions_deliveryQuantity, getMonthDateRange } from '@/common/format'
import { getList } from "@api/merchant"
import { outputValue_operTypeOpt } from "@/common/constants.js"
import { insertDeliverTargeConfig, updateDeliverTargeConfig, getById_deliver, getCarBrand } from '@api/shopConfig'
import periodDateRange from './periodDateRange'
// import reportTrackFunMixin from '@/mixins/reportTrackFunMixin'
export default {
name: 'EditDialog',
components: {
periodDateRange
},
// mixins: [reportTrackFunMixin],
directives: {
'el-select-loadmore': {
......@@ -169,7 +183,9 @@ export default {
childId: '',
childName: '',
targetValue: '',
targetMonth: ''
targetMonth: '',
periodRange: [],
periodDateStr: ''
},
oldVal: {
targetValue: ''
......@@ -183,6 +199,30 @@ export default {
merchantId: [{ required: true, message: '请选择4S门店', trigger: 'change' }],
brand: [{ required: true, message: '请选择品牌', trigger: 'change' }],
targetMonth: [{ required: true, message: '请选择交付目标月份', trigger: 'change' }],
periodRange: [{
required: true,
trigger: 'change',
validator: (rule, value, callback) => {
if (!value || value.length !== 2 || !value[0] || !value[1]) {
callback(new Error('请选择归属周期'))
return
}
const monthRange = getMonthDateRange(this.formData.targetMonth)
if (!monthRange) {
callback(new Error('请先选择交付目标月份'))
return
}
if (value[0] !== monthRange.startDate) {
callback(new Error('归属周期开始日期必须为当月1号'))
return
}
if (value[1] < value[0] || value[1] > monthRange.endDate) {
callback(new Error('归属周期结束日期无效'))
return
}
callback()
}
}],
targetValue: [{ required: true, message: '请输入交付数', trigger: 'blur' }]
},
searchForm: {
......@@ -338,10 +378,31 @@ export default {
this.formData.createdDateShow = this.formData.createdDate
? Util.dateFormate(this.formData.createdDate, 'YYYY-MM-DD HH:mm:ss')
: ""
this.fillPeriodRange()
}).catch(() => {
})
},
fillPeriodRange() {
if (this.operationType === 'detail') return
if (this.formData.periodStartDate && this.formData.periodEndDate) {
this.formData.periodRange = [this.formData.periodStartDate, this.formData.periodEndDate]
return
}
if (this.formData.periodDateStr) {
const parts = this.formData.periodDateStr.split('-')
if (parts.length >= 2) {
const start = parts[0].replace(/\//g, '-')
const end = parts.slice(1).join('-').replace(/\//g, '-')
this.formData.periodRange = [start, end]
}
}
},
handleTargetMonthChange() {
this.formData.periodRange = []
},
choose4S(merchantId) {
this.formData.brand = []
this.formData.brandId = ''
......@@ -392,6 +453,9 @@ export default {
this.$refs.infoForm.validate(valid => {
if (valid) {
var params = deepClone(this.formData)
params.periodStartDate = params.periodRange[0]
params.periodEndDate = params.periodRange[1]
delete params.periodRange
if (params.id) {
updateDeliverTargeConfig(params).then(res => {
this.notice.okTips('操作成功')
......
<!-- 归属周期:日期区间 + 全月 -->
<template>
<div class="period-date-range">
<el-date-picker v-model="innerRange"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
format="yyyy/MM/dd"
:disabled="disabled || !targetMonth"
:picker-options="periodPickerOptions"
class="period-picker"
@change="handleRangeChange" />
<el-checkbox v-model="isFullMonth"
:disabled="disabled || !targetMonth"
class="full-month-check"
@change="handleFullMonthChange">
全月
</el-checkbox>
</div>
</template>
<script>
import { getMonthDateRange } from '@/common/format'
export default {
name: 'PeriodDateRange',
props: {
value: {
type: Array,
default: () => []
},
targetMonth: {
type: String,
default: ''
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
innerRange: [],
isFullMonth: false,
rangePickAnchor: null
}
},
computed: {
periodPickerOptions() {
const monthRange = getMonthDateRange(this.targetMonth)
return {
onPick: ({ minDate, maxDate }) => {
if (maxDate) {
this.rangePickAnchor = null
} else if (minDate) {
this.rangePickAnchor = minDate
}
},
disabledDate: (time) => {
if (!monthRange) return true
const { startDate, endDate } = monthRange
const timeStr = this.formatDateStr(time)
if (timeStr < startDate || timeStr > endDate) return true
if (!this.rangePickAnchor) {
return timeStr !== startDate
}
return timeStr < startDate || timeStr > endDate
}
}
}
},
watch: {
value: {
immediate: true,
handler(val) {
this.innerRange = val && val.length ? [...val] : []
this.syncFullMonthState()
}
},
targetMonth(val, oldVal) {
if (val !== oldVal) {
this.rangePickAnchor = null
this.innerRange = []
this.isFullMonth = false
this.emitChange([])
}
}
},
methods: {
formatDateStr(time) {
const y = time.getFullYear()
const m = String(time.getMonth() + 1).padStart(2, '0')
const d = String(time.getDate()).padStart(2, '0')
return `${y}-${m}-${d}`
},
syncFullMonthState() {
if (!this.targetMonth || !this.innerRange || this.innerRange.length !== 2) {
this.isFullMonth = false
return
}
const { startDate, endDate } = getMonthDateRange(this.targetMonth) || {}
this.isFullMonth = this.innerRange[0] === startDate && this.innerRange[1] === endDate
},
normalizeRange(range) {
if (!range || range.length !== 2 || !this.targetMonth) return []
const { startDate, endDate } = getMonthDateRange(this.targetMonth) || {}
if (!startDate || !endDate) return []
let end = range[1]
if (end < startDate) end = startDate
if (end > endDate) end = endDate
return [startDate, end]
},
emitChange(range) {
this.$emit('input', range)
this.$emit('change', range)
},
handleRangeChange(val) {
this.rangePickAnchor = null
if (!val || val.length !== 2) {
this.isFullMonth = false
this.emitChange([])
return
}
const normalized = this.normalizeRange(val)
this.innerRange = normalized
this.syncFullMonthState()
this.emitChange(normalized)
},
handleFullMonthChange(checked) {
if (checked) {
const { startDate, endDate } = getMonthDateRange(this.targetMonth) || {}
if (startDate && endDate) {
this.innerRange = [startDate, endDate]
this.emitChange([startDate, endDate])
}
} else {
this.innerRange = []
this.emitChange([])
}
}
}
}
</script>
<style lang="scss" scoped>
.period-date-range {
display: flex;
align-items: center;
width: 90%;
.period-picker {
flex: 1;
}
.full-month-check {
margin-left: 10px;
white-space: nowrap;
}
}
</style>
......@@ -91,7 +91,26 @@
title="交付数导入"
@closeDialog="handleImport"
@confirmDialog="handleConfirmImport"
@downloadTemplate="exportTemplate" />
@downloadTemplate="exportTemplate">
<template #prepend>
<el-form-item label="交付目标月份:"
required>
<el-date-picker v-model="importForm.targetMonth"
type="month"
value-format="yyyy-MM"
format="yyyy-MM"
placeholder="选择月"
:picker-options="importMonthPickerOption"
style="width: 100%;"
@change="handleImportTargetMonthChange" />
</el-form-item>
<el-form-item label="归属周期:"
required>
<period-date-range v-model="importForm.periodRange"
:target-month="importForm.targetMonth" />
</el-form-item>
</template>
</d2-file-import-dialog>
<!-- 新增&修改&详情 -->
<edit-dialog :visible.sync="editVisible"
v-if="editVisible"
......@@ -106,9 +125,11 @@ import { mapActions, mapState } from "vuex"
import { Util, deepClone } from "@/common/util"
import inputRange from './components/inputRange'
import editDialog from "./components/editDialog"
import periodDateRange from './components/periodDateRange'
import { listWithPage_deliver, deliverTargeConfigImport, deleteById_deliver, distinctAllBrand } from '@api/shopConfig'
import { getList } from "@api/merchant"
import reportTrackFunMixin from '@/mixins/reportTrackFunMixin'
import { rangePickerOptions_deliveryQuantity_import } from '@/common/format'
export default {
name: "DeliveryQuantity",
mixins: [reportTrackFunMixin], // 导入混入
......@@ -199,6 +220,14 @@ export default {
width: "150"
},
{
label: "归属周期",
prop: "periodDateStr",
width: "200",
formatter: (cellValue) => {
return cellValue.periodDateStr || "-"
}
},
{
label: "交付数",
prop: "targetValue",
width: "200",
......@@ -226,6 +255,11 @@ export default {
pageSize: 20,
fileVisible: false,
editVisible: false,
importMonthPickerOption: rangePickerOptions_deliveryQuantity_import,
importForm: {
targetMonth: '',
periodRange: []
},
track_event_code: 'shopConfig_deliver_list',
track_businessParam_key: 'searchForm'
}
......@@ -233,7 +267,8 @@ export default {
components: {
inputRange,
editDialog
editDialog,
periodDateRange
},
computed: {
...mapState({
......@@ -436,12 +471,43 @@ export default {
},
handleImport() {
if (this.fileVisible) {
this.resetImportForm()
}
this.fileVisible = !this.fileVisible
},
resetImportForm() {
this.importForm = {
targetMonth: '',
periodRange: []
}
},
handleImportTargetMonthChange() {
this.importForm.periodRange = []
},
validateImportForm() {
if (!this.importForm.targetMonth) {
this.notice.warningTips('请选择交付目标月份')
return false
}
const { periodRange } = this.importForm
if (!periodRange || periodRange.length !== 2 || !periodRange[0] || !periodRange[1]) {
this.notice.warningTips('请选择归属周期')
return false
}
return true
},
handleConfirmImport({ fileName, fileData }) {
if (!this.validateImportForm()) return
var params = {
file: fileData
file: fileData,
targetMonth: this.importForm.targetMonth,
periodStartDate: this.importForm.periodRange[0],
periodEndDate: this.importForm.periodRange[1]
}
deliverTargeConfigImport(params).then(res => {
if (res) {
......@@ -455,6 +521,7 @@ export default {
this.actionSetDownloadList({ list, type: 'updateList' })
this.notice.okTips('上传成功')
this.$refs.recordTable.refreshTable(false, true)
this.resetImportForm()
this.handleImport()
}
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!