Commit a81c8954 by cwq0219

设备管理-导入,字段修改

1 parent 7e06632e
......@@ -69,36 +69,46 @@ export const resources = {
parentId: '0',
cache: true
},
auth: [
{
authId: '10201',
parentId: '102',
label: '重置密码',
handle: 'handleResetPassword',
ruleObj: {
attr: 'status',
rule: { 0: '重置密码', 1: '重置密码', 2: '' }
auth: [{
authId: '10201',
parentId: '102',
label: '重置密码',
handle: 'handleResetPassword',
ruleObj: {
attr: 'status',
rule: {
0: '重置密码',
1: '重置密码',
2: ''
}
}, {
authId: '10202',
parentId: '102',
label: '启用',
handle: 'handleUpOrDown',
ruleObj: {
attr: 'status',
rule: { 0: '启用', 1: '停用', 2: '' }
}
}, {
authId: '10202',
parentId: '102',
label: '启用',
handle: 'handleUpOrDown',
ruleObj: {
attr: 'status',
rule: {
0: '启用',
1: '停用',
2: ''
}
}, {
authId: '10203',
parentId: '102',
label: '审核通过',
handle: 'handleExamine',
ruleObj: {
attr: 'status',
rule: { 0: '', 1: '', 2: '审核通过' }
}
}, {
authId: '10203',
parentId: '102',
label: '审核通过',
handle: 'handleExamine',
ruleObj: {
attr: 'status',
rule: {
0: '',
1: '',
2: '审核通过'
}
}
],
}],
component: _import('customer/customer')
},
'103': {
......@@ -111,6 +121,13 @@ export const resources = {
parentId: '0',
cache: true
},
auth: [{
authId: '10301',
parentId: '103',
label: '导出',
category: 'Button',
handle: 'handleImport'
}],
component: _import('device/device')
}
// '104': {
......
<!-- 设备管理 -->
<template>
<d2-container>
<d2-container class="device-list">
<el-form
slot="header"
inline="true"
......@@ -38,7 +38,7 @@
></el-option>
</el-select>
</el-form-item>
<el-form-item label="发货时间:">
<el-form-item label="导入时间:">
<el-date-picker
v-model="createTime"
:size="$store.state.d2admin.size.value"
......@@ -64,12 +64,65 @@
>重置</el-button>
</el-form-item>
</el-form>
<d2-table-header title="设备列表">
<auth-button category="Button"></auth-button>
</d2-table-header>
<d2-table
:beforeSearchFn="beforeSearchFn"
:searchForm="searchForm"
:tableParams="tableParams"
:getListApi="getListApi"
></d2-table>
<d2-dialog
:title="'导入'"
:isVisible="fileVisible"
@closeDialog="handleImport"
@confirmDialog="handleConfirmImport"
>
<slot>
<el-form
:model="fileForm"
ref="fileRuleForm"
:rules="fileRules"
label-width="120px"
>
<el-form-item
label="导入文件:"
prop="fileName"
>
<el-col :span="16">
<el-input
readonly
v-model="fileForm.fileName"
></el-input>
</el-col>
<el-col
:span="4"
class="m-l-md"
>
<el-button class="import-btn">导入文件
<input
type="file"
id="fileUpload"
class="import-input"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
@change="importFile($event)"
/>
<el-link
href="http://img01.glsx.com.cn/upload/salesexcel/预录订单导入模板.xlsx"
type="primary"
class="import-template"
icon="el-icon-link"
>模版下载</el-link>
</el-button>
</el-col>
</el-form-item>
<el-form-item v-show="showNum">
<span>导入成功{{importNum.succNum}}条,导入失败{{importNum.failNum}}条</span>
</el-form-item>
</el-form>
</slot>
</d2-dialog>
</d2-container>
</template>
......@@ -81,6 +134,19 @@ export default {
data() {
return {
rangePickerOptions: rangePickerOptions,
fileVisible: false,
fileForm: {
sellerUserId: ''
},
total: 0,
showNum: false,
importNum: {
succNum: 0,
failNum: 0
},
fileRules: {
fileName: [{ required: true, message: '请上传文件', trigger: 'change' }]
},
searchForm: {
customerName: ''
},
......@@ -103,7 +169,7 @@ export default {
label: '客户',
prop: 'customerName'
}, {
label: '发货时间',
label: '导入时间',
prop: 'createTime',
formatter: (cellValue) => {
return cellValue.createTime.split(' ')[0]
......@@ -139,6 +205,58 @@ export default {
resolve()
})
},
handleImport() {
this.fileForm = {
fileName: ''
}
this.showNum = false
this.importNum = {
succNum: 0,
failNum: 0
}
this.$refs.fileRuleForm && this.$refs.fileRuleForm.resetFields()
this.fileVisible = !this.fileVisible
},
// 上传文件,转码为base64
importFile(e) {
const size = e.target.files[0].size / 1024 / 1024
if (size < 9) {
this.$set(this.fileForm, 'fileName', e.target.files[0].name)
// // 转码base64
const reader = new FileReader()
reader.readAsDataURL(e.target.files[0])
reader.onload = event => {
const imgFile = event.target.result
const arrBase64 = imgFile.split(',')
this.fileInfo = e.target.files[0].name.split('.')[1] + '@' + arrBase64[1]
document.getElementById('fileUpload').value = ''
}
} else {
this.notice.errorTips('上传文件不可超过9M')
}
},
handleConfirmImport() {
this.$refs.fileRuleForm.validate(valid => {
console.log(valid)
if (valid) {
this.notice.okTips()
this.handleImport()
// recordUpload(params).then(res => {
// this.showNum = !!res.failNum
// if (res.failNum) {
// this.importNum = {
// succNum: res.succNum,
// failNum: res.failNum
// }
// this.exportFailList(res.errorList)
// return true
// }
// this.notice.okTips('导入成功')
// this.$refs.recordTable.refreshTable()
// })
}
})
},
handleRest() {
this.createTime = []
this.searchForm = {
......@@ -155,5 +273,24 @@ export default {
}
</script>
<style scoped>
<style>
.device-list .import-btn {
position: relative;
}
.device-list .import-input {
opacity: 0;
position: absolute;
right: 0;
top: 0;
width: 98px;
height: 36px;
cursor: pointer;
font-size: 0;
}
.device-list .import-template {
position: absolute;
height: 20px;
top: 50px;
left: 0;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!