合作伙伴的添加删除

This commit is contained in:
熊丽君
2021-10-27 15:40:13 +08:00
parent 5c9f7730cd
commit 11dc40aac7
2 changed files with 87 additions and 41 deletions

36
src/api/asdm/partner.js Normal file
View File

@ -0,0 +1,36 @@
import request from '@/utils/request';
// 获取合作伙伴列表
export function getList(params) {
return request({
url: '/partner/getList',
params
});
}
// 添加合作伙伴
export function addPartner(data) {
return request({
url: '/partner/addPartner',
method: 'post',
data
});
}
// 修改合作伙伴
export function updatePartner(data) {
return request({
url: '/partner/updatePartner',
method: 'post',
data
});
}
// 批量删除合作伙伴 body ids
export function delPartner(data) {
return request({
url: '/partner/delPartner',
method: 'post',
data
});
}

View File

@ -13,15 +13,24 @@
align="center"
type="index"
></el-table-column>
<el-table-column label="合作伙伴Logo" prop="pic" align="center">
<el-table-column label="合作伙伴Logo" prop="img" align="center">
<template slot-scope="scope">
<el-image
style="width: 100px; height: 100px"
:src="scope.row.pic"
style="width: 150px; height: 70px"
:src="scope.row.img"
fit="cover">
</el-image>
</template>
</el-table-column>
<el-table-column
label="是否显示"
align="center"
prop="status"
>
<template slot-scope="scope">
{{scope.row.status=='1'?'显示':'不显示'}}
</template>
</el-table-column>
<el-table-column
label="创建时间"
align="center"
@ -32,9 +41,9 @@
<el-button @click="handleUpdate(scope.row)" type="text" size="small"
>编辑</el-button
>
<el-button @click="handleDelete(scope.row.id)" type="text" size="small"
<!-- <el-button @click="handleDelete(scope.row.partnerId)" type="text" size="small"
>删除</el-button
>
> -->
</template>
</el-table-column>
</el-table>
@ -48,15 +57,22 @@
<el-dialog
title="合作伙伴Logo"
:visible.sync="dialogVisible"
width="30%">
width="32%">
<el-form
:model="ruleForm"
ref="ruleForm"
:rules="rules"
label-width="80px"
label-width="100px"
>
<el-form-item label="Logo" prop="pic">
<multi-upload v-model="selectProductPics" :maxCount="this.ruleForm.id?1:2"></multi-upload>
<el-form-item label="是否显示:">
<el-radio-group v-model="ruleForm.status">
<el-radio label="1">是</el-radio>
<el-radio label="0">否</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="Logo" prop="img">
<multi-upload v-model="selectProductPics" :maxCount="1"></multi-upload>
<span style="color:#999"> 建议上传144*70分辨率的照片</span>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
@ -67,8 +83,12 @@
</div>
</template>
<script>
import { getRotationList,addRotation, deleteRotation, updateRotation } from '@/api/rotation';
import { getList,addPartner, delPartner, updatePartner } from '@/api/asdm/partner';
import MultiUpload from '@/components/Upload/multiUpload';
const defaultParams = {
img: '',
status: '1',
};
export default {
components: {
MultiUpload
@ -82,13 +102,9 @@ export default {
total: 0,
rotationList: [],
dialogVisible: false,
ruleForm: {
url: '',
pic: ''
},
ruleForm: Object.assign({},defaultParams),
rules: {
url: [{ required: true, message: '请输入', trigger: 'blur' }],
pic: [{ required: true, message: '请上传', trigger: 'blur' }]
img: [{ required: true, message: '请上传', trigger: 'blur' }]
}
};
},
@ -98,13 +114,13 @@ export default {
get: function() {
let pics = [];
if (
this.ruleForm.pic === undefined ||
this.ruleForm.pic == null ||
this.ruleForm.pic === ''
this.ruleForm.img === undefined ||
this.ruleForm.img == null ||
this.ruleForm.img === ''
) {
return pics;
}
pics.push(this.ruleForm.pic);
pics.push(this.ruleForm.img);
if (
this.ruleForm.albumPics === undefined ||
this.ruleForm.albumPics == null ||
@ -120,10 +136,10 @@ export default {
},
set: function(newValue) {
if (newValue == null || newValue.length === 0) {
this.ruleForm.pic = null;
this.ruleForm.img = null;
this.ruleForm.albumPics = null;
} else {
this.ruleForm.pic = newValue[0];
this.ruleForm.img = newValue[0];
// this.ruleForm.picList = newValue;
this.ruleForm.albumPics = '';
if (newValue.length > 1) {
@ -140,15 +156,13 @@ export default {
},
methods: {
getList() {
getRotationList(this.queryParams).then(({ data }) => {
getList(this.queryParams).then(({ data }) => {
this.rotationList = data.list;
this.total = data.total
});
},
open(){
this.ruleForm={
pic: ''
},
this.ruleForm = Object.assign({}, defaultParams),
this.dialogVisible = true
},
handleUpdate(row){
@ -158,23 +172,17 @@ export default {
submitForm(formName){
this.$refs[formName].validate(valid=>{
if(valid){
if(this.ruleForm.id){
updateRotation(this.ruleForm).then(res=>{
if(this.ruleForm.partnerId){
updatePartner(this.ruleForm).then(res=>{
this.msgSuccess(res.data)
this.ruleForm = {
url: '',
pic: ''
}
this.ruleForm = Object.assign({}, defaultParams),
this.getList()
this.dialogVisible = false
})
}else{
addRotation(this.ruleForm).then(res=>{
addPartner(this.ruleForm).then(res=>{
this.msgSuccess(res.data)
this.ruleForm = {
url: '',
pic: ''
}
this.ruleForm = Object.assign({}, defaultParams),
this.getList()
this.dialogVisible = false
})
@ -191,7 +199,7 @@ export default {
type: 'warning'
})
.then(function() {
return deleteRotation({id});
return delPartner({ids:[id]});
})
.then(() => {
this.getList();
@ -205,7 +213,9 @@ export default {
};
</script>
<style lang="scss" scoped>
// .el-tag + .el-tag {
// margin-left: 10px;
// }
.el-table{
/deep/td{
padding: 0 !important;
}
}
</style>