cnetong-core-frontend
Version:
## 1. 开始使用 ```js // 在npm项目中的main.js文件中加入以下代码 import Base from "cnetong-core-frontend";
51 lines (47 loc) • 1.35 kB
JavaScript
import moment from "moment";
/**
* 基本CRUD视图功能
*/
export default {
computed: {
sysCode() {
return this.$store.state.base.sysCode;
}
},
methods: {
/**
* 时间列格式化
*/
formatterDate(row, column, cellValue) {
return cellValue ? moment(cellValue).format("LL") : null;
},
formatterDateTime(row, column, cellValue) {
return cellValue ? moment(cellValue).format("LL LTS") : null;
},
simpleFormatterDate(cellValue, defaultValue = null) {
return cellValue ? moment(cellValue).format("LL LTS") : defaultValue;
},
/**
* 使用确认框
*/
confirm(data, txt = "您确定要这样做么?") {
return this.$confirm(txt, {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => data);
},
addView(name, path, propsData) {
let idx = this.$tabView.viewList.findIndex(item => item.name === name);
if (idx === -1) this.$tabView.viewList.push({name, path, propsData});
this.$tabView.active = name;
},
removeView(name) {
let idx = this.$tabView.viewList.findIndex(item => item.name === name);
if (idx > -1) {
this.$tabView.active = this.$tabView.viewList[idx - 1].name;
this.$tabView.viewList.splice(idx, 1);
}
}
}
};