glj-代码提交

This commit is contained in:
glj 2023-05-13 18:04:42 +08:00
parent 707bbb3f0b
commit 53ce25b4d6
5 changed files with 152 additions and 113 deletions

View File

@ -24,3 +24,11 @@ export const review = (ids,status,type) => {
}
})
}
export const importTemplate = (data) => {
return request({
url: '/api/'+moduleName+'/ui/news/importTemplate',
headers:{'Content-Type': 'multipart/form-data'},
method: 'post',
data: data
})
}

View File

@ -0,0 +1,104 @@
<template>
<el-dialog title="upload" v-model="state.isShowDialog" width="550px">
<el-form :model="state.ruleForm" size="default" label-width="150px" :rules="rules" ref="adminAddFormRef">
<el-form-item label="file:" style="margin-top: 30px;">
<el-upload ref="upFileRef" class="upload-demo" :file-list="state.fileData" :auto-upload="false" :on-change="handleChange">
<template #trigger>
<el-button type="primary">select file</el-button>
</template>
</el-upload>
</el-form-item>
<el-form-item prop="title" label="type:" style="margin-top: 30px;">
<el-select v-model="state.ruleForm.title" class="m-2" placeholder="please enter name">
<el-option label="bing" value="1"></el-option>
<el-option label="baidu" value="0"></el-option>
<el-option label="twitter" value="2"></el-option>
<el-option label="weibo" value="3"></el-option>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="onCancel" size="default">cancel</el-button>
<el-button type="primary" @click="uploadHandler()" size="default"
:loading="state.isLoading">upload</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup>
import { reactive, ref } from "vue";
import { importTemplate } from '/@/api/news/index.js';
import { ElMessage } from "element-plus";
const upFileRef = ref();
const emit = defineEmits(['callback']);
const adminAddFormRef = ref();
const state = reactive({
fileList: [],
isShowDialog: false,
isLoading: false,
ruleForm: {
title: null,
},
})
//onchanne
const handleChange = (file, fileList) => {
state.fileList = fileList;
console.log(state.fileList)
};
//
const uploadHandler = () => {
const form = new FormData();
form.append("fileData", state.fileList[0].raw);
form.append("type", state.ruleForm.title);
form.append("disasterId", state.ruleForm.disasterId);
state.isLoading = true;
importTemplate(form).then(da => {
ElMessage.success("success");
emit('callback');
}).finally(() => {
state.isLoading = false;
})
closeDialog();
};
//
const rules = reactive({
title: [
{ required: true, message: 'please enter type', trigger: 'change' }
],
})
//
const resetField = () => {
adminAddFormRef.value.resetFields();
state.fileArray = [];
upFileRef.value.clearFiles();
}
//
const openDialog = (row) => {
state.isShowDialog = true;
state.ruleForm.disasterId = row;
};
//
const closeDialog = () => {
state.isShowDialog = false;
resetField();
};
//
const onCancel = () => {
closeDialog();
};
//
defineExpose({
openDialog,
});
</script>
<style scoped></style>

View File

