diff --git a/packages/conv/creditScore/AppGridMemberScore/components/gridScoreManage.vue b/packages/conv/creditScore/AppGridMemberScore/components/gridScoreManage.vue index e8a88d81..c6fcab54 100644 --- a/packages/conv/creditScore/AppGridMemberScore/components/gridScoreManage.vue +++ b/packages/conv/creditScore/AppGridMemberScore/components/gridScoreManage.vue @@ -10,16 +10,16 @@ + @clear="current = 1, search.userName = '', getTableData()" suffix-icon="iconfont iconSearch" + v-throttle="() => {(current = 1), getTableData();}"/> 导出 - + {{ row.integral }} @@ -100,9 +100,9 @@ export default { size: 10, }, tableData: [], - page: {current: 1, size: 10, total: 0}, + page: {size: 10, total: 0}, + current: 1, girdList: [], - form: { ids: [], eventDesc: "", @@ -153,6 +153,7 @@ export default { params: { ...this.page, ...this.search, + current: this.current } }).then(res => { if(res?.data) { diff --git a/packages/conv/creditScore/AppGridMemberScore/components/gridScoreRules.vue b/packages/conv/creditScore/AppGridMemberScore/components/gridScoreRules.vue index cdcc76e7..0b57cfb3 100644 --- a/packages/conv/creditScore/AppGridMemberScore/components/gridScoreRules.vue +++ b/packages/conv/creditScore/AppGridMemberScore/components/gridScoreRules.vue @@ -6,41 +6,77 @@ - 添加 - + 添加 + + v-model="search.status" + @change="(page.current = 1), getList()" + placeholder="请选择状态" + :selectList="$dict.getDict('integralRuleStatus')" + > - + :tableData="tableData" + :col-configs="colConfigs" + :total="page.total" + :dict="dict" + :current.sync="page.current" + :size.sync="page.size" + @getList="getList()" + > - - {{ row.integralStart > 0 ? '+' + row.integralStart : row.integralStart }} ~ {{ row.integralEnd > 0 ? '+' + row.integralEnd : row.integralEnd }} - - {{ row.integral > 0 ? '+' : '' }}{{ row.integral }} + + {{ + row.integralStart > 0 + ? "+" + row.integralStart + : row.integralStart + }} + ~ + {{ + row.integralEnd > 0 ? "+" + row.integralEnd : row.integralEnd + }} + + {{ row.integral > 0 ? "+" : "" }}{{ row.integral }} - + - + 停用 - 启用 + 启用 编辑 删除 @@ -50,23 +86,40 @@ - + - - - - 系统规则 - 自定义规则 - - - + - + - - + + @@ -101,15 +154,22 @@ --> - + - + - + @@ -119,29 +179,50 @@ - - 请选择 + + {{ girdInfoList.length ? "已选择" : "请选择" }} - - + + :data="treeObj.treeList" + :props="treeObj.defaultProps" + node-key="id" + ref="tree" + :check-strictly="true" + show-checkbox + default-expand-all + :default-checked-keys="currCheckedKeys" + @check="onCheckChange" + > @@ -155,47 +236,89 @@ export default { props: { instance: Function, dict: Object, - permissions: Function + permissions: Function, }, data() { return { - search: {status: "", eventType: null}, - page: {current: 1, size: 10, total: 0}, + search: { + status: "", + systemRuleId: "", + }, + page: { current: 1, size: 10, total: 0 }, colConfigs: [ - {prop: "event", label: "事件", dict: "integralRuleEvent"}, - {prop: "type", label: "类型", dict: "integralRuleEventType"}, - {prop: "ruleType", label: "规则", dict: "integralRuleRuleType"}, - {prop: "scoringCycle", label: "周期范围", dict: "integralRuleScoringCycle"}, - {slot: "integral",label: "积分分值", align: "center"}, - {prop: "validRangeType", label: "有效范围", dict: "integralRuleScoringCycle"}, - {prop: "status", label: "状态", align: "center", width: 96, dict: "integralRuleStatus"}, - {slot: "options", label: "操作", align: "center"}, + { + prop: "parentRuleName", + label: "类型", + dict: "integralRuleEventType", + }, + { prop: "ruleName", label: "事件", dict: "integralRuleEvent" }, + { prop: "ruleType", label: "规则", dict: "integralRuleRuleType" }, + { + prop: "scoringCycle", + label: "周期范围", + dict: "integralRuleScoringCycle", + render: (h, { row }) => { + return h( + "span", + {}, + row.numberLimit.length + ? $dict.getLabel("integralRuleScoringCycle", row.scoringCycle) + : $dict.getLabel("integralRuleScoringCycle", row.scoringCycle) + + row.numberLimit + + "次" + ); + }, + }, + { slot: "integral", label: "积分分值", align: "center" }, + { + prop: "validRangeType", + label: "有效范围", + formart: (v) => (v == 0 ? "全局" : "指定网格"), + }, + { + prop: "status", + label: "状态", + align: "center", + width: 96, + dict: "integralRuleStatus", + }, + { slot: "options", label: "操作", align: "center" }, ], tableData: [], dialog: false, form: { - systemRuleId: '', - ruleName: '', - scoringCycle: '', - numberLimit: '', - integral: '', - validRangeType: '0', - validRangeData: '' + ruleType: "0", + systemRuleId: "", + ruleName: "", + scoringCycle: "", + numberLimit: "", + integral: "", + validRangeType: "0", + validRangeData: "", }, formRules: { - systemRuleId: [{required: true, message: "请选择事件/类型", trigger: "change"}], - scoringCycle: [{required: true, message: "请选择周期范围", trigger: "change"}], - // numberLimit: [{pattern: /^\d*$/, message: "请输入正整数"}], - integral: [{required: true, pattern: /^\d*[.\d]\d?$/, message: "请输入积分分值,最多保留一位小数"}], - validRangeType: [{required: true, message: "请选择有效范围", trigger: "change"}], - // validRangeData: [{required: true, message: "请选择生效网格", trigger: "change"}], + systemRuleId: [ + { required: true, message: "请选择事件/类型", trigger: "change" }, + ], + scoringCycle: [ + { required: true, message: "请选择周期范围", trigger: "change" }, + ], + integral: [ + { + required: true, + pattern: /^\d*[.\d]\d?$/, + message: "请输入积分分值,最多保留一位小数", + }, + ], + validRangeType: [ + { required: true, message: "请选择有效范围", trigger: "change" }, + ], }, rulesOps: [], - rulesOpsList: [], rulesProps: { label: "ruleName", value: "id", - checkStrictly:true, + checkStrictly: true, }, radio: 0, showGrid: false, @@ -209,144 +332,164 @@ export default { }, girdInfoList: [], currCheckedKeys: [], - rulueType: '0', + rulueType: "0", }; }, created() { - this.$dict.load("integralRuleStatus", "integralRuleRuleType", 'integralRuleScoringCycle', 'integralRuleEvent', 'integralRuleEventType').then(() => { - this.getList() - this.getRulesList() - this.beforeSelectTree() - }); + this.$dict + .load( + "integralRuleStatus", + "integralRuleRuleType", + "integralRuleScoringCycle", + "integralRuleEvent", + "integralRuleEventType" + ) + .then(() => { + this.getList(); + this.getRulesList(); + this.beforeSelectTree(); + }); }, methods: { getList() { - this.instance.post(`/app/appintegralrule/list`, null, { - params: {...this.search, ...this.page}, - }).then(res => { - if (res?.data) { - this.tableData = res.data.records; - this.page.total = res.data.total; - } - }); + this.instance + .post(`/app/appintegralrule/list`, null, { + params: { + ...this.search, + ...this.page, + }, + }) + .then((res) => { + if (res?.data) { + this.tableData = res.data.records; + this.page.total = res.data.total; + } + }); + }, + closed() { + this.form = { + ruleType: "0", + systemRuleId: "", + ruleName: "", + scoringCycle: "", + numberLimit: "", + integral: "", + validRangeType: "0", + validRangeData: "", + }; }, toEdit(row) { - this.form = this.$copy(row) - let {ladderRule, event, type} = this.form, - dict = 'integralRuleEvent' + event - this.$dict.load(dict).then(() => { - this.form.eventType = [event, type] - this.form.ladderRule = JSON.parse(ladderRule || "[]") - this.cacheOps = this.$dict.getDict('integralRuleEvent').map(e => { - if (e.dictValue == event) { - e.children = this.$dict.getDict(dict).map(d => ({...d, leaf: true})) - } - return e - }) - this.$nextTick(() => { - this.dialog = true - }) - }) + this.form = this.$copy(row); + this.girdInfoList = this.form?.validRangeData?.split(","); + this.$nextTick(() => { + this.dialog = true; + }); }, remove(id) { this.$confirm("删除后不可恢复,是否要删除该事项?", { - type: 'error' + type: "error", }).then(() => { - this.instance.post(`/app/appintegralrule/delete?ids=${id}`).then((res) => { - if (res.code == 0) { - this.$message.success("删除成功!") - this.getList(); - } - }); + this.instance + .post(`/app/appintegralrule/delete?ids=${id}`) + .then((res) => { + if (res.code == 0) { + this.$message.success("删除成功!"); + this.getList(); + } + }); }); }, changeStatus(id, status) { - let text = status == 1 ? '启用' : '停用' + let text = status == 1 ? "启用" : "停用"; this.$confirm(`确定${text}该条规则?`).then(() => { - this.instance.post(`/app/appintegralrule/enableStatus?id=${id}`).then((res) => { - if (res.code == 0) { - this.$message.success(`${text}成功!`) - this.getList(); - } - }); + this.instance + .post(`/app/appintegralrule/enableStatus?id=${id}`) + .then((res) => { + if (res.code == 0) { + this.$message.success(`${text}成功!`); + this.getList(); + } + }); }); }, onReset() { - this.page.current = 1 - this.search.classification = "" - this.search.integralType = "" - this.search.ruleStatus = "" + this.page.current = 1; + this.search.classification = ""; + this.search.integralType = ""; + this.search.ruleStatus = ""; this.getList(); }, onConfirm() { - if(this.form.ruleType==1 && !this.form.ladderRule.length) { - return this.$message.error('请添加规则') - } + // if(this.form.ruleType==1 && !this.form.ladderRule.length) { + // return this.$message.error('请添加规则') + // } this.$refs.DialogForm.validate((valid) => { if (valid) { - let formData = this.$copy(this.form) - formData.ladderRule = JSON.stringify(formData.ladderRule) - formData.integral = formData.integral || 0 - this.instance.post(`/app/appintegralrule/addOrUpdate`, formData).then((res) => { - if (res.code == 0) { - this.$message.success(`${this.isEdit ? '编辑成功' : '添加成功'}`) - this.onReset() - this.dialog = false; - } - }); + let formData = this.$copy(this.form); + // formData.ladderRule = JSON.stringify(formData.ladderRule) + formData.integral = formData.integral || 0; + this.instance + .post(`/app/appintegralrule/addOrUpdate`, formData) + .then((res) => { + if (res.code == 0) { + this.$message.success( + `${this.isEdit ? "编辑成功" : "添加成功"}` + ); + this.onReset(); + this.dialog = false; + } + }); } else { return false; } }); }, handleTypeSearch(v) { - this.search.event = v?.[0] - this.search.type = v?.[1] - this.page.current = 1 - this.$refs.eventTypeSearch.dropDownVisible = false - this.getList() + this.search.systemRuleId = v?.[v.length - 1]; + this.page.current = 1; + this.$refs.eventTypeSearch.dropDownVisible = false; + this.getList(); }, handleTypeForm(v) { if (this.dialog) { - // this.form.event = v?.[0] - this.form.systemRuleId = v?.[v.length - 1] - console.log(this.form.systemRuleId); - // this.form.ruleType = !this.form.event ? null : this.form.event == 3 ? 1 : 0 + this.form.systemRuleId = v?.[v.length - 1]; } }, handleDelete(i) { - this.$confirm("是否要删除该规则?").then(() => { - this.form.ladderRule.splice(i, 1) - }).catch(() => 0) + this.$confirm("是否要删除该规则?") + .then(() => { + this.form.ladderRule.splice(i, 1); + }) + .catch(() => 0); }, checkIntegral(v) { - return /\.\d{2,}$/.test(v) ? Math.abs(v).toFixed(1) : Math.abs(v) + return /\.\d{2,}$/.test(v) ? Math.abs(v).toFixed(1) : Math.abs(v); }, getRulesList() { - this.instance.post(`/app/appintegralsystemrule/list?current=1&sizes=3000`).then(res=> { - if(res?.data) { - this.rulesOps = this.toTree(res.data.records) - this.rulesOpsList = this.rulesOps - this.rulesOpsList.push({ - ruleName: '自定义', - id: '自定义' - }) - } - }) + this.instance + .post(`/app/appintegralsystemrule/list?current=1&sizes=3000`) + .then((res) => { + if (res?.data) { + this.rulesOps = this.toTree(res.data.records); + this.rulesOps.push({ + ruleName: "自定义", + id: "自定义", + }); + } + }); }, // 转树形结构 toTree(data) { let result = []; if (!Array.isArray(data)) { - return result + return result; } let map = {}; - data.forEach(item => { + data.forEach((item) => { map[item.id] = item; }); - data.forEach(item => { + data.forEach((item) => { let parent = map[item.parentRuleId]; - console.log(parent); if (parent) { (parent.children || (parent.children = [])).push(item); } else { @@ -359,13 +502,13 @@ export default { girdToTree(data) { let result = []; if (!Array.isArray(data)) { - return result + return result; } let map = {}; - data.forEach(item => { + data.forEach((item) => { map[item.id] = item; }); - data.forEach(item => { + data.forEach((item) => { let parent = map[item.parentGirdId]; if (parent) { (parent.children || (parent.children = [])).push(item); @@ -378,58 +521,77 @@ export default { getCheckedTree() { if (!this.$refs.tree.getCheckedNodes().length) { - return this.$message.error('请选择网格') + return this.$message.error("请选择网格"); } - - this.$set(this.girdInfoList, this.currIndex, { - ...this.$refs.tree.getCheckedNodes(), - checkType: true - }) - - // this.girdInfoList = this.$refs.tree.getCheckedNodes() - + console.log(this.girdInfoList, this.$refs.tree.getCheckedNodes()); + this.girdInfoList = this.$refs.tree.getCheckedNodes().map((item) => { + return { ...item, checkType: true }; + }); + // this.$set(this.girdInfoList, this.currIndex, { + // ...this.$refs.tree.getCheckedNodes(), + // checkType: true + // }) + this.form.validRangeData = this.$refs.tree + .getCheckedNodes() + .map((e) => e.id) + .toString(); this.showGrid = false; }, - + beforeSelectTree() { this.treeObj.checkedKeys = []; - this.instance.post(`/app/appgirdinfo/listAll3`, null, null).then((res) => { - if (res.code == 0) { - this.treeObj.treeList = this.girdToTree(res.data) - this.girdInfoList.map((e) => { - this.treeObj.checkedKeys.push(e.id); - }); - } - }); - }, - - onCheckChange(e) { - this.$refs.tree.setChecked(e.id, true) + this.instance + .post(`/app/appgirdinfo/listAll3`, null, null) + .then((res) => { + if (res.code == 0) { + // res.data.forEach((item)=>{ + // const isChecked= this.girdInfoList.find((checkedId)=>{ + // return item.id===checkedId + // }) + + // if(isChecked) item.checkType=true + // }) + // console.log(res.data) + + this.treeObj.treeList = this.girdToTree(res.data); + this.girdInfoList.map((e) => { + this.treeObj.checkedKeys.push(e.id); + }); + this.$nextTick(() => { + this.currCheckedKeys = this.girdInfoList; + this.$nextTick(() => { + this.$refs.tree?.setCheckedKeys(this.currCheckedKeys); + }); + }); + } + }); }, + onCheckChange(e) { + this.$refs.tree.setChecked(e.id, true); + }, }, computed: { isEdit() { - return !!this.form.id + return !!this.form.id; }, dialogTitle() { - return this.isEdit ? "编辑积分规则" : "添加积分规则" + return this.isEdit ? "编辑积分规则" : "添加积分规则"; }, etOps() { return { value: "id", label: "ruleName", - } + }; }, // currCheckedKeys() { - // if (this.girdInfoList && this.girdInfoList[this.currIndex] && this.girdInfoList[this.currIndex].id) { - // return [this.girdInfoList[this.currIndex].id] + // if (this.girdInfoList) { + // return this.girdInfoList // } // return [] // }, }, - -} +};