Commit ad8aece5 by hank

merge

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