liaoxiping
4 years ago
356 changed files with 86715 additions and 84650 deletions
@ -0,0 +1,58 @@
|
||||
import axiosApi from './AxiosApi.js' |
||||
|
||||
const apiList = { |
||||
page: { |
||||
method: 'POST', |
||||
url: `/information/list`, |
||||
}, |
||||
update: { |
||||
method: 'PUT', |
||||
url: `/information` |
||||
}, |
||||
save: { |
||||
method: 'POST', |
||||
url: `/information` |
||||
}, |
||||
delete: { |
||||
method: 'DELETE', |
||||
url: `/information` |
||||
}, |
||||
} |
||||
|
||||
export default { |
||||
page (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.page, |
||||
data, |
||||
custom |
||||
}) |
||||
}, |
||||
// query (data, custom = {}) {
|
||||
// return axiosApi({
|
||||
// ...apiList.query,
|
||||
// data,
|
||||
// custom
|
||||
// })
|
||||
// },
|
||||
save (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.save, |
||||
data, |
||||
custom |
||||
}) |
||||
}, |
||||
update (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.update, |
||||
data, |
||||
custom |
||||
}) |
||||
}, |
||||
delete (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.delete, |
||||
data, |
||||
custom |
||||
}) |
||||
}, |
||||
} |
@ -0,0 +1,96 @@
|
||||
import axiosApi from './AxiosApi.js' |
||||
|
||||
const apiList = { |
||||
page: { |
||||
method: 'POST', |
||||
url: `/brand/page`, |
||||
}, |
||||
query: { |
||||
method: 'POST', |
||||
url: `/brand/query`, |
||||
}, |
||||
update: { |
||||
method: 'PUT', |
||||
url: `/brand` |
||||
}, |
||||
save: { |
||||
method: 'POST', |
||||
url: `/brand` |
||||
}, |
||||
delete: { |
||||
method: 'DELETE', |
||||
url: `/brand` |
||||
}, |
||||
export: { |
||||
method: 'POST', |
||||
url: `/brand/export` |
||||
}, |
||||
preview: { |
||||
method: 'POST', |
||||
url: `/brand/preview` |
||||
}, |
||||
import: { |
||||
method: 'POST', |
||||
url: `/brand/import` |
||||
} |
||||
} |
||||
|
||||
export default { |
||||
page (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.page, |
||||
data, |
||||
custom |
||||
}) |
||||
}, |
||||
query (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.query, |
||||
data, |
||||
custom |
||||
}) |
||||
}, |
||||
save (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.save, |
||||
data, |
||||
custom |
||||
}) |
||||
}, |
||||
update (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.update, |
||||
data, |
||||
custom |
||||
}) |
||||
}, |
||||
delete (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.delete, |
||||
data, |
||||
custom |
||||
}) |
||||
}, |
||||
export (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.export, |
||||
responseType: "blob", |
||||
data, |
||||
custom |
||||
}) |
||||
}, |
||||
preview (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.preview, |
||||
data, |
||||
custom |
||||
}) |
||||
}, |
||||
import (data, custom = {}) { |
||||
return axiosApi({ |
||||
...apiList.import, |
||||
data, |
||||
custom |
||||
}) |
||||
} |
||||
} |
@ -0,0 +1,225 @@
|
||||
<template> |
||||
<el-dialog :close-on-click-modal="false" :close-on-press-escape="true" :title="title" :type="type" |
||||
:visible.sync="isVisible" :width="width" top="50px" v-el-drag-dialog> |
||||
<el-form :model="brand" :rules="rules" label-position="right" label-width="100px" ref="form"> |
||||
<el-form-item :label="$t('table.brand.name')" prop="name"> |
||||
<el-input type="" v-model="brand.name" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.image')" prop="image"> |
||||
<!-- <el-input type="" v-model="brand.image" placeholder=""/> --> |
||||
<el-upload |
||||
class="avatar-uploader" |
||||
:headers="headers" |
||||
:data="dataObj" |
||||
:action="action" |
||||
:show-file-list="false" |
||||
:on-success="handleAvatarSuccess" |
||||
> |
||||
<el-button size="small" type="primary" |
||||
>点击上传</el-button |
||||
> |
||||
</el-upload> |
||||
<img |
||||
style="margin-top:5px" |
||||
v-if="brand.image" |
||||
:src="brand.image" |
||||
class="avatar" |
||||
width="80" |
||||
height="80" |
||||
/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.video')" prop="video"> |
||||
<el-input type="" v-model="brand.video" placeholder=""/> |
||||
|
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.desc')" prop="desc"> |
||||
<el-input type="" v-model="brand.desc" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.content')" prop="content"> |
||||
<!-- <el-input type="" v-model="brand.content" placeholder=""/> --> |
||||
<Tinymce ref="content" v-if="isVisible" v-model="brand.content" :height="200" /> |
||||
</el-form-item> |
||||
<!-- <el-form-item :label="$t('table.brand.sort')" prop="sort"> |
||||
<el-input type="" v-model="brand.sort" placeholder=""/> |
||||
</el-form-item> --> |
||||
</el-form> |
||||
<div class="dialog-footer" slot="footer"> |
||||
<el-button @click="isVisible = false" plain type="warning"> |
||||
{{ $t("common.cancel") }} |
||||
</el-button> |
||||
<el-button @click="submitForm" :disabled="confirmDisabled" plain type="primary"> |
||||
{{ $t("common.confirm") }} |
||||
</el-button> |
||||
</div> |
||||
</el-dialog> |
||||
</template> |
||||
<script> |
||||
import elDragDialog from '@/directive/el-drag-dialog' |
||||
import brandApi from "@/api/Brand.js"; |
||||
import db from '@/utils/localstorage' |
||||
import Tinymce from '@/components/Tinymce' |
||||
export default { |
||||
name: "BrandEdit", |
||||
directives: { elDragDialog }, |
||||
components: {Tinymce }, |
||||
props: { |
||||
dialogVisible: { |
||||
type: Boolean, |
||||
default: false |
||||
}, |
||||
type: { |
||||
type: String, |
||||
default: "add" |
||||
} |
||||
}, |
||||
data() { |
||||
return { |
||||
confirmDisabled: false, |
||||
brand: this.initBrand(), |
||||
screenWidth: 0, |
||||
width: this.initWidth(), |
||||
rules: { |
||||
|
||||
}, |
||||
// 枚举 |
||||
enums: { |
||||
}, |
||||
// 字典 |
||||
dicts: { |
||||
}, |
||||
//图片上传 |
||||
headers: { |
||||
Authorization: '', |
||||
}, |
||||
action: `${process.env.VUE_APP_DEV_REQUEST_DOMAIN_PREFIX}/file/upload`, |
||||
dataObj: { |
||||
folderId: 1 |
||||
}, |
||||
fileList: [] |
||||
}; |
||||
}, |
||||
computed: { |
||||
isVisible: { |
||||
get() { |
||||
return this.dialogVisible; |
||||
}, |
||||
set() { |
||||
this.close(); |
||||
this.reset(); |
||||
} |
||||
}, |
||||
title() { |
||||
return this.$t("common." + this.type); |
||||
} |
||||
}, |
||||
watch: {}, |
||||
created() { |
||||
this.headers.token = 'Bearer ' + db.get('TOKEN', '') |
||||
this.headers.tenant = 'MDAwMA==' |
||||
}, |
||||
mounted() { |
||||
window.onresize = () => { |
||||
return (() => { |
||||
this.width = this.initWidth(); |
||||
})(); |
||||
}; |
||||
}, |
||||
methods: { |
||||
handleAvatarSuccess (response) { |
||||
const { url } = response.data |
||||
this.brand.image = url |
||||
console.log(response,"response") |
||||
}, |
||||
initBrand() { |
||||
return { |
||||
id: "", |
||||
name: '', |
||||
image: '', |
||||
video: '', |
||||
desc: '', |
||||
content: '', |
||||
sort: 50, |
||||
}; |
||||
}, |
||||
initWidth() { |
||||
this.screenWidth = document.body.clientWidth; |
||||
if (this.screenWidth < 991) { |
||||
return "90%"; |
||||
} else if (this.screenWidth < 1400) { |
||||
return "45%"; |
||||
} else { |
||||
return "800px"; |
||||
} |
||||
}, |
||||
setBrand(val = {}) { |
||||
const vm = this; |
||||
|
||||
vm.dicts = val['dicts']; |
||||
vm.enums = val['enums']; |
||||
if (val['row']) { |
||||
vm.brand = { ...val['row'] }; |
||||
|
||||
} |
||||
}, |
||||
close() { |
||||
this.$emit("close"); |
||||
}, |
||||
reset() { |
||||
// 先清除校验,再清除表单,不然有奇怪的bug |
||||
this.$refs.form.clearValidate(); |
||||
this.$refs.form.resetFields(); |
||||
this.confirmDisabled = false; |
||||
this.brand = this.initBrand(); |
||||
}, |
||||
submitForm() { |
||||
const vm = this; |
||||
this.$refs.form.validate(valid => { |
||||
if (valid) { |
||||
vm.editSubmit(); |
||||
} else { |
||||
return false; |
||||
} |
||||
}); |
||||
}, |
||||
editSubmit() { |
||||
const vm = this; |
||||
if (vm.type === "edit") { |
||||
vm.update(); |
||||
} else { |
||||
vm.save(); |
||||
} |
||||
}, |
||||
save() { |
||||
const vm = this; |
||||
vm.confirmDisabled = true; |
||||
brandApi.save(this.brand).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
vm.isVisible = false; |
||||
vm.$message({ |
||||
message: vm.$t("tips.createSuccess"), |
||||
type: "success" |
||||
}); |
||||
vm.$emit("success"); |
||||
} |
||||
}).finally(()=> vm.confirmDisabled = false); |
||||
}, |
||||
update() { |
||||
const vm = this; |
||||
vm.confirmDisabled = true; |
||||
brandApi.update(this.brand).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
vm.isVisible = false; |
||||
vm.$message({ |
||||
message: this.$t("tips.updateSuccess"), |
||||
type: "success" |
||||
}); |
||||
vm.$emit("success"); |
||||
} |
||||
}).finally(()=> vm.confirmDisabled = false); |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped></style> |
@ -0,0 +1,352 @@
|
||||
<template> |
||||
<div class="app-container"> |
||||
<div class="filter-container"> |
||||
|
||||
<el-date-picker :range-separator="null" class="filter-item search-item date-range-item" |
||||
end-placeholder="结束日期" format="yyyy-MM-dd HH:mm:ss" start-placeholder="开始日期" |
||||
type="daterange" v-model="queryParams.timeRange" value-format="yyyy-MM-dd HH:mm:ss" |
||||
/> |
||||
<el-button @click="search" class="filter-item" plain type="primary"> |
||||
{{ $t("table.search") }} |
||||
</el-button> |
||||
<el-button @click="reset" class="filter-item" plain type="warning"> |
||||
{{ $t("table.reset") }} |
||||
</el-button> |
||||
<el-button @click="add" class="filter-item" plain type="danger" v-has-permission="['brand:add']"> |
||||
{{ $t("table.add") }} |
||||
</el-button> |
||||
<el-dropdown class="filter-item" trigger="click" v-has-any-permission="['brand:delete', 'brand:export', |
||||
'brand:import']"> |
||||
<el-button> |
||||
{{ $t("table.more") }}<i class="el-icon-arrow-down el-icon--right" /> |
||||
</el-button> |
||||
<el-dropdown-menu slot="dropdown"> |
||||
<el-dropdown-item @click.native="batchDelete" v-has-permission="['brand:delete']"> |
||||
{{ $t("table.delete") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="exportExcel" v-has-permission="['brand:export']"> |
||||
{{ $t("table.export") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="exportExcelPreview" v-has-permission="['brand:export']"> |
||||
{{ $t("table.exportPreview") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="importExcel" v-has-permission="['brand:import']"> |
||||
{{ $t("table.import") }} |
||||
</el-dropdown-item> |
||||
</el-dropdown-menu> |
||||
</el-dropdown> |
||||
</div> |
||||
|
||||
<el-table :data="tableData.records" :key="tableKey" @cell-click="cellClick" |
||||
@filter-change="filterChange" @selection-change="onSelectChange" @sort-change="sortChange" |
||||
border fit row-key="id" ref="table" style="width: 100%;" v-loading="loading"> |
||||
<el-table-column align="center" type="selection" width="40px" :reserve-selection="true"/> |
||||
<el-table-column :label="$t('table.brand.name')" :show-overflow-tooltip="true" align="center" prop="name" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.name }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.brand.image')" :show-overflow-tooltip="true" align="center" prop="image" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<!-- <span>{{ scope.row.image }}</span> --> |
||||
<img |
||||
v-if="scope.row.image" |
||||
:src="scope.row.image" |
||||
class="avatar" |
||||
width="80" |
||||
height="80" |
||||
/> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.brand.video')" :show-overflow-tooltip="true" align="center" prop="video" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.video }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.brand.desc')" :show-overflow-tooltip="true" align="center" prop="desc" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.desc }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.brand.content')" :show-overflow-tooltip="true" align="center" prop="content" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.content }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.brand.sort')" :show-overflow-tooltip="true" align="center" prop="sort" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.sort }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column |
||||
:label="$t('table.createTime')" |
||||
align="center" |
||||
prop="createTime" |
||||
sortable="custom" |
||||
width="170px"> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.createTime }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column |
||||
:label="$t('table.operation')" align="center" column-key="operation" class-name="small-padding fixed-width" width="100px"> |
||||
<template slot-scope="{ row }"> |
||||
<i @click="copy(row)" class="el-icon-copy-document table-operation" :title="$t('common.delete')" |
||||
style="color: #2db7f5;" v-hasPermission="['brand:add']"/> |
||||
<i @click="edit(row)" class="el-icon-edit table-operation" :title="$t('common.delete')" |
||||
style="color: #2db7f5;" v-hasPermission="['brand:update']"/> |
||||
<i @click="singleDelete(row)" class="el-icon-delete table-operation" :title="$t('common.delete')" |
||||
style="color: #f50;" v-hasPermission="['brand:delete']"/> |
||||
<el-link class="no-perm" v-has-no-permission="['brand:update', 'brand:copy', 'brand:delete']"> |
||||
{{ $t("tips.noPermission") }} |
||||
</el-link> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<pagination :limit.sync="queryParams.size" :page.sync="queryParams.current" |
||||
:total="Number(tableData.total)" @pagination="fetch" v-show="tableData.total > 0"/> |
||||
<brand-edit :dialog-visible="dialog.isVisible" :type="dialog.type" |
||||
@close="editClose" @success="editSuccess" ref="edit"/> |
||||
|
||||
<el-dialog :close-on-click-modal="false" :close-on-press-escape="true" |
||||
title="预览" width="80%" top="50px" :visible.sync="preview.isVisible" v-el-drag-dialog> |
||||
<el-scrollbar> |
||||
<div v-html="preview.context"></div> |
||||
</el-scrollbar> |
||||
</el-dialog> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import Pagination from "@/components/Pagination"; |
||||
import elDragDialog from '@/directive/el-drag-dialog' |
||||
import BrandEdit from "./Edit"; |
||||
import brandApi from "@/api/Brand.js"; |
||||
import {convertEnum} from '@/utils/utils' |
||||
import {downloadFile, loadEnums, initDicts, initQueryParams} from '@/utils/commons' |
||||
|
||||
export default { |
||||
name: "BrandManage", |
||||
directives: { elDragDialog }, |
||||
components: { Pagination, BrandEdit}, |
||||
filters: { |
||||
|
||||
}, |
||||
data() { |
||||
return { |
||||
// 编辑 |
||||
dialog: { |
||||
isVisible: false, |
||||
type: "add" |
||||
}, |
||||
// 预览 |
||||
preview: { |
||||
isVisible: false, |
||||
context: '' |
||||
}, |
||||
// 导入 |
||||
fileImport: { |
||||
isVisible: false, |
||||
type: "import", |
||||
action: `${process.env.VUE_APP_BASE_API}/brand/brand/import` |
||||
}, |
||||
tableKey: 0, |
||||
queryParams: initQueryParams(), |
||||
selection: [], |
||||
loading: false, |
||||
tableData: { |
||||
total: 0 |
||||
}, |
||||
// 枚举 |
||||
enums: { |
||||
}, |
||||
// 字典 |
||||
dicts: { |
||||
} |
||||
}; |
||||
}, |
||||
computed: { |
||||
}, |
||||
watch: { |
||||
}, |
||||
mounted() { |
||||
this.fetch(); |
||||
|
||||
// 初始化字典和枚举 |
||||
const enumList = []; |
||||
const dictList = []; |
||||
loadEnums(enumList, this.enums, 'brand'); |
||||
initDicts(dictList, this.dicts); |
||||
}, |
||||
methods: { |
||||
editClose() { |
||||
this.dialog.isVisible = false; |
||||
}, |
||||
editSuccess() { |
||||
this.search(); |
||||
}, |
||||
onSelectChange(selection) { |
||||
this.selection = selection; |
||||
}, |
||||
search() { |
||||
this.fetch({ |
||||
...this.queryParams |
||||
}); |
||||
}, |
||||
reset() { |
||||
this.queryParams = initQueryParams(); |
||||
this.$refs.table.clearSort(); |
||||
this.$refs.table.clearFilter(); |
||||
this.search(); |
||||
}, |
||||
exportExcelPreview() { |
||||
if (this.queryParams.timeRange) { |
||||
this.queryParams.map.createTime_st = this.queryParams.timeRange[0]; |
||||
this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]; |
||||
} |
||||
this.queryParams.map.fileName = '导出数据'; |
||||
brandApi.preview(this.queryParams).then(response => { |
||||
const res = response.data; |
||||
this.preview.isVisible = true; |
||||
this.preview.context = res.data; |
||||
}); |
||||
}, |
||||
exportExcel() { |
||||
if (this.queryParams.timeRange) { |
||||
this.queryParams.map.createTime_st = this.queryParams.timeRange[0]; |
||||
this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]; |
||||
} |
||||
this.queryParams.map.fileName = '导出数据'; |
||||
brandApi.export(this.queryParams).then(response => { |
||||
downloadFile(response); |
||||
}); |
||||
}, |
||||
importExcel() { |
||||
this.fileImport.type = "upload"; |
||||
this.fileImport.isVisible = true; |
||||
this.$refs.import.setModel(false); |
||||
}, |
||||
importSuccess() { |
||||
this.search(); |
||||
}, |
||||
importClose() { |
||||
this.fileImport.isVisible = false; |
||||
}, |
||||
singleDelete(row) { |
||||
this.$refs.table.clearSelection() |
||||
this.$refs.table.toggleRowSelection(row, true); |
||||
this.batchDelete(); |
||||
}, |
||||
batchDelete() { |
||||
if (!this.selection.length) { |
||||
this.$message({ |
||||
message: this.$t("tips.noDataSelected"), |
||||
type: "warning" |
||||
}); |
||||
return; |
||||
} |
||||
this.$confirm(this.$t("tips.confirmDelete"), this.$t("common.tips"), { |
||||
confirmButtonText: this.$t("common.confirm"), |
||||
cancelButtonText: this.$t("common.cancel"), |
||||
type: "warning" |
||||
}) |
||||
.then(() => { |
||||
const ids = this.selection.map(u => u.id); |
||||
this.delete(ids); |
||||
}) |
||||
.catch(() => { |
||||
this.clearSelections(); |
||||
}); |
||||
}, |
||||
clearSelections() { |
||||
this.$refs.table.clearSelection(); |
||||
}, |
||||
delete(ids) { |
||||
brandApi.delete({ ids: ids }).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
this.$message({ |
||||
message: this.$t("tips.deleteSuccess"), |
||||
type: "success" |
||||
}); |
||||
this.search(); |
||||
} |
||||
}); |
||||
}, |
||||
add() { |
||||
this.dialog.type = "add"; |
||||
this.dialog.isVisible = true; |
||||
this.$refs.edit.setBrand({ enums: this.enums, dicts: this.dicts}); |
||||
}, |
||||
copy(row) { |
||||
this.$refs.edit.setBrand({row, enums: this.enums, dicts: this.dicts}); |
||||
this.dialog.type = "copy"; |
||||
this.dialog.isVisible = true; |
||||
}, |
||||
edit(row) { |
||||
this.$refs.edit.setBrand({row, enums: this.enums, dicts: this.dicts}); |
||||
this.dialog.type = "edit"; |
||||
this.dialog.isVisible = true; |
||||
}, |
||||
fetch(params = {}) { |
||||
this.loading = true; |
||||
if (this.queryParams.timeRange) { |
||||
this.queryParams.map.createTime_st = this.queryParams.timeRange[0]; |
||||
this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]; |
||||
} |
||||
|
||||
this.queryParams.current = params.current ? params.current : this.queryParams.current; |
||||
this.queryParams.size = params.size ? params.size : this.queryParams.size; |
||||
|
||||
brandApi.page(this.queryParams).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
this.tableData = res.data; |
||||
} |
||||
}).finally(() => this.loading = false); |
||||
}, |
||||
sortChange(val) { |
||||
this.queryParams.sort = val.prop; |
||||
this.queryParams.order = val.order; |
||||
if (this.queryParams.sort) { |
||||
this.search(); |
||||
} |
||||
}, |
||||
filterChange (filters) { |
||||
for (const key in filters) { |
||||
if(key.includes('.')) { |
||||
const val = { }; |
||||
val[key.split('.')[1]] = filters[key][0]; |
||||
this.queryParams.model[key.split('.')[0]] = val; |
||||
} else { |
||||
this.queryParams.model[key] = filters[key][0] |
||||
} |
||||
} |
||||
this.search() |
||||
}, |
||||
cellClick (row, column) { |
||||
if (column['columnKey'] === "operation") { |
||||
return; |
||||
} |
||||
let flag = false; |
||||
this.selection.forEach((item)=>{ |
||||
if(item.id === row.id) { |
||||
flag = true; |
||||
this.$refs.table.toggleRowSelection(row); |
||||
} |
||||
}) |
||||
|
||||
if(!flag){ |
||||
this.$refs.table.toggleRowSelection(row, true); |
||||
} |
||||
}, |
||||
} |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped></style> |
@ -0,0 +1,184 @@
|
||||
<template> |
||||
<el-dialog :close-on-click-modal="false" :close-on-press-escape="true" :title="title" :type="type" |
||||
:visible.sync="isVisible" :width="width" top="50px" v-el-drag-dialog> |
||||
<el-form :model="brand" :rules="rules" label-position="right" label-width="100px" ref="form"> |
||||
<el-form-item :label="$t('table.brand.name')" prop="name"> |
||||
<el-input type="" v-model="brand.name" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.image')" prop="image"> |
||||
<el-input type="" v-model="brand.image" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.video')" prop="video"> |
||||
<el-input type="" v-model="brand.video" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.desc')" prop="desc"> |
||||
<el-input type="" v-model="brand.desc" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.content')" prop="content"> |
||||
<el-input type="" v-model="brand.content" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.sort')" prop="sort"> |
||||
<el-input type="" v-model="brand.sort" placeholder=""/> |
||||
</el-form-item> |
||||
</el-form> |
||||
<div class="dialog-footer" slot="footer"> |
||||
<el-button @click="isVisible = false" plain type="warning"> |
||||
{{ $t("common.cancel") }} |
||||
</el-button> |
||||
<el-button @click="submitForm" :disabled="confirmDisabled" plain type="primary"> |
||||
{{ $t("common.confirm") }} |
||||
</el-button> |
||||
</div> |
||||
</el-dialog> |
||||
</template> |
||||
<script> |
||||
import elDragDialog from '@/directive/el-drag-dialog' |
||||
import brandApi from "@/api/Brand.js"; |
||||
|
||||
export default { |
||||
name: "BrandEdit", |
||||
directives: { elDragDialog }, |
||||
components: { }, |
||||
props: { |
||||
dialogVisible: { |
||||
type: Boolean, |
||||
default: false |
||||
}, |
||||
type: { |
||||
type: String, |
||||
default: "add" |
||||
} |
||||
}, |
||||
data() { |
||||
return { |
||||
confirmDisabled: false, |
||||
brand: this.initBrand(), |
||||
screenWidth: 0, |
||||
width: this.initWidth(), |
||||
rules: { |
||||
|
||||
}, |
||||
// 枚举 |
||||
enums: { |
||||
}, |
||||
// 字典 |
||||
dicts: { |
||||
} |
||||
}; |
||||
}, |
||||
computed: { |
||||
isVisible: { |
||||
get() { |
||||
return this.dialogVisible; |
||||
}, |
||||
set() { |
||||
this.close(); |
||||
this.reset(); |
||||
} |
||||
}, |
||||
title() { |
||||
return this.$t("common." + this.type); |
||||
} |
||||
}, |
||||
watch: {}, |
||||
mounted() { |
||||
window.onresize = () => { |
||||
return (() => { |
||||
this.width = this.initWidth(); |
||||
})(); |
||||
}; |
||||
}, |
||||
methods: { |
||||
initBrand() { |
||||
return { |
||||
id: "", |
||||
name: '', |
||||
image: '', |
||||
video: '', |
||||
desc: '', |
||||
content: '', |
||||
sort: null, |
||||
}; |
||||
}, |
||||
initWidth() { |
||||
this.screenWidth = document.body.clientWidth; |
||||
if (this.screenWidth < 991) { |
||||
return "90%"; |
||||
} else if (this.screenWidth < 1400) { |
||||
return "45%"; |
||||
} else { |
||||
return "800px"; |
||||
} |
||||
}, |
||||
setBrand(val = {}) { |
||||
const vm = this; |
||||
|
||||
vm.dicts = val['dicts']; |
||||
vm.enums = val['enums']; |
||||
if (val['row']) { |
||||
vm.brand = { ...val['row'] }; |
||||
|
||||
} |
||||
}, |
||||
close() { |
||||
this.$emit("close"); |
||||
}, |
||||
reset() { |
||||
// 先清除校验,再清除表单,不然有奇怪的bug |
||||
this.$refs.form.clearValidate(); |
||||
this.$refs.form.resetFields(); |
||||
this.confirmDisabled = false; |
||||
this.brand = this.initBrand(); |
||||
}, |
||||
submitForm() { |
||||
const vm = this; |
||||
this.$refs.form.validate(valid => { |
||||
if (valid) { |
||||
vm.editSubmit(); |
||||
} else { |
||||
return false; |
||||
} |
||||
}); |
||||
}, |
||||
editSubmit() { |
||||
const vm = this; |
||||
if (vm.type === "edit") { |
||||
vm.update(); |
||||
} else { |
||||
vm.save(); |
||||
} |
||||
}, |
||||
save() { |
||||
const vm = this; |
||||
vm.confirmDisabled = true; |
||||
brandApi.save(this.brand).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
vm.isVisible = false; |
||||
vm.$message({ |
||||
message: vm.$t("tips.createSuccess"), |
||||
type: "success" |
||||
}); |
||||
vm.$emit("success"); |
||||
} |
||||
}).finally(()=> vm.confirmDisabled = false); |
||||
}, |
||||
update() { |
||||
const vm = this; |
||||
vm.confirmDisabled = true; |
||||
brandApi.update(this.brand).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
vm.isVisible = false; |
||||
vm.$message({ |
||||
message: this.$t("tips.updateSuccess"), |
||||
type: "success" |
||||
}); |
||||
vm.$emit("success"); |
||||
} |
||||
}).finally(()=> vm.confirmDisabled = false); |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped></style> |
@ -0,0 +1,25 @@
|
||||
export default { |
||||
table: { |
||||
// 以下复制到en.js
|
||||
brand: { |
||||
id: 'ID', |
||||
name: 'name', |
||||
image: 'image', |
||||
video: 'video', |
||||
desc: 'desc', |
||||
content: 'content', |
||||
sort: 'sort', |
||||
}, |
||||
// 以下复制到zh.js
|
||||
brand: { |
||||
id: 'ID', |
||||
name: 'name', |
||||
image: 'image', |
||||
video: 'video', |
||||
desc: 'desc', |
||||
content: 'content', |
||||
sort: 'sort', |
||||
}, |
||||
// 复制之后,删除 lang.js
|
||||
}, |
||||
} |
@ -0,0 +1,347 @@
|
||||
<template> |
||||
<div class="app-container"> |
||||
<div class="filter-container"> |
||||
|
||||
<el-date-picker :range-separator="null" class="filter-item search-item date-range-item" |
||||
end-placeholder="结束日期" format="yyyy-MM-dd HH:mm:ss" start-placeholder="开始日期" |
||||
type="daterange" v-model="queryParams.timeRange" value-format="yyyy-MM-dd HH:mm:ss" |
||||
/> |
||||
<el-button @click="search" class="filter-item" plain type="primary"> |
||||
{{ $t("table.search") }} |
||||
</el-button> |
||||
<el-button @click="reset" class="filter-item" plain type="warning"> |
||||
{{ $t("table.reset") }} |
||||
</el-button> |
||||
<el-button @click="add" class="filter-item" plain type="danger" v-has-permission="['brand:add']"> |
||||
{{ $t("table.add") }} |
||||
</el-button> |
||||
<el-dropdown class="filter-item" trigger="click" v-has-any-permission="['brand:delete', 'brand:export', |
||||
'brand:import']"> |
||||
<el-button> |
||||
{{ $t("table.more") }}<i class="el-icon-arrow-down el-icon--right" /> |
||||
</el-button> |
||||
<el-dropdown-menu slot="dropdown"> |
||||
<el-dropdown-item @click.native="batchDelete" v-has-permission="['brand:delete']"> |
||||
{{ $t("table.delete") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="exportExcel" v-has-permission="['brand:export']"> |
||||
{{ $t("table.export") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="exportExcelPreview" v-has-permission="['brand:export']"> |
||||
{{ $t("table.exportPreview") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="importExcel" v-has-permission="['brand:import']"> |
||||
{{ $t("table.import") }} |
||||
</el-dropdown-item> |
||||
</el-dropdown-menu> |
||||
</el-dropdown> |
||||
</div> |
||||
|
||||
<el-table :data="tableData.records" :key="tableKey" @cell-click="cellClick" |
||||
@filter-change="filterChange" @selection-change="onSelectChange" @sort-change="sortChange" |
||||
border fit row-key="id" ref="table" style="width: 100%;" v-loading="loading"> |
||||
<el-table-column align="center" type="selection" width="40px" :reserve-selection="true"/> |
||||
<el-table-column :label="$t('table.brand.name')" :show-overflow-tooltip="true" align="center" prop="name" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.name }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.brand.image')" :show-overflow-tooltip="true" align="center" prop="image" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.image }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.brand.video')" :show-overflow-tooltip="true" align="center" prop="video" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.video }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.brand.desc')" :show-overflow-tooltip="true" align="center" prop="desc" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.desc }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.brand.content')" :show-overflow-tooltip="true" align="center" prop="content" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.content }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.brand.sort')" :show-overflow-tooltip="true" align="center" prop="sort" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.sort }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column |
||||
:label="$t('table.createTime')" |
||||
align="center" |
||||
prop="createTime" |
||||
sortable="custom" |
||||
width="170px"> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.createTime }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column |
||||
:label="$t('table.operation')" align="center" column-key="operation" class-name="small-padding fixed-width" width="100px"> |
||||
<template slot-scope="{ row }"> |
||||
<i @click="copy(row)" class="el-icon-copy-document table-operation" :title="$t('common.delete')" |
||||
style="color: #2db7f5;" v-hasPermission="['brand:add']"/> |
||||
<i @click="edit(row)" class="el-icon-edit table-operation" :title="$t('common.delete')" |
||||
style="color: #2db7f5;" v-hasPermission="['brand:update']"/> |
||||
<i @click="singleDelete(row)" class="el-icon-delete table-operation" :title="$t('common.delete')" |
||||
style="color: #f50;" v-hasPermission="['brand:delete']"/> |
||||
<el-link class="no-perm" v-has-no-permission="['brand:update', 'brand:copy', 'brand:delete']"> |
||||
{{ $t("tips.noPermission") }} |
||||
</el-link> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<pagination :limit.sync="queryParams.size" :page.sync="queryParams.current" |
||||
:total="Number(tableData.total)" @pagination="fetch" v-show="tableData.total > 0"/> |
||||
<brand-edit :dialog-visible="dialog.isVisible" :type="dialog.type" |
||||
@close="editClose" @success="editSuccess" ref="edit"/> |
||||
<brand-import ref="import" :dialog-visible="fileImport.isVisible" :type="fileImport.type" |
||||
:action="fileImport.action" accept=".xls,.xlsx" @close="importClose" @success="importSuccess" /> |
||||
<el-dialog :close-on-click-modal="false" :close-on-press-escape="true" |
||||
title="预览" width="80%" top="50px" :visible.sync="preview.isVisible" v-el-drag-dialog> |
||||
<el-scrollbar> |
||||
<div v-html="preview.context"></div> |
||||
</el-scrollbar> |
||||
</el-dialog> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import Pagination from "@/components/Pagination"; |
||||
import elDragDialog from '@/directive/el-drag-dialog' |
||||
import BrandEdit from "./Edit"; |
||||
import brandApi from "@/api/Brand.js"; |
||||
import BrandImport from "@/components/zsw/Import" |
||||
import {convertEnum} from '@/utils/utils' |
||||
import {downloadFile, loadEnums, initDicts, initQueryParams} from '@/utils/commons' |
||||
|
||||
export default { |
||||
name: "BrandManage", |
||||
directives: { elDragDialog }, |
||||
components: { Pagination, BrandEdit, BrandImport}, |
||||
filters: { |
||||
|
||||
}, |
||||
data() { |
||||
return { |
||||
// 编辑 |
||||
dialog: { |
||||
isVisible: false, |
||||
type: "add" |
||||
}, |
||||
// 预览 |
||||
preview: { |
||||
isVisible: false, |
||||
context: '' |
||||
}, |
||||
// 导入 |
||||
fileImport: { |
||||
isVisible: false, |
||||
type: "import", |
||||
action: `${process.env.VUE_APP_BASE_API}/brand/brand/import` |
||||
}, |
||||
tableKey: 0, |
||||
queryParams: initQueryParams(), |
||||
selection: [], |
||||
loading: false, |
||||
tableData: { |
||||
total: 0 |
||||
}, |
||||
// 枚举 |
||||
enums: { |
||||
}, |
||||
// 字典 |
||||
dicts: { |
||||
} |
||||
}; |
||||
}, |
||||
computed: { |
||||
}, |
||||
watch: { |
||||
}, |
||||
mounted() { |
||||
this.fetch(); |
||||
|
||||
// 初始化字典和枚举 |
||||
const enumList = []; |
||||
const dictList = []; |
||||
loadEnums(enumList, this.enums, 'brand'); |
||||
initDicts(dictList, this.dicts); |
||||
}, |
||||
methods: { |
||||
editClose() { |
||||
this.dialog.isVisible = false; |
||||
}, |
||||
editSuccess() { |
||||
this.search(); |
||||
}, |
||||
onSelectChange(selection) { |
||||
this.selection = selection; |
||||
}, |
||||
search() { |
||||
this.fetch({ |
||||
...this.queryParams |
||||
}); |
||||
}, |
||||
reset() { |
||||
this.queryParams = initQueryParams(); |
||||
this.$refs.table.clearSort(); |
||||
this.$refs.table.clearFilter(); |
||||
this.search(); |
||||
}, |
||||
exportExcelPreview() { |
||||
if (this.queryParams.timeRange) { |
||||
this.queryParams.map.createTime_st = this.queryParams.timeRange[0]; |
||||
this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]; |
||||
} |
||||
this.queryParams.map.fileName = '导出数据'; |
||||
brandApi.preview(this.queryParams).then(response => { |
||||
const res = response.data; |
||||
this.preview.isVisible = true; |
||||
this.preview.context = res.data; |
||||
}); |
||||
}, |
||||
exportExcel() { |
||||
if (this.queryParams.timeRange) { |
||||
this.queryParams.map.createTime_st = this.queryParams.timeRange[0]; |
||||
this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]; |
||||
} |
||||
this.queryParams.map.fileName = '导出数据'; |
||||
brandApi.export(this.queryParams).then(response => { |
||||
downloadFile(response); |
||||
}); |
||||
}, |
||||
importExcel() { |
||||
this.fileImport.type = "upload"; |
||||
this.fileImport.isVisible = true; |
||||
this.$refs.import.setModel(false); |
||||
}, |
||||
importSuccess() { |
||||
this.search(); |
||||
}, |
||||
importClose() { |
||||
this.fileImport.isVisible = false; |
||||
}, |
||||
singleDelete(row) { |
||||
this.$refs.table.clearSelection() |
||||
this.$refs.table.toggleRowSelection(row, true); |
||||
this.batchDelete(); |
||||
}, |
||||
batchDelete() { |
||||
if (!this.selection.length) { |
||||
this.$message({ |
||||
message: this.$t("tips.noDataSelected"), |
||||
type: "warning" |
||||
}); |
||||
return; |
||||
} |
||||
this.$confirm(this.$t("tips.confirmDelete"), this.$t("common.tips"), { |
||||
confirmButtonText: this.$t("common.confirm"), |
||||
cancelButtonText: this.$t("common.cancel"), |
||||
type: "warning" |
||||
}) |
||||
.then(() => { |
||||
const ids = this.selection.map(u => u.id); |
||||
this.delete(ids); |
||||
}) |
||||
.catch(() => { |
||||
this.clearSelections(); |
||||
}); |
||||
}, |
||||
clearSelections() { |
||||
this.$refs.table.clearSelection(); |
||||
}, |
||||
delete(ids) { |
||||
brandApi.delete({ ids: ids }).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
this.$message({ |
||||
message: this.$t("tips.deleteSuccess"), |
||||
type: "success" |
||||
}); |
||||
this.search(); |
||||
} |
||||
}); |
||||
}, |
||||
add() { |
||||
this.dialog.type = "add"; |
||||
this.dialog.isVisible = true; |
||||
this.$refs.edit.setBrand({ enums: this.enums, dicts: this.dicts}); |
||||
}, |
||||
copy(row) { |
||||
this.$refs.edit.setBrand({row, enums: this.enums, dicts: this.dicts}); |
||||
this.dialog.type = "copy"; |
||||
this.dialog.isVisible = true; |
||||
}, |
||||
edit(row) { |
||||
this.$refs.edit.setBrand({row, enums: this.enums, dicts: this.dicts}); |
||||
this.dialog.type = "edit"; |
||||
this.dialog.isVisible = true; |
||||
}, |
||||
fetch(params = {}) { |
||||
this.loading = true; |
||||
if (this.queryParams.timeRange) { |
||||
this.queryParams.map.createTime_st = this.queryParams.timeRange[0]; |
||||
this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]; |
||||
} |
||||
|
||||
this.queryParams.current = params.current ? params.current : this.queryParams.current; |
||||
this.queryParams.size = params.size ? params.size : this.queryParams.size; |
||||
|
||||
brandApi.page(this.queryParams).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
this.tableData = res.data; |
||||
} |
||||
}).finally(() => this.loading = false); |
||||
}, |
||||
sortChange(val) { |
||||
this.queryParams.sort = val.prop; |
||||
this.queryParams.order = val.order; |
||||
if (this.queryParams.sort) { |
||||
this.search(); |
||||
} |
||||
}, |
||||
filterChange (filters) { |
||||
for (const key in filters) { |
||||
if(key.includes('.')) { |
||||
const val = { }; |
||||
val[key.split('.')[1]] = filters[key][0]; |
||||
this.queryParams.model[key.split('.')[0]] = val; |
||||
} else { |
||||
this.queryParams.model[key] = filters[key][0] |
||||
} |
||||
} |
||||
this.search() |
||||
}, |
||||
cellClick (row, column) { |
||||
if (column['columnKey'] === "operation") { |
||||
return; |
||||
} |
||||
let flag = false; |
||||
this.selection.forEach((item)=>{ |
||||
if(item.id === row.id) { |
||||
flag = true; |
||||
this.$refs.table.toggleRowSelection(row); |
||||
} |
||||
}) |
||||
|
||||
if(!flag){ |
||||
this.$refs.table.toggleRowSelection(row, true); |
||||
} |
||||
}, |
||||
} |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped></style> |
@ -0,0 +1,356 @@
|
||||
<template> |
||||
<div class="brand"> |
||||
<el-row :gutter="10"> |
||||
<el-col :sm="12" :xs="24"> |
||||
<div class="app-container"> |
||||
<div class="filter-container"> |
||||
<el-input :placeholder="$t('table.brand.label')" class="filter-item search-item" v-model="label"/> |
||||
<el-button @click="search" class="filter-item" plain type="primary"> |
||||
{{ $t("table.search") }} |
||||
</el-button> |
||||
<el-button @click="reset" class="filter-item" plain type="warning"> |
||||
{{ $t("table.reset") }} |
||||
</el-button> |
||||
<el-button @click="add" class="filter-item" plain type="danger" v-has-permission="['brand:add']"> |
||||
{{ $t("table.add") }} |
||||
</el-button> |
||||
<el-dropdown class="filter-item" trigger="click" v-has-any-permission="['brand:import', 'brand:delete', 'brand:export']"> |
||||
<el-button> |
||||
{{ $t("table.more") }}<i class="el-icon-arrow-down el-icon--right"/> |
||||
</el-button> |
||||
<el-dropdown-menu slot="dropdown"> |
||||
<el-dropdown-item @click.native="batchDelete" v-has-permission="['brand:delete']"> |
||||
{{ $t("table.delete") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="exportExcel" v-has-permission="['brand:export']"> |
||||
{{ $t("table.export") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="exportExcelPreview" v-has-permission="['brand:export']"> |
||||
{{ $t("table.exportPreview") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="importExcel" v-has-permission="['brand:import']"> |
||||
{{ $t("table.import") }} |
||||
</el-dropdown-item> |
||||
</el-dropdown-menu> |
||||
</el-dropdown> |
||||
</div> |
||||
<el-tree |
||||
:check-strictly="true" |
||||
:data="brandTree" |
||||
:filter-node-method="filterNode" |
||||
@node-click="nodeClick" |
||||
:load="loadTree" |
||||
highlight-current |
||||
node-key="id" |
||||
ref="brandTree" |
||||
:lazy="true" |
||||
show-checkbox/> |
||||
</div> |
||||
</el-col> |
||||
<el-col :sm="12" :xs="24"> |
||||
<el-card class="box-card"> |
||||
<div class="clearfix" slot="header"> |
||||
<span> |
||||
{{brand.id === "" ? this.$t("common.add") : this.$t("common.edit")}} |
||||
</span> |
||||
</div> |
||||
<div> |
||||
<el-form :model="brand" :rules="rules" label-position="right" label-width="100px" ref="form"> |
||||
<el-form-item :hidden="true" :label="$t('table.brand.parentId')" prop="parentId"> |
||||
<el-tooltip :content="$t('tips.topId')" class="item" effect="dark" placement="top-start"> |
||||
<el-input readonly v-model="brand.parentId"/> |
||||
</el-tooltip> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.parentId')" prop="parentLabel"> |
||||
<el-input readonly disabled="disabled" v-model="brand.parentLabel"/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.label')" prop="label"> |
||||
<el-input v-model="brand.label"/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.name')" prop="name"> |
||||
<el-input type="" v-model="brand.name" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.image')" prop="image"> |
||||
<el-input type="" v-model="brand.image" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.video')" prop="video"> |
||||
<el-input type="" v-model="brand.video" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.desc')" prop="desc"> |
||||
<el-input type="" v-model="brand.desc" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.content')" prop="content"> |
||||
<el-input type="" v-model="brand.content" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.sort')" prop="sort"> |
||||
<el-input type="" v-model="brand.sort" placeholder=""/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.brand.sortValue')" prop="sortValue"> |
||||
<el-input-number :max="100" :min="0" @change="handleNumChange" v-model="brand.sortValue"/> |
||||
</el-form-item> |
||||
</el-form> |
||||
</div> |
||||
</el-card> |
||||
<el-card class="box-card" style="margin-top: -2rem;"> |
||||
<el-row> |
||||
<el-col :span="24" style="text-align: right"> |
||||
<el-button @click="submit" plain type="primary"> |
||||
{{brand.id === "" ? this.$t("common.add") : this.$t("common.edit") }} |
||||
</el-button> |
||||
</el-col> |
||||
</el-row> |
||||
</el-card> |
||||
</el-col> |
||||
</el-row> |
||||
|
||||
<brand-import ref="import" :dialog-visible="fileImport.isVisible" :type="fileImport.type" |
||||
:action="fileImport.action" accept=".xls,.xlsx" @close="importClose" @success="importSuccess" /> |
||||
<el-dialog :close-on-click-modal="false" :close-on-press-escape="true" |
||||
title="预览" width="80%" top="50px" :visible.sync="preview.isVisible" v-el-drag-dialog> |
||||
<el-scrollbar> |
||||
<div v-html="preview.context"></div> |
||||
</el-scrollbar> |
||||
</el-dialog> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
import brandApi from "@/api/Brand.js"; |
||||
import elDragDialog from '@/directive/el-drag-dialog' |
||||
import BrandImport from "@/components/zsw/Import" |
||||
import {downloadFile, loadEnums, initDicts, initQueryParams} from '@/utils/commons' |
||||
|
||||
export default { |
||||
name: "BrandManager", |
||||
directives: { elDragDialog }, |
||||
components: { BrandImport }, |
||||
data() { |
||||
return { |
||||
label: "", |
||||
brandTree: [], |
||||
brand: this.initBrand(), |
||||
rules: { |
||||
|
||||
}, |
||||
// 预览 |
||||
preview: { |
||||
isVisible: false, |
||||
context: '' |
||||
}, |
||||
// 导入 |
||||
fileImport: { |
||||
isVisible: false, |
||||
type: "import", |
||||
action: `${process.env.VUE_APP_BASE_API}/brand/brand/import` |
||||
}, |
||||
// 枚举 |
||||
enums: { |
||||
}, |
||||
// 字典 |
||||
dicts: { |
||||
} |
||||
}; |
||||
}, |
||||
mounted() { |
||||
// 初始化字典和枚举 |
||||
const enumList = []; |
||||
const dictList = []; |
||||
loadEnums(enumList, this.enums, 'brand'); |
||||
initDicts(dictList, this.dicts); |
||||
}, |
||||
methods: { |
||||
initBrand() { |
||||
return { |
||||
id: "", |
||||
label: "", |
||||
sortValue: 0, |
||||
parentId: 0, |
||||
parentLabel: "", |
||||
name: '', |
||||
image: '', |
||||
video: '', |
||||
desc: '', |
||||
content: '', |
||||
sort: null, |
||||
}; |
||||
}, |
||||
initBrandTree(parentId = 0) { |
||||
brandApi.query({parentId: parentId}).then(response => { |
||||
const res = response.data; |
||||
this.brandTree = res.data; |
||||
}); |
||||
}, |
||||
loadTree(node, resolve) { |
||||
brandApi.query({parentId: node.data.id ? node.data.id : 0}).then(response => { |
||||
const res = response.data; |
||||
resolve(res.data); |
||||
}); |
||||
}, |
||||
exportExcelPreview() { |
||||
const queryParams = initQueryParams(); |
||||
queryParams.map.fileName = '导出数据'; |
||||
brandApi.preview(queryParams).then(response => { |
||||
const res = response.data; |
||||
this.preview.isVisible = true; |
||||
this.preview.context = res.data; |
||||
}); |
||||
}, |
||||
exportExcel() { |
||||
const queryParams = initQueryParams(); |
||||
queryParams.map.fileName = '导出数据'; |
||||
brandApi.export(queryParams).then(response => { |
||||
downloadFile(response); |
||||
}); |
||||
}, |
||||
importExcel() { |
||||
this.fileImport.type = "upload"; |
||||
this.fileImport.isVisible = true; |
||||
this.$refs.import.setModel(false); |
||||
}, |
||||
importSuccess() { |
||||
this.initBrandTree(0); |
||||
}, |
||||
importClose() { |
||||
this.fileImport.isVisible = false; |
||||
}, |
||||
handleNumChange(val) { |
||||
this.brand.sortValue = val; |
||||
}, |
||||
filterNode(value, data) { |
||||
if (!value) return true; |
||||
return data.label.indexOf(value) !== -1; |
||||
}, |
||||
nodeClick(val) { |
||||
const vm = this; |
||||
if(val){ |
||||
this.brand = {...val}; |
||||
|
||||
} |
||||
|
||||
const parent = this.$refs.brandTree.getNode(val.parentId); |
||||
if (parent) { |
||||
this.brand.parentLabel = parent.label; |
||||
} |
||||
|
||||
this.$refs.form.clearValidate(); |
||||
}, |
||||
add() { |
||||
this.resetForm(); |
||||
const checked = this.$refs.brandTree.getCheckedNodes(); |
||||
if (checked.length > 1) { |
||||
this.$message({ |
||||
message: this.$t("tips.onlyChooseOne"), |
||||
type: "warning" |
||||
}); |
||||
} else if (checked.length > 0) { |
||||
this.brand.parentId = checked[0].id; |
||||
this.brand.parentLabel = checked[0].label; |
||||
} else { |
||||
this.brand.parentId = 0; |
||||
this.brand.parentLabel = ""; |
||||
} |
||||
}, |
||||
batchDelete() { |
||||
const checked = this.$refs.brandTree.getCheckedKeys(); |
||||
if (checked.length === 0) { |
||||
this.$message({ |
||||
message: this.$t("tips.noNodeSelected"), |
||||
type: "warning" |
||||
}); |
||||
} else { |
||||
this.$confirm(this.$t("tips.confirmDeleteNode"), this.$t("common.tips"), { |
||||
confirmButtonText: this.$t("common.confirm"), |
||||
cancelButtonText: this.$t("common.cancel"), |
||||
type: "warning" |
||||
}).then(() => { |
||||
brandApi.delete({ids: checked}).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
this.$message({ |
||||
message: this.$t("tips.deleteSuccess"), |
||||
type: "success" |
||||
}); |
||||
} |
||||
this.reset(); |
||||
}); |
||||
}).catch(() => { |
||||
this.$refs.brandTree.setCheckedKeys([]); |
||||
}); |
||||
} |
||||
}, |
||||
search() { |
||||
this.$refs.brandTree.filter(this.label); |
||||
}, |
||||
reset() { |
||||
this.initBrandTree(); |
||||
this.label = ""; |
||||
this.resetForm(); |
||||
}, |
||||
submit() { |
||||
this.$refs.form.validate(valid => { |
||||
if (valid) { |
||||
if (this.brand.id) { |
||||
this.update(); |
||||
} else { |
||||
this.save(); |
||||
} |
||||
} else { |
||||
return false; |
||||
} |
||||
}); |
||||
}, |
||||
save() { |
||||
brandApi.save({...this.brand}).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
this.$message({ |
||||
message: this.$t("tips.createSuccess"), |
||||
type: "success" |
||||
}); |
||||
} |
||||
|
||||
this.reset(); |
||||
}); |
||||
}, |
||||
update() { |
||||
brandApi.update({...this.brand}).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
this.$message({ |
||||
message: this.$t("tips.updateSuccess"), |
||||
type: "success" |
||||
}); |
||||
} |
||||
this.reset(); |
||||
}); |
||||
}, |
||||
resetForm() { |
||||
this.$refs.form.clearValidate(); |
||||
this.$refs.form.resetFields(); |
||||
this.brand = this.initBrand(); |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
.brand { |
||||
margin: 10px; |
||||
|
||||
.app-container { |
||||
margin: 0 0 10px 0 !important; |
||||
} |
||||
} |
||||
|
||||
.el-card.is-always-shadow { |
||||
box-shadow: none; |
||||
} |
||||
|
||||
.el-card { |
||||
border-radius: 0; |
||||
border: none; |
||||
|
||||
.el-card__header { |
||||
padding: 10px 20px !important; |
||||
border-bottom: 1px solid #f1f1f1 !important; |
||||
} |
||||
} |
||||
</style> |
@ -1,210 +1,297 @@
|
||||
<template> |
||||
<el-dialog :close-on-click-modal="false" :close-on-press-escape="true" :title="title" :type="type" |
||||
:visible.sync="isVisible" :width="width" top="50px" v-el-drag-dialog> |
||||
<el-form :model="information" :rules="rules" label-position="right" label-width="100px" ref="form"> |
||||
<el-form-item :label="$t('table.information.storeId')" prop="storeId"> |
||||
<el-input type="" v-model="information.storeId" placeholder="店铺ID"/> |
||||
<el-dialog |
||||
:close-on-click-modal="false" |
||||
:title="title" |
||||
:type="type" |
||||
:visible.sync="isVisible" |
||||
width="800px" |
||||
top="50px" |
||||
class="group-dialog" |
||||
> |
||||
<el-form :model="params" label-width="100px" :rules="rules" ref="params"> |
||||
<el-form-item label="活动标题" prop="mainTitle"> |
||||
<el-input v-model="params.mainTitle" style="width: 200px" /> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.information.mainTitle')" prop="mainTitle"> |
||||
<el-input type="" v-model="information.mainTitle" placeholder="主标题"/> |
||||
<el-form-item label="活动简介" prop="viceTitle"> |
||||
<el-input v-model="params.viceTitle" style="width: 200px" /> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.information.viceTitle')" prop="viceTitle"> |
||||
<el-input type="" v-model="information.viceTitle" placeholder="副标题"/> |
||||
<el-form-item label="作者" prop="name"> |
||||
<el-input v-model="params.name" style="width: 200px" /> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.information.content')" prop="content"> |
||||
<el-input type="" v-model="information.content" placeholder="内容"/> |
||||
<el-form-item label="作者头像" prop="avatar"> |
||||
<!-- <el-input v-model="params.author.avatar" style="width: 200px" /> --> |
||||
<el-upload |
||||
class="avatar-uploader" |
||||
:headers="headers" |
||||
:data="dataObj" |
||||
:action="action" |
||||
:show-file-list="false" |
||||
:on-success="handleAvatarSuccessAvatar" |
||||
> |
||||
<!-- <img |
||||
v-if="params.avatar" |
||||
:src="params.avatar" |
||||
class="avatar" |
||||
width="80" |
||||
height="80" |
||||
/> --> |
||||
<!-- <i v-else class="el-icon-plus avatar-uploader-icon"></i> --> |
||||
<el-button size="small" type="primary" |
||||
>点击上传</el-button |
||||
> |
||||
</el-upload> |
||||
<img |
||||
style="margin-top:5px" |
||||
v-if="params.avatar" |
||||
:src="params.avatar" |
||||
class="avatar" |
||||
width="80" |
||||
height="80" |
||||
/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.information.coverImg')" prop="coverImg"> |
||||
<el-input type="" v-model="information.coverImg" placeholder="封面图"/> |
||||
<el-form-item label="活动封面图" prop="coverImg"> |
||||
<!-- <el-input v-model="params.coverImg" style="width: 200px" /> --> |
||||
<el-upload |
||||
class="avatar-uploader" |
||||
:headers="headers" |
||||
:data="dataObj" |
||||
:action="action" |
||||
:show-file-list="false" |
||||
:on-success="handleAvatarSuccess" |
||||
> |
||||
|
||||
<!-- <i v-else class="el-icon-plus avatar-uploader-icon"></i> --> |
||||
<el-button size="small" type="primary" |
||||
>点击上传</el-button |
||||
> |
||||
</el-upload> |
||||
<img |
||||
style="margin-top:5px" |
||||
v-if="params.coverImg" |
||||
:src="params.coverImg" |
||||
class="avatar" |
||||
width="80" |
||||
height="80" |
||||
/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.information.startTime')" prop="startTime"> |
||||
<el-date-picker |
||||
v-model="information.startTime" |
||||
placeholder="开始时间" |
||||
:start-placeholder="$t('table.information.startTime')" |
||||
value-format="yyyy-MM-dd HH:mm:ss" |
||||
format="yyyy-MM-dd HH:mm:ss" |
||||
class="filter-item date-range-item" |
||||
type="datetime"/> |
||||
<el-form-item label="开始时间" prop="startTime"> |
||||
<el-date-picker |
||||
v-model="params.startTime" |
||||
type="datetime" |
||||
placeholder="选择日期时间" |
||||
value-format="yyyy-MM-dd HH:mm:ss" |
||||
> |
||||
</el-date-picker> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.information.endTime')" prop="endTime"> |
||||
<el-form-item label="结束时间" prop="endTime"> |
||||
<el-date-picker |
||||
v-model="information.endTime" |
||||
placeholder="结束时间" |
||||
:start-placeholder="$t('table.information.endTime')" |
||||
value-format="yyyy-MM-dd HH:mm:ss" |
||||
format="yyyy-MM-dd HH:mm:ss" |
||||
class="filter-item date-range-item" |
||||
type="datetime"/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.information.state')" prop="state"> |
||||
<el-input type="" v-model="information.state" placeholder="状态:1-上架,0-下架"/> |
||||
v-model="params.endTime" |
||||
type="datetime" |
||||
placeholder="选择日期时间" |
||||
value-format="yyyy-MM-dd HH:mm:ss" |
||||
> |
||||
</el-date-picker> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('table.information.isDelete')" prop="isDelete"> |
||||
<el-input type="" v-model="information.isDelete" placeholder="逻辑删除:1-删除 0-未删除"/> |
||||
<el-form-item label="富文本" prop="content"> |
||||
<Tinymce ref="content" v-if="isVisible" v-model="params.content" :height="200" /> |
||||
</el-form-item> |
||||
<!-- <el-form-item label="是否上架" prop="state"> |
||||
<el-radio-group v-model="params.state" size="medium"> |
||||
<el-radio-button :label="0">{{ |
||||
$t('common.yes') |
||||
}}</el-radio-button> |
||||
<el-radio-button :label="1">{{ |
||||
$t('common.no') |
||||
}}</el-radio-button> |
||||
</el-radio-group> |
||||
</el-form-item> --> |
||||
</el-form> |
||||
<div class="dialog-footer" slot="footer"> |
||||
<el-button @click="isVisible = false" plain type="warning"> |
||||
{{ $t("common.cancel") }} |
||||
{{ $t('common.cancel') }} |
||||
</el-button> |
||||
<el-button @click="submitForm" :disabled="confirmDisabled" plain type="primary"> |
||||
{{ $t("common.confirm") }} |
||||
<el-button |
||||
@click="submitForm('params')" |
||||
plain |
||||
type="primary" |
||||
> |
||||
{{ $t('common.confirm') }} |
||||
</el-button> |
||||
</div> |
||||
</el-dialog> |
||||
</template> |
||||
<script> |
||||
import elDragDialog from '@/directive/el-drag-dialog' |
||||
import informationApi from "@/api/InformationApi.js"; |
||||
|
||||
import db from '@/utils/localstorage' |
||||
import ActivityTweets from '@/api/ActivityTweets' |
||||
import Tinymce from '@/components/Tinymce' |
||||
// import moment from 'moment' |
||||
export default { |
||||
name: "InformationEdit", |
||||
directives: { elDragDialog }, |
||||
components: { }, |
||||
components:{ |
||||
Tinymce |
||||
}, |
||||
props: { |
||||
dialogVisible: { |
||||
type: Boolean, |
||||
default: false |
||||
default: false, |
||||
}, |
||||
type: { |
||||
type: String, |
||||
default: "add" |
||||
} |
||||
default: 'add', |
||||
}, |
||||
}, |
||||
data() { |
||||
return { |
||||
confirmDisabled: false, |
||||
information: this.initInformation(), |
||||
screenWidth: 0, |
||||
width: this.initWidth(), |
||||
rules: { |
||||
|
||||
options: [], |
||||
sizeForm: {}, |
||||
headers: { |
||||
Authorization: '', |
||||
}, |
||||
// 枚举 |
||||
enums: { |
||||
action: `${process.env.VUE_APP_DEV_REQUEST_DOMAIN_PREFIX}/file/upload`, |
||||
dataObj: { |
||||
folderId: 1, |
||||
}, |
||||
// 字典 |
||||
dicts: { |
||||
} |
||||
}; |
||||
params: { |
||||
id: '', |
||||
mainTitle: '', |
||||
viceTitle: 1, |
||||
coverImg: '', |
||||
startTime: '', |
||||
endTime: '', |
||||
content: '', |
||||
name: '', |
||||
avatar: '' |
||||
}, |
||||
rules: { |
||||
groupName: [{ required: true, message: '不可为空', trigger: 'blur' }], |
||||
}, |
||||
} |
||||
}, |
||||
computed: { |
||||
isVisible: { |
||||
get() { |
||||
return this.dialogVisible; |
||||
return this.dialogVisible |
||||
}, |
||||
set() { |
||||
this.close(); |
||||
this.reset(); |
||||
} |
||||
this.close() |
||||
this.reset() |
||||
}, |
||||
}, |
||||
title() { |
||||
return this.$t("common." + this.type); |
||||
} |
||||
return this.type === 'add' ? '新建活动' : '查看活动' |
||||
}, |
||||
}, |
||||
watch: {}, |
||||
mounted() { |
||||
window.onresize = () => { |
||||
return (() => { |
||||
this.width = this.initWidth(); |
||||
})(); |
||||
}; |
||||
created() { |
||||
this.headers.token = 'Bearer ' + db.get('TOKEN', '') |
||||
this.headers.tenant = db.get('TENANT') |
||||
}, |
||||
methods: { |
||||
initInformation() { |
||||
return { |
||||
id: "", |
||||
storeId: null, |
||||
mainTitle: '', |
||||
viceTitle: '', |
||||
content: '', |
||||
coverImg: '', |
||||
startTime: null, |
||||
endTime: null, |
||||
state: null, |
||||
isDelete: null, |
||||
}; |
||||
}, |
||||
initWidth() { |
||||
this.screenWidth = document.body.clientWidth; |
||||
if (this.screenWidth < 991) { |
||||
return "90%"; |
||||
} else if (this.screenWidth < 1400) { |
||||
return "45%"; |
||||
} else { |
||||
return "800px"; |
||||
} |
||||
}, |
||||
setInformation(val = {}) { |
||||
const vm = this; |
||||
|
||||
vm.dicts = val['dicts']; |
||||
vm.enums = val['enums']; |
||||
if (val['row']) { |
||||
vm.information = { ...val['row'] }; |
||||
|
||||
} |
||||
}, |
||||
close() { |
||||
this.$emit("close"); |
||||
this.$emit('close') |
||||
}, |
||||
reset() { |
||||
// 先清除校验,再清除表单,不然有奇怪的bug |
||||
this.$refs.form.clearValidate(); |
||||
this.$refs.form.resetFields(); |
||||
this.confirmDisabled = false; |
||||
this.information = this.initInformation(); |
||||
this.params = {} |
||||
}, |
||||
submitForm() { |
||||
const vm = this; |
||||
this.$refs.form.validate(valid => { |
||||
async submitForm(params) { |
||||
this.$refs[params].validate((valid) => { |
||||
if (valid) { |
||||
vm.editSubmit(); |
||||
if (this.type === 'add') { |
||||
this.addGroup() |
||||
} else if (this.type === 'edit') { |
||||
this.updateGroup() |
||||
} |
||||
} else { |
||||
return false; |
||||
// console.log(false+'123') |
||||
// if( |
||||
// !this.params.groupName || |
||||
// !this.params.printerId ){ |
||||
// this.$message.warning("请填写完整商品信息!"); |
||||
// }else{ |
||||
// } |
||||
} |
||||
}); |
||||
}) |
||||
}, |
||||
editSubmit() { |
||||
const vm = this; |
||||
if (vm.type === "edit") { |
||||
vm.update(); |
||||
} else { |
||||
vm.save(); |
||||
async addGroup() { |
||||
// this.params.startTime = moment(this.params.startTime).format('YYYY-MM-DD HH:mm:ss') |
||||
// this.params.endTime = moment(this.params.endTime).format('YYYY-MM-DD HH:mm:ss') |
||||
this.params.type = 2 |
||||
let data = { |
||||
name: this.params.name, |
||||
avatar: this.params.avatar |
||||
} |
||||
this.params.author = JSON.stringify(data) |
||||
// console.log(this.params, '商品') |
||||
const res = await ActivityTweets.save(this.params) |
||||
// console.log(res, 'resxinz') |
||||
const resData = res.data |
||||
const { code } = resData |
||||
if (code === 0) { |
||||
this.isVisible = false |
||||
this.$message({ |
||||
message: this.$t('tips.createSuccess'), |
||||
type: 'success', |
||||
}) |
||||
this.$emit('success') |
||||
} |
||||
}, |
||||
save() { |
||||
const vm = this; |
||||
vm.confirmDisabled = true; |
||||
informationApi.save(this.information).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
vm.isVisible = false; |
||||
vm.$message({ |
||||
message: vm.$t("tips.createSuccess"), |
||||
type: "success" |
||||
}); |
||||
vm.$emit("success"); |
||||
} |
||||
}).finally(()=> vm.confirmDisabled = false); |
||||
async updateGroup() { |
||||
let data = { |
||||
name: this.params.name, |
||||
avatar: this.params.avatar |
||||
} |
||||
this.params.author = JSON.stringify(data) |
||||
// this.params.startTime = moment(this.params.startTime).format('YYYY-MM-DD HH:mm:ss') |
||||
// this.params.endTime = moment(this.params.endTime).format('YYYY-MM-DD HH:mm:ss') |
||||
this.params.type = 2 |
||||
const res = await ActivityTweets.update(this.params) |
||||
const resData = res.data |
||||
const { code } = resData |
||||
if (code === 0) { |
||||
this.isVisible = false |
||||
this.$message({ |
||||
message: this.$t('tips.updateSuccess'), |
||||
type: 'success', |
||||
}) |
||||
this.$emit('success') |
||||
} |
||||
}, |
||||
update() { |
||||
const vm = this; |
||||
vm.confirmDisabled = true; |
||||
informationApi.update(this.information).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
vm.isVisible = false; |
||||
vm.$message({ |
||||
message: this.$t("tips.updateSuccess"), |
||||
type: "success" |
||||
}); |
||||
vm.$emit("success"); |
||||
} |
||||
}).finally(()=> vm.confirmDisabled = false); |
||||
handleAvatarSuccess(response) { |
||||
const { url } = response.data |
||||
this.params.coverImg = url |
||||
}, |
||||
handleAvatarSuccessAvatar(response) { |
||||
const { url } = response.data |
||||
this.params.avatar = url |
||||
}, |
||||
setParams(val = {}) { |
||||
this.params = {} |
||||
if(val) { |
||||
this.params = JSON.parse(JSON.stringify(val)) |
||||
this.params.name = JSON.parse(this.params.author).name |
||||
this.params.avatar = JSON.parse(this.params.author).avatar |
||||
} |
||||
}, |
||||
}, |
||||
} |
||||
</script> |
||||
<style lang="less" scoped> |
||||
.group-dialog { |
||||
.upload-wrap { |
||||
width: 100%; |
||||
display: flex; |
||||
align-items: flex-end; |
||||
.image-wrap { |
||||
width: 120px; |
||||
height: 120px; |
||||
line-height: 120px; |
||||
margin-right: 15px; |
||||
margin-bottom: 15px; |
||||
text-align: center; |
||||
border: 1px dashed #d9d9d9; |
||||
img { |
||||
width: 100%; |
||||
height: 100%; |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped></style> |
||||
} |
||||
</style> |
||||
|
@ -1,370 +1,227 @@
|
||||
<template> |
||||
<div class="app-container"> |
||||
<div class="filter-container"> |
||||
<el-input |
||||
:placeholder="$t('table.information.mainTitle')" |
||||
class="filter-item search-item" |
||||
v-model="queryParams.model.mainTitle" |
||||
/> |
||||
<div class="group-page"> |
||||
<div class="toolbar"> |
||||
<el-button |
||||
type="primary" |
||||
size="mini" |
||||
|
||||
<el-date-picker :range-separator="null" class="filter-item search-item date-range-item" |
||||
end-placeholder="结束日期" format="yyyy-MM-dd HH:mm:ss" start-placeholder="开始日期" |
||||
type="daterange" v-model="queryParams.timeRange" value-format="yyyy-MM-dd HH:mm:ss" |
||||
/> |
||||
<el-button @click="search" class="filter-item" plain type="primary"> |
||||
{{ $t("table.search") }} |
||||
@click="getActivityTweetsList" |
||||
icon="el-icon-zoom-in" |
||||
> |
||||
查询 |
||||
</el-button> |
||||
<el-button @click="reset" class="filter-item" plain type="warning"> |
||||
{{ $t("table.reset") }} |
||||
<el-button type="warning" size="mini" @click="reset" icon="el-icon-refresh-right"> |
||||
重置 |
||||
</el-button> |
||||
<el-button @click="add" class="filter-item" plain type="danger" v-has-permission="['information:add']"> |
||||
{{ $t("table.add") }} |
||||
<el-button |
||||
type="goon" |
||||
size="mini" |
||||
@click="addGroup" |
||||
icon="el-icon-circle-plus-outline" |
||||
> |
||||
新增 |
||||
</el-button> |
||||
<el-dropdown class="filter-item" trigger="click" v-has-any-permission="['information:delete', 'information:export', |
||||
'information:import']"> |
||||
<el-button> |
||||
{{ $t("table.more") }}<i class="el-icon-arrow-down el-icon--right" /> |
||||
</el-button> |
||||
<el-dropdown-menu slot="dropdown"> |
||||
<el-dropdown-item @click.native="batchDelete" v-has-permission="['information:delete']"> |
||||
{{ $t("table.delete") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="exportExcel" v-has-permission="['information:export']"> |
||||
{{ $t("table.export") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="exportExcelPreview" v-has-permission="['information:export']"> |
||||
{{ $t("table.exportPreview") }} |
||||
</el-dropdown-item> |
||||
<el-dropdown-item @click.native="importExcel" v-has-permission="['information:import']"> |
||||
{{ $t("table.import") }} |
||||
</el-dropdown-item> |
||||
</el-dropdown-menu> |
||||
</el-dropdown> |
||||
</div> |
||||
|
||||
<el-table :data="tableData.records" :key="tableKey" @cell-click="cellClick" |
||||
@filter-change="filterChange" @selection-change="onSelectChange" @sort-change="sortChange" |
||||
border fit row-key="id" ref="table" style="width: 100%;" v-loading="loading"> |
||||
<el-table-column align="center" type="selection" width="40px" :reserve-selection="true"/> |
||||
<el-table-column :label="$t('table.information.storeId')" :show-overflow-tooltip="true" align="center" prop="storeId" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.storeId }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.information.mainTitle')" :show-overflow-tooltip="true" align="center" prop="mainTitle" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.mainTitle }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.information.viceTitle')" :show-overflow-tooltip="true" align="center" prop="viceTitle" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.viceTitle }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.information.content')" :show-overflow-tooltip="true" align="center" prop="content" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.content }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.information.coverImg')" :show-overflow-tooltip="true" align="center" prop="coverImg" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.coverImg }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.information.startTime')" :show-overflow-tooltip="true" align="center" prop="startTime" |
||||
width="170"> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.startTime }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.information.endTime')" :show-overflow-tooltip="true" align="center" prop="endTime" |
||||
width="170"> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.endTime }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.information.state')" :show-overflow-tooltip="true" align="center" prop="state" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.state }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column :label="$t('table.information.isDelete')" :show-overflow-tooltip="true" align="center" prop="isDelete" |
||||
width=""> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.isDelete }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column |
||||
:label="$t('table.createTime')" |
||||
align="center" |
||||
prop="createTime" |
||||
sortable="custom" |
||||
width="170px"> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.createTime }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column |
||||
:label="$t('table.operation')" align="center" column-key="operation" class-name="small-padding fixed-width" width="100px"> |
||||
<template slot-scope="{ row }"> |
||||
<i @click="copy(row)" class="el-icon-copy-document table-operation" :title="$t('common.delete')" |
||||
style="color: #2db7f5;" v-hasPermission="['information:add']"/> |
||||
<i @click="edit(row)" class="el-icon-edit table-operation" :title="$t('common.delete')" |
||||
style="color: #2db7f5;" v-hasPermission="['information:update']"/> |
||||
<i @click="singleDelete(row)" class="el-icon-delete table-operation" :title="$t('common.delete')" |
||||
style="color: #f50;" v-hasPermission="['information:delete']"/> |
||||
<el-link class="no-perm" v-has-no-permission="['information:update', 'information:copy', 'information:delete']"> |
||||
{{ $t("tips.noPermission") }} |
||||
</el-link> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<pagination :limit.sync="queryParams.size" :page.sync="queryParams.current" |
||||
:total="Number(tableData.total)" @pagination="fetch" v-show="tableData.total > 0"/> |
||||
<information-edit :dialog-visible="dialog.isVisible" :type="dialog.type" |
||||
@close="editClose" @success="editSuccess" ref="edit"/> |
||||
<information-import ref="import" :dialog-visible="fileImport.isVisible" :type="fileImport.type" |
||||
:action="fileImport.action" accept=".xls,.xlsx" @close="importClose" @success="importSuccess" /> |
||||
<el-dialog :close-on-click-modal="false" :close-on-press-escape="true" |
||||
title="预览" width="80%" top="50px" :visible.sync="preview.isVisible" v-el-drag-dialog> |
||||
<el-scrollbar> |
||||
<div v-html="preview.context"></div> |
||||
</el-scrollbar> |
||||
</el-dialog> |
||||
<div class="group-content"> |
||||
<el-table |
||||
id="tables" |
||||
:data="tableData.list" |
||||
style="width: 100%" |
||||
v-loading="loading" |
||||
row-key="id" |
||||
> |
||||
<el-table-column |
||||
prop="mainTitle" |
||||
label="活动标题" |
||||
align="center" |
||||
width="200" |
||||
></el-table-column> |
||||
<el-table-column |
||||
prop="viceTitle" |
||||
label="活动简介" |
||||
align="center" |
||||
width="200" |
||||
></el-table-column> |
||||
<!-- <el-table-column |
||||
prop="coverImg" |
||||
label="活动封面图" |
||||
align="center" |
||||
width="200" |
||||
> |
||||
<template slot-scope="scope"> |
||||
<img |
||||
v-if="scope.row.coverImg" |
||||
:src="scope.row.coverImg" |
||||
class="avatar" |
||||
width="80" |
||||
height="80" |
||||
/> |
||||
</template> |
||||
</el-table-column> --> |
||||
<el-table-column |
||||
prop="createTime" |
||||
label="发布时间" |
||||
align="center" |
||||
width="200" |
||||
></el-table-column> |
||||
<el-table-column |
||||
prop="storeName" |
||||
label="发布人(平台)" |
||||
align="center" |
||||
width="200" |
||||
></el-table-column> |
||||
<!-- <el-table-column |
||||
prop="updateTime" |
||||
label="最后修改时间" |
||||
align="center" |
||||
width="200" |
||||
></el-table-column> --> |
||||
<el-table-column label="操作" align="center"> |
||||
<template slot-scope="scope"> |
||||
<el-button |
||||
type="text" |
||||
size="small" |
||||
@click.native.prevent="editGroup(scope.row)" |
||||
> |
||||
编辑 |
||||
</el-button> |
||||
<el-button |
||||
type="text" |
||||
size="small" |
||||
@click.native.prevent="deleteGroup(scope.row)" |
||||
> |
||||
删除 |
||||
</el-button> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
</div> |
||||
<pagination |
||||
v-show="tableData.total > 0" |
||||
:limit.sync="formParams.pageSize" |
||||
:page.sync="formParams.pageNum" |
||||
:total="Number(tableData.total)" |
||||
@pagination="fetch" |
||||
/> |
||||
<grope-edit |
||||
ref="edit" |
||||
:dialog-visible="dialog.isVisible" |
||||
:type="dialog.type" |
||||
@close="editClose" |
||||
@success="getActivityTweetsList" |
||||
/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import Pagination from "@/components/Pagination"; |
||||
import elDragDialog from '@/directive/el-drag-dialog' |
||||
import InformationEdit from "./Edit"; |
||||
import informationApi from "@/api/InformationApi.js"; |
||||
import InformationImport from "@/components/ceres/Import" |
||||
import {convertEnum} from '@/utils/utils' |
||||
import {downloadFile, loadEnums, initDicts, initQueryParams} from '@/utils/commons' |
||||
|
||||
import ActivityTweets from '@/api/ActivityTweets' |
||||
import GropeEdit from './Edit' |
||||
import Pagination from '@/components/Pagination' |
||||
import db from '@/utils/localstorage' |
||||
export default { |
||||
name: "InformationManage", |
||||
directives: { elDragDialog }, |
||||
components: { Pagination, InformationEdit, InformationImport}, |
||||
filters: { |
||||
|
||||
name: 'ActivityTweets', |
||||
components: { |
||||
GropeEdit, |
||||
Pagination, |
||||
}, |
||||
data() { |
||||
return { |
||||
// 编辑 |
||||
dialog: { |
||||
isVisible: false, |
||||
type: "add" |
||||
loading: true, |
||||
formParams: { |
||||
"pageNum": 1, |
||||
"pageSize": 10, |
||||
"searchKey": "", |
||||
"type": 2, |
||||
state: 1 |
||||
}, |
||||
// 预览 |
||||
preview: { |
||||
isVisible: false, |
||||
context: '' |
||||
}, |
||||
// 导入 |
||||
fileImport: { |
||||
dialog: { |
||||
type: 'add', |
||||
isVisible: false, |
||||
type: "import", |
||||
action: `${process.env.VUE_APP_BASE_API}/store/information/import` |
||||
}, |
||||
tableKey: 0, |
||||
queryParams: initQueryParams(), |
||||
selection: [], |
||||
loading: false, |
||||
tableData: { |
||||
total: 0 |
||||
}, |
||||
// 枚举 |
||||
enums: { |
||||
}, |
||||
// 字典 |
||||
dicts: { |
||||
} |
||||
}; |
||||
tableData: [], |
||||
} |
||||
}, |
||||
computed: { |
||||
created() { |
||||
this.getActivityTweetsList() |
||||
}, |
||||
watch: { |
||||
}, |
||||
mounted() { |
||||
this.fetch(); |
||||
|
||||
// 初始化字典和枚举 |
||||
const enumList = []; |
||||
const dictList = []; |
||||
loadEnums(enumList, this.enums, 'store'); |
||||
initDicts(dictList, this.dicts); |
||||
mounted(){ |
||||
}, |
||||
methods: { |
||||
editClose() { |
||||
this.dialog.isVisible = false; |
||||
}, |
||||
editSuccess() { |
||||
this.search(); |
||||
}, |
||||
onSelectChange(selection) { |
||||
this.selection = selection; |
||||
}, |
||||
search() { |
||||
this.fetch({ |
||||
...this.queryParams |
||||
}); |
||||
}, |
||||
reset() { |
||||
this.queryParams = initQueryParams(); |
||||
this.$refs.table.clearSort(); |
||||
this.$refs.table.clearFilter(); |
||||
this.search(); |
||||
}, |
||||
exportExcelPreview() { |
||||
if (this.queryParams.timeRange) { |
||||
this.queryParams.map.createTime_st = this.queryParams.timeRange[0]; |
||||
this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]; |
||||
} |
||||
this.queryParams.map.fileName = '导出数据'; |
||||
informationApi.preview(this.queryParams).then(response => { |
||||
const res = response.data; |
||||
this.preview.isVisible = true; |
||||
this.preview.context = res.data; |
||||
}); |
||||
}, |
||||
exportExcel() { |
||||
if (this.queryParams.timeRange) { |
||||
this.queryParams.map.createTime_st = this.queryParams.timeRange[0]; |
||||
this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]; |
||||
async getActivityTweetsList() { |
||||
this.loading = true |
||||
const res = await ActivityTweets.page(this.formParams) |
||||
const resData = res.data |
||||
const { code } = resData |
||||
if (code === 0) { |
||||
this.tableData = resData.data |
||||
this.loading = false |
||||
console.log(this.tableData,'this.tableData') |
||||
} |
||||
this.queryParams.map.fileName = '导出数据'; |
||||
informationApi.export(this.queryParams).then(response => { |
||||
downloadFile(response); |
||||
}); |
||||
}, |
||||
importExcel() { |
||||
this.fileImport.type = "upload"; |
||||
this.fileImport.isVisible = true; |
||||
this.$refs.import.setModel(false); |
||||
fetch() { |
||||
this.getActivityTweetsList() |
||||
}, |
||||
importSuccess() { |
||||
this.search(); |
||||
}, |
||||
importClose() { |
||||
this.fileImport.isVisible = false; |
||||
}, |
||||
singleDelete(row) { |
||||
this.$refs.table.clearSelection() |
||||
this.$refs.table.toggleRowSelection(row, true); |
||||
this.batchDelete(); |
||||
reset() { |
||||
this.getActivityTweetsList() |
||||
}, |
||||
batchDelete() { |
||||
if (!this.selection.length) { |
||||
this.$message({ |
||||
message: this.$t("tips.noDataSelected"), |
||||
type: "warning" |
||||
}); |
||||
return; |
||||
addGroup() { |
||||
this.dialog = { |
||||
type: 'add', |
||||
isVisible: true, |
||||
} |
||||
this.$confirm(this.$t("tips.confirmDelete"), this.$t("common.tips"), { |
||||
confirmButtonText: this.$t("common.confirm"), |
||||
cancelButtonText: this.$t("common.cancel"), |
||||
type: "warning" |
||||
}) |
||||
.then(() => { |
||||
const ids = this.selection.map(u => u.id); |
||||
this.delete(ids); |
||||
}) |
||||
.catch(() => { |
||||
this.clearSelections(); |
||||
}); |
||||
}, |
||||
clearSelections() { |
||||
this.$refs.table.clearSelection(); |
||||
}, |
||||
delete(ids) { |
||||
informationApi.delete({ ids: ids }).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
this.$message({ |
||||
message: this.$t("tips.deleteSuccess"), |
||||
type: "success" |
||||
}); |
||||
this.search(); |
||||
} |
||||
}); |
||||
}, |
||||
add() { |
||||
this.dialog.type = "add"; |
||||
this.dialog.isVisible = true; |
||||
this.$refs.edit.setInformation({ enums: this.enums, dicts: this.dicts}); |
||||
}, |
||||
copy(row) { |
||||
this.$refs.edit.setInformation({row, enums: this.enums, dicts: this.dicts}); |
||||
this.dialog.type = "copy"; |
||||
this.dialog.isVisible = true; |
||||
}, |
||||
edit(row) { |
||||
this.$refs.edit.setInformation({row, enums: this.enums, dicts: this.dicts}); |
||||
this.dialog.type = "edit"; |
||||
this.dialog.isVisible = true; |
||||
this.$refs.edit.setParams(null) |
||||
}, |
||||
fetch(params = {}) { |
||||
this.loading = true; |
||||
if (this.queryParams.timeRange) { |
||||
this.queryParams.map.createTime_st = this.queryParams.timeRange[0]; |
||||
this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]; |
||||
} |
||||
|
||||
this.queryParams.current = params.current ? params.current : this.queryParams.current; |
||||
this.queryParams.size = params.size ? params.size : this.queryParams.size; |
||||
|
||||
informationApi.page(this.queryParams).then(response => { |
||||
const res = response.data; |
||||
if (res.isSuccess) { |
||||
this.tableData = res.data; |
||||
} |
||||
}).finally(() => this.loading = false); |
||||
editClose() { |
||||
this.dialog.isVisible = false |
||||
}, |
||||
sortChange(val) { |
||||
this.queryParams.sort = val.prop; |
||||
this.queryParams.order = val.order; |
||||
if (this.queryParams.sort) { |
||||
this.search(); |
||||
editGroup(row) { |
||||
const {id, mainTitle, viceTitle, coverImg, startTime, endTime, content, state} = row |
||||
this.dialog = { |
||||
type: 'edit', |
||||
isVisible: true, |
||||
} |
||||
this.$refs.edit.setParams(row) |
||||
}, |
||||
filterChange (filters) { |
||||
for (const key in filters) { |
||||
if(key.includes('.')) { |
||||
const val = { }; |
||||
val[key.split('.')[1]] = filters[key][0]; |
||||
this.queryParams.model[key.split('.')[0]] = val; |
||||
} else { |
||||
this.queryParams.model[key] = filters[key][0] |
||||
} |
||||
async delete(params) { |
||||
const res = await ActivityTweets.delete(params) |
||||
const resData = res.data |
||||
const { code } = resData |
||||
if (code === 0) { |
||||
this.$message({ |
||||
message: this.$t('tips.deleteSuccess'), |
||||
type: 'success', |
||||
}) |
||||
this.getActivityTweetsList() |
||||
} |
||||
this.search() |
||||
}, |
||||
cellClick (row, column) { |
||||
if (column['columnKey'] === "operation") { |
||||
return; |
||||
} |
||||
let flag = false; |
||||
this.selection.forEach((item)=>{ |
||||
if(item.id === row.id) { |
||||
flag = true; |
||||
this.$refs.table.toggleRowSelection(row); |
||||
} |
||||
deleteGroup(row) { |
||||
const { id } = row |
||||
this.$confirm(this.$t('tips.confirmDelete'), this.$t('common.tips'), { |
||||
confirmButtonText: this.$t('common.confirm'), |
||||
cancelButtonText: this.$t('common.cancel'), |
||||
type: 'warning', |
||||
}) |
||||
|
||||
if(!flag){ |
||||
this.$refs.table.toggleRowSelection(row, true); |
||||
} |
||||
.then(() => { |
||||
this.delete({ |
||||
id, |
||||
}) |
||||
}) |
||||
.catch(() => {}) |
||||
}, |
||||
} |
||||
}; |
||||
}, |
||||
} |
||||
</script> |
||||
<style lang="scss" scoped></style> |
||||
<style lang="less" scoped> |
||||
.group-page { |
||||
padding: 15px 20px; |
||||
.toolbar { |
||||
margin-bottom: 20px; |
||||
text-align: left; |
||||
.el-input{ |
||||
margin-right: 10px !important; |
||||
} |
||||
.group-name { |
||||
width: 180px; |
||||
} |
||||
} |
||||
} |
||||
</style> |
||||
|
Loading…
Reference in new issue