|
|
@@ -1,5 +1,5 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { apisystemdzbcArealist } from '../../request/api.js'
|
|
|
+import { apisystemdzbcArealist,apisystemdzbcAreaexport,apisystemdzbcAreaDel,apisystemdzbcAreaAdd } from '../../request/api.js'
|
|
|
import type { ComponentSize, FormInstance, FormRules } from 'element-plus'
|
|
|
|
|
|
interface RuleForm {
|
|
|
@@ -97,7 +97,11 @@ const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
if (!formEl) return
|
|
|
await formEl.validate((valid, fields) => {
|
|
|
if (valid) {
|
|
|
- console.log('submit!')
|
|
|
+ apisystemdzbcAreaAdd(ruleForm).then((res:any)=>{
|
|
|
+
|
|
|
+ }).catch((err:any)=>{
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
} else {
|
|
|
console.log('error submit!', fields)
|
|
|
}
|
|
|
@@ -113,25 +117,59 @@ let pageNum=ref(1)
|
|
|
let dialogVisible=ref(false)
|
|
|
let logtitle=ref('新增用户')
|
|
|
let loading=ref(true)
|
|
|
+let excellloading=ref(false)
|
|
|
const tableData = ref([])
|
|
|
-
|
|
|
+//v-loading="excellloading" @click="downExcell"
|
|
|
let activeName=ref('first')
|
|
|
|
|
|
const addUser=val=>{
|
|
|
dialogVisible.value=val
|
|
|
}
|
|
|
-
|
|
|
+const downExcell=()=>{
|
|
|
+ excellloading.value=true
|
|
|
+ apisystemdzbcAreaexport({}).then((res:any)=>{
|
|
|
+
|
|
|
+ // 这里 data 是返回来的二进制数据
|
|
|
+ let blob = new Blob([res], {
|
|
|
+ type: "application/x-msdownload;charset=UTF-8",
|
|
|
+ });
|
|
|
+ // 创建一个blob的对象链接
|
|
|
+ const url = window.URL.createObjectURL(blob);
|
|
|
+ const link = document.createElement('a');
|
|
|
+ link.href = url;
|
|
|
+ // 把获得的blob的对象链接赋值给新创建的这个 a 链接
|
|
|
+ link.setAttribute('download', '数据管理列表.xls'); // 设置下载文件名
|
|
|
+ document.body.appendChild(link);
|
|
|
+ // 使用js点击这个链接
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link) // 下载完成移除元素
|
|
|
+ window.URL.revokeObjectURL(url) // 释放blob对象
|
|
|
+ excellloading.value=false
|
|
|
+ }).catch((err:any)=>{
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+}
|
|
|
const getTableData=()=>{
|
|
|
apisystemdzbcArealist({
|
|
|
|
|
|
}).then(res=>{
|
|
|
+ if(res.code==200){
|
|
|
+ tableData.value=res.rows
|
|
|
+ }
|
|
|
loading.value=false
|
|
|
- tableData.value=res.data.rows
|
|
|
+
|
|
|
}).catch(err=>{
|
|
|
console.log(err)
|
|
|
})
|
|
|
}
|
|
|
+//
|
|
|
+const deleteItem=(id)=>{
|
|
|
+ apisystemdzbcAreaDel({id}).then((res:any)=>{
|
|
|
|
|
|
+ }).catch((err:any)=>{
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
onMounted(()=>{
|
|
|
getTableData()
|
|
|
@@ -173,8 +211,8 @@ onMounted(()=>{
|
|
|
</div>
|
|
|
<div class="right-part">
|
|
|
|
|
|
- <!-- <el-button :icon="Download">导出</el-button>
|
|
|
- <el-button :icon="Tools">设置</el-button> -->
|
|
|
+ <el-button :loading="excellloading" @click="downExcell" :icon="Download">{{ excellloading?'正在导出':'导出' }}</el-button>
|
|
|
+ <!-- <el-button :icon="Tools">设置</el-button> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
<el-table element-loading-text='加载中' header-row-class-name="reset-gray-head" :data="tableData" style="width: 100%" v-loading="loading">
|
|
|
@@ -190,11 +228,11 @@ onMounted(()=>{
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="by" label="所属客运站" />
|
|
|
<el-table-column fixed="right" label="操作" min-width="120">
|
|
|
- <template #default>
|
|
|
+ <template #default="scope">
|
|
|
<el-button link type="primary" size="small">
|
|
|
编辑
|
|
|
</el-button>
|
|
|
- <el-button link type="danger" size="small">删除</el-button>
|
|
|
+ <el-button @click="deleteItem(scope.row.id)" link type="danger" size="small">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -280,7 +318,7 @@ onMounted(()=>{
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
<el-button @click="dialogVisible = false" :icon="Close">取消</el-button>
|
|
|
- <el-button type="primary" :icon="Check" @click="addUser(false)">
|
|
|
+ <el-button type="primary" :icon="Check" @click="submitForm(ruleFormRef)">
|
|
|
确认创建
|
|
|
</el-button>
|
|
|
</div>
|