Commit c4be7d8b by 张立顺

fix bug

1 parent 04d23d73
......@@ -35,14 +35,22 @@ alwaysApply: true
## C. 测试(改后必做)
- **纯函数 / service**:在 `tests/` 下补 `*.test.mjs`(`node:test` + `createRequire`),运行并报告结果
- **纯函数 / service**:在 `tests/` 下补 `*.test.mjs`(`node:test`,优先 ES `import` 被测模块),运行并报告结果
- **createOrder services**:`npm run test:createOrder`
- **全量**:`npm test`
- 无测试的新纯函数应补最小覆盖
- 页面/UI 逻辑无法自动化时,列出手动回归路径
## D. 模块导出(页面 services / 组件 helper)
- 页面 `services/`、组件 `.helpers.js` / `.pagination.js` 等纯函数模块:**必须使用 ES `export`**,禁止 `module.exports`
- 页面/组件引用 helper:**优先 ES `import`**,避免 `import` 引用 `module.exports` 混用导致微信依赖分析误判
- 保持 `project.config.json` 中 `ignoreUploadUnusedFiles: true`(上传过滤无依赖文件以控制包体);新增页面 helper 须 ES export,必要时在 `packOptions.include` 登记兜底
- 开发/测试/元数据文件走 `packOptions.ignore`(如 `tests/`、`package-lock.json`、`.cursor/`)
## 改动自检清单
- [ ] 新增/修改函数已补 JSDoc
- [ ] 新增/修改 helper 使用 ES export(见 D)
- [ ] 已检索跨页引用并说明影响面
- [ ] 已运行相关测试(或说明手动回归项)
module.exports = {
form: {
export const form = {
merchantRange: {
data: [],
key: 'sellerMerchantId',
......@@ -53,5 +52,4 @@ module.exports = {
key: 'baseSceneCode',
type: 'array'
},
},
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
* @file 客户档案选择弹框:分页拉取工单客户列表,不调 setData 外的页面实例。
*/
import api from '../../api/api.js'
const {
import {
DEFAULT_PAGE_SIZE,
canLoadMorePage,
mapCustomerListWithCarType
} = require('./customerInfo.pagination.js')
} from './customerInfo.pagination.js'
Component({
properties: {
......
......@@ -32,7 +32,7 @@ function mapCustomerListWithCarType(list) {
})
}
module.exports = {
export {
DEFAULT_PAGE_SIZE,
canLoadMorePage,
mapCustomerListWithCarType
......
......@@ -177,7 +177,7 @@
- **展示条件**:周历选中当天(`isTodayReport`)且表单加载成功;入口条在 `scroll-view` 内随表单滚动
- **入口条**:展示 `todayPlanStore.count`;只读态(`formDisabled`)隐藏「查看客户」按钮
- **弹层**:组件 [`today-plan-customer-popup`](../components/today-plan-customer-popup/);日期 ±7 天切换;多选后「添加到洽谈明细」
- **弹层**:组件 [`today-plan-customer-popup`](../components/today-plan-customer-popup/);日期前后各 6 天(含今天共 7 天)切换;多选后「添加到洽谈明细」
- **导入规则**([`negotiationCustomerImport.js`](../services/negotiationCustomerImport.js)):
- 仅写入**当前可见** F3 subform(F3-1~F3-4)
- 全有或全无;任一可见 subform 超 20 行 → `wx.showModal`「添加失败」,文案为**对应 F3 子表单 `label`**(如「问界鸿蒙洽谈明细 (延保)一次最多添加20个客户」)
......@@ -216,7 +216,7 @@
- `IT-DISC-STAFF-*` / `IT-SUMMARY-*` — 汇总员工列表与 jsonContent 表格转换
- `IT-NEG-DETAIL-GET-001` — detail.get templateType=3
- `IT-NEG-BRAND-CACHE-001`
- `IT-PLAN-DATE-001` ~ `IT-PLAN-DATE-005` — 弹层日期文案、±7 边界、手机号脱敏(`today-plan-date.test.mjs`)
- `IT-PLAN-DATE-001` ~ `IT-PLAN-DATE-005` — 弹层日期文案、前后各 6 天边界、手机号脱敏(`today-plan-date.test.mjs`)
- `IT-PLAN-ADAPTER-001` ~ `IT-PLAN-ADAPTER-004` — todayPlanStore mock/real 归一(`negotiationTodayPlanStoreAdapters.test.mjs`)
- `IT-PLAN-IMPORT-001` ~ `IT-PLAN-IMPORT-003` — F3 字段映射、20 行上限、engine 写入(`negotiationCustomerImport.test.mjs`)
- `upgrade-icon-url.test.mjs` — CDN 图标 URL 拼接
......
......@@ -44,7 +44,7 @@
| IT-APP-LISTS-* | app-save-lists-from-json.test.mjs | `npm test` | buildAppNormalizedListsFromJsonContent |
| IT-SUBFORM-MAX-001 ~ 004 | subform-max-rows.test.mjs | `npm test` | subform 最多 20 行 |
| IT-STORE-APP-* / IT-STORE-ECHO-* | store-app-json-*.test.mjs | `npm test` | 门店保存/回显 jsonContent |
| IT-PLAN-DATE-001 ~ 005 | today-plan-date.test.mjs | `npm test` | 弹层日期文案、±7 边界、手机号脱敏 |
| IT-PLAN-DATE-001 ~ 005 | today-plan-date.test.mjs | `npm test` | 弹层日期文案、前后各 6 天边界、手机号脱敏 |
| IT-PLAN-ADAPTER-001 ~ 004 | negotiationTodayPlanStoreAdapters.test.mjs | `npm test` | todayPlanStore mock/real 与响应归一 |
| IT-PLAN-IMPORT-001 ~ 003 | negotiationCustomerImport.test.mjs | `npm test` | F3 字段映射、20 行上限、engine 写入 |
| upgrade-icon-url.test.mjs | upgrade-icon-url | `npm test` | CDN 图标 URL 三类路径拼接 |
......
......@@ -73,7 +73,7 @@ function formatPlanStoreDateLabel(dateStr) {
}
/**
* 是否可切换日期(过去含今天共 7 天;未来最多 +7 天)
* 是否可切换日期(前后各含今天共 7 天,偏移 ±6)
* @param {string} currentDateStr
* @param {number} offset -1 前一天 / +1 后一天
* @returns {boolean}
......@@ -89,15 +89,15 @@ function canShiftPlanStoreDate(currentDateStr, offset) {
}
/**
* 判断日期是否在可选范围内(过去含今天共 PLAN_STORE_DATE_RANGE_DAYS 天;未来最多 +PLAN_STORE_DATE_RANGE_DAYS 天)
* 判断日期是否在可选范围内(前后各含今天共 PLAN_STORE_DATE_RANGE_DAYS 天,偏移 ±(N-1))
* @param {string} dateStr
* @returns {boolean}
*/
function isPlanStoreDateInRange(dateStr) {
const diff = diffPlanStoreDaysFromToday(dateStr)
// 含当天共 N 天 → 最早偏移 -(N-1)
const pastMinDiff = -(PLAN_STORE_DATE_RANGE_DAYS - 1)
return diff >= pastMinDiff && diff <= PLAN_STORE_DATE_RANGE_DAYS
// 含当天共 N 天 → 前后各偏移 N-1
const maxOffset = PLAN_STORE_DATE_RANGE_DAYS - 1
return diff >= -maxOffset && diff <= maxOffset
}
/**
......
......@@ -22,11 +22,15 @@ describe('today-plan-date', () => {
assert.match(label, /月/)
})
it('IT-PLAN-DATE-002: isPlanStoreDateInRange past 7 days incl today, future +7', () => {
const dPlus = new Date()
dPlus.setDate(dPlus.getDate() + 7)
const plus7 = timeUtil.formatDateStr(dPlus)
assert.equal(isPlanStoreDateInRange(plus7), true)
it('IT-PLAN-DATE-002: isPlanStoreDateInRange past/future 7 days incl today (offset ±6)', () => {
const dPlus6 = new Date()
dPlus6.setDate(dPlus6.getDate() + 6)
const plus6 = timeUtil.formatDateStr(dPlus6)
assert.equal(isPlanStoreDateInRange(plus6), true)
const dPlus7 = new Date()
dPlus7.setDate(dPlus7.getDate() + 7)
const plus7 = timeUtil.formatDateStr(dPlus7)
assert.equal(isPlanStoreDateInRange(plus7), false)
const dMinus6 = new Date()
dMinus6.setDate(dMinus6.getDate() - 6)
const minus6 = timeUtil.formatDateStr(dMinus6)
......@@ -45,6 +49,10 @@ describe('today-plan-date', () => {
const next = shiftPlanStoreDate(today, 1)
assert.ok(next)
assert.equal(canShiftPlanStoreDate(today, 1), true)
const dPlus6 = new Date()
dPlus6.setDate(dPlus6.getDate() + 6)
const plus6 = timeUtil.formatDateStr(dPlus6)
assert.equal(canShiftPlanStoreDate(plus6, 1), false)
})
it('IT-PLAN-DATE-004: maskCustomerPhone masks 11-digit phone', () => {
......
......@@ -49,15 +49,76 @@
"type": "folder"
},
{
"value": "tabWorkOrder/pages/createOrder/tests",
"type": "folder"
},
{
"value": "tabWorkOrder/pages/refundApply/tests",
"type": "folder"
},
{
"value": "tabWorkOrder/pages/upgradeStaffDaily/tests",
"type": "folder"
},
{
"value": "tests",
"type": "folder"
},
{
"value": "packageEquity/docs",
"type": "folder"
},
{
"value": "cdn-upload",
"type": "folder"
},
{
"value": "package-lock.json",
"type": "file"
},
{
"value": "package.json",
"type": "file"
},
{
"value": "project.private.config.json",
"type": "file"
},
{
"value": "jsconfig.json",
"type": "file"
},
{
"value": ".cursor",
"type": "folder"
},
{
"value": "scripts",
"type": "folder"
},
{
"value": ".cloudbase",
"type": "folder"
}
],
"include": []
"include": [
{
"value": "tabWorkOrder/pages/createOrder/services/pagePopupLock.js",
"type": "file"
},
{
"value": "tabWorkOrder/pages/upgradeStaffDaily/services/dailyReportInconsistency.helpers.js",
"type": "file"
},
{
"value": "components/CustomerInfo/customerInfo.pagination.js",
"type": "file"
},
{
"value": "components/Confirm/form.js",
"type": "file"
}
]
},
"setting": {
"urlCheck": false,
......@@ -103,6 +164,6 @@
"tabIndent": "insertSpaces",
"tabSize": 2
},
"appid": "wx4e697bcf4954ceef",
"appid": "wx570d9331f9ace0bd",
"simulatorPluginLibVersion": {}
}
\ No newline at end of file
......@@ -133,6 +133,11 @@ Component({
orderObj
})
},
/** 取消时通知父页面关闭弹框;内部 show 兼容未绑 cancel 的引用页 */
onPopupCancel() {
this.setData({ show: false })
this.triggerEvent('cancel')
},
async confirm() {
let data = this.data.orderObj
let thisPage = wx.$router.getPageInstance()
......@@ -144,6 +149,7 @@ Component({
this.setData({
show: false
})
this.triggerEvent('confirm', data)
},
}
})
<!--components/subShopMerchant/subShopMerchant.wxml-->
<popup show="{{show}}" bindconfirm="confirm" title="{{title}}">
<popup show="{{show}}" bindconfirm="confirm" bindcancel="onPopupCancel" title="{{title}}">
<scroll-view class="sub-shop-merchant-box" scroll-y enhanced="{{true}}" show-scrollbar="{{false}}">
<view class="box">
<!-- <view class="sub-title text-center">{{title}}</view> -->
......
......@@ -565,6 +565,14 @@ Page({
const popupKey = e.currentTarget.dataset.popupKey
this.setData(closePagePopupPatch(popupKey))
},
/** 二级流量方确认:组件已写入 orderObj,此处仅关弹框解锁 */
onSubShopMerchantConfirm() {
this.setData(closePagePopupPatch('subShopMerchantBox'))
},
/** 多规格商品确认:SkuGoods 已写入 goodsList,此处仅关弹框解锁 */
onSkuGoodsConfirm() {
this.setData(closePagePopupPatch('skuGoodsBox'))
},
closeTips() {
this.setData({
showTips: false
......
......@@ -825,6 +825,9 @@ value="{{ orderObj.remark }}"
<sub-shop-merchant
show="{{ subShopMerchantBox }}"
title="选择二级流量方"
bindconfirm="onSubShopMerchantConfirm"
bindcancel="onPagePopupCancel"
data-popup-key="subShopMerchantBox"
selectedSelesMerchantId="{{ orderObj.merchantId || '' }}"
selectedCustomerInfo="{{ orderObj.customer.customerId || '' }}"
selectedSubShopMerchantId="{{ orderObj.subShopMerchantId || '' }}"
......@@ -872,7 +875,15 @@ value="{{ orderObj.remark }}"
isSolarFilm="{{ true }}"
baseConfigData="{{ baseConfigData }}"
/>
<sku-goods show="{{ skuGoodsBox }}" sceneType="1" goodsData="{{ skuGoodsData }}" chooseGoodsList="{{ goodsList }}"></sku-goods>
<sku-goods
show="{{ skuGoodsBox }}"
sceneType="1"
goodsData="{{ skuGoodsData }}"
chooseGoodsList="{{ goodsList }}"
bindconfirm="onSkuGoodsConfirm"
bindcancel="onPagePopupCancel"
data-popup-key="skuGoodsBox"
></sku-goods>
<customerInfo show="{{ customerInfoBox }}" bindconfirm="chooseCustomerInfo" bindcancel="onCustomerInfoCancel" />
<van-popup show="{{ showSource }}" position="bottom" bind:close="onCloseSource">
<van-picker
......
......@@ -113,7 +113,7 @@ function mergeSetDataForPopupLock(data, updates) {
return merged
}
module.exports = {
export {
PAGE_POPUP_KEYS,
computePagePopupVisible,
shouldSyncPagePopup,
......
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
import {
computePagePopupVisible,
shouldSyncPagePopup,
closePagePopupPatch,
mergeSetDataForPopupLock
} = require('../services/pagePopupLock.js')
} from '../services/pagePopupLock.js'
describe('pagePopupLock', () => {
it('computePagePopupVisible is false when no popup open', () => {
......@@ -58,4 +55,19 @@ describe('pagePopupLock', () => {
const merged = mergeSetDataForPopupLock(data, updates)
assert.equal(computePagePopupVisible(merged), false)
})
it('closing subShopMerchantBox unlocks page when no other popup open', () => {
const data = { subShopMerchantBox: true, customerInfoBox: false }
const merged = mergeSetDataForPopupLock(
data,
closePagePopupPatch('subShopMerchantBox')
)
assert.equal(computePagePopupVisible(merged), false)
})
it('closing skuGoodsBox unlocks page when no other popup open', () => {
const data = { skuGoodsBox: true, goodsBox: false }
const merged = mergeSetDataForPopupLock(data, closePagePopupPatch('skuGoodsBox'))
assert.equal(computePagePopupVisible(merged), false)
})
})
......@@ -13,7 +13,7 @@ import {
import api from '../../api'
import comApi from '~/api/api'
import { setConfigInfo } from '~/store/index'
const {
import {
isStaffCountInconsistent,
findInconsistentBrandField,
hasExistingInputErrors,
......@@ -21,7 +21,7 @@ const {
buildBrandFieldInconsistencyMessage,
buildBrandCheckWarningLines,
STAFF_DAILY_FIELD_KEYS
} = require('../upgradeStaffDaily/services/dailyReportInconsistency.helpers.js')
} from '../upgradeStaffDaily/services/dailyReportInconsistency.helpers.js'
let toastList = {
deliveryCount: '新车交付数不能为空',
// filmToShopCount: '到店流量数(太阳膜)不能为空',
......
......@@ -185,7 +185,7 @@ function buildBrandCheckWarningLines(failedItems) {
)
}
module.exports = {
export {
BRAND_INCONSISTENCY_FIELD_KEYS,
UPGRADE_STAFF_DAILY_FIELD_KEYS,
STAFF_DAILY_FIELD_KEYS,
......
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
import {
isStaffCountInconsistent,
findInconsistentBrandField,
hasExistingInputErrors,
buildBrandCheckWarningLines
} = require('../services/dailyReportInconsistency.helpers.js')
buildBrandCheckWarningLines,
STAFF_DAILY_FIELD_KEYS
} from '../services/dailyReportInconsistency.helpers.js'
const userInfo = { uuid: 'user-b' }
const orderObjBase = {
......@@ -91,9 +89,6 @@ describe('dailyReportInconsistency.helpers', () => {
})
it('findInconsistentBrandField uses staffDaily field keys', () => {
const { STAFF_DAILY_FIELD_KEYS, findInconsistentBrandField } = require(
'../services/dailyReportInconsistency.helpers.js'
)
assert.ok(STAFF_DAILY_FIELD_KEYS.includes('extendedWarrantyToShopCount'))
const result = findInconsistentBrandField({
carBandList: [
......
......@@ -12,14 +12,14 @@ import api from '../../api'
import apiCon from '~/api/api'
import { getYQInfo } from '~/store/index'
import comApi from '~/api/api'
const {
import {
isStaffCountInconsistent,
findInconsistentBrandField,
hasExistingInputErrors,
buildStaffCountInconsistencyMessage,
buildBrandFieldInconsistencyMessage,
buildBrandCheckWarningLines
} = require('./services/dailyReportInconsistency.helpers.js')
} from './services/dailyReportInconsistency.helpers.js'
let toastList = {
deliveryCount: '新车交付数不能为空',
// filmToShopCount: '到店流量数(太阳膜)不能为空',
......
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
import {
DEFAULT_PAGE_SIZE,
canLoadMorePage,
mapCustomerListWithCarType
} = require('../components/CustomerInfo/customerInfo.pagination.js')
} from '../components/CustomerInfo/customerInfo.pagination.js'
describe('customerInfo.pagination', () => {
it('DEFAULT_PAGE_SIZE is 20', () => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!