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 3532 additions and 1114 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 @@
],
"cSpell.words": [
"vuex",
"Cascader"
"Cascader",
"glsx"
],
"workbench.tree.indent": 24,
"eslint.enable": true,
......@@ -17,25 +18,19 @@
"vetur.validation.style": true,
"vetur.ignoreProjectWarning": false,
"vetur.experimental.templateInterpolationService": false,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true,
"editor.autoIndent": "full",
"editor.codeActionsOnSave": {
// "source.organizeImports": "explicit",
"source.fixAll.eslint": "explicit"
},
"[vue]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true,
"editor.autoIndent": "full",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
},
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
},
"[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({
"dist",
// unplugin-auto-import 生成的类型文件,每次提交都改变,所以加入这里吧,与 .gitignore 配合使用
"auto-import.d.ts",
"build/",
"tests/",
"node_modules/",
// # node 覆盖率文件
"coverage/",
"**/*-min.js",
"**/*.min.js",
],
stylistic: {
"indent": "tab", // 4个空格
......@@ -20,6 +29,12 @@ export default antfu({
"array-bracket-spacing": ["error", "always"],
},
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",
"no-useless-return": "off",
"vue/no-deprecated-delete-set": "off",
......@@ -31,6 +46,8 @@ export default antfu({
"vue/no-deprecated-v-bind-sync": "off",
"vue/no-lone-template": "off",
"vue/no-mutating-props": "off",
"vue/no-deprecated-filter": "off",
"vue/no-v-for-template-key-on-child": "off",
// 强制:Vue 多行 HTML 元素的内容前后必须换行
"vue/multiline-html-element-content-newline": [
"error",
......@@ -88,7 +105,7 @@ export default antfu({
"EVENTS", // @click @focus
"CONTENT", // v-text v-html
],
alphabetical: true, // 是否在同组内再按字母排序(建议 false,官方默认顺序更好)
alphabetical: false, // 是否在同组内再按字母排序(建议 false,官方默认顺序更好)
}],
// 强制:Vue SFC 中块的顺序(template -> script -> style)
"vue/block-order": [
......
......@@ -6,7 +6,7 @@ module.exports = {
'vue'
],
transform: {
'^.+\\.vue$': 'vue-jest',
'^.+\\.vue$': '@vue/vue2-jest',
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.jsx?$': 'babel-jest'
},
......
......@@ -11,7 +11,8 @@
"baseUrl": ".",
"module": "ESNext",
/* Bundler mode */
"moduleResolution": "bundler",
// 按 Node 规则解析模块
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
......@@ -38,4 +39,7 @@
"dist",
".git"
]
// 对齐 Webpack 的 extensions 优先级
// "extensions": [".vue", ".js", ".ts", ".json"]
}
......@@ -32,6 +32,7 @@
"default-passive-events": "^2.0.0",
"echarts": "^5.3.2",
"element-ui": "2.13.2",
"emoji-regex": "^10.6.0",
"file-saver": "^2.0.5",
"flex.css": "^1.1.7",
"fuse.js": "^3.4.4",
......@@ -44,8 +45,10 @@
"js-cookie": "^2.2.0",
"js-md5": "^0.7.3",
"jspdf": "^2.5.1",
"lodash": "^4.17.23",
"lodash-es": "^4.17.22",
"lowdb": "^1.0.0",
"nanoid": "^5.1.6",
"nprogress": "^0.2.0",
"number-precision": "^1.6.0",
"print-js": "^1.6.0",
......@@ -73,6 +76,7 @@
"@antfu/eslint-config": "^6.7.3",
"@babel/core": "^7.12.16",
"@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-unit-jest": "~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 @@
*/
import axios from "axios";
// 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 实例
*/
......@@ -65,12 +63,12 @@ function mockRequest(params = {}, httpMethod = "post") {
// 根据HTTP方法处理参数
if (httpMethod.toLowerCase() === "post" || httpMethod.toLowerCase() === "put") {
config.data = data;
config.data = params;
} else {
// GET请求,将参数作为query string
config.params = {
"ropRequestContext.key": data["ropRequestContext.key"] || "",
...data,
...params,
};
}
......@@ -131,7 +129,7 @@ mockAxios.interceptors.request.use(
mockAxios.interceptors.response.use(
(response) => {
console.log("Mock Response:", response.data);
return response.data;
return response.data.data;
},
(error) => {
console.error("Mock Error:", error);
......
......@@ -6,32 +6,33 @@
* @FilePath: \dj-car-life-system\src\api\shelfManage.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import request from "./request"
import RequestMethods from "./request.methods"
const path = "dj.api.create.business.approve."
import request from "./request";
import RequestMethods from "./request.methods";
const path = "dj.api.create.business.approve.";
// 获取企微审批模版
export function getWorkwechatTemplate(data) {
data.method = `${path}workwechat.template`
return request(data, RequestMethods.POST)
data.method = `${path}workwechat.template`;
return request(data, RequestMethods.POST);
}
// 分页查询嘀加上架列表
export function getPage(data) {
data.method = `${path}page`
return request(data, RequestMethods.POST)
data.method = `${path}page`;
return request(data, RequestMethods.POST);
}
// 驳回嘀加上架
export function reject(data) {
data.method = `${path}reject`
return request(data, RequestMethods.POST)
data.method = `${path}reject`;
return request(data, RequestMethods.POST);
}
// 嘀加上架查看详情(分账、对账配置)
export function merchantSettleDistributeRuleLastRule(data) {
data.method = `dj.api.create.business.approve.detail.rule`
return request(data)
data.method = `dj.api.create.business.approve.detail.rule`;
return request(data);
}
// 保存财务分账规则
......@@ -47,93 +48,211 @@ export function getDjzhySubMerchant(data) {
}
// 获取不同场景的商品分类
export function getGoodsCategoryConfiguration(data) {
data.currentPage = 1
data.pageSize = 999999
// data.method = `${path}goodsCategoryConfiguration.page`
data.method = `${path}goodsCategoryConfiguration.page.new`
return request(data)
data.currentPage = 1;
data.pageSize = 999999;
// data.method = `${path}goodsCategoryConfiguration.page`
data.method = `${path}goodsCategoryConfiguration.page.new`;
return request(data);
}
// 财务 - 2 - 获取导流方
export function getMerchantLevelApi(data) {
data.method = `dj.api.smartcarlife.get.merchantLevel`
return request(data, "post")
data.method = `dj.api.smartcarlife.get.merchantLevel`;
return request(data, "post");
}
// 嘀加上架 - 基本信息
export function getBusisDetailBasic(data) {
data.method = `dj.api.create.business.approve.detail.basic`
return request(data)
data.method = `dj.api.create.business.approve.detail.basic`;
return request(data);
}
// 新增商户 - 车品牌
export function brandList(data) {
data.method = `merchants.api.merchantCommon.getCarbrandTree`
return request(data, RequestMethods.POST)
data.method = `merchants.api.merchantCommon.getCarbrandTree`;
return request(data, RequestMethods.POST);
}
// 新增商户 - 商户类型
export function getMerchantType(data) {
data.method = `merchants.api.menu.findAllDictData`
return request(data, RequestMethods.POST)
data.method = `merchants.api.menu.findAllDictData`;
return request(data, RequestMethods.POST);
}
// 嘀加上架查看详情(上架商品及测算)
export function getGoodsDetail(data) {
data.method = `${path}detail.goods`
return request(data, RequestMethods.POST)
data.method = `${path}detail.goods`;
return request(data, RequestMethods.POST);
}
// 嘀加上架提交
export function saveApprove(data) {
data.method = `${path}save`
return request(data, RequestMethods.POST, ["file"])
data.method = `${path}save`;
return request(data, RequestMethods.POST, ["file"]);
}
// 新增商户 - 保存商户
export function saveMerchant(data) {
data.method = `merchants.api.merchant.saveMerchant.permissions`
return request(data, RequestMethods.POST)
data.method = `merchants.api.merchant.saveMerchant.permissions`;
return request(data, RequestMethods.POST);
}
// 新增商户 - 下级商户
export function findMerchantListByPage(data) {
data.method = `merchants.api.open.findMerchantListByPage`
return request(data, RequestMethods.POST)
data.method = `merchants.api.open.findMerchantListByPage`;
return request(data, RequestMethods.POST);
}
// 嘀加上架 - 保存
export function operationConfirm(data) {
data.method = `dj.api.create.business.approve.operationConfirm`
return request(data, RequestMethods.POST)
data.method = `dj.api.create.business.approve.operationConfirm`;
return request(data, RequestMethods.POST);
}
// 嘀加上架 - 保存
export function operationConfirmJson(data) {
data.method = `dj.api.create.business.approve.operationConfirm.json`
return request(data, RequestMethods.POST)
data.method = `dj.api.create.business.approve.operationConfirm.json`;
return request(data, RequestMethods.POST);
}
// 嘀加上架 - 保存异步
export function operationConfirmJsonAsync(data) {
data.method = `dj.api.create.business.approve.operationConfirm.json.async`
return request(data, RequestMethods.POST)
data.method = `dj.api.create.business.approve.operationConfirm.json.async`;
return request(data, RequestMethods.POST);
}
// 嘀加上架 - 保存异步
export function approveAsyncProcess(data) {
data.method = `dj.api.create.business.approve.asyncProcess`
return request(data, RequestMethods.POST)
data.method = `dj.api.create.business.approve.asyncProcess`;
return request(data, RequestMethods.POST);
}
// 嘀加上架 - 测算
export function computeProductProfitDetail(data) {
data.method = `dj.api.smartcarlife.createBusiness.approve.computeProductProfitDetail.json`
return request(data, RequestMethods.POST)
data.method = `dj.api.smartcarlife.createBusiness.approve.computeProductProfitDetail.json`;
return request(data, RequestMethods.POST);
}
// 附件上传接口
export function uploadFileWithFileName(data) {
data.method = `dj.api.common.uploadFile.with.file.name`
return request(data, RequestMethods.POST, ["file"])
data.method = `dj.api.common.uploadFile.with.file.name`;
return request(data, RequestMethods.POST, ["file"]);
}
// 查询门店
export function getMerchantPage(data) {
data.method = `dj.api.merchant.page`
return request(data, RequestMethods.POST)
data.method = `dj.api.merchant.page`;
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 = {
positionTypeList: "positionTypeList", // 太阳膜商品部位
extendedPosiTypeList: "extendedPosiTypeList", // 延保类商品部位
};
/** 计价单位选项 1-把、2-本、3-对、4-个、5-根、6-盒、7-件、8-卷、9-块、10-辆、11-米、12-克、13-升、14-双、15-台、16-套、17-条、18-桶、19-位、20-页、21-张 */
export const priceUnitTypeList = [
{ value: 1, label: "把" },
......@@ -522,10 +521,10 @@ export const warrantyProList = [1, 4, 6, 12, 14];
// 所属场景
export const sceneCodeList = [
{ confId: 0, confValue: "会员权益/升级" },
{ confId: 1, confValue: "精品升级" },
{ confId: 2, confValue: "次新车转化" },
{ confId: 3, confValue: "售后众筹" },
{ confId: 0, confValue: "会员权益/升级" },
{ confId: 4, 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 = {
label: "嘀加上架与销售合同",
category: "Button",
type: "primary",
handle: "handleAdd",
handle: "handleEdit",
addRoutePath: [
{
authId: "9031302",
......@@ -535,7 +535,7 @@ export const routerName = {
authId: "9031309",
parentId: "90313",
label: "重新发起",
handle: "handleAgain",
handle: "handleEdit",
addRoutePath: [
{
authId: "9031302",
......@@ -557,7 +557,7 @@ export const routerName = {
sideHidden: true,
activePath: "/shelfManage",
},
component: _import("goods/shelfManage/editShelf"),
component: _import("goods/shelfManage/view/modifyTable"),
},
9031305: {
path: "/contractDetail",
......@@ -569,7 +569,7 @@ export const routerName = {
sideHidden: true,
activePath: "/shelfManage",
},
component: _import("goods/shelfManage/contractDetail"),
component: _import("goods/shelfManage/view/contractDetail"),
},
9031307: {
path: "/editContract",
......@@ -581,7 +581,7 @@ export const routerName = {
sideHidden: true,
activePath: "/shelfManage",
},
component: _import("goods/shelfManage/editContract"),
component: _import("goods/shelfManage/view/editMultilateralContract"),
},
9031310: {
path: "/editMultilateralContract",
......@@ -593,7 +593,7 @@ export const routerName = {
sideHidden: true,
activePath: "/shelfManage",
},
component: _import("goods/shelfManage/editMultilateralContract"),
component: _import("goods/shelfManage/view/editMultilateralContract"),
},
90314: {
path: "/purchaseOnShelves",
......
import Vue from "vue";
import Vuex from "vuex";
import ShelfManage from "@/views/goods/shelfManage/store/index.js";
import performanceFormStore from "@/views/residentManage/salaryPerformance/performanceScheme/store/performanceFormStore.js";
import cacheStore from "./modules/cacheStore";
import d2admin, { storeResets } from "./modules/d2admin";
import FinancialRules from "./modules/FinancialRules";
import goodsInfoData from "./modules/goodsInfoData";
......@@ -23,8 +26,10 @@ if (!isProd) {
export default new Vuex.Store({
modules: {
d2admin,
cacheStore,
goodsInfoData,
FinancialRules,
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 @@
:placeholder="item.label"
:style="{ width: item.width || formItemWidth }"
@blur="blur(item)"
@input="input($event, item)">
@input="input($event, item)"
>
</el-input>
<template v-if="item.name == 'minSellPrice'">
<el-checkbox v-model="formData.validMinSellPriceFlag"
......@@ -340,8 +341,8 @@
:prop="item.name"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<template>
<el-upload accept=".jpg,.png,.pdf"
action=""
<el-upload
accept=".jpg,.png,.pdf"action=""
:auto-upload="false"
class="upload-file"
drag
......@@ -463,6 +464,7 @@
<el-input v-model.trim="storeSearchForm.yqMerchantName"
clearable
placeholder="服务对接"
clearable
@keydown.native="handleStoreInput" />
</el-form-item>
<el-form-item label="服务对接商户号:">
......
<!-- 上架编辑 -->
<template>
<d2-container v-loading="!show" class="edit-commodity">
<div v-if="show" class="">
......@@ -25,7 +24,6 @@ import { baseConfig } from "@/main";
import { convertYuanToWan, filterSpecsStr } from "../filterOption";
import groundingForm from "./components/groundingForm.vue";
import { baseSupplyModeList, productList, upgradeSupplyModeList } from "./constants/data";
export default {
name: "EditGrounding",
components: {
......@@ -39,13 +37,14 @@ export default {
proFormRef: "pro",
editForm: [{
title: "商品信息",
formBlock: [{
name: "upgradeGoodsId",
label: "上架商品",
isRequired: true,
type: "searchSelect",
optionList: [],
isClear: false,
formBlock: [
{
name: "upgradeGoodsId",
label: "上架商品",
isRequired: true,
type: "searchSelect",
optionList: [],
isClear: false,
optionId: "confId",
optionNameLabel: "confNameValue",
optionTypeNameLabel: "confTypeNameValue",
......@@ -95,20 +94,21 @@ export default {
name: "goodsAlias",
label: "商品别名",
type: "input",
maxlength: 50,
width: "432px",
}, {
name: "warrantyType",
label: "质保卡类型",
type: "select",
isClear: false,
optionList: [{
confId: 0,
confName: "质保卡",
}, {
confId: 1,
confName: "质保权益卡",
}],
maxlength: 50,
width: "432px",
},
{
name: "warrantyType",
label: "质保卡类型",
type: "select",
isClear: false,
optionList: [{
confId: 0,
confName: "质保卡",
}, {
confId: 1,
confName: "质保权益卡",
}],
optionId: "confId",
optionLabel: "confName",
width: "432px",
......@@ -121,90 +121,99 @@ export default {
name: "baseSupplyMode",
label: "基础产品供货模式",
type: "radio",
index: 1,
radioGroupList: [],
}, {
name: "upgradeSupplyMode",
label: "升级/产品供货模式",
type: "radio",
index: 2,
radioGroupList: [],
}, {
name: "sellPrice",
label: "售价",
type: "input",
width: "432px",
unit: true,
handleInput: true,
}, {
name: "minSellPrice",
label: "最低售价",
type: "input",
width: "432px",
unit: true,
handleInput: true,
}, {
name: "upgradeProductCost",
label: "产品、升级成本",
type: "input",
width: "432px",
unit: true,
handleInput: true,
}, {
name: "giftCost",
label: "赠送成本",
type: "input",
width: "432px",
unit: true,
handleInput: true,
}, {
name: "recoveryCost",
label: "回收成本",
type: "input",
width: "432px",
unit: true,
handleInput: true,
}, {
name: "virtualAccountCost",
label: "虚拟对账成本",
type: "input",
width: "432px",
unit: true,
handleInput: true,
}, {
name: "djCost",
label: "嘀加成本",
type: "input",
width: "432px",
unit: true,
isDisabled: false,
handleInput: true,
}, {
name: "thirdPartyCost",
label: "第三方成本",
type: "input",
width: "432px",
unit: true,
index: 1,
radioGroupList: [],
},
{
name: "upgradeSupplyMode",
label: "升级/产品供货模式",
type: "radio",
index: 2,
radioGroupList: [],
},
{
name: "sellPrice",
label: "售价",
type: "input",
width: "432px",
unit: true,
handleInput: true,
},
{
name: "minSellPrice",
label: "最低售价",
type: "input",
width: "432px",
unit: true,
handleInput: true,
},
{
name: "upgradeProductCost",
label: "产品、升级成本",
type: "input",
width: "432px",
unit: true,
handleInput: true,
},
{
name: "giftCost",
label: "赠送成本",
type: "input",
width: "432px",
unit: true,
handleInput: true,
},
{
name: "recoveryCost",
label: "回收成本",
type: "input",
width: "432px",
unit: true,
handleInput: true,
},
{
name: "virtualAccountCost",
label: "虚拟对账成本",
type: "input",
width: "432px",
unit: true,
handleInput: true,
},
{
name: "djCost",
label: "嘀加成本",
type: "input",
width: "432px",
unit: true,
isDisabled: false,
handleInput: true,
},
{
name: "thirdPartyCost",
label: "第三方成本",
type: "input",
width: "432px",
unit: true,
handleInput: true,
}, {
name: "sellPriceValidType",
label: "售价有效期",
type: "flagRadio",
radioGroupList: [{
radioGroupList: [{
label: "终生有效",
value: 1,
}, {
label: "临时有效",
value: 2,
}],
}, {
}, {
name: "tempValidDate",
label: "有效期",
type: "datePicker",
maxlength: 120,
width: "432px",
}, {
name: "financeCheckFlag",
}, {
name: "financeCheckFlag",
label: "财务规则校验",
type: "flagRadio",
radioGroupList: [{
......@@ -356,7 +365,7 @@ export default {
specificationData: this.filterSpecsStr(res?.upgradeGoods),
carTypeConfigName: res?.upgradeGoods?.carTypeConfigList?.map(item => item.seriesName).join("/"),
upgradeCommodityCode: res?.upgradeGoods?.commodityCode,
sellPriceValidType: res?.sellPriceValidType ? res?.sellPriceValidType + "" : "1",
sellPriceValidType: res?.sellPriceValidType ? res?.sellPriceValidType + "" : "1",
tempValidDate,
};
this.editData = res || {};
......@@ -395,7 +404,7 @@ export default {
arr.push({
merchantId: val.merchantId,
merchantName: val.merchantName,
inventoryType: val.inventoryType,
inventoryType: val.inventoryType,
});
});
const fileArr = [];
......@@ -418,12 +427,12 @@ export default {
voucherList: fileArr,
existCheck,
validMinSellPrice: data?.validMinSellPrice,
tempValidStartDate: data?.tempValidStartDate || "",
tempValidStartDate: data?.tempValidStartDate || "",
tempValidEndDate: data?.tempValidEndDate || "",
};
if (params.tempValidDate) {
delete params.tempValidDate;
}
};
if (data?.goodsType == 1 && data?.sceneType != 1)
return this.$message.warning("太阳膜类商品仅支持上架至精品升级场景");
if (this.extendedPosiType.includes(data.goodsType) && data?.sceneType != 0)
......
......@@ -55,8 +55,8 @@
width="120">
<template #default="scope">
<el-select v-model="scope.row.inventoryType" size="small">
<el-option label="实物管控" :value="2"></el-option>
<el-option label="虚拟管控" :value="1"></el-option>
<el-option label="实物" :value="2"></el-option>
<el-option label="虚拟" :value="1"></el-option>
</el-select>
</template>
</el-table-column>
......@@ -150,9 +150,6 @@ export default {
},
methods: {
getIndex(index) {
if (!this.isHide) {
return index + 1;
}
// 当有合并单元格时,计算当前行在 spanArr 中是第几个非0项,从而得出正确的顺序序号
let count = 0;
for (let i = 0; i <= index; i++) {
......
......@@ -654,9 +654,10 @@ export default {
}
let _formData = [];
this.formData.groundingGoodsList.forEach((item) => {
_formData.push({
merchantGoodsId: item.id || item.upgradeGoods.id,
merchantGoodsId: item?.id || item?.upgradeGoods?.id,
upgradeGoodsName: item.upgradeGoods?.upgradeGoodsName,
inventoryType: item.inventoryType || 2,
});
......@@ -957,9 +958,9 @@ export default {
};
}
merchantGoodsMap[item.merchantId].inventoryTypeRefList.push({
merchantGoodsId: item.merchantGoodsId || item.upgradeGoods.id,
merchantId: item.merchantId,
merchantName: item.merchantName,
merchantGoodsId: item?.merchantGoodsId || item?.upgradeGoods?.id,
merchantId: item?.merchantId,
merchantName: item?.merchantName,
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>
<baseDialog :dialog-config="dialogConfig"
:is-show.sync="visible"
class="accountDailog"
@handleClick="handleAddConfirm">
<div class="reject-dialog">
<glsx-combi-form class="edit-form-container"
ref="formRef"
label-width="150px"
default-width="350px"
:form-ref="rejectRef"
:form-obj="infoForm"
:form-data="editFormData"
:form-rules="formRules"></glsx-combi-form>
</div>
</baseDialog>
<baseDialog class="accountDailog"
:dialog-config="dialogConfig"
:is-show.sync="visible"
@handleClick="handleAddConfirm">
<div class="reject-dialog">
<glsx-combi-form ref="formRef"
class="edit-form-container"
default-width="350px"
:form-data="editFormData"
:form-obj="infoForm"
:form-ref="rejectRef"
:form-rules="formRules"
label-width="150px">
</glsx-combi-form>
</div>
</baseDialog>
</template>
<script>
import {
reject
} from "@api/shelfManage.js"
reject,
} from "@api/shelfManage.js";
export default {
name: 'RejectDialog',
data() {
return {
userInfo: this.$store.state.d2admin.user.info,
infoForm: {
remark: ''
},
dialogConfig: {
title: '驳回',
width: '600px'
},
rejectRef: 'rejectRef',
formRules: {
remark: [{ required: true, message: '请输入驳回原因', trigger: 'blur' }]
},
editFormData: [{
label: '驳回原因',
name: 'remark',
type: 'input',
maxlength: 50,
inputType: 'textarea',
showLimit: true,
rows: 4
}],
baseData: {
name: "RejectDialog",
}
}
},
props: {
rejectVisible: {
type: Boolean,
default: false,
},
paramsObj: {
type: Object,
default: () => ({}),
},
},
data() {
return {
userInfo: this.$store.state.d2admin.user.info,
infoForm: {
remark: "",
},
dialogConfig: {
title: "驳回",
width: "600px",
},
rejectRef: "rejectRef",
formRules: {
remark: [{ required: true, message: "请输入驳回原因", trigger: "blur" }],
},
editFormData: [{
label: "驳回原因",
name: "remark",
type: "input",
maxlength: 50,
inputType: "textarea",
showLimit: true,
rows: 4,
}],
baseData: {
props: {
rejectVisible: {
type: Boolean,
default: false
},
paramsObj: {
type: Object,
default: {}
}
},
computed: {
visible: {
get() {
return this.rejectVisible
},
set(newVal) {
this.$emit('dialogClose', { flag: newVal, attrName: 'rejectVisible' })
}
}
},
},
};
},
computed: {
visible: {
get() {
return this.rejectVisible;
},
set(newVal) {
this.$emit("dialogClose", { flag: newVal, attrName: "rejectVisible" });
},
},
},
mounted() {
console.log('paramsObj', this.paramsObj)
},
mounted() {
console.log("paramsObj", this.paramsObj);
},
methods: {
methods: {
handleAddConfirm() {
this.$refs.formRef.$refs[this.rejectRef].validate(valid => {
if (valid) {
var params = {}
params.rejectedReason = this.infoForm.remark
params.id = this.paramsObj.id
handleAddConfirm() {
this.$refs.formRef.$refs[this.rejectRef].validate((valid) => {
if (valid) {
let params = {};
params.rejectedReason = this.infoForm.remark;
params.id = this.paramsObj.id;
reject(params).then(res => {
this.notice.okTips('操作成功')
this.visible = true
})
}
})
}
}
}
reject(params).then((res) => {
this.notice.okTips("操作成功");
this.visible = true;
});
}
});
},
},
};
</script>
<style lang="scss" scoped>
.reject-dialog {
margin: 65px 0;
margin: 65px 0;
.reject-input {
::v-deep .el-textarea__inner {
height: 70px;
}
}
.reject-input {
::v-deep .el-textarea__inner {
height: 70px;
}
}
.el-textarea .el-input__count {
right: 90px;
bottom: -10px;
font-size: 12px;
color: #999999;
}
.el-textarea .el-input__count {
right: 90px;
bottom: -10px;
font-size: 12px;
color: #999999;
}
.tips {
color: #999999;
}
.tips {
color: #999999;
}
}
</style>
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 {
const textArr = [];
this.editableTabs.push({
title:
item.groupType == 1
? "全部品类"
: "特殊品类" + (hasAllGoodsType ? index : index + 1),
title: item.groupType == 1 ? "全部品类" : "特殊品类" + (hasAllGoodsType ? index : index + 1),
name: (index + 1).toString(),
});
// 按具体商品
......
<!-- 编辑 - 上架商品及测算 -->
<template>
<div class="edit-page goods-info">
<div class="title">
<span>上架商品</span>
<div class="edit-page goods-info">
<div class="title">
<span>上架商品</span>
</div>
<div class="check-tab">
<el-tabs v-model="tabsValue"
class="my-tab-pane"
type="card">
<el-tab-pane v-for="(item, idx) in goodTabs"
:key="item.name"
:name="item.name">
<template #label>
<span>
<i v-if="item.valiadError == 'Y'"
class="el-icon-warning car-error-txt" />{{ item.title ? item.title + (idx + 1) : item.goodsName }}
</span>
</template>
<span>
<GoodTab :info="item.info"
:tab-idx="item.tabIndex" />
</span>
</el-tab-pane>
<el-tab-pane v-for="(item, idx) in packageTabs"
:key="item.name"
:label="item.title"
:name="item.name">
<template #label>
<span>
<i v-if="item.valiadError == 'Y'"
class="el-icon-warning car-error-txt" />{{ item.title ? item.title + (idx + 1) : item.goodsName }}
</span>
</template>
<span>
<PackageTab :info="item.info"
:tab-idx="item.tabIndex"
@packageEditInfo="getPackageEditInfo_notice" />
</span>
</el-tab-pane>
</el-tabs>
</div>
</div>
<div class="check-tab">
<el-tabs v-model="tabsValue"
type="card"
class="my-tab-pane">
<el-tab-pane v-for="(item, idx) in goodTabs"
:key="item.name"
:name="item.name">
<span slot="label"><i class="el-icon-warning car-error-txt"
v-if="item.valiadError == 'Y'" />{{ item.title ? item.title + (idx + 1) : item.goodsName }}
</span>
<span>
<good-tab :info="item.info"
:tab-idx="item.tabIndex" />
</span>
</el-tab-pane>
<el-tab-pane v-for="(item, idx) in packageTabs"
:key="item.name"
:label="item.title"
:name="item.name">
<span slot="label"><i class="el-icon-warning car-error-txt"
v-if="item.valiadError == 'Y'" />{{ item.title ? item.title + (idx + 1) : item.goodsName }}
</span>
<span>
<package-tab :info="item.info"
:tab-idx="item.tabIndex"
@packageEditInfo="getPackageEditInfo_notice" />
</span>
</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
<script>
import { getGoodsDetail } from "@api/shelfManage.js"
import goodTab from "./common/goodTab.vue"
import packageTab from "./common/packageTab.vue"
import { deepClone } from "@/common/util"
import { getGoodsDetail } from "@api/shelfManage.js";
import { deepClone } from "@/common/util";
import goodTab from "./common/goodTab.vue";
import packageTab from "./common/packageTab.vue";
export default {
name: "GoodsInfo",
props: {
recordId: {
type: Number,
default: null
}
},
components: {
goodTab,
packageTab
},
data() {
// 这里存放数据
return {
tabsValue: "1",
currentIndex: 1,
addIndex: 1,
tabIndex: 1,
goodTabs: [],
packageTabs: [],
goodInfoList: [],
packageInfoList: [],
goodsInfo: {}
}
},
computed: {
routeInfo() {
return this.$route.params
}
},
mounted() {
this.getDetail()
},
methods: {
getDetail() {
console.log("getGoodsDetail")
// this.recordId
getGoodsDetail({ id: this.routeInfo.id })
.then((res) => {
console.log(res, "getGoodsDetail")
this.goodsInfo = res
const goodsList = deepClone(res.goodsList)
const packageGoodsList = deepClone(res.packageGoodsList)
goodsList.forEach((item, idx) => {
const length = this.goodTabs.length
const tabIndex =
length == 0 ? length : this.goodTabs[length - 1].tabIndex + 1
this.goodTabs.push({
goodsName: item.upgradeGoodsName,
name: "good_" + tabIndex,
tabIndex: tabIndex,
// goodId: item.id,
info: item
})
this.tabsValue = "good_" + tabIndex
})
packageGoodsList.forEach((item, idx) => {
const length = this.packageTabs.length
const tabIndex =
length == 0 ? length : this.packageTabs[length - 1].tabIndex + 1
this.packageTabs.push({
goodsName: item.packageName,
name: "package_" + tabIndex,
tabIndex: tabIndex,
// goodId: item.id,
info: item
})
this.tabsValue = "package_" + tabIndex
})
this.packageNotice()
})
.catch((err) => {
console.log(err)
})
},
/* 活动标签切换时触发 */
beforeLeave(currentName, oldName) {
// console.log("currentName", currentName)
// 通过tab标签的切换事件触发增加的函数
// 如果name是add,则调用增加tab的函数
this.currentIndex = currentName
},
// 填写套餐名称时通知
getPackageEditInfo_notice(obj) {
console.log("obj", obj)
this.packageTabs.find((item) => item.tabIndex == obj.idx).info = obj.info
this.packageNotice()
},
name: "GoodsInfo",
components: {
GoodTab: goodTab,
PackageTab: packageTab,
},
props: {
recordId: {
type: Number,
default: null,
},
},
data() {
// 这里存放数据
return {
tabsValue: "1",
currentIndex: 1,
addIndex: 1,
tabIndex: 1,
goodTabs: [],
packageTabs: [],
goodInfoList: [],
packageInfoList: [],
goodsInfo: {},
};
},
computed: {
routeInfo() {
return this.$route.params;
},
},
mounted() {
this.getDetail();
},
methods: {
getDetail() {
console.log("getGoodsDetail");
// this.recordId
getGoodsDetail({ id: this.routeInfo.id })
.then((res) => {
console.log(res, "getGoodsDetail");
this.goodsInfo = res;
const goodsList = deepClone(res.goodsList);
const packageGoodsList = deepClone(res.packageGoodsList);
goodsList.forEach((item, idx) => {
const length = this.goodTabs.length;
const tabIndex
= length == 0 ? length : this.goodTabs[length - 1].tabIndex + 1;
this.goodTabs.push({
goodsName: item.upgradeGoodsName,
name: "good_" + tabIndex,
tabIndex,
// goodId: item.id,
info: item,
});
this.tabsValue = "good_" + tabIndex;
});
packageGoodsList.forEach((item, idx) => {
const length = this.packageTabs.length;
const tabIndex
= length == 0 ? length : this.packageTabs[length - 1].tabIndex + 1;
this.packageTabs.push({
goodsName: item.packageName,
name: "package_" + tabIndex,
tabIndex,
// goodId: item.id,
info: item,
});
this.tabsValue = "package_" + tabIndex;
});
this.packageNotice();
})
.catch((err) => {
console.log(err);
});
},
/* 活动标签切换时触发 */
beforeLeave(currentName, oldName) {
// console.log("currentName", currentName)
// 通过tab标签的切换事件触发增加的函数
// 如果name是add,则调用增加tab的函数
this.currentIndex = currentName;
},
// 填写套餐名称时通知
getPackageEditInfo_notice(obj) {
console.log("obj", obj);
this.packageTabs.find(item => item.tabIndex == obj.idx).info = obj.info;
this.packageNotice();
},
// 初始化、填写套餐名称时、删除套餐时通知
packageNotice() {
this.packageInfoList = []
this.packageTabs.forEach((item) => {
if (item.info) {
console.log(item)
const o = {
name: item.info.val1 || item.info.packageName,
virtualCode: item.info.timeId,
id: item.info.id,
packageCode: item.info.packageCode
}
this.packageInfoList.push(o)
}
})
}
}
}
// 初始化、填写套餐名称时、删除套餐时通知
packageNotice() {
this.packageInfoList = [];
this.packageTabs.forEach((item) => {
if (item.info) {
console.log(item);
const o = {
name: item.info.val1 || item.info.packageName,
virtualCode: item.info.timeId,
id: item.info.id,
packageCode: item.info.packageCode,
};
this.packageInfoList.push(o);
}
});
},
},
};
</script>
<style lang="scss" scoped>
@import "../../style/editdetailCon.scss";
.addBtnSpan {
float: right;
float: right;
}
</style>
......@@ -8,84 +8,90 @@
-->
<template>
<div class="edit-page">
<div class="title">
<span>操作记录</span>
</div>
<div style="padding: 20px" v-if="list && list.length > 0">
<div class="wrap" v-for="(item, index) in list" :key="index">
<div class="type">
{{ item.operatorTypeText }}
<div class="edit-page">
<div class="title">
<span>操作记录</span>
</div>
<div v-if="list && list.length > 0" style="padding: 20px">
<div v-for="(item, index) in list"
:key="index"
class="wrap">
<div class="type">
{{ item.operatorTypeText }}
</div>
<div class="operate">
{{ item.operatorTypeText }}人:{{ item.createdBy }}
</div>
<div>操作时间:{{ item.createdDate }}</div>
</div>
</div>
<div class="operate">
{{ item.operatorTypeText }}人:{{ item.createdBy }}
<div v-else class="empty">
暂无记录
</div>
<div>操作时间:{{ item.createdDate }}</div>
</div>
</div>
<div v-else class="empty">暂无记录</div>
</div>
</template>
<script>
import { deepClone ,Util} from "@/common/util"
export default {
name: "OperateList",
props: {
logList: {
type: Array,
default: () => []
}
},
watch: {
logList(val) {
import { deepClone, Util } from "@/common/util";
this.list = val
for (var item in this.types) {
this.list.forEach((ele) => {
if (ele.operatorType == item) {
ele.operatorTypeText = this.types[item]
}
})
}
// console.log(this.list, "✈")
this.list = deepClone(this.list)
}
},
data() {
//这里存放数据
return {
list: [],
types: { 1: "创建", 2: "驳回", 3: "确认", 4: "完成" }
}
},
methods: {}
}
export default {
name: "OperateList",
props: {
logList: {
type: Array,
default: () => [],
},
},
data() {
// 这里存放数据
return {
list: [],
types: { 1: "创建", 2: "驳回", 3: "确认", 4: "完成" },
};
},
watch: {
logList(val) {
this.list = val;
for (let item in this.types) {
this.list.forEach((ele) => {
if (ele.operatorType == item) {
ele.operatorTypeText = this.types[item];
}
});
}
// console.log(this.list, "✈")
this.list = deepClone(this.list);
},
},
methods: {},
};
</script>
<style lang="scss" scoped>
@import "../../style/editdetailCon.scss";
.wrap {
display: flex;
align-items: center;
color: #333333;
font-size: 14px;
margin-bottom: 20px;
.type {
font-weight: bold;
margin-right: 60px;
}
.operate {
min-width: 160px;
margin-right: 86px;
white-space: nowrap;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
}
display: flex;
align-items: center;
color: #333333;
font-size: 14px;
margin-bottom: 20px;
.type {
font-weight: bold;
margin-right: 60px;
}
.operate {
min-width: 160px;
margin-right: 86px;
white-space: nowrap;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
}
}
.empty {
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
</style>
\ No newline at end of file
</style>
<!-- 查看 - 流量方信息 -->
<template>
<div class="edit-page shop-merchant-info-detail">
<div style="padding: 20px 20px 0">
<el-form :model="merchantInfoDetail" label-width="250px">
<el-form-item v-for="(item, index) in editFormData" :key="index" class="form-item" :style="{ width: '48%' }">
<span slot="label" class="label">{{ item.label }}:</span>
<span>{{ merchantInfoDetail[item.name] || "-" }}{{ item.suffix }}</span>
</el-form-item>
</el-form>
<div class="edit-page shop-merchant-info-detail">
<div style="padding: 20px 20px 0">
<el-form label-width="250px" :model="merchantInfoDetail">
<el-form-item v-for="(item, index) in editFormData"
:key="index"
class="form-item"
:style="{ width: '48%' }">
<template #label>
<span class="label">{{ item.label }}:</span>
</template>
<span>{{ merchantInfoDetail[item.name] || "-" }}{{ item.suffix }}</span>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script>
import { deepClone } from "@/common/util"
import { sceneCodeList } from "@/common/constants.js"
import { sceneCodeList } from "@/common/constants.js";
import { deepClone } from "@/common/util";
import {
busiModeList,
operationModeList,
onlinePointsEnabledList
} from "../../constant/baseData"
businessModeList,
onlinePointsEnabledList,
operationModeList,
} from "../../constant/baseData";
export default {
name: "ShopMerchantInfo",
props: {
merchantInfo: {
type: Object,
default: () => { }
}
},
name: "ShopMerchantInfo",
props: {
merchantInfo: {
type: Object,
default: () => { },
},
},
data() {
// 这里存放数据
return {
editFormData: [
{
label: "流量方信息",
name: "merchantName",
},
{
label: "集团(上级商户)",
name: "parentMerchantName",
},
{
label: "业务模式",
name: "businessModeName",
attrName: "businessMode",
optionsName: "businessModeList",
},
{
label: "签约主体",
name: "contractingMerchantName",
},
{
label: "业务场景",
name: "sceneTypeName",
attrName: "sceneType",
optionLabel: "confValue",
optionsName: "sceneCodeList",
},
{
label: "园区店",
name: "yqMerchantName",
},
{
label: "预估流量/月",
name: "estimatedFlow",
},
{
label: "预估转化率",
name: "estimatedUpgradeRate",
suffix: "%",
},
{
label: "运营模式",
name: "operationModeName",
attrName: "operationMode",
optionsName: "operationModeList",
},
{
label: "服务商",
name: "partnerMerchantName",
},
{
label: "上级服务商",
name: "parentPartnerMerchantName",
},
{
label: "一线阳光是否开启线上积分",
name: "firstLineSunshineOnlinePointsFlag",
attrName: "firstLineSunshineOnlinePointsFlag",
optionsName: "onlinePointsEnabledList",
},
{
label: "一线阳光2是否开启线上积分",
name: "firstLineSunshine2OnlinePointsFlag",
attrName: "firstLineSunshine2OnlinePointsFlag",
optionsName: "onlinePointsEnabledList",
},
],
baseData: {
businessModeList,
sceneCodeList,
operationModeList,
onlinePointsEnabledList,
},
merchantInfoDetail: {},
};
},
watch: {
merchantInfo: {
handler(val, oldVal) {
if (val) {
this.dealInitData()
}
},
deep: true,
immediate: true
}
},
data() {
// 这里存放数据
return {
editFormData: [
{
label: "流量方信息",
name: "merchantName"
},
{
label: "集团(上级商户)",
name: "parentMerchantName"
},
{
label: "业务模式",
name: "businessModeName",
attrName: "businessMode",
optionsName: "busiModeList"
},
{
label: "签约主体",
name: "contractingMerchantName"
},
{
label: "业务场景",
name: "sceneTypeName",
attrName: "sceneType",
optionLabel: "confValue",
optionsName: "sceneCodeList"
},
{
label: "园区店",
name: "yqMerchantName"
},
{
label: "预估流量/月",
name: "estimatedFlow"
},
{
label: "预估转化率",
name: "estimatedUpgradeRate",
suffix: "%"
},
{
label: "运营模式",
name: "operationModeName",
attrName: "operationMode",
optionsName: "operationModeList"
},
{
label: "服务商",
name: "partnerMerchantName"
},
{
label: "上级服务商",
name: "parentPartnerMerchantName"
},
{
label: "一线阳光是否开启线上积分",
name: "firstLineSunshineOnlinePointsFlag",
attrName: "firstLineSunshineOnlinePointsFlag",
optionsName: "onlinePointsEnabledList"
},
{
label: "一线阳光2是否开启线上积分",
name: "firstLineSunshine2OnlinePointsFlag",
attrName: "firstLineSunshine2OnlinePointsFlag",
optionsName: "onlinePointsEnabledList"
}
],
baseData: {
busiModeList: busiModeList,
sceneCodeList: sceneCodeList,
operationModeList: operationModeList,
onlinePointsEnabledList
},
merchantInfoDetail: {}
}
},
methods: {
dealInitData() {
console.log(this.merchantInfo, "merchantInfo")
this.editFormData.forEach((item) => {
if (item.attrName) {
const obj =
this.baseData[item.optionsName].find(
(k) =>
k[item.optionId || "confId"] == this.merchantInfo[item.attrName]
) || {}
// console.log(this.merchantInfo[item.attrName], this.baseData[item.optionsName])
// console.log(obj, 'dealInitData')
this.merchantInfoDetail[item.name] = deepClone(obj[item.optionLabel || "confName"])
} else {
this.merchantInfoDetail[item.name] = deepClone(this.merchantInfo[item.name])
}
})
}
}
}
watch: {
merchantInfo: {
handler(val, oldVal) {
if (val) {
this.dealInitData();
}
},
deep: true,
immediate: true,
},
},
methods: {
dealInitData() {
console.log(this.merchantInfo, "merchantInfo");
this.editFormData.forEach((item) => {
if (item.attrName) {
const obj
= this.baseData[item.optionsName].find(
k =>
k[item.optionId || "confId"] == this.merchantInfo[item.attrName],
) || {};
// console.log(this.merchantInfo[item.attrName], this.baseData[item.optionsName])
// console.log(obj, 'dealInitData')
this.merchantInfoDetail[item.name] = deepClone(obj[item.optionLabel || "confName"]);
} else {
this.merchantInfoDetail[item.name] = deepClone(this.merchantInfo[item.name]);
}
});
},
},
};
</script>
<style lang="scss">
@import "../../style/editdetailCon.scss";
.shop-merchant-info-detail {
.el-form-item__label {
padding-right: 0;
}
.el-form-item__label {
padding-right: 0;
}
.el-form-item__label,
.el-form-item__content {
line-height: 20px !important;
}
.el-form-item__label,
.el-form-item__content {
line-height: 20px !important;
}
.form-item {
display: inline-block;
line-height: 20px;
margin-bottom: 20px;
}
.form-item {
display: inline-block;
line-height: 20px;
margin-bottom: 20px;
}
.download {
margin-left: 8px;
}
.download {
margin-left: 8px;
}
}
</style>
<template>
<div class="edit-page shop-merchant-info">
<div class="title">
<span>流量方信息</span>
</div>
<div class="content">
<el-tabs v-model="tabsValue" type="card" :before-leave="beforeLeave" class="my-tab-pane">
<el-tab-pane v-for="(item) in tabsList" :key="item.tabIndex" :name="item.tabIndex + ''">
<span slot="label"><i class="el-icon-warning car-error-txt" v-if="item.valiadError == 'Y'" />{{ item.title }}
</span>
<span>
<!-- <shop-merchant-info :merchantInfo="merchantInfo"></shop-merchant-info> -->
<shop-merchant-info :merchantInfo="merchantsList[item.tabIndex]" :ref="`shopMerchant${item.tabIndex}`"
:key="item.tabIndex" :edit-data-obj="merchantsList[item.tabIndex]"></shop-merchant-info>
</span>
</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
<script>
import ShopMerchantInfo from "./ShopMerchantInfo"
import { deepClone } from "@/common/util"
export default {
name: "EditMultilateralContract",
components: {
ShopMerchantInfo
},
props: {
merchantsList: {
type: Array,
default: () => { }
}
},
watch: {
merchantsList(val) {
this.tabsList = val.map((item, idx) => {
return {
title: item.merchantName,
tabIndex: idx
}
})
}
},
data() {
return {
tabsValue: 0,
tabsList: []
}
},
mounted() { },
methods: {
getAllParams() {
const list = deepClone(this.tabsList)
const merchants = []
// 需要使用for循环解决异步同步问题
for (var index = 0; index < list.length; index++) {
// const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0]
const res = node.getParams()
merchants.push(res)
}
return merchants
// })
},
submit() {
return new Promise(async (resolve, reject) => {
let flag = true
const list = deepClone(this.tabsList)
// 需要使用for循环解决异步同步问题
for (var index = 0; index < list.length; index++) {
// const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0]
const res = await node.submit()
flag = flag && res
}
this.$forceUpdate()
resolve(flag)
})
},
/* 活动标签切换时触发 */
beforeLeave(currentName, oldName) {
// console.log("currentName", currentName)
// 通过tab标签的切换事件触发增加的函数
this.currentIndex = currentName
}
}
}
</script>
<style scoped lang="scss">
@import "../../style/editdetailCon.scss";
.shop-merchant-info {
.add-mer-btn {
margin-left: 12px;
}
}
.content {
box-sizing: border-box;
margin: 20px 20px 0 20px;
}
</style>
\ No newline at end of file
<template>
<div class="edit-page shop-merchant-info">
<div class="title">
<span>流量方信息</span>
</div>
<div class="content">
<el-tabs v-model="tabsValue"
:before-leave="beforeLeave"
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>
</template>
<span>
<!-- <shop-merchant-info :merchantInfo="merchantInfo"></shop-merchant-info> -->
<ShopMerchantInfo :key="item.tabIndex"
:ref="`shopMerchant${item.tabIndex}`"
:edit-data-obj="merchantsList[item.tabIndex]"
:merchant-info="merchantsList[item.tabIndex]">
</ShopMerchantInfo>
</span>
</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
<script>
import { deepClone } from "@/common/util";
import ShopMerchantInfo from "./ShopMerchantInfo";
export default {
name: "EditMultilateralContract",
components: {
ShopMerchantInfo,
},
props: {
merchantsList: {
type: Array,
default: () => { },
},
},
data() {
return {
tabsValue: 0,
tabsList: [],
};
},
watch: {
merchantsList(val) {
this.tabsList = val.map((item, idx) => {
return {
title: item.merchantName,
tabIndex: idx,
};
});
},
},
mounted() { },
methods: {
getAllParams() {
const list = deepClone(this.tabsList);
const merchants = [];
// 需要使用for循环解决异步同步问题
for (let index = 0; index < list.length; index++) {
// const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0];
const res = node.getParams();
merchants.push(res);
}
return merchants;
// })
},
submit() {
return new Promise(async (resolve, reject) => {
let flag = true;
const list = deepClone(this.tabsList);
// 需要使用for循环解决异步同步问题
for (let index = 0; index < list.length; index++) {
// const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0];
const res = await node.submit();
flag = flag && res;
}
this.$forceUpdate();
resolve(flag);
});
},
/* 活动标签切换时触发 */
beforeLeave(currentName, oldName) {
// console.log("currentName", currentName)
// 通过tab标签的切换事件触发增加的函数
this.currentIndex = currentName;
},
},
};
</script>
<style scoped lang="scss">
@import "../../style/editdetailCon.scss";
.shop-merchant-info {
.add-mer-btn {
margin-left: 12px;
}
}
.content {
box-sizing: border-box;
margin: 20px 20px 0 20px;
}
</style>
<!-- 编辑 - 基础信息 -->
<template>
<div class="edit-page base-info">
<div class="title">
<span>基础信息</span>
<div 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 == 0">
-
</div>
<div v-else>
<div v-for="(k, kIdx) in item.fileList" :key="kIdx">
<span>{{ k.fileName }}</span>
<el-link class="download"
:href="k.url"
type="primary">
下载
</el-link>
</div>
</div>
</div>
<span v-else class="rich-text">{{ item.showValue || "-" }}</span>
</el-form-item>
</el-form>
</div>
</div>
<div style="padding: 20px 20px 0">
<el-form :model="basicInfo" label-width="150px">
<el-form-item v-for="(item, index) in editFormData" :key="index" class="form-item"
:style="{ width: [2, 7].includes(item.inputType) ? '100%' : '48%' }">
<span slot="label" class="label">{{ item.title }}:</span>
<div v-if="item.inputType == 7">
<div v-if="item.fileList.length == 0">-</div>
<div v-else>
<div v-for="(k, kIdx) in item.fileList" :key="kIdx">
<span>{{ k.fileName }}</span>
<el-link type="primary" class="download" :href="k.url">
下载
</el-link>
</div>
</div>
</div>
<span v-else class="rich-text">{{ item.showValue || "-" }}</span>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
export default {
name: "BaseInfo",
props: {
basicInfo: {
type: Object,
default: () => { }
}
},
name: "BaseInfo",
props: {
basicInfo: {
type: Object,
default: () => ({}),
},
},
data() {
// 这里存放数据
return {
};
},
computed: {
/**
* 动态表单
* inputType 输入类型,1.文本;2.多行文本;3.数字;4.金额;5.单选;6.多选;7.附件;
*/
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: {
basicInfo(val) {
if (val?.basicApproveInfo) {
this.dealFormData()
}
}
},
data() {
//这里存放数据
return {
/** 动态表单
* inputType 输入类型,1.文本;2.多行文本;3.数字;4.金额;5.单选;6.多选;7.附件;
*/
editFormData: []
}
},
},
mounted() { },
watch: {
methods: {
dealFormData() {
this.editFormData = JSON.parse(this.basicInfo.basicApproveInfo)
this.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]
})
}
})
}
})
}
}
}
},
mounted() { },
methods: {
dealFormData() {
console.log("this.basicInfo", this.basicInfo);
this.editFormData = JSON.parse(this.basicInfo.basicApproveInfo);
console.log("this.editFormData", this.editFormData);
this.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],
});
}
});
}
});
},
},
};
</script>
<style lang="scss">
@import "../../style/editdetailCon.scss";
.base-info {
.el-form-item__label {
padding-right: 0;
}
.el-form-item__label {
padding-right: 0;
}
.el-form-item__label,
.el-form-item__content {
line-height: 20px !important;
}
.el-form-item__label,
.el-form-item__content {
line-height: 20px !important;
}
.form-item {
display: inline-block;
line-height: 20px;
margin-bottom: 20px;
}
.form-item {
display: inline-block;
line-height: 20px;
margin-bottom: 20px;
}
.download {
margin-left: 8px;
}
.download {
margin-left: 8px;
}
.rich-text {
display: inline-block;
max-width: 90%;
overflow-wrap: break-word;
}
.rich-text {
display: inline-block;
max-width: 90%;
overflow-wrap: break-word;
}
}
</style>
This diff could not be displayed because it is too large.
<template>
<d2-dialog title="变更说明" :is-visible.sync="dialogShow" width="40%" @confirmDialog="dialogShow = false"
@closeDialog="dialogShow = false" :noCancel="true" class="relateStore">
<d2-table :hasPage="false" :tableData="tableData" :table-params="tableParams">
</d2-table>
</d2-dialog>
<d2-dialog class="relateStore"
:is-visible.sync="dialogShow"
: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-dialog>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'RuleUpdateDialog',
props: {
show: Boolean,
tableData: {
type: Array,
default: () => {
return []
}
}
},
data() {
return {
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: "list",
tableColumns: [
{
label: '变更内容',
prop: 'diffType',
width: 120
},
{
label: '变更后',
prop: 'diffAfter'
},
{
label: '变更前',
prop: 'diffBefore'
}
]
}
}
},
computed: {
dialogShow: {
get() {
return this.show
},
set(n) {
this.$emit('update:show', n)
}
}
},
mounted() {
},
methods: {
init() {
},
handleClick() {
}
}
}
name: "RuleUpdateDialog",
props: {
show: Boolean,
tableData: {
type: Array,
default: () => {
return [];
},
},
},
data() {
return {
tableParams: {
btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list",
tableColumns: [
{
label: "变更内容",
prop: "diffType",
width: 120,
},
{
label: "变更后",
prop: "diffAfter",
},
{
label: "变更前",
prop: "diffBefore",
},
],
},
};
},
computed: {
dialogShow: {
get() {
return this.show;
},
set(n) {
this.$emit("update:show", n);
},
},
},
mounted() {
},
methods: {
init() {
},
handleClick() {
},
},
};
</script>
<style scoped lang='scss'>
.dialog {
&-content {
padding: 5px 0;
&-content {
padding: 5px 0;
.month {
display: flex;
align-items: center;
margin-bottom: 32px;
.month {
display: flex;
align-items: center;
margin-bottom: 32px;
.label {
color: #333333;
font-size: 14px;
width: 150px;
display: flex;
align-items: center;
justify-content: flex-end;
.label {
color: #333333;
font-size: 14px;
width: 150px;
display: flex;
align-items: center;
justify-content: flex-end;
&::before {
content: "*";
color: #eb4e4e;
display: block;
margin-right: 6px;
}
}
}
}
&::before {
content: "*";
color: #eb4e4e;
display: block;
margin-right: 6px;
}
}
}
}
.input-box {
padding: 4px 10px;
display: flex;
align-items: center;
justify-content: center;
}
.input-box {
padding: 4px 10px;
display: flex;
align-items: center;
justify-content: center;
}
}
</style>
\ No newline at end of file
</style>
<template>
<div class="edit-page shop-merchant-info">
<div class="title">
<span>流量方信息</span>
</div>
<div class="content">
<el-tabs v-model="tabsValue" type="card" :before-leave="beforeLeave" class="my-tab-pane">
<el-tab-pane v-for="(item) in tabsList" :key="item.tabIndex" :name="item.tabIndex + ''">
<span slot="label"><i class="el-icon-warning car-error-txt" v-if="item.valiadError == 'Y'" />{{ item.title }}
</span>
<span>
<shop-merchant-info :yqMerchantList="yqMerchantList" :serviceList="serviceList"
:platformLevelList="platformLevelList" :ref="`shopMerchant${item.tabIndex}`" :key="item.tabIndex"
:edit-data-obj="merchantsList[item.tabIndex]"></shop-merchant-info>
</span>
</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
<script>
import ShopMerchantInfo from "./ShopMerchantInfo"
import { deepClone } from "@/common/util"
import {
// serviceGetMerchantList,
getyqMerchantList,
getServiceList,
// getMerchantLevelApi
} from "@api/merchant"
import { getPlatformMerchantList } from "@api/index"
export default {
name: "EditMultilateralContract",
components: {
ShopMerchantInfo
},
props: {
merchantsList: {
type: Array,
default: () => { }
}
},
watch: {
merchantsList(val) {
this.tabsList = val.map((item, idx) => {
return {
title: item.merchantName,
tabIndex: idx
}
})
}
},
data() {
return {
tabsValue: 0,
tabsList: [],
yqMerchantList: [],
serviceList: [],
platformLevelList: []
}
},
mounted() {
this.initList()
},
methods: {
initList() {
getyqMerchantList({ currentPage: 1, pageSize: 100000 }).then((res) => {
res?.list?.forEach((val) => {
val.merchantId = val.merchantNo - 0
})
this.yqMerchantList = res?.list || []
})
getServiceList({ currentPage: 1, pageSize: 100000 }).then((res) => {
res?.list?.forEach((val) => {
val.merchantId = val.merchantNo - 0
})
this.serviceList = res?.list || []
})
// initPlatformLevelList() {
getPlatformMerchantList({}).then((res) => {
res.unshift({
merchantId: -1,
merchantName: "嘀加智慧云"
})
this.platformLevelList = res
})
},
getAllParams() {
const list = deepClone(this.tabsList)
const merchants = []
// 需要使用for循环解决异步同步问题
for (var index = 0; index < list.length; index++) {
// const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0]
const res = node.getParams()
merchants.push(res)
}
return merchants
// })
},
submit() {
return new Promise(async (resolve, reject) => {
let flag = true
const list = deepClone(this.tabsList)
// 需要使用for循环解决异步同步问题
for (var index = 0; index < list.length; index++) {
// const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0]
const res = await node.submit()
flag = flag && res
}
this.$forceUpdate()
resolve(flag)
})
},
/* 活动标签切换时触发 */
beforeLeave(currentName, oldName) {
// console.log("currentName", currentName)
// 通过tab标签的切换事件触发增加的函数
this.currentIndex = currentName
}
}
}
</script>
<style scoped lang="scss">
@import "../../style/editdetailCon.scss";
.shop-merchant-info {
.add-mer-btn {
margin-left: 12px;
}
}
.content {
box-sizing: border-box;
margin: 20px 20px 0 20px;
}
</style>
\ No newline at end of file
<template>
<div class="edit-page shop-merchant-info">
<div class="title">
<span>流量方信息</span>
</div>
<div class="content">
<el-tabs v-model="tabsValue"
:before-leave="beforeLeave"
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>
</template>
<span>
<ShopMerchantInfo :key="item.tabIndex"
:ref="`shopMerchant${item.tabIndex}`"
:edit-data-obj="merchantsList[item.tabIndex]"
:platform-level-list="platformLevelList"
:service-list="serviceList"
:yq-merchant-list="yqMerchantList">
</ShopMerchantInfo>
</span>
</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
<script>
import { getPlatformMerchantList } from "@api/index";
import {
getServiceList,
// serviceGetMerchantList,
getyqMerchantList,
// getMerchantLevelApi
} from "@api/merchant";
import { deepClone } from "@/common/util";
import ShopMerchantInfo from "./ShopMerchantInfo.vue";
export default {
name: "EditMultilateralContract",
components: {
ShopMerchantInfo,
},
props: {
merchantsList: {
type: Array,
default: () => { },
},
},
data() {
return {
tabsValue: 0,
tabsList: [],
yqMerchantList: [],
serviceList: [],
platformLevelList: [],
};
},
watch: {
merchantsList(val) {
this.tabsList = val.map((item, idx) => {
return {
title: item.merchantName,
tabIndex: idx,
};
});
},
},
async mounted() {
await this.initList();
},
methods: {
async getYqMerchantList() {
const res = await getyqMerchantList({ currentPage: 1, pageSize: 100000 });
res?.list?.forEach((val) => {
val.merchantId = val.merchantNo - 0;
});
this.yqMerchantList = res?.list || [];
},
async getServiceListData() {
const res = await getServiceList({ currentPage: 1, pageSize: 100000 });
res?.list?.forEach((val) => {
val.merchantId = val.merchantNo - 0;
});
this.serviceList = res?.list || [];
},
async getPlatformMerchantListData() {
const res = await getPlatformMerchantList({});
res.unshift({
merchantId: -1,
merchantName: "嘀加智慧云",
});
this.platformLevelList = res;
},
async initList() {
await this.getYqMerchantList();
await this.getServiceListData();
await this.getPlatformMerchantListData();
},
getAllParams() {
const list = deepClone(this.tabsList);
const merchants = [];
// 需要使用for循环解决异步同步问题
for (let index = 0; index < list.length; index++) {
// const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0];
const res = node.getParams();
merchants.push(res);
}
return merchants;
// })
},
async submit() {
let flag = true;
const list = deepClone(this.tabsList);
// 需要使用for循环解决异步同步问题
for (let index = 0; index < list.length; index++) {
// const element = array[index];
const node = this.$refs[`shopMerchant${list[index].tabIndex}`][0];
const res = await node.submit();
flag = flag && res;
}
this.$forceUpdate();
return flag;
},
},
};
</script>
<style scoped lang="scss">
@import "../../style/editdetailCon.scss";
.shop-merchant-info {
.add-mer-btn {
margin-left: 12px;
}
}
.content {
box-sizing: border-box;
margin: 20px 20px 0 20px;
}
</style>
<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>
This diff could not be displayed because it is too large.
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!