优化逻辑

dev
smallchill 6 years ago
parent ef020657eb
commit 02de800cce
  1. 21
      src/util/func.js
  2. 20
      src/views/authority/datascope.vue

@ -1,9 +1,14 @@
/**
* 通用工具类
*/
export default class func {
/**
* 不为空
* @param val
* @returns {boolean}
*/
export function notEmpty(val) {
static notEmpty(val) {
return !this.isEmpty(val);
}
@ -12,7 +17,7 @@ export function notEmpty(val) {
* @param val
* @returns {boolean}
*/
export function isEmpty(val) {
static isEmpty(val) {
if (
val === null ||
typeof val === 'undefined' ||
@ -29,7 +34,7 @@ export function isEmpty(val) {
* @param defaultValue
* @returns {number}
*/
export function toInt(val, defaultValue) {
static toInt(val, defaultValue) {
if (this.isEmpty(val)) {
return defaultValue === undefined ? -1 : defaultValue;
}
@ -42,7 +47,7 @@ export function toInt(val, defaultValue) {
* @param obj
* @returns {FormData}
*/
export function toFormData(obj) {
static toFormData(obj) {
const data = new FormData();
Object.keys(obj).forEach(key => {
data.append(key, Array.isArray(obj[key]) ? obj[key].join(',') : obj[key]);
@ -56,7 +61,7 @@ export function toFormData(obj) {
* @param format
* @returns {null}
*/
export function format(date, format = 'YYYY-MM-DD HH:mm:ss') {
static format(date, format = 'YYYY-MM-DD HH:mm:ss') {
return date ? date.format(format) : null;
}
@ -65,7 +70,7 @@ export function format(date, format = 'YYYY-MM-DD HH:mm:ss') {
* @param arr
* @returns {string}
*/
export function join(arr) {
static join(arr) {
return arr ? arr.join(',') : '';
}
@ -74,7 +79,7 @@ export function join(arr) {
* @param str
* @returns {string}
*/
export function split(str) {
static split(str) {
return str ? String(str).split(',') : '';
}
}

@ -87,6 +87,7 @@
} from "@/api/system/scope";
import {mapGetters} from "vuex";
import iconList from "@/config/iconList";
import func from "@/util/func";
export default {
data() {
@ -431,26 +432,27 @@
},
methods: {
initScope() {
if (this.watchMode) {
const scopeType = this.formScope.scopeType;
const scopeType = func.toInt(this.formScope.scopeType);
const watchMode = this.watchMode;
let column = "-", name = "暂无";
if (scopeType === "1") {
if (scopeType === 1) {
column = "-";
name = "全部可见";
} else if (scopeType === "2") {
} else if (scopeType === 2) {
column = "create_user";
name = "本人可见";
} else if (scopeType === "3") {
} else if (scopeType === 3) {
column = "create_dept";
name = "所在机构可见";
} else if (scopeType === "4") {
} else if (scopeType === 4) {
column = "create_dept";
name = "所在机构可见及子级可见";
} else if (scopeType === "5") {
} else if (scopeType === 5) {
column = "";
name = "自定义";
}
this.$refs.crudScope.option.column.filter(item => {
if (watchMode) {
if (item.prop === "scopeName") {
this.formScope.scopeName = `${this.scopeMenuName} [${name}]`;
}
@ -460,11 +462,11 @@
if (item.prop === "scopeColumn") {
this.formScope.scopeColumn = column;
}
}
if (item.prop === "scopeValue") {
item.display = scopeType === '5';
item.display = scopeType === 5;
}
});
}
},
//
rowSave(row, loading, done) {

Loading…
Cancel
Save