glj-代码提交
This commit is contained in:
parent
707bbb3f0b
commit
53ce25b4d6
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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>
|
|
@ -44,12 +44,21 @@
|
|||
Search
|
||||
</el-button>
|
||||
</div>
|
||||
<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.1KB转化成B
|
||||
data = size.toFixed(2) + "B";
|
||||
} else if (size < 0.1 * 1024 * 1024) {//如果小于0.1MB转化成KB
|
||||
data = (size / 1024).toFixed(2) + "KB";
|
||||
} else if (size < 0.1 * 1024 * 1024 * 1024) { //如果小于0.1GB转化成MB
|
||||
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,7 +235,6 @@ 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);
|
||||
|
@ -277,70 +246,28 @@ const getTableData = () => {
|
|||
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 data,Whether 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();
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue