diff --git a/src/views/modules/workSys/pointAditive/rule.vue b/src/views/modules/workSys/pointAditive/rule.vue index 54ce3db6..5cbc4c83 100644 --- a/src/views/modules/workSys/pointAditive/rule.vue +++ b/src/views/modules/workSys/pointAditive/rule.vue @@ -20,9 +20,6 @@ :prop="item.columnName" :label="item.label" :align="item.align"> - 添加二级分类 + class="btn-color-1j">添加二级分类 添加积分规则 - 添加积分规则 + 修改 - 修改 + 删除 + class="btn-color-del">删除 @@ -67,7 +67,7 @@ placeholder="请选择" size="small" style="width: 180px;" - :disabled="addLevel == '2' || addLevel == '3' ? true : false" + :disabled="addLevel == '2' || addLevel == '3' || addLevel == '4' ? true : false" clearable> - - - (减分请输入负数) - + prop="applyFlag" + label-width="200px"> 允许申请 不允许申请 @@ -124,23 +125,12 @@ export default { return { tableLoading: false, btnLoading: false, - disabled: false, pageLoading: false, dialogVisible: false, tableData: [], sHeight: 0, addLevel: '1', addType: 'add', - value: '', - options: [ - { - label: '是', - value: 1 - }, { - label: '否', - value: 2 - } - ], tableHeader: [ { label: '积分类别', @@ -152,12 +142,13 @@ export default { align: 'center' } ], - customerId: '', - form: { + typeList: [], //类别 + form: { // 新增修改相关 categoryName: '', // 类别名称 pid: '', // 上级类别ID + newPid: '', // 添加积分规则用到的pid ruleName: '', // 积分规则名称 - pointValue: '', + pointValue: '', // 加减积分 applyFlag: '0' // 允许申请0,不允许申请1 }, rules: { @@ -166,14 +157,7 @@ export default { ruleName: [{ required: true, message: '规则名称不能为空', trigger: 'blur' }], pointValue: [{ required: true, message: '加减分值不能为空', trigger: 'blur' }], applyFlag: [{ required: true, message: '请选择积分申请', trigger: 'blur' }] - }, - typeList: [{ - value: '03dedaa5dbb822550e7b25e75aa9fdde', - label: '德育积分' - },{ - value: '7a487c4c23243cbf23afb4bc8c35a3d8', - label: '党建积分' - }],//类别 + } } }, computed: { @@ -186,27 +170,16 @@ export default { ...mapGetters(['clientHeight', 'iframeHeight']) }, async created () { - this.customerId = localStorage.getItem('customerId') this.getTableData() this.pageLoading = true }, mounted () { this.$nextTick(() => { - this.sHeight = 250 - console.log('tableHeight', this.tableHeight) + this.sHeight = 210 }) }, methods: { - - handleFilterSpan (row, item) { - let _val = '' - if (item.options && item.options.length > 0) { - item.options.forEach((n) => { - if (n.value === row[item.columnName]) _val = n.label - }) - } - return _val || row[item.columnName] - }, + // 列表添加相关 handleAdd (type, addType, id, pid, categoryName) { this.addLevel = type this.addType = addType @@ -216,6 +189,7 @@ export default { if (type == '3') { this.form.pid = pid + this.form.newPid = id this.form.categoryName = categoryName } this.dialogVisible = true @@ -223,14 +197,27 @@ export default { handlerCancle () { this.dialogVisible = false }, - async handleEdit (row, addType) { - - this.form = { ...row } - this.addLevel = row.level + // 列表修改点击事件 + async handleEdit (row, addType, level) { + let url = '' + if (level === '4') { + url = `/point/additiverule/categorydetail/${row.id}` + } else if(level === '5') { + url = `/point/additiverule/ruledetail/${row.id}` + } + this.addLevel = level this.addType = addType this.dialogVisible = true + await this.$http.post(url).then(({ data: res }) => { + if (res.code !== 0) { + return this.$message.error(res.msg) + } else { + this.form = { ...res.data } + } + }) }, - async addLevelFirst () { // 从添加 按钮点击进来的 + // 添加积分类别 + async addLevelFirst () { const _form = { pid: this.form.pid, // 上级类别ID categoryName: this.form.categoryName // 类别名称 @@ -254,7 +241,7 @@ export default { async addLevelChild () { const _form = { ruleName: this.form.ruleName, - pid: this.form.pid, + pid: this.form.newPid, pointValue: this.form.pointValue, applyFlag: this.form.applyFlag } @@ -273,28 +260,7 @@ export default { }) this.btnLoading = false }, - async editCate () { - const _form = { - customerId: localStorage.getItem('customerId'), - categoryName: this.form.categoryName, - level: this.form.level, - pointValue: this.form.pointValue - } - await this.$http - .post('/heart/icresidemanddict/update', _form) - .then(({ data: res }) => { - if (res.code !== 0) { - return this.$message.error(res.msg) - } else { - this.dialogVisible = false - this.getTableData() - } - }) - .catch(() => { - return this.$message.error('网络错误') - }) - this.btnLoading = false - }, + // 提交按钮 handleSUbmit () { this.$refs.ruleForm.validate(async (valid) => { if (valid) { @@ -309,30 +275,55 @@ export default { return false; } }); - }, - handleDel (row) { - let params = { - formCode: 'resi_base_info', - icResiUserId: row.icResiUserId + // 修改提交 ---------------这里还没做 + async editCate () { + const _form = { + categoryName: this.form.categoryName, + level: this.form.level, + pointValue: this.form.pointValue } - console.log('row1', row) - this.$http - .post('/epmetuser/icresiuser/delete', params) + await this.$http + .post('/heart/icresidemanddict/update', _form) .then(({ data: res }) => { - console.log('row2', row) if (res.code !== 0) { return this.$message.error(res.msg) } else { - console.log('row3', row) - this.$message.success('删除成功') + this.dialogVisible = false this.getTableData() } }) - .catch((err) => { - console.log('row4', err) + .catch(() => { return this.$message.error('网络错误') }) + this.btnLoading = false + }, + // 删除 + handleDel (row) { + this.$confirm("确认删除?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }).then(() => { + let params = [row.id] + console.log('row1', row) + this.$http.post('/point/additiverule/delete', params) + .then(({ data: res }) => { + if (res.code !== 0) { + return this.$message.error(res.msg) + } else { + console.log('row3', row) + this.$message.success('删除成功') + this.getTableData() + } + }) + .catch((err) => { + console.log('row4', err) + return this.$message.error('网络错误') + }) + }).catch(err => { + console.log(err) + }); }, // 查询积分类别规则列表 async getTableData () { @@ -343,13 +334,19 @@ export default { return this.$message.error(res.msg) } else { let list = [] - res.data.forEach(element => { - if (element.pid === '0') { // 一级组织 - element.children = [] - list.push(element) - } - }); - if (list.length > 0) { + if (res.data.length > 0) { + res.data.forEach(element => { // 一级循环 + if (element.pid === '0') { + element.children = [] + list.push(element) + this.typeList.push({ //类别 + value: element.id, + label: element.categoryName + }) + } + }); + } + if (list.length > 0) { // 二级循环 res.data.forEach(element => { if (element.pid) { list.forEach((item, index) => { @@ -361,8 +358,7 @@ export default { } }); } - - if (list.length > 0) { + if (list.length > 0) { // 三级循环 res.data.forEach(element => { if (element.pid) { list.forEach((item, index) => { @@ -392,7 +388,6 @@ export default { }) this.tableLoading = false } - } } @@ -422,6 +417,14 @@ export default { margin-left: 10px; color: rgba(213, 16, 16, 1); } + ::v-deep .btn-color-2j { + margin-left: 10px; + color: #fdaf30; + } + ::v-deep .btn-color-1j { + margin-left: 10px; + color: #3cb357; + } ::v-deep .btn-color-edit { color: rgba(0, 167, 169, 1); }