Commit e514108b by hank

fix bug

parent f8bfa01e
...@@ -46,7 +46,7 @@ service.interceptors.response.use( ...@@ -46,7 +46,7 @@ service.interceptors.response.use(
const res = response.data const res = response.data
console.log(res.code, res.code !== '0', 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 && res.code !== 20000) {
Message({ Message({
message: res.msg || ' response Error', message: res.msg || ' response Error',
type: 'error', type: 'error',
......
...@@ -130,20 +130,20 @@ import { ...@@ -130,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() {
...@@ -162,42 +162,42 @@ export default { ...@@ -162,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: [],
...@@ -205,220 +205,221 @@ export default { ...@@ -205,220 +205,221 @@ 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) { onProgress(event) {
console.log(event); console.log(event)
this.fullscreenLoading = true; this.fullscreenLoading = true
if (event.percent === 100) { // if (event.percent === 100) {
this.fullscreenLoading = false; // this.fullscreenLoading = false
} // }
}, },
uploadZipSuccess(e) { uploadZipSuccess(e) {
if (e.code && e.code !== "0") { this.fullscreenLoading = false
this.$message.error(e.msg); if (e.code && e.code !== '0') {
this.$message.error(e.msg)
} else { } else {
this.fullscreenLoading = false; this.fullscreenLoading = false
this.$message("上传成功"); this.$message('上传成功')
this.temp.frameInfo.frameUrl = e.frameUrl; this.temp.frameInfo.frameUrl = e.frameUrl
this.temp.resourceInfo.resourceUrl = e.resourceUrl; this.temp.resourceInfo.resourceUrl = e.resourceUrl
this.temp.templateCount = e.pictureUrl.length; 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>
...@@ -51,6 +51,11 @@ ...@@ -51,6 +51,11 @@
<span>{{ scope.row.templateCount }}</span> <span>{{ scope.row.templateCount }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="资源路径" width="210px" align="center">
<template slot-scope="scope">
<span>{{ scope.row.frameUrl.split('/').splice(-2, 3)[0]}}</span>
</template>
</el-table-column>
<!-- <el-table-column label="状态" class-name="status-col" width="100"> <!-- <el-table-column label="状态" class-name="status-col" width="100">
<template slot-scope="{row}"> <template slot-scope="{row}">
<el-tag :type="row.templateShow | statusFilter"> <el-tag :type="row.templateShow | statusFilter">
...@@ -60,6 +65,9 @@ ...@@ -60,6 +65,9 @@
</el-table-column> --> </el-table-column> -->
<el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
<template slot-scope="{row}"> <template slot-scope="{row}">
<el-button type="primary" size="mini">
<a :href="row.frameUrl" target="_blank">预览</a>
</el-button>
<el-button type="primary" size="mini" @click="handleUpdate(row)"> <el-button type="primary" size="mini" @click="handleUpdate(row)">
详情 详情
</el-button> </el-button>
......
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