Commit ca67a4b4 by yugujie

update: actcode

parent 8ade44ab
...@@ -4,4 +4,13 @@ import { postRequest } from '@/api/api'; ...@@ -4,4 +4,13 @@ import { postRequest } from '@/api/api';
export const findActCodeGroupListApi = params => postRequest('/hm/group/list', params); export const findActCodeGroupListApi = params => postRequest('/hm/group/list', params);
// 新增活码分组 // 新增活码分组
export const addActCodeGroup = params => postRequest('/hm/group/save', params); export const addActCodeGroupApi = params => postRequest('/hm/group/save', params);
// 编辑活码分组
export const editActCodeGroupApi = params => postRequest('/hm/group/edit', params);
// 删除分组
export const delActCodeGroupApi = params => postRequest('/hm/group/delete', params);
// 活码列表
export const actCodeListApi = params => postRequest('', params);
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</div> </div>
<el-popover placement="bottom" trigger="hover" v-if="isShowGroupListItemMore(listItem)"> <el-popover placement="bottom" trigger="hover" v-if="isShowGroupListItemMore(listItem)">
<p class="more" @click="editGroupListItem(listItem)">编辑</p> <p class="more" @click="editGroupListItem(listItem)">编辑</p>
<p class="more" @click="delGroupListItem(listItem)">删除</p> <p class="more" @click="delGroupListItem(listItem)" v-if="!listItem.releationNum">删除</p>
<i slot="reference" class="iconfont-hb3 icongengduo icon"></i> <i slot="reference" class="iconfont-hb3 icongengduo icon"></i>
</el-popover> </el-popover>
</li> </li>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<el-button type="primary" class="ghost-btn add-group" @click="addGroup">新增分组</el-button> <el-button type="primary" class="ghost-btn add-group" @click="addGroup">新增分组</el-button>
</div> </div>
<!-- 新增/编辑分组 --> <!-- 新增/编辑分组 -->
<el-dialog :title="title" :visible.sync="addOrEditGroupDialog" width="500px" top="30vh" :close-on-click-modal="false"> <el-dialog :title="isEditGroup ? '编辑分组' : '新增分组'" :visible.sync="addOrEditGroupDialog" width="500px" top="30vh" :close-on-click-modal="false">
<el-form :model="groupListForm" :rules="groupListFormRules" ref="groupListForm"> <el-form :model="groupListForm" :rules="groupListFormRules" ref="groupListForm">
<el-form-item label="分组名称" prop="groupName"> <el-form-item label="分组名称" prop="groupName">
<el-input placeholder="请输入分组名称" v-model="groupListForm.groupName" :maxlength="10" show-word-limit clearable></el-input> <el-input placeholder="请输入分组名称" v-model="groupListForm.groupName" :maxlength="10" show-word-limit clearable></el-input>
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
</template> </template>
<script> <script>
import { findActCodeGroupListApi, addActCodeGroup } from '@/api/actCode.js'; import { findActCodeGroupListApi, addActCodeGroupApi, editActCodeGroupApi, delActCodeGroupApi } from '@/api/actCode.js';
export default { export default {
name: 'staffActCodeGroupList', name: 'staffActCodeGroupList',
data() { data() {
...@@ -118,7 +118,12 @@ export default { ...@@ -118,7 +118,12 @@ export default {
return !hiddenListItemMore.includes(listItem.groupId); return !hiddenListItemMore.includes(listItem.groupId);
}, },
addGroup() { addGroup() {
this.scrollLoad = false;
this.isEditGroup = false; this.isEditGroup = false;
this.groupListForm = {
groupName: '',
groupId: ''
};
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.groupListForm.clearValidate(); this.$refs.groupListForm.clearValidate();
}); });
...@@ -142,33 +147,56 @@ export default { ...@@ -142,33 +147,56 @@ export default {
// 删除操作 // 删除操作
const listItemIndex = this.groupList.findIndex(item => item.groupId === listItem.groupId); const listItemIndex = this.groupList.findIndex(item => item.groupId === listItem.groupId);
if (listItemIndex < 0) return; if (listItemIndex < 0) return;
this.groupList.splice(listItemIndex, 1);
})
.catch(() => {});
},
handleGroupListItem() {
this.$refs.groupListForm.validate(valid => {
if (valid) {
let params = { let params = {
groupName: this.groupListForm.groupName groupId: listItem.groupId
}; };
addActCodeGroup(params).then(res => { delActCodeGroupApi(params).then(res => {
if (res.errorCode == 0) { if (res.errorCode == 0) {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '新增成功', message: '删除成功!'
duration: 1000
}); });
this.groupList.splice(listItemIndex, 1);
}
});
})
.catch(() => {});
},
handleGroupListItem() {
this.$refs.groupListForm.validate(async valid => {
if (valid) {
// 用来接收编辑或者新增后的返回结果
let res = {};
let resSucTip = `${this.isEditGroup ? '修改' : '新增'}成功`;
let resErTip = `${this.isEditGroup ? '修改' : '新增'}失败`;
if (this.isEditGroup) {
res = await editActCodeGroupApi(this.groupListForm);
} else {
let params = {
groupName: this.groupListForm.groupName
};
res = await addActCodeGroupApi(params);
}
if (res.errorCode == 0) {
this.$message({
type: 'success',
message: resSucTip,
duration: 1000
});
if (this.isEditGroup) {
const groupListItem = this.groupList.find(({ groupId }) => groupId == this.groupListForm.groupId);
groupListItem.groupName = this.groupListForm.groupName;
} else {
this.pageNum = 1; this.pageNum = 1;
this.searchGroup(); this.searchGroup();
} else {
this.$message({
type: 'error',
message: res.message || '新增失败'
});
} }
this.editDialog.visible = false; this.addOrEditGroupDialog = false;
}); } else {
this.$message({
type: 'error',
message: resErTip
});
}
} }
}); });
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment