diff --git a/packages/conv/creditScore/scoreRules/AppScoreRules.vue b/packages/conv/creditScore/scoreRules/AppScoreRules.vue index 8a581616..4d26d53c 100644 --- a/packages/conv/creditScore/scoreRules/AppScoreRules.vue +++ b/packages/conv/creditScore/scoreRules/AppScoreRules.vue @@ -1,27 +1,17 @@ - + - - - - + @@ -31,15 +21,15 @@ - 添加 + 添加 @@ -53,92 +43,63 @@ - 停用 + + 停用 - 启用 - 编辑 - 删除 + 启用 + 编辑 + 删除 - - + 暂无应用权限 + - - - - + + + - - + + + + 添加 + + + + + + + + + + + + + + + + 删除 + + + - - - + + - - - 加分 - 扣分 - - - - - - - + + + - + + + + - @@ -150,8 +111,33 @@ export default { props: { instance: Function, dict: Object, + permissions: Function + }, + computed: { + isEdit() { + return !!this.form.id + }, + dialogTitle() { + return this.isEdit ? "编辑积分规则" : "添加积分规则" + }, + etOps() { + return { + lazy: true, + value: "dictValue", + label: "dictName", + lazyLoad: (node, resolve) => { + if (node.level == 0) resolve(this.dict.getDict('integralRuleEvent')) + else if (node.level == 1) { + let dict = 'integralRuleEvent' + node.value + this.dict.load(dict).then(() => { + let nodes = this.dict.getDict(dict).map(e => ({...e, leaf: true})) + resolve(nodes) + }) + } + } + } + }, }, - data() { var integralPass = (rule, value, callback) => { if (value) { @@ -164,116 +150,47 @@ export default { callback(new Error("请输入积分")); } }; - var integralStartPass = (rule, value, callback) => { - if (value) { - if ((/(^[1-9]\d*$)/.test(value))) { - callback(); - } else { - callback(new Error("请输入整数积分")); - } - } else { - callback(new Error("请输入积分")); - } - }; - var integralEndPass = (rule, value, callback) => { - if (value) { - if ((/(^[1-9]\d*$)/.test(value))) { - if (Number(value) < Number(this.dialogInfo.integralStart)) { - callback(new Error("请输入大于前面数字的积分")); - } else { - callback() - } - } else { - callback(new Error("请输入整数积分")); - } - } else { - callback(new Error("请输入积分")); - } - }; return { - search: { - current: 1, - size: 10, - classification: "", - integralType: "", - ruleStatus: "", - }, - total: 10, + search: {status: "", eventType: null}, + page: {current: 1, size: 10, total: 0}, colConfigs: [ - {prop: "classification", label: "类型", width: 168, dict: "atWillReportType"}, - {prop: "ruleName", label: "事项", showOverflowTooltip: true, width: 260}, - {prop: "ruleDescription", label: "规则说明", width: 390}, - {prop: "integralType", label: "类型", width: 60, dict: "integralIntegralType"}, - {slot: "integral", label: "分值", width: 70}, - {prop: "doTime", label: "最后编辑时间", width: 160}, - {prop: "doUserName", label: "操作人", width: 120}, - {prop: "ruleStatus", label: "状态", align: "center", width: 96, dict: "integralRuleStatus", fixed: "right"}, + {prop: "event", label: "事件", dict: "integralRuleEvent"}, + {prop: "type", label: "类型", dict: "integralRuleEventType"}, + {prop: "ruleType", label: "规则", dict: "integralRuleRuleType"}, + {slot: "scoringCycle", label: "周期范围", dict: "integralRuleScoringCycle"}, + {prop: "status", label: "状态", align: "center", width: 96, dict: "integralRuleStatus"}, {slot: "options", label: "操作", align: "center"}, ], tableData: [], - - dialog: { - title: "", - visible: false, - }, - dialogInfo: { - classification: "", - ruleName: "", - ruleDescription: "", - integralType: '1', - integralValueType: '0', - integral: "", - // integralStart: "", - // integralEnd: "", - doTime: '', - id: '', - doUserId: '', - doUserName: '', - }, + dialog: false, + form: {ladderRule: []}, formRules: { - classification: [{required: true, message: "请选择类型", trigger: "change"}], - ruleName: [{required: true, message: "请输入事项", trigger: "blur"}], - ruleDescription: [{required: true, message: "请输入规则说明", trigger: "blur"}], - integralType: [{required: true, message: "请选择类型", trigger: "change"}], - integralValueType: [{required: true, message: "请选择分值类型", trigger: "change"}], + eventType: [{required: true, message: "请选择事件/类型", trigger: "change"}], integral: [{required: true, validator: integralPass, trigger: "change"}], - integralStart: [{required: true, validator: integralStartPass, trigger: "change"}], - integralEnd: [{required: true, validator: integralEndPass, trigger: "change"}], }, }; }, - created() { - this.dict.load(["integralIntegralType", "integralRuleStatus", 'atWillReportType']).then(() => { + this.dict.load("integralRuleStatus", "integralRuleRuleType", 'integralRuleScoringCycle', 'integralRuleEvent', 'integralRuleEventType').then(() => { this.getList(); }); }, - methods: { getList() { - this.instance - .post(`/app/appvillagerintegralrule/list`, null, { - params: { - ...this.search, - }, - }) - .then((res) => { - if (res.code == 0) { + this.instance.post(`/app/appvillagerintegralrule/list`, null, { + params: {...this.search, ...this.page}, + }).then(res => { + if (res?.data) { this.tableData = res.data.records; - this.total = res.data.total; + this.page.total = res.data.total; } }); }, - toEdit(row) { - this.dialog.title = "编辑积分规则"; - this.dialog.visible = true; - this.dialogInfo = {...row} - this.dialogInfo.integralStart = Math.abs(this.dialogInfo.integralStart) - this.dialogInfo.integralEnd = Math.abs(this.dialogInfo.integralEnd) - this.dialogInfo.integral = Math.abs(this.dialogInfo.integral) + this.dialog = true; + this.form = this.$copy(row) + this.form.ladderRule = JSON.parse(this.formRules.ladderRule) }, - remove(id) { this.$confirm("删除后不可恢复,是否要删除该事项?", { type: 'error' @@ -288,7 +205,6 @@ export default { }); }); }, - changeStatus(id, status) { var text = status == 1 ? '启用' : '停用' this.$confirm(`确定${text}该条规则?`).then(() => { @@ -302,36 +218,23 @@ export default { }); }); }, - onReset() { - this.search.current = 1 + this.page.current = 1 this.search.classification = "" this.search.integralType = "" this.search.ruleStatus = "" this.getList(); }, - - onAdd() { - this.$emit("change", { - type: "add", - }); - }, - - addRule() { - this.dialog.title = "添加积分规则"; - this.dialog.visible = true; - }, - - onConfirm(formName) { - this.$refs[formName].validate((valid) => { + onConfirm() { + this.$refs.DialogForm.validate((valid) => { if (valid) { - this.instance - .post(`/app/appvillagerintegralrule/addOrUpdate`, this.dialogInfo) - .then((res) => { + let formData = this.$copy(this.form) + formData.ladderRule = JSON.stringify(formData.ladderRule) + this.instance.post(`/app/appvillagerintegralrule/addOrUpdate`, formData).then((res) => { if (res.code == 0) { - this.$message.success(`${this.dialogInfo.id ? '编辑成功' : '添加成功'}`) + this.$message.success(`${this.isEdit ? '编辑成功' : '添加成功'}`) this.onReset() - this.onCancel(); + this.dialog = false; } }); } else { @@ -339,43 +242,50 @@ export default { } }); }, - - onCancel() { - this.dialog.visible = false; + handleTypeSearch(v) { + this.search.event = v?.[0] + this.search.type = v?.[1] + this.page.current = 1 + this.$refs.eventTypeSearch.dropDownVisible = false + this.getList() }, - - numTypeChange() { - // this.dialogInfo.integra = ""; - // this.dialogInfo.integralStart = ""; - // this.dialogInfo.integralEnd = ""; - }, - - init() { - this.dialogInfo = {integralType: '1', integralValueType: '0'} + handleTypeForm(v) { + if (this.dialog) { + this.form.event = v?.[0] + this.form.type = v?.[1] + this.form.ruleType = !this.form.event ? null : this.form.event == 3 ? 1 : 0 + } }, + handleDelete(i) { + this.$confirm("是否要删除该规则?").then(() => { + this.form.ladderRule.splice(i, 1) + }).catch(() => 0) + } }, }; -