diff --git a/examples/main.js b/examples/main.js
index 317f9bd..1c9e88f 100644
--- a/examples/main.js
+++ b/examples/main.js
@@ -13,100 +13,38 @@ import '@/styles/theme/index.css';
import '@/styles/nprogress.scss';
import "highlight.js/styles/color-brewer.css";
-import { Notification } from 'element-ui';
-
const request = axios.create({
baseURL: 'http://47.110.137.80:7104/cbin/',
timeout: 1000 * 60,
withCredentials: true,
headers: {
- token: 'd2ec639eb3a4e6e2fc3ab2adc6e652fc',
+ token: '04c8fe07d7ded87936343ef8f0a6767a',
'Accept-Language': 'zh-CN'
}
});
-const codeMessage = {
- 200: '服务器成功返回请求的数据',
- 201: '新建或修改数据成功。',
- 202: '一个请求已经进入后台排队(异步任务)',
- 204: '删除数据成功。',
- 400: '发出的请求有错误,服务器没有进行新建或修改数据,的操作。',
- 401: '用户没有权限(令牌、用户名、密码错误)。',
- 403: '用户得到授权,但是访问是被禁止的。',
- 404: '发出的请求针对的是不存在的记录,服务器没有进行操作',
- 406: '请求的格式不可得。',
- 410: '请求的资源被永久删除,且不会再得到的。',
- 422: '当创建一个对象时,发生一个验证错误。',
- 500: '服务器发生错误,请检查服务器',
- 502: '网关错误',
- 503: '服务不可用,服务器暂时过载或维护',
- 504: '网关超时'
-};
-
-const checkStatus = (response) => {
- if (response.status >= 200 && response.status < 300) {
- return response;
- }
- const errortext = codeMessage[response.status] || response.statusText;
- const messageContent = `
- ${response.request.responseURL}
- ${errortext}
- `;
- Notification.error({
- title: `请求错误 ${response.status}:`,
- message: messageContent,
- duration: 3000,
- });
- const error = new Error(errortext);
- error.name = response.status;
- error.response = response;
- return error;
-}
-
// respone 拦截器
request.interceptors.response.use(
response => {
const { data = {}, config } = response;
- const { code, msg } = data;
+ const { code } = data;
if (config && config.interceptors === false) { // 请求配置不做返回拦截的情况
return response;
} else {
- if (`${code}` === '401') { // 授权失效
- removeToken();
- router.push({ name: 'login' }, () => {
- location.reload();
- });
- } else if (`${code}` === '1000') { // 业务逻辑错误提示
- Notification.error({
- title: '提示',
- message: msg,
- duration: 3000,
- });
- return false;
- } else if (`${code}` === '0') { // 请求成功
+ if (`${code}` === '0') {
return data;
- } else { // 其它错误,开发环境提示
- if (process.env.NODE_ENV === 'development') {
- Notification.error({
- title: '提示',
- message: msg,
- duration: 3000,
- });
- }
+ } else {
return false;
}
}
},
error => {
- const e = checkStatus(error.response);
- console.error(e);
+ console.error(error);
return { success: false };
});
Vue.prototype.$axios = request;
-
-
// 进度条配置
NProgress.configure({ showSpinner: false });
diff --git a/examples/views/page/test.vue b/examples/views/page/test.vue
index 7a38097..8acbf77 100644
--- a/examples/views/page/test.vue
+++ b/examples/views/page/test.vue
@@ -1,9 +1,20 @@
-
+
+
+
+
+
+
+ {{ productName || productCode }}
+
+
+
+
+
+
+
+
@@ -13,40 +24,41 @@ export default {
data() {
return {
schemeList: [
- { type: 'el-input', label: 'ID', key: 'id', include: 'form', visible: (model, { formMode } = {}) => { return formMode == 'edit' },
+ { type: 'el-input', label: 'ID', key: 'id', include: 'form', visible: (model, { formMode } = {}) => { return formMode == 'edit' }, show: false,
props: { disabled: true },
},
- { type: 'el-input', label: '门店编码', key: 'code', exclude: 'search',
- rules: [{ required: true, message: '门店编码不能为空', trigger: 'blur' }],
- props: { placeholder: '门店编码' },
+ { type: 'el-input', label: '编码', key: 'code', default: '1231231321231',
+ rules: [{ required: true, message: '编码不能为空', trigger: 'blur' }],
+ props: { placeholder: '编码', disabled: (model, { formMode } = {}) => { return formMode == 'edit' } },
},
- { type: 'el-input', label: '门店名称', key: 'name',
- rules: [{ required: true, message: '门店名称不能为空', trigger: 'blur' }],
- props: { placeholder: '门店名称' },
+ { type: 'el-input', label: '产品', key: 'productCode',
+ rules: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
+ props: { url: '/overseas/product/select' },
},
- { type: 'el-input', label: '合作伙伴', key: 'dwCustomerCode', exclude: 'search',
- rules: [{ required: true, message: '合作伙伴不能为空', trigger: 'change' }],
- props: { placeholder: '合作伙伴' },
+ { type: 'el-input-number', label: '价格', key: 'price', exclude: 'search',
+ rules: [{ required: true, message: '价格不能为空', trigger: 'blur' }],
+ props: { placeholder: '价格' },
},
- { type: 'el-input', label: '联系人', key: 'contact', exclude: 'search',
- rules: [{ required: true, message: '联系人不能为空', trigger: 'change' }],
- props: { placeholder: '联系人' },
+ { type: 'el-input', label: '价格说明', key: 'note', exclude: 'search',
+ props: { placeholder: '价格说明' },
},
- { type: 'el-input', label: '联系方式', key: 'phone', exclude: 'search',
- rules: [{ required: true, message: '联系方式不能为空', trigger: 'change' }],
- props: { placeholder: '联系方式' },
+ { type: 'el-input', label: '出发城市', key: 'fromCity', exclude: 'search',
+ rules: [{ required: true, message: '出发城市不能为空', trigger: 'change' }],
+ props: { dictionaryCode: 'FROM_CITY_LIST' },
},
- { type: 'el-input', label: '联系地址', key: 'address', exclude: 'search',
- rules: [{ required: true, message: '联系地址不能为空', trigger: 'change' }],
- props: { placeholder: '联系地址' },
+ { type: 'el-input', label: '目的地', key: 'toCountry', exclude: 'search',
+ rules: [{ required: true, message: '目的地不能为空', trigger: 'change' }],
+ props: { dictionaryCode: 'TO_COUNTRY' },
},
- { type: 'el-input', label: '管理员密码', key: 'password', exclude: 'search',
- rules: [{ required: true, message: '管理员密码不能为空', trigger: 'change' }],
- props: { placeholder: '管理员密码' },
+ { type: 'el-input', label: '状态', key: 'enableFlag', span: 24, searchScheme: { span: 6 },
},
- { type: 'el-input', label: '门店类型', key: 'type',
- rules: [{ required: true, message: '管理员密码不能为空', trigger: 'change' }],
- props: { placeholder: '管理员密码' },
+ { type: 'el-date-picker', label: '生效时间', key: 'enabledTime', exclude: 'search', minWidth: '180',
+ rules: [{ required: true, message: '生效时间不能为空', trigger: 'change' }],
+ props: { type: 'datetime', placeholder: '生效时间', 'value-format': 'yyyy-MM-dd HH:mm:ss' },
+ },
+ { type: 'el-date-picker', label: '禁用时间', key: 'disabledTime', exclude: 'search', minWidth: '180',
+ rules: [{ required: true, message: '禁用时间不能为空', trigger: 'change' }],
+ props: { type: 'datetime', placeholder: '禁用时间', 'value-format': 'yyyy-MM-dd HH:mm:ss' },
},
],
}
diff --git a/packages/scheme/index.vue b/packages/scheme/index.vue
index 9f2faf2..5954380 100644
--- a/packages/scheme/index.vue
+++ b/packages/scheme/index.vue
@@ -115,7 +115,7 @@
-
+
@@ -298,7 +298,6 @@ export default {
async doSearch(param) {
const { totalCountAlias = 'totalCount' } = this.option || {};
if (this.option.searchAPI) { // 配置了自定义查询API的情况
- console.log('searchAPI');
this.tableLoading = true;
try {
const response = await this.option.searchAPI(param) || {};
@@ -311,7 +310,6 @@ export default {
this.tableLoading = false;
}
} else if (_$http && this.option.url) { // 给定了http的情况
- console.log('_$http search');
this.tableLoading = true;
_$http.get(`${this.option.url.trim('/')}/${this.option.searchMethod || 'page'}?${stringify(param)}`)
.then((response) => {
@@ -333,7 +331,7 @@ export default {
this.dialogTitle = this.i18n('eagle.scheme.detail') || '详情';
this.dialogType = 'dialog-view';
this.tableCurrentRow = row;
- this.formModel = {};
+ this.resetFormModel();
this.formMode = "view";
this.$emit('dialog-change', this.dialogType);
this.showDialog();
@@ -343,7 +341,6 @@ export default {
async doDetail(param) {
const { primaryKey = 'id', detailPrimaryKey, detailRow = false } = this.option || {};
if (this.option.detailAPI && !detailRow) { // 配置了自定义查询API的情况
- console.log('detailAPI');
this.dialogLoading = true;
try {
const result = await this.option.detailAPI(param);
@@ -354,7 +351,6 @@ export default {
this.dialogLoading = false;
}
} else if (_$http && this.option.url && !detailRow) { // 给定了http的情况
- console.log('_$http detail');
this.dialogLoading = true;
const defaultDetailMethod = `info/${detailPrimaryKey || primaryKey}/${param[detailPrimaryKey] || param[primaryKey]}`;
const detailMethodFormat = this.option.detailMethod ? `${this.option.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}` : undefined;
@@ -375,7 +371,7 @@ export default {
this.dialogTitle = this.i18n('eagle.scheme.new') || '新增';
this.dialogType = 'dialog-form';
this.tableCurrentRow = row;
- this.formModel = {};
+ this.resetFormModel();
this.formMode = "new";
this.$emit('dialog-change', this.dialogType);
this.showDialog();
@@ -385,7 +381,7 @@ export default {
this.dialogTitle = this.i18n('eagle.scheme.edit') || '编辑';
this.dialogType = 'dialog-form';
this.tableCurrentRow = row;
- this.formModel = {};
+ this.resetFormModel();
this.formMode = "edit";
this.$emit('dialog-change', this.dialogType);
this.showDialog();
@@ -395,7 +391,6 @@ export default {
async doGet(param) {
const { primaryKey = 'id', getPrimaryKey, getRow = false } = this.option || {};
if (this.option.getAPI) { // 配置了自定义查询API的情况
- console.log('getAPI');
this.dialogLoading = true;
try {
const result = await this.option.getAPI(param);
@@ -406,7 +401,6 @@ export default {
this.dialogLoading = false;
}
} else if (_$http && this.option.url && !getRow) { // 给定了http的情况
- console.log('_$http get');
this.dialogLoading = true;
const defaultGetMethod = `get/${getPrimaryKey || primaryKey}/${param[getPrimaryKey] || param[primaryKey]}`;
const getMethodFormat = this.option.getMethod ? `${this.option.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}` : undefined;
@@ -445,7 +439,6 @@ export default {
const { primaryKey = 'id', deletePrimaryKey } = this.option || {};
const param = selection.map(item => item[deletePrimaryKey || primaryKey]);
if (this.option.deleteAPI) { // 配置了自定义删除API的情况
- console.log('deleteAPI');
this.dialogLoading = true;
try {
const success = await this.option.deleteAPI(param, selection);
@@ -460,7 +453,6 @@ export default {
this.dialogLoading = false;
}
} else if (_$http && this.option.url) { // 给定了http的情况
- console.log('_$http delete');
this.dialogLoading = true;
const postData = param;
_$http.post(`${this.option.url.trim('/')}/${this.option.deleteMethod || 'delete'}`, postData)
@@ -477,6 +469,18 @@ export default {
});
}
},
+ // 重置表单值
+ resetFormModel() {
+ this.$nextTick(() => {
+ if (this.$refs['eagle-form']) {
+ this.$refs['eagle-form'].reset();
+ } else {
+ Object.keys(this.formModel).forEach(key => {
+ this.formModel[key] = undefined;
+ });
+ }
+ });
+ },
// 设置表单值
setFormModel(value) {
if (value && value instanceof Object) {
@@ -511,7 +515,6 @@ export default {
async doNewSubmit(param) {
const { primaryKey = 'id', formPrimaryKey } = this.option || {};
if (this.option.newAPI) { // 配置了自定义查询API的情况
- console.log('newAPI');
this.dialogLoading = true;
try {
const success = await this.option.newAPI(param);
@@ -526,7 +529,6 @@ export default {
this.dialogLoading = false;
}
} else if (_$http && this.option.url) { // 给定了http的情况
- console.log('_$http new');
this.dialogLoading = true;
const postData = { ...param };
delete postData[formPrimaryKey || primaryKey];
@@ -547,7 +549,6 @@ export default {
// 编辑提交逻辑
async doEditSubmit(param) {
if (this.option.editAPI) { // 配置了自定义查询API的情况
- console.log('editAPI');
this.dialogLoading = true;
try {
const success = await this.option.editAPI(param);
@@ -562,7 +563,6 @@ export default {
this.dialogLoading = false;
}
} else if (_$http && this.option.url) { // 给定了http的情况
- console.log('_$http edit');
this.dialogLoading = true;
_$http.post(`${this.option.url.trim('/')}/${this.option.editMethod || 'update'}`, param)
.then(response => {
--
libgit2 0.21.0