From 67d3b57765b0ba66ae25a9da84a16e44a4ef2937 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期三, 25 三月 2026 09:13:59 +0800
Subject: [PATCH] 调整
---
src/views/dataAnalysis/components/CustTypeModal.vue | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 154 insertions(+), 26 deletions(-)
diff --git a/src/views/dataAnalysis/components/CustTypeModal.vue b/src/views/dataAnalysis/components/CustTypeModal.vue
index 6f675b4..169830c 100644
--- a/src/views/dataAnalysis/components/CustTypeModal.vue
+++ b/src/views/dataAnalysis/components/CustTypeModal.vue
@@ -17,6 +17,9 @@
v-model="clientConfigsList.clientName"
></a-input>
</a-form-item>
+ <div v-if="!clientConfigsList.clientConfigs || clientConfigsList.clientConfigs.length === 0" style="text-align: center">
+ <a-button type="primary" @click="addConditions"> 娣诲姞瑙勫垯 </a-button>
+ </div>
<div v-for="(subItem, subIndex) in clientConfigsList.clientConfigs" :key="subIndex">
<div style="display: flex">
<div>鏉′欢{{ subIndex + 1 }}锛�</div>
@@ -44,34 +47,100 @@
<a-select-option value="1,YEARS"> 杩�1骞� </a-select-option>
</a-select>
</a-form-item>
- <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="鍔犳补棰戞">
+ <!-- 瑙勫垯绫诲瀷閫夋嫨锛氬姞娌归娆� OR 鍔犳补瓒嬪娍 -->
+ <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="瑙勫垯绫诲瀷">
<a-select
- :disabled="subItem.timeStr == '7,DAYS' || subItem.timeStr == '30,DAYS'"
style="width: 300px"
- v-model="subItem.countType"
+ v-model="subItem.ruleType"
placeholder="璇烽�夋嫨"
+ @change="ruleTypeChange($event, subIndex)"
>
- <a-select-option :value="1"> 绱 </a-select-option>
- <a-select-option :value="2"> 姣忔湀 </a-select-option>
+ <a-select-option :value="1"> 鍔犳补棰戞 </a-select-option>
+ <a-select-option :value="2"> 鍔犳补瓒嬪娍 </a-select-option>
</a-select>
- <div style="display: flex">
- <a-select style="width: 150px" v-model="subItem.countRef" placeholder="璇烽�夋嫨">
- <a-select-option :value="1"> 澶т簬 </a-select-option>
- <a-select-option :value="0"> 绛変簬 </a-select-option>
- <a-select-option :value="-1"> 灏忎簬 </a-select-option>
+ </a-form-item>
+ <!-- 鍔犳补棰戞閰嶇疆锛坮uleType=1鏃舵樉绀猴級 -->
+ <div v-show="subItem.ruleType == 1">
+ <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="鍔犳补棰戞">
+ <a-select
+ :disabled="subItem.timeStr == '7,DAYS' || subItem.timeStr == '30,DAYS'"
+ style="width: 300px"
+ v-model="subItem.countType"
+ placeholder="璇烽�夋嫨"
+ >
+ <a-select-option :value="1"> 绱 </a-select-option>
+ <a-select-option :value="2"> 姣忔湀 </a-select-option>
</a-select>
+ <div style="display: flex">
+ <a-select style="width: 150px" v-model="subItem.countRef" placeholder="璇烽�夋嫨">
+ <a-select-option :value="1"> 澶т簬 </a-select-option>
+ <a-select-option :value="0"> 绛変簬 </a-select-option>
+ <a-select-option :value="-1"> 灏忎簬 </a-select-option>
+ </a-select>
+ <a-input
+ style="width: 150px"
+ placeholder="璇疯緭鍏ユ鏁�"
+ onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
+ onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}"
+ v-model="subItem.countNum"
+ ></a-input>
+ </div>
+ </a-form-item>
+ </div>
+ <!-- 鍔犳补瓒嬪娍閰嶇疆锛坮uleType=2鏃舵樉绀猴級 -->
+ <div v-show="subItem.ruleType == 2">
+ <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="鍔犳补瓒嬪娍">
+ <a-select
+ style="width: 300px"
+ v-model="subItem.countTrend"
+ placeholder="璇烽�夋嫨"
+ >
+ <a-select-option :value="1"> 绋冲畾 </a-select-option>
+ <a-select-option :value="2"> 鍑忓皯 </a-select-option>
+ </a-select>
+ <div v-if="subItem.countTrend == 1" style="color: #999; font-size: 12px; margin-top: 5px;">
+ 绋冲畾锛氬巻鍙叉湀鍔犳补娆℃暟鈮ユ鏁� 涓� 杩戞湡鏈堝姞娌规鏁扳墺娆℃暟
+ </div>
+ <div v-if="subItem.countTrend == 2" style="color: #999; font-size: 12px; margin-top: 5px;">
+ 鍑忓皯锛氬巻鍙叉湀鍔犳补娆℃暟鈮ユ鏁� 浣� 杩戞湡鏈堝姞娌规鏁�<娆℃暟
+ </div>
+ </a-form-item>
+ <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="鍘嗗彶鏈堟暟">
+ <a-select
+ style="width: 140px"
+ v-model="subItem.historyMonths"
+ placeholder="鍘嗗彶鏈堟暟"
+ >
+ <a-select-option :value="3"> 3涓湀 </a-select-option>
+ <a-select-option :value="6"> 6涓湀 </a-select-option>
+ <a-select-option :value="9"> 9涓湀 </a-select-option>
+ <a-select-option :value="12"> 12涓湀 </a-select-option>
+ </a-select>
+ </a-form-item>
+ <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="杩戞湡鏈堟暟">
+ <a-select
+ style="width: 140px"
+ v-model="subItem.recentMonths"
+ placeholder="杩戞湡鏈堟暟"
+ >
+ <a-select-option :value="1"> 1涓湀 </a-select-option>
+ <a-select-option :value="2"> 2涓湀 </a-select-option>
+ <a-select-option :value="3"> 3涓湀 </a-select-option>
+ </a-select>
+ </a-form-item>
+ <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="鍥哄畾鍔犳补娆℃暟">
<a-input
style="width: 150px"
- placeholder="璇疯緭鍏ユ鏁�"
+ placeholder="姣忔湀鍥哄畾娆℃暟"
onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}"
v-model="subItem.countNum"
></a-input>
- </div>
- </a-form-item>
- </div>
- <div style="text-align: center">
- <a-button type="primary" @click="addConditions"> 澧炲姞鏉′欢 </a-button>
+ </a-form-item>
+ </div>
+ <div style="text-align: center" v-if="subIndex === clientConfigsList.clientConfigs.length - 1">
+ <a-button type="primary" @click="addConditions"> 澧炲姞鏉′欢 </a-button>
+ </div>
</div>
</div>
</a-spin>
@@ -119,6 +188,21 @@
methods: {
moment,
+ buildCondition(condition = {}) {
+ return Object.assign(
+ {
+ ruleType: 1,
+ timeStr: '3,MONTHS',
+ countType: 2,
+ countRef: 1,
+ countNum: 3,
+ countTrend: null,
+ historyMonths: null,
+ recentMonths: null,
+ },
+ condition
+ )
+ },
//鍒犻櫎鏉′欢
delConditions(index) {
console.log(index)
@@ -129,10 +213,46 @@
this.clientConfigsList.clientConfigs[index].countType = 1
}
},
+ trendChange(e, index) {
+ // 閫夋嫨瓒嬪娍鏃讹紝璁剧疆榛樿鍊�
+ if (e > 0) {
+ this.clientConfigsList.clientConfigs[index].historyMonths = 3
+ this.clientConfigsList.clientConfigs[index].recentMonths = 3
+ } else {
+ // 娓呴櫎瓒嬪娍閰嶇疆
+ this.clientConfigsList.clientConfigs[index].historyMonths = null
+ this.clientConfigsList.clientConfigs[index].recentMonths = null
+ }
+ },
+ ruleTypeChange(e, index) {
+ let target = this.clientConfigsList.clientConfigs[index]
+ // 鍒囨崲瑙勫垯绫诲瀷鏃讹紝娓呯┖瀵瑰簲鐨勯厤缃�
+ if (e == 1) {
+ // 鍔犳补棰戞锛氭竻闄よ秼鍔块厤缃�
+ Object.assign(target, {
+ ruleType: 1,
+ countTrend: null,
+ historyMonths: null,
+ recentMonths: null,
+ countType: target.countType || 2,
+ countRef: target.countRef || 1,
+ })
+ } else if (e == 2) {
+ // 鍔犳补瓒嬪娍锛氭竻闄ら娆¢厤缃紝璁剧疆榛樿鍊�
+ Object.assign(target, {
+ ruleType: 2,
+ countType: 2,
+ countRef: 1,
+ countTrend: target.countTrend || 1,
+ historyMonths: target.historyMonths || 3,
+ recentMonths: target.recentMonths || 3,
+ })
+ }
+ },
//鏂板鏉′欢
addConditions(index) {
console.log(index)
- this.clientConfigsList.clientConfigs.push({})
+ this.clientConfigsList.clientConfigs.push(this.buildCondition())
},
disabledDate(current) {
// Can not select days before today and today
@@ -151,7 +271,7 @@
add() {
this.edit({
clientName: '',
- clientConfigs: [{}],
+ clientConfigs: [this.buildCondition()],
})
},
edit(record) {
@@ -163,7 +283,11 @@
// }
this.visible = true
this.model = Object.assign({}, record)
- this.clientConfigsList = record
+ this.clientConfigsList = Object.assign({}, record, {
+ clientConfigs: (record.clientConfigs || []).length
+ ? record.clientConfigs.map((item) => this.buildCondition(item))
+ : [],
+ })
},
close() {
this.$emit('close')
@@ -183,16 +307,20 @@
if (JSON.stringify(el) == '{}') {
isEmpty = true
}
- for (let k in el) {
- if (el[k] == '' || el[k].length == '0') {
+ // 鏍规嵁瑙勫垯绫诲瀷鏍¢獙
+ if (el.ruleType == 1) {
+ // 鍔犳补棰戞锛氭鏌ユ椂闂磋寖鍥淬�佹鏁扮被鍨嬨�佸叧绯汇�佹鏁�
+ if (!el.timeStr || !el.countRef || !el.countType || !el.countNum) {
isEmpty = true
}
- }
- if (!el.timeStr || !el.countRef || !el.countType || !el.countNum) {
- isEmpty = true
- if (el.countRef == 0 || el.countNum == 0) {
- isEmpty = false
+ } else if (el.ruleType == 2) {
+ // 鍔犳补瓒嬪娍锛氭鏌ユ椂闂磋寖鍥淬�佽秼鍔裤�佸巻鍙叉湀鏁般�佽繎鏈熸湀鏁般�佹鏁�
+ if (!el.timeStr || !el.countTrend || !el.historyMonths || !el.recentMonths || !el.countNum) {
+ isEmpty = true
}
+ } else {
+ // 鏈�夋嫨瑙勫垯绫诲瀷
+ isEmpty = true
}
})
if (isEmpty) {
--
Gitblit v1.8.0