1231233
This commit is contained in:
@@ -20,7 +20,7 @@ export function getDynamic(id) {
|
||||
// 新增主播动态
|
||||
export function addDynamic(data) {
|
||||
return request({
|
||||
url: '/cai/dynamic',
|
||||
url: '/cai/dynamic/create',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
|
||||
@@ -64,6 +64,18 @@ export function getFullUser(id) {
|
||||
})
|
||||
}
|
||||
|
||||
export function listUserByAnchorUserCode(usercode) {
|
||||
return request({
|
||||
url: '/cai/user/listByUserCode',
|
||||
method: 'get',
|
||||
params:{
|
||||
usercode: usercode,
|
||||
isAnchor: 1,
|
||||
limit: 40
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function listUserByUserCode(usercode) {
|
||||
return request({
|
||||
url: '/cai/user/listByUserCode',
|
||||
|
||||
@@ -94,16 +94,20 @@ export default {
|
||||
watch: {
|
||||
value: {
|
||||
async handler(val) {
|
||||
console.log("数据变化前",val,this.fileList);
|
||||
if (val) {
|
||||
// 首先将值转为数组
|
||||
let list;
|
||||
if (Array.isArray(val)) {
|
||||
list = val;
|
||||
} else {
|
||||
list = [{
|
||||
url: store.getters.filePrefix + val,
|
||||
ossId: val,
|
||||
path: val }];
|
||||
let listNames = val.split(",");
|
||||
list = listNames.map(item => {
|
||||
return {
|
||||
url: store.getters.filePrefix + item,
|
||||
ossId: item,
|
||||
path: item }
|
||||
})
|
||||
}
|
||||
// 然后将数组转为对象数组
|
||||
this.fileList = list.map(item => {
|
||||
@@ -116,6 +120,7 @@ export default {
|
||||
this.fileList = [];
|
||||
return [];
|
||||
}
|
||||
console.log("数据变化后",this.fileList);
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
|
||||
104
src/views/cai/dynamicSuccess/dynamic-add-dialog.vue
Normal file
104
src/views/cai/dynamicSuccess/dynamic-add-dialog.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :close-on-click-modal="false" :visible.sync="open" width="700px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="图片" prop="imageList">
|
||||
<image-upload2 v-model="form.imageList" :limit="6"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="内容" prop="content">
|
||||
<el-input type="textarea" v-model="form.content" placeholder="内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="主播编号" prop="usercode">
|
||||
<el-autocomplete
|
||||
class="inline-input"
|
||||
v-model="form.usercode"
|
||||
:fetch-suggestions="querySearch"
|
||||
placeholder="请输入内容"
|
||||
@select="handleSelect"
|
||||
></el-autocomplete>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="open = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {enableStatusList, versionPlatformList, yesOrNoList} from '@/constant/statusMap'
|
||||
import {addDynamic} from "@/api/cai/dynamic";
|
||||
import {getUserByUsercode, listUserByAnchorUserCode} from "@/api/cai/user";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
versionPlatformList,yesOrNoList,enableStatusList,
|
||||
open: false,
|
||||
title: '',
|
||||
form:{
|
||||
imageList: undefined,
|
||||
content: undefined,
|
||||
usercode: undefined,
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
imageList: [
|
||||
{ required: true, message: "数据不能为空", trigger: "blur" }
|
||||
],
|
||||
content: [
|
||||
{ required: true, message: "数据不能为空", trigger: "blur" }
|
||||
],
|
||||
usercode: [
|
||||
{ required: true, message: "数据不能为空", trigger: "blur" }
|
||||
],
|
||||
},
|
||||
buttonLoading: false,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
init (id) {
|
||||
this.form.id = id || undefined;
|
||||
this.title = "新增动态";
|
||||
this.open = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs['form'].resetFields();
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
submitForm () {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.buttonLoading = true;
|
||||
addDynamic(this.form).then(data => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.buttonLoading = false;
|
||||
this.open = false
|
||||
this.$emit('refreshDataList')
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
handleSelect(item){
|
||||
getUserByUsercode(item.value).then(res => {
|
||||
this.info = res.data
|
||||
})
|
||||
},
|
||||
querySearch(querySearch,cb){
|
||||
listUserByAnchorUserCode(querySearch).then(res => {
|
||||
cb(res.data.map((terminal) => {
|
||||
return {
|
||||
value: terminal,
|
||||
name: terminal,
|
||||
};
|
||||
}))
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -23,6 +23,18 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="dynamicList" @selection-change="handleSelectionChange">
|
||||
<el-table-column label="ID" align="center" prop="id"/>
|
||||
<el-table-column label="置顶" align="center" prop="sort">
|
||||
@@ -71,6 +83,7 @@
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
<dynamic-add-dialog v-if="addDialogVisible" ref="addDialog" @refreshDataList="getList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -85,13 +98,16 @@ import {
|
||||
updateDynamic
|
||||
} from "@/api/cai/dynamic";
|
||||
import {auditStatusList} from "@/constant/statusMap";
|
||||
import DynamicAddDialog from "@/views/cai/dynamicSuccess/dynamic-add-dialog.vue";
|
||||
|
||||
export default {
|
||||
name: "Dynamic",
|
||||
components: {DynamicAddDialog},
|
||||
data() {
|
||||
return {
|
||||
systemName: process.env.VUE_APP_SYSTEM_HOME,
|
||||
auditStatusList,
|
||||
addDialogVisible: false,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
@@ -147,6 +163,12 @@ export default {
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
handleAdd(){
|
||||
this.addDialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addDialog.init()
|
||||
})
|
||||
},
|
||||
handleAudit(row,auditStatus){
|
||||
let message = auditStatus === 3 ? "通过" : "不通过";
|
||||
this.$modal.confirm('是否确认'+message+'动态编号为"' + row.id + '"的数据项?').then(() => {
|
||||
|
||||
Reference in New Issue
Block a user