提交 5da5ee84 authored 作者: 龙菲's avatar 龙菲

文献管理

上级 0a3512e2
......@@ -9,6 +9,14 @@ export function getLiteratureList(data) {
data
})
}
export function addLiterature(data) {
return request({
url: '/sysLiterature/add',
method: 'post',
data
})
}
export function editLiterature(data) {
return request({
url: '/sysLiterature/update',
......@@ -16,3 +24,18 @@ export function editLiterature(data) {
data
})
}
// 带权限的文献列表分页
export function getLtListPer(data) {
return request({
url: '/sysLiterature/listByPagePer',
method: 'post',
data
})
}
export function deleteLt(data) {
return request({
url: '/sysLiterature/delete',
method: 'delete',
data
})
}
import {
getDictCode
} from "@/api/dict";
import {
getLiteratureList
} from '@/api/literature'
import store from "@/store";
import Vue from "vue";
class Dict {
constructor(dict) {
this.dict = dict;
}
async init(names) {
// 先判断list中的name是否存在,如果不存在,把不存在的放置在一个list中,再对list进行获取
var nonExistentNames = []
// debugger
names.forEach(name => {
if (store.getters.dicts[name]) {
Vue.set(this.dict, name, store.getters.dicts[name]);
} else {
nonExistentNames.push(name) //存入list中,单独进行处理调用
}
});
var index = nonExistentNames.indexOf('literature')
if (index != -1) {
// debugger
Vue.set(this.dict, 'literature', []);
nonExistentNames.splice(index, 1)
var params = {
limit: 100,
page: 1
}
var res = await getLiteratureList(params)
if (res.code == 0) {
var literatureList = res.data.records
Vue.set(this.dict, 'literature', literatureList);
this.dict['literature'] = Object.freeze(literatureList)
store.commit("dict/SET_DICTS", {
label: 'literature',
value: Object.freeze(literatureList),
});
}
}
if (nonExistentNames.length > 0) {
// debugger
var res = await getDictCode(nonExistentNames)
nonExistentNames.forEach(n => {
Vue.set(this.dict, n, []);
// var arr = []
var obj = {}
if (res.code == 0) {
res.data.map(item => {
if (item.dictType === n) {
obj[item.value]=item.label
}
})
this.dict[n] = Object.freeze(obj)
store.commit("dict/SET_DICTS", {
label: n,
value: Object.freeze(obj),
});
}
})
}
}
}
const install = function (Vue) {
Vue.mixin({
data() {
// 如果在调用组件处data中有定义dicts,再进行初始化dict
if (
this.$options.dicts instanceof Array &&
this.$options.dicts.length > 0
) {
return {
dict: {}
};
} else {
return {};
}
},
created() {
// 如果在调用组件处data中有定义dicts,再进行获取dicts中定义的字典
if (
this.$options.dicts instanceof Array &&
this.$options.dicts.length > 0
) {
new Dict(this.dict).init(this.$options.dicts);
}
},
});
};
export default {
install
};
......@@ -61,12 +61,12 @@ export default {
edit: "el-icon-edit",
view: "el-icon-view",
delete: "el-icon-delete",
download:'el-icon-download'
},
};
},
methods: {
clickOperation(operation) {
console.log('123');
this.$emit("handleOperation", operation, this.rawData);
},
},
......
......@@ -13,8 +13,6 @@ import router from './router'
import '@/icons' // icon
import '@/permission' // permission control
import dict from '@/components/Dict'
Vue.use(dict);
Vue.use(ElementUI)
......
import {
getDictCode,
getDictTree
} from '@/api/dict'
import {
getCulturalRelicList
} from '@/api/culturalRelic'
import {
getLiteratureList
} from '@/api/literature'
import {
getLtListPer
} from '@/api/literature'
const state = {
dicts: {},
crList: [] //文物列表,布展关联文物时使用
dicts: {}, //字典
crList: [], //文物列表
ltList: [] //文献列表
};
const mutations = {
......@@ -19,61 +29,116 @@ const mutations = {
};
const actions = {
// user login
getDictTree({
/**
* 获取普通list结构(非树结构)的字典
* @param {Array} data 字典的key集合
* @returns {Promise}
*/
getDictList({
commit
}, data) {
let dicts = []
let dicts = {}
let requestDicts = []
data.forEach(i => {
// 如果state中不存在的就需要重新获取
if (!state.dicts[i]) {
requestDicts.push(i)
} else {
// 如果存在就直接存入dicts中
let obj = {}
obj[i] = state.dicts[i]
dicts.push(obj)
dicts[i] = state.dicts[i]
}
});
return new Promise((resolve, reject) => {
getDictTree(requestDicts).then(res => {
let dictsObj = {}
requestDicts.forEach(reqDict => {
dictsObj[reqDict] = []
res.data.map(item => {
if (item.dictType == reqDict) {
dictsObj[reqDict].push(item)
if (requestDicts.length > 0) {
return new Promise((resolve, reject) => {
getDictCode(requestDicts).then(res => {
requestDicts.forEach(reqDict => {
var obj = {}
if (res.code == 0) {
res.data.map(item => {
if (item.dictType == reqDict) {
obj[item.value] = item.label
}
})
dicts[reqDict] = Object.freeze(obj)
commit('SET_DICTS', {
label: reqDict,
value: Object.freeze(obj)
})
}
})
commit("SET_DICTS", {
label: reqDict,
value: Object.freeze(dictsObj[reqDict]),
});
resolve(dicts)
}).catch(error => {
reject(error)
})
resolve(dictsObj)
}).catch(error => {
reject(error)
});
} else {
return new Promise((resolve, reject) => {
resolve(dicts)
})
});
}
},
/**
* 获取树形结构的字典树,如文物年代、文物质地
* @param {Array} data 字典的key集合
* @returns {Promise}
*/
getDictTree({
commit
}, data) {
let dicts = {}
let requestDicts = []
data.forEach(i => {
if (!state.dicts[i]) {
requestDicts.push(i)
} else {
dicts[i] = state.dicts[i]
}
});
if (requestDicts.length > 0) {
return new Promise((resolve, reject) => {
getDictTree(requestDicts).then(res => {
let dictsObj = {}
requestDicts.forEach(reqDict => {
dictsObj[reqDict] = []
res.data.map(item => {
if (item.dictType == reqDict) {
dictsObj[reqDict].push(item)
}
})
commit("SET_DICTS", {
label: reqDict,
value: Object.freeze(dictsObj[reqDict]),
});
})
resolve(dictsObj)
}).catch(error => {
reject(error)
})
});
} else {
return new Promise((resolve, reject) => {
resolve(dicts)
})
}
},
/**
* 获取文物列表
* @param {Boolean} isReload 是否要重新加载
* @param {params} params 分页或一些查询参数
* @returns {Promise}
*/
getCrList({
commit
}, {
isReload,
params
}) {
// 如果是空或者需要重新加载则重新调取接口获取,否则直接获取状态管理中的
if (!state.crList || state.crList == 0 || isReload) {
if (!state.crList || state.crList.length == 0 || isReload) {
return new Promise((resolve, reject) => {
getCulturalRelicList(params).then(response => {
const {
data
} = response
console.log('response',response);
commit('SET_CR_LIST', data.records)
resolve(response)
}).catch(error => {
......@@ -87,6 +152,45 @@ const actions = {
}
},
/**
* 获取文献列表
* @param {Boolean} hasPer 是否含有权限
* @param {params} params 分页或一些查询参数
* @returns {Promise}
*/
getLtList({
commit
}, {
hasPer,
params
}) {
if (hasPer) {
return new Promise((resolve, reject) => {
getLtListPer(params).then(response => {
const {
data
} = response
commit('SET_CR_LIST', data.records)
resolve(response)
}).catch(error => {
reject(error)
})
})
} else {
return new Promise((resolve, reject) => {
getLiteratureList(params).then(response => {
const {
data
} = response
commit('SET_CR_LIST', data.records)
resolve(response)
}).catch(error => {
reject(error)
})
})
}
},
}
......
......@@ -2,7 +2,7 @@ import axios from 'axios'
import {
getToken
} from '@/utils/auth'
import request from "./request";
// var uploadUrl =
// process.env.NODE_ENV === "test" ||
// process.env.NODE_ENV === "development" ?
......@@ -23,7 +23,7 @@ var importZipUrl = process.env.VUE_APP_BASE_API + "/bizImport/importZip"
* @param data
* @returns {Promise}
*/
export function upload(data) {
export function uploadFile(data) {
return new Promise((resolve, reject) => {
axios.post(uploadUrl, data, {
headers: {
......@@ -85,3 +85,68 @@ export function importZip(data, callback) {
})
})
}
/**
* 下载文件
* @param href 下载地址
* @param dowmloadName 下载文件用户看到的名称
*/
export function downloadFile(href, dowmloadName) {
let a = document.createElement("a");
a.href = href;
a.download = dowmloadName;
a.style.display = "none";
document.body.appendChild(a);
a.click();
a.remove();
}
/**
* 预览文件
* @param href 预览地址
* @param previewName 预览文件用户看到的名称
*/
export function previewFile(href, previewName) {
let a = document.createElement("a");
a.href = href;
a.target = '_blank'
a.download = previewName;
a.style.display = "none";
document.body.appendChild(a);
a.click();
a.remove();
}
/**
* 下载文件
* @param url 下载地址
* @param fileName 下载文件用户看到的名称
* @param typeSuffix 文件后缀
*/
export function downloadBlob(url, fileName, typeSuffix) {
axios({
url,
method: 'get',
responseType: 'blob',
headers: {
'authorization': getToken()
}
}).
then(response => {
console.log('response', response);
const blob = new Blob([response.data])
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
if (typeSuffix) {
link.download = fileName + '.' + typeSuffix
} else {
link.download = fileName
}
link.click()
URL.revokeObjectURL(link.href)
}).catch(err => {
console.error(err);
})
};
......@@ -45,7 +45,9 @@ export function parseTime(time, cFormat) {
const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
const value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
if (key === 'a') {
return ['日', '一', '二', '三', '四', '五', '六'][value]
}
return value.toString().padStart(2, '0')
})
return time_str
......@@ -123,18 +125,18 @@ export function param2Obj(url) {
* @returns {Function}
* @constructor
*/
export const Debounce = (fn, t) => {
export const Debounce = (fn, t) => {
let delay = t || 500;
let timer;
return function() {
let args = arguments;
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
timer = null;
fn.apply(this, args);
}, delay);
return function () {
let args = arguments;
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
timer = null;
fn.apply(this, args);
}, delay);
}
};
......@@ -150,18 +152,19 @@ export const Throttle = (fn, t) => {
let last;
let timer;
let interval = t || 500;
return function() {
let args = arguments;
let now = +new Date();
if (last && now - last < interval) {
clearTimeout(timer);
timer = setTimeout(() => {
last = now;
fn.apply(this, args);
}, interval);
} else {
last = now;
fn.apply(this, args);
}
return function () {
let args = arguments;
let now = +new Date();
if (last && now - last < interval) {
clearTimeout(timer);
timer = setTimeout(() => {
last = now;
fn.apply(this, args);
}, interval);
} else {
last = now;
fn.apply(this, args);
}
}
}
......@@ -23,7 +23,7 @@
></el-input>
</el-form-item>
<el-form-item label="文物类别" :label-width="formLabelWidth">
<el-form-item label="文物类别" :label-width="formLabelWidth">
<el-select
v-model="dialogForm.type"
placeholder="请选择文物类别"
......@@ -31,7 +31,7 @@
filterable
>
<el-option
v-for="(value, key) in dict.culturalRelicType"
v-for="(value, key) in dicts.culturalRelicType"
:key="key"
:label="value"
:value="key"
......@@ -47,7 +47,7 @@
filterable
>
<el-option
v-for="(value, key) in dict.culturalRelicLevel"
v-for="(value, key) in dicts.culturalRelicLevel"
:key="key"
:label="value"
:value="key"
......@@ -56,7 +56,7 @@
</el-select>
</el-form-item>
<el-form-item label="文物质地" :label-width="formLabelWidth">
<el-cascader
<el-cascader
style="width: 100%"
v-model="dialogForm.textureType"
:options="culturalRelicTextureType"
......@@ -96,7 +96,6 @@
filterable
>
</el-cascader>
</el-form-item>
<el-form-item label="文物数量" :label-width="formLabelWidth">
<!-- <el-input
......@@ -273,13 +272,13 @@ export default {
},
},
computed: {
...mapGetters(["userInfo"]),
dialogVisible: {
get: function () {
return this.visible;
},
set: function () {},
},
...mapGetters(["userInfo", "dicts"]),
// dialogVisible: {
// get: function () {
// return this.visible;
// },
// set: function () {},
// },
title() {
if (this.dialogForm.crId) {
return "修改信息";
......@@ -287,15 +286,16 @@ export default {
return "新增发布";
}
},
// sayExplain() {
// if (this.dialogForm.sayExplainVo) {
// return this.dialogForm.sayExplainVo;
// } else {
// return [];
// }
// },
},
watch: {
visible: {
handler: function (value) {
console.log('visible',value);
this.dialogVisible = value;
},
immediate: true,
deep: true,
},
form: {
handler(value) {
this.dialogForm = JSON.parse(JSON.stringify(value));
......@@ -326,7 +326,7 @@ export default {
this.dialogForm.literatureVo &&
this.dialogForm.literatureVo.length > 0
) {
this.literatureList = [...this.dict.literature];
this.literatureList = [...this.dicts.literature];
this.literatureNames = [];
this.literatureValues = [];
this.dialogForm.literatureVo.forEach((lt) => {
......@@ -342,13 +342,7 @@ export default {
immediate: true,
deep: true,
},
dict(value) {
if (value) {
this.dict = value;
}
},
},
dicts: ["culturalRelicLevel", "culturalRelicType", "literature"],
data() {
return {
dialogForm: {
......@@ -384,23 +378,20 @@ export default {
children: "children",
checkStrictly: true, //单选选择任意一级选项
},
dialogVisible: false,
};
},
async created() {
// setTimeout(() => {
// console.log("22222this.dict", this.dict);
// });
},
mounted() {
this.$store
.dispatch("dict/getDictTree", [
"culturalRelicTextureType",
"culturalRelicYears",
])
.then((res) => {
this.culturalRelicTextureType = res.culturalRelicTextureType;
this.culturalRelicYears = res.culturalRelicYears;
});
await this.$store.dispatch("dict/getDictList", [
"culturalRelicLevel",
"culturalRelicType",
]);
let res = await this.$store.dispatch("dict/getDictTree", [
"culturalRelicTextureType",
"culturalRelicYears",
]);
this.culturalRelicTextureType = res.culturalRelicTextureType;
this.culturalRelicYears = res.culturalRelicYears;
},
methods: {
// 关联文献查询
......@@ -537,7 +528,8 @@ export default {
}
// 处理质地
if (params.textureType instanceof Array) {
params.textureType = params.textureType[params.textureType.length - 1].trim();
params.textureType =
params.textureType[params.textureType.length - 1].trim();
}
let res = await editCulturalRelic(params);
if (res.code == 0) {
......
......@@ -37,19 +37,33 @@
<div class="upload-progress" v-if="isUpLoading">
<div class="subtitle">
<div class="divider"></div>
<div class="label">上传进度</div>
<div class="label">当前上传列表</div>
</div>
<el-progress :percentage="percentState" :status="uploadStatus"></el-progress>
<!-- <el-progress
:percentage="percentState"
:status="progressStatus"
></el-progress> -->
<!-- <el-table>
<el-table-column prop="fileName" label="文件名"> </el-table-column>
<el-table-column prop="size" label="文件大小"> </el-table-column>
<el-table-column prop="progress" label="进度">
<template slot-scope="scope">
<i class="el-icon-time"></i>
<span style="margin-left: 10px">{{ scope.row.date }}</span>
</template>
</el-table-column>
<el-table-column prop="operation" label="操作"> </el-table-column>
</el-table> -->
</div>
<div class="upload-records">
<div class="subtitle">
<div class="divider"></div>
<div class="label">上传记录</div>
<div class="label">上传历史记录</div>
</div>
<TablePage :data="list.records" :tableTitle="tableTitle" />
</div>
<div class="dialog-footer">
<el-button type="primary" @click="handleClose">关闭</el-button>
<el-button type="primary" @click.native="handleClose">关闭</el-button>
</div>
</div>
</el-dialog>
......@@ -71,9 +85,6 @@ export default {
},
},
watch: {
// visible(value) {
// this.dialogVisible = value;
// },
visible: {
handler: function (value) {
this.dialogVisible = value;
......@@ -87,7 +98,6 @@ export default {
dialogVisible: false,
isUpLoading: false,
percentState: 0,
uploadStatus:'primary',
list: {
records: [],
current: 1,
......@@ -120,6 +130,7 @@ export default {
columnAlign: "center",
},
],
progressStatus: null,
};
},
mounted() {
......@@ -128,7 +139,7 @@ export default {
methods: {
// 取消编辑
cancelForm() {
this.$emit("handleClose");
this.handleClose();
},
async loadData() {
const params = {
......@@ -139,12 +150,33 @@ export default {
this.list = res.data;
},
handleClose(done) {
this.$confirm("确认关闭?")
.then((_) => {
done();
this.$emit("handleClose");
let title = this.isUpLoading
? "当前有上传任务,是否后台继续上传?"
: "确认关闭?";
let confirmButtonText = this.isUpLoading ? "是" : "确定";
let cancelButtonText = this.isUpLoading ? "取消上传" : "取消";
let that = this;
this.$confirm(title, "提示", {
confirmButtonText,
cancelButtonText,
type: "warning",
})
.then(() => {
// 点击继续后台上传
if (that.isUpLoading) {
this.$message.warning("文件仍在上传,请勿关闭窗口!");
}
this.dialogVisible = false;
that.$emit("handleClose");
})
.catch((_) => {});
.catch(() => {
// 点击取消上传
if (that.isUpLoading) {
// TODO:取消上传
this.$message.info("已取消上传!");
}
});
},
handleDownloadTemplate() {
......@@ -156,31 +188,45 @@ export default {
a.click();
a.remove();
},
async handleChange(file, fileList) {
console.log("handleChange", file, fileList);
if (file.status == "ready") {
this.isUpLoading = true;
// TODO:
let formData = new FormData();
formData.append("type", "biz_cultural_relic");
formData.append("zipFile", file.raw);
let res = await importZip(formData, this.updateProgress);
if (res.code == 0) {
this.$message.success("上传成功!");
let { name, size, raw } = file;
size = size / 1024 / 1024 / 100;
console.log('size',size);
// let fileItem = {
// name,
// size,
// };
// this.fileList.push(file);
// this.isUpLoading = true;
// let formData = new FormData();
// formData.append("type", "biz_cultural_relic");
// formData.append("zipFile", file.raw);
// let res = await importZip(formData, this.updateProgress);
// if (res.code == 0) {
// this.percentState = 100;
// this.$message.success("上传成功!");
// this.progressStatus = "success";
// this.isUpLoading = false;
} else {
this.$message.error(res.msg);
}
// let index = this.fileList.indexOf(file);
// this.fileList.splice(index, 1); //上传成功后删除当前文件
// } else {
// this.progressStatus = "warning";
// this.$message.error(res.msg);
// }
}
},
updateProgress(e) {
//e为回调回来的参数 通过进行和total的值来进行进度
this.percentState = parseInt((e.loaded / e.total) * 100);
if (this.percentState == 100) {
this.percentState = parseInt((e.loaded / e.total) * 100) - 1;
if (this.percentState == 99) {
// this.$message.success("上传成功!");
// this.isUpLoading = false;
this.uploadStatus = 'success'
// this.uploadStatus = "success";
}
},
},
......
<template>
<div
class="app-container"
v-loading="loading"
element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.3)"
>
<div class="app-container">
<div class="top-bar">
<SearchBar :config="searchConfig" @search="search" @reset="reset" />
<div class="tools">
......@@ -52,16 +46,16 @@
/>
</template>
<template v-slot:years="data">
{{ dict.cultural_relic_years[data.scope.years] }}
{{ dicts.cultural_relic_years[data.scope.years] }}
</template>
<template v-slot:level="data">
{{ dict.cultural_relic_level[data.scope.level] }}
{{ dicts.cultural_relic_level[data.scope.level] }}
</template>
<template v-slot:textureType="data">
{{ dict.cultural_relic_texture[data.scope.textureType] }}
{{ dicts.cultural_relic_texture[data.scope.textureType] }}
</template>
<template v-slot:type="data">
{{ dict.cultural_relic_type[data.scope.type] }}
{{ dicts.cultural_relic_type[data.scope.type] }}
</template>
<template v-slot:operates="scope">
<TableOperation
......@@ -98,6 +92,7 @@
<script>
import TablePage from "@/components/Table/TablePage.vue";
import TableOperation from "@/components/Table/TableOperation.vue";
import SearchBar from "@/components/SearchBar";
import { title, operates, operations } from "./config";
import {
getCulturalRelicList,
......@@ -107,23 +102,21 @@ import {
} from "@/api/culturalRelic";
import InfoEditDialog from "./components/InfoEditDialog";
import MultiUploadDialog from "./components/MultiUploadDialog";
import SearchBar from "@/components/SearchBar";
import { mapGetters } from "vuex";
export default {
components: {
TablePage,
TableOperation,
InfoEditDialog,
SearchBar,
MultiUploadDialog
MultiUploadDialog,
},
dicts: [
// "cultural_relic_years",
"culturalRelicLevel",
// "cultural_relic_texture",
"culturalRelicType",
],
// dicts: [
// // "cultural_relic_years",
// "culturalRelicLevel",
// // "cultural_relic_texture",
// "culturalRelicType",
// ],
data() {
return {
list: {
......@@ -196,13 +189,6 @@ export default {
imgList: [],
};
},
watch: {
dict(value) {
if (value) {
this.dict = value;
}
},
},
computed: {
tableTitle() {
return title;
......@@ -223,7 +209,7 @@ export default {
};
},
},
mounted() {
async created() {
this.loadData();
},
methods: {
......@@ -286,7 +272,9 @@ export default {
}
break;
case "multiAdd":
this.multiUploadVisible = true
// debugger
this.multiUploadVisible = true;
console.log('this.multiUploadVisible',this.multiUploadVisible);
break;
}
},
......@@ -360,6 +348,7 @@ export default {
},
handleMultiUploadClose() {
this.multiUploadVisible = false;
console.log('父组件关闭被触发');
},
},
};
......
......@@ -29,7 +29,7 @@
style="width: 100%"
>
<el-option
v-for="(value, key) in dict.display_type"
v-for="(value, key) in dicts.display_type"
:key="key"
:label="value"
:value="key"
......@@ -258,7 +258,7 @@ export default {
},
},
computed: {
...mapGetters(["userInfo"]),
...mapGetters(["userInfo", "dicts"]),
dialogVisible: {
get: function () {
return this.visible;
......@@ -369,13 +369,11 @@ export default {
},
immediate: true,
},
dict(value) {
if (value) {
this.dict = value;
}
},
},
dicts: ["display_character", "display_type", "literature"],
async created() {
await this.$store.dispatch("dict/getDictList", ["display_type"]);
},
// dicts: ["display_character", "display_type", "literature"],
data() {
return {
dialogForm: {
......@@ -418,7 +416,17 @@ export default {
};
setTimeout(async () => {
this.loading = false;
const res = await getLiteratureList(params);
// const res = await getLiteratureList(params);
// if (res.code == 0) {
// this.literatureList = res.data.records;
// } else {
// this.literatureList = [];
// this.$message.error(res.msg);
// }
const res = await this.$store.dispatch("dict/getLtList", {
hasPer:false,
params,
});
if (res.code == 0) {
this.literatureList = res.data.records;
} else {
......@@ -427,7 +435,7 @@ export default {
}
}, 500);
},
// 关联文查询
// 关联文查询
searchCR(queryString) {
let that = this;
if (!queryString.trim()) {
......@@ -663,6 +671,7 @@ export default {
deptId,
regionCode,
};
// params.displayCharacter = 1;//展览类型传布展
params.literature = this.literatureValues.join(",");
params.status = this.dialogForm.status ? 1 : 0;
params.crIds = this.crIds.join(",");
......
......@@ -28,7 +28,7 @@
</el-popconfirm>
</template>
<template v-slot:displayType="data">
{{ dict.display_type[data.scope.type] }}
{{ dicts.display_type[data.scope.type] }}
</template>
<template v-slot:faceImageUrl="data">
<img
......@@ -116,7 +116,7 @@ import InfoEditDialog from "./components/InfoEditDialog";
import PreviewDialog from "./components/PreviewDialog";
import CopyDialog from "./components/CopyDialog";
import SearchBar from "@/components/SearchBar";
import { mapGetters } from "vuex";
export default {
components: {
TablePage,
......@@ -189,14 +189,8 @@ export default {
displayTypes: {},
};
},
watch: {
dict(value) {
if (value) {
this.dict = value;
}
},
},
computed: {
...mapGetters(["dicts"]),
tableTitle() {
return title;
},
......@@ -216,8 +210,9 @@ export default {
};
},
},
dicts: ["display_type"],
mounted() {
async created() {
await this.$store.dispatch("dict/getDictList", ["display_type"]);
this.loadData();
},
methods: {
......@@ -342,9 +337,9 @@ export default {
const { exhibitionId } = value;
let res = await getDisplayById({ exhibitionId });
delete res.data.exhibitionId;
this.form = {...res.data};
this.form = { ...res.data };
this.editDialogVisible = true;
console.log('this.form',this.form);
console.log("this.form", this.form);
},
},
};
......
<template>
<el-dialog
:visible.sync="dialogVisible"
:visible="dialogVisible"
width="40%"
style="height: 98%"
:before-close="handleClose"
......@@ -22,47 +22,52 @@
</el-form-item>
<el-form-item label="作者" :label-width="formLabelWidth">
<el-input
v-model="dialogForm.name"
v-model="dialogForm.authors"
autocomplete="off"
placeholder="请输入作者"
></el-input>
</el-form-item>
<el-form-item label="日期" :label-width="formLabelWidth">
<!-- <el-input
v-model="dialogForm.name"
<el-form-item label="文献来源" :label-width="formLabelWidth">
<el-input
v-model="dialogForm.source"
autocomplete="off"
placeholder="请输入作者"
></el-input> -->
placeholder="请输入文献来源"
></el-input>
</el-form-item>
<el-form-item label="出版/发布日期" :label-width="formLabelWidth">
<el-date-picker
style="width: 100%"
v-model="dialogForm.date"
type="date"
placeholder="请选择日期(出版年份、发布日期)"
placeholder="请选择出版/发布日期"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
<el-form-item label="备注" :label-width="formLabelWidth">
<el-input
type="textarea"
placeholder="请输入备注"
v-model="dialogForm.remark"
maxlength="600"
show-word-limit
>
</el-input>
</el-form-item>
<el-form-item label="状态" :label-width="formLabelWidth">
<el-switch v-model="status"> </el-switch>
</el-form-item>
<el-form-item label="文件" :label-width="formLabelWidth">
<AutoUploader
v-model="ltFile"
<ManualUploader
:files="files"
:fileLimit="1"
:fileSize="50"
listType="text"
:fileType="['pdf']"
ref="museumFaceImage"
ref="pdf"
/>
</el-form-item>
<el-form-item label="备注" :label-width="formLabelWidth">
<el-input
type="textarea"
placeholder="请输入备注"
v-model="dialogForm.remark"
maxlength="600"
show-word-limit
>
</el-input>
</el-form-item>
</el-form>
</div>
<div class="dialog-footer">
......@@ -75,13 +80,14 @@
</template>
<script>
import { addVirtual, editVirtual } from "@/api/vitual";
import AutoUploader from "@/components/Uploader/AutoUploader.vue";
import { addLiterature, editLiterature } from "@/api/literature";
import ManualUploader from "@/components/Uploader/ManualUploader.vue";
import { mapGetters } from "vuex";
import { uploadFile } from "@/utils/file";
export default {
name: "InfoEditDialog",
components: {
AutoUploader,
ManualUploader,
},
props: {
visible: {
......@@ -95,17 +101,11 @@ export default {
},
computed: {
...mapGetters(["userInfo"]),
dialogVisible: {
get: function () {
return this.visible;
},
set: function () {},
},
title() {
if (this.dialogForm.bvId) {
return "修改虚拟展厅信息";
if (this.dialogForm.literatureId) {
return "修改文献";
} else {
return "添加虚拟展厅";
return "添加文献";
}
},
},
......@@ -113,28 +113,27 @@ export default {
form: {
handler: function (value) {
let that = this;
that.dialogForm = JSON.parse(JSON.stringify(value));
// 编辑状态
if (that.dialogForm.literatureId) {
// console.log("that.dialogForm.", that.dialogForm);
// 回填状态
that.status = Boolean(Number(that.dialogForm.status));
// 回填封面
if (this.dialogForm.files) {
that.files = [
{
name: this.dialogForm.name + "封面.png",
url: this.dialogForm.faceImageUrl,
fileId: this.dialogForm.faceImage,
},
];
// 回填文件
if (that.dialogForm.files) {
that.files = that.dialogForm.files;
}
}
},
immediate: true,
deep: true,
},
status(value) {
console.log(value);
visible: {
handler: function (value) {
this.dialogVisible = value;
},
deep: true,
immediate: true,
},
},
data() {
......@@ -143,6 +142,7 @@ export default {
formLabelWidth: "100px",
status: false,
files: [], //文献文件
dialogVisible: false,
};
},
methods: {
......@@ -159,30 +159,38 @@ export default {
},
async handleSubmit() {
if (this.dialogForm.bvId) {
let params = { ...this.dialogForm };
// 回填文件
if (this.faceImage.length > 0) {
params.faceImage = this.faceImage[0].fileId;
// debugger
// console.log(this.dialogForm);
// return
let params = JSON.parse(JSON.stringify(this.dialogForm));
// 回填文件
let file = this.$refs.pdf.getFiles();
let formData = new FormData();
// console.log("file", file);
// return
// debugger;
if (file[0].status == "ready") {
// debugger;
formData.append("files", file[0].raw);
let upLoadRes = await uploadFile(formData);
if (upLoadRes.code == 0) {
params.pdfFile = upLoadRes.data[0].fileId;
} else {
this.$message.error("上传失败!:" + upLoadRes.data.msg);
}
// 处理状态
// debugger
params.status = this.status ? 1 : 0;
let res = await editVirtual(params);
} else if (file[0].status == "success") {
params.pdfFile = file[0].fileId;
}
// 修改状态
params.status = this.status ? 1 : 0;
if (params.literatureId) {
let res = await editLiterature(params);
if (res.code == 0) {
this.$message.success("修改成功!");
this.reload();
}
} else {
let params = { ...this.dialogForm };
// 回填图片
if (this.faceImage.length > 0) {
params.faceImage = this.faceImage[0].fileId;
}
// 处理状态
params.status = this.status ? 1 : 0;
// return
let res = await addVirtual(params);
let res = await addLiterature(params);
if (res.code == 0) {
this.$message.success("添加成功!");
this.reload();
......@@ -190,16 +198,16 @@ export default {
}
},
reload() {
this.$emit("refresh", true); //需要重新获取orgTree
this.$emit("refresh");
this.$emit("handleClose");
this.faceImage = [];
this.files = [];
},
handleClose(done) {
this.$confirm("确认关闭?")
.then((_) => {
done();
this.$emit("handleClose");
this.faceImage = [];
this.files = [];
})
.catch((_) => {});
},
......@@ -227,15 +235,10 @@ export default {
flex: 1;
margin-right: 48px;
}
.relate {
flex: 1;
}
}
.dialog-footer {
display: flex;
justify-content: flex-end;
}
</style>
\ No newline at end of file
export const title = [{
prop: "name",
label: "名称",
columnAlign: 'center',
width: 200,
showOverFlowToolTip: true
},
{
prop: "authors",
label: "作者",
columnAlign: 'center',
},
prop: "name",
label: "名称",
columnAlign: 'center',
width: 200,
showOverFlowToolTip: true
},
{
prop: "authors",
label: "作者",
columnAlign: 'center',
},
{
prop: "browseCount",
label: "浏览量",
columnAlign: 'center',
},
{
prop: "status",
label: "状态",
columnAlign: 'center',
isStatus: true,
width: 100
},
{
prop: "date",
label: "日期(出版年份、发布日期)",
columnAlign: 'center',
},
{
prop: "pdfFile",
label: "pdf文件",
columnAlign: 'center',
},
{
prop: "source",
label: "文献来源",
columnAlign: 'center',
},
{
prop: "remark",
label: "备注",
columnAlign: 'center',
showOverFlowToolTip: true,
},
{
prop: "browseCount",
label: "浏览量",
columnAlign: 'center',
},
{
prop: "status",
label: "状态",
columnAlign: 'center',
isStatus: true,
width: 100
},
{
prop: "date",
label: "出版/发布日期",
columnAlign: 'center',
},
// {
// prop: "pdfFile",
// label: "pdf文件",
// columnAlign: 'center',
// },
{
prop: "source",
label: "文献来源",
columnAlign: 'center',
},
{
prop: "remark",
label: "备注",
columnAlign: 'center',
showOverFlowToolTip: true,
},
]
export const operates = {
operate: true,
label: "操作",
width: "200px",
titleAlign: "center",
columnAlign: "center",
operate: true,
label: "操作",
width: "360px",
minwidth: "220px",
titleAlign: "center",
columnAlign: "center",
}
export const operations = [
// {
// type: 'view',
// title: '预览'
// },
{
type: 'edit',
title: '编辑'
},
{
type: 'delete',
title: '删除'
},
export const operations = [{
type: 'view',
title: '预览'
},
{
type: 'download',
title: '下载'
},
{
type: 'edit',
title: '编辑'
},
{
type: 'delete',
title: '删除'
},
]
......@@ -26,6 +26,14 @@
></el-switch>
</el-popconfirm>
</template>
<template v-slot:operates="scope">
<TableOperation
:operations="tableOperations"
:rawData="scope.scope.row"
@handleOperation="handleOperation"
></TableOperation>
</template>
</TablePage>
<el-pagination
@size-change="handleSizeChange"
......@@ -51,9 +59,10 @@
import TablePage from "@/components/Table/TablePage.vue";
import TableOperation from "@/components/Table/TableOperation.vue";
import { title, operates, operations } from "./config";
import { editLiterature, getLiteratureList } from "@/api/literature";
import { editLiterature, deleteLt } from "@/api/literature";
import InfoEditDialog from "./components/InfoEditDialog";
import SearchBar from "@/components/SearchBar";
import { downloadFile, previewFile, downloadBlob } from "@/utils/file";
export default {
components: {
......@@ -146,8 +155,10 @@ export default {
if (params.status == "") {
delete params.status;
}
console.log("params", params);
let res = await getLiteratureList(params);
const res = await this.$store.dispatch("dict/getLtList", {
hasPer: true,
params,
});
if (res.code == 0) {
this.list = res.data;
}
......@@ -163,7 +174,10 @@ export default {
page: this.list.current,
limit: this.list.size,
};
let res = await getLiteratureList(params);
const res = await this.$store.dispatch("dict/getLtList", {
hasPer: true,
params,
});
if (res.code == 0) {
this.list = res.data;
}
......@@ -175,14 +189,26 @@ export default {
this.drawerVisible = true;
break;
case "view":
// TODO:
if (row.files && row.files.length > 0 && row.files[0].url) {
previewFile(row.files[0].url, row.name);
} else {
this.$message.info("暂无文献附件!");
}
break;
case "download":
if (row.files && row.files.length > 0 && row.files[0].url) {
let url = '/files'+row.files[0].url.split('files')[1]
downloadBlob(url, row.name, "pdf");
} else {
this.$message.info("暂无文献!");
}
break;
case "edit":
this.form = row;
this.drawerVisible = true;
break;
case "delete":
let deleteRes = await deleteVirtual([row.bvId]);
let deleteRes = await deleteLt([row.literatureId]);
if (deleteRes.code == 0) {
this.$message.success("删除成功!");
this.loadData();
......
......@@ -138,13 +138,6 @@ export default {
loading: false,
};
},
watch: {
dict(value) {
if (value) {
this.dict = value;
}
},
},
computed: {
tableTitle() {
return title;
......
......@@ -141,13 +141,6 @@ export default {
tabelData:[]
};
},
watch: {
dict(value) {
if (value) {
this.dict = value;
}
},
},
computed: {
tableTitle() {
return title;
......
......@@ -138,13 +138,6 @@ export default {
imgList: [],
};
},
watch: {
dict(value) {
if (value) {
this.dict = value;
}
},
},
computed: {
tableTitle() {
return title;
......
......@@ -28,9 +28,10 @@ module.exports = {
outputDir: 'dist',
assetsDir: 'static',
// lintOnSave: process.env.NODE_ENV === 'development',
lintOnSave:false,
lintOnSave: false,
productionSourceMap: false,
devServer: {
host: '172.24.100.18',
port: port,
open: true,
overlay: {
......@@ -39,13 +40,21 @@ module.exports = {
},
proxy: {
'/api': {
// target: 'http://172.24.100.189:8080',
target:'http://222.85.214.245:9066/api',
target: 'http://192.168.1.230:9566/api',
// target:'http://222.85.214.245:9066/api',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
},
'/files': {
target: 'http://192.168.1.230:9563/files',
changeOrigin: true,
pathRewrite: {
'^/files': ''
}
},
}
},
configureWebpack: {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论