@ -44,12 +44,21 @@
Search
</el-button>
</div>
<el-button size="default" type="success" class="ml10" @click="openDialog">
<el-icon>
<ele-Upload />
</el-icon>
Batch operation
</el-button>
<div>
<el-button size="default" type="success" class="ml10" @click="openDialog">
<el-icon>
<ele-Upload />
</el-icon>
Batch operation
</el-button>
<el-button size="default" type="success" class="ml10" @click="OpenuploadDataRef()">
<el-icon>
<ele-Upload />
</el-icon>
Upload
</el-button>
</div>
<el-table :data="state.tableData.data" v-loading="state.tableData.loading"
@selection-change="handleSelectionChange" style="width: 100%; height: 600px;">
<el-table-column type="selection" width="55" />
@ -107,33 +116,28 @@
</el-dialog>
</el-config-provider>
<boot ref="bootRef" @callback="getTableData" />
<uploadData ref="uploadDataRef" @callback="getTableData" />
</div>
</template>
<script lang="ts" setup name="dataMultimediaData">
import en from 'element-plus/dist/locale/en.mjs'
import type { TabsPaneContext } from 'element-plus';
import { getOtherDataPage, getDisasterPage, deleteData } from '/@/api/data/otherData.js'
import { getList } from '/@/api/disasterInfo/index';
import { getList as getNewsList, review } from '/@/api/news/index';
import { getDictionary } from '/@/api/system/dictbiz';
//
import { defineAsyncComponent, reactive, onMounted, ref } from 'vue';
import { ElMessageBox, ElMessage } from 'element-plus';
import { reactive, onMounted, ref } from 'vue';
import { ElMessage } from 'element-plus';
import boot from "./component/boot.vue";
import uploadData from "./component/uploadData.vue";
import disasterTable from "/@/components/table/DisasterTable.vue";
//
const auditRef = ref();
const bootRef = ref();
const uploadDataRef = ref();
//
const roleDialogRef = ref();
const getValue = (key) => {
//state.disasterTypeLis value
return state.disasterTypeList.find((item) => item.dictKey === key)?.dictValue;
};
const state = reactive({
dialogVisible: false,
multipleSelection: [],
@ -167,6 +171,7 @@ const state = reactive({
},
selectList: [],
});
const openDialog = async (row, bool) => {
if (bool) {
state.selectList = [row]
@ -175,6 +180,7 @@ const openDialog = async (row, bool) => {
}
state.dialogVisible = true;
};
const reviews = async (status) => {
let ids = state.selectList.map((item) => item.id);
//ids 使
@ -186,41 +192,11 @@ const reviews = async (status) => {
getTableData();
}
};
const handleSelectionChange = (val) => {
state.multipleSelection = val
}
const auditData = (row) => {
let id = row.id
auditRef.value.openDialog([{ "id": id }]);
}
//
const formatSize = (size) => {
var data = "";
if (size < 0.1 * 1024) { //0.1KBB
data = size.toFixed(2) + "B";
} else if (size < 0.1 * 1024 * 1024) {//0.1MBKB
data = (size / 1024).toFixed(2) + "KB";
} else if (size < 0.1 * 1024 * 1024 * 1024) { //0.1GBMB
data = (size / (1024 * 1024)).toFixed(2) + "MB";
} else { //GB
data = (size / (1024 * 1024 * 1024)).toFixed(2) + "GB";
}
var sizestr = data + "";
var len = sizestr.indexOf("\.");
var dec = sizestr.substr(len + 1, 2);
if (dec == "00") {//00
return sizestr.substring(0, len) + sizestr.substr(len + 3, 2);
}
return sizestr;
}
const formatSizeUnits = (size) => {
if (size === 0) return '0 B';
var k = 1000, // or 1024
sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(size) / Math.log(k));
};
return (size / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
}
//
const tableClick = (i) => {
state.disasterId = i.disasterId;
@ -229,12 +205,6 @@ const tableClick = (i) => {
//
const getDisasterData = () => {
state.disasterData.loading = true;
// param: {
// search: '',
// current: 1,
// size: 10,
// respondStatus: 0,
// },
let param = {
"search": state.disasterData.param.search,
"current": state.disasterData.param.pageNum,
@ -265,82 +235,39 @@ const getTableData = () => {
state.tableData.data = res.records;
if (state.searchName == '1') {
console.log(111111111111111111);
state.tableData.data.forEach(item => {
let date = item.createTime.slice(0, 10);
item.time = date;
})
}else{
} else {
state.tableData.data.forEach(item => {
let date = item.time.slice(0, 10);
item.time = date;
})
}
state.tableData.total = res.total;
})
/* state.tableData.data = data;
state.tableData.total = state.tableData.data.length;*/
setTimeout(() => {
state.tableData.loading = false;
}, 500);
};
//
const startBot = (row: any) => {
bootRef.value.openDialog(row);
};
//
const onOpenEditRole = (type, row) => {
roleDialogRef.value.openDialog(type, row);
};
//
const batchDel = () => {
if (state.multipleSelection.length == 0) {
ElMessage.warning("Select the data to be operated first");
//
const OpenuploadDataRef = () => {
if (state.disasterId == null) {
ElMessage.warning('Please select the disaster first');
return false;
}
ElMessageBox.confirm(`This action batch deletes the other dataWhether to continue?`, 'tip', {
confirmButtonText: 'confirm',
cancelButtonText: 'cancel',
type: 'warning',
})
.then(() => {
let id = state.multipleSelection.map(item => item.id)
deleteData(id.join()).then(res => {
getTableData();
ElMessage.success('delete successfully');
})
})
.catch(() => { });
}
//
const del = (row) => {
ElMessageBox.confirm(`This action deletes the other data${row.title}Whether to continue?`, 'tip', {
confirmButtonText: 'confirm',
cancelButtonText: 'cancel',
type: 'warning',
})
.then(() => {
deleteData(row.id).then(res => {
getTableData();
ElMessage.success('delete successfully');
})
})
.catch(() => { });
};
//
const onHandleDisasterSizeChange = (val) => {
state.disasterData.param.pageSize = val;
getDisasterData();
};
//
const onHandleDisasterCurrentChange = (val) => {
state.disasterData.param.pageNum = val;
getDisasterData();
uploadDataRef.value.openDialog(state.disasterId);
};
//
const onHandleSizeChange = (val) => {
state.tableData.param.pageSize = val;
@ -351,6 +278,7 @@ const onHandleCurrentChange = (val) => {
state.tableData.param.pageNum = val;
getTableData();
};
//
onMounted(() => {
getDisasterData();

View File

@ -94,7 +94,6 @@ const rules = reactive({
})
//
const handleRemove = (uploadFile, uploadFiles) => {
console.log(uploadFile, uploadFiles)
state.hideUpload = state.fileList.length >= 1
}
//
@ -165,10 +164,8 @@ const onSubmit = () => {
state.dataForm.append('isMain', state.ruleForm.isMain);
state.dataForm.append('id', state.id);
state.dataForm.append('name', state.ruleForm.title);
for (let [a, b] of state.dataForm.entries()) {
console.log(a, b, '--------------');
}
updatePicture(state.dataForm).then(res => {
state.dataForm = new FormData(),
ElMessage.success("Upload successfully");
emit('callback');
}).finally(() => {

View File

@ -86,7 +86,9 @@ const save = async () => {
chiefId: state.selectData[0].id,
chiefName: state.selectData[0].name,
};
let res = await submit(params);
let res = await submit(params).then(da=>{
ElMessage.success('Save success');
});
emit('callback');
closeDialog();
};