From 22bef48ed9841b3c499e3e2466f52427f9c5ecac Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期一, 08 一月 2024 12:39:43 +0800
Subject: [PATCH] 销售订单-下载word修改2
---
src/views/admin/user/index.vue | 141 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 139 insertions(+), 2 deletions(-)
diff --git a/src/views/admin/user/index.vue b/src/views/admin/user/index.vue
index 68ef1e1..d50b400 100644
--- a/src/views/admin/user/index.vue
+++ b/src/views/admin/user/index.vue
@@ -66,6 +66,15 @@
@click="$refs.crud.rowAdd()"
>娣诲姞
</el-button>
+ <!-- <el-button
+ v-if="sys_user_add"
+ class="filter-item"
+ type="primary"
+ size="small"
+ icon="el-icon-upload"
+ @click="importDialogVisible=true"
+ >瀵煎叆
+ </el-button> -->
</template>
<template slot="username" slot-scope="scope">
<span>{{ scope.row.username }}</span>
@@ -147,6 +156,45 @@
:currshowlist.sync="showStaff"
@listenToStaffEvent="selectStaff"
/>
+ <el-dialog title="瀵煎叆" :visible.sync="importDialogVisible" width="30%">
+ <span>
+ <div>
+ <div>
+ <el-upload
+ style="margin-left:8px;display: inline;"
+ class="upload-demo"
+ drag
+ :headers="headers"
+ :action="uploadInfo.url"
+ :beforeUpload="beforeAvatarUpload"
+ :limit="1"
+ :show-file-list="false"
+ :file-list="fileList"
+ :on-success="fileSuccessUploadScan"
+ :on-error="handleError"
+ accept=".xlsx,.xls,.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
+ :auto-upload="true"
+ ref="uploadScan"
+ multiple
+ >
+ <i class="el-icon-upload"></i>
+ <div class="el-upload__text"><em>鐐瑰嚮瀵煎叆鏁版嵁</em></div>
+ <div class="el-upload__tip" slot="tip" >
+ 鍙兘涓婁紶xlsx/xls鏂囦欢锛屼笖涓嶈秴杩�10M<el-button
+ type="text"
+ style="font-size:12px;"
+ @click="downDataTemplate(uploadInfo.fileName)"
+ v-if="uploadInfo.Download"
+ >涓嬭浇妯℃澘</el-button
+ >
+ </div>
+ </el-upload>
+ </div>
+ <div></div>
+ </div>
+ </span>
+ <span slot="footer" class="dialog-footer"> </span>
+ </el-dialog>
</div>
</template>
<script>
@@ -158,12 +206,26 @@
import { mapGetters } from 'vuex'
import Template from '../../quality/parts/template'
import { getObj } from '@/api/basic/staff'
-
+import { getStore } from '@/util/store.js'
+import { uploadTemplate } from '@/api/basic/template'
export default {
name: 'SysUser',
components: { Template, staffDialog },
data() {
return {
+ fileList: [], // 涓婁紶鏂囦欢鍒楄〃
+ // 涓婁紶澶翠俊鎭�
+ headers: {
+ Authorization: 'Bearer ' + getStore({ name: 'access_token' })
+ },
+ uploadInfo: {
+ // 鏄惁灞曠ず涓婁紶EXCEL浠ュ強瀵瑰簲鐨剈rl
+ isShow: true,
+ url: '/mes/user/upload',
+ download: true,
+ fileName: '鐢ㄦ埛妯℃澘'
+ },
+ importDialogVisible: false,
showStaff: false,
searchForm: {},
treeOption: {
@@ -216,6 +278,77 @@
this.init()
},
methods: {
+ // 闄愬埗鏂囦欢涓婁紶澶у皬锛岀洰鍓嶉檺鍒朵负10M锛堝彟鍙互鍔犵被鍨嬮檺鍒讹級
+ beforeAvatarUpload(file) {
+ const fileName = file.name
+ const fileType = fileName.substring(fileName.lastIndexOf('.') + 1)
+ const isLt10M = file.size / 1024 / 1024 < 10
+ if (fileType !== 'xlsx' && fileType !== 'xls') {
+ this.$message.error('鏂囦欢鏍煎紡鍙兘涓簒lsx鎴杧ls,璇峰垹闄ゅ悗閲嶆柊涓婁紶')
+ }
+ if (!isLt10M) {
+ this.$message({
+ message: '鏂囦欢澶у皬',
+ type: 'warning'
+ })
+ }
+ return isLt10M
+ },
+ // 鏂囦欢涓婁紶鎴愬姛鍥炶皟浜嬩欢
+ fileSuccessUploadScan(response, file, fileList) {
+ if (response.code != '0') {
+ this.$message.warning(response.msg)
+ } else {
+ if(response.data!=""&&response.data!=[]&&response.data!=null){
+ this.$message({
+ message: response.data,
+ type: 'success',
+ dangerouslyUseHTMLString: true,
+ })
+ }else{
+ this.$message({
+ message: '涓婁紶鎴愬姛',
+ type: 'success'
+ })
+ }
+ this.importDialogVisible=false
+ this.fileList=[]
+ this.init()
+ // this.getDataList()
+ }
+ this.$refs.uploadScan.clearFiles()
+ },
+ // 涓婁紶澶辫触
+ handleError(err, file, fileList) {
+ const error = JSON.parse(err.message)
+ if (error.msg) {
+ this.$message.error(error.msg)
+ } else {
+ this.$message.error('涓婁紶澶辫触')
+ }
+ },
+ // 涓嬭浇鏁版嵁妯℃澘
+ downDataTemplate() {
+ uploadTemplate("user").then((response) => {
+ const blob = new Blob([response.data], {
+ type: 'application/force-download'
+ })
+ let fileName="妯℃澘鏂囦欢";
+ if(this.uploadInfo.fileName!=undefined&&this.uploadInfo.fileName!=''&&this.uploadInfo.fileName!=null){
+ fileName=this.uploadInfo.fileName
+ }
+ const filename = decodeURI(fileName+'.xlsx')
+ // 鍒涘缓涓�涓秴閾炬帴锛屽皢鏂囦欢娴佽祴杩涘幓锛岀劧鍚庡疄鐜拌繖涓秴閾炬帴鐨勫崟鍑讳簨浠�
+ const elink = document.createElement('a')
+ elink.download = filename
+ elink.style.display = 'none'
+ elink.href = URL.createObjectURL(blob)
+ document.body.appendChild(elink)
+ elink.click()
+ URL.revokeObjectURL(elink.href) // 閲婃斁URL 瀵硅薄
+ document.body.removeChild(elink)
+ })
+ },
selectStaff(staff) {
this.form.staffInfo = staff.staffName + '-' + staff.staffNo
this.form.phone = staff.phone
@@ -343,7 +476,11 @@
})
},
unlock(row, index) {
- unlock({ id: row.userId }).then((repsonse) => {})
+ unlock({ id: row.userId }).then((repsonse) => {
+ if(repsonse.data.data){
+ this.$message.success("璇ョ敤鎴峰凡瑙i攣")
+ }
+ })
}
}
}
--
Gitblit v1.9.3