居民积分
This commit is contained in:
		
							
								
								
									
										82
									
								
								project/qujing/app/AppResidentCredits/AppResidentCredits.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								project/qujing/app/AppResidentCredits/AppResidentCredits.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,82 @@ | ||||
| <template> | ||||
|   <ai-list> | ||||
|     <template slot="title"> | ||||
|       <ai-title title="居民积分" :isShowArea="currIndex === '0'" :hideLevel="$store.state.user.info.areaList.length - 1" v-model="areaId" :instance="instance" @change="search.current = 1, getList()"></ai-title> | ||||
|     </template> | ||||
|     <template slot="tabs"> | ||||
|       <el-tabs v-model="currIndex"> | ||||
|         <el-tab-pane v-for="(tab,i) in tabs" :key="i" :label="tab.label"> | ||||
|           <component :areaId="areaId" :ref="String(i)" v-if="currIndex == i" :is="tab.comp" @change="onChange" lazy :instance="instance" :dict="dict" :permissions="permissions"/> | ||||
|         </el-tab-pane> | ||||
|       </el-tabs> | ||||
|     </template> | ||||
|   </ai-list> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
|   import List from './components/List' | ||||
|   import Rule from './components/Rule' | ||||
|  | ||||
|   export default { | ||||
|     name: 'AppResidentCredits', | ||||
|     label: '居民积分', | ||||
|  | ||||
|     props: { | ||||
|       instance: Function, | ||||
|       dict: Object, | ||||
|       permissions: Function | ||||
|     }, | ||||
|  | ||||
|     data () { | ||||
|       return { | ||||
|         component: 'List', | ||||
|         params: {}, | ||||
|         currIndex: '0', | ||||
|         areaId: '' | ||||
|       } | ||||
|     }, | ||||
|  | ||||
|     components: { | ||||
|       List, | ||||
|       Rule | ||||
|     }, | ||||
|  | ||||
|     computed: { | ||||
|       tabs () { | ||||
|         return [ | ||||
|           {label: '居民积分', name: 'List', comp: List, permission: ''}, | ||||
|           {label: `积分规则`, name: 'Rule', comp: Rule, permission: ''} | ||||
|         ].filter(item => { | ||||
|           return true | ||||
|         }) | ||||
|       } | ||||
|     }, | ||||
|  | ||||
|     created () { | ||||
|       this.areaId = this.$store.state.user.info.areaId | ||||
|     }, | ||||
|  | ||||
|     methods: { | ||||
|       onChange (data) { | ||||
|         if (data.type === 'List') { | ||||
|           this.component = 'List' | ||||
|           this.params = data.params | ||||
|           this.isShowDetail = false | ||||
|         } | ||||
|  | ||||
|         if (data.type === 'Rule') { | ||||
|           this.component = 'Rule' | ||||
|           this.params = data.params | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| </script> | ||||
|  | ||||
| <style lang="scss"> | ||||
|   .doc-circulation { | ||||
|     height: 100%; | ||||
|     background: #F3F6F9; | ||||
|     overflow: auto; | ||||
|   } | ||||
| </style> | ||||
							
								
								
									
										107
									
								
								project/qujing/app/AppResidentCredits/components/List.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								project/qujing/app/AppResidentCredits/components/List.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,107 @@ | ||||
| <template> | ||||
|   <ai-list isTabs> | ||||
|     <template slot="content"> | ||||
|       <ai-search-bar class="search-bar"> | ||||
|         <template #left> | ||||
|         </template> | ||||
|         <template #right> | ||||
|           <el-input | ||||
|             v-model="search.title" | ||||
|             class="search-input" | ||||
|             size="small" | ||||
|             v-throttle="() => {search.current = 1, getList()}" | ||||
|             placeholder="请输入标题" | ||||
|             clearable | ||||
|             @clear="search.current = 1, search.title = '', getList()" | ||||
|             suffix-icon="iconfont iconSearch"> | ||||
|           </el-input> | ||||
|         </template> | ||||
|       </ai-search-bar> | ||||
|       <ai-table | ||||
|         :tableData="tableData" | ||||
|         :col-configs="colConfigs" | ||||
|         :total="total" | ||||
|         style="margin-top: 6px;" | ||||
|         :current.sync="search.current" | ||||
|         :size.sync="search.size" | ||||
|         @getList="getList"> | ||||
|         <el-table-column slot="comment" label="评论数" align="center" v-if="permissions('app_appcontentcomment_detail')"> | ||||
|           <template slot-scope="{ row }"> | ||||
|             <div class="table-options"> | ||||
|               <el-button type="text" @click="toComment(row.id)">{{ row.msgCount }}</el-button> | ||||
|             </div> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column slot="options" width="160px" fixed="right" label="操作" align="center"> | ||||
|           <template slot-scope="{ row }"> | ||||
|             <div class="table-options"> | ||||
|               <el-button type="text" @click="toAdd(row.id)">编辑</el-button> | ||||
|               <el-button type="text" @click="toDetail(row.id)">详情</el-button> | ||||
|               <el-button type="text" @click="remove(row.id)">删除</el-button> | ||||
|             </div> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|       </ai-table> | ||||
|     </template> | ||||
|   </ai-list> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
|   export default { | ||||
|     name: 'List', | ||||
|  | ||||
|     props: { | ||||
|       instance: Function, | ||||
|       dict: Object, | ||||
|       areaId: String, | ||||
|       permissions: Function | ||||
|     }, | ||||
|  | ||||
|     data() { | ||||
|       return { | ||||
|         search: { | ||||
|           current: 1, | ||||
|           size: 10, | ||||
|           title: '' | ||||
|         }, | ||||
|         total: 10, | ||||
|         colConfigs: [ | ||||
|           { prop: 'title',  label: '标题', align: 'left', width: '200px' }, | ||||
|           { prop: 'areaName', label: '地区', align: 'left' }, | ||||
|           { prop: 'examineStatus', label: '状态', align: 'center', format: v => this.dict.getLabel('auditStatus', v) }, | ||||
|           { prop: 'examineOpinion', label: '审核意见', align: 'center' }, | ||||
|           { prop: 'viewCount', label: '浏览次数', align: 'center' }, | ||||
|           { slot: 'comment', label: '评论次数', align: 'center' }, | ||||
|           { prop: 'createUserName', label: '发布人', align: 'center' }, | ||||
|           { prop: 'createTime', label: '发布时间', align: 'center' } | ||||
|         ], | ||||
|         tableData: [] | ||||
|       } | ||||
|     }, | ||||
|  | ||||
|     created() { | ||||
|       this.dict.load('auditStatus').then(() => { | ||||
|         this.getList() | ||||
|       }) | ||||
|     }, | ||||
|  | ||||
|     methods: { | ||||
|       getList() { | ||||
|         this.instance.post(`/app/appintegralsystemrule/listByAppletQJ`, null, { | ||||
|           params: { | ||||
|             ...this.search, | ||||
|             areaId: this.areaId | ||||
|           } | ||||
|         }).then(res => { | ||||
|           if (res.code == 0) { | ||||
|             this.tableData = res.data.records | ||||
|             this.total = res.data.total | ||||
|           } | ||||
|         }) | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| </script> | ||||
|  | ||||
| <style lang="scss" scoped> | ||||
| </style> | ||||
							
								
								
									
										373
									
								
								project/qujing/app/AppResidentCredits/components/Rule.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										373
									
								
								project/qujing/app/AppResidentCredits/components/Rule.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,373 @@ | ||||
| <template> | ||||
|   <ai-list isTabs class="gridScoreRules"> | ||||
|     <template slot="content"> | ||||
|       <ai-search-bar> | ||||
|         <template #left> | ||||
|           <el-button type="primary" icon="iconfont iconAdd" @click="dialog = true"> 添加</el-button> | ||||
|           <el-cascader size="small" v-model="systemRuleIdList" :options="rulesOps" placeholder="请选择事件/类型" clearable :props="rulesProps" | ||||
|                         @change="handleTypeSearch" ref="eventTypeSearch"/> | ||||
|           <ai-select v-model="search.status" @change="(page.current = 1), getList()" placeholder="请选择状态" :selectList="$dict.getDict('integralRuleStatus')"> | ||||
|           </ai-select> | ||||
|         </template> | ||||
|       </ai-search-bar> | ||||
|       <ai-table :tableData="tableData" :col-configs="colConfigs" :total="page.total" :dict="dict" :current.sync="page.current" :size.sync="page.size" | ||||
|                 @getList="getList()"> | ||||
|         <el-table-column slot="integral" label="分值" align="center"> | ||||
|           <template slot-scope="{ row }"> | ||||
|             <!-- <span v-if="row.integralValueType == 1"> | ||||
|               {{ row.integralStart > 0 ? "+" + row.integralStart : row.integralStart }}~{{ row.integralEnd > 0 ? "+" + row.integralEnd : row.integralEnd }} | ||||
|             </span> --> | ||||
|             <span>{{ row.integral > 0 ? "+" : "" }}{{ row.integral }}</span> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column slot="options" label="操作" align="center" fixed="right" width="200"> | ||||
|           <template slot-scope="{ row }"> | ||||
|             <div class="table-options"> | ||||
|               <el-button type="text" @click="changeStatus(row.id, 0)" v-if="row.status == 1">停用</el-button> | ||||
|               <el-button type="text" @click="changeStatus(row.id, 1)" v-else>启用</el-button> | ||||
|               <el-button type="text" @click="toEdit(row)">编辑</el-button> | ||||
|               <el-button type="text" @click="remove(row.id)">删除</el-button> | ||||
|             </div> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|       </ai-table> | ||||
|       <ai-dialog :title="dialogTitle" :visible.sync="dialog" @onConfirm="onConfirm" @closed="closed" width="900px"> | ||||
|         <div class="form_div"> | ||||
|           <el-form ref="DialogForm" :model="form" :rules="formRules" size="small" label-suffix=":" label-width="150px"> | ||||
|             <el-form-item label="事件类型" prop="systemRuleId"> | ||||
|               <el-cascader v-model="form.systemRuleId" ref="cascaderArr" :props="etOps" clearable placeholder="请选择" @change="handleTypeForm" :options="rulesOps"/> | ||||
|             </el-form-item> | ||||
|             <el-form-item label="自定义事件" v-if="form.systemRuleId == '自定义'" prop="ruleName"> | ||||
|               <el-input placeholder="请输入,周期范围内,不填写表示不限制" v-model="form.ruleName" clearable maxlength="10" show-word-limit/> | ||||
|             </el-form-item> | ||||
|  | ||||
|             <el-form-item label="规则"> | ||||
|               <div>常规</div> | ||||
|             </el-form-item> | ||||
|  | ||||
|             <el-form-item label="周期范围" prop="scoringCycle"> | ||||
|               <ai-select v-model="form.scoringCycle" :selectList="$dict.getDict('integralRuleScoringCycle')" :disabled="isOneAndTen"/> | ||||
|             </el-form-item> | ||||
|  | ||||
|             <el-form-item label="奖励次数"> | ||||
|               <el-input type="number" placeholder="请输入,周期范围内,不填写表示不限制" v-model.number="form.numberLimit" clearable :disabled="isOneAndTen"/> | ||||
|             </el-form-item> | ||||
|  | ||||
|             <el-form-item label="积分分值" prop="integral"> | ||||
|               <el-input placeholder="请输入" v-model="form.integral" clearable/> | ||||
|             </el-form-item> | ||||
|           </el-form> | ||||
|         </div> | ||||
|       </ai-dialog> | ||||
|     </template> | ||||
|   </ai-list> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| export default { | ||||
|   name: "gridScoreRules", | ||||
|   label: "积分规则", | ||||
|   props: { | ||||
|     instance: Function, | ||||
|     dict: Object, | ||||
|     permissions: Function, | ||||
|   }, | ||||
|   data() { | ||||
|     var validcode = (rule, value, callback) => { | ||||
|       if (value) { | ||||
|         if (value != 0) { | ||||
|           if (!/^([+-]?([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/.test(value)) { | ||||
|             callback(new Error('请输入积分分值,可输入正数、负数、最多保留两位小数')) | ||||
|           } else { | ||||
|             callback(); | ||||
|           } | ||||
|         } else { | ||||
|           callback(new Error('请输入有效的积分分值')); | ||||
|         } | ||||
|       } else { | ||||
|         callback(new Error('请输入积分分值')); | ||||
|       } | ||||
|     } | ||||
|     return { | ||||
|       search: { | ||||
|         status: "", | ||||
|         systemRuleId: "", | ||||
|         ruleName: "" | ||||
|       }, | ||||
|       systemRuleIdList: [], | ||||
|       page: {current: 1, size: 10, total: 0}, | ||||
|       colConfigs: [ | ||||
|         { | ||||
|           prop: "parentRuleName", | ||||
|           label: "类型", | ||||
|           dict: "integralRuleEventType", | ||||
|         }, | ||||
|         {prop: "ruleName", label: "事件", align: "center", dict: "integralRuleEvent"}, | ||||
|         {prop: "ruleType", label: "规则", align: "center", dict: "integralRuleRuleType"}, | ||||
|         { | ||||
|           prop: "scoringCycle", | ||||
|           label: "周期范围", | ||||
|           align: "center", | ||||
|           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: "status", | ||||
|           label: "状态", | ||||
|           align: "center", | ||||
|           width: 96, | ||||
|           dict: "integralRuleStatus", | ||||
|         }, | ||||
|         {slot: "options", label: "操作", align: "center"}, | ||||
|       ], | ||||
|       tableData: [], | ||||
|       dialog: false, | ||||
|       form: { | ||||
|         ruleType: "0", | ||||
|         systemRuleId: "", | ||||
|         ruleName: "", | ||||
|         scoringCycle: "", | ||||
|         numberLimit: "", | ||||
|         integral: "" | ||||
|       }, | ||||
|       formRules: { | ||||
|         systemRuleId: [ | ||||
|           {required: true, message: "请选择事件/类型", trigger: "change"}, | ||||
|         ], | ||||
|         ruleName: [ | ||||
|           {required: true, message: "请输入自定义事件", trigger: "change"}, | ||||
|         ], | ||||
|         scoringCycle: [ | ||||
|           {required: true, message: "请选择周期范围", trigger: "change"}, | ||||
|         ], | ||||
|         integral: [{required: true, validator: validcode, trigger: "blur"},] | ||||
|       }, | ||||
|       rulesOps: [], | ||||
|       rulesProps: { | ||||
|         label: "ruleName", | ||||
|         value: "id", | ||||
|         checkStrictly: true, | ||||
|       }, | ||||
|       radio: 0, | ||||
|       rulueType: "0", | ||||
|       list: [], | ||||
|       isOneAndTen: false, | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     this.$dict.load("integralRuleStatus", "integralRuleRuleType", "integralRuleScoringCycle", | ||||
|         "integralRuleEvent", "integralRuleEventType").then(() => { | ||||
|       this.getList(); | ||||
|       this.getRulesList(); | ||||
|     }); | ||||
|   }, | ||||
|   methods: { | ||||
|     getList() { | ||||
|       this.instance | ||||
|       .post(`/app/appintegralrule/listByAppletQJ`, 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: "", | ||||
|       }; | ||||
|       this.girdInfoList = [] | ||||
|       this.treeSelected = {} | ||||
|     }, | ||||
|     toEdit(row) { | ||||
|       this.form = {...row} | ||||
|       if (this.form?.validRangeData) { | ||||
|         this.girdInfoList = JSON.parse(this.form.validRangeData) | ||||
|         this.girdNameList = this.girdInfoList.map(e => e.girdName) | ||||
|       } | ||||
|       this.$nextTick(() => { | ||||
|         this.dialog = true; | ||||
|       }); | ||||
|     }, | ||||
|     remove(id) { | ||||
|       this.$confirm("删除后不可恢复,是否要删除该规则?", { | ||||
|         type: "error", | ||||
|       }).then(() => { | ||||
|         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 ? "启用" : "停用"; | ||||
|       this.$confirm(`确定${text}该条规则?`).then(() => { | ||||
|         this.instance | ||||
|         .post(`/app/appintegralrule/enableStatus?id=${id}`) | ||||
|         .then((res) => { | ||||
|           if (res.code == 0) { | ||||
|             this.$message.success(`${text}成功!`); | ||||
|             this.getList(); | ||||
|           } | ||||
|         }); | ||||
|       }); | ||||
|     }, | ||||
|     onConfirm() { | ||||
|       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.dialog = false; | ||||
|               this.getList(); | ||||
|               this.closed(); | ||||
|               this.girdInfoList = [] | ||||
|               this.girdNameList = [] | ||||
|             } | ||||
|           }); | ||||
|         } else { | ||||
|           return false; | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     handleTypeSearch(v) { | ||||
|       this.systemRuleIdList = v | ||||
|       this.search.systemRuleId = v?.[v.length - 1]; | ||||
|       this.search.ruleName = this.$refs.eventTypeSearch.getCheckedNodes()[0]?.label | ||||
|       this.page.current = 1; | ||||
|       this.$refs.eventTypeSearch.dropDownVisible = false; | ||||
|       this.getList(); | ||||
|     }, | ||||
|     handleTypeForm(v) { | ||||
|       if (this.dialog) { | ||||
|         if(v[0] == '1' || v[0]== '10') { | ||||
|           this.form.scoringCycle = '0' | ||||
|           this.form.numberLimit = '1' | ||||
|           this.isOneAndTen = true | ||||
|         } else { | ||||
|           this.form.scoringCycle = '' | ||||
|           this.form.numberLimit = '' | ||||
|           this.isOneAndTen = false | ||||
|         } | ||||
|         this.form.systemRuleId = v?.[v.length - 1]; | ||||
|       } | ||||
|     }, | ||||
|     handleDelete(i) { | ||||
|       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); | ||||
|     }, | ||||
|     getRulesList() { | ||||
|       this.instance | ||||
|       .post(`/app/appintegralsystemrule/listByAppletQJ?current=1&size=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; | ||||
|       } | ||||
|       let map = {}; | ||||
|       data.forEach((item) => { | ||||
|         map[item.id] = item; | ||||
|       }); | ||||
|       data.forEach((item) => { | ||||
|         let parent = map[item.parentRuleId]; | ||||
|         if (parent) { | ||||
|           (parent.children || (parent.children = [])).push(item); | ||||
|         } else { | ||||
|           result.push(item); | ||||
|         } | ||||
|       }); | ||||
|       return result; | ||||
|     } | ||||
|   }, | ||||
|   computed: { | ||||
|     isEdit() { | ||||
|       return !!this.form.id; | ||||
|     }, | ||||
|     dialogTitle() { | ||||
|       return this.isEdit ? "编辑积分规则" : "添加积分规则"; | ||||
|     }, | ||||
|     etOps() { | ||||
|       return { | ||||
|         value: "id", | ||||
|         label: "ruleName", | ||||
|       }; | ||||
|     }, | ||||
|   }, | ||||
| }; | ||||
| </script> | ||||
|  | ||||
| <style lang="scss" scoped> | ||||
|   .gridScoreRules { | ||||
|     height: 100%; | ||||
|     background: #f3f6f9; | ||||
|  | ||||
|     :deep( .ai-list__content--right ){ | ||||
|       width: 100%; | ||||
|     } | ||||
|  | ||||
|     :deep( .ai-dialog ){ | ||||
|       .el-cascader { | ||||
|         width: 100%; | ||||
|       } | ||||
|  | ||||
|       .tableInput { | ||||
|         & > input { | ||||
|           text-align: center; | ||||
|           border: none; | ||||
|           background: transparent; | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| </style> | ||||
		Reference in New Issue
	
	Block a user