Commit ad8aece5 by hank

merge

parents 492b637f 2af77db9
......@@ -2,7 +2,7 @@
ENV = 'development'
# base api
VUE_APP_BASE_API = 'https://manager.bdideal.com'
VUE_APP_BASE_API = 'http://39.97.179.60:8092'
VUE_APP_BASE_API_MOCK = '/dev-api'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
......
......@@ -2,5 +2,5 @@
ENV = 'production'
# base api
VUE_APP_BASE_API = '/prod-api'
VUE_APP_BASE_API = 'https://manager.bdideal.com'
# just a flag
ENV = 'production'
# base api
VUE_APP_BASE_API = 'http://39.97.179.60:8092'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
# It only does one thing by converting all import() to require().
# This configuration can significantly increase the speed of hot updates,
# when you have a large number of pages.
# Detail: https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/babel-preset-app/index.js
VUE_CLI_BABEL_TRANSPILE_MODULES = true
......@@ -26,7 +26,7 @@ const users = {
export default [
// user login
{
url: '/user/login',
url: '/publics/login',
type: 'post',
response: config => {
const { username } = config.body
......@@ -49,7 +49,7 @@ export default [
// get user info
{
url: '/user/info\.*',
url: '/publics/get/info\.*',
type: 'get',
response: config => {
const { token } = config.query
......@@ -64,15 +64,14 @@ export default [
}
return {
code: 20000,
data: info
info
}
}
},
// user logout
{
url: '/user/logout',
url: '/publics/logout',
type: 'post',
response: _ => {
return {
......
......@@ -7,6 +7,7 @@
"scripts": {
"dev": "vue-cli-service serve",
"build:prod": "vue-cli-service build",
"build:test": "vue-cli-service build --mode test",
"build:stage": "vue-cli-service build --mode staging",
"preview": "node build/index.js --preview",
"lint": "eslint --fix --ext .js,.vue src",
......
import request from '@/utils/requestMock.js'
import request from '@/utils/request'
export function login(data) {
return request({
url: '/user/login',
url: '/publics/login',
method: 'post',
data
})
......@@ -10,7 +10,7 @@ export function login(data) {
export function getInfo(token) {
return request({
url: '/user/info',
url: '/publics/get/info',
method: 'get',
params: { token }
})
......@@ -18,7 +18,7 @@ export function getInfo(token) {
export function logout() {
return request({
url: '/user/logout',
url: '/publics/logout',
method: 'post'
})
}
......@@ -35,8 +35,8 @@ const actions = {
return new Promise((resolve, reject) => {
login({ username: username.trim(), password: password }).then(response => {
const { data } = response
commit('SET_TOKEN', data.token)
setToken(data.token)
commit('SET_TOKEN', data)
setToken(data)
resolve()
}).catch(error => {
reject(error)
......@@ -48,7 +48,7 @@ const actions = {
getInfo({ commit, state }) {
return new Promise((resolve, reject) => {
getInfo(state.token).then(response => {
const { data } = response
const data = response
if (!data) {
reject('Verification failed, please Login again.')
......
......@@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth'
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
timeout: 10000 // request timeout
timeout: 10000000 // request timeout
})
// request interceptor
......@@ -44,7 +44,7 @@ service.interceptors.response.use(
*/
response => {
const res = response.data
console.log(res.code, res.code !== 'undefined', String(res.code))
console.log(res.code, res.code !== '0', String(res.code))
// if the custom code is not 20000, it is judged as an error.
if (res.code !== '0' && res.code) {
Message({
......
......@@ -5,7 +5,7 @@ import { getToken } from '@/utils/auth'
// create an axios instance
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API_MOCK, // url = base url + request url
baseURL: process.env.VUE_APP_BASE_API_MOCK || '', // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
timeout: 10000 // request timeout
})
......
......@@ -5,7 +5,7 @@
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>-->
</div>
<div>
<div v-loading.fullscreen.lock="fullscreenLoading">
<el-form
ref="dataForm"
:rules="rules"
......@@ -101,6 +101,7 @@
accept=".zip"
:show-file-list="false"
:on-success="uploadZipSuccess"
:on-progress="onProgress"
:action="templateUploadZipUrl"
>
<i class="el-icon-upload" />
......@@ -108,7 +109,7 @@
将文件拖到此处,或
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">只能上传zip包</div>
<div slot="tip" class="el-upload__tip">只能上传zip包 {{ temp.templateCount ? '上传成功' : '' }}</div>
</el-upload>
</el-form-item>
</el-form>
......@@ -129,20 +130,20 @@ import {
templateAdd,
templateUpdate,
getDetail
} from '@/api/template'
import waves from '@/directive/waves' // waves directive
} from "@/api/template";
import waves from "@/directive/waves"; // waves directive
export default {
name: 'ComplexTable',
name: "ComplexTable",
directives: { waves },
filters: {
statusFilter(status) {
const statusMap = {
published: 'success',
draft: 'info',
deleted: 'danger'
}
return statusMap[status]
published: "success",
draft: "info",
deleted: "danger"
};
return statusMap[status];
}
},
data() {
......@@ -151,6 +152,7 @@ export default {
list: null,
total: 0,
listLoading: true,
fullscreenLoading: false,
typeList: null,
tagsList: null,
showStatus: this.$store.state.app.showStatus,
......@@ -160,42 +162,42 @@ export default {
page: 1,
limit: 20,
typeId: undefined,
title: '',
title: "",
tagId: undefined,
sort: '+id'
sort: "+id"
},
templateId: '',
templateId: "",
sortOptions: [
{ label: 'ID Ascending', key: '+id' },
{ label: 'ID Descending', key: '-id' }
{ label: "ID Ascending", key: "+id" },
{ label: "ID Descending", key: "-id" }
],
statusOptions: ['published', 'draft', 'deleted'],
statusOptions: ["published", "draft", "deleted"],
showReviewer: false,
temp: {
templateName: '',
templateUrl: '',
templateName: "",
templateUrl: "",
frameInfo: {
frameUrl: ''
frameUrl: ""
},
resourceInfo: {
resourceUrl: ''
resourceUrl: ""
},
templateDescribe: '',
typeId: '',
templateDescribe: "",
typeId: "",
tagIds: [],
templateEnvironment: '',
templateShow: '',
templateProportion: '',
templateProportion1: '',
templateProportion2: '',
templatePackageName: '',
templateEnvironment: "",
templateShow: "",
templateProportion: "",
templateProportion1: "",
templateProportion2: "",
templatePackageName: "",
templateCount: 0
},
dialogFormVisible: true,
dialogStatus: '',
dialogStatus: "",
textMap: {
update: 'Edit',
create: 'Create'
update: "Edit",
create: "Create"
},
dialogPvVisible: false,
pvData: [],
......@@ -203,212 +205,220 @@ export default {
templateName: [
{
required: true,
message: 'templateName is required',
trigger: 'change'
message: "templateName is required",
trigger: "change"
}
],
templateDescribe: [
{
required: true,
message: 'templateDescribe is required',
trigger: 'change'
message: "templateDescribe is required",
trigger: "change"
}
],
typeId: [
{ required: true, message: 'typeId is required', trigger: 'change' }
{ required: true, message: "typeId is required", trigger: "change" }
],
templateEnvironment: [
{
required: true,
message: 'templateEnvironment is required',
trigger: 'change'
message: "templateEnvironment is required",
trigger: "change"
}
],
templateShow: [
{
required: true,
message: 'templateShow is required',
trigger: 'change'
message: "templateShow is required",
trigger: "change"
}
],
templatePackageName: [
{
required: true,
message: 'templatePackageName is required',
trigger: 'change'
message: "templatePackageName is required",
trigger: "change"
}
],
title: [
{ required: true, message: 'title is required', trigger: 'blur' }
{ required: true, message: "title is required", trigger: "blur" }
]
},
downloadLoading: false
}
};
},
created() {
this.templateId = this.$route.query.templateId
this.getList()
this.getTypeList()
this.getTempalteDetail()
this.templateId = this.$route.query.templateId;
this.getList();
this.getTypeList();
this.getTempalteDetail();
},
methods: {
getList() {
this.listLoading = true
this.listLoading = true;
getList(this.listQuery, this.listQuery.page, this.listQuery.limit).then(
response => {
this.list = response.list
this.total = response.count
this.list = response.list;
this.total = response.count;
// Just to simulate the time of the request
setTimeout(() => {
this.listLoading = false
}, 1.5 * 1000)
this.listLoading = false;
}, 1.5 * 1000);
}
)
);
},
handleFilter() {
this.listQuery.page = 1
this.getList()
this.listQuery.page = 1;
this.getList();
},
getTypeList() {
templateGetTypeList().then(res => {
this.typeList = res
})
this.typeList = res;
});
},
getTagsList() {
templateGetTagList(this.temp.typeId).then(res => {
this.tagsList = res
})
this.tagsList = res;
});
},
getTempalteDetail() {
const id = this.$route.query.templateId
const id = this.$route.query.templateId;
if (id) {
getDetail(this.$route.query.templateId).then(response => {
const tempData = JSON.parse(JSON.stringify(response))
const tempData = JSON.parse(JSON.stringify(response));
tempData.templateShow =
tempData.templateShow && tempData.templateShow.toUpperCase()
tempData.templateShow && tempData.templateShow.toUpperCase();
tempData.templateProportion1 =
tempData.templateProportion &&
tempData.templateProportion.split('/')[0]
tempData.templateProportion.split("/")[0];
tempData.templateProportion2 =
tempData.templateProportion &&
tempData.templateProportion.split('/')[1]
this.temp = Object.assign(this.temp, tempData)
this.getTagsList()
console.log(response)
})
tempData.templateProportion.split("/")[1];
this.temp = Object.assign(this.temp, tempData);
this.getTagsList();
console.log(response);
});
}
},
typeChange(value) {
this.listQuery.tagId = undefined
this.temp.tagIds = []
this.getTagsList()
this.listQuery.tagId = undefined;
this.temp.tagIds = [];
this.getTagsList();
},
onProgress(event) {
console.log(event);
this.fullscreenLoading = true;
if (event.percent === 100) {
this.fullscreenLoading = false;
}
},
uploadZipSuccess(e) {
if (e.code && e.code !== '0') {
this.$message.error(e.msg)
if (e.code && e.code !== "0") {
this.$message.error(e.msg);
} else {
this.$message('上传成功')
this.temp.frameInfo.frameUrl = e.frameUrl
this.temp.resourceInfo.resourceUrl = e.resourceUrl
this.temp.templateCount = e.pictureUrl.length
this.fullscreenLoading = false;
this.$message("上传成功");
this.temp.frameInfo.frameUrl = e.frameUrl;
this.temp.resourceInfo.resourceUrl = e.resourceUrl;
this.temp.templateCount = e.pictureUrl.length;
this.temp.templateUrl = e.pictureUrl
.map(item => {
if (item.indexOf('http') !== -1 || item.indexOf('https') !== -1) {
return item + ''
if (item.indexOf("http") !== -1 || item.indexOf("https") !== -1) {
return item + "";
} else {
return e.url + item + ''
return e.url + item + "";
}
})
.join(',')
console.log(this.temp)
.join(",");
console.log(this.temp);
}
console.log(e)
console.log(e);
},
resetTemp() {
this.temp = {
id: undefined,
importance: 1,
remark: '',
remark: "",
timestamp: new Date(),
title: '',
status: 'published',
type: ''
}
title: "",
status: "published",
type: ""
};
},
handleCreate() {
this.resetTemp()
this.dialogStatus = 'create'
this.dialogFormVisible = true
this.resetTemp();
this.dialogStatus = "create";
this.dialogFormVisible = true;
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
this.$refs["dataForm"].clearValidate();
});
},
createData() {
this.$refs['dataForm'].validate(valid => {
this.$refs["dataForm"].validate(valid => {
if (valid) {
const uploadTemp = Object.assign({}, this.temp)
const uploadTemp = Object.assign({}, this.temp);
uploadTemp.templateProportion =
uploadTemp.templateProportion1 +
'/' +
uploadTemp.templateProportion2
"/" +
uploadTemp.templateProportion2;
if (this.templateId) {
templateUpdate(this.templateId, uploadTemp).then(res => {
this.$notify({
title: 'Success',
message: 'Update Successfully',
type: 'success',
title: "Success",
message: "Update Successfully",
type: "success",
duration: 2000
})
this.getTempalteDetail()
this.$router.back()
})
});
this.getTempalteDetail();
this.$router.back();
});
} else {
templateAdd(uploadTemp).then(() => {
this.$notify({
title: 'Success',
message: 'Created Successfully',
type: 'success',
title: "Success",
message: "Created Successfully",
type: "success",
duration: 2000
})
this.$router.back()
})
});
this.$router.back();
});
}
}
})
});
},
handleDelete(row) {
this.$confirm('此操作将删除该模板, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
this.$confirm("此操作将删除该模板, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
templateDel(row.templateId).then(() => {
this.$message({
type: 'success',
message: '删除成功!'
})
this.getList()
})
type: "success",
message: "删除成功!"
});
this.getList();
});
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
type: "info",
message: "已取消删除"
});
});
},
getSortClass: function(key) {
const sort = this.listQuery.sort
const sort = this.listQuery.sort;
return sort === `+${key}`
? 'ascending'
? "ascending"
: sort === `-${key}`
? 'descending'
: ''
? "descending"
: "";
}
}
}
};
</script>
<style lang="scss" scoped>
</style>
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 sign in to comment