Commit 3f7385ab by 张立顺

Merge branch 'SAAS+V5.7.1' of http://192.168.3.233:8090/saas_plus/dj-car-life-sy…

…stem into SAAS+V5.7.1
2 parents aa4d9ae1 38eb4b4d
Showing 132 changed files with 3572 additions and 478 deletions
# 忽略目录
build/
tests/
node_modules/
# node 覆盖率文件
coverage/
# 忽略文件
**/*-min.js
**/*.min.js
**/*.vue
# DJ Car Life System - AI Agent Instructions
## Project Overview
嘀加智享车生活后台系统是一个大型Vue 2企业管理后台系统,涵盖车主生活管理、订单管理、财务清分、员工管理等多个业务领域。支持多个API网关和签名方案。
## Architecture Essentials
### Tech Stack
- **Frontend**: Vue 2.6 + Vue Router 3.0 + Vuex 3.0
- **UI Framework**: Element UI 2.13
- **Build**: Vue CLI 5 + Webpack 5 + Babel
- **HTTP**: Axios with custom signing layer
- **State Management**: Vuex with d2admin framework module
- **Node Version**: 14.21.3
### Project Structure
```
src/
├── api/ # API layer with custom request signing (~50+ service files)
├── views/ # 23+ feature modules (financeManage/, salesManagement/, etc.)
├── router/ # Dynamic route loading with permission checks
├── store/ # Vuex modules (d2admin, goodsInfoData, FinancialRules)
├── common/ # Shared utilities & configs (baseConfig.js, util.js, format.js)
├── components/ # Reusable UI components
├── plugin/ # Core plugins (d2admin framework, axios, error handling)
└── assets/ # Style, SVG icons, localization resources
```
## Critical Development Patterns
### 1. API Request Layer Architecture
The system uses a **custom ROP (Request-Over-Protocol) gateway pattern** with multiple API endpoints:
```javascript
// Each API file (api/account.js, api/orderManage.js, etc.) follows:
import request from './request'
const path = 'dj.api.smartcarlife.'
export function getListApi(data) {
data.method = `${path}orderDivision.page` // Service method name
return request(data, 'post')
}
```
**Key Points**:
- `data.method` determines which backend service is invoked (not the URL)
- `request()` in [src/api/request.js](src/api/request.js) handles:
- API routing via `baseConfig[apiName]` mappings (axios, axios2-10, axios_strategy)
- Request signing (SHA1/MD5) based on method prefix
- Session token injection from cookies
- Multiple API gateways: dj, scrm, merchants, reportExport, riskmanage, strategy
### 2. Multi-Gateway Routing
[src/api/request.js#L18-L66](src/api/request.js#L18-L66) contains the routing logic:
- `dj.api.smartcarlife.*` → axios (main gateway)
- `dj.api.script.*` → axios7 (script service)
- `risk.manage.api.*` → axios10 (risk management)
- `scrm.api.shopmall.*` → axios2 (SCRM shopping)
- Each maps to different `appkey/secret` in [src/common/baseConfig.js](src/common/baseConfig.js)
### 3. State Management
Vuex store structure ([src/store/modules/](src/store/modules/)):
- **d2admin**: Main framework state (page navigation, auth, search, themes)
- **goodsInfoData**: Product information shared across modules
- **FinancialRules**: Financial configuration rules
- **performanceFormStore**: Resident management performance data
Access pattern: `this.$store.dispatch('d2admin/page/currentSet', path)`
### 4. Router & Permission System
[src/router/index.js](src/router/index.js):
- Dynamic route loading from Vuex auth state
- Router guards intercept all navigation (`router.beforeEach`)
- NProgress bar shows loading state
- Permission source comes from `store.state.d2admin.auth.source`
### 5. View Module Organization
Features live in [src/views/](src/views/) folders with encapsulated patterns:
```
views/
├── financeManage/ # Financial clearing & reconciliation
├── salesManagement/ # Sales dashboards & analytics
├── orderManage/ # Order lifecycle management
├── residentManage/ # Resident info & performance tracking
├── goods/ # Product management & SKU
└── invoiceManage/ # Invoice generation & tracking
```
Each module can have local stores, components, and APIs.
## Build & Development Workflow
### Commands
```bash
npm run dev # Local development (with --openssl-legacy-provider flag)
npm run build # Production build
npm run build:nomock # Build without mock data
npm run lint # ESLint fix
npm run test:unit # Jest unit tests
npm run report # Build with webpack report
```
### Configuration
- **Base path**: `/dj-carlife-web/` (set in [vue.config.js](vue.config.js))
- **CDN**: https://img02.glsx.com.cn/dj-carlife-web for assets
- **Mock support**: Via [src/mock/d2-mock/](src/mock/d2-mock/) (mockjs-based)
- **Sentry integration**: Error tracking in production only
## Code Patterns & Conventions
### Export Functions from API Files
Always use named exports with `Api` suffix:
```javascript
export function getListApi(data) { ... } // List endpoints
export function getDetailApi(data) { ... } // Detail/fetch
export function updateXxxApi(data) { ... } // Create/update
export function deleteXxxApi(data) { ... } // Delete
export function exportXxxApi(data) { ... } // Export to Excel
```
### View Component Structure
```vue
<template>
<!-- Element UI components: el-table, el-dialog, el-form -->
</template>
<script>
import * as accountApi from '@/api/account'
export default {
data() { return { list: [], filters: {} } },
methods: {
async fetchList() {
const res = await accountApi.getListApi(this.filters)
this.list = res.data
}
}
}
</script>
```
### Common Utilities
- **[src/common/util.js](src/common/util.js)**: Util.msg() for dialogs, cookies management, date formatting
- **[src/common/format.js](src/common/format.js)**: Formatting helpers for display
- **[src/common/Export2Excel.js](src/common/Export2Excel.js)**: Excel export via xlsx
- **[src/common/constants.js](src/common/constant/)**: Shared enums and constants
## Testing & Quality
### Jest Configuration
[jest.config.js](jest.config.js) tests located in `/tests/unit/**/*.spec.js`
### ESLint
Modern ESLint 9 + antfu config ([eslint.config.js](eslint.config.js))
## Deployment Notes
- **Environments**: Production (dj.glsx.com.cn), Testing (frontend.test.glsx.com.cn)
- **Multiple release branches**: dev_v4.x.x branches per release cycle
- **Legacy Node flags**: Build requires `NODE_OPTIONS=--openssl-legacy-provider` (Node 14 compatibility)
## Key Files for New Features
1. **API integration**: Add new exports in [src/api/](src/api/) matching service method
2. **View component**: Create in appropriate [src/views/](src/views/) module folder
3. **Store data**: Add to Vuex if cross-module state needed
4. **Routes**: Register in [src/router/routes.js](src/router/routes.js) or dynamic loading
5. **Styles**: Use SCSS in [src/assets/style/](src/assets/style/), leverage flex.css utility classes
## Common Tasks
- **Add new API endpoint**: Create function in relevant api/*.js file, inject session/signature in request()
- **Create list page**: Use Element Table + pagination, implement async fetchList() method
- **Export to Excel**: Import Export2Excel from common/, pass table data
- **Add menu item**: Register in router + add permission checks in router.beforeEach
- **Cross-component communication**: Use Vuex store or pass via props/events
---
# Language
默认使用 **简体中文** 输出,包括:
- Git commit message
- Pull Request 描述
- 代码解释
- 技术说明
只有在代码注释或特殊要求时才使用英文。
---
# Git Commit Message 规范
生成 commit message 时必须遵循 **Conventional Commits 规范**。
## 基本格式
type: 简短描述
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
], ],
"cSpell.words": [ "cSpell.words": [
"vuex", "vuex",
"Cascader" "Cascader",
"glsx"
], ],
"workbench.tree.indent": 24, "workbench.tree.indent": 24,
"eslint.enable": true, "eslint.enable": true,
...@@ -17,25 +18,19 @@ ...@@ -17,25 +18,19 @@
"vetur.validation.style": true, "vetur.validation.style": true,
"vetur.ignoreProjectWarning": false, "vetur.ignoreProjectWarning": false,
"vetur.experimental.templateInterpolationService": false, "vetur.experimental.templateInterpolationService": false,
"[vue]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint", "editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.autoIndent": "full", "editor.autoIndent": "full",
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
// "source.organizeImports": "explicit",
"source.fixAll.eslint": "explicit" "source.fixAll.eslint": "explicit"
} },
"[vue]": {
}, },
"[javascript]": { "[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}, },
"[javascriptreact]": { "[javascriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}, },
"i18n-ally.sourceLanguage": "zh-chs" "i18n-ally.sourceLanguage": "zh-chs",
"javascript.suggest.autoImports": true
} }
...@@ -12,6 +12,15 @@ export default antfu({ ...@@ -12,6 +12,15 @@ export default antfu({
"dist", "dist",
// unplugin-auto-import 生成的类型文件,每次提交都改变,所以加入这里吧,与 .gitignore 配合使用 // unplugin-auto-import 生成的类型文件,每次提交都改变,所以加入这里吧,与 .gitignore 配合使用
"auto-import.d.ts", "auto-import.d.ts",
"build/",
"tests/",
"node_modules/",
// # node 覆盖率文件
"coverage/",
"**/*-min.js",
"**/*.min.js",
], ],
stylistic: { stylistic: {
"indent": "tab", // 4个空格 "indent": "tab", // 4个空格
...@@ -20,6 +29,12 @@ export default antfu({ ...@@ -20,6 +29,12 @@ export default antfu({
"array-bracket-spacing": ["error", "always"], "array-bracket-spacing": ["error", "always"],
}, },
rules: { rules: {
"no-useless-catch": "warn",
"vue/no-unused-refs": "warn",
"unused-imports/no-unused-imports": "warn",
"no-unused-vars": "warn",
"style/eol-last": "off",
"no-prototype-builtins": "warn",
"prefer-template": "off", "prefer-template": "off",
"no-useless-return": "off", "no-useless-return": "off",
"vue/no-deprecated-delete-set": "off", "vue/no-deprecated-delete-set": "off",
...@@ -31,6 +46,8 @@ export default antfu({ ...@@ -31,6 +46,8 @@ export default antfu({
"vue/no-deprecated-v-bind-sync": "off", "vue/no-deprecated-v-bind-sync": "off",
"vue/no-lone-template": "off", "vue/no-lone-template": "off",
"vue/no-mutating-props": "off", "vue/no-mutating-props": "off",
"vue/no-deprecated-filter": "off",
"vue/no-v-for-template-key-on-child": "off",
// 强制:Vue 多行 HTML 元素的内容前后必须换行 // 强制:Vue 多行 HTML 元素的内容前后必须换行
"vue/multiline-html-element-content-newline": [ "vue/multiline-html-element-content-newline": [
"error", "error",
...@@ -88,7 +105,7 @@ export default antfu({ ...@@ -88,7 +105,7 @@ export default antfu({
"EVENTS", // @click @focus "EVENTS", // @click @focus
"CONTENT", // v-text v-html "CONTENT", // v-text v-html
], ],
alphabetical: true, // 是否在同组内再按字母排序(建议 false,官方默认顺序更好) alphabetical: false, // 是否在同组内再按字母排序(建议 false,官方默认顺序更好)
}], }],
// 强制:Vue SFC 中块的顺序(template -> script -> style) // 强制:Vue SFC 中块的顺序(template -> script -> style)
"vue/block-order": [ "vue/block-order": [
......
...@@ -6,7 +6,7 @@ module.exports = { ...@@ -6,7 +6,7 @@ module.exports = {
'vue' 'vue'
], ],
transform: { transform: {
'^.+\\.vue$': 'vue-jest', '^.+\\.vue$': '@vue/vue2-jest',
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub', '.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.jsx?$': 'babel-jest' '^.+\\.jsx?$': 'babel-jest'
}, },
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
"baseUrl": ".", "baseUrl": ".",
"module": "ESNext", "module": "ESNext",
/* Bundler mode */ /* Bundler mode */
"moduleResolution": "bundler", // 按 Node 规则解析模块
"moduleResolution": "node",
"paths": { "paths": {
"@/*": [ "@/*": [
"src/*" "src/*"
...@@ -38,4 +39,7 @@ ...@@ -38,4 +39,7 @@
"dist", "dist",
".git" ".git"
] ]
// 对齐 Webpack 的 extensions 优先级
// "extensions": [".vue", ".js", ".ts", ".json"]
} }
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
"default-passive-events": "^2.0.0", "default-passive-events": "^2.0.0",
"echarts": "^5.3.2", "echarts": "^5.3.2",
"element-ui": "2.13.2", "element-ui": "2.13.2",
"emoji-regex": "^10.6.0",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"flex.css": "^1.1.7", "flex.css": "^1.1.7",
"fuse.js": "^3.4.4", "fuse.js": "^3.4.4",
...@@ -44,8 +45,10 @@ ...@@ -44,8 +45,10 @@
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",
"js-md5": "^0.7.3", "js-md5": "^0.7.3",
"jspdf": "^2.5.1", "jspdf": "^2.5.1",
"lodash": "^4.17.23",
"lodash-es": "^4.17.22", "lodash-es": "^4.17.22",
"lowdb": "^1.0.0", "lowdb": "^1.0.0",
"nanoid": "^5.1.6",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"number-precision": "^1.6.0", "number-precision": "^1.6.0",
"print-js": "^1.6.0", "print-js": "^1.6.0",
...@@ -73,6 +76,7 @@ ...@@ -73,6 +76,7 @@
"@antfu/eslint-config": "^6.7.3", "@antfu/eslint-config": "^6.7.3",
"@babel/core": "^7.12.16", "@babel/core": "^7.12.16",
"@kazupon/vue-i18n-loader": "^0.4.1", "@kazupon/vue-i18n-loader": "^0.4.1",
"@vue/babel-helper-vue-jsx-merge-props": "^1.4.0",
"@vue/cli-plugin-babel": "~5.0.8", "@vue/cli-plugin-babel": "~5.0.8",
"@vue/cli-plugin-unit-jest": "~5.0.8", "@vue/cli-plugin-unit-jest": "~5.0.8",
"@vue/cli-service": "~5.0.8", "@vue/cli-service": "~5.0.8",
......
This diff could not be displayed because it is too large.
/**
* 离线估算财务规则保存接口 JSON 体积与 JSON.stringify 耗时。
* 用法:node scripts/benchmark-financial-submit-payload.js
* 可按需修改 RULE_COUNT / USE_HEAVY_RULE 贴近生产。
*
* 参考(Node 一次跑数,轻量规则约 12 条分账行/ tab):1000 tab ≈ 4.2MB UTF-8,stringify 约数十 ms 级;
* 浏览器主线程略慢,且真实类目/ nested children 更大时需以 USE_HEAVY_RULE=true 再测。
*/
const RULE_COUNT = 1000
const USE_HEAVY_RULE = process.argv.includes("--heavy")
const sampleRuleLight = {
expenseCategoryRules: [
{
expenseCategoryCalculateType: 1,
expenseCategoryValue: 2,
expenseCategoryId: 1,
expenseCategoryName: "流量费",
formType: 1,
calculateMode: 1,
nodeType: 1,
targetType: 1,
children: []
}
],
shop4sDeductChargeFlag: "Y",
partnerDeductChargeFlag: "Y",
virtualAccountCostFlag: "Y",
recoveryCostFlag: "Y",
groupDivisionRuleId: 38108,
djCostFlag: "Y",
thirdPartyCostFlag: "Y",
goodsCostFlag: "Y",
goodsSource: 1,
goodsCostConvertRate: 100,
virtualAccountCostConvertRate: 100,
recoveryCostConvertRate: 100,
djCostConvertRate: 100,
thirdPartyCostConvertRate: 100,
groupType: 2,
goodsTypes: [],
merchantDistributionRules: Array.from({ length: 12 }, (_, i) => ({
applicationObjectType: i % 3 || 1,
id: i,
expenseCategoryId: i,
applicationObjectName: `项${i}`,
merchantId: "-1",
merchantName: "示例",
targetMerchantType: 1
})),
owningMerchantDistributionRules: Array.from({ length: 12 }, (_, i) => ({
applicationObjectType: i % 3 || 1,
id: i,
expenseCategoryId: i,
applicationObjectName: `项${i}`,
merchantId: "-1",
merchantName: "示例",
targetMerchantType: 1
}))
}
/** 更接近接口示例:多条 expenseCategory + children + 两套分账表各 ~12 行 */
const sampleRuleHeavy = {
expenseCategoryRules: [
{
expenseCategoryCalculateType: 1,
expenseCategoryValue: 2,
expenseCategoryId: 1,
expenseCategoryName: "流量费",
formType: 1,
calculateMode: 1,
nodeType: 1,
targetType: 1,
targetMerchant: {},
children: []
},
{
expenseCategoryCalculateType: 2,
expenseCategoryValue: 2,
expenseCategoryId: 302,
expenseCategoryName: "资源费",
formType: 1,
calculateMode: 1,
nodeType: 1,
targetType: 1,
children: []
},
{
expenseCategoryCalculateType: 1,
expenseCategoryValue: 2,
expenseCategoryId: 1151,
expenseCategoryName: "自定义类目2",
formType: 2,
calculateMode: 1,
nodeType: 2,
targetType: 2,
targetMerchant: {},
children: [
{
expenseCategoryCalculateType: 3,
expenseCategoryValue: 222,
expenseCategoryId: 1152,
expenseCategoryName: "自定义1",
calculateMode: 1,
nodeType: 3,
categoryToSort: 1,
targetType: 2,
targetMerchant: {}
},
{
expenseCategoryCalculateType: "",
expenseCategoryValue: "",
expenseCategoryId: 1153,
expenseCategoryName: "自定义2",
calculateMode: 1,
nodeType: 4,
categoryToSort: 2,
targetType: 2,
targetMerchant: {}
}
]
}
],
shop4sDeductChargeFlag: "Y",
partnerDeductChargeFlag: "Y",
virtualAccountCostFlag: "Y",
recoveryCostFlag: "Y",
groupDivisionRuleId: 38108,
djCostFlag: "Y",
thirdPartyCostFlag: "Y",
goodsCostFlag: "Y",
goodsSource: 1,
goodsCostConvertRate: 100,
virtualAccountCostConvertRate: 100,
recoveryCostConvertRate: 100,
djCostConvertRate: 100,
thirdPartyCostConvertRate: 100,
groupType: 2,
goodsTypes: [{ goodsType: 4, goodsTypeName: "示例品类", categoryType: 1 }],
goodsTypeGroupRelations: [{ goodsType: 4, goodsTypeName: "示例品类", categoryType: 1 }],
merchantDistributionRules: sampleRuleLight.merchantDistributionRules,
owningMerchantDistributionRules: sampleRuleLight.owningMerchantDistributionRules
}
const sampleRule = USE_HEAVY_RULE ? sampleRuleHeavy : sampleRuleLight
const payload = {
merchantId: 44218596,
realityPlatformMerchantId: "-1",
settleRuleId: 6058,
divisionRuleId: 6016,
goodsTypeGroupRules: Array.from({ length: RULE_COUNT }, (_, i) => ({
...sampleRule,
groupDivisionRuleId: 38100 + i,
groupType: i === 0 ? 1 : 2
})),
divisionRuleAutos: [],
autoFlag: "N",
settleTimeType: 1,
sceneType: 1
}
const t0 = Date.now()
const json = JSON.stringify(payload)
const ms = Date.now() - t0
const utf8Bytes = Buffer.byteLength(json, "utf8")
// eslint-disable-next-line no-console
console.log(JSON.stringify({
ruleCount: RULE_COUNT,
heavy: USE_HEAVY_RULE,
stringifyMs: ms,
jsonChars: json.length,
utf8Bytes,
utf8MB: (utf8Bytes / (1024 * 1024)).toFixed(2)
}, null, 2))
...@@ -6,10 +6,8 @@ ...@@ -6,10 +6,8 @@
*/ */
import axios from "axios"; import axios from "axios";
// Mock 基础配置 // Mock 基础配置
const MOCK_BASE_URL = "http://127.0.0.1:4523/m1/7746299-7491170-default"; const MOCK_BASE_URL = "http://127.0.0.1:4523/m1/7475619-7210332-default/";
/** /**
* 创建 Mock Axios 实例 * 创建 Mock Axios 实例
*/ */
...@@ -65,12 +63,12 @@ function mockRequest(params = {}, httpMethod = "post") { ...@@ -65,12 +63,12 @@ function mockRequest(params = {}, httpMethod = "post") {
// 根据HTTP方法处理参数 // 根据HTTP方法处理参数
if (httpMethod.toLowerCase() === "post" || httpMethod.toLowerCase() === "put") { if (httpMethod.toLowerCase() === "post" || httpMethod.toLowerCase() === "put") {
config.data = data; config.data = params;
} else { } else {
// GET请求,将参数作为query string // GET请求,将参数作为query string
config.params = { config.params = {
"ropRequestContext.key": data["ropRequestContext.key"] || "", "ropRequestContext.key": data["ropRequestContext.key"] || "",
...data, ...params,
}; };
} }
...@@ -131,7 +129,7 @@ mockAxios.interceptors.request.use( ...@@ -131,7 +129,7 @@ mockAxios.interceptors.request.use(
mockAxios.interceptors.response.use( mockAxios.interceptors.response.use(
(response) => { (response) => {
console.log("Mock Response:", response.data); console.log("Mock Response:", response.data);
return response.data; return response.data.data;
}, },
(error) => { (error) => {
console.error("Mock Error:", error); console.error("Mock Error:", error);
......
...@@ -6,32 +6,33 @@ ...@@ -6,32 +6,33 @@
* @FilePath: \dj-car-life-system\src\api\shelfManage.js * @FilePath: \dj-car-life-system\src\api\shelfManage.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
import request from "./request" import request from "./request";
import RequestMethods from "./request.methods" import RequestMethods from "./request.methods";
const path = "dj.api.create.business.approve."
const path = "dj.api.create.business.approve.";
// 获取企微审批模版 // 获取企微审批模版
export function getWorkwechatTemplate(data) { export function getWorkwechatTemplate(data) {
data.method = `${path}workwechat.template` data.method = `${path}workwechat.template`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 分页查询嘀加上架列表 // 分页查询嘀加上架列表
export function getPage(data) { export function getPage(data) {
data.method = `${path}page` data.method = `${path}page`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 驳回嘀加上架 // 驳回嘀加上架
export function reject(data) { export function reject(data) {
data.method = `${path}reject` data.method = `${path}reject`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 嘀加上架查看详情(分账、对账配置) // 嘀加上架查看详情(分账、对账配置)
export function merchantSettleDistributeRuleLastRule(data) { export function merchantSettleDistributeRuleLastRule(data) {
data.method = `dj.api.create.business.approve.detail.rule` data.method = `dj.api.create.business.approve.detail.rule`;
return request(data) return request(data);
} }
// 保存财务分账规则 // 保存财务分账规则
...@@ -47,93 +48,211 @@ export function getDjzhySubMerchant(data) { ...@@ -47,93 +48,211 @@ export function getDjzhySubMerchant(data) {
} }
// 获取不同场景的商品分类 // 获取不同场景的商品分类
export function getGoodsCategoryConfiguration(data) { export function getGoodsCategoryConfiguration(data) {
data.currentPage = 1 data.currentPage = 1;
data.pageSize = 999999 data.pageSize = 999999;
// data.method = `${path}goodsCategoryConfiguration.page` // data.method = `${path}goodsCategoryConfiguration.page`
data.method = `${path}goodsCategoryConfiguration.page.new` data.method = `${path}goodsCategoryConfiguration.page.new`;
return request(data) return request(data);
} }
// 财务 - 2 - 获取导流方 // 财务 - 2 - 获取导流方
export function getMerchantLevelApi(data) { export function getMerchantLevelApi(data) {
data.method = `dj.api.smartcarlife.get.merchantLevel` data.method = `dj.api.smartcarlife.get.merchantLevel`;
return request(data, "post") return request(data, "post");
} }
// 嘀加上架 - 基本信息 // 嘀加上架 - 基本信息
export function getBusisDetailBasic(data) { export function getBusisDetailBasic(data) {
data.method = `dj.api.create.business.approve.detail.basic` data.method = `dj.api.create.business.approve.detail.basic`;
return request(data) return request(data);
} }
// 新增商户 - 车品牌 // 新增商户 - 车品牌
export function brandList(data) { export function brandList(data) {
data.method = `merchants.api.merchantCommon.getCarbrandTree` data.method = `merchants.api.merchantCommon.getCarbrandTree`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 新增商户 - 商户类型 // 新增商户 - 商户类型
export function getMerchantType(data) { export function getMerchantType(data) {
data.method = `merchants.api.menu.findAllDictData` data.method = `merchants.api.menu.findAllDictData`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 嘀加上架查看详情(上架商品及测算) // 嘀加上架查看详情(上架商品及测算)
export function getGoodsDetail(data) { export function getGoodsDetail(data) {
data.method = `${path}detail.goods` data.method = `${path}detail.goods`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 嘀加上架提交 // 嘀加上架提交
export function saveApprove(data) { export function saveApprove(data) {
data.method = `${path}save` data.method = `${path}save`;
return request(data, RequestMethods.POST, ["file"]) return request(data, RequestMethods.POST, ["file"]);
} }
// 新增商户 - 保存商户 // 新增商户 - 保存商户
export function saveMerchant(data) { export function saveMerchant(data) {
data.method = `merchants.api.merchant.saveMerchant.permissions` data.method = `merchants.api.merchant.saveMerchant.permissions`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 新增商户 - 下级商户 // 新增商户 - 下级商户
export function findMerchantListByPage(data) { export function findMerchantListByPage(data) {
data.method = `merchants.api.open.findMerchantListByPage` data.method = `merchants.api.open.findMerchantListByPage`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 嘀加上架 - 保存 // 嘀加上架 - 保存
export function operationConfirm(data) { export function operationConfirm(data) {
data.method = `dj.api.create.business.approve.operationConfirm` data.method = `dj.api.create.business.approve.operationConfirm`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 嘀加上架 - 保存 // 嘀加上架 - 保存
export function operationConfirmJson(data) { export function operationConfirmJson(data) {
data.method = `dj.api.create.business.approve.operationConfirm.json` data.method = `dj.api.create.business.approve.operationConfirm.json`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 嘀加上架 - 保存异步 // 嘀加上架 - 保存异步
export function operationConfirmJsonAsync(data) { export function operationConfirmJsonAsync(data) {
data.method = `dj.api.create.business.approve.operationConfirm.json.async` data.method = `dj.api.create.business.approve.operationConfirm.json.async`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 嘀加上架 - 保存异步 // 嘀加上架 - 保存异步
export function approveAsyncProcess(data) { export function approveAsyncProcess(data) {
data.method = `dj.api.create.business.approve.asyncProcess` data.method = `dj.api.create.business.approve.asyncProcess`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 嘀加上架 - 测算 // 嘀加上架 - 测算
export function computeProductProfitDetail(data) { export function computeProductProfitDetail(data) {
data.method = `dj.api.smartcarlife.createBusiness.approve.computeProductProfitDetail.json` data.method = `dj.api.smartcarlife.createBusiness.approve.computeProductProfitDetail.json`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 附件上传接口 // 附件上传接口
export function uploadFileWithFileName(data) { export function uploadFileWithFileName(data) {
data.method = `dj.api.common.uploadFile.with.file.name` data.method = `dj.api.common.uploadFile.with.file.name`;
return request(data, RequestMethods.POST, ["file"]) return request(data, RequestMethods.POST, ["file"]);
} }
// 查询门店 // 查询门店
export function getMerchantPage(data) { export function getMerchantPage(data) {
data.method = `dj.api.merchant.page` data.method = `dj.api.merchant.page`;
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST);
} }
// 分页查询嘀加上架列表
export function getDPlusPage(data) {
data.method = `dj.api.create.business.approve.page`;
return request(data);
}
export function getTrafficSourceListApi(data) {
data.method = "dj.api.create.business.approve.merchantPage";
return request(data);
}
export function getTrafficSourceDataApi(data) {
data.method = "dj.api.create.business.approve.getMerchantInfo";
return request(data);
}
// data.merchantId 有值 修改
// data.merchantId 无值 新增
export function saveTrafficSourceDataApi(data) {
data.method = "dj.api.create.business.approve.updateMerchantInfo";
return request(data);
}
export function getProductPackagesListApi(data) {
data.method = "dj.api.create.business.approve.baseProductPage";
return request(data);
}
export function getProductPackagesApi(data) {
data.method = "dj.api.create.business.approve.getProductInfo";
return request(data);
}
// 保存单个商品
export function postProductApi(data) {
data.method = "dj.api.create.business.approve.saveGoodsInfo";
return request(data, "post");
}
// 保存单个商品
export function postPackageApi(data) {
data.method = "dj.api.create.business.approve.savePackageInfo";
return request(data, "post");
}
// 获取上架基础信息
export function getShelveBaseDetailApi(data) {
data.method = "dj.api.create.business.approve.getConfirmStep";
return request(data);
};
// 删除产品 ( 产品 -> 可能是商品也可能是套餐)
export function delProductPackagesApi(data) {
data.method = "dj.api.create.business.approve.deleteProductInfo";
return request(data);
};
// 获取分账信息下 所有 特殊品类列表
export function getProfitSharingTypeListApi(data) {
data.method = "dj.api.create.business.approve.listSettleGoodsTypeGroup";
return request(data);
};
// 获取分账信息下 所有 单个特殊品类的详情
export function getProfitSharingTypeDetailApi(data) {
data.method = "dj.api.create.business.approve.getSettleGoodsTypeGroupRuleDetail";
return request(data);
};
// 获取 已经保存的 流量方信息 businessCode
export function getSaveRuleMerchantApi(data) {
data.method = "dj.api.create.business.approve.getSaveRuleMerchant";
return request(data);
};
// 保存分账信息 -单个特殊品类的信息
export function saveProfitSharingConfigSpecialDetailApi(data) {
data.method = "dj.api.create.business.approve.saveSettleGoodsTypeGroupRule";
return request(data, "post");
};
export function getProfitSharingConfigOtherGoodsItemApi(data) {
data.method = "dj.api.create.business.approve.listOtherGoodsTypeItem";
return request(data, "post");
};
export function delProfitSharingConfigSpecialItemApi(data) {
data.method = "dj.api.smartcarlife.merchantSettleDistributeRule.deleteGoodsTypeRule";
return request(data, "post");
};
// 获取对账配置 单个详情
export function getReconciliationGoodsTypeDetailApi(data) {
data.method = "dj.api.create.business.approve.getReconciliationGoodsTypeGroupRuleDetail";
return request(data, "post");
};
// 保存对账配置 单个详情
export function postReconciliationGoodsTypeApi(data) {
data.method = "dj.api.create.business.approve.saveReconciliationGoodsTypeGroupRule";
return request(data, "post");
};
export function getReconciliationOtherGoodsItemApi(data) {
data.method = "dj.api.smartcarlife.reconciliation.listReconciliationOtherGoodsTypeItem";
return request(data, "post");
};
export function delReconciliationConfigSpecialItemApi(data) {
data.method = "dj.api.smartcarlife.reconciliation.deleteGoodsTypeRule";
return request(data, "post");
};
export function postChangeBaseStepApi(data) {
data.method = "dj.api.create.business.approve.updateNextStep";
return request(data, "post");
};
// 整个嘀加上架 的最后一步提交
export function postShelveApi(data) {
data.method = "dj.api.create.business.approve.operationConfirm.json.async";
return request(data, "post");
};
...@@ -16,7 +16,6 @@ export const BaseData = { ...@@ -16,7 +16,6 @@ export const BaseData = {
positionTypeList: "positionTypeList", // 太阳膜商品部位 positionTypeList: "positionTypeList", // 太阳膜商品部位
extendedPosiTypeList: "extendedPosiTypeList", // 延保类商品部位 extendedPosiTypeList: "extendedPosiTypeList", // 延保类商品部位
}; };
/** 计价单位选项 1-把、2-本、3-对、4-个、5-根、6-盒、7-件、8-卷、9-块、10-辆、11-米、12-克、13-升、14-双、15-台、16-套、17-条、18-桶、19-位、20-页、21-张 */ /** 计价单位选项 1-把、2-本、3-对、4-个、5-根、6-盒、7-件、8-卷、9-块、10-辆、11-米、12-克、13-升、14-双、15-台、16-套、17-条、18-桶、19-位、20-页、21-张 */
export const priceUnitTypeList = [ export const priceUnitTypeList = [
{ value: 1, label: "把" }, { value: 1, label: "把" },
...@@ -522,10 +521,10 @@ export const warrantyProList = [1, 4, 6, 12, 14]; ...@@ -522,10 +521,10 @@ export const warrantyProList = [1, 4, 6, 12, 14];
// 所属场景 // 所属场景
export const sceneCodeList = [ export const sceneCodeList = [
{ confId: 0, confValue: "会员权益/升级" },
{ confId: 1, confValue: "精品升级" }, { confId: 1, confValue: "精品升级" },
{ confId: 2, confValue: "次新车转化" }, { confId: 2, confValue: "次新车转化" },
{ confId: 3, confValue: "售后众筹" }, { confId: 3, confValue: "售后众筹" },
{ confId: 0, confValue: "会员权益/升级" },
{ confId: 4, confValue: "积分商城" }, { confId: 4, confValue: "积分商城" },
]; ];
export const otherSceneList = [{ confId: 7, confValue: "二手车" }]; export const otherSceneList = [{ confId: 7, confValue: "二手车" }];
......
<template>
<el-select ref="selectRef"
:key="forceKey"
v-select-load-more="loadMore"
:value="value"
v-bind="selectProps"
v-on="selectEvent"
@blur="handleSelectBlur"
@change="handleSelectChange">
<el-option v-for="subItem in localOptions"
:key="subItem[fieldName.value]"
v-bind="{
value: $attrs['value-key'] ? subItem : subItem[fieldName.value],
label: subItem[fieldName.label],
...isFunction(optionProps) ? optionProps(subItem) : optionProps,
}">
<slot name="options" :row="subItem"></slot>
</el-option>
<template #empty>
<div class="temp-wrapper empty-wrapper" style="text-align: center;cursor: not-allowed;padding:4px 0;">
<div v-if="loading">
<span class="el-icon-loading" />
</div>
<div v-else title="请键入其他关键字">
没有找到相关数据
</div>
</div>
</template>
<div class="temp-wrapper page-tips" title="不要点我">
<div v-if="(pageQuery.currentPage < pageQuery.pages) && loading">
<span>
下一页加载中
</span>
<span class="el-icon-loading" />
</div>
<div v-else>
到底没有更多了
</div>
</div>
</el-select>
</template>
<script>
import { isFunction, omit } from "lodash-es";
import { nanoid } from "nanoid";
export default {
name: "",
directives: {
"select-load-more": {
bind(el, binding) {
const SELECT_WRAP_DOM = el.querySelector(".el-select-dropdown .el-select-dropdown__wrap");
SELECT_WRAP_DOM.addEventListener("scroll", function () {
const condition
= this.scrollHeight - this.scrollTop <= this.clientHeight;
if (condition) {
binding.value();
}
});
},
},
},
props: {
fetchApi: {
required: true,
type: Function,
},
immediate: {
default: false,
type: Boolean,
},
optionProps: {
default: () => ({}),
type: [Object, Function],
},
options: {
default: () => ([]),
type: Array,
},
value: {
required: true,
type: [Array, String, Number],
},
fieldName: {
type: Object,
default: () => ({
label: "label",
value: "value",
}),
},
},
data() {
return {
localOptions: [],
pageQuery: {
searchValue: "",
currentPage: 1,
pageSize: 15,
pages: 0,
},
// 初始时候为false的话. 输入文字的一瞬间会显示为空
loading: true,
forceKey: nanoid(),
};
},
computed: {
selectProps() {
return {
"collapse-tags": true,
"filterable": true,
"multiple": true,
"remote": true,
"reserve-keyword": true,
"placeholder": "请选择",
"remote-method": this.remoteOptions,
...this.$attrs,
};
},
selectEvent() {
return {
"visible-change": this.visibleChange,
...omit(this.$listeners, ["change", "blur"]),
};
},
},
watch: {
options: {
handler(val) {
this.localOptions = [...this.options];
},
immediate: true,
},
},
async mounted() {
console.log("初始化?");
if (this.immediate) {
await this.getApi(false, true);
}
},
methods: {
async getApi(loadMore = false, isImmediate = false) {
this.loading = true;
try {
const { list, query } = await this.fetchApi({
// 组件内部的 查询
pageQuery: this.pageQuery,
// 组件内部维护的options列表
localOptions: this.localOptions,
// 是否加载更多触发的
loadMore,
// 是否第一次触发
isImmediate,
});
if (loadMore) {
this.localOptions = this.localOptions.concat(list);
} else {
this.localOptions = list;
}
this.$emit("update:options", this.localOptions);
Object.assign(this.pageQuery, query);
} finally {
this.$nextTick(() => {
this.loading = false;
});
}
},
handleSelectChange(e) {
this.$emit("input", e);
if (isFunction(this.$listeners?.change)) {
this.$listeners.change(e);
}
},
async handleSelectBlur() {
// 失焦时, 检查 query.searchValue的内容. 如果有值 且 options 又为空. 说明筛选到空的值
// 需要去掉searchValue 重新获取默认的options
if (this.pageQuery.searchValue && !this.localOptions.length) {
console.log("重新获取默认的options");
this.pageQuery.searchValue = "";
// 重置页数
this.resetPageQuery();
await this.getApi();
}
if (isFunction(this.$listeners?.blur)) {
this.$listeners.blur();
}
},
isFunction,
async loadMore() {
if (!this.loading) {
this.loading = true;
const query = this.pageQuery;
query.currentPage = query.currentPage + 1;
if (query.currentPage > query.pages) {
return;
}
await this.getApi(true);
}
},
async remoteOptions(query) {
this.loading = true;
// 还原滚动条位置
const wrap = this.$refs.selectRef.$refs.popper.$el.querySelector(".el-select-dropdown__wrap");
if (wrap) {
this.$refs.selectRef.$refs.scrollbar.moveY = 0;
wrap.scrollTop = 0;
}
// this.$refs.selectRef.$refs.scrollbar.scrollTop = 0;
// 清空选项
this.localOptions = [];
this.$emit("update:options", this.localOptions);
// 重置query
this.resetPageQuery();
this.pageQuery.searchValue = query;
await this.getApi();
},
// 重置页数.做成函数可以给父组件调用
resetPageQuery() {
this.pageQuery.currentPage = 1;
},
forceUpdate() {
this.forceKey = nanoid();
},
visibleChange(show) {
// if (!show) {
// this.options = [];
// this.loading = true;
// }
},
},
};
</script>
<style scoped lang="scss">
.temp-wrapper {
font-size: 14px;
color: #606266;
line-height: 34px;
&.page-tips {
cursor: not-allowed;
padding: 0 20px;
color: #ccc;
}
}
</style>
<script>
export default {
functional: true,
props: {
render: Function,
row: Object,
},
render(h, ctx) {
return ctx.props.render(h, ctx.props.row);
},
};
</script>
...@@ -470,7 +470,7 @@ export const routerName = { ...@@ -470,7 +470,7 @@ export const routerName = {
label: "嘀加上架与销售合同", label: "嘀加上架与销售合同",
category: "Button", category: "Button",
type: "primary", type: "primary",
handle: "handleAdd", handle: "handleEdit",
addRoutePath: [ addRoutePath: [
{ {
authId: "9031302", authId: "9031302",
...@@ -535,7 +535,7 @@ export const routerName = { ...@@ -535,7 +535,7 @@ export const routerName = {
authId: "9031309", authId: "9031309",
parentId: "90313", parentId: "90313",
label: "重新发起", label: "重新发起",
handle: "handleAgain", handle: "handleEdit",
addRoutePath: [ addRoutePath: [
{ {
authId: "9031302", authId: "9031302",
...@@ -557,7 +557,7 @@ export const routerName = { ...@@ -557,7 +557,7 @@ export const routerName = {
sideHidden: true, sideHidden: true,
activePath: "/shelfManage", activePath: "/shelfManage",
}, },
component: _import("goods/shelfManage/editShelf"), component: _import("goods/shelfManage/view/modifyTable"),
}, },
9031305: { 9031305: {
path: "/contractDetail", path: "/contractDetail",
...@@ -569,7 +569,7 @@ export const routerName = { ...@@ -569,7 +569,7 @@ export const routerName = {
sideHidden: true, sideHidden: true,
activePath: "/shelfManage", activePath: "/shelfManage",
}, },
component: _import("goods/shelfManage/contractDetail"), component: _import("goods/shelfManage/view/contractDetail"),
}, },
9031307: { 9031307: {
path: "/editContract", path: "/editContract",
...@@ -581,7 +581,7 @@ export const routerName = { ...@@ -581,7 +581,7 @@ export const routerName = {
sideHidden: true, sideHidden: true,
activePath: "/shelfManage", activePath: "/shelfManage",
}, },
component: _import("goods/shelfManage/editContract"), component: _import("goods/shelfManage/view/editMultilateralContract"),
}, },
9031310: { 9031310: {
path: "/editMultilateralContract", path: "/editMultilateralContract",
...@@ -593,7 +593,7 @@ export const routerName = { ...@@ -593,7 +593,7 @@ export const routerName = {
sideHidden: true, sideHidden: true,
activePath: "/shelfManage", activePath: "/shelfManage",
}, },
component: _import("goods/shelfManage/editMultilateralContract"), component: _import("goods/shelfManage/view/editMultilateralContract"),
}, },
90314: { 90314: {
path: "/purchaseOnShelves", path: "/purchaseOnShelves",
......
import Vue from "vue"; import Vue from "vue";
import Vuex from "vuex"; import Vuex from "vuex";
import ShelfManage from "@/views/goods/shelfManage/store/index.js";
import performanceFormStore from "@/views/residentManage/salaryPerformance/performanceScheme/store/performanceFormStore.js"; import performanceFormStore from "@/views/residentManage/salaryPerformance/performanceScheme/store/performanceFormStore.js";
import cacheStore from "./modules/cacheStore";
import d2admin, { storeResets } from "./modules/d2admin"; import d2admin, { storeResets } from "./modules/d2admin";
import FinancialRules from "./modules/FinancialRules"; import FinancialRules from "./modules/FinancialRules";
import goodsInfoData from "./modules/goodsInfoData"; import goodsInfoData from "./modules/goodsInfoData";
...@@ -23,8 +26,10 @@ if (!isProd) { ...@@ -23,8 +26,10 @@ if (!isProd) {
export default new Vuex.Store({ export default new Vuex.Store({
modules: { modules: {
d2admin, d2admin,
cacheStore,
goodsInfoData, goodsInfoData,
FinancialRules, FinancialRules,
PerformanceFormStore: performanceFormStore, PerformanceFormStore: performanceFormStore,
ShelfManage,
}, },
}); });
# Vuex 缓存模块使用指南
## 1. 模块注册
### 在 `src/store/index.js` 中注册模块
```javascript
import cacheStore from "./modules/cacheStore";
export default new Vuex.Store({
modules: {
cacheStore // 使用命名空间 'cacheStore'
}
});
```
## 2. 组件调用示例
### 基础用法:缓存优先策略
```vue
<template>
<div class="example-container">
<!-- 加载状态 -->
<div v-if="isLoading" class="loading">
数据加载中...
</div>
<!-- 错误显示 -->
<div v-else-if="error" class="error">
{{ error }}
</div>
<!-- 数据显示 -->
<div v-else-if="userData" class="data">
<h3>用户信息</h3>
<p>姓名: {{ userData.name }}</p>
<p>邮箱: {{ userData.email }}</p>
</div>
<!-- 操作按钮 -->
<div class="actions">
<button @click="fetchUserData">
获取用户数据(缓存优先)
</button>
<button @click="refreshUserData">
刷新数据(强制更新)
</button>
<button @click="clearData">
清除缓存
</button>
</div>
</div>
</template>
<script>
import { mapActions, mapGetters } from "vuex";
import * as userApi from "@/api/user"; // 导入 API 模块
export default {
name: "UserExample",
data() {
return {
userId: 123 // 示例用户 ID
};
},
computed: {
// 使用 getter 获取缓存数据、加载状态、错误信息
...mapGetters("cacheStore", {
userData: state => state.getCacheData("user_123"),
isLoading: state => state.isLoading("user_123"),
error: state => state.getError("user_123")
})
},
methods: {
...mapActions("cacheStore", ["fetchData", "clearCache"]),
// 缓存优先:第一次调用会从接口获取,第二次调用直接返回缓存
async fetchUserData() {
try {
const data = await this.fetchData({
key: "user_123",
apiFn: userApi.getUserDetailApi,
params: { userId: this.userId }
});
console.log("用户数据:", data);
} catch (error) {
console.error("获取数据失败:", error);
}
},
// 强制刷新:忽略缓存,重新从接口获取
async refreshUserData() {
try {
const data = await this.fetchData({
key: "user_123",
apiFn: userApi.getUserDetailApi,
params: { userId: this.userId },
forceRefresh: true // 强制刷新
});
console.log("最新用户数据:", data);
} catch (error) {
console.error("刷新失败:", error);
}
},
// 清除缓存
clearData() {
this.clearCache("user_123");
}
},
mounted() {
// 组件挂载时自动获取数据
this.fetchUserData();
}
};
</script>
<style scoped>
.loading,
.error,
.data {
padding: 20px;
margin-bottom: 20px;
border-radius: 4px;
}
.loading {
background-color: #e3f2fd;
color: #1976d2;
}
.error {
background-color: #ffebee;
color: #c62828;
}
.data {
background-color: #f3e5f5;
color: #6a1b9a;
}
.actions {
margin-top: 20px;
}
button {
margin-right: 10px;
padding: 8px 16px;
border: 1px solid #ccc;
border-radius: 4px;
cursor: pointer;
}
</style>
```
## 3. 高级用法:带缓存时间限制
```vue
<script>
export default {
methods: {
// 数据缓存 5 分钟(300000 毫秒)后过期
async fetchProductList() {
await this.fetchData({
key: "product_list",
apiFn: productApi.getProductListApi,
params: { category: "electronics" },
cacheTime: 300000 // 5 分钟有效期
});
}
}
};
</script>
```
## 4. API 模块示例
在 `src/api/user.js` 中:
```javascript
import request from "./request";
const path = "dj.api.smartcarlife.";
/**
* 获取用户详情
* @param {object} data - 请求数据
* @param {number} data.userId - 用户 ID
*/
export function getUserDetailApi(data) {
data.method = `${path}user.detail`;
return request(data, "post");
}
/**
* 更新用户信息
*/
export function updateUserApi(data) {
data.method = `${path}user.update`;
return request(data, "post");
}
```
## 5. Vuex 模块核心特性
### ✅ 缓存优先策略
```javascript
// 第一次调用:从接口获取数据并缓存
await this.fetchData({
key: "user_123",
apiFn: userApi.getUserDetailApi,
params: { userId: 123 }
});
// 第二次调用:直接返回缓存数据,不调用接口
await this.fetchData({
key: "user_123",
apiFn: userApi.getUserDetailApi,
params: { userId: 123 }
});
```
### ✅ 避免重复请求
如果在第一个请求还未完成时,又发起了相同的请求,模块会复用之前的 Promise:
```javascript
// 同时发起三个相同的请求
Promise.all([
this.fetchData({ key: "data", apiFn: api1 }),
this.fetchData({ key: "data", apiFn: api1 }),
this.fetchData({ key: "data", apiFn: api1 })
]);
// 只会触发一次接口调用,其他请求复用 Promise
```
### ✅ 完整的状态管理
```javascript
computed: {
...mapGetters('cacheStore', {
data: state => state.getCacheData('key'),
isLoading: state => state.isLoading('key'),
error: state => state.getError('key'),
hasCache: state => state.hasCacheData('key')
})
}
```
### ✅ 灵活的缓存控制
```javascript
// 清除指定缓存
this.$store.dispatch("cacheStore/clearCache", "user_123");
// 清除所有缓存
this.$store.dispatch("cacheStore/clearAllCache");
// 手动更新缓存
this.$store.dispatch("cacheStore/updateCache", {
key: "user_123",
value: newData
});
```
## 6. 在路由守卫中预加载数据
```javascript
// src/router/index.js
router.beforeEach((to, from, next) => {
if (to.meta.requiresData) {
store.dispatch('cacheStore/fetchData', {
key: to.meta.dataKey,
apiFn: to.meta.dataApi,
params: to.params
}).then(() => {
next()
}).catch(() => {
next(false)
})
} else {
next()
}
})
// 路由定义
{
path: '/user/:id',
component: UserDetail,
meta: {
requiresData: true,
dataKey: 'user_detail',
dataApi: userApi.getUserDetailApi
}
}
```
## 7. TypeScript 支持(可选)
如果项目使用 TypeScript,可以定义接口:
```typescript
interface FetchDataOptions {
key: string
apiFn: (params: any) => Promise<any>
params?: Record<string, any>
forceRefresh?: boolean
cacheTime?: number
}
interface CacheState {
cache: Record<string, any>
loading: Record<string, boolean>
errors: Record<string, string | null>
requestMap: Record<string, Promise<any>>
}
```
## 总结
| 功能 | 说明 |
|------|------|
| 缓存优先 | 优先检查 state 中的缓存,无缓存则调用接口 |
| 接口兜底 | 缓存无效时自动调用接口获取最新数据 |
| 避免重复 | 相同请求进行中时复用 Promise,避免重复调用 |
| 时间限制 | 支持设置缓存有效期,过期自动更新 |
| 完整状态 | 加载状态、错误信息、缓存数据全方位管理 |
| 命名空间 | 开启 namespaced,防止状态冲突 |
| 响应式 | 通过 mutation 更新,保证视图同步更新 |
/**
* Vuex 缓存模块 - 支持缓存优先、接口兜底
* 特性:
* 1. 缓存优先策略:state中有有效值则直接返回,无则调用接口
* 2. 支持自定义参数:接口函数可接收 params 参数
* 3. 避免重复请求:使用 requestMap 跟踪请求中的 Promise
* 4. 完整的加载/错误状态管理
* 5. 开启命名空间防止状态冲突
*/
export default {
namespaced: true,
state: {
// 缓存数据存储对象,key为缓存键名,value为缓存数据
cache: {},
// 加载状态映射,key为缓存键名,value为 boolean
loading: {},
// 错误信息映射,key为缓存键名,value为错误信息字符串
errors: {},
// 正在进行的请求 Promise 映射,用于避免重复请求
// key为缓存键名,value为 Promise 对象
requestMap: {},
},
mutations: {
/**
* 设置缓存数据
* @param {string} key - 缓存键名
* @param {*} value - 缓存数据值
*/
SET_CACHE(state, { key, value }) {
state.cache[key] = value;
},
/**
* 设置加载状态
* @param {string} key - 缓存键名
* @param {boolean} loading - 加载状态
*/
SET_LOADING(state, { key, loading }) {
state.loading[key] = loading;
},
/**
* 设置错误信息
* @param {string} key - 缓存键名
* @param {string} error - 错误信息,null 表示清除错误
*/
SET_ERROR(state, { key, error }) {
state.errors[key] = error;
},
/**
* 设置请求 Promise(用于防止重复请求)
* @param {string} key - 缓存键名
* @param {Promise} promise - Promise 对象或 null
*/
SET_REQUEST(state, { key, promise }) {
if (promise) {
state.requestMap[key] = promise;
} else {
delete state.requestMap[key];
}
},
/**
* 清除指定键的所有数据
* @param {string} key - 缓存键名
*/
CLEAR_CACHE(state, key) {
delete state.cache[key];
delete state.loading[key];
delete state.errors[key];
delete state.requestMap[key];
},
/**
* 清空所有缓存数据
*/
CLEAR_ALL_CACHE(state) {
state.cache = {};
state.loading = {};
state.errors = {};
state.requestMap = {};
},
},
actions: {
/**
* 获取缓存数据或调用接口获取
* 核心方法:实现缓存优先、接口兜底的逻辑
*
* @param {object} context - Vuex action context
* @param {object} options - 配置选项
* @param {string} options.key - 缓存键名(必填)
* @param {Function} options.apiFn - 接口函数(必填),返回 Promise
* @param {object} options.params - 接口参数(可选)
* @param {boolean} options.forceRefresh - 是否强制刷新,忽略缓存(可选,默认 false)
* @param {number} options.cacheTime - 缓存有效期(毫秒),0 表示永久有效(可选,默认 0)
* @returns {Promise} 返回缓存数据或接口响应数据
*/
async fetchData({ state, commit }, options) {
const { key, apiFn, params = {}, forceRefresh = false, cacheTime = 0 } = options;
if (!key || !apiFn) {
throw new Error("fetchData 方法必须提供 key 和 apiFn 参数");
}
// 1. 检查是否有正在进行的请求,有则直接返回 Promise (避免重复请求)
if (state.requestMap[key]) {
return state.requestMap[key];
}
// 2. 缓存优先策略:检查是否有有效缓存(非强制刷新)
if (!forceRefresh && state.cache[key] !== undefined) {
// 如果设置了缓存时间限制,需要检查缓存是否过期
if (cacheTime === 0 || (state.cache[key]._timestamp && Date.now() - state.cache[key]._timestamp < cacheTime)) {
return state.cache[key];
}
}
// 3. 无有效缓存,调用接口获取数据
commit("SET_LOADING", { key, loading: true });
commit("SET_ERROR", { key, error: null });
const promise = apiFn(params).then((response) => {
// 接口成功响应
const data = response.data || response;
// 如果设置了缓存时间,记录时间戳
const cacheData = cacheTime > 0
? Object.assign({}, data, { _timestamp: Date.now() })
: data;
// 存储到 state,保证响应式
commit("SET_CACHE", { key, value: cacheData });
commit("SET_ERROR", { key, error: null });
commit("SET_LOADING", { key, loading: false });
commit("SET_REQUEST", { key, promise: null });
return cacheData;
}).catch((error) => {
// 接口调用失败
const errorMsg = error.message || "数据获取失败";
commit("SET_ERROR", { key, error: errorMsg });
commit("SET_LOADING", { key, loading: false });
commit("SET_REQUEST", { key, promise: null });
console.error(`[cacheStore] 接口请求失败 [${key}]:`, error);
throw error;
});
// 保存正在进行的请求
commit("SET_REQUEST", { key, promise });
return promise;
},
/**
* 手动更新缓存数据
* @param {object} context - Vuex action context
* @param {object} options - 配置选项
* @param {string} options.key - 缓存键名
* @param {*} options.value - 新的缓存值
*/
updateCache({ commit }, { key, value }) {
commit("SET_CACHE", { key, value });
},
/**
* 清除指定缓存
* @param {object} context - Vuex action context
* @param {string} key - 缓存键名
*/
clearCache({ commit }, key) {
commit("CLEAR_CACHE", key);
},
/**
* 清空所有缓存
* @param {object} context - Vuex action context
*/
clearAllCache({ commit }) {
commit("CLEAR_ALL_CACHE");
},
},
getters: {
/**
* 获取指定键的缓存数据
*/
getCacheData: state => (key) => {
return state.cache[key];
},
/**
* 获取指定键的加载状态
*/
isLoading: state => (key) => {
return state.loading[key] || false;
},
/**
* 获取指定键的错误信息
*/
getError: state => (key) => {
return state.errors[key] || null;
},
/**
* 检查指定键是否有有效缓存
*/
hasCacheData: state => (key) => {
return state.cache[key] !== undefined;
},
},
};
...@@ -186,7 +186,8 @@ ...@@ -186,7 +186,8 @@
:placeholder="item.label" :placeholder="item.label"
:style="{ width: item.width || formItemWidth }" :style="{ width: item.width || formItemWidth }"
@blur="blur(item)" @blur="blur(item)"
@input="input($event, item)"> @input="input($event, item)"
>
</el-input> </el-input>
<template v-if="item.name == 'minSellPrice'"> <template v-if="item.name == 'minSellPrice'">
<el-checkbox v-model="formData.validMinSellPriceFlag" <el-checkbox v-model="formData.validMinSellPriceFlag"
...@@ -340,8 +341,8 @@ ...@@ -340,8 +341,8 @@
:prop="item.name" :prop="item.name"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }"> :style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<template> <template>
<el-upload accept=".jpg,.png,.pdf" <el-upload
action="" accept=".jpg,.png,.pdf"action=""
:auto-upload="false" :auto-upload="false"
class="upload-file" class="upload-file"
drag drag
...@@ -463,6 +464,7 @@ ...@@ -463,6 +464,7 @@
<el-input v-model.trim="storeSearchForm.yqMerchantName" <el-input v-model.trim="storeSearchForm.yqMerchantName"
clearable clearable
placeholder="服务对接" placeholder="服务对接"
clearable
@keydown.native="handleStoreInput" /> @keydown.native="handleStoreInput" />
</el-form-item> </el-form-item>
<el-form-item label="服务对接商户号:"> <el-form-item label="服务对接商户号:">
......
<!-- 上架编辑 -->
<template> <template>
<d2-container v-loading="!show" class="edit-commodity"> <d2-container v-loading="!show" class="edit-commodity">
<div v-if="show" class=""> <div v-if="show" class="">
...@@ -25,7 +24,6 @@ import { baseConfig } from "@/main"; ...@@ -25,7 +24,6 @@ import { baseConfig } from "@/main";
import { convertYuanToWan, filterSpecsStr } from "../filterOption"; import { convertYuanToWan, filterSpecsStr } from "../filterOption";
import groundingForm from "./components/groundingForm.vue"; import groundingForm from "./components/groundingForm.vue";
import { baseSupplyModeList, productList, upgradeSupplyModeList } from "./constants/data"; import { baseSupplyModeList, productList, upgradeSupplyModeList } from "./constants/data";
export default { export default {
name: "EditGrounding", name: "EditGrounding",
components: { components: {
...@@ -39,7 +37,8 @@ export default { ...@@ -39,7 +37,8 @@ export default {
proFormRef: "pro", proFormRef: "pro",
editForm: [{ editForm: [{
title: "商品信息", title: "商品信息",
formBlock: [{ formBlock: [
{
name: "upgradeGoodsId", name: "upgradeGoodsId",
label: "上架商品", label: "上架商品",
isRequired: true, isRequired: true,
...@@ -97,7 +96,8 @@ export default { ...@@ -97,7 +96,8 @@ export default {
type: "input", type: "input",
maxlength: 50, maxlength: 50,
width: "432px", width: "432px",
}, { },
{
name: "warrantyType", name: "warrantyType",
label: "质保卡类型", label: "质保卡类型",
type: "select", type: "select",
...@@ -123,55 +123,63 @@ export default { ...@@ -123,55 +123,63 @@ export default {
type: "radio", type: "radio",
index: 1, index: 1,
radioGroupList: [], radioGroupList: [],
}, { },
{
name: "upgradeSupplyMode", name: "upgradeSupplyMode",
label: "升级/产品供货模式", label: "升级/产品供货模式",
type: "radio", type: "radio",
index: 2, index: 2,
radioGroupList: [], radioGroupList: [],
}, { },
{
name: "sellPrice", name: "sellPrice",
label: "售价", label: "售价",
type: "input", type: "input",
width: "432px", width: "432px",
unit: true, unit: true,
handleInput: true, handleInput: true,
}, { },
{
name: "minSellPrice", name: "minSellPrice",
label: "最低售价", label: "最低售价",
type: "input", type: "input",
width: "432px", width: "432px",
unit: true, unit: true,
handleInput: true, handleInput: true,
}, { },
{
name: "upgradeProductCost", name: "upgradeProductCost",
label: "产品、升级成本", label: "产品、升级成本",
type: "input", type: "input",
width: "432px", width: "432px",
unit: true, unit: true,
handleInput: true, handleInput: true,
}, { },
{
name: "giftCost", name: "giftCost",
label: "赠送成本", label: "赠送成本",
type: "input", type: "input",
width: "432px", width: "432px",
unit: true, unit: true,
handleInput: true, handleInput: true,
}, { },
{
name: "recoveryCost", name: "recoveryCost",
label: "回收成本", label: "回收成本",
type: "input", type: "input",
width: "432px", width: "432px",
unit: true, unit: true,
handleInput: true, handleInput: true,
}, { },
{
name: "virtualAccountCost", name: "virtualAccountCost",
label: "虚拟对账成本", label: "虚拟对账成本",
type: "input", type: "input",
width: "432px", width: "432px",
unit: true, unit: true,
handleInput: true, handleInput: true,
}, { },
{
name: "djCost", name: "djCost",
label: "嘀加成本", label: "嘀加成本",
type: "input", type: "input",
...@@ -179,7 +187,8 @@ export default { ...@@ -179,7 +187,8 @@ export default {
unit: true, unit: true,
isDisabled: false, isDisabled: false,
handleInput: true, handleInput: true,
}, { },
{
name: "thirdPartyCost", name: "thirdPartyCost",
label: "第三方成本", label: "第三方成本",
type: "input", type: "input",
...@@ -423,7 +432,7 @@ export default { ...@@ -423,7 +432,7 @@ export default {
}; };
if (params.tempValidDate) { if (params.tempValidDate) {
delete params.tempValidDate; delete params.tempValidDate;
} };
if (data?.goodsType == 1 && data?.sceneType != 1) if (data?.goodsType == 1 && data?.sceneType != 1)
return this.$message.warning("太阳膜类商品仅支持上架至精品升级场景"); return this.$message.warning("太阳膜类商品仅支持上架至精品升级场景");
if (this.extendedPosiType.includes(data.goodsType) && data?.sceneType != 0) if (this.extendedPosiType.includes(data.goodsType) && data?.sceneType != 0)
......
...@@ -55,8 +55,8 @@ ...@@ -55,8 +55,8 @@
width="120"> width="120">
<template #default="scope"> <template #default="scope">
<el-select v-model="scope.row.inventoryType" size="small"> <el-select v-model="scope.row.inventoryType" size="small">
<el-option label="实物管控" :value="2"></el-option> <el-option label="实物" :value="2"></el-option>
<el-option label="虚拟管控" :value="1"></el-option> <el-option label="虚拟" :value="1"></el-option>
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
...@@ -150,9 +150,6 @@ export default { ...@@ -150,9 +150,6 @@ export default {
}, },
methods: { methods: {
getIndex(index) { getIndex(index) {
if (!this.isHide) {
return index + 1;
}
// 当有合并单元格时,计算当前行在 spanArr 中是第几个非0项,从而得出正确的顺序序号 // 当有合并单元格时,计算当前行在 spanArr 中是第几个非0项,从而得出正确的顺序序号
let count = 0; let count = 0;
for (let i = 0; i <= index; i++) { for (let i = 0; i <= index; i++) {
......
...@@ -654,9 +654,10 @@ export default { ...@@ -654,9 +654,10 @@ export default {
} }
let _formData = []; let _formData = [];
this.formData.groundingGoodsList.forEach((item) => { this.formData.groundingGoodsList.forEach((item) => {
_formData.push({ _formData.push({
merchantGoodsId: item.id || item.upgradeGoods.id, merchantGoodsId: item?.id || item?.upgradeGoods?.id,
upgradeGoodsName: item.upgradeGoods?.upgradeGoodsName, upgradeGoodsName: item.upgradeGoods?.upgradeGoodsName,
inventoryType: item.inventoryType || 2, inventoryType: item.inventoryType || 2,
}); });
...@@ -957,9 +958,9 @@ export default { ...@@ -957,9 +958,9 @@ export default {
}; };
} }
merchantGoodsMap[item.merchantId].inventoryTypeRefList.push({ merchantGoodsMap[item.merchantId].inventoryTypeRefList.push({
merchantGoodsId: item.merchantGoodsId || item.upgradeGoods.id, merchantGoodsId: item?.merchantGoodsId || item?.upgradeGoods?.id,
merchantId: item.merchantId, merchantId: item?.merchantId,
merchantName: item.merchantName, merchantName: item?.merchantName,
inventoryType: item.inventoryType, inventoryType: item.inventoryType,
}); });
}); });
......
<!-- 编辑 - 基础信息 -->
<template>
<div v-loading="loading" class="edit-page base-info">
<div class="title">
<span>基础信息</span>
</div>
<div style="padding: 20px 20px 0">
<el-form label-width="150px" :model="basicInfo">
<el-form-item v-for="(item, index) in editFormData"
:key="index"
class="form-item"
:style="{ width: [2, 7].includes(item.inputType) ? '100%' : '48%' }">
<template #label>
<span class="label">{{ item.title }}:</span>
</template>
<div v-if="item.inputType === 7">
<div v-if="!item.fileList.length">
-
</div>
<div v-else style="width:100%">
<div v-for="(k, kIdx) in item.fileList"
:key="kIdx"
class="file-name-wrapper">
<div class="name text-hide" :title="k.fileName">
{{ k.fileName }}
</div>
<el-link class="download"
:href="k.url"
type="primary">
下载
</el-link>
</div>
</div>
</div>
<span v-else
class="rich-text text-hide"
:title="item.showValue || '-'">
{{ item.showValue || "-" }}
</span>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
import { last } from "lodash-es";
import { getBusisDetailBasic } from "@/api/shelfManage.js";
export default {
name: "BaseInfo",
props: {
shelveId: {
type: [String, Number],
require: true,
},
},
data() {
return {
loading: false,
basicInfo: {},
editFormData: [],
};
},
computed: {
},
watch: {
},
async mounted() {
this.loading = true;
try {
await this.getData(this.shelveId);
} finally {
this.loading = false;
}
},
methods: {
async getData(shelveId) {
const { basicInfo } = await getBusisDetailBasic({ id: shelveId });
console.log("basicInfo", basicInfo);
if (!basicInfo?.basicApproveInfo) {
return [];
}
const editFormData = JSON.parse(basicInfo.basicApproveInfo);
console.log("editFormData", editFormData);
editFormData.forEach((item) => {
// 直接展示
if ([1, 2, 3, 4].includes(item.inputType)) {
item.showValue = item.value;
} else if (item.inputType === 5) {
// 单选
item.showValue = item.options.find(k => k.key == item.value)?.value || "";
} else if (item.inputType === 6) {
// 多选
// console.log(item.value, 'item.value')
const list = item.value.split(",");
item.showValue = "";
list.forEach((m, idx) => {
let label = item.options.find(k => k.key == m)?.value || "";
item.showValue = item.showValue + (idx !== 0 ? "," + label : label);
});
} else if (item.inputType === 7) {
// 附件
item.fileList = [];
if (basicInfo.goodsCreateExcel) {
const goodsCreateExcel = basicInfo.goodsCreateExcel.split("/");
item.fileList.push({
url: basicInfo.goodsCreateExcel,
fileName: last(goodsCreateExcel),
});
}
if (basicInfo?.submitGoodsCreateExcel) {
const submitGoodsCreateExcel = basicInfo.submitGoodsCreateExcel.split("/");
item.fileList.push({
url: basicInfo.submitGoodsCreateExcel,
fileName: last(submitGoodsCreateExcel),
});
}
// console.log(item.value, 'item.value')
const valueList = item.value ? item.value.split(",") : [];
valueList.forEach((k, kIdx) => {
if (k) {
item.fileList.push({
url: k,
fileName: k.split("/")[k.split("/").length - 1],
});
}
});
}
});
this.editFormData = editFormData;
this.baseInfo = basicInfo;
},
},
};
</script>
<style lang="scss">
@import "../../style/editdetailCon.scss";
.base-info {
.el-form-item__label {
padding-right: 0;
}
.el-form-item__label,
.el-form-item__content {
line-height: 20px !important;
}
.form-item {
display: inline-block;
line-height: 20px;
margin-bottom: 20px;
.file-name-wrapper {
width: 100%;
display: flex;
align-items: center;
overflow: hidden;
.download {
margin-left: 12px;
flex-shrink: 0;
}
}
}
.rich-text {
display: inline-block;
max-width: 98%;
overflow-wrap: break-word;
}
}
</style>
<!-- 驳回 --> <!-- 驳回 -->
<template> <template>
<baseDialog :dialog-config="dialogConfig" <baseDialog class="accountDailog"
:dialog-config="dialogConfig"
:is-show.sync="visible" :is-show.sync="visible"
class="accountDailog"
@handleClick="handleAddConfirm"> @handleClick="handleAddConfirm">
<div class="reject-dialog"> <div class="reject-dialog">
<glsx-combi-form class="edit-form-container" <glsx-combi-form ref="formRef"
ref="formRef" class="edit-form-container"
label-width="150px"
default-width="350px" default-width="350px"
:form-ref="rejectRef"
:form-obj="infoForm"
:form-data="editFormData" :form-data="editFormData"
:form-rules="formRules"></glsx-combi-form> :form-obj="infoForm"
:form-ref="rejectRef"
:form-rules="formRules"
label-width="150px">
</glsx-combi-form>
</div> </div>
</baseDialog> </baseDialog>
</template> </template>
<script> <script>
import { import {
reject reject,
} from "@api/shelfManage.js" } from "@api/shelfManage.js";
export default { export default {
name: 'RejectDialog', name: "RejectDialog",
props: {
rejectVisible: {
type: Boolean,
default: false,
},
paramsObj: {
type: Object,
default: () => ({}),
},
},
data() { data() {
return { return {
userInfo: this.$store.state.d2admin.user.info, userInfo: this.$store.state.d2admin.user.info,
infoForm: { infoForm: {
remark: '' remark: "",
}, },
dialogConfig: { dialogConfig: {
title: '驳回', title: "驳回",
width: '600px' width: "600px",
}, },
rejectRef: 'rejectRef', rejectRef: "rejectRef",
formRules: { formRules: {
remark: [{ required: true, message: '请输入驳回原因', trigger: 'blur' }] remark: [{ required: true, message: "请输入驳回原因", trigger: "blur" }],
}, },
editFormData: [{ editFormData: [{
label: '驳回原因', label: "驳回原因",
name: 'remark', name: "remark",
type: 'input', type: "input",
maxlength: 50, maxlength: 50,
inputType: 'textarea', inputType: "textarea",
showLimit: true, showLimit: true,
rows: 4 rows: 4,
}], }],
baseData: { baseData: {
}
}
},
props: {
rejectVisible: {
type: Boolean,
default: false
}, },
paramsObj: { };
type: Object,
default: {}
}
}, },
computed: { computed: {
visible: { visible: {
get() { get() {
return this.rejectVisible return this.rejectVisible;
}, },
set(newVal) { set(newVal) {
this.$emit('dialogClose', { flag: newVal, attrName: 'rejectVisible' }) this.$emit("dialogClose", { flag: newVal, attrName: "rejectVisible" });
} },
} },
}, },
mounted() { mounted() {
console.log('paramsObj', this.paramsObj) console.log("paramsObj", this.paramsObj);
}, },
methods: { methods: {
handleAddConfirm() { handleAddConfirm() {
this.$refs.formRef.$refs[this.rejectRef].validate(valid => { this.$refs.formRef.$refs[this.rejectRef].validate((valid) => {
if (valid) { if (valid) {
var params = {} let params = {};
params.rejectedReason = this.infoForm.remark params.rejectedReason = this.infoForm.remark;
params.id = this.paramsObj.id params.id = this.paramsObj.id;
reject(params).then(res => { reject(params).then((res) => {
this.notice.okTips('操作成功') this.notice.okTips("操作成功");
this.visible = true this.visible = true;
}) });
}
})
}
} }
} });
},
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.reject-dialog { .reject-dialog {
margin: 65px 0; margin: 65px 0;
......
import { limitPrice } from "@/common/format";
import store from "@/store";
export const CategoryTypeOptions = [
{ label: "按商品分类", value: 1 },
{ label: "按具体商品", value: 2 },
{ label: "按具体套餐", value: 3 },
];
<template>
<el-row class="description-wrapper">
<template v-for="item in schema">
<el-col v-if="!isHideSchemaItem(item)"
:key="item.name + item.label"
:span="item.col || 12">
<slot :name="item.slot || item.name ">
<div class="form-item" :style="item.itemStyle || {}">
<span class="label" :style="{ width: item.labelWidth || '150px' }">
<slot :name="`${item.slot || item.name}-label`">
{{ item.label }}:
</slot>
</span>
<span class="value">
<div class="text-hide" :style="{ width: item.valueWidth || '100%' }">
<template v-if="item.render">
<RenderProxy :render="item.render"
:row="{ data, schemaItem: item, schema }" />
</template>
<template v-else>
<template v-if="item.tooltip && (data[item.descKey] || data[item.name])">
<el-tooltip :content="isZeroOrNumber(data[item.descKey] || data[item.name]) " v-bind="item.tooltipProps">
<div class="text-hide">
{{ isZeroOrNumber(data[item.descKey] || data[item.name]) }}
</div>
</el-tooltip>
</template>
<template v-else>
<slot :name="`${item.slot || item.name}-value`">
{{ isZeroOrNumber(data[item.descKey] || data[item.name]) }}
</slot>
</template>
</template>
</div>
</span>
</div>
</slot>
</el-col>
</template>
</el-row>
</template>
<script>
import { isFunction } from "lodash-es";
import RenderProxy from "@/components/renderProxy/index.vue";
export default {
name: "Descriptions",
components: {
RenderProxy,
},
props: {
// name : - 唯一key , 数据的键值
// label : 文案
// col : 占24分之几
// valueWidth : 值的宽度,默认为100%
// labelWidth : 标签宽度,默认为150px
// slot : 整体的插槽名,优先级高于name
// itemStyle: 每一项的样式
// tooltip: boolean 是否用tooltip 展示data数据
// tooltipProps: el-tooltip 的传参
// render ?:(h,{ data,schemaItem,schema } )=>{} 自定义渲染
// isHide 是否隐藏 (data)=>boolean || boolean
schema: {
type: Array,
default: () => ([]),
},
data: {
type: Object,
default: () => ({}),
},
},
methods: {
isZeroOrNumber(val) {
const valid = (val === 0 || !Number.isNaN(val)) && val !== undefined && val !== null && val !== "";
return valid ? val : "-";
},
isHideSchemaItem(schemaItem) {
if (isFunction(schemaItem.isHide)) {
return schemaItem.isHide({ formModel: this.data });
}
return schemaItem.isHide;
},
},
render(h, ctx) {
return ctx.props.render(h, ctx.props.row);
},
};
</script>
<style scoped lang="scss">
.description-wrapper {
font-size: 14px;
.form-item {
display: flex;
flex-direction: row;
line-height: 32px;
margin-bottom: 20px;
> .label {
text-align: right;
color: #666666;
font-size: 14px;
flex-shrink: 0;
}
> .value {
flex-shrink: 0;
flex: 1;
overflow: hidden;
}
}
}
</style>
...@@ -131,10 +131,7 @@ export default { ...@@ -131,10 +131,7 @@ export default {
const textArr = []; const textArr = [];
this.editableTabs.push({ this.editableTabs.push({
title: title: item.groupType == 1 ? "全部品类" : "特殊品类" + (hasAllGoodsType ? index : index + 1),
item.groupType == 1
? "全部品类"
: "特殊品类" + (hasAllGoodsType ? index : index + 1),
name: (index + 1).toString(), name: (index + 1).toString(),
}); });
// 按具体商品 // 按具体商品
......
...@@ -6,16 +6,19 @@ ...@@ -6,16 +6,19 @@
</div> </div>
<div class="check-tab"> <div class="check-tab">
<el-tabs v-model="tabsValue" <el-tabs v-model="tabsValue"
type="card" class="my-tab-pane"
class="my-tab-pane"> type="card">
<el-tab-pane v-for="(item, idx) in goodTabs" <el-tab-pane v-for="(item, idx) in goodTabs"
:key="item.name" :key="item.name"
:name="item.name"> :name="item.name">
<span slot="label"><i class="el-icon-warning car-error-txt" <template #label>
v-if="item.valiadError == 'Y'" />{{ item.title ? item.title + (idx + 1) : item.goodsName }} <span>
<i v-if="item.valiadError == 'Y'"
class="el-icon-warning car-error-txt" />{{ item.title ? item.title + (idx + 1) : item.goodsName }}
</span> </span>
</template>
<span> <span>
<good-tab :info="item.info" <GoodTab :info="item.info"
:tab-idx="item.tabIndex" /> :tab-idx="item.tabIndex" />
</span> </span>
</el-tab-pane> </el-tab-pane>
...@@ -23,11 +26,14 @@ ...@@ -23,11 +26,14 @@
:key="item.name" :key="item.name"
:label="item.title" :label="item.title"
:name="item.name"> :name="item.name">
<span slot="label"><i class="el-icon-warning car-error-txt" <template #label>
v-if="item.valiadError == 'Y'" />{{ item.title ? item.title + (idx + 1) : item.goodsName }} <span>
<i v-if="item.valiadError == 'Y'"
class="el-icon-warning car-error-txt" />{{ item.title ? item.title + (idx + 1) : item.goodsName }}
</span> </span>
</template>
<span> <span>
<package-tab :info="item.info" <PackageTab :info="item.info"
:tab-idx="item.tabIndex" :tab-idx="item.tabIndex"
@packageEditInfo="getPackageEditInfo_notice" /> @packageEditInfo="getPackageEditInfo_notice" />
</span> </span>
...@@ -38,21 +44,22 @@ ...@@ -38,21 +44,22 @@
</template> </template>
<script> <script>
import { getGoodsDetail } from "@api/shelfManage.js" import { getGoodsDetail } from "@api/shelfManage.js";
import goodTab from "./common/goodTab.vue" import { deepClone } from "@/common/util";
import packageTab from "./common/packageTab.vue" import goodTab from "./common/goodTab.vue";
import { deepClone } from "@/common/util" import packageTab from "./common/packageTab.vue";
export default { export default {
name: "GoodsInfo", name: "GoodsInfo",
components: {
GoodTab: goodTab,
PackageTab: packageTab,
},
props: { props: {
recordId: { recordId: {
type: Number, type: Number,
default: null default: null,
}
}, },
components: {
goodTab,
packageTab
}, },
data() { data() {
// 这里存放数据 // 这里存放数据
...@@ -65,92 +72,93 @@ export default { ...@@ -65,92 +72,93 @@ export default {
packageTabs: [], packageTabs: [],
goodInfoList: [], goodInfoList: [],
packageInfoList: [], packageInfoList: [],
goodsInfo: {} goodsInfo: {},
} };
}, },
computed: { computed: {
routeInfo() { routeInfo() {
return this.$route.params return this.$route.params;
} },
}, },
mounted() { mounted() {
this.getDetail() this.getDetail();
}, },
methods: { methods: {
getDetail() { getDetail() {
console.log("getGoodsDetail") console.log("getGoodsDetail");
// this.recordId // this.recordId
getGoodsDetail({ id: this.routeInfo.id }) getGoodsDetail({ id: this.routeInfo.id })
.then((res) => { .then((res) => {
console.log(res, "getGoodsDetail") console.log(res, "getGoodsDetail");
this.goodsInfo = res this.goodsInfo = res;
const goodsList = deepClone(res.goodsList) const goodsList = deepClone(res.goodsList);
const packageGoodsList = deepClone(res.packageGoodsList) const packageGoodsList = deepClone(res.packageGoodsList);
goodsList.forEach((item, idx) => { goodsList.forEach((item, idx) => {
const length = this.goodTabs.length const length = this.goodTabs.length;
const tabIndex = const tabIndex
length == 0 ? length : this.goodTabs[length - 1].tabIndex + 1 = length == 0 ? length : this.goodTabs[length - 1].tabIndex + 1;
this.goodTabs.push({ this.goodTabs.push({
goodsName: item.upgradeGoodsName, goodsName: item.upgradeGoodsName,
name: "good_" + tabIndex, name: "good_" + tabIndex,
tabIndex: tabIndex, tabIndex,
// goodId: item.id, // goodId: item.id,
info: item info: item,
}) });
this.tabsValue = "good_" + tabIndex this.tabsValue = "good_" + tabIndex;
}) });
packageGoodsList.forEach((item, idx) => { packageGoodsList.forEach((item, idx) => {
const length = this.packageTabs.length const length = this.packageTabs.length;
const tabIndex = const tabIndex
length == 0 ? length : this.packageTabs[length - 1].tabIndex + 1 = length == 0 ? length : this.packageTabs[length - 1].tabIndex + 1;
this.packageTabs.push({ this.packageTabs.push({
goodsName: item.packageName, goodsName: item.packageName,
name: "package_" + tabIndex, name: "package_" + tabIndex,
tabIndex: tabIndex, tabIndex,
// goodId: item.id, // goodId: item.id,
info: item info: item,
}) });
this.tabsValue = "package_" + tabIndex this.tabsValue = "package_" + tabIndex;
}) });
this.packageNotice() this.packageNotice();
}) })
.catch((err) => { .catch((err) => {
console.log(err) console.log(err);
}) });
}, },
/* 活动标签切换时触发 */ /* 活动标签切换时触发 */
beforeLeave(currentName, oldName) { beforeLeave(currentName, oldName) {
// console.log("currentName", currentName) // console.log("currentName", currentName)
// 通过tab标签的切换事件触发增加的函数 // 通过tab标签的切换事件触发增加的函数
// 如果name是add,则调用增加tab的函数 // 如果name是add,则调用增加tab的函数
this.currentIndex = currentName this.currentIndex = currentName;
}, },
// 填写套餐名称时通知 // 填写套餐名称时通知
getPackageEditInfo_notice(obj) { getPackageEditInfo_notice(obj) {
console.log("obj", obj) console.log("obj", obj);
this.packageTabs.find((item) => item.tabIndex == obj.idx).info = obj.info this.packageTabs.find(item => item.tabIndex == obj.idx).info = obj.info;
this.packageNotice() this.packageNotice();
}, },
// 初始化、填写套餐名称时、删除套餐时通知 // 初始化、填写套餐名称时、删除套餐时通知
packageNotice() { packageNotice() {
this.packageInfoList = [] this.packageInfoList = [];
this.packageTabs.forEach((item) => { this.packageTabs.forEach((item) => {
if (item.info) { if (item.info) {
console.log(item) console.log(item);
const o = { const o = {
name: item.info.val1 || item.info.packageName, name: item.info.val1 || item.info.packageName,
virtualCode: item.info.timeId, virtualCode: item.info.timeId,
id: item.info.id, id: item.info.id,
packageCode: item.info.packageCode packageCode: item.info.packageCode,
} };
this.packageInfoList.push(o) this.packageInfoList.push(o);
}
})
} }
} });
} },
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "../../style/editdetailCon.scss"; @import "../../style/editdetailCon.scss";
......
...@@ -12,8 +12,10 @@ ...@@ -12,8 +12,10 @@
<div class="title"> <div class="title">
<span>操作记录</span> <span>操作记录</span>
</div> </div>
<div style="padding: 20px" v-if="list && list.length > 0"> <div v-if="list && list.length > 0" style="padding: 20px">
<div class="wrap" v-for="(item, index) in list" :key="index"> <div v-for="(item, index) in list"
:key="index"
class="wrap">
<div class="type"> <div class="type">
{{ item.operatorTypeText }} {{ item.operatorTypeText }}
</div> </div>
...@@ -23,44 +25,48 @@ ...@@ -23,44 +25,48 @@
<div>操作时间:{{ item.createdDate }}</div> <div>操作时间:{{ item.createdDate }}</div>
</div> </div>
</div> </div>
<div v-else class="empty">暂无记录</div> <div v-else class="empty">
暂无记录
</div>
</div> </div>
</template> </template>
<script> <script>
import { deepClone ,Util} from "@/common/util" import { deepClone, Util } from "@/common/util";
export default { export default {
name: "OperateList", name: "OperateList",
props: { props: {
logList: { logList: {
type: Array, type: Array,
default: () => [] default: () => [],
} },
},
data() {
// 这里存放数据
return {
list: [],
types: { 1: "创建", 2: "驳回", 3: "确认", 4: "完成" },
};
}, },
watch: { watch: {
logList(val) { logList(val) {
this.list = val;
this.list = val for (let item in this.types) {
for (var item in this.types) {
this.list.forEach((ele) => { this.list.forEach((ele) => {
if (ele.operatorType == item) { if (ele.operatorType == item) {
ele.operatorTypeText = this.types[item] ele.operatorTypeText = this.types[item];
} }
}) });
} }
// console.log(this.list, "✈") // console.log(this.list, "✈")
this.list = deepClone(this.list) this.list = deepClone(this.list);
}
}, },
data() {
//这里存放数据
return {
list: [],
types: { 1: "创建", 2: "驳回", 3: "确认", 4: "完成" }
}
}, },
methods: {} methods: {},
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "../../style/editdetailCon.scss"; @import "../../style/editdetailCon.scss";
.wrap { .wrap {
......
...@@ -2,9 +2,14 @@ ...@@ -2,9 +2,14 @@
<template> <template>
<div class="edit-page shop-merchant-info-detail"> <div class="edit-page shop-merchant-info-detail">
<div style="padding: 20px 20px 0"> <div style="padding: 20px 20px 0">
<el-form :model="merchantInfoDetail" label-width="250px"> <el-form label-width="250px" :model="merchantInfoDetail">
<el-form-item v-for="(item, index) in editFormData" :key="index" class="form-item" :style="{ width: '48%' }"> <el-form-item v-for="(item, index) in editFormData"
<span slot="label" class="label">{{ item.label }}:</span> :key="index"
class="form-item"
:style="{ width: '48%' }">
<template #label>
<span class="label">{{ item.label }}:</span>
</template>
<span>{{ merchantInfoDetail[item.name] || "-" }}{{ item.suffix }}</span> <span>{{ merchantInfoDetail[item.name] || "-" }}{{ item.suffix }}</span>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -13,32 +18,21 @@ ...@@ -13,32 +18,21 @@
</template> </template>
<script> <script>
import { deepClone } from "@/common/util" import { sceneCodeList } from "@/common/constants.js";
import { sceneCodeList } from "@/common/constants.js" import { deepClone } from "@/common/util";
import { import {
busiModeList, businessModeList,
onlinePointsEnabledList,
operationModeList, operationModeList,
onlinePointsEnabledList } from "../../constant/baseData";
} from "../../constant/baseData"
export default { export default {
name: "ShopMerchantInfo", name: "ShopMerchantInfo",
props: { props: {
merchantInfo: { merchantInfo: {
type: Object, type: Object,
default: () => { } default: () => { },
}
}, },
watch: {
merchantInfo: {
handler(val, oldVal) {
if (val) {
this.dealInitData()
}
},
deep: true,
immediate: true
}
}, },
data() { data() {
// 这里存放数据 // 这里存放数据
...@@ -46,99 +40,112 @@ export default { ...@@ -46,99 +40,112 @@ export default {
editFormData: [ editFormData: [
{ {
label: "流量方信息", label: "流量方信息",
name: "merchantName" name: "merchantName",
}, },
{ {
label: "集团(上级商户)", label: "集团(上级商户)",
name: "parentMerchantName" name: "parentMerchantName",
}, },
{ {
label: "业务模式", label: "业务模式",
name: "businessModeName", name: "businessModeName",
attrName: "businessMode", attrName: "businessMode",
optionsName: "busiModeList" optionsName: "businessModeList",
}, },
{ {
label: "签约主体", label: "签约主体",
name: "contractingMerchantName" name: "contractingMerchantName",
}, },
{ {
label: "业务场景", label: "业务场景",
name: "sceneTypeName", name: "sceneTypeName",
attrName: "sceneType", attrName: "sceneType",
optionLabel: "confValue", optionLabel: "confValue",
optionsName: "sceneCodeList" optionsName: "sceneCodeList",
}, },
{ {
label: "园区店", label: "园区店",
name: "yqMerchantName" name: "yqMerchantName",
}, },
{ {
label: "预估流量/月", label: "预估流量/月",
name: "estimatedFlow" name: "estimatedFlow",
}, },
{ {
label: "预估转化率", label: "预估转化率",
name: "estimatedUpgradeRate", name: "estimatedUpgradeRate",
suffix: "%" suffix: "%",
}, },
{ {
label: "运营模式", label: "运营模式",
name: "operationModeName", name: "operationModeName",
attrName: "operationMode", attrName: "operationMode",
optionsName: "operationModeList" optionsName: "operationModeList",
}, },
{ {
label: "服务商", label: "服务商",
name: "partnerMerchantName" name: "partnerMerchantName",
}, },
{ {
label: "上级服务商", label: "上级服务商",
name: "parentPartnerMerchantName" name: "parentPartnerMerchantName",
}, },
{ {
label: "一线阳光是否开启线上积分", label: "一线阳光是否开启线上积分",
name: "firstLineSunshineOnlinePointsFlag", name: "firstLineSunshineOnlinePointsFlag",
attrName: "firstLineSunshineOnlinePointsFlag", attrName: "firstLineSunshineOnlinePointsFlag",
optionsName: "onlinePointsEnabledList" optionsName: "onlinePointsEnabledList",
}, },
{ {
label: "一线阳光2是否开启线上积分", label: "一线阳光2是否开启线上积分",
name: "firstLineSunshine2OnlinePointsFlag", name: "firstLineSunshine2OnlinePointsFlag",
attrName: "firstLineSunshine2OnlinePointsFlag", attrName: "firstLineSunshine2OnlinePointsFlag",
optionsName: "onlinePointsEnabledList" optionsName: "onlinePointsEnabledList",
} },
], ],
baseData: { baseData: {
busiModeList: busiModeList, businessModeList,
sceneCodeList: sceneCodeList, sceneCodeList,
operationModeList: operationModeList, operationModeList,
onlinePointsEnabledList onlinePointsEnabledList,
},
merchantInfoDetail: {},
};
}, },
merchantInfoDetail: {}
watch: {
merchantInfo: {
handler(val, oldVal) {
if (val) {
this.dealInitData();
} }
}, },
deep: true,
immediate: true,
},
},
methods: { methods: {
dealInitData() { dealInitData() {
console.log(this.merchantInfo, "merchantInfo") console.log(this.merchantInfo, "merchantInfo");
this.editFormData.forEach((item) => { this.editFormData.forEach((item) => {
if (item.attrName) { if (item.attrName) {
const obj = const obj
this.baseData[item.optionsName].find( = this.baseData[item.optionsName].find(
(k) => k =>
k[item.optionId || "confId"] == this.merchantInfo[item.attrName] k[item.optionId || "confId"] == this.merchantInfo[item.attrName],
) || {} ) || {};
// console.log(this.merchantInfo[item.attrName], this.baseData[item.optionsName]) // console.log(this.merchantInfo[item.attrName], this.baseData[item.optionsName])
// console.log(obj, 'dealInitData') // console.log(obj, 'dealInitData')
this.merchantInfoDetail[item.name] = deepClone(obj[item.optionLabel || "confName"]) this.merchantInfoDetail[item.name] = deepClone(obj[item.optionLabel || "confName"]);
} else { } else {
this.merchantInfoDetail[item.name] = deepClone(this.merchantInfo[item.name]) this.merchantInfoDetail[item.name] = deepClone(this.merchantInfo[item.name]);
}
})
} }
} });
} },
},
};
</script> </script>
<style lang="scss"> <style lang="scss">
@import "../../style/editdetailCon.scss"; @import "../../style/editdetailCon.scss";
......
...@@ -4,14 +4,25 @@ ...@@ -4,14 +4,25 @@
<span>流量方信息</span> <span>流量方信息</span>
</div> </div>
<div class="content"> <div class="content">
<el-tabs v-model="tabsValue" type="card" :before-leave="beforeLeave" class="my-tab-pane"> <el-tabs v-model="tabsValue"
<el-tab-pane v-for="(item) in tabsList" :key="item.tabIndex" :name="item.tabIndex + ''"> :before-leave="beforeLeave"
<span slot="label"><i class="el-icon-warning car-error-txt" v-if="item.valiadError == 'Y'" />{{ item.title }} class="my-tab-pane"
type="card">
<el-tab-pane v-for="(item) in tabsList"
:key="item.tabIndex"
:name="`${item.tabIndex}`">
<template #label>
<span>
<i v-if="item.valiadError == 'Y'" class="el-icon-warning car-error-txt" />{{ item.title }}
</span> </span>
</template>
<span> <span>
<!-- <shop-merchant-info :merchantInfo="merchantInfo"></shop-merchant-info> --> <!-- <shop-merchant-info :merchantInfo="merchantInfo"></shop-merchant-info> -->
<shop-merchant-info :merchantInfo="merchantsList[item.tabIndex]" :ref="`shopMerchant${item.tabIndex}`" <ShopMerchantInfo :key="item.tabIndex"
:key="item.tabIndex" :edit-data-obj="merchantsList[item.tabIndex]"></shop-merchant-info> :ref="`shopMerchant${item.tabIndex}`"
:edit-data-obj="merchantsList[item.tabIndex]"
:merchant-info="merchantsList[item.tabIndex]">
</ShopMerchantInfo>
</span> </span>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
...@@ -20,73 +31,74 @@ ...@@ -20,73 +31,74 @@
</template> </template>
<script> <script>
import ShopMerchantInfo from "./ShopMerchantInfo" import { deepClone } from "@/common/util";
import { deepClone } from "@/common/util" import ShopMerchantInfo from "./ShopMerchantInfo";
export default { export default {
name: "EditMultilateralContract", name: "EditMultilateralContract",
components: { components: {
ShopMerchantInfo ShopMerchantInfo,
}, },
props: { props: {
merchantsList: { merchantsList: {
type: Array, type: Array,
default: () => { } default: () => { },
} },
},
data() {
return {
tabsValue: 0,
tabsList: [],
};
}, },
watch: { watch: {
merchantsList(val) { merchantsList(val) {
this.tabsList = val.map((item, idx) => { this.tabsList = val.map((item, idx) => {
return { return {
title: item.merchantName, title: item.merchantName,
tabIndex: idx tabIndex: idx,
} };
}) });
}
}, },
data() {
return {
tabsValue: 0,
tabsList: []
}
}, },
mounted() { }, mounted() { },
methods: { methods: {
getAllParams() { getAllParams() {
const list = deepClone(this.tabsList) const list = deepClone(this.tabsList);
const merchants = [] const merchants = [];
// 需要使用for循环解决异步同步问题 // 需要使用for循环解决异步同步问题
for (var index = 0; index < list.length; index++) { for (let index = 0; index < list.length; index++) {
// const element = array[index]; // const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0] const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0];
const res = node.getParams() const res = node.getParams();
merchants.push(res) merchants.push(res);
} }
return merchants return merchants;
// }) // })
}, },
submit() { submit() {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
let flag = true let flag = true;
const list = deepClone(this.tabsList) const list = deepClone(this.tabsList);
// 需要使用for循环解决异步同步问题 // 需要使用for循环解决异步同步问题
for (var index = 0; index < list.length; index++) { for (let index = 0; index < list.length; index++) {
// const element = array[index]; // const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0] const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0];
const res = await node.submit() const res = await node.submit();
flag = flag && res flag = flag && res;
} }
this.$forceUpdate() this.$forceUpdate();
resolve(flag) resolve(flag);
}) });
}, },
/* 活动标签切换时触发 */ /* 活动标签切换时触发 */
beforeLeave(currentName, oldName) { beforeLeave(currentName, oldName) {
// console.log("currentName", currentName) // console.log("currentName", currentName)
// 通过tab标签的切换事件触发增加的函数 // 通过tab标签的切换事件触发增加的函数
this.currentIndex = currentName this.currentIndex = currentName;
} },
} },
} };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -5,16 +5,24 @@ ...@@ -5,16 +5,24 @@
<span>基础信息</span> <span>基础信息</span>
</div> </div>
<div style="padding: 20px 20px 0"> <div style="padding: 20px 20px 0">
<el-form :model="basicInfo" label-width="150px"> <el-form label-width="150px" :model="basicInfo">
<el-form-item v-for="(item, index) in editFormData" :key="index" class="form-item" <el-form-item v-for="(item, index) in editFormData"
:key="index"
class="form-item"
:style="{ width: [2, 7].includes(item.inputType) ? '100%' : '48%' }"> :style="{ width: [2, 7].includes(item.inputType) ? '100%' : '48%' }">
<span slot="label" class="label">{{ item.title }}:</span> <template #label>
<span class="label">{{ item.title }}:</span>
</template>
<div v-if="item.inputType == 7"> <div v-if="item.inputType == 7">
<div v-if="item.fileList.length == 0">-</div> <div v-if="item.fileList.length == 0">
-
</div>
<div v-else> <div v-else>
<div v-for="(k, kIdx) in item.fileList" :key="kIdx"> <div v-for="(k, kIdx) in item.fileList" :key="kIdx">
<span>{{ k.fileName }}</span> <span>{{ k.fileName }}</span>
<el-link type="primary" class="download" :href="k.url"> <el-link class="download"
:href="k.url"
type="primary">
下载 下载
</el-link> </el-link>
</div> </div>
...@@ -33,86 +41,133 @@ export default { ...@@ -33,86 +41,133 @@ export default {
props: { props: {
basicInfo: { basicInfo: {
type: Object, type: Object,
default: () => { } default: () => ({}),
}
}, },
watch: {
basicInfo(val) {
if (val?.basicApproveInfo) {
this.dealFormData()
}
}
}, },
data() { data() {
//这里存放数据 // 这里存放数据
return { return {
/** 动态表单 };
},
computed: {
/**
* 动态表单
* inputType 输入类型,1.文本;2.多行文本;3.数字;4.金额;5.单选;6.多选;7.附件; * inputType 输入类型,1.文本;2.多行文本;3.数字;4.金额;5.单选;6.多选;7.附件;
*/ */
editFormData: [] editFormData() {
if (!this.basicInfo?.basicApproveInfo) {
return [];
}
const editFormData = JSON.parse(this.basicInfo.basicApproveInfo);
editFormData.forEach((item) => {
// 直接展示
if ([1, 2, 3, 4].includes(item.inputType)) {
item.showValue = item.value;
} else if (item.inputType === 5) {
// 单选
item.showValue = item.options.find(k => k.key == item.value)?.value || "";
} else if (item.inputType === 6) {
// 多选
// console.log(item.value, 'item.value')
const list = item.value.split(",");
item.showValue = "";
list.forEach((m, idx) => {
let label = item.options.find(k => k.key == m)?.value || "";
item.showValue = item.showValue + (idx != 0 ? "," + label : label);
});
} else if (item.inputType == 7) {
// 附件
item.fileList = [];
if (this.basicInfo.goodsCreateExcel) {
item.fileList.push({
url: this.basicInfo.goodsCreateExcel,
fileName: this.basicInfo.goodsCreateExcel.split("/")[this.basicInfo.goodsCreateExcel.split("/").length - 1],
});
} }
if (this.basicInfo.submitGoodsCreateExcel) {
item.fileList.push({
url: this.basicInfo.submitGoodsCreateExcel,
fileName: this.basicInfo.submitGoodsCreateExcel.split("/")[this.basicInfo.goodsCreateExcel.split("/").length - 1],
});
}
// console.log(item.value, 'item.value')
const valueList = item.value ? item.value.split(",") : [];
valueList.forEach((k, kIdx) => {
if (k) {
item.fileList.push({
url: k,
fileName: k.split("/")[k.split("/").length - 1],
});
}
});
}
});
return editFormData;
},
},
watch: {
}, },
mounted() { }, mounted() { },
methods: { methods: {
dealFormData() { dealFormData() {
this.editFormData = JSON.parse(this.basicInfo.basicApproveInfo) console.log("this.basicInfo", this.basicInfo);
this.editFormData = JSON.parse(this.basicInfo.basicApproveInfo);
console.log("this.editFormData", this.editFormData);
this.editFormData.forEach((item) => { this.editFormData.forEach((item) => {
// 直接展示 // 直接展示
if ([1, 2, 3, 4].includes(item.inputType)) { if ([1, 2, 3, 4].includes(item.inputType)) {
item.showValue = item.value item.showValue = item.value;
} else if (item.inputType == 5) { } else if (item.inputType == 5) {
// 单选 // 单选
item.showValue = item.showValue
item.options.find((k) => k.key == item.value)?.value || "" = item.options.find(k => k.key == item.value)?.value || "";
} else if (item.inputType == 6) { } else if (item.inputType == 6) {
// 多选 // 多选
// console.log(item.value, 'item.value') // console.log(item.value, 'item.value')
const list = item.value.split(",") const list = item.value.split(",");
item.showValue = "" item.showValue = "";
list.forEach((m, idx) => { list.forEach((m, idx) => {
let label = item.options.find((k) => k.key == m)?.value || "" let label = item.options.find(k => k.key == m)?.value || "";
item.showValue = item.showValue + (idx != 0 ? "," + label : label) item.showValue = item.showValue + (idx != 0 ? "," + label : label);
}) });
} else if (item.inputType == 7) { } else if (item.inputType == 7) {
// 附件 // 附件
item.fileList = [] item.fileList = [];
if (this.basicInfo.goodsCreateExcel) { if (this.basicInfo.goodsCreateExcel) {
item.fileList.push({ item.fileList.push({
url: this.basicInfo.goodsCreateExcel, url: this.basicInfo.goodsCreateExcel,
fileName: fileName: this.basicInfo.goodsCreateExcel.split("/")[this.basicInfo.goodsCreateExcel.split("/").length - 1],
this.basicInfo.goodsCreateExcel.split("/")[ });
this.basicInfo.goodsCreateExcel.split("/").length - 1
]
})
} }
if (this.basicInfo.submitGoodsCreateExcel) { if (this.basicInfo.submitGoodsCreateExcel) {
item.fileList.push({ item.fileList.push({
url: this.basicInfo.submitGoodsCreateExcel, url: this.basicInfo.submitGoodsCreateExcel,
fileName: fileName: this.basicInfo.submitGoodsCreateExcel.split("/")[this.basicInfo.goodsCreateExcel.split("/").length - 1],
this.basicInfo.submitGoodsCreateExcel.split("/")[ });
this.basicInfo.goodsCreateExcel.split("/").length - 1
]
})
} }
// console.log(item.value, 'item.value') // console.log(item.value, 'item.value')
const valueList = item.value ? item.value.split(",") : [] const valueList = item.value ? item.value.split(",") : [];
valueList.forEach((k, kIdx) => { valueList.forEach((k, kIdx) => {
if (k) { if (k) {
item.fileList.push({ item.fileList.push({
url: k, url: k,
fileName: k.split("/")[k.split("/").length - 1] fileName: k.split("/")[k.split("/").length - 1],
}) });
}
})
} }
}) });
} }
} });
} },
},
};
</script> </script>
<style lang="scss"> <style lang="scss">
@import "../../style/editdetailCon.scss"; @import "../../style/editdetailCon.scss";
......
<template> <template>
<d2-dialog title="变更说明" :is-visible.sync="dialogShow" width="40%" @confirmDialog="dialogShow = false" <d2-dialog class="relateStore"
@closeDialog="dialogShow = false" :noCancel="true" class="relateStore"> :is-visible.sync="dialogShow"
<d2-table :hasPage="false" :tableData="tableData" :table-params="tableParams"> :no-cancel="true"
title="变更说明"
width="40%"
@closeDialog="dialogShow = false"
@confirmDialog="dialogShow = false">
<d2-table :has-page="false"
:table-data="tableData"
:table-params="tableParams">
</d2-table> </d2-table>
</d2-dialog> </d2-dialog>
</template> </template>
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
export default { export default {
name: 'RuleUpdateDialog', name: "RuleUpdateDialog",
props: { props: {
show: Boolean, show: Boolean,
tableData: { tableData: {
type: Array, type: Array,
default: () => { default: () => {
return [] return [];
} },
} },
}, },
data() { data() {
return { return {
tableParams: { tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000), btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list", listName: "list",
tableColumns: [ tableColumns: [
{ {
label: '变更内容', label: "变更内容",
prop: 'diffType', prop: "diffType",
width: 120 width: 120,
}, },
{ {
label: '变更后', label: "变更后",
prop: 'diffAfter' prop: "diffAfter",
}, },
{ {
label: '变更前', label: "变更前",
prop: 'diffBefore' prop: "diffBefore",
} },
] ],
} },
} };
}, },
computed: { computed: {
dialogShow: { dialogShow: {
get() { get() {
return this.show return this.show;
}, },
set(n) { set(n) {
this.$emit('update:show', n) this.$emit("update:show", n);
} },
} },
}, },
mounted() { mounted() {
}, },
...@@ -57,9 +64,9 @@ export default { ...@@ -57,9 +64,9 @@ export default {
init() { init() {
}, },
handleClick() { handleClick() {
} },
} },
} };
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
......
...@@ -4,14 +4,26 @@ ...@@ -4,14 +4,26 @@
<span>流量方信息</span> <span>流量方信息</span>
</div> </div>
<div class="content"> <div class="content">
<el-tabs v-model="tabsValue" type="card" :before-leave="beforeLeave" class="my-tab-pane"> <el-tabs v-model="tabsValue"
<el-tab-pane v-for="(item) in tabsList" :key="item.tabIndex" :name="item.tabIndex + ''"> :before-leave="beforeLeave"
<span slot="label"><i class="el-icon-warning car-error-txt" v-if="item.valiadError == 'Y'" />{{ item.title }} class="my-tab-pane"
type="card">
<el-tab-pane v-for="(item) in tabsList"
:key="item.tabIndex"
:name="`${item.tabIndex}`">
<template #label>
<span>
<i v-if="item.valiadError === 'Y'" class="el-icon-warning car-error-txt" />{{ item.title }}
</span> </span>
</template>
<span> <span>
<shop-merchant-info :yqMerchantList="yqMerchantList" :serviceList="serviceList" <ShopMerchantInfo :key="item.tabIndex"
:platformLevelList="platformLevelList" :ref="`shopMerchant${item.tabIndex}`" :key="item.tabIndex" :ref="`shopMerchant${item.tabIndex}`"
:edit-data-obj="merchantsList[item.tabIndex]"></shop-merchant-info> :edit-data-obj="merchantsList[item.tabIndex]"
:platform-level-list="platformLevelList"
:service-list="serviceList"
:yq-merchant-list="yqMerchantList">
</ShopMerchantInfo>
</span> </span>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
...@@ -20,35 +32,26 @@ ...@@ -20,35 +32,26 @@
</template> </template>
<script> <script>
import ShopMerchantInfo from "./ShopMerchantInfo" import { getPlatformMerchantList } from "@api/index";
import { deepClone } from "@/common/util"
import { import {
getServiceList,
// serviceGetMerchantList, // serviceGetMerchantList,
getyqMerchantList, getyqMerchantList,
getServiceList,
// getMerchantLevelApi // getMerchantLevelApi
} from "@api/merchant" } from "@api/merchant";
import { getPlatformMerchantList } from "@api/index" import { deepClone } from "@/common/util";
import ShopMerchantInfo from "./ShopMerchantInfo.vue";
export default { export default {
name: "EditMultilateralContract", name: "EditMultilateralContract",
components: { components: {
ShopMerchantInfo ShopMerchantInfo,
}, },
props: { props: {
merchantsList: { merchantsList: {
type: Array, type: Array,
default: () => { } default: () => { },
}
}, },
watch: {
merchantsList(val) {
this.tabsList = val.map((item, idx) => {
return {
title: item.merchantName,
tabIndex: idx
}
})
}
}, },
data() { data() {
return { return {
...@@ -56,71 +59,81 @@ export default { ...@@ -56,71 +59,81 @@ export default {
tabsList: [], tabsList: [],
yqMerchantList: [], yqMerchantList: [],
serviceList: [], serviceList: [],
platformLevelList: [] platformLevelList: [],
} };
},
watch: {
merchantsList(val) {
this.tabsList = val.map((item, idx) => {
return {
title: item.merchantName,
tabIndex: idx,
};
});
}, },
mounted() { },
this.initList() async mounted() {
await this.initList();
}, },
methods: { methods: {
initList() { async getYqMerchantList() {
getyqMerchantList({ currentPage: 1, pageSize: 100000 }).then((res) => { const res = await getyqMerchantList({ currentPage: 1, pageSize: 100000 });
res?.list?.forEach((val) => { res?.list?.forEach((val) => {
val.merchantId = val.merchantNo - 0 val.merchantId = val.merchantNo - 0;
}) });
this.yqMerchantList = res?.list || [] this.yqMerchantList = res?.list || [];
}) },
getServiceList({ currentPage: 1, pageSize: 100000 }).then((res) => {
async getServiceListData() {
const res = await getServiceList({ currentPage: 1, pageSize: 100000 });
res?.list?.forEach((val) => { res?.list?.forEach((val) => {
val.merchantId = val.merchantNo - 0 val.merchantId = val.merchantNo - 0;
}) });
this.serviceList = res?.list || [] this.serviceList = res?.list || [];
}) },
// initPlatformLevelList() {
getPlatformMerchantList({}).then((res) => { async getPlatformMerchantListData() {
const res = await getPlatformMerchantList({});
res.unshift({ res.unshift({
merchantId: -1, merchantId: -1,
merchantName: "嘀加智慧云" merchantName: "嘀加智慧云",
}) });
this.platformLevelList = res this.platformLevelList = res;
}) },
async initList() {
await this.getYqMerchantList();
await this.getServiceListData();
await this.getPlatformMerchantListData();
}, },
getAllParams() { getAllParams() {
const list = deepClone(this.tabsList) const list = deepClone(this.tabsList);
const merchants = [] const merchants = [];
// 需要使用for循环解决异步同步问题 // 需要使用for循环解决异步同步问题
for (var index = 0; index < list.length; index++) { for (let index = 0; index < list.length; index++) {
// const element = array[index]; // const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0] const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0];
const res = node.getParams() const res = node.getParams();
merchants.push(res) merchants.push(res);
} }
return merchants return merchants;
// }) // })
}, },
submit() { async submit() {
return new Promise(async (resolve, reject) => { let flag = true;
let flag = true const list = deepClone(this.tabsList);
const list = deepClone(this.tabsList)
// 需要使用for循环解决异步同步问题 // 需要使用for循环解决异步同步问题
for (var index = 0; index < list.length; index++) { for (let index = 0; index < list.length; index++) {
// const element = array[index]; // const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0] const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0];
const res = await node.submit() const res = await node.submit();
flag = flag && res flag = flag && res;
} }
this.$forceUpdate() this.$forceUpdate();
resolve(flag) return flag;
})
}, },
/* 活动标签切换时触发 */ },
beforeLeave(currentName, oldName) { };
// console.log("currentName", currentName)
// 通过tab标签的切换事件触发增加的函数
this.currentIndex = currentName
}
}
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
<template>
<div class="detail-wrapper">
<Descriptions :data="packageData" :schema="packagesSchema" />
<el-divider class="divider"></el-divider>
<div v-for="productData in goodsList"
:key="productData.id"
class="product-detail-wrapper">
<Product :product="productData"
:mode="VIEW_MODE.VIEW"
:scene-type="productData.sceneType"
:show-business-line="false"
:show-sales-proportion-percent="false"
:show-settlement-type="false"
use-parent-mode />
<el-divider class="divider"></el-divider>
</div>
</div>
</template>
<script>
import { cloneDeep } from "lodash-es";
import Descriptions from "@/views/goods/shelfManage/components/descriptions/index.vue";
import { productShelvingComboDetailFormItems } from "@/views/goods/shelfManage/components/productShelving/productShelving.data.js";
import { VIEW_MODE } from "@/views/goods/shelfManage/constant/baseData";
import Product from "../../../product/index.vue";
export default {
components: {
Descriptions,
Product,
},
props: {
packages: {
type: Object,
default: () => ({ }),
},
},
data() {
return {
VIEW_MODE,
packageData: {},
packagesSchema: productShelvingComboDetailFormItems,
goodsList: [],
};
},
watch: {
packages: {
handler(val) {
this.packageData = val;
this.goodsList = val?.merchantGoodsInfoList;
},
immediate: true,
},
},
mounted() {
},
methods: {
},
};
</script>
<style lang="scss" scoped>
.detail-wrapper {
padding: 20px;
.product-detail-wrapper {
padding-top: 16px;
}
}
.divider {
margin: 0px 16px 0;
width: calc(100% - 32px);
}
</style>
<template>
<div class="content">
<div class="tabs-wrapper">
<Detail v-show="mode === VIEW_MODE.VIEW"
v-bind="$attrs"
:packages="localProduct"
v-on="$listeners" />
<Modify v-show="mode === VIEW_MODE.EDIT"
ref="modifyRef"
:packages="localProduct"
v-bind="$attrs"
v-on="$listeners" />
</div>
</div>
</template>
<script>
import { VIEW_MODE } from "@/views/goods/shelfManage/constant/baseData.js";
import Detail from "./components/detail/index.vue";
import Modify from "./components/modify/index.vue";
export default {
name: "",
components: {
Modify,
Detail,
},
inheritAttrs: false,
props: {
mode: {
type: String,
default: VIEW_MODE.VIEW,
},
packages: {
type: Object,
required: true,
},
},
data() {
return {
VIEW_MODE,
localProduct: {},
};
},
watch: {
packages: {
handler(val) {
this.$set(this, "localProduct", val);
},
immediate: true,
deep: true,
},
},
methods: {
async validate() {
const modifyRef = this.$refs.modifyRef;
if (!modifyRef) {
// 尚未初始化
return;
}
return await modifyRef.validate();
},
},
};
</script>
<style scoped lang="scss">
</style>
<template>
<div class="detail-wrapper">
<Descriptions :data="descData" :schema="formItems">
<template #upgradeGoodsId-value>
<div class="sub-desc-wrapper">
<Descriptions :data="descData.upgradeGoods" :schema="subFormItems" />
</div>
</template>
</Descriptions>
</div>
</template>
<script>
import Descriptions from "@/views/goods/shelfManage/components/descriptions/index.vue";
import { productShelvingProductDetailFormItems, productShelvingProductDetailSubFormItems } from "@/views/goods/shelfManage/components/productShelving/productShelving.data.js";
import { handleCoverProductForm } from "@/views/goods/shelfManage/components/productShelving/utils/index.js";
export default {
name: "",
components: {
Descriptions,
},
props: {
product: {
type: Object,
required: true,
},
// 当套餐加载这个组件的时候 不需要业务线
showBusinessLine: {
type: Boolean,
default: true,
},
// 当套餐加载这个组件的时候 不需要结算方式
showSettlementType: {
type: Boolean,
default: true,
},
// 当套餐加载这个组件的时候 不需要销售占比
showSalesProportionPercent: {
type: Boolean,
default: true,
},
},
data() {
return {
subFormItems: productShelvingProductDetailSubFormItems,
schema: [],
};
},
computed: {
descData() {
return handleCoverProductForm(this.product);
},
formItems() {
return this.schema.filter((item) => {
if (item.name === "businessLine") {
return this.showBusinessLine;
}
if (item.name === "settlementType") {
return this.showSettlementType;
}
if (item.name === "salesProportionPercent") {
return this.showSalesProportionPercent;
}
return true;
});
},
},
async mounted() {
this.schema = await productShelvingProductDetailFormItems();
},
};
</script>
<style scoped lang="scss">
.sub-desc-wrapper {
background: #f2f4f7;
padding: 16px 8px;
// border-bottom: 1px solid #eee;
}
.detail-wrapper {
padding: 20px 20px 0;
}
</style>
<template>
<div class="">
<Detail v-show="mode === VIEW_MODE.VIEW"
v-bind="$attrs"
:mode="mode"
v-on="$listeners" />
<Modify v-show="mode === VIEW_MODE.EDIT"
v-bind="$attrs"
ref="modifyRef"
:mode="mode"
v-on="$listeners" />
</div>
</template>
<script>
import { VIEW_MODE } from "@/views/goods/shelfManage/constant/baseData.js";
import Detail from "./components/detail/index.vue";
import Modify from "./components/modify/index.vue";
export default {
components: {
Detail,
Modify,
},
inheritAttrs: false,
props: {
mode: {
type: String,
required: true,
},
},
data() {
return {
VIEW_MODE,
};
},
computed: {
},
watch: {
},
methods: {
async validate() {
const modifyRef = this.$refs.modifyRef;
if (!modifyRef) {
// 尚未初始化
return;
}
return await modifyRef.validate();
},
},
};
</script>
export const productFromRules = {
upgradeGoodsId: [
{ required: true, message: "请选择上架商品", trigger: "change" },
],
position: [
{ required: true, message: "请选择上架部位", trigger: "change" },
],
businessLine: [
{ required: true, message: "请选择业务线", trigger: "change" },
],
settlementType: [
{ required: true, message: "请选择结算方式", trigger: "change" },
],
salesProportionPercent: [
{ required: true, message: "请输入销售占比", trigger: "change" },
],
penetrationRate: [
{ required: true, message: "请输入渗透率要求", trigger: "change" },
],
sellPrice: [
{ required: true, message: "请输入售价", trigger: "change" },
],
minSellPrice: [
{ required: true, message: "请输入最低售价", trigger: "change" },
],
thirdPartyCost: [
{ required: true, message: "请输入第三方成本", trigger: "change" },
],
upgradeProductCost: [
{ required: true, message: "请输入升级成本", trigger: "change" },
],
};
export const packageFormRules = {
packageName: [
{ required: true, message: "请输入套餐名称", trigger: "change" },
],
businessLine: [
{ required: true, message: "请选择业务线", trigger: "change" },
],
settlementType: [
{ required: true, message: "请选择结算方式", trigger: "change" },
],
salesProportionPercent: [
{ required: true, message: "请输入销售占比", trigger: "change" },
],
penetrationRate: [
{ required: true, message: "请输入渗透率要求", trigger: "change" },
],
};
import { cloneDeep } from "lodash-es";
import { convertYuanToWan, filterSpecsStr } from "@/views/goods/filterOption.js";
export function getFormServiceItemNames(upgradeGoodsServiceItemsList = []) {
const textArr = upgradeGoodsServiceItemsList?.map((item) => {
return `${item.serviceName}-${item.serviceGrade}/${item.servicePeriod}${item.serviceItemId
? `/${convertYuanToWan(item.minPrice)}-${convertYuanToWan(item.maxPrice)}万`
: ""
}`;
});
return textArr?.join(",") || "";
}
export function getGoodsTypes(goodsInfo) {
const { goodsTypeName, secondaryGoodsTypeName, thirdLevelGoodsTypeName } = goodsInfo || {};
const types = [
goodsTypeName,
secondaryGoodsTypeName,
thirdLevelGoodsTypeName,
];
return types.join("-");
}
export function filterEmpty(data) {
return (data ?? "") === "";
}
export function handleCoverProductForm(product = {}) {
product.upgradeGoods = makeUpgradeGoods(product);
return product;
}
export function makeUpgradeGoods(formData) {
console.log("makeUpgradeGoods", formData);
return {
// ...formData,
upgradeGoodsName: formData.upgradeGoodsName,
goodsName: formData.goodsInfo?.goodsName,
tempGoodsTypeName: getGoodsTypes(formData?.goodsInfo),
position: formData.upgradeGoods?.position,
positionList: formData.upgradeGoods.position?.split(",")?.map(item => Number(item.trim())),
// 服务项目
serviceItemNames: getFormServiceItemNames(formData.upgradeGoods?.upgradeGoodsServiceItemsList),
specificationData: filterSpecsStr(formData.upgradeGoods),
djCost: formData.upgradeGoods?.djCost,
carTypeConfigName: formData.upgradeGoods?.carTypeConfigList?.map(item => item.seriesName).join("/"),
commodityCode: formData.upgradeGoods?.commodityCode,
purchasePrice: formData.upgradeGoods?.purchasePrice,
upgradePrice: formData.upgradeGoods?.upgradePrice,
type: formData.upgradeGoods?.type,
thirdPartyCode: formData.upgradeGoods?.thirdPartyCode,
};
}
// 价格计算精度丢失处理
export function subStrPrice(num1, num2) {
let r1, r2;
try {
r1 = num1.toString().split(".")[1].length;
} catch (e) {
r1 = 0;
}
try {
r2 = num2.toString().split(".")[1].length;
} catch (e) {
r2 = 0;
}
const m = 10 ** Math.max(r1, r2);
const n = r1 >= r2 ? r1 : r2;
return ((num1 * m + num2 * m) / m).toFixed(n);
}
<template>
<div class="division-rule">
<p class="edit-sub-title">
实际分账设置 (用于定义费用的实际分账归属)
</p>
<el-form ref="divisionRuleRef"
class="formSty"
label-suffix=":"
label-width="180px"
:model="form"
:rules="rules">
<el-form-item label="" label-width="54px">
<table cellpadding="0"
cellspacing="0"
class="table-block">
<tr class="tableHeader">
<td>分账对象/分账类目</td>
<!-- <td>平台方分账金额</td> -->
<td v-for="(item, index) in radioList" :key="index">
{{ item.applicationObjectName || item.expenseCategoryName }}
</td>
</tr>
<tr>
<td class="merchantNameTd p-b-20">
<p v-for="(item, index) in tableSelectOptions"
:key="index"
:title="item | filterMerchantType">
{{ item | filterMerchantType }}
</p>
</td>
<td v-for="(item, index) in radioList"
:key="`${index}radioList`"
class="p-b-20">
<el-form-item label-width="0"
:prop="`id${item.expenseCategoryId}`">
<el-radio-group v-model="form[`id${item.expenseCategoryId}`]"
@change="
(e) => handleClearValid(e, `id${item.expenseCategoryId}`)
">
<el-radio v-for="(el, index2) in tableSelectOptions"
:key="index2"
:label="el.merchantId" />
</el-radio-group>
</el-form-item>
</td>
</tr>
</table>
</el-form-item>
</el-form>
</div>
</template>
<script>
// import { userType } from '@/common/constants'
export default {
name: "TableAccount",
filters: {
// 过滤商户类型
filterMerchantType(val) {
const name = {
1: "平台方",
2: "服务商",
3: "流量方",
4: "平台方",
};
const type = val.targetMerchantType;
return `${name[type]}: ${val.merchantName}`;
},
},
props: {
// 列选项
tableCategoryOptions: {
type: Object,
default: () => { },
},
merchantDistributionRules: {
type: Array,
default: () => {
return [];
},
},
owningMerchantDistributionRules: {
type: Array,
default: () => {
return [];
},
},
// 分账对象选项 1:平台方 2:服务商 3:流量方 4:子商户
tableSelectCategoryOptions: {
type: Array,
default: () => [],
},
},
data() {
return {
// 多商户存导流方id
copyMerchantInfo: {},
form: {
// settleTimeType: 1
},
rules: {},
};
},
computed: {
radioList() {
const obj = this.classificationObjSelect;
let list = [];
let arr = [];
const arrIdx = [1, 2, 302, 701, 4];
for (const key in obj) {
obj[key].map((item) => {
if (
arrIdx.includes(item.id)
|| arrIdx.includes(item.expenseCategoryId)
) {
list.push(item);
}
});
}
arr = list.filter((item) => {
return (
arrIdx.includes(item.id) || arrIdx.includes(item.expenseCategoryId)
);
});
// console.log('list', arr)
return arr;
},
},
watch: {
// merchantDistributionRules: {
// handler() {
// this.initList();
// },
// deep: true,
// // immediate: true
// },
},
mounted() { },
methods: {
initList() {
const obj = this.classificationObjSelect;
const tableSelectOptionsId = this.tableSelectOptions.some(item => item.merchantId == 1);
const form = {};
// 判断是不是多商户的,是改一下结构绑定
for (const key in obj) {
obj[key].map((item) => {
// 数字转字符串
const name = "id" + item.expenseCategoryId;
// 做回显用数据
const findObj = this.merchantDistributionRules.find((el) => {
return el.expenseCategoryId == item.expenseCategoryId;
});
// 还要跟存在现在的选项里面
form[name] = findObj?.merchantId || "";
});
}
// 判断id是否有在选项里面 没有就去掉
Object.assign(this.form, form);
},
changFormList() {
// console.log(this.form,'this.form')
// 判断id是否有在选项里面 没有就去掉
for (const key in this.form) {
const element = this.form[key];
const index = this.tableSelectOptions.findIndex((opt) => {
return opt.merchantId == element;
});
if (index === -1) {
this.form[key] = "";
}
}
this.$forceUpdate();
},
handleClearValid(e, validField) {
this.$forceUpdate();
// this.handleConfirm()
// console.log('validField', validField)
this.$refs.divisionRuleRef.clearValidate(validField);
},
async handleConfirm() {
const valid = await this.$refs.divisionRuleRef.validate();
if (valid) {
// this.form
return this.getTableAccountParams();
}
},
getTableAccountParams() {
const merchantDistributionRules = this.radioList.reduce((prev, next) => {
const id = this.form["id" + next.expenseCategoryId];
// console.log(id)
const merchantObj = this.tableSelectOptions.find(
// (item) => item.merchantId == id
// (item) => (item.merchantId == id) || item.targetMerchantLevel == id
item => (item.merchantId == id) || (item.targetMerchantType == 3 && item.targetMerchantLevel == id),
);
if (merchantObj?.merchantId == 1) {
merchantObj.merchantId = this.copyMerchantInfo.merchantId;
merchantObj.merchantName = this.copyMerchantInfo.merchantName;
}
next = {
...next,
expenseCategoryId: next.expenseCategoryId,
...merchantObj,
};
// console.log(next, 'next')
// const name = 'id' + next.id
// prev[name] = this.form[name]
prev.push(next);
return prev;
}, []);
return merchantDistributionRules;
},
},
};
</script>
<style scoped lang="scss">
// .formSty {
// overflow-x: scroll;
// }
// .division-rule table {
// width: 98%;
// color: #666666;
// border: 1px solid #e5e6e7;
// border-width: 1px 0 0 1px;
// }
// .division-rule table tr {
// height: 50px;
// line-height: 50px;
// }
// .division-rule table th,
// .division-rule table td {
// font-size: 12px;
// font-weight: normal;
// padding: 0px 10px;
// border: 1px solid #e5e6e7;
// border-width: 0px 1px 1px 0px;
// border-spacing: 0;
// text-align: center;
// min-width: 100px;
// white-space: nowrap;
// /* white-space: nowrap; */
// /* overflow: hidden; */
// /* text-overflow: ellipsis; */
// }
// .division-rule table .merchantNameTd {
// min-width: 150px;
// }
// .division-rule .flex {
// display: flex;
// justify-content: space-around;
// }
// .table-block td {
// font-size: 14px !important;
// }
// .division-rule .table-block .el-radio {
// display: block;
// height: 60px;
// line-height: 42px;
// margin-right: 0;
// }
// .p-b-20 {
// padding-bottom: 26px !important;
// }
// .division-rule ::v-deep {
// .table-block .el-radio__label {
// display: none !important;
// }
// }
</style>
<!-- 2 - 分账金额设置 -->
<template>
<div class="attribution-setting-wrapper">
<el-form-item :label="title" style="flex:1;">
<table cellpadding="0"
cellspacing="0"
class="table-block">
<tr class="table-header">
<th>分账对象/分账类目</th>
<!-- <td>平台方分账金额</td> -->
<th v-for="(item, index) in tableCols"
:key="index">
{{ item.feeCategoryName || item.expenseCategoryName }}
</th>
</tr>
<tr v-for="(item, rowIndex) in tableRows"
:key="item.targetMerchantType"
class="table-body">
<td class="merchant-name-wrapper">
<span :title="getMerchantTypeName(item)">
{{ getMerchantTypeName(item) }}
</span>
</td>
<template v-for="(colItem, colIndex) in tableCols">
<td :key="`${colIndex}colList`" class="radio-wrapper">
<el-form-item label-width="0">
<el-radio :value="value[colItem.expenseCategoryId]"
:label="item.targetMerchantType"
:disabled="disabled"
@input="val => handleRadioChange(colItem.expenseCategoryId, val)">
{{ "" }}
</el-radio>
</el-form-item>
</td>
</template>
</tr>
</table>
</el-form-item>
</div>
</template>
<script>
import { cloneDeep, uniqBy } from "lodash-es";
// targetMerchantType 决定行数
// expenseCategoryId 决定列数
import { mapGetters, mapState } from "vuex";
// import { userType } from '@/common/constants'
import { getTableFilterIds, isBatchPublishMode, isSingleShopMode } from "../../utils/feeCategoryHelper.js";
export default {
name: "TableAccount",
props: {
title: {
type: String,
default: "",
},
tableCols: {
type: Array,
default: () => ([]),
},
// 分账对象选项 1:平台方 2:服务商 3:流量方 4:子商户
tableRows: {
type: Array,
default: () => ([]),
},
value: {
type: Object,
default: () => ({}),
},
disabled: {
type: Boolean,
default: false,
},
},
data() {
return {
copyMerchantInfo: {}, // 多商户存导流方id
rules: {},
// 导流方下拉选项对应
attrToVal: [
{
confId: 3,
confLabel: "city",
},
{
// confId: 4,
confId: 2,
confLabel: "province",
},
{
// confId: 5,
confId: 1,
confLabel: "factory",
},
],
realityShopMerchant: {
merchantId: "",
merchantName: "",
userType: "",
},
};
},
computed: {
...mapState("ShelfManage/ProfitSharingConfigStore", ["shelfType", "sceneType"]),
...mapGetters("ShelfManage/ProfitSharingConfigStore", {
_expenseCategoryRules: "expenseCategoryRules",
goodsTypeGroupRules: "goodsTypeGroupRules",
}),
},
mounted() {
},
methods: {
handleRadioChange(expenseCategoryId, val) {
const newValue = { ...this.value, [expenseCategoryId]: val };
this.$emit("input", newValue);
},
getMerchantTypeName(item) {
const name = {
1: "平台方",
2: "服务商",
3: "流量方",
4: "平台方",
};
// TODO: 如果是 项目制批量上架 不显示name
if (isBatchPublishMode(this.shelfType)) {
return item.merchantName;
}
const type = item.targetMerchantType;
return `${name[type]}: ${item.merchantName}`;
},
},
};
</script>
<style scoped lang="scss">
.attribution-setting-wrapper {
display: flex;
> .label {
width: 150px;
text-align: right;
flex-shrink: 0;
vertical-align: middle;
font-size: 14px;
color: #606266;
line-height: 32px;
padding: 0 12px 0 0;
box-sizing: border-box;
}
.form-wrapper {
overflow-x: scroll;
flex-shrink: 0;
flex: 1;
}
::v-deep .table-block {
width: 100%;
table-layout: fixed;
border-collapse: collapse;
th,
td {
border: 1px solid #e5e5e5;
}
.table-header {
padding: 14px 0;
th {
width: auto;
line-height: 20px;
color: #333333;
font-size: 14px;
&:first-child {
width: 150px;
}
}
}
.table-body {
td {
padding: 18px 0;
}
.merchant-name-wrapper {
line-height: 20px;
color: #666666;
font-size: 14px;
text-align: center;
}
.radio-wrapper {
.el-form-item {
margin-bottom: 0 !important;
.el-form-item__content {
justify-content: center;
align-items: center;
}
}
}
}
// th,
// td {
// font-size: 12px;
// font-weight: normal;
// padding: 0px 10px;
// border: 1px solid #e5e6e7;
// border-width: 0px 1px 1px 0px;
// border-spacing: 0;
// text-align: center;
// min-width: 100px;
// white-space: nowrap;
// &.merchant-name-wrapper {
// min-width: 150px;
// }
// }
// td {
// font-size: 14px !important;
// }
}
}
.pb-20 {
padding-bottom: 26px !important;
}
</style>
<template>
<div class="detail-wrapper ">
<Descriptions :form-items="formItems" />
</div>
</template>
<script>
import Descriptions from "@/views/goods/shelfManage/components/descriptions/index.vue";
import { ShopMerchantFormData } from "../modify/data.js";
export default {
name: "Detail",
components: {
Descriptions,
},
props: {
trafficSourceData: {
type: Object,
default: () => ({}),
},
baseData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
};
},
computed: {
formItems() {
return ShopMerchantFormData.map(item => ({
name: item.name,
label: item.label,
valueWidth: "314px",
labelWidth: "250px",
itemStyle: {
"margin-right": "30px",
},
}));
},
},
mounted() {
},
methods: {
getDisplayValue(item) {
// const value = this.editData[item.name];
// if (item.type === "select" && item.optionsName && this.baseData[item.optionsName]) {
// const option = this.baseData[item.optionsName].find(opt => opt[item.optionId] === value);
// return option ? option[item.optionLabel] : value;
// }
// return value || "";
},
},
};
</script>
<style scoped lang="scss">
.detail-wrapper {
padding-top: 20px;
}
</style>
import { limitPrice } from "@/common/format";
import store from "@/store";
export const ShopMerchantInfoFormRules = {
merchantId: [
{ required: true, message: "请选择流量方信息" },
],
parentMerchantName: [
{ required: true, message: "请选择集团(上级商户)" },
],
businessMode: [
{ required: true, message: "请选择业务模式" },
],
contractingMerchantId: [
{ required: true, message: "请选择签约主体" },
],
sceneType: [
{ required: true, message: "请选择业务场景" },
],
yqMerchantId: [
{ required: true, message: "请选择园区店" },
],
estimatedFlow: [
{ required: true, message: "请输入预估流量" },
],
estimatedUpgradeRate: [
{ required: true, message: "请输入预估转化率" },
],
operationMode: [
{ required: true, message: "请选择运营模式" },
],
partnerMerchantId: [
{ required: true, message: "请选择服务商" },
],
parentPartnerMerchantId: [
{ required: true, message: "请输入上级服务商" },
],
firstLineSunshineOnlinePointsFlag: [
{ required: true, message: "请选择一线阳光是否开启线上积分" },
],
firstLineSunshine2OnlinePointsFlag: [
{ required: true, message: "请选择一线阳光2是否开启线上积分" },
],
};
// TODO: 修改this
export const ShopMerchantFormData = [
{
label: "流量方信息",
name: "merchantId",
addHtml: "merchantId",
style: { width: "calc( 50% - 30px )" },
placeholder: "请选择流量方信息",
optionList: [],
optionId: "merchantId",
optionLabel: "merchantName",
optionsName: "merchantList",
searchKey: "merchantNameKeyword",
},
{
label: "集团(上级商户)",
name: "parentMerchantName",
type: "input",
style: { width: "calc( 50% - 30px )" },
placeholder: "选择流量方后自动获取",
isDisabled: true,
},
{
label: "业务模式",
name: "businessMode",
type: "select",
style: { width: "calc( 50% - 30px )" },
optionList: [],
optionId: "confId",
optionLabel: "confName",
optionsName: "businessModeList",
},
{
label: "签约主体",
name: "contractingMerchantId",
type: "select",
style: { width: "calc( 50% - 30px )" },
optionList: [],
optionId: "merchantId",
optionLabel: "merchantName",
optionsName: "contractMerList",
},
{
label: "业务场景",
name: "sceneType",
type: "select",
style: { width: "calc( 50% - 30px )" },
isDisabled: true,
optionList: [],
optionId: "confId",
optionLabel: "confValue",
optionsName: "sceneCodeList",
},
{
label: "园区店",
name: "yqMerchantId",
type: "select",
style: { width: "calc( 50% - 30px )" },
optionList: [],
optionId: "merchantId",
optionLabel: "merchantName",
optionsName: "yqMerchantList",
},
{
label: "预估流量/月",
name: "estimatedFlow",
type: "input",
style: { width: "calc( 50% - 30px )" },
maxlength: 6,
},
{
label: "预估转化率",
name: "estimatedUpgradeRate",
type: "input",
style: { width: "calc( 50% - 30px )" },
maxlength: 6,
append: "%",
},
{
label: "运营模式",
name: "operationMode",
type: "select",
style: { width: "calc( 50% - 30px )" },
optionList: [],
optionId: "confId",
optionLabel: "confName",
optionsName: "operationModeList",
},
{
label: "服务商",
name: "partnerMerchantId",
type: "select",
style: { width: "calc( 50% - 30px )" },
isDisabled: false,
optionList: [],
optionId: "merchantId",
optionLabel: "merchantName",
optionsName: "partnerMerchantList",
},
{
label: "上级服务商",
name: "parentPartnerMerchantName",
type: "input",
style: { width: "calc( 50% - 30px )" },
maxlength: 50,
},
{
label: "一线阳光是否开启线上积分",
name: "firstLineSunshineOnlinePointsFlag",
type: "select",
style: { width: "calc( 50% - 30px )" },
optionList: [],
optionId: "confId",
optionLabel: "confName",
optionsName: "onlinePointsEnabledList",
},
{
label: "一线阳光2是否开启线上积分",
name: "firstLineSunshine2OnlinePointsFlag",
type: "select",
style: { width: "calc( 50% - 30px )" },
optionList: [],
optionId: "confId",
optionLabel: "confName",
optionsName: "onlinePointsEnabledList",
},
];
<!-- 编辑 - 流量方信息 -->
<template>
<div class="modify-wrapper">
<glsx-combi-form ref="editFormRef"
class="edit-form-container"
default-width="314px"
:form-data="editFormData"
:form-obj="editData"
:form-ref="editChildRef"
:form-rules="formRules"
label-width="250px">
<template #merchantId="scope">
<div>
<el-select v-model="editData[scope.scope.name]"
disabled
:placeholder="scope.scope.placeholder"
style="width: 314px">
<el-option v-for="subItem in scope.scope.optionList"
:key="subItem[scope.scope.optionId]"
:label="subItem[scope.scope.optionLabel]"
:value="subItem[scope.scope.optionId]">
</el-option>
</el-select>
</div>
</template>
</glsx-combi-form>
</div>
</template>
<script>
import { getMerchantLevelApi, serviceGetMerchantList } from "@api/merchant";
import { mapGetters, mapMutations } from "vuex";
import { sceneCodeList } from "@/common/constants.js";
import { deepClone } from "@/common/util";
import { businessModeList, onlinePointsEnabledList, operationModeList } from "../../../../constant/baseData";
import { ShopMerchantFormData, ShopMerchantInfoFormRules } from "./data.js";
export default {
name: "ShopMerchantInfo",
props: {
editDataObj: {
type: Object,
default: () => ({}),
},
serviceList: {
type: Array,
default: () => ([]),
},
yqMerchantList: {
type: Array,
default: () => ([]),
},
platformLevelList: {
type: Array,
default: () => ([]),
},
},
data() {
// 这里存放数据
return {
editData: {},
editChildRef: "editChildRef",
storeCurrentPage: 1, // 流量方 - 4s店数据分页
pageSize: 50,
merchantNameKeyword: "", // 流量方下拉框搜索
selected4SOptionObj: {}, // 已选的4S店
formRules: ShopMerchantInfoFormRules,
editFormData: ShopMerchantFormData,
baseData: {
merchantList: [],
merchantLevelList: [],
businessModeList,
contractMerList: [],
sceneCodeList,
yqMerchantList: [],
operationModeList,
onlinePointsEnabledList,
partnerMerchantList: [],
},
};
},
computed: {},
mounted() {
this.getOptionsList();
},
methods: {
...mapMutations("goodsInfoData", ["SET_DATA"]),
getOptionsList() {
},
async submit() {
// 直接利用验证回调构造的 promise,返回布尔值
return this.$refs.editFormRef.$refs[this.editChildRef].validate();
},
},
};
</script>
<style lang="scss" scoped>
.modify-wrapper {
padding-top: 20px;
}
.shop-merchant-info {
.add-mer-btn {
margin-left: 12px;
}
}
</style>
<template>
<div v-if="isInitialized" class="">
<Detail v-if="mode === VIEW_MODE.VIEW"
v-bind="$attrs"
:goods-list="options.productType"
:scene-type="sceneType"
v-on="$listeners" />
<Modify v-if="mode === VIEW_MODE.EDIT"
ref="modifyRef"
:goods-list="options.productType"
:scene-type="sceneType" />
</div>
</template>
<script>
import { mapActions, mapState } from "vuex";
import { getProfitSharingConfigOtherGoodsItemApi } from "@/api/shelfManage.js";
import {
queryFeeCategoryByType as getFeeCategoryByTypeApi,
getGoodsCategoryConfiguration as getGoodsCategoryConfigurationApi,
} from "@/api/sys.base.js";
import { VIEW_MODE } from "@/views/goods/shelfManage/constant/baseData.js";
import Detail from "./specialCategoryDetail/index.vue";
import Modify from "./specialCategoryModify/index.vue";
export default {
components: {
Detail,
Modify,
},
inheritAttrs: false,
props: {
mode: {
type: String,
require: true,
},
},
data() {
return {
VIEW_MODE,
localGoodsTypeGroupRules: {},
options: {
category: {},
productType: [],
selectedGoodsType: [],
},
isInitialized: false,
};
},
computed: {
...mapState("ShelfManage/ProfitSharingConfigStore", {
sceneType: state => state.sceneType,
goodsTypeGroupRules: state => state.profitSharingForm.goodsTypeGroupRules,
businessCode: "businessCode",
specialCategory: "specialCategory",
}),
},
watch: {
},
async mounted() {
await this.init();
},
methods: {
...mapActions("ShelfManage/ProfitSharingConfigStore", ["getFeeCategoryByType"]),
async init() {
try {
// 商品分类
await this.getProductTypeOptions();
} finally {
this.isInitialized = true;
}
},
async validate() {
const modifyRef = this.$refs.modifyRef;
if (!modifyRef) {
// 尚未初始化
return;
}
return await modifyRef.validate();
},
async getProductTypeOptions() {
const { list } = await getGoodsCategoryConfigurationApi({});
if (!this.options.selectedGoodsType.length) {
const goodsTypeGroupRuleId = String(this.specialCategory.active).startsWith("nano-") ? undefined : this.specialCategory.active;
const selectedGoods = await getProfitSharingConfigOtherGoodsItemApi({
goodsTypeGroupRuleId,
categoryType: 1,
businessCode: this.businessCode,
});
this.options.selectedGoodsType = selectedGoods.map(item => item.goodsType);
}
if (list && list.length) {
this.options.productType = list.map(({ categoryType, categoryName }) => {
return {
goodsType: categoryType,
goodsTypeName: categoryName,
disabled: this.options.selectedGoodsType.includes(categoryType),
};
});
}
},
},
};
</script>
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!