提交 920cf86c authored 作者: 龙菲's avatar 龙菲

feat:修改文物年代选择器

上级 490896a1
import {
getDictTree
} from '@/api/dict'
const state = { const state = {
dicts: {}, dicts: {}, //{ displayTypes: }
}; };
const mutations = { const mutations = {
...@@ -14,30 +17,40 @@ const actions = { ...@@ -14,30 +17,40 @@ const actions = {
commit commit
}, data) { }, data) {
let dicts = [] let dicts = []
let requestDicts = []
data.forEach(i => { data.forEach(i => {
if (state.dicts[i]) { // 如果state中不存在的就需要重新获取
dicts.push(dicts) if (!state.dicts[i]) {
requestDicts.push(i)
} else {
// 如果存在就直接存入dicts中
let obj = {}
obj[i] = state.dicts[i]
dicts.push(obj)
} }
}); });
if (dicts.length > 0) { return new Promise((resolve, reject) => {
return dicts getDictTree(requestDicts).then(res => {
} else { console.log(res.data);
return new Promise((resolve, reject) => { let dictsObj = {}
getDictTree(data).then(response => { requestDicts.forEach(reqDict => {
const { dictsObj[reqDict] = []
data res.data.map(item => {
} = response if (item.dictType == reqDict) {
commit('SET_TOKEN', data.accessToken) dictsObj[reqDict].push(item)
commit('SET_NAME', data.username) }
commit('SET_USERINFO', data) })
setToken(data.accessToken) commit("SET_DICTS", {
setUserInfo(data) label: reqDict,
resolve() value: Object.freeze(dictsObj[reqDict]),
}).catch(error => { });
reject(error)
}) })
resolve(dictsObj)
}).catch(error => {
reject(error)
}) })
} });
} }
} }
......
...@@ -76,19 +76,27 @@ ...@@ -76,19 +76,27 @@
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="文物年代" :label-width="formLabelWidth"> <el-form-item label="文物年代" :label-width="formLabelWidth">
<el-select <el-cascader
style="width: 100%"
v-model="dialogForm.years"
:options="culturalRelicYears"
:props="culturalRelicYearsProps"
placeholder="请选择文物年代"
>
</el-cascader>
<!-- <el-select
v-model="dialogForm.years" v-model="dialogForm.years"
placeholder="请选择文物年代" placeholder="请选择文物年代"
style="width: 100%" style="width: 100%"
> >
<el-option <el-option
v-for="(value, key) in culturalRelicYears" v-for="(item, key) in culturalRelicYears"
:key="key" :key="key"
:label="value" :label="item.label"
:value="key" :value="item.value"
> >
</el-option> </el-option> -->
</el-select> <!-- </el-select> -->
</el-form-item> </el-form-item>
<el-form-item label="文物数量" :label-width="formLabelWidth"> <el-form-item label="文物数量" :label-width="formLabelWidth">
<!-- <el-input <!-- <el-input
...@@ -204,7 +212,7 @@ ...@@ -204,7 +212,7 @@
:fileLimit="6" :fileLimit="6"
:fileSize="50" :fileSize="50"
:fileType="['mp4', 'wav']" :fileType="['mp4', 'wav']"
listType="picture-card" listType="text"
ref="videos" ref="videos"
/> />
</el-form-item> </el-form-item>
...@@ -233,7 +241,7 @@ ...@@ -233,7 +241,7 @@
<div class="dialog-footer"> <div class="dialog-footer">
<el-button @click="cancelForm">取 消</el-button> <el-button @click="cancelForm">取 消</el-button>
<el-button type="primary" @click="handleSubmit" <el-button type="primary" @click="handleSubmit" :loading="loading"
>确定<i class="el-icon-right" style="margin-left: 5px"></i >确定<i class="el-icon-right" style="margin-left: 5px"></i
></el-button> ></el-button>
</div> </div>
...@@ -296,11 +304,13 @@ export default { ...@@ -296,11 +304,13 @@ export default {
// debugger // debugger
// 回填媒体 // 回填媒体
if (this.dialogForm.faceImageUrl) { if (this.dialogForm.faceImageUrl) {
this.faceImage = [{ this.faceImage = [
name: "", {
url: this.dialogForm.faceImageUrl, name: "",
fileId: this.dialogForm.faceImage, url: this.dialogForm.faceImageUrl,
}]; fileId: this.dialogForm.faceImage,
},
];
} }
if (this.dialogForm.imagesVo) { if (this.dialogForm.imagesVo) {
this.images = this.dialogForm.imagesVo; this.images = this.dialogForm.imagesVo;
...@@ -338,13 +348,7 @@ export default { ...@@ -338,13 +348,7 @@ export default {
} }
}, },
}, },
dicts: [ dicts: ["culturalRelicLevel", "culturalRelicType", "literature"],
// "cultural_relic_texture",
"culturalRelicLevel",
// "cultural_relic_years",
"culturalRelicType",
"literature",
],
data() { data() {
return { return {
dialogForm: { dialogForm: {
...@@ -366,14 +370,33 @@ export default { ...@@ -366,14 +370,33 @@ export default {
images: [], images: [],
videos: [], videos: [],
audios: [], audios: [],
culturalRelicTexture: { 1: "铜", 1: "织绣" }, //TODO:等后台字典更新后改回 culturalRelicTexture: "",
culturalRelicYears: { 1: "元(1206~1368)" }, culturalRelicYears: "",
culturalRelicYearsProps: {
value: "value",
label: "label",
children: "children",
checkStrictly: true, //单选选择任意一级选项
},
}; };
}, },
async created() { async created() {
setTimeout(() => { // setTimeout(() => {
console.log("22222this.dict", this.dict); // console.log("22222this.dict", this.dict);
}); // });
},
mounted() {
this.$store
.dispatch("dict/getDictTree", [
"culturalRelicTexture",
"culturalRelicYears",
])
.then((res) => {
// debugger;
// console.log(res);
this.culturalRelicTexture = res.culturalRelicTexture;
this.culturalRelicYears = res.culturalRelicYears;
});
}, },
methods: { methods: {
// 关联文献查询 // 关联文献查询
...@@ -409,11 +432,12 @@ export default { ...@@ -409,11 +432,12 @@ export default {
// 取消编辑 // 取消编辑
cancelForm() { cancelForm() {
this.$emit("handleClose"); this.$emit("handleClose");
this.literatureValues = []; this.reset();
}, },
async handleSubmit() { async handleSubmit() {
var that = this; var that = this;
let formData = new FormData(); let formData = new FormData();
this.loading = true;
// 已存在的文件的对象 // 已存在的文件的对象
let successFilesObj = []; let successFilesObj = [];
// 添加布展本身的媒体文件至formData // 添加布展本身的媒体文件至formData
...@@ -487,23 +511,38 @@ export default { ...@@ -487,23 +511,38 @@ export default {
const params = { ...this.dialogForm, deptId, regionCode }; const params = { ...this.dialogForm, deptId, regionCode };
params.literature = this.literatureValues.join(","); params.literature = this.literatureValues.join(",");
params.status = this.dialogForm.status ? 1 : 0; params.status = this.dialogForm.status ? 1 : 0;
// 处理年份
params.years = params.years[params.years.length - 1];
// 处理质地TODO:
// params.texture = params.texture[params.texture.length - 1];
let res = await addCulturalRelic(params); let res = await addCulturalRelic(params);
if (res.code == 0) { if (res.code == 0) {
this.$message.success("提交成功!"); this.$message.success("提交成功!");
this.loading = false; this.loading = false;
this.$emit("handleClose"); this.$emit("handleClose");
this.$emit("refresh"); this.$emit("refresh");
this.reset();
} }
} else { } else {
const params = { ...this.dialogForm }; const params = { ...this.dialogForm };
params.literature = this.literatureValues.join(","); params.literature = this.literatureValues.join(",");
params.status = this.dialogForm.status ? 1 : 0; params.status = this.dialogForm.status ? 1 : 0;
// return;
// 处理年份
if (params.years instanceof Array) {
params.years = params.years[params.years.length - 1];
}
// 处理质地
// if (params.texture instanceof Array) {
// params.texture = params.texture[params.texture.length - 1];
// }
let res = await editCulturalRelic(params); let res = await editCulturalRelic(params);
if (res.code == 0) { if (res.code == 0) {
this.$message.success("修改成功!"); this.$message.success("修改成功!");
this.loading = false; this.loading = false;
this.$emit("handleClose"); this.$emit("handleClose");
this.$emit("refresh"); this.$emit("refresh");
this.reset();
} }
// const { // const {
// exhibitionId, // exhibitionId,
...@@ -550,12 +589,11 @@ export default { ...@@ -550,12 +589,11 @@ export default {
.then((_) => { .then((_) => {
done(); done();
this.$emit("handleClose"); this.$emit("handleClose");
this.reset() this.reset();
}) })
.catch((_) => {}); .catch((_) => {});
}, },
// 清空编辑组件中的所有值 // 清空编辑组件中的所有值
reset() { reset() {
//父组件将清空form绑定的值 //父组件将清空form绑定的值
// 清空文献 // 清空文献
......
...@@ -749,14 +749,6 @@ export default { ...@@ -749,14 +749,6 @@ export default {
this.dialogForm.auidos = str; this.dialogForm.auidos = str;
}, },
// startLoading() {
// this.loading = true;
// },
// endLoading() {
// this.loading = false;
// },
refresh() { refresh() {
this.$emit("refresh"); this.$emit("refresh");
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论