合作伙伴的添加删除

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