Commit c0dac7a1 authored by forevertyler's avatar forevertyler

add:地磅和人员定位卡

parent c7ad9ac9
import request from '@/utils/request'
export function diBangGet(params) {
return request({
url: 'api/diBang/page',
method: 'get',
params
})
}
export function personCardGet(params) {
return request({
url: 'api/perInfo/page',
method: 'get',
params
})
}
\ No newline at end of file
......@@ -21,6 +21,8 @@ import './assets/styles/common.css'
import App from './App'
import store from './store'
import router from './router/routers'
import { download } from '@/utils/request'
import './assets/icons' // icon
import './router/index' // permission control
......@@ -29,6 +31,7 @@ import './router/index' // permission control
Vue.use(checkPer)
//Vue.use(VueHighlightJS)
//Vue.use(mavonEditor)
Vue.prototype.download = download
Vue.use(permission)
Vue.use(dict)
Vue.use(Element, {
......
import axios from 'axios'
import {Loading, Message} from 'element-ui'
import { Notification } from 'element-ui'
import { getToken } from '@/utils/auth'
import Config from '@/settings'
let downloadLoadingInstance;
// 使请求头可以携带cookie
axios.defaults.withCredentials = true;
......@@ -69,4 +70,32 @@ service.interceptors.response.use(
}
}
)
// 通用下载方法
export function download(url, params, filename, config) {
console.log(url, params, filename, config,'url, params, filename, config')
downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
return service.post(url, params, {
transformRequest: [(params) => { return tansParams(params) }],
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'blob',
...config
}).then(async (data) => {
const isBlob = blobValidate(data);
if (isBlob) {
const blob = new Blob([data])
saveAs(blob, filename)
} else {
const resText = await data.text();
const rspObj = JSON.parse(resText);
const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
Message.error(errMsg);
}
downloadLoadingInstance.close();
}).catch((r) => {
console.error(r)
Message.error('下载文件出现错误,请联系管理员!')
downloadLoadingInstance.close();
})
}
export default service
<template>
<div class="common-page page-t1 module-config">
<div class="option page-row">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="创建时间">
<el-date-picker
v-model="queryParams.range"
@change="dateChange"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<!--el-button type="primary" @click="getList">查询</el-button-->
</el-form>
</div>
<div class="tongji">{{tongji}}</div>
<div class="panel-bottom page-row">
<div class="ctin-box">
<div class="content-within">
<div class="content-fix">
<el-table
v-loading="loading"
:data="dataList"
>
<el-table-column label="重量" align="center" prop="weight" />
<el-table-column label="时间" align="center" prop="weightTime" />
</el-table>
<!-- 添加分页组件 -->
<el-pagination
v-show="total>0"
class="pagination-container"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="queryParams.page"
:page-sizes="[10, 20, 30, 50]"
:page-size="queryParams.size"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { diBangGet } from '@/api/newApi'
export default {
name: "diBang",
components: {},
props: [],
data() {
return {
// 遮罩层
loading: true,
// 查询参数
queryParams: {
page: 1,
size: 10,
range: [],
},
total: 0, // 总条数
dataList:[],
value1:null,
tongji:'',
};
},
watch: {},
created() {
this.$nextTick(function () {});
},
mounted() {
this.$nextTick(function () {
this.getList()
});
},
methods: {
getList(){
diBangGet(this.queryParams).then(res=>{
this.dataList = res.body.records
this.tongji = res.cycleStatistics
this.total = res.body.total;
this.loading = false;
})
},
dateChange(e){
console.log(e)
this.getList()
},
handleSizeChange(val) {
this.queryParams.size = val;
this.getList();
},
handleCurrentChange(val) {
this.queryParams.page = val;
this.getList();
},
},
};
</script>
\ No newline at end of file
<template>
<div class="common-page page-t1 module-config">
<div class="option page-row">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="创建时间">
<el-date-picker
v-model="queryParams.range"
@change="dateChange"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<!--el-button type="primary" @click="getList">查询</el-button-->
</el-form>
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport">导入</el-button>
</div>
<!-- <div class="tongji">{{tongji}}</div> -->
<div class="panel-bottom page-row">
<div class="ctin-box">
<div class="content-within">
<div class="content-fix">
<el-table
v-loading="loading"
:data="dataList"
>
<el-table-column label="姓名" align="center" prop="perName" />
<el-table-column label="性别" align="center" prop="perSex" >
<template slot-scope="scope">
<div v-if="scope.row.perSex==1"></div>
<div v-else></div>
</template>
</el-table-column>
<el-table-column label="部门" align="center" prop="perDept" />
<el-table-column label="职务" align="center" prop="perOffice" />
<el-table-column label="卡号" align="center" prop="phone" />
<el-table-column label="电话" align="center" prop="perTel" />
</el-table>
<!-- 添加分页组件 -->
<el-pagination
v-show="total>0"
class="pagination-container"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="queryParams.page"
:page-sizes="[10, 20, 30, 50]"
:page-size="queryParams.size"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</div>
</div>
</div>
<!-- 人员定位卡导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xls、xlsx格式文件。</span>
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button @click="upload.open = false">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { personCardGet } from '@/api/newApi'
import { getToken } from "@/utils/auth";
import {Loading, Message} from 'element-ui'
export default {
name: "diBang",
components: {},
props: [],
data() {
return {
// 遮罩层
loading: true,
// 查询参数
queryParams: {
page: 1,
size: 10,
range: [],
},
total: 0, // 总条数
dataList:[],
value1:null,
tongji:'',
// 用户导入参数
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_LOCAL_API + "/api/perInfo/import"
},
};
},
watch: {},
created() {
this.$nextTick(function () {});
},
mounted() {
this.$nextTick(function () {
this.getList()
});
},
methods: {
getList(){
personCardGet(this.queryParams).then(res=>{
this.dataList = res.body.list; // 改为使用分页数据
this.total = res.body.total; // 获取总条数
this.loading = false;
this.loading = false;
})
},
handleSizeChange(val) {
this.queryParams.size = val;
this.getList();
},
handleCurrentChange(val) {
this.queryParams.page = val;
this.getList();
},
dateChange(e){
console.log(e)
this.getList()
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
console.log(file, fileList,'1111')
this.upload.isUploading = true;
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
console.log(response, file, fileList,'aaa')
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
if (response.code === 200) {
this.$alert("导入成功", "提示", { confirmButtonText: "确定" });
// 导入成功后刷新列表
this.getList();
} else {
this.$message.error(response.msg);
}
},
// 提交上传文件
submitFileForm() {
this.$refs.upload.submit();
},
// 提交上传文件
submitFileForm() {
this.$refs.upload.submit();
},
// 下载模板
importTemplate() {
// 实际项目中需要替换为真实的模板下载地址
window.location.href = process.env.VUE_APP_LOCAL_API + '/api/perInfo/exportTemplate'
},
beforeUpload(file) {
const isExcel = file.type.includes('sheet');
if (!isExcel) {
this.$message.error('只能上传excel文件');
return false;
}
return true;
},
handleImport(){
this.upload.open = true
},
},
};
</script>
\ No newline at end of file
<template>
<div v-if="crud.props.searchToggle">
<el-input
v-model="query.blurry"
clearable
size="small"
placeholder="请输入你要搜索的内容"
style="width: 200px;"
class="filter-item"
/>
<date-range-picker v-model="query.createTime" class="date-item" />
<rrOperation />
</div>
</template>
<script>
import { header } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import DateRangePicker from '@/components/DateRangePicker'
export default {
components: { rrOperation, DateRangePicker },
mixins: [header()]
}
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment