feat(web-admin): unify CRM confirm dialogs for customer and product.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-10-18 18:26:56 +08:00
1 parent 5c791b00cb
commit 4fd178499e
17 files changed
+4186 -206

No files matched your search

@@ -0,0 +1,43 @@
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
const root = new URL('../src/views/m/crm/customer/', import.meta.url)
const files = [
'index.vue',
'detail.vue',
'form.vue',
'ContactPanel.vue',
'FollowPanel.vue',
'InvoicePanel.vue',
'OpportunityActions.vue',
'CustomerPoolSheet.vue'
]
const sources = {}
for (const name of files) {
sources[name] = await readFile(new URL(name, root), 'utf8')
}
const customerScss = await readFile(new URL('customer.scss', root), 'utf8')
assert.match(
customerScss,
/van-dialog:not\(\.mp-crm-dialog\)/,
'客户 scss 不得用旧 Dialog 按钮样式压扁 mp-crm-dialog'
)
for (const [name, src] of Object.entries(sources)) {
assert.doesNotMatch(src, /showConfirmDialog\s*\(/, `${name} 不得直接调用 showConfirmDialog`)
assert.match(src, /showCrmConfirmDialog|from '@\/utils\/mp-crm-confirm'/, `${name} 必须使用 CRM 确认弹窗`)
}
assert.match(sources['index.vue'], /kind:\s*'danger'/, '列表删除客户须 danger')
assert.match(sources['detail.vue'], /kind:\s*'danger'/, '详情删除客户须 danger')
assert.match(sources['ContactPanel.vue'], /kind:\s*'danger'/, '删除联系人须 danger')
assert.match(sources['ContactPanel.vue'], /kind:\s*'default'/, '设主要联系人须 default')
assert.match(sources['FollowPanel.vue'], /kind:\s*'danger'/, '删除跟进须 danger')
assert.match(sources['InvoicePanel.vue'], /kind:\s*'danger'/, '删除开票须 danger')
assert.match(sources['OpportunityActions.vue'], /kind:\s*'danger'/, '删除商机须 danger')
assert.match(sources['form.vue'], /kind:\s*'default'/, '新增字典项须 default')
assert.match(sources['CustomerPoolSheet.vue'], /kind:\s*'default'/, '放入公海须 default')
console.log('mp-crm-customer-confirm-dom: ok')
@@ -2,27 +2,29 @@ import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
const root = new URL('../src/views/m/crm/product/', import.meta.url)
const util = await readFile(new URL('../src/utils/mp-crm-product-confirm.ts', import.meta.url), 'utf8')
const scss = await readFile(new URL('product.scss', root), 'utf8')
const util = await readFile(new URL('../src/utils/mp-crm-confirm.ts', import.meta.url), 'utf8')
const alias = await readFile(new URL('../src/utils/mp-crm-product-confirm.ts', import.meta.url), 'utf8')
const primitives = await readFile(new URL('../src/styles/mp-crm-primitives.scss', import.meta.url), 'utf8')
const list = await readFile(new URL('index.vue', root), 'utf8')
const detail = await readFile(new URL('detail.vue', root), 'utf8')
const categories = await readFile(new URL('categories.vue', root), 'utf8')
assert.match(util, /ProductConfirmKind\s*=\s*'default'\s*\|\s*'danger'/, 'helper 必须支持 danger kind')
assert.match(util, /CrmConfirmKind\s*=\s*'default'\s*\|\s*'danger'/, 'helper 必须支持 danger kind')
assert.match(util, /kind\s*===\s*'danger'/, 'helper 必须分支处理 danger')
assert.match(util, /mp-product-dialog--danger/, 'helper 必须带 danger className')
assert.match(util, /mp-product-dialog__title/, '方案 B 标题须写入 HTML(图标在上)')
assert.match(util, /mp-crm-dialog--danger/, 'helper 必须带 danger className')
assert.match(util, /mp-crm-dialog__title/, '方案 B 标题须写入 HTML')
assert.match(util, /#dc2626/, '删除确认色必须为危险红')
assert.match(util, /#0a9f6d/, '普通确认色必须为三墙绿')
assert.doesNotMatch(util, /round-button/, '禁止 round-button 主题')
assert.doesNotMatch(util, /#10b981/, '禁止 Fresh Mint')
assert.match(scss, /body \.van-dialog\.mp-product-dialog/, 'scss 必须限定产品 Dialog')
assert.match(scss, /mp-product-dialog--danger/, 'scss 必须覆盖危险确认键')
assert.match(scss, /mp-product-dialog__warn-icon/, 'scss 必须有警示图标')
assert.match(scss, /mp-product-dialog__title/, 'scss 必须有居中标题')
assert.match(scss, /text-align:\s*center/, '标题/文案须居中')
assert.doesNotMatch(scss, /#10b981/, 'scss 禁止 Fresh Mint')
assert.match(alias, /showCrmConfirmDialog as showProductConfirmDialog/, '产品侧须转发共用 helper')
assert.match(primitives, /body \.van-dialog\.mp-crm-dialog/, 'primitives 必须限定 CRM Dialog')
assert.match(primitives, /mp-crm-dialog--danger/, 'primitives 必须覆盖危险确认键')
assert.match(primitives, /mp-crm-dialog__warn-icon/, 'primitives 必须有警示图标')
assert.match(primitives, /mp-crm-dialog__title/, 'primitives 必须有居中标题')
assert.doesNotMatch(primitives, /#10b981/, 'scss 禁止 Fresh Mint')
for (const [name, src] of [
['index', list],