Commit fc573372 authored by 黄奎's avatar 黄奎

页面修改

parent df16d6d1
......@@ -47,7 +47,7 @@ module.exports = function(ctx) {
vueRouterMode: 'history', // available values: 'hash', 'history'
env: ctx.dev ? {
API: 'http://localhost:5001/api',
API: 'http://localhost:8300/api',
// API: 'http://192.168.10.128:8300/api',
// API: 'https://eduapi.oytour.com/api',
API_ZC: 'http://192.168.5.238:8087/api',
......
......@@ -25,8 +25,8 @@ export function getFontConfig() {
export function CommonConfig() {
return {
FileConfig: {
FileUrl: 'http://192.168.5.46:8130', //本地服务器文件预览地址
UploadUrl: 'http://192.168.5.46:8120'
FileUrl: 'http://192.168.5.214:8130', //本地服务器文件预览地址
UploadUrl: 'http://192.168.5.214:8120'
}
}
}
......@@ -296,7 +296,7 @@ export function UploadFileToALi(uploadConfig, fileFullPath, fileObj, uploadLoadd
if (locationName.indexOf('localhost') !== -1) {
uploadConfig.UploadDomain = fileConfig.FileConfig.UploadUrl;
}
let url = uploadConfig.UploadDomain + "/Upload/UploadToALiOSS?filePath=" + newFileName;
let url = uploadConfig.UploadDomain + "/Upload/UploadToALiOSS?isDomain=1&filePath=" + newFileName;
let formData = new FormData()
formData.append('myfile', fileObj)
let xhr = new XMLHttpRequest()
......@@ -332,7 +332,7 @@ export function UploadFileToTencent(uploadConfig, fileFullPath, fileObj, uploadL
if (locationName.indexOf('localhost') !== -1) {
uploadConfig.UploadDomain = fileConfig.FileConfig.UploadUrl;
}
let url = uploadConfig.UploadDomain + "/Upload/UploadToTecent?filePath=" + newFileName;
let url = uploadConfig.UploadDomain + "/Upload/UploadToTecent?isDomain=1&filePath=" + newFileName;
let formData = new FormData()
formData.append('myfile', fileObj)
let xhr = new XMLHttpRequest()
......
<style>
.personalData {
justify-content: space-between;
}
.personalData .box_l,
.box_r {
background: #fff;
border-radius: 6px;
}
.personalData .box_l {
width: 380px;
margin-right: 30px;
padding: 40px;
}
.personalData .box_r {
flex: 1;
width: 1px;
padding: 20px 26px;
}
.personalData .box_r2{
flex: 1;
width: 1px;
padding: 0px 0px;
}
.personalData .box_l_t {
margin-top: 28px;
font-size: 14px;
color: #999999;
}
.personalData .box_l_t_l {
color: #3F4254;
font-weight: bold;
}
.personalData .box_l_title {
width: 100%;
height: 50px;
line-height: 50px;
background: #2961FE;
border-radius: 4px;
font-size: 16px;
font-weight: bold;
color: #FFFFFF;
padding-left: 39px;
/* margin-top: 55px; */
margin-top: 8px;
cursor: pointer;
}
.personalData .box_l_cen {
width: 100%;
height: 50px;
line-height: 50px;
border-radius: 4px;
font-size: 16px;
font-weight: bold;
color: #3F4254;
padding-left: 39px;
margin-top: 8px;
cursor: pointer;
justify-content: space-between;
}
.personalData .headportrait {
width: 120px;
height: 120px;
border-radius: 20px;
position: relative;
margin-top: 20px;
}
.personalData .editbianji {
position: absolute;
right: -10px;
top: -10px;
width: 26px;
height: 26px;
background: #FFFFFF;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0px 0px 10px 0px rgba(2, 44, 66, 0.15);
}
.personalData .box_r_title {
font-size: 12px;
font-weight: bold;
color: #000000;
margin-top: 27px
}
.personalData .box_r_input {
width: 55%;
margin-top: 20px;
}
.personalData {
justify-content: space-between;
}
.personalData .box_l,
.box_r {
background: #fff;
border-radius: 6px;
}
.personalData .box_l {
width: 380px;
margin-right: 30px;
padding: 40px;
}
.personalData .box_r {
flex: 1;
width: 1px;
padding: 20px 26px;
}
.personalData .box_r2 {
flex: 1;
width: 1px;
padding: 0px 0px;
}
.personalData .box_l_t {
margin-top: 28px;
font-size: 14px;
color: #999999;
}
.personalData .box_l_t_l {
color: #3F4254;
font-weight: bold;
}
.personalData .box_l_title {
width: 100%;
height: 50px;
line-height: 50px;
background: #2961FE;
border-radius: 4px;
font-size: 16px;
font-weight: bold;
color: #FFFFFF;
padding-left: 39px;
/* margin-top: 55px; */
margin-top: 8px;
cursor: pointer;
}
.personalData .box_l_cen {
width: 100%;
height: 50px;
line-height: 50px;
border-radius: 4px;
font-size: 16px;
font-weight: bold;
color: #3F4254;
padding-left: 39px;
margin-top: 8px;
cursor: pointer;
justify-content: space-between;
}
.personalData .headportrait {
width: 120px;
height: 120px;
border-radius: 20px;
position: relative;
margin-top: 20px;
}
.personalData .editbianji {
position: absolute;
right: -10px;
top: -10px;
width: 26px;
height: 26px;
background: #FFFFFF;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0px 0px 10px 0px rgba(2, 44, 66, 0.15);
}
.personalData .box_r_title {
font-size: 12px;
font-weight: bold;
color: #000000;
margin-top: 27px
}
.personalData .box_r_input {
width: 55%;
margin-top: 20px;
}
</style>
<template>
<div class="page-body personalData row" style="background: transparent;">
<div class="box_l">
<div class="q-mt-lg flex">
<q-avatar size="100px" font-size="36px" rounded style="background:#C9F7F5" text-color="white">
<img :src="showObj.UserIcon" v-if="showObj.UserIcon">
<span v-else>{{showObj.AccountName.substring(0,1)}}</span>
</q-avatar>
<div class="col q-ml-md">
<div class="text-weight-bold" style="font-size:18px;font-weight: 800;color: #3F4254;">
{{showObj.AccountName}}</div>
<div class="text-muted" style="font-size:14px;margin-top: 12px;">
{{showObj.SchoolName}}·{{showObj.PostName}}</div>
<div class="q-mt-xs">
<q-btn style="background: var(--q-color-negative);color: white;margin-top: 10px;" size="sm" @click="logout">退出登录</q-btn>
</div>
</div>
</div>
<div class="box_l_t" style="margin-top: 40px;">
<span class="box_l_t_l">邮箱:</span>
<span>{{showObj.Email}}</span>
</div>
<div class="box_l_t">
<span class="box_l_t_l">电话:</span>
<span>{{showObj.UserMobile}}</span>
</div>
<div class="box_l_t" style="margin-bottom: 55px;">
<span class="box_l_t_l">部门:</span>
<span>{{showObj.DeptName}}</span>
</div>
<div :class="rightType==0?'box_l_title':'box_l_cen'" @click='rightType=0'>概要信息</div>
<!-- <div :class="rightType==3?'box_l_title':'box_l_cen'" @click='rightType=3'>预警信息</div> -->
<div :class="rightType==1?'box_l_title':'box_l_cen'" @click='rightType=1'>账户资料</div>
<div :class="rightType==2?'box_l_title':'box_l_cen'" @click='rightType=2'>密码修改</div>
<div class="page-body personalData row" style="background: transparent;">
<div class="box_l">
<div class="q-mt-lg flex">
<q-avatar size="100px" font-size="36px" rounded style="background:#C9F7F5" text-color="white">
<img :src="showObj.UserIcon" v-if="showObj.UserIcon">
<span v-else>{{showObj.AccountName.substring(0,1)}}</span>
</q-avatar>
<div class="col q-ml-md">
<div class="text-weight-bold" style="font-size:18px;font-weight: 800;color: #3F4254;">
{{showObj.AccountName}}</div>
<div class="text-muted" style="font-size:14px;margin-top: 12px;">
{{showObj.SchoolName}}·{{showObj.PostName}}</div>
<div class="q-mt-xs">
<q-btn style="background: var(--q-color-negative);color: white;margin-top: 10px;" size="sm" @click="logout">
退出登录</q-btn>
</div>
</div>
</div>
<div class="box_l_t" style="margin-top: 40px;">
<span class="box_l_t_l">邮箱:</span>
<span>{{showObj.Email}}</span>
</div>
<div class="box_l_t">
<span class="box_l_t_l">电话:</span>
<span>{{showObj.UserMobile}}</span>
</div>
<div class="box_l_t" style="margin-bottom: 55px;">
<span class="box_l_t_l">部门:</span>
<span>{{showObj.DeptName}}</span>
</div>
<div :class="rightType==0?'box_l_title':'box_l_cen'" @click='rightType=0'>概要信息</div>
<!-- <div :class="rightType==3?'box_l_title':'box_l_cen'" @click='rightType=3'>预警信息</div> -->
<div :class="rightType==1?'box_l_title':'box_l_cen'" @click='rightType=1'>账户资料</div>
<div :class="rightType==2?'box_l_title':'box_l_cen'" @click='rightType=2'>密码修改</div>
</div>
<!-- 个人资料 -->
<div v-if='rightType == 0' class="box_r2">
<summaryInfo></summaryInfo>
</div>
<div class="box_r" v-if='rightType !=0'>
<template v-if='rightType == 1'>
<div style="font-size: 16px;font-weight: bold;color: #000000;">账户资料</div>
<div class="box_r_title">账户资料</div>
<div class="headportrait">
<q-avatar size="120px" font-size="36px" rounded style="background:#C9F7F5" text-color="white">
<img :src="datamodify.UserIcon" v-if="datamodify.UserIcon">
<span v-else>{{showObj.AccountName.substring(0,1)}}</span>
</q-avatar>
<el-upload class="editbianji" :http-request="uploadFileBtn" :multiple="false" action=''
accept=".JPG, .PNG, .JPEG,.jpg, .png, .jpeg" :show-file-list="false">
<q-icon name="edit" />
</el-upload>
</div>
<div style="font-size: 12px;color: #999999;margin-top: 12px;">图片格式:png、jpg、jpeg</div>
<div class="box_r_title">基础资料</div>
<div class="box_r_input">
<q-input v-model="datamodify.EmployeeName" label="姓名" :rules="[val => !!val || '姓名不能为空']" lazy-rules filled
maxlength="20" />
</div>
<div class="box_r_input">
<q-select filled stack-label option-value="SId" option-label="SName" v-model="datamodify.School_Id" ref="SId"
:options="CompanyList" label="校区" :dense="false" emit-value map-options />
</div>
<!-- 个人资料 -->
<div v-if='rightType == 0' class="box_r2">
<summaryInfo></summaryInfo>
<div class="box_r_title">联系方式</div>
<div class="box_r_input">
<q-input v-model="datamodify.EmployeeTel" label="电话" type='number' :rules="[val => !!val || '电话不能为空']"
lazy-rules filled maxlength="11" />
</div>
<div class="box_r" v-if='rightType !=0'>
<template v-if='rightType == 1'>
<div style="font-size: 16px;font-weight: bold;color: #000000;">账户资料</div>
<div class="box_r_title">账户资料</div>
<div class="headportrait">
<q-avatar size="120px" font-size="36px" rounded style="background:#C9F7F5" text-color="white">
<img :src="datamodify.UserIcon" v-if="datamodify.UserIcon">
<span v-else>{{showObj.AccountName.substring(0,1)}}</span>
</q-avatar>
<el-upload class="editbianji" :http-request="uploadFileBtn" :multiple="false" action=''
accept=".JPG, .PNG, .JPEG,.jpg, .png, .jpeg" :show-file-list="false">
<q-icon name="edit" />
</el-upload>
</div>
<div style="font-size: 12px;color: #999999;margin-top: 12px;">图片格式:png、jpg、jpeg</div>
<div class="box_r_title">基础资料</div>
<div class="box_r_input">
<q-input v-model="datamodify.EmployeeName" label="姓名"
:rules="[val => !!val || '姓名不能为空']" lazy-rules filled maxlength="20" />
</div>
<div class="box_r_input">
<q-select filled stack-label option-value="SId" option-label="SName" v-model="datamodify.School_Id"
ref="SId" :options="CompanyList" label="校区" :dense="false" emit-value map-options />
</div>
<div class="box_r_title">联系方式</div>
<div class="box_r_input">
<q-input v-model="datamodify.EmployeeTel" label="电话" type='number'
:rules="[val => !!val || '电话不能为空']" lazy-rules filled maxlength="11" />
</div>
<div class="box_r_input">
<q-input v-model="datamodify.Email" label="邮箱"
:rules="[val => !!val || '邮箱不能为空']" lazy-rules filled maxlength="20" />
</div>
<q-btn color="primary" style="width: 300px;margin-top: 50px;" :loading="loading1" @click='dataSubmit'>
<div class="ellipsis">
提交
</div>
</q-btn>
</template>
<template v-if='rightType == 2'>
<div style="font-size: 16px;font-weight: bold;color: #000000;">密码修改</div>
<form @submit.prevent.stop="passwordSubmit" class="q-gutter-md">
<div class="box_r_title">原密码</div>
<div class="box_r_input">
<q-input v-model="passwordMsg.OldPassWord" label="请输入旧密码" type='password' ref='OldPassWord'
:rules="[val => !!val || '请输入旧密码']" lazy-rules filled />
</div>
<div class="box_r_title">新密码</div>
<div class="box_r_input">
<q-input v-model="passwordMsg.NewPassWord" label="请输入新密码" type='password' ref='NewPassWord'
:rules="[val => !!val || '请输入新密码']" lazy-rules filled />
</div>
<div class="box_r_input">
<q-input v-model="passwordMsg.NewSurePassWord" label="请再次输入新密码" type='password' ref='NewSurePassWord'
:rules="[val => !!val || '请再次输入新密码']" lazy-rules filled />
</div>
<q-btn color="primary" style="width: 300px;margin-top: 50px;" :loading="loading2" label="确定修改" type="submit" > </q-btn>
</form>
</template>
<div class="box_r_input">
<q-input v-model="datamodify.Email" label="邮箱" :rules="[val => !!val || '邮箱不能为空']" lazy-rules filled
maxlength="20" />
</div>
<q-btn color="primary" style="width: 300px;margin-top: 50px;" :loading="loading1" @click='dataSubmit'>
<div class="ellipsis">
提交
</div>
</q-btn>
</template>
<template v-if='rightType == 2'>
<div style="font-size: 16px;font-weight: bold;color: #000000;">密码修改</div>
<form @submit.prevent.stop="passwordSubmit" class="q-gutter-md">
<div class="box_r_title">原密码</div>
<div class="box_r_input">
<q-input v-model="passwordMsg.OldPassWord" label="请输入旧密码" type='password' ref='OldPassWord'
:rules="[val => !!val || '请输入旧密码']" lazy-rules filled />
</div>
<div class="box_r_title">新密码</div>
<div class="box_r_input">
<q-input v-model="passwordMsg.NewPassWord" label="请输入新密码" type='password' ref='NewPassWord'
:rules="[val => !!val || '请输入新密码']" lazy-rules filled />
</div>
<div class="box_r_input">
<q-input v-model="passwordMsg.NewSurePassWord" label="请再次输入新密码" type='password' ref='NewSurePassWord'
:rules="[val => !!val || '请再次输入新密码']" lazy-rules filled />
</div>
<q-btn color="primary" style="width: 300px;margin-top: 50px;" :loading="loading2" label="确定修改" type="submit">
</q-btn>
</form>
</template>
</div>
</div>
</template>
<script>
import {
setEmployeeBaseInfo,
updateUserPassword
} from '../../api/users/user'
import {
getSchoolDropdown,
} from '../../api/school/index'
import {
UploadSelfFile
} from '../../api/common/common'
const defaultpassword = {
OldPassWord:'',
NewPassWord:'',
NewSurePassWord:'',
}
import summaryInfo from '../../components/user/summaryInfo'
import Lockr from 'lockr'
export default {
meta: {
title: "个人资料"
},
components: {
summaryInfo
},
data() {
return {
loading1: false,
loading2:false,
showObj: {},
rightType: 0,//右边显示类型
datamodify: {},
CompanyList: [],
passwordMsg:Object.assign({},defaultpassword),
}
},
created() {
this.showObj = this.getLocalStorage();
this.datamodify = {
EmployeeName: this.showObj.AccountName,
UserIcon: this.showObj.UserIcon,
EmployeeTel: this.showObj.UserMobile,
Email: this.showObj.Email,
School_Id: this.showObj.School_Id,
import {
setEmployeeBaseInfo,
updateUserPassword
} from '../../api/users/user'
import {
getSchoolDropdown,
} from '../../api/school/index'
import {
UploadSelfFile
} from '../../api/common/common'
const defaultpassword = {
OldPassWord: '',
NewPassWord: '',
NewSurePassWord: '',
}
import summaryInfo from '../../components/user/summaryInfo'
import Lockr from 'lockr'
export default {
meta: {
title: "个人资料"
},
components: {
summaryInfo
},
data() {
return {
loading1: false,
loading2: false,
showObj: {},
rightType: 0, //右边显示类型
datamodify: {},
CompanyList: [],
passwordMsg: Object.assign({}, defaultpassword),
}
},
created() {
this.showObj = this.getLocalStorage();
this.datamodify = {
EmployeeName: this.showObj.AccountName,
UserIcon: this.showObj.UserIcon,
EmployeeTel: this.showObj.UserMobile,
Email: this.showObj.Email,
School_Id: this.showObj.School_Id,
}
},
mounted() {
this.getBranchList()
},
methods: {
getBranchList() { //获取校区
getSchoolDropdown({}).then(res => {
this.CompanyList = res.Data;
}).catch(() => {
})
},
uploadFileBtn(file) { //上传
//UploadFileToTencent
//UploadSelfFile
this.UploadFileToTencent('studentIcon', file.file, x => {
if (x.Code == 1) {
this.datamodify.UserIcon = x.FileUrl
}
}, 1);
},
logout() { //退出登录
this.$store
.dispatch('LogOut')
.then(() => {
this.$router.push('/login')
})
.catch((e) => {
})
},
dataSubmit() { //资料提交
if (this.datamodify.UserIcon == null || this.datamodify.UserIcon == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `照片不能为空`
})
return
}
if (this.datamodify.EmployeeName == null || this.datamodify.EmployeeName == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `姓名不能为空`
})
return
}
if (this.datamodify.EmployeeTel == null || this.datamodify.EmployeeTel == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `电话不能为空`
})
return
}
if (this.datamodify.Email == null || this.datamodify.Email == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `邮箱不能为空`
})
return
}
setEmployeeBaseInfo(this.datamodify).then(res => {
if (res.Code == 1) {
this.$q.notify({
type: 'iconfont icon-chenggong',
color: 'accent',
position: "top",
message: res.Message
})
this.showObj.AccountName = this.datamodify.EmployeeName
this.showObj.UserIcon = this.datamodify.UserIcon
this.showObj.UserMobile = this.datamodify.EmployeeTel
this.showObj.Email = this.datamodify.Email
this.showObj.School_Id = this.datamodify.School_Id
this.CompanyList.map(x => {
if (x.SId == this.datamodify.School_Id) {
this.showObj.SchoolName = x.SName;
return
}
})
Lockr.set("loginUserInfo", this.showObj)
this.$store.dispatch("setUserUpdate", this.showObj)
// location.reload()
// this.$router.push({
// path: this.redirect || '/home'
// })
// let obj = JSON.parse(JSON.stringify(this.datamodify))
// obj.SchoolName = this.showObj.SchoolName
// setTimeout(() => {
// this.MsgBus.$emit('add',obj);
// }, 10);
}
}).catch(() => {
})
},
passwordSubmit() {
this.$refs.OldPassWord.validate()
this.$refs.NewPassWord.validate()
this.$refs.NewSurePassWord.validate()
if (this.$refs.OldPassWord.hasError || this.$refs.NewPassWord.hasError || this.$refs.NewSurePassWord.hasError) {
this.formHasError = true
} else {
// 掉接口
updateUserPassword(this.passwordMsg).then(res => {
if (res.Code == 1) {
this.$q.notify({
type: 'iconfont icon-chenggong',
color: 'accent',
position: "top",
message: res.Message
})
// this.passwordMsg = Object.assign({},defaultpassword)
this.$q.dialog({
title: '功能提示',
message: '密码修改需重新登录',
persistent: true
}).onOk(() => {
this.$store
.dispatch('LogOut')
.then(() => {
this.$router.push('/login')
})
.catch((e) => {
})
});
}
},
mounted() {
this.getBranchList()
},
methods: {
getBranchList() {//获取校区
getSchoolDropdown({}).then(res => {
this.CompanyList = res.Data;
}).catch(() => {
})
},
uploadFileBtn(file) { //上传
UploadSelfFile('studentIcon', file.file, x => {
if (x.Code == 1) {
this.datamodify.UserIcon = x.FileUrl
}
}, 1);
},
logout() {//退出登录
this.$store
.dispatch('LogOut')
.then(() => {
this.$router.push('/login')
})
.catch((e) => {
})
},
dataSubmit() {//资料提交
if (this.datamodify.UserIcon == null || this.datamodify.UserIcon == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `照片不能为空`
})
return
}
if (this.datamodify.EmployeeName == null || this.datamodify.EmployeeName == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `姓名不能为空`
})
return
}
if (this.datamodify.EmployeeTel == null || this.datamodify.EmployeeTel == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `电话不能为空`
})
return
}
if (this.datamodify.Email == null || this.datamodify.Email == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `邮箱不能为空`
})
return
}
setEmployeeBaseInfo(this.datamodify).then(res => {
if (res.Code == 1) {
this.$q.notify({
type: 'iconfont icon-chenggong',
color: 'accent',
position: "top",
message: res.Message
})
this.showObj.AccountName = this.datamodify.EmployeeName
this.showObj.UserIcon = this.datamodify.UserIcon
this.showObj.UserMobile = this.datamodify.EmployeeTel
this.showObj.Email = this.datamodify.Email
this.showObj.School_Id = this.datamodify.School_Id
this.CompanyList.map(x=>{
if(x.SId == this.datamodify.School_Id){
this.showObj.SchoolName = x.SName;
return
}
})
Lockr.set("loginUserInfo",this.showObj)
this.$store.dispatch("setUserUpdate",this.showObj)
// location.reload()
// this.$router.push({
// path: this.redirect || '/home'
// })
// let obj = JSON.parse(JSON.stringify(this.datamodify))
// obj.SchoolName = this.showObj.SchoolName
// setTimeout(() => {
// this.MsgBus.$emit('add',obj);
// }, 10);
}
}).catch(() => {
})
},
passwordSubmit () {
this.$refs.OldPassWord.validate()
this.$refs.NewPassWord.validate()
this.$refs.NewSurePassWord.validate()
if (this.$refs.OldPassWord.hasError || this.$refs.NewPassWord.hasError|| this.$refs.NewSurePassWord.hasError) {
this.formHasError = true
}
else {
// 掉接口
updateUserPassword(this.passwordMsg).then(res => {
if (res.Code == 1) {
this.$q.notify({
type: 'iconfont icon-chenggong',
color: 'accent',
position: "top",
message: res.Message
})
// this.passwordMsg = Object.assign({},defaultpassword)
this.$q.dialog({
title: '功能提示',
message: '密码修改需重新登录',
persistent: true
}).onOk(() => {
this.$store
.dispatch('LogOut')
.then(() => {
this.$router.push('/login')
})
.catch((e) => {
})
});
}
}).catch(() => {
})
}
},
},
}
}).catch(() => {
})
}
},
},
}
</script>
<style lang="sass">
@import url('~assets/css/table.sass')
</style>
\ No newline at end of file
@import url('~assets/css/table.sass')
</style>
......@@ -11,12 +11,12 @@ export default {
Vue.prototype.MsgBus = MsgBus;
//消息成功提示
Vue.prototype.Success = function (msg) {
this.$message({
message: msg,
duration: 2000,
type: "success"
});
},
this.$message({
message: msg,
duration: 2000,
type: "success"
});
},
//错误提示
Vue.prototype.Error = function (msg) {
this.$message({
......@@ -45,10 +45,10 @@ export default {
//Confirm
Vue.prototype.Confirm = function (msg, callback) {
this.$confirm(msg, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
if (typeof callback === 'function') {
callback();
......@@ -71,21 +71,21 @@ export default {
Vue.prototype.md5 = md5;
//ERP本地缓存
Vue.prototype.getLocalStorage = function () {
var localStorageData = window.localStorage["loginUserInfo"];
if (localStorageData !== undefined && localStorageData != 'undefined') {
return JSON.parse(localStorageData).data;
} else {
return null;
}
},
var localStorageData = window.localStorage["loginUserInfo"];
if (localStorageData !== undefined && localStorageData != 'undefined') {
return JSON.parse(localStorageData).data;
} else {
return null;
}
},
//域名管理对象
Vue.prototype.domainManager = function () {
//let domainUrl = 'http://192.168.10.214';
let domainUrl = 'http://192.168.5.34';
let viewFileUrl = 'http://192.168.5.214:8120';
let mallUrl = "http://192.168.5.2:8088";
let vtUploadUrl = "http://upload.oytour.com";
let vtViewUrl = "http://192.168.5.214:8130";
let locationName = window.location.hostname;
......@@ -160,7 +160,7 @@ export default {
document.body.appendChild(link);
link.click();
successCall(res);
}).catch(function (res) { });
}).catch(function (res) {});
},
//HTTP提交数据
......@@ -201,11 +201,11 @@ export default {
"uName": uName //用户名称
}
this.$http.post(apiurl, postData, {
headers: {
'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path
}
})
headers: {
'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path
}
})
.then(res => {
if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {
this.$router.push({
......@@ -266,13 +266,13 @@ export default {
var apiurl = this.domainManager().mallUrl + cmd;
var postData = this.GetPostDataDS(cmd, msg, "");
this.$http.post(apiurl, postData, {
headers: {
'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path
}
})
headers: {
'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path
}
})
.then(res => {
if (res.data.resultCode == 10000 || res.data.resultCode == 10001) { } else if (res.resultCode == 10005) {
if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {} else if (res.resultCode == 10005) {
this.$router.go(-1);
} else {
successCall(res);
......@@ -281,23 +281,23 @@ export default {
}
//电商文件下载
Vue.prototype.GetLocalFileDS = function (cmd, msg, fileName, newCmd, successCall) {
var apiurl = this.domainManager().mallUrl + cmd;
var postData = this.GetPostDataDS(cmd, msg, newCmd);
this.$http.post(apiurl, postData, {
responseType: 'arraybuffer'
}).then((res) => {
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel"
})
let url = URL.createObjectURL(blob);
let link = document.createElement('a');
link.href = url;
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
successCall(res);
}).catch(function (res) { });
},
var apiurl = this.domainManager().mallUrl + cmd;
var postData = this.GetPostDataDS(cmd, msg, newCmd);
this.$http.post(apiurl, postData, {
responseType: 'arraybuffer'
}).then((res) => {
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel"
})
let url = URL.createObjectURL(blob);
let link = document.createElement('a');
link.href = url;
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
successCall(res);
}).catch(function (res) {});
},
//价钱格式化,三位数逗号分隔,保留两位小数 duanjun
Vue.prototype.moneyFormat = function (value) {
let nStr = Number(value).toFixed(2)
......@@ -433,63 +433,71 @@ export default {
},
//上传文件到云存储
Vue.prototype.UploadFileToTencent = function (path, fileObj, callback) {
var upInfo = JSON.parse(localStorage.uploadInfo);
let maxSize = 500 * 1024
if ((fileObj.type == "image/png" || fileObj.type == "image/jpeg") && fileObj.size > maxSize) {
let that = this
lrz(fileObj, {
width: 750,
quality: 0.8
})
.then(function (rst) {
//成功时执行
var arr = rst.base64.split(',');
var mime = arr[0].match(/:(.*?);/)[1];
var bstr = atob(arr[1]);
var n = bstr.length;
var u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
var newFile = new File([u8arr], fileObj.name, {
type: mime
});
let str = '';
str = "/2024/"
var newFileName = str + path;
let url = upInfo.UploadDomain + "/Upload/UploadToTecent?filePath=" + newFileName;
let formData = new FormData()
formData.append('myfile', newFile)
let xhr = new XMLHttpRequest()
xhr.onload = function () {
uploadLoadding.hide();
var jsonObj = JSON.parse(xhr.responseText);
if (jsonObj.StatusCode === 1 && callback) {
var uploadResult = {
resultCode: 1,
FileName: fileObj.name,
FileUrl: jsonObj.FilePath,
}
if (callback) {
callback(uploadResult);
}
var localCache = this.getLocalStorage();
if (localCache && localCache.UploadConfig) {
let maxSize = 500 * 1024
if ((fileObj.type == "image/png" || fileObj.type == "image/jpeg") && fileObj.size > maxSize) {
let that = this
lrz(fileObj, {
width: 750,
quality: 0.8
})
.then(function (rst) {
//成功时执行
var arr = rst.base64.split(',');
var mime = arr[0].match(/:(.*?);/)[1];
var bstr = atob(arr[1]);
var n = bstr.length;
var u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
}
xhr.open('post', url, true)
xhr.send(formData)
}).catch(function (error) {
}).always(function () {
//不管成功或失败,都会执行
})
} else {
var newFile = new File([u8arr], fileObj.name, {
type: mime
});
this.RealFileToTencent(path,newFile,callback)
}).catch(function (error) {
}).always(function () {
//不管成功或失败,都会执行
})
} else {
this.RealFileToTencent(path,fileObj,callback)
}
}
},
//公用判断图片地址 判断是否包含http
Vue.prototype.getIconLink = function (url) {
//真实上传文件方法
Vue.prototype.RealFileToTencent = function (path, fileObj, callback) {
let str = '';
str = "/2024/"
var newFileName = str + path;
var upInfo = this.getLocalStorage().UploadConfig;
var u_url = upInfo.UploadDomain;
//u_url = "http://192.168.5.46:8120"
let url = u_url + "/Upload/UploadToTecent?isDomain=1&filePath=" + newFileName;
let formData = new FormData()
formData.append('myfile', fileObj)
let xhr = new XMLHttpRequest()
xhr.onload = function () {
var jsonObj = JSON.parse(xhr.responseText);
if (jsonObj.StatusCode === 1 && callback) {
var uploadResult = {
Code:1,
FileName: fileObj.name,
FileUrl: jsonObj.FilePath,
}
if (callback) {
callback(uploadResult);
}
}
}
xhr.open('post', url, true)
xhr.send(formData)
}
//公用判断图片地址 判断是否包含http
Vue.prototype.getIconLink = function (url) {
let str = ''
if (url && url != '') {
if (url.indexOf('http') != -1) {
......@@ -504,7 +512,7 @@ export default {
Vue.prototype.isOnline = function () {
return process.env.NODE_ENV !== 'development';
},
Vue.prototype.getAnyFileBlob = function (url) {
let getBlob = new Promise(resolve => {
const xhr = new XMLHttpRequest();
......@@ -519,13 +527,13 @@ export default {
});
return getBlob
},
Vue.prototype.accAdd = function (arg1, arg2) {//加法精密计算
Vue.prototype.accAdd = function (arg1, arg2) { //加法精密计算
var r1;
var r2;
var m;
var c;
try {
r1 = arg1.toString().split('.')[1].length;
r1 = arg1.toString().split('.')[1].length;
} catch (e) {
r1 = 0;
}
......@@ -538,13 +546,13 @@ export default {
m = Math.pow(10, Math.max(r1, r2));
if (c > 0) {
var cm = Math.pow(10, c);
if (r1 > r2) {
arg1 = Number(arg1.toString().replace('.', ''));
arg2 = Number(arg2.toString().replace('.', '')) * cm;
} else {
arg1 = Number(arg1.toString().replace('.', '')) * cm;
arg2 = Number(arg2.toString().replace('.', ''));
}
if (r1 > r2) {
arg1 = Number(arg1.toString().replace('.', ''));
arg2 = Number(arg2.toString().replace('.', '')) * cm;
} else {
arg1 = Number(arg1.toString().replace('.', '')) * cm;
arg2 = Number(arg2.toString().replace('.', ''));
}
} else {
arg1 = Number(arg1.toString().replace('.', ''));
arg2 = Number(arg2.toString().replace('.', ''));
......@@ -552,19 +560,17 @@ export default {
return (arg1 + arg2) / m;
},
// 减法
Vue.prototype.subtr = function(arg1, arg2) {
Vue.prototype.subtr = function (arg1, arg2) {
var r1, r2, m, n;
try {
r1 = arg1.toString().split(".")[1].length;
}
catch (e) {
r1 = 0;
r1 = arg1.toString().split(".")[1].length;
} catch (e) {
r1 = 0;
}
try {
r2 = arg2.toString().split(".")[1].length;
}
catch (e) {
r2 = 0;
r2 = arg2.toString().split(".")[1].length;
} catch (e) {
r2 = 0;
}
m = Math.pow(10, Math.max(r1, r2));
//last modify by deeka
......@@ -572,21 +578,33 @@ export default {
n = (r1 >= r2) ? r1 : r2;
return ((arg1 * m - arg2 * m) / m).toFixed(n);
}
// 乘法获取准确值
Vue.prototype.accMul = function(arg1,arg2){
var m=0,s1=arg1.toString(),s2=arg2.toString();
try{m+=s1.split(".")[1].length}catch(e){}
try{m+=s2.split(".")[1].length}catch(e){}
return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
}
// 除法获取精确值
Vue.prototype.accDiv = function(arg1, arg2) {
var t1 = 0, t2 = 0, r1, r2;
try { t1 = arg1.toString().split(".")[1].length } catch (e) { }
try { t2 = arg2.toString().split(".")[1].length } catch (e) { }
Math.r1 = Number(arg1.toString().replace(".", ""))
Math.r2 = Number(arg2.toString().replace(".", ""))
return (Math.r1 / Math.r2) * Math.pow(10, t2 - t1);
}
// 乘法获取准确值
Vue.prototype.accMul = function (arg1, arg2) {
var m = 0,
s1 = arg1.toString(),
s2 = arg2.toString();
try {
m += s1.split(".")[1].length
} catch (e) {}
try {
m += s2.split(".")[1].length
} catch (e) {}
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
}
// 除法获取精确值
Vue.prototype.accDiv = function (arg1, arg2) {
var t1 = 0,
t2 = 0,
r1, r2;
try {
t1 = arg1.toString().split(".")[1].length
} catch (e) {}
try {
t2 = arg2.toString().split(".")[1].length
} catch (e) {}
Math.r1 = Number(arg1.toString().replace(".", ""))
Math.r2 = Number(arg2.toString().replace(".", ""))
return (Math.r1 / Math.r2) * Math.pow(10, t2 - t1);
}
}
}
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