Commit dba1baaa authored by 廖旭伟's avatar 廖旭伟

Merge remote-tracking branch 'origin/master'

parents 8784135f 364c2fbd
...@@ -8,15 +8,13 @@ export default { ...@@ -8,15 +8,13 @@ export default {
methods: { methods: {
// 渲染前置处理 // 渲染前置处理
beforeRender(data) { beforeRender(data) {
return data return data;
}, },
// 渲染后置处理 // 渲染后置处理
afterRender(data) { afterRender(data) {},
},
// 提交表单的前置处理 // 提交表单的前置处理
beforeSubmit(data) { beforeSubmit(data) {
return data return data;
}, },
// 提交表单的后置处理, 会阻断默认的回退行为 // 提交表单的后置处理, 会阻断默认的回退行为
afterSubmit(data) { afterSubmit(data) {
...@@ -38,16 +36,18 @@ export default { ...@@ -38,16 +36,18 @@ export default {
this.dict = Object.assign({}, this.dict, res.dict); this.dict = Object.assign({}, this.dict, res.dict);
this.afterRender(res); this.afterRender(res);
}) })
.catch(error => { .catch((error) => {
console.error(error)
this.$message.error(error.message); this.$message.error(error.message);
error.message.indexOf("过期") > -1
? (window.location = "/#/login")
: "";
}) })
.then(data => { .then((data) => {
clearTimeout(this.loadingTimer); clearTimeout(this.loadingTimer);
this.loadingTimer = setTimeout(() => { this.loadingTimer = setTimeout(() => {
this.loading = false; this.loading = false;
}, 300); }, 300);
}) });
}, },
// 提交表单 // 提交表单
submitForm(ref) { submitForm(ref) {
...@@ -55,72 +55,81 @@ export default { ...@@ -55,72 +55,81 @@ export default {
el.validate((valid) => { el.validate((valid) => {
if (!valid) return; if (!valid) return;
this.loading = true; this.loading = true;
this.$post(this.urls.saveUrl || this.pageInfo.saveUrl, this.$post(
this.beforeSubmit(this.form) this.urls.saveUrl || this.pageInfo.saveUrl,
this.beforeSubmit(this.form)
) )
.then(res => { .then((res) => {
this.$message.success(res.msg); this.$message.success(res.msg);
this.afterSubmit(res); this.afterSubmit(res);
}) })
.catch(error => { .catch((error) => {
this.$message.error(error.message); this.$message.error(error.message);
}) })
.then(data => { .then((data) => {
clearTimeout(this.loadingTimer); clearTimeout(this.loadingTimer);
this.loadingTimer = setTimeout(() => { this.loadingTimer = setTimeout(() => {
this.loading = false; this.loading = false;
}, 200); }, 200);
}) });
}); });
}, },
// 复制一个数组或对象 // 复制一个数组或对象
util_copy(data) { util_copy(data) {
return JSON.parse(JSON.stringify(data)) return JSON.parse(JSON.stringify(data));
}, },
// 工具方法,把数字转化为字符串 // 工具方法,把数字转化为字符串
util_toString(data, array) { util_toString(data, array) {
//原始数据 //原始数据
const dataCopy = Object.assign({}, data); const dataCopy = Object.assign({}, data);
array.forEach(item => { array.forEach((item) => {
//如果相等做操作 //如果相等做操作
dataCopy[item] = dataCopy[item] === undefined ? '' : dataCopy[item] + ''; dataCopy[item] =
}) dataCopy[item] === undefined ? "" : dataCopy[item] + "";
});
return dataCopy; return dataCopy;
}, },
// 工具方法,把字符串转化为数组 // 工具方法,把字符串转化为数组
util_toArrays(data, array) { util_toArrays(data, array) {
const dataCopy = Object.assign({}, data); const dataCopy = Object.assign({}, data);
array.forEach(item => { array.forEach((item) => {
dataCopy[item] = dataCopy[item] === undefined ? [] : dataCopy[item].split(","); dataCopy[item] =
}) dataCopy[item] === undefined ? [] : dataCopy[item].split(",");
});
return dataCopy; return dataCopy;
}, },
// 工具方法,把字符串转化为格式化日期 // 工具方法,把字符串转化为格式化日期
util_toDateStr(data, array) { util_toDateStr(data, array) {
const dataCopy = Object.assign({}, data); const dataCopy = Object.assign({}, data);
array.forEach(item => { array.forEach((item) => {
dataCopy[item] = dataCopy[item] === undefined ? '' : this.util_formatterDate(dataCopy[item]); dataCopy[item] =
}) dataCopy[item] === undefined
? ""
: this.util_formatterDate(dataCopy[item]);
});
return dataCopy; return dataCopy;
}, },
util_formatterDate(time) { util_formatterDate(time) {
let date = new Date(Number(time)); let date = new Date(Number(time));
let Y = date.getFullYear() + '-'; let Y = date.getFullYear() + "-";
let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; let M =
let D = this.panLeft(date.getDate()) + ' '; (date.getMonth() + 1 < 10
let h = this.panLeft(date.getHours()) + ':'; ? "0" + (date.getMonth() + 1)
let m = this.panLeft(date.getMinutes()) + ':'; : date.getMonth() + 1) + "-";
let D = this.panLeft(date.getDate()) + " ";
let h = this.panLeft(date.getHours()) + ":";
let m = this.panLeft(date.getMinutes()) + ":";
let s = this.panLeft(date.getSeconds()); let s = this.panLeft(date.getSeconds());
return Y+M+D+h+m+s; return Y + M + D + h + m + s;
}, },
panLeft(num){ panLeft(num) {
return num < 10 ? '0'+num : num; return num < 10 ? "0" + num : num;
}, },
// 从dict字段暴力取值,取不到则返回原值 // 从dict字段暴力取值,取不到则返回原值
util_formatter(key, val) { util_formatter(key, val) {
try { try {
return this.dict[key][val] return this.dict[key][val];
} catch (error) { } catch (error) {
return val; return val;
} }
...@@ -133,24 +142,24 @@ export default { ...@@ -133,24 +142,24 @@ export default {
} }
}); });
}, 0); }, 0);
} },
}, },
computed: { computed: {
pageInfo() { pageInfo() {
let currUrl = this.$route.path; let currUrl = this.$route.path;
let urlArray = currUrl.split('/'); let urlArray = currUrl.split("/");
let type = urlArray.pop(); let type = urlArray.pop();
urlArray.push('save'); urlArray.push("save");
let saveUrl = urlArray.join('/'); let saveUrl = urlArray.join("/");
urlArray.pop(); urlArray.pop();
urlArray.push('edit'); urlArray.push("edit");
let editUrl = urlArray.join('/'); let editUrl = urlArray.join("/");
urlArray.pop(); urlArray.pop();
urlArray.push('add'); urlArray.push("add");
let addUrl = urlArray.join('/'); let addUrl = urlArray.join("/");
urlArray.pop(); urlArray.pop();
urlArray.push('view'); urlArray.push("view");
let viewUrl = urlArray.join('/'); let viewUrl = urlArray.join("/");
return { return {
type, type,
currUrl, currUrl,
...@@ -174,9 +183,6 @@ export default { ...@@ -174,9 +183,6 @@ export default {
toString: [], // 需要把number转化为string的表单字段name数组 toString: [], // 需要把number转化为string的表单字段name数组
toArrays: [], // 需要把number转化为arrays的表单字段name数组 toArrays: [], // 需要把number转化为arrays的表单字段name数组
toDate: [], // 需要把number转化为date的表单字段name数组 toDate: [], // 需要把number转化为date的表单字段name数组
} };
} },
} };
...@@ -51,6 +51,9 @@ export default { ...@@ -51,6 +51,9 @@ export default {
}) })
.catch((error) => { .catch((error) => {
this.$message.error(error.message); this.$message.error(error.message);
error.message.indexOf("过期") > -1
? (window.location = "/#/login")
: "";
throw error; throw error;
}) })
.then((data) => { .then((data) => {
......
...@@ -25,6 +25,7 @@ export default { ...@@ -25,6 +25,7 @@ export default {
this.changePath("device"); this.changePath("device");
} }
this.query = Object.assign({}, this.query, route.query); this.query = Object.assign({}, this.query, route.query);
this.getData(); this.getData();
}, },
}, },
...@@ -63,6 +64,13 @@ export default { ...@@ -63,6 +64,13 @@ export default {
return; return;
} }
this.tableData.loading = true; this.tableData.loading = true;
if (this.$route.path == "/user/list") {
this.query.userType
? (this.query.userTypeList = [])
: "userType" in this.query
? (this.query.userTypeList = [])
: (this.query.userTypeList = ["0", "1"]);
}
this.$post(this.pageInfo.list, this.query, { this.$post(this.pageInfo.list, this.query, {
cancelToken: this.source.token, cancelToken: this.source.token,
}) })
...@@ -73,8 +81,12 @@ export default { ...@@ -73,8 +81,12 @@ export default {
this.afterRender(this.tableData); this.afterRender(this.tableData);
}) })
.catch((error) => { .catch((error) => {
console.log(error);
if (error.message == "自动取消ajax操作") return; if (error.message == "自动取消ajax操作") return;
this.$message.error(error.message); this.$message.error(error.message);
error.message.indexOf("过期") > -1
? (window.location = "/#/login")
: "";
}) })
.then((data) => { .then((data) => {
clearTimeout(this.loadingTimer); clearTimeout(this.loadingTimer);
......
import axios from 'axios'; import axios from "axios";
import Qs from 'qs'; import Qs from "qs";
const JSONbig = require('json-bigint')({"storeAsString": true}); const JSONbig = require("json-bigint")({ storeAsString: true });
import cookie from './cookie'; import cookie from "./cookie";
import httpErrorHandler from './httpErrorHandler'; import httpErrorHandler from "./httpErrorHandler";
const instance = axios.create({ const instance = axios.create({
baseURL: '/enterprise', baseURL: "/enterprise",
headers: { headers: {
post: { post: {
'Content-Type': 'application/json;charset=UTF-8', "Content-Type": "application/json;charset=UTF-8",
'dataType': 'json', dataType: "json",
} },
}, },
transformResponse: [data=>{ transformResponse: [
try { (data) => {
JSON.parse(data); try {
return JSONbig.parse(data); JSON.parse(data);
} catch (error) { return JSONbig.parse(data);
return data; } catch (error) {
} return data;
}], }
},
],
}); });
instance.interceptors.request.use(
(config) => {
//config.data = Qs.stringify(config.data, {arrayFormat: 'repeat', allowDots: true});
//config.data = Qs.stringify(config.data, {arrayFormat: 'indices', allowDots: true});
//brackets
// 也可以在这里给请求添加token之类的字段
// config.headers['Content-Type'] = 'application/json;charset=UTF-8'
// config.headers.timestamp = Math.floor(new Date().getTime() / 1000)
// console.log("sessionStorage",window.sessionStorage)
config.headers.Authorization = window.sessionStorage.getItem("token") || "";
//console.log("request config and session",config,window.sessionStorage);
instance.interceptors.request.use(config => { return config;
//config.data = Qs.stringify(config.data, {arrayFormat: 'repeat', allowDots: true}); },
//config.data = Qs.stringify(config.data, {arrayFormat: 'indices', allowDots: true}); (err) => {
//brackets return Promise.reject(err);
// 也可以在这里给请求添加token之类的字段 }
// config.headers['Content-Type'] = 'application/json;charset=UTF-8' );
// config.headers.timestamp = Math.floor(new Date().getTime() / 1000)
// console.log("sessionStorage",window.sessionStorage)
config.headers.Authorization = window.sessionStorage.getItem('token') || ''
//console.log("request config and session",config,window.sessionStorage);
return config;
}, err => {
return Promise.reject(err);
});
instance.interceptors.response.use(response=>{ instance.interceptors.response.use((response) => {
return response.data return response.data;
},httpErrorHandler); }, httpErrorHandler);
/** /**
* 封装后的axios post方法 * 封装后的axios post方法
...@@ -52,9 +57,9 @@ instance.interceptors.response.use(response=>{ ...@@ -52,9 +57,9 @@ instance.interceptors.response.use(response=>{
*/ */
export function post(url, option, config = {}) { export function post(url, option, config = {}) {
const data = Object.assign({}, option, { const data = Object.assign({}, option, {
// __mortals_token__: cookie.getItem('__mortals_token__'), // __mortals_token__: cookie.getItem('__mortals_token__'),
}) });
return instance.post(url, data, config) return instance.post(url, data, config, httpErrorHandler);
} }
/** /**
...@@ -68,24 +73,23 @@ export function post(url, option, config = {}) { ...@@ -68,24 +73,23 @@ export function post(url, option, config = {}) {
export function get(url, option, config = {}) { export function get(url, option, config = {}) {
const data = Object.assign({}, option, { const data = Object.assign({}, option, {
//__mortals_token__: cookie.getItem('__mortals_token__'), //__mortals_token__: cookie.getItem('__mortals_token__'),
}) });
return instance.get(url, { params: data }, config) return instance.get(url, { params: data }, config, httpErrorHandler);
} }
// 文件上传 // 文件上传
const uploadInstance = axios.create({ const uploadInstance = axios.create({
baseURL: '/m', baseURL: "/m",
headers: { headers: {
post: { post: {
'Content-Type': 'multipart/form-data', "Content-Type": "multipart/form-data",
} },
} },
}); });
uploadInstance.interceptors.response.use(response=>{ uploadInstance.interceptors.response.use((response) => {
return response.data return response.data;
},httpErrorHandler); }, httpErrorHandler);
/** /**
* 封装后的axios upload方法 * 封装后的axios upload方法
...@@ -97,8 +101,8 @@ uploadInstance.interceptors.response.use(response=>{ ...@@ -97,8 +101,8 @@ uploadInstance.interceptors.response.use(response=>{
*/ */
export function upload(url, option, config = {}) { export function upload(url, option, config = {}) {
let formdata = new FormData(); let formdata = new FormData();
Object.keys(option).forEach(key=>{ Object.keys(option).forEach((key) => {
formdata.append(key, option[key]) formdata.append(key, option[key]);
}) });
return uploadInstance.post(url, formdata, config) return uploadInstance.post(url, formdata, config);
} }
exports.install = function (Vue) { exports.install = function(Vue) {
// 把需要暴露出去的方法挂载到Vue原型上,避免了全局变量过多的问题 // 把需要暴露出去的方法挂载到Vue原型上,避免了全局变量过多的问题
Vue.prototype.refreshData = function () { Vue.prototype.refreshData = function() {
console.log("刷新设备列表");
console.log("刷新设备列表") const component = findComponentDownward(this, "Device");
const component = findComponentDownward(this, 'Device') console.log("component", component);
console.log("component",component) if (component) {
if(component){ component.getData();
component.getData()
}
} }
} };
};
/**
* 由一个组件,向下找到最近的指定组件 /**
* @param {*} context 当前上下文,比如你要基于哪个组件来向上寻找,一般都是基于当前的组件,也就是传入 this * 由一个组件,向下找到最近的指定组件
* @param {*} componentName 要找的组件的 name * @param {*} context 当前上下文,比如你要基于哪个组件来向上寻找,一般都是基于当前的组件,也就是传入 this
*/ * @param {*} componentName 要找的组件的 name
function findComponentDownward(context, componentName) { */
const childrens = context.$children function findComponentDownward(context, componentName) {
let children = null const childrens = context.$children;
let children = null;
if (childrens.length) {
for (const child of childrens) { if (childrens.length) {
const name = child.$options.name for (const child of childrens) {
const name = child.$options.name;
if (name === componentName) {
children = child if (name === componentName) {
break children = child;
} else { break;
children = findComponentDownward(child, componentName) } else {
if (children) break children = findComponentDownward(child, componentName);
} if (children) break;
} }
} }
return children
} }
return children;
\ No newline at end of file }
export default (error) => { export default (error) => {
if(error.message === '自动取消ajax操作') return Promise.reject(error); if (error.message === "自动取消ajax操作") return Promise.reject(error);
if (!error.response) { if (!error.response) {
console.error(error); console.error(error);
return Promise.reject({
message: '未知错误',
error,
});
};
let tip = '';
const status = error.response.status;
switch (status) {
case 400:
tip = '错误的请求参数';
break;
case 401:
tip = '没有该操作权限';
break;
case 403:
tip = '用户未登录或登录失效,请重新登录';
break;
case 404:
tip = '错误的请求地址';
break;
case 405:
tip = '请修改当前密码(原因:首次登录或超过期限未修改密码)';
break;
case 500:
case 501:
case 502:
case 503:
case 504:
tip = '服务器错误';
break;
default:
tip = '未知错误' + status;
}
if(status === 405){
window.location='/#/login/updatePwd';
}else{
tip +=',将自动返回主页';
window.location='/#/';
}
return Promise.reject({ return Promise.reject({
message: tip, message: "未知错误",
error, error,
status,
}); });
} }
\ No newline at end of file
let tip = "";
const status = error.response.status;
switch (status) {
case 400:
tip = "错误的请求参数";
break;
case 401:
tip = "没有该操作权限";
break;
case 403:
tip = "用户未登录或登录失效,请重新登录";
break;
case 404:
tip = "错误的请求地址";
break;
case 405:
tip = "请修改当前密码(原因:首次登录或超过期限未修改密码)";
break;
case 500:
case 501:
case 502:
case 503:
case 504:
tip = "服务器错误";
break;
default:
tip = "未知错误" + status;
}
if (status === 405) {
window.location = "/#/login/updatePwd";
} else {
tip += ",将自动返回主页";
window.location = "/#/";
}
return Promise.reject({
message: tip,
error,
status,
});
};
import axios from 'axios'; import axios from "axios";
import Qs from 'qs'; import Qs from "qs";
import cookie from './cookie'; import cookie from "./cookie";
import httpErrorHandler from './httpErrorHandler'; import httpErrorHandler from "./httpErrorHandler";
const isDev = process.env.NODE_ENV === 'development'; const isDev = process.env.NODE_ENV === "development";
const queue = []; const queue = [];
const cancelToken = axios.CancelToken; const cancelToken = axios.CancelToken;
const token = (config) =>{ const token = (config) => {
return `${config.url}_${config.method}` return `${config.url}_${config.method}`;
} };
const instance = axios.create({ const instance = axios.create({
baseURL: '/m', baseURL: "/m",
headers: { headers: {
token: cookie.getItem('fe_t'), token: cookie.getItem("fe_t"),
post: { post: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
'dataType': 'json', dataType: "json",
} },
} },
}); });
const removeQueue = (config) => { const removeQueue = (config) => {
for(let i=0, size = queue.length; i < size; i++){ for (let i = 0, size = queue.length; i < size; i++) {
const task = queue[i]; const task = queue[i];
if(task.token === token(config)) { if (task.token === token(config)) {
task.cancel(); task.cancel();
queue.splice(i, 1); queue.splice(i, 1);
} }
} }
} };
//添加请求拦截器 //添加请求拦截器
instance.interceptors.request.use(config=>{ instance.interceptors.request.use(
removeQueue(config); //在一个ajax发送前执行一下取消操作 (config) => {
config.cancelToken = new cancelToken((c)=>{ removeQueue(config); //在一个ajax发送前执行一下取消操作
queue.push({ token: token(config), cancel: c }); config.cancelToken = new cancelToken((c) => {
}); queue.push({ token: token(config), cancel: c });
return config; });
}, error => { return config;
return Promise.reject(error); },
}); (error) => {
return Promise.reject(error);
}
);
//添加响应拦截器 //添加响应拦截器
instance.interceptors.response.use(response=>{ instance.interceptors.response.use((response) => {
removeQueue(response.config); removeQueue(response.config);
return response.data return response.data;
}, httpErrorHandler); }, httpErrorHandler);
/** /**
...@@ -56,5 +59,5 @@ instance.interceptors.response.use(response=>{ ...@@ -56,5 +59,5 @@ instance.interceptors.response.use(response=>{
* @returns * @returns
*/ */
export default (url, data, config = {}) => { export default (url, data, config = {}) => {
return instance.post(url, data, config) return instance.post(url, data, config);
} };
<template> <template>
<div style="width: 100%" class="upload-file"> <div style="width: 100%" class="upload-file">
<el-upload <el-upload
:action="uploadFileUrl + '?prePath=' + prePath" :action="uploadFileUrl + '?prePath=' + prePath"
:before-upload="handleBeforeUpload" :before-upload="handleBeforeUpload"
:file-list="fileList" :file-list="fileList"
:limit="limit" :limit="limit"
:on-error="handleUploadError" :on-error="handleUploadError"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:on-success="handleUploadSuccess" :on-success="handleUploadSuccess"
:show-file-list="false" :show-file-list="false"
:headers="headers" :headers="headers"
class="upload-file-uploader" class="upload-file-uploader"
ref="upload" ref="upload"
> >
<!-- 上传按钮 --> <!-- 上传按钮 -->
<el-button size="mini" type="primary">选取文件</el-button> <el-button size="mini" type="primary">选取文件</el-button>
...@@ -31,15 +31,15 @@ ...@@ -31,15 +31,15 @@
<!-- 文件列表 --> <!-- 文件列表 -->
<transition-group <transition-group
style="width: 100%" style="width: 100%"
class="upload-file-list el-upload-list el-upload-list--text" class="upload-file-list el-upload-list el-upload-list--text"
name="el-fade-in-linear" name="el-fade-in-linear"
tag="ul" tag="ul"
> >
<li <li
:key="file.uid" :key="file.uid"
class="el-upload-list__item ele-upload-list__item-content" class="el-upload-list__item ele-upload-list__item-content"
v-for="(file, index) in fileList" v-for="(file, index) in fileList"
> >
<el-link :href="file.url" :underline="false" target="_blank"> <el-link :href="file.url" :underline="false" target="_blank">
<span class="el-icon-document" style="font-size: 12px"> <span class="el-icon-document" style="font-size: 12px">
...@@ -48,13 +48,12 @@ ...@@ -48,13 +48,12 @@
</el-link> </el-link>
<div class="ele-upload-list__item-content-action"> <div class="ele-upload-list__item-content-action">
<el-link <el-link
:underline="false" :underline="false"
style="font-size: 12px" style="font-size: 12px"
@click="handleDelete(index)" @click="handleDelete(index)"
type="danger" type="danger"
>删除 >删除
</el-link </el-link>
>
</div> </div>
</li> </li>
</transition-group> </transition-group>
...@@ -62,7 +61,6 @@ ...@@ -62,7 +61,6 @@
</template> </template>
<script> <script>
export default { export default {
props: { props: {
// 值 // 值
...@@ -86,18 +84,18 @@ export default { ...@@ -86,18 +84,18 @@ export default {
// 是否显示提示 // 是否显示提示
isShowTip: { isShowTip: {
type: Boolean, type: Boolean,
default: true default: true,
}, },
//保存服务器路径前缀地址 //保存服务器路径前缀地址
prePath: { prePath: {
type: String, type: String,
default: '', default: "",
}, },
//默认文件名称 //默认文件名称
fileName: { fileName: {
type: String, type: String,
default: '', default: "",
} },
}, },
data() { data() {
return { return {
...@@ -112,14 +110,14 @@ export default { ...@@ -112,14 +110,14 @@ export default {
watch: { watch: {
value: { value: {
handler(val) { handler(val) {
if (val&&val!=='') { if (val && val !== "") {
this.showFileList(); this.showFileList();
} else { } else {
this.fileList = []; this.fileList = [];
return []; return [];
} }
} },
} },
}, },
computed: { computed: {
...@@ -129,16 +127,15 @@ export default { ...@@ -129,16 +127,15 @@ export default {
}, },
}, },
methods: { methods: {
showFileList() {
showFileList(){
let temp = 1; let temp = 1;
// 首先将值转为数组 // 首先将值转为数组
const filePathlist = this.value.split(','); const filePathlist = this.value.split(",");
// 然后将数组转为对象数组 // 然后将数组转为对象数组
const fileNamelist =this.fileName.split(','); const fileNamelist = this.fileName.split(",");
for (var i = 0; i < filePathlist.length; i++) { for (var i = 0; i < filePathlist.length; i++) {
if(filePathlist[i]==='') continue if (filePathlist[i] === "") continue;
let item = {} let item = {};
if (fileNamelist.length === filePathlist.length) { if (fileNamelist.length === filePathlist.length) {
item.name = fileNamelist[i]; item.name = fileNamelist[i];
} else { } else {
...@@ -146,11 +143,10 @@ export default { ...@@ -146,11 +143,10 @@ export default {
} }
item.url = filePathlist[i]; item.url = filePathlist[i];
item.uid = new Date().getTime() + temp++; item.uid = new Date().getTime() + temp++;
this.fileList.push(item) this.fileList.push(item);
} }
}, },
// 上传前校检格式和大小 // 上传前校检格式和大小
handleBeforeUpload(file) { handleBeforeUpload(file) {
// 校检文件类型 // 校检文件类型
...@@ -165,7 +161,9 @@ export default { ...@@ -165,7 +161,9 @@ export default {
return false; return false;
}); });
if (!isTypeOk) { if (!isTypeOk) {
this.$message.error(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`); this.$message.error(
`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`
);
return false; return false;
} }
} }
...@@ -190,13 +188,17 @@ export default { ...@@ -190,13 +188,17 @@ export default {
// 上传成功回调 // 上传成功回调
handleUploadSuccess(res, file) { handleUploadSuccess(res, file) {
if (res.code === 1) { if (res.code === 1) {
this.fileList.push({name: res.fileName, url: res.url, uid: new Date().getTime()}); this.fileList.push({
name: res.fileName,
url: res.url,
uid: new Date().getTime(),
});
let newFileList = this.fileList.map(i => i.url); let newFileList = this.fileList.map((i) => i.url);
let newFileNameList = this.fileList.map(i => i.name); let newFileNameList = this.fileList.map((i) => i.name);
this.$emit("input", newFileList.join(",")); this.$emit("input", newFileList.join(","));
this.$emit("getFileName", newFileNameList.join(",")); this.$emit("getFileName", newFileNameList.join(","));
this.fileList =[] this.fileList = [];
this.$message.success("上传成功"); this.$message.success("上传成功");
} else { } else {
this.$message.error(res.msg); this.$message.error(res.msg);
...@@ -206,12 +208,12 @@ export default { ...@@ -206,12 +208,12 @@ export default {
handleDelete(index) { handleDelete(index) {
//todo 删除文件 //todo 删除文件
this.fileList.splice(index, 1); this.fileList.splice(index, 1);
let newFileList = this.fileList.map(i => i.url); let newFileList = this.fileList.map((i) => i.url);
let newFileNameList = this.fileList.map(i => i.name); let newFileNameList = this.fileList.map((i) => i.name);
this.$emit("input", newFileList.join(",")); this.$emit("input", newFileList.join(","));
this.$emit("getFileName", newFileNameList.join(",")); this.$emit("getFileName", newFileNameList.join(","));
this.fileList =[] this.fileList = [];
// this.$emit("input", ''); // this.$emit("input", '');
}, },
// 获取文件名称 // 获取文件名称
getFileName(name) { getFileName(name) {
...@@ -220,11 +222,14 @@ export default { ...@@ -220,11 +222,14 @@ export default {
} else { } else {
return name; return name;
} }
} },
}, },
created() { created() {
console.log("file create") this.$nextTick(() => {
this.showFileList(); console.log(this.list);
this.showFileList();
});
// this.fileList = this.list; // this.fileList = this.list;
}, },
}; };
......
...@@ -202,7 +202,6 @@ export default { ...@@ -202,7 +202,6 @@ export default {
emit() { emit() {
this.$emit("input", this.newVal); this.$emit("input", this.newVal);
this.$emit("change", this.newVal); this.$emit("change", this.newVal);
console.log(this.newVal);
}, },
}, },
computed: { computed: {
......
<template>
<div>
<el-image
v-for="val in realSrcList"
:key="val"
:src="`${val}`"
fit="cover"
:style="`width:${realWidth};height:${realHeight};margin-right:10px;margin-bottom:10px`"
:preview-src-list="realSrcList"
>
<div slot="error" class="image-slot">
<i class="el-icon-picture-outline"></i>
</div>
</el-image>
</div>
</template>
<script>
export default {
name: "ImagePreview",
props: {
src: {
type: String,
required: true,
},
width: {
type: [Number, String],
default: "",
},
height: {
type: [Number, String],
default: "",
},
},
computed: {
realSrc() {
let real_src = this.src.split(",");
return real_src;
},
realSrcList() {
let real_src_list = this.src.split(",");
let srcList = [];
real_src_list.forEach((item) => {
return srcList.push(item);
});
return srcList;
},
realWidth() {
return typeof this.width == "string" ? this.width : `${this.width}px`;
},
realHeight() {
return typeof this.height == "string" ? this.height : `${this.height}px`;
},
},
};
</script>
<style lang="scss" scoped>
.el-image {
border-radius: 5px;
background-color: #ebeef5;
box-shadow: 0 0 5px 1px #ccc;
::v-deep .el-image__inner {
transition: all 0.3s;
cursor: pointer;
&:hover {
transform: scale(1.2);
}
}
::v-deep .image-slot {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
color: #909399;
font-size: 30px;
}
}
</style>
...@@ -256,6 +256,7 @@ export default { ...@@ -256,6 +256,7 @@ export default {
} }
}); });
this.form = Object.assign({}, this.form, newFormData); this.form = Object.assign({}, this.form, newFormData);
//this.form = Object.assign({}, this.form, data); //this.form = Object.assign({}, this.form, data);
}, },
cleanForm() { cleanForm() {
...@@ -277,6 +278,11 @@ export default { ...@@ -277,6 +278,11 @@ export default {
onSubmit() { onSubmit() {
let { path, query } = this.$route; let { path, query } = this.$route;
let data = this.decode(this.form); let data = this.decode(this.form);
for (let val in data) {
if (val == "userType") {
query.userTypeList = [];
}
}
this.$router.push({ this.$router.push({
path: path, path: path,
query: Object.assign({}, query, data), query: Object.assign({}, query, data),
......
...@@ -3,15 +3,22 @@ ...@@ -3,15 +3,22 @@
<template> <template>
<div class="my-upload"> <div class="my-upload">
<label> <label>
<el-button icon='el-icon-upload' size='mini' :loading='loading'>{{loading ? '上传中...' : tip}}</el-button> <el-button icon="el-icon-upload" size="mini" :loading="loading">{{
<input type="file" @change='chooseFile' :disabled="loading" ref="referenceUpload"> loading ? "上传中..." : tip
}}</el-button>
<input
type="file"
@change="chooseFile"
:disabled="loading"
ref="referenceUpload"
/>
</label> </label>
<div v-if='value' class='flex'> <div v-if="value" class="flex">
<div style="margin-right: 20px"> <div style="margin-right: 20px">
<div v-if='type === "thumb"' class='thumb' :style="imgCover"></div> <div v-if="type === 'thumb'" class="thumb" :style="imgCover"></div>
<div v-else>文件名: {{value}}</div> <div v-else>文件名: {{ value }}</div>
</div> </div>
<!-- <div> <!-- <div>
<el-button icon="el-icon-delete" size='mini' plain @click='del'>删除</el-button> <el-button icon="el-icon-delete" size='mini' plain @click='del'>删除</el-button>
</div>--> </div>-->
</div> </div>
...@@ -23,37 +30,39 @@ export default { ...@@ -23,37 +30,39 @@ export default {
props: { props: {
value: { value: {
type: String, type: String,
default: '', default: "",
}, },
type: { // 展示类型,文件名或缩略图 filename | thumb type: {
// 展示类型,文件名或缩略图 filename | thumb
type: String, type: String,
default: 'filename', default: "filename",
}, },
tip: { // 按钮文字 tip: {
// 按钮文字
type: String, type: String,
default: '上传文件', default: "上传文件",
}, },
prePath: { prePath: {
type: String, type: String,
default: '', default: "",
} },
}, },
methods: { methods: {
del() { del() {
this.$emit("input", "") this.$emit("input", "");
}, },
async chooseFile(e) { async chooseFile(e) {
this.loading = true; this.loading = true;
console.log(e); console.log(e);
try { try {
const {code, url} = await this.$upload('file/upload', { const { code, url } = await this.$upload("file/upload", {
uploadFile: e.target.files[0], uploadFile: e.target.files[0],
prePath: this.prePath prePath: this.prePath,
}); });
if(code === 1) { if (code === 1) {
this.$emit('input', url) this.$emit("input", url);
}else{ } else {
this.$message.error('上传文件失败'); this.$message.error("上传文件失败");
} }
} catch (error) { } catch (error) {
this.$message.error(error.message); this.$message.error(error.message);
...@@ -65,21 +74,21 @@ export default { ...@@ -65,21 +74,21 @@ export default {
computed: { computed: {
imgCover() { imgCover() {
return `background-image: url(${this.value})`; return `background-image: url(${this.value})`;
} },
}, },
data() { data() {
return { return {
loading: false, loading: false,
} };
} },
} };
</script> </script>
<style lang="less"> <style lang="less">
.my-upload{ .my-upload {
label{ label {
position: relative; position: relative;
input{ input {
display: block; display: block;
position: absolute; position: absolute;
width: 100%; width: 100%;
...@@ -89,7 +98,7 @@ export default { ...@@ -89,7 +98,7 @@ export default {
opacity: 0; opacity: 0;
} }
} }
.thumb{ .thumb {
width: 80px; width: 80px;
height: 80px; height: 80px;
background-size: contain; background-size: contain;
...@@ -99,7 +108,7 @@ export default { ...@@ -99,7 +108,7 @@ export default {
border-radius: 5px; border-radius: 5px;
overflow: hidden; overflow: hidden;
} }
p{ p {
color: #666; color: #666;
font-size: 14px; font-size: 14px;
} }
......
...@@ -61,7 +61,18 @@ export default { ...@@ -61,7 +61,18 @@ export default {
style="width: 70px; height: 70px" style="width: 70px; height: 70px"
src={row.photoPath} src={row.photoPath}
preview-src-list={[row.photoPath]} preview-src-list={[row.photoPath]}
></el-image> >
<div
slot="error"
class="image-slot"
style="width: 70px; height: 70px;display:flex;justify-content: center;align-items: center;"
>
<i
class="el-icon-picture-outline"
style="font-size:26px"
></i>
</div>
</el-image>
) : ( ) : (
"--" "--"
); );
......
...@@ -103,8 +103,6 @@ export default { ...@@ -103,8 +103,6 @@ export default {
}, },
beforeSubmit(data) { beforeSubmit(data) {
data.companyIds = data.companyIds.join(",");
return data; return data;
}, },
......
...@@ -101,7 +101,18 @@ export default { ...@@ -101,7 +101,18 @@ export default {
style="width: 70px; height: 70px" style="width: 70px; height: 70px"
src={row.photoPath} src={row.photoPath}
preview-src-list={[row.photoPath]} preview-src-list={[row.photoPath]}
></el-image> >
<div
slot="error"
class="image-slot"
style="width: 70px; height: 70px;display:flex;justify-content: center;align-items: center;"
>
<i
class="el-icon-picture-outline"
style="font-size:26px"
></i>
</div>
</el-image>
) : ( ) : (
"--" "--"
); );
......
...@@ -45,8 +45,32 @@ ...@@ -45,8 +45,32 @@
</div> </div>
<div class="jyitem"> <div class="jyitem">
<div class="leftlabel">附件</div> <div class="leftlabel">附件</div>
<!-- <Field label="附件名称,多个逗号分割" prop="fileName" v-model="form.fileName" placeholder="请输入附件名称,多个逗号分割"/> <image-preview-single
<Field label="附件地址,多个逗号分割"><fileUpload v-model="form.filePath" prePath="/file/fileupload"/></Field> --> v-if="form.filePath && form.filePath != ''"
:src="form.filePath"
:width="'100px'"
:height="'100px'"
/>
<div v-else>--</div>
<!-- <Field
label="附件名称,多个逗号分割"
prop="fileName"
v-model="form.fileName"
placeholder="请输入附件名称,多个逗号分割"
/> -->
<!-- <Field label="附件地址,多个逗号分割">
<fileUpload
v-model="form.filePath"
prePath=""
/>
</Field> -->
<!-- <el-upload
class="upload-demo"
:action="uploadFileUrl + '?prePath=' + '/file/fileupload'"
:file-list="fileList"
>
</el-upload> -->
</div> </div>
<div class="jyitem"> <div class="jyitem">
<div class="leftlabel">提交日期</div> <div class="leftlabel">提交日期</div>
...@@ -145,10 +169,11 @@ ...@@ -145,10 +169,11 @@
<script> <script>
import moment from "moment"; import moment from "moment";
import form from "@/assets/mixins/formdialog"; import form from "@/assets/mixins/formdialog";
import ImagePreviewSingle from "@/components/ImagePreviewSingle.vue";
export default { export default {
name: "FeedbackDetail", name: "FeedbackDetail",
mixins: [form], mixins: [form],
components: {}, components: { ImagePreviewSingle },
watch: { watch: {
form(newval) { form(newval) {
if (newval.createTime) { if (newval.createTime) {
...@@ -163,6 +188,8 @@ export default { ...@@ -163,6 +188,8 @@ export default {
}, },
data() { data() {
return { return {
fileList: [],
uploadFileUrl: "/enterprise/file/commonupload", // 上传的地址
createTime: "", createTime: "",
// 遮罩层 // 遮罩层
loading: true, loading: true,
...@@ -215,7 +242,7 @@ export default { ...@@ -215,7 +242,7 @@ export default {
], ],
replyContent: [ replyContent: [
{ required: true, message: "请输入回复", trigger: "blur" }, { required: true, message: "请输入回复", trigger: "blur" },
{ max: 64, message: "最多只能录入64个字符", trigger: "blur" }, { max: 200, message: "最多只能录入200个字符", trigger: "blur" },
], ],
feedbackType: [ feedbackType: [
{ required: true, message: "请输入反馈类型 ", trigger: "blur" }, { required: true, message: "请输入反馈类型 ", trigger: "blur" },
...@@ -274,7 +301,18 @@ export default { ...@@ -274,7 +301,18 @@ export default {
}, },
/**获取数据前弹框 */ /**获取数据前弹框 */
beforeRender(data) { beforeRender(data) {
data.entity.deptId = String(data.entity.deptId); data.entity.deptId && data.entity.deptId != ""
? (data.entity.deptId = String(data.entity.deptId))
: "";
let arr = data.entity.filePath.split(",");
this.fileList = arr.map((v, i) => {
let obj = {
name: "附件" + (i + 1),
url: v,
};
return obj;
});
console.log(this.fileList);
return data; return data;
}, },
/**获取数据后弹框 */ /**获取数据后弹框 */
...@@ -376,7 +414,7 @@ export default { ...@@ -376,7 +414,7 @@ export default {
padding: 20px; padding: 20px;
} }
} }
/deep/.el-form-item__error{ /deep/.el-form-item__error {
font-size: 14px; font-size: 14px;
} }
</style> </style>
\ No newline at end of file
...@@ -132,7 +132,7 @@ export default { ...@@ -132,7 +132,7 @@ export default {
label: "真实姓名", label: "真实姓名",
prop: "feedbackName", prop: "feedbackName",
formatter: this.formatter, formatter: this.formatter,
width: 120, width: 100,
}, },
{ {
label: "联系电话", label: "联系电话",
......
...@@ -47,7 +47,7 @@ export default { ...@@ -47,7 +47,7 @@ export default {
{ label: "标签名称", prop: "labelName" }, { label: "标签名称", prop: "labelName" },
// { label: "标签描述", prop: "labelDesc", formatter: this.formatters }, // { label: "标签描述", prop: "labelDesc", formatter: this.formatters },
{ {
label: "标签图标", label: "标签图标",
...@@ -58,7 +58,18 @@ export default { ...@@ -58,7 +58,18 @@ export default {
style="width: 70px; height: 70px" style="width: 70px; height: 70px"
src={row.labelLogoPath} src={row.labelLogoPath}
preview-src-list={[row.labelLogoPath]} preview-src-list={[row.labelLogoPath]}
></el-image> >
<div
slot="error"
class="image-slot"
style="width: 70px; height: 70px;display:flex;justify-content: center;align-items: center;"
>
<i
class="el-icon-picture-outline"
style="font-size:26px"
></i>
</div>
</el-image>
) : ( ) : (
"--" "--"
); );
......
...@@ -31,6 +31,19 @@ export default { ...@@ -31,6 +31,19 @@ export default {
toView(row) { toView(row) {
this.$refs.drawerform.view(row); this.$refs.drawerform.view(row);
}, },
// 复职操作
handleReback(row) {
this.$post("/staff/leave/save", { id: row.id, staffStatus: 1 })
.then((res) => {
if (res.code == 1) {
this.$message.success("复职成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
}, },
data() { data() {
return { return {
...@@ -53,7 +66,7 @@ export default { ...@@ -53,7 +66,7 @@ export default {
{ type: "selection", width: 60 }, { type: "selection", width: 60 },
{ type: "index", label: "序号", width: 50 }, { type: "index", label: "序号", width: 50 },
{ label: "员工姓名", prop: "name" }, { label: "员工姓名", prop: "name", width: 120 },
{ {
label: "照片", label: "照片",
...@@ -64,33 +77,79 @@ export default { ...@@ -64,33 +77,79 @@ export default {
style="width: 70px; height: 70px" style="width: 70px; height: 70px"
src={row.photoPath} src={row.photoPath}
preview-src-list={[row.photoPath]} preview-src-list={[row.photoPath]}
></el-image> >
<div
slot="error"
class="image-slot"
style="width: 70px; height: 70px;display:flex;justify-content: center;align-items: center;"
>
<i
class="el-icon-picture-outline"
style="font-size:26px"
></i>
</div>
</el-image>
) : ( ) : (
"--" "--"
); );
}, },
width: 110, width: 100,
}, },
{ label: "邮件地址", prop: "email" }, { label: "邮件地址", prop: "email", width: 160 },
{ label: "联系电话", prop: "phoneNumber" }, { label: "联系电话", prop: "phoneNumber", width: 120 },
{ label: "所属公司", prop: "companyIds", formatter: this.formatters }, {
label: "所属公司",
prop: "companyIds",
formatter: this.formatters,
},
{ label: "职位名称", prop: "positionName" }, { label: "职位名称", prop: "positionName", width: 120 },
{
label: "员工状态",
prop: "staffStatus",
formatter: this.formatter,
width: 80,
},
{ {
label: "离职时间", label: "离职时间",
prop: "leaveDate", prop: "leaveDate",
formatter: this.formatterDate, formatter: this.formatterDate,
width: 140,
}, },
{ {
label: "操作用户", label: "操作用户",
prop: "createUserId", prop: "createUserId",
formatter: this.formatter, formatter: this.formatter,
width: 120,
}, },
// {
// label: "操作",
// width: 100,
// formatter: (row) => {
// return row.staffStatus == 3 ? (
// <div>
// <el-button
// type="text"
// icon="el-icon-refresh-left"
// size="mini"
// onClick={() => {
// this.handleReback(row);
// }}
// title="复职"
// >
// 复职
// </el-button>
// </div>
// ) : (
// "--"
// );
// },
// },
], ],
}, },
}; };
......
...@@ -30,6 +30,19 @@ export default { ...@@ -30,6 +30,19 @@ export default {
toView(row) { toView(row) {
this.$refs.drawerform.view(row); this.$refs.drawerform.view(row);
}, },
// 复职操作
handleReback(row) {
this.$post("/staff/save", { id: row.id, staffStatus: 1 })
.then((res) => {
if (res.code == 1) {
this.$message.success("复职成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
// 离职操作 // 离职操作
toDimission(row) { toDimission(row) {
console.log(row); console.log(row);
...@@ -59,16 +72,17 @@ export default { ...@@ -59,16 +72,17 @@ export default {
}, },
// 重写getData // 重写getData
async getData() { async getData() {
this.query = Object.assign( this.query = Object.assign(this.query, this.$route.query);
{ staffStatus: 1 },
this.query,
this.$route.query
);
try { try {
await this.beforeFecth(); await this.beforeFecth();
} catch (error) { } catch (error) {
return; return;
} }
this.query.staffStatus
? ""
: "staffStatus" in this.query
? ""
: (this.query.staffStatus = 1);
this.tableData.loading = true; this.tableData.loading = true;
this.$post(this.pageInfo.list, this.query, { this.$post(this.pageInfo.list, this.query, {
cancelToken: this.source.token, cancelToken: this.source.token,
...@@ -95,6 +109,12 @@ export default { ...@@ -95,6 +109,12 @@ export default {
return { return {
config: { config: {
search: [ search: [
{
name: "staffStatus",
type: "select",
placeholder: "请选择员工状态",
label: "员工状态",
},
{ {
name: "companyId", name: "companyId",
type: "select", type: "select",
...@@ -123,14 +143,30 @@ export default { ...@@ -123,14 +143,30 @@ export default {
style="width: 70px; height: 70px" style="width: 70px; height: 70px"
src={row.photoPath} src={row.photoPath}
preview-src-list={[row.photoPath]} preview-src-list={[row.photoPath]}
></el-image> >
<div
slot="error"
class="image-slot"
style="width: 70px; height: 70px;display:flex;justify-content: center;align-items: center;"
>
<i
class="el-icon-picture-outline"
style="font-size:26px"
></i>
</div>
</el-image>
) : ( ) : (
"--" "--"
); );
}, },
width: 110, width: 110,
}, },
{
label: "员工状态",
prop: "staffStatus",
formatter: this.formatter,
width: 80,
},
{ label: "联系电话", prop: "phoneNumber", width: 110 }, { label: "联系电话", prop: "phoneNumber", width: 110 },
{ {
...@@ -168,7 +204,38 @@ export default { ...@@ -168,7 +204,38 @@ export default {
label: "操作", label: "操作",
width: 180, width: 180,
formatter: (row) => { formatter: (row) => {
return ( return row.staffStatus == 3 ? (
<div>
<table-buttons
noAdd
noView
row={row}
onEdit={this.toEdit}
onView={this.toView}
onDel={this.toDel}
/>
{/* <span
onClick={() => {
this.toDimission(row);
}}
style="color:#409EFF;margin-left:10px;cursor:pointer"
>
<i class="el-icon-document-delete"></i>
离职
</span> */}
<el-button
type="text"
icon="el-icon-refresh-left"
size="mini"
onClick={() => {
this.handleReback(row);
}}
title="复职"
>
复职
</el-button>
</div>
) : (
<div> <div>
<table-buttons <table-buttons
noAdd noAdd
......
<template> <template>
<div class="page"> <div class="page">
<LayoutTable :data="tableData" :config="tableConfig" /> <LayoutTable :data="tableData" :config="tableConfig" ref="layouttable" />
<dialog-show ref="dialogform" @ok="getData" /> <dialog-show ref="dialogform" @ok="getData" />
<el-dialog title="用户已分配的角色" :visible.sync="role.visible"> <el-dialog title="用户已分配的角色" :visible.sync="role.visible">
...@@ -49,6 +49,9 @@ import table from "@/assets/mixins/table"; ...@@ -49,6 +49,9 @@ import table from "@/assets/mixins/table";
export default { export default {
mixins: [table], mixins: [table],
components: { dialogShow }, components: { dialogShow },
mounted() {
console.log(this.$refs.layouttable.$refs.searchform);
},
methods: { methods: {
// 打开弹窗 // 打开弹窗
async findRole({ id }) { async findRole({ id }) {
...@@ -223,6 +226,9 @@ export default { ...@@ -223,6 +226,9 @@ export default {
name: "userType", name: "userType",
type: "select", type: "select",
label: "用户类型", label: "用户类型",
change: (val) => {
console.log(val);
},
}, },
{ {
name: "loginName", name: "loginName",
......
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