|
@@ -6,8 +6,22 @@
|
|
|
<!-- <el-button icon="el-icon-plus" type="success" @click="addItem()">新增</el-button > -->
|
|
|
|
|
|
<div>
|
|
|
- <el-button type="primary">导入</el-button>
|
|
|
- <el-button type="primary">导出</el-button>
|
|
|
+ <el-upload
|
|
|
+ class="upload-demo"
|
|
|
+ :action="fileUrl + '/deviceAttribute/deviceAttributeImport'"
|
|
|
+ :on-progress="handleProgress"
|
|
|
+ :on-success="handleUpAvatar"
|
|
|
+ multiple
|
|
|
+ :limit="1"
|
|
|
+ :headers="{
|
|
|
+ accessToken: [accessToken],
|
|
|
+ }"
|
|
|
+ :file-list="fileList"
|
|
|
+ style="margin-right:10px;display:inline-block"
|
|
|
+ >
|
|
|
+ <el-button size="small" type="primary">导入</el-button>
|
|
|
+ </el-upload>
|
|
|
+ <el-button type="primary" @click="DataReportExport()">导出</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 筛选end -->
|
|
@@ -145,6 +159,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { useStore } from 'vuex'
|
|
|
import { defineComponent, ref, reactive, onMounted,watch } from 'vue'
|
|
|
import * as api from '@/api/siteManage/watchDog.js'
|
|
|
import { ElMessage } from 'element-plus'
|
|
@@ -156,6 +171,12 @@ export default defineComponent({
|
|
|
components: { DialogComponent, Clone },
|
|
|
props:[ 'siteId'],
|
|
|
setup(props, { emit }) {
|
|
|
+ const store = useStore()
|
|
|
+ store
|
|
|
+ const fileUrl = ref(window.PLATFROM_CONFIG.baseUrl)
|
|
|
+ const fileList = ref([])
|
|
|
+ const accessToken = ref(store.state.user.accessToken)
|
|
|
+
|
|
|
const total = ref(0)
|
|
|
const pageSize = ref(15)
|
|
|
const currentPage = ref(1)
|
|
@@ -249,6 +270,36 @@ export default defineComponent({
|
|
|
const cancelEvent = () => {
|
|
|
console.log('cancel!')
|
|
|
}
|
|
|
+
|
|
|
+ const handleProgress = (file, fileList) => {
|
|
|
+ file
|
|
|
+ if (
|
|
|
+ !(
|
|
|
+ fileList.raw.type ===
|
|
|
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ||
|
|
|
+ fileList.raw.type === 'application/vnd.ms-excel'
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ ElMessage({
|
|
|
+ message: '上传文件只能是 xls 和 xlsx 格式!',
|
|
|
+ type: 'error',
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleUpAvatar = (res, file) => {
|
|
|
+ console.log(res, file)
|
|
|
+ fileList.value = []
|
|
|
+ ElMessage.success({
|
|
|
+ message: '导入成功',
|
|
|
+ type: 'success',
|
|
|
+ })
|
|
|
+ deviceNewsList()
|
|
|
+ }
|
|
|
+
|
|
|
//监听变化
|
|
|
watch(
|
|
|
() => props.siteId,
|
|
@@ -281,6 +332,25 @@ export default defineComponent({
|
|
|
currentPage.value = val
|
|
|
deviceNewsList()
|
|
|
}
|
|
|
+
|
|
|
+ //导出
|
|
|
+ const DataReportExport = () => {
|
|
|
+ api
|
|
|
+ .deviceAttributeExport({
|
|
|
+ siteId:props.siteId,
|
|
|
+ })
|
|
|
+ .then((requset) => {
|
|
|
+ if (requset.status === 'SUCCESS') {
|
|
|
+ window.location.href = window.PLATFROM_CONFIG.fileUrl + requset.data
|
|
|
+ ElMessage.success({
|
|
|
+ message: '导出成功',
|
|
|
+ type: 'success',
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ ElMessage.error(requset.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
return {
|
|
|
tableData,
|
|
|
showDialog,
|
|
@@ -310,6 +380,14 @@ export default defineComponent({
|
|
|
cancelEvent,
|
|
|
handleSizeChange,
|
|
|
handleCurrentChange,
|
|
|
+
|
|
|
+ DataReportExport,
|
|
|
+
|
|
|
+ fileList,
|
|
|
+ fileUrl,
|
|
|
+ accessToken,
|
|
|
+ handleProgress,
|
|
|
+ handleUpAvatar,
|
|
|
}
|
|
|
},
|
|
|
})
|