Commit 7d4a0472 by jack

v3.6需求

1 parent 3e22460a
......@@ -35,4 +35,22 @@
.ellipsis{
white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.el_table {
thead {
th {
background: rgba(197, 197, 197, 0.1);
}
}
}
.pagination_list {
text-align: right;
padding: 10px 0;
}
.links_group {
display: flex;
align-items: center;
justify-content: space-between;
margin: 10px 0;
}
</style>
import Vue from 'vue'
import { Message, MessageBox, Loading } from 'element-ui';
import { Message, MessageBox, Loading } from 'element-ui'
import moment from 'moment'
let loadingInstance = ''
export const Util = {
/**
* 简单alert
* title 标题
......@@ -16,7 +15,7 @@ export const Util = {
* confirmButtonColor 确认按钮颜色
* cancelButtonColor 取消按钮颜色
*/
msg: function(options) {
msg: function (options) {
MessageBox({
title: options.title || '',
type: options.type || 'error',
......@@ -28,17 +27,17 @@ export const Util = {
confirmButtonColor: options.confirmButtonColor || '#1989fa',
cancelButtonColor: options.cancelButtonColor || '#000',
dangerouslyUseHTMLString: true,
callback: function(action, done) {
callback: function (action, done) {
if (action == 'confirm') {
if (options.success) {
(options.success)(done)
options.success(done)
}
} else {
console.log(done);
console.log(done)
done()
}
}
});
},
})
/* Vue.$vux.alert.show({
title: options.title||'',
......@@ -55,134 +54,133 @@ export const Util = {
/**
* 提示框
*/
Info: function(options) {
Info: function (options) {
Message({
message: options.message || '提示',
type: options.type || 'error',
duration: options.time || 2000,
onClose: options.onClose || ''
});
onClose: options.onClose || '',
})
},
/**
* 轻提示
*/
Tips: function(options) {
Tips: function (options) {
Message({
message: options.message || '提示',
duration: options.duration || 3000,
type: options.type || 'text',
icon: options.icon || ''
icon: options.icon || '',
})
},
/**
* loading
*/
loading: function(message) {
loading: function (message) {
loadingInstance = Loading.service({
text: message || '加载中...'
});
text: message || '加载中...',
})
},
/**
* 关闭loading
*/
closeLoading: function() {
loadingInstance.close();
closeLoading: function () {
loadingInstance.close()
},
/**
* 校验手机号码格式
*/
checkPhone: function(mobile) {
let myreg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/;
return myreg.test(mobile);
checkPhone: function (mobile) {
let myreg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/
return myreg.test(mobile)
},
/**
* 校验固定电话
*/
validationTel: function(tel) {
let reg = /^0[\d]{2,3}-[\d]{7,8}$/;
return reg.test(tel);
validationTel: function (tel) {
let reg = /^0[\d]{2,3}-[\d]{7,8}$/
return reg.test(tel)
},
/**
* 是否特殊字符
*/
isSpecialLetter: function(str) {
let reg = new RegExp("[`~!@#$^&*=|{}':;',\\[\\]<>?~!@#¥……&*——|{}【】‘;:”“'。,、? ]");
return reg.test(str);
isSpecialLetter: function (str) {
let reg = new RegExp(
"[`~!@#$^&*=|{}':;',\\[\\]<>?~!@#¥……&*——|{}【】‘;:”“'。,、? ]"
)
return reg.test(str)
},
/**
* 获取当前时间
*/
getCurrentDate: function() {
let time = new Date();
let y = time.getFullYear();
let m = time.getMonth() + 1;
let d = time.getDate();
getCurrentDate: function () {
let time = new Date()
let y = time.getFullYear()
let m = time.getMonth() + 1
let d = time.getDate()
return {
date: y + '/' + m + '/' + d
date: y + '/' + m + '/' + d,
}
},
/**
* 获取浏览器参数
*/
getUrlParams: function(name) {
getUrlParams: function (name) {
let vars = [],
hash;
let oParams = {};
let hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
hash
let oParams = {}
let hashes = window.location.href
.slice(window.location.href.indexOf('?') + 1)
.split('&')
for (let i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
oParams[hash[0]] = hash[1];
hash = hashes[i].split('=')
vars.push(hash[0])
oParams[hash[0]] = hash[1]
}
console.log(vars);
if(name){
return oParams[name];
}else{
return oParams;
console.log(vars)
if (name) {
return oParams[name]
} else {
return oParams
}
},
/**
* 根据当前时间,计算往后30天的日期
*/
getAfterDate: function(day) {
let date1 = new Date();
let date2 = new Date(date1);
let time = 30;
getAfterDate: function (day) {
let date1 = new Date()
let date2 = new Date(date1)
let time = 30
if (day) {
time = day;
time = day
}
date2.setDate(date1.getDate() + time);
date2.setDate(date1.getDate() + time)
let _date = date2.getFullYear() + '-' + (date2.getMonth() + 1) + '-' + date2.getDate();
let _date =
date2.getFullYear() + '-' + (date2.getMonth() + 1) + '-' + date2.getDate()
return {
date: _date,
year: date2.getFullYear(),
month: date2.getMonth() + 1,
day: date2.getDate()
};
day: date2.getDate(),
}
},
/**
* 日期格式转换
*/
dateFormate: function(str, type) {
dateFormate: function (str, type) {
let txt = 'YYYY-MM-DD'
if (type) {
txt = type
......@@ -194,7 +192,7 @@ export const Util = {
/**
* 字段截取
*/
cutStr: function(str, num) {
cutStr: function (str, num) {
if (!str) {
return ''
}
......@@ -207,8 +205,41 @@ export const Util = {
if (str.length > m) {
n = str.slice(0, m) + '...'
}
return n
}
},
/**
* 深克隆 所有原型链上的对象和属性
* 例: const bar=deepClone(foo)
* console.log(bar===foo) false
* @param {*} obj
*/
deepClone: function (obj) {
// Handle the 3 simple types, and null or undefined or function
if (obj == null || typeof obj !== 'object') return obj
// Handle Date
if (obj instanceof Date) {
const copy = new Date()
copy.setTime(obj.getTime())
return copy
}
// Handle Array or Object
if ((obj instanceof Array) | (obj instanceof Object)) {
const copy = obj instanceof Array ? [] : {}
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) {
copy[attr] = Util.deepClone(obj[attr])
}
}
return copy
}
throw new Error("Unable to clone obj! Its type isn't supported.")
},
}
export const showModal = Util.msg;
export const showToast = Util.Info;
export const showLoading = Util.loading
export const hideLoading = Util.closeLoading
export const deepClone = Util.deepClone
import axios from './api' // 倒入 api
import config from './config.js' // 倒入默认配置
export const BASEURL = config.baseURL
// 设备管理-批量初始化-获取列表
export const PAGEDEVICESNINITRECORD = (params) => {
return axios({
url: 'jxcmtDeviceSnInitRecord/pageDeviceSnInitRecord',
method: 'GET',
params,
})
}
// 设备管理-批量初始化-模板下载
export const DEVICESNINITRECORDDOWNLOADTEMPLATE =
BASEURL + 'jxcmtDeviceSnInitRecord/DeviceSnInitRecordDownloadTemplate'
// 设备管理-批量初始化-模板校验
export const CHECKDEVICESNINITRECORDIMPORT =
BASEURL + 'jxcmtDeviceSnInitRecord/checkDeviceSnInitRecordImport'
// 设备管理-批量初始化-导入模板数据
export const IMPORTDEVICESNINITRECORDIMPORT = (params) => {
return axios({
url: 'jxcmtDeviceSnInitRecord/importDeviceSnInitRecordImport',
method: 'POST',
data: params,
})
}
......@@ -120,6 +120,18 @@ export const resources = {
component: _import('main/deviceUnstock'),
auth: []
},
'10206': {
path: '/main/initialize',
name: 'fimsTable10206',
meta: {
title: '批量初始化',
authId: '10206',
parentId: '102',
cache: true
},
component: _import('main/initialize'),
auth: []
},
'103': {
path: '/equipment',
icon: 'document',
......
......@@ -5,32 +5,17 @@
<el-form-item label="设备类型">
<el-select v-model="formInline.typeId" placeholder="请选择">
<el-option value label="全部">全部</el-option>
<el-option
v-for="item in deviceTypeList"
:key="item.id"
:value="item.id"
:label="item.name"
>{{ item.name }}</el-option>
<el-option v-for="item in deviceTypeList" :key="item.id" :value="item.id" :label="item.name">{{ item.name }}</el-option>
</el-select>
</el-form-item>
<el-form-item label="设备编号">
<el-input v-model="formInline.deviceCode" placeholder="请输入发货单号" />
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
:loading="tableLoading"
@click="getList()"
>搜索</el-button>
<el-button type="primary" icon="el-icon-search" :loading="tableLoading" @click="getList()">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-download"
:loading="exportLoading"
@click="exportExcel()"
>导出</el-button>
<el-button type="primary" icon="el-icon-download" :loading="exportLoading" @click="exportExcel()">导出</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-plus" @click="add()">新建</el-button>
......@@ -40,23 +25,16 @@
<!-- 表格区域 开始 -->
<div class="table_box">
<el-table
v-loading="tableLoading"
:data="tableData"
stripe
style="width: 100%"
size="small"
border
>
<el-table v-loading="tableLoading" :data="tableData" stripe style="width: 100%" size="small" border>
<el-table-column type="index" :index="index => {return index+1}" label="序号" width="80" />
<el-table-column prop="deviceCode" label="设备编号" />
<el-table-column prop="deviceName" label="设备名称" />
<el-table-column prop="iccid" label="设备类型">
<el-table-column prop="deviceCode" label="设备编号" show-overflow-tooltip />
<el-table-column prop="deviceName" label="设备名称" show-overflow-tooltip />
<el-table-column prop="iccid" label="设备类型" show-overflow-tooltip>
<template slot-scope="scoped">{{ scoped.row.deviceType.name }}</template>
</el-table-column>
<el-table-column prop="merchantName" label="品牌定制商" />
<el-table-column prop="merchantName" label="品牌定制商" show-overflow-tooltip />
<el-table-column prop="imei" label="创建人" />
<el-table-column prop="createdDate" label="创建时间">
<el-table-column prop="createdDate" label="创建时间" show-overflow-tooltip>
<template slot-scope="scoped">{{ DATEFORMATE(scoped.row.createdDate) }}</template>
</el-table-column>
<el-table-column prop="createdDate" label="操作" align="center">
......@@ -67,15 +45,7 @@
</el-table-column>
</el-table>
<div class="pagination_list">
<el-pagination
background
layout="sizes, total,prev, pager, next, jumper"
:total="pageTotal"
:page-size="pageSize"
:page-sizes="pageSizes"
@current-change="getList"
@size-change="changePageSize"
/>
<el-pagination background layout="sizes, total,prev, pager, next, jumper" :total="pageTotal" :page-size="pageSize" :page-sizes="pageSizes" @current-change="getList" @size-change="changePageSize" />
</div>
</div>
<!-- 表格区域 end -->
......@@ -99,26 +69,12 @@
<span class="name">导入设备:</span>
<div class="content">
<el-input type="text" class="a_input" :value="uploadFile.name" readonly />
<el-upload
class="upload-demo"
ref="upload"
:action="PREDEVICEIMPORT"
multiple
:limit="1"
:data="uploadForm"
:file-list="fileList"
:show-file-list="false"
:on-change="uploadChange"
:on-success="uploadSuccess"
>
<el-upload class="upload-demo" ref="upload" :action="PREDEVICEIMPORT" multiple :limit="1" :data="uploadForm" :file-list="fileList" :show-file-list="false" :on-change="uploadChange" :on-success="uploadSuccess">
<el-button size="small" type="primary">选择文件</el-button>
</el-upload>
</div>
</div>
<div
class="upload_cell cell_center"
v-if="uploadError.totalCount || uploadError.totalCount==0"
>
<div class="upload_cell cell_center" v-if="uploadError.totalCount || uploadError.totalCount==0">
<span>检验成功{{uploadError.successCount}}条,失败{{uploadError.failCount}}条</span>
<span v-if="uploadError.url">请下载</span>
<a :href="uploadError.url" target="_blank" v-if="uploadError.url">导出失败列表</a>
......
<template>
<d2-container>
<el-card shadow="never">
<el-form :inline="true" :model="formInline" class="demo-form-inline" size="small">
<el-form-item label="关键字">
<el-input v-model="formInline.dvSn" placeholder="设备号/设备IMEI/ICCID" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" :loading="tableLoading" plain @click="getList()">搜索</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- 按钮操作区域 开始 -->
<div class="links_group">
<div class="left"></div>
<div class="right">
<el-button type="primary" plain icon="el-icon-upload2" @click="openDialog">导入</el-button>
</div>
</div>
<!-- 按钮操作区域 开始 -->
<!-- 表格区域 开始 -->
<div class="table_box">
<el-table class="el_table" v-loading="tableLoading" :data="tableData" stripe style="width: 100%" size="small" border>
<el-table-column prop="seedTag" label="批次码" />
<el-table-column prop="dvSn" label="设备号" />
<el-table-column prop="dvImei" label="设备IMEI" />
<el-table-column prop="dvIccid" label="流量卡ICCID" />
<el-table-column prop="dvOperatorType" label="操作方式">
<template slot-scope="scope">{{showType(scope.row.dvOperatorType)}}</template>
</el-table-column>
<el-table-column prop="dvRemark" label="备注" />
<el-table-column prop="dvFailreason" label="失败原因" />
<el-table-column prop="createdDate" label="发起时间" />
</el-table>
<div class="pagination_list">
<el-pagination background layout="sizes, total,prev, pager, next, jumper" :total="pageTotal" :page-size="pageSize" :page-sizes="pageSizes" @current-change="getList" @size-change="changePageSize" />
</div>
</div>
<!-- 表格区域 end -->
<!-- 弹框 开始 -->
<glsx-dialog :show="showDialog" title="批量初始化" width="30%" usefooter @closed="closeDialog">
<div class="upload_box">
<h2 class="h2">
请点击下载"
<a :href="DEVICESNINITRECORDDOWNLOADTEMPLATE" target="_blank">批量初始化模版</a>"
</h2>
<el-form :model="uploadForm" :rules="uploadFormRules" label-width="120px">
<el-form-item label="操作方式:" prop="operatorType">
<el-select v-model="uploadForm.operatorType">
<el-option v-for="item in DVOPERATORTYPE" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="导入文件:" prop="msg">
<div class="upload_cell">
<el-input type="text" class="a_input" :value="uploadFile.name" readonly />
<el-upload class="upload-demo" ref="upload" :action="CHECKDEVICESNINITRECORDIMPORT" multiple :limit="1" :data="uploadForm" :on-exceed="handleExceed" :file-list="fileList" :show-file-list="false" :on-change="uploadChange" :on-success="uploadSuccess">
<el-button size="small" type="primary">选择文件</el-button>
</el-upload>
</div>
<div class="upload_cell cell_center" v-if="uploadError.totalCount || uploadError.totalCount==0">
<span>检验成功{{uploadError.successCount}}条,失败{{uploadError.failCount}}条</span>
<span>请下载</span>
<a :href="uploadError.url" target="_blank">导出失败列表</a>
</div>
</el-form-item>
</el-form>
</div>
<div slot="footer" class="btn_group">
<el-button type="success" @click="uploadInfoToServer">导入</el-button>
<el-button @click="closeDialog">取消</el-button>
</div>
</glsx-dialog>
<!-- 弹框 end -->
</d2-container>
</template>
<script>
import { PAGEDEVICESNINITRECORD,DEVICESNINITRECORDDOWNLOADTEMPLATE,CHECKDEVICESNINITRECORDIMPORT,IMPORTDEVICESNINITRECORDIMPORT } from '@/http/device'
import GlsxDialog from '@/components/dialog/index'
import { deepClone, showToast } from '@/common/util'
export default {
components: {
'glsx-dialog': GlsxDialog,
},
data() {
return {
formInline: {},
tableData: [],
tableLoading: false,
pageTotal: 0,
currentPage: 1,
pageSizes: [10, 20, 30, 40],
pageSize: 10,
tdWidth: 170,
showDialog: false,
uploadFile: {},
deviceList: [],
DEVICESNINITRECORDDOWNLOADTEMPLATE: DEVICESNINITRECORDDOWNLOADTEMPLATE,
CHECKDEVICESNINITRECORDIMPORT: CHECKDEVICESNINITRECORDIMPORT,
uploadForm: { },
uploadError: {},
DVOPERATORTYPE: [
{ id: 'I', name: '初始化' },
{ id: 'Q', name: '取消出库' },
{ id: 'P', name: '取消入库' },
],
uploadFormRules:{
operatorType:[{required:true,message:'请选择操作方式',trigger:'change'}]
}
}
},
created() {},
mounted: function () {
this.getList()
},
methods: {
/**
* 查询列表
*/
getList: function (current) {
const _this = this
const oParams = _this.getParams()
console.log(current)
oParams.pageNum = current || _this.currentPage
_this.tableLoading = true
PAGEDEVICESNINITRECORD(oParams).then((res) => {
console.log(res)
_this.tableLoading = false
if (res.returnCode == 0) {
const { data } = res
const { total, listVo } = data
_this.tableData = listVo || []
_this.pageTotal = total
}
})
},
/**
* 获取查询参数
*/
getParams: function () {
let oParams = deepClone(this.formInline)
oParams.dvIccid = oParams.dvSn
oParams.dvImei = oParams.dvSn
oParams.pageSize = this.pageSize
return oParams
},
/**
* 每页展示
*/
changePageSize: function (e) {
this.pageSize = e
this.getList()
},
/**监听文件改变 */
uploadChange: function (file, fileList) {
console.log(file)
this.uploadFile = file
},
/**监听文件上传成功 */
uploadSuccess: function (res, file, fileList) {
console.log(res)
//this.$refs.upload.submit();
let o = res.data || []
let m = o[0] || {}
this.$refs.upload.clearFiles()
if (m.url) {
this.uploadError = m
return false
}
this.fileInfo = m.msg
},
/**手动上传文件 */
uploadInfoToServer: function () {
let _this = this
let o = this.fileInfo
let m = this.uploadForm
if (!o) {
return false
}
let oParams = {}
oParams.msg = o;
IMPORTDEVICESNINITRECORDIMPORT(oParams).then((res) => {
console.log(res)
_this.fileLoading = false
if (res.returnCode == 0) {
_this.closeDialog()
showToast({
message: '导入成功',
type: 'success',
})
_this.getList()
}
})
},
// 打开弹框
openDialog() {
this.uploadFile = {}
this.showDialog = true
},
/**关闭弹框 */
closeDialog: function () {
this.$refs.upload.clearFiles()
this.uploadFile = {}
this.showDialog = false
},
// 展示操作方式
showType(id) {
let _list = this.DVOPERATORTYPE
let o = _list.find((k) => k.id == id)
if (o) {
return o.name
} else {
return ''
}
},
},
}
</script>
<style lang="scss" scoped>
.table_box {
margin: 10px 0;
}
.upload_box {
.h2 {
font-size: 14px;
font-weight: normal;
a {
color: #337ab7;
}
}
.h3 {
font-size: 14px;
color: #f00;
font-weight: normal;
}
}
.upload_cell {
display: flex;
align-items: center;
margin: 10px 0;
.name {
width: 80px;
font-weight: bold;
}
.a_input {
margin: 0 8px 0 0;
width: 217px;
}
}
.cell_center {
text-align: center;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!