Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
traceSourceMb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yanyanhong
traceSourceMb
Commits
80d03bd1
Commit
80d03bd1
authored
Dec 11, 2020
by
chenqikuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增编辑模板
parent
d7ce97c2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
204 additions
and
37 deletions
+204
-37
template.ts
src/api/modules/template.ts
+9
-9
template.ts
src/mixins/template.ts
+12
-2
index.ts
src/router/index.ts
+8
-1
Add.vue
src/views/template/Add.vue
+55
-24
EditTemplate.vue
src/views/template/EditTemplate.vue
+114
-0
WordsManager.vue
src/views/template/components/WordsManager.vue
+0
-0
TemplateList.vue
src/views/viewTemplate/components/TemplateList.vue
+6
-1
No files found.
src/api/modules/template.ts
View file @
80d03bd1
...
...
@@ -35,12 +35,12 @@ const template = {
...
params
,
});
},
getFolder
(
id
:
string
){
getFolder
(
id
:
string
)
{
return
axios
.
get
(
`
${
base
}
/getFolder`
,
{
params
:
{
id
}
})
id
,
}
,
})
;
},
addFolder
(
name
:
string
,
params
:
any
)
{
return
axios
.
post
(
`
${
base
}
/addFolder`
,
{
...
...
@@ -82,15 +82,15 @@ const template = {
},
updateCustomize
(
params
:
any
)
{
return
axios
.
put
(
`
${
base
}
/updateCustomize`
,
{
...
params
...
params
,
});
},
getTemplate
(
id
:
string
){
getTemplate
(
id
:
string
)
{
return
axios
.
get
(
`
${
base
}
/get`
,
{
params
:
{
id
}
})
id
,
}
,
})
;
},
};
export
default
template
;
src/mixins/template.ts
View file @
80d03bd1
...
...
@@ -12,7 +12,7 @@ export default class Template extends Vue {
key
:
'edit'
,
icon
:
'zhongmingming2x'
,
text
:
'编辑'
,
//
callback: this.editTemplate,
callback
:
this
.
editTemplate
,
},
rename
:
{
key
:
'rename'
,
...
...
@@ -94,9 +94,19 @@ export default class Template extends Vue {
const
{
id
:
templateId
,
name
:
templateName
}
=
folder
;
// 退出到首页,让用户选择文件夹,并点击进入。
Toast
(
'请选择要移入的文件夹,并点击进入该文件夹'
);
this
.
setMovedTemplateId
(
Number
.
parseInt
(
templateId
));
this
.
setMovedTemplateId
(
Number
.
parseInt
(
templateId
,
10
));
this
.
$router
.
push
({
path
:
'/'
,
});
}
private
editTemplate
(
folder
:
any
)
{
const
{
id
}
=
folder
;
this
.
$router
.
push
({
name
:
'EditTemplate'
,
query
:
{
id
,
},
});
}
}
src/router/index.ts
View file @
80d03bd1
...
...
@@ -62,7 +62,7 @@ const routes: RouteConfig[] = [
name
:
'ViewTemplate'
,
component
:
()
=>
import
(
/* webpackChunkName: "view-template" */
'@/views/viewTemplate/Index.vue'
),
props
:
({
query
})
=>
({
folderId
:
Number
.
parseInt
(
query
.
folderId
as
string
),
folderId
:
Number
.
parseInt
(
query
.
folderId
as
string
,
10
),
folderName
:
query
.
folderName
,
}),
meta
:
{
requiresAuth
:
true
},
...
...
@@ -127,6 +127,13 @@ const routes: RouteConfig[] = [
meta
:
{
requiresAuth
:
true
},
},
{
path
:
'/editTemplate'
,
name
:
'EditTemplate'
,
component
:
()
=>
import
(
/* webpackChunkName: "edit-template" */
'@/views/template/EditTemplate.vue'
),
props
:
({
query
})
=>
({
id
:
Number
.
parseInt
(
query
.
id
as
string
,
10
)
}),
meta
:
{
requiresAuth
:
true
},
},
{
path
:
'/templList'
,
name
:
'TemplList'
,
// route level code-splitting
...
...
src/views/template/Add.vue
View file @
80d03bd1
<
template
>
<div>
<base-info
:showBaseInfo
.
sync=
"showBaseInfo"
@
next=
"baseInfoNext"
@
cancel=
"cancelCreateTempl"
></base-info>
<words-manager
:data
.
sync=
"words"
@
show-preview=
"showPreview= true;"
@
confirm-words=
"confirm"
></words-manager>
<div>
<!-- 拿到 模板名称和图片地址信息等信息 -->
<base-info
:showBaseInfo
.
sync=
"showBaseInfo"
@
next=
"baseInfoNext"
@
cancel=
"cancelCreateTempl"
></base-info>
<!-- 对words进行修改。 -->
<words-manager
:data
.
sync=
"words"
@
show-preview=
"showPreview = true"
@
confirm-words=
"confirm"
></words-manager>
<transition
name=
"van-slide-up"
>
<preview-template
:data=
"words"
v-if=
"showPreview"
@
cancel=
"showPreview = false"
@
employ=
"employ"
></preview-template>
</transition>
</div>
<preview-template
:data=
"words"
v-if=
"showPreview"
@
cancel=
"showPreview = false"
@
employ=
"employ"
></preview-template>
</transition>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
Component
,
Prop
,
Vue
}
from
'vue-property-decorator'
;
...
...
@@ -21,20 +36,21 @@ import WordsManager from './components/WordsManager.vue';
},
})
export
default
class
Add
extends
Vue
{
private
showBaseInfo
:
boolean
=
true
;
/* 创建存证所需要的数据 */
private
baseInfo
:
any
=
{
templateName
:
''
,
folder
:
{},
imgUrl
:
''
,
};
private
showWordsManager
:
boolean
=
false
;
private
words
:
any
[]
=
[];
private
showWordsManager
:
boolean
=
false
;
private
showPreview
:
boolean
=
false
;
get
templateData
()
{
const
{
baseInfo
,
words
}
=
this
;
const
{
baseInfo
,
words
}
=
this
;
const
{
templateName
,
folder
}
=
baseInfo
;
return
{
templateName
,
...
...
@@ -43,7 +59,9 @@ export default class Add extends Vue {
};
}
private
baseInfoNext
(
data
:
any
)
{
this
.
baseInfo
=
{...
data
};
console
.
log
(
data
);
this
.
baseInfo
=
{
...
data
};
}
private
cancelCreateTempl
()
{
this
.
$router
.
back
();
...
...
@@ -52,23 +70,36 @@ export default class Add extends Vue {
if
(
this
.
words
.
length
<=
0
)
{
return
Promise
.
reject
(
'请添加字段'
);
}
return
this
.
$api
.
template
.
customize
(
this
.
baseInfo
.
templateName
,
this
.
words
,
this
.
baseInfo
.
folder
.
id
,
{
s_image_url
:
this
.
baseInfo
.
imgUrl
,
});
/* 创建存证 */
return
this
.
$api
.
template
.
customize
(
this
.
baseInfo
.
templateName
,
this
.
words
,
this
.
baseInfo
.
folder
.
id
,
{
s_image_url
:
this
.
baseInfo
.
imgUrl
,
}
);
}
private
async
confirm
()
{
try
{
/* 创建存证 */
const
res
=
await
this
.
commitTemplate
();
this
.
$dialog
.
confirm
({
title
:
'提示'
,
message
:
'近保存还是去存证'
,
confirmButtonText
:
'立即存证'
,
cancelButtonText
:
'仅保存'
,
}).
then
(()
=>
{
this
.
$router
.
push
({
name
:
'ProofDetail'
,
query
:
{
templateId
:
res
.
id
}});
}).
catch
(()
=>
{
this
.
$router
.
push
({
path
:
'/'
});
});
this
.
$dialog
.
confirm
({
title
:
'提示'
,
message
:
'近保存还是去存证'
,
confirmButtonText
:
'立即存证'
,
cancelButtonText
:
'仅保存'
,
})
.
then
(()
=>
{
this
.
$router
.
push
({
name
:
'ProofDetail'
,
query
:
{
templateId
:
res
.
id
},
});
})
.
catch
(()
=>
{
this
.
$router
.
push
({
path
:
'/'
});
});
}
catch
(
err
)
{
this
.
$toast
(
err
);
}
...
...
src/views/template/EditTemplate.vue
0 → 100644
View file @
80d03bd1
<
template
>
<div>
<words-manager
:data
.
sync=
"words"
@
show-preview=
"showPreview = true"
@
confirm-words=
"confirm"
></words-manager>
<transition
name=
"van-slide-up"
>
<preview-template
:data=
"words"
v-if=
"showPreview"
@
cancel=
"showPreview = false"
@
employ=
"employ"
></preview-template>
</transition>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
Component
,
Prop
,
Vue
}
from
'vue-property-decorator'
;
import
{
TEMPLATETYPE
,
DataType
}
from
'@/const/enum'
;
import
BaseInfo
from
'./components/BaseInfo.vue'
;
import
PreviewTemplate
from
'./components/PreviewTemplate.vue'
;
import
WordsManager
from
'./components/WordsManager.vue'
;
@
Component
({
components
:
{
BaseInfo
,
PreviewTemplate
,
WordsManager
,
},
})
export
default
class
Add
extends
Vue
{
@
Prop
()
private
id
!
:
number
;
private
showBaseInfo
:
boolean
=
true
;
/* 创建存证所需要的数据 */
private
baseInfo
:
any
=
{
templateName
:
''
,
folder
:
{},
imgUrl
:
''
,
};
private
words
:
any
[]
=
[];
private
showWordsManager
:
boolean
=
false
;
private
showPreview
:
boolean
=
false
;
get
templateData
()
{
const
{
baseInfo
,
words
}
=
this
;
const
{
templateName
,
folder
}
=
baseInfo
;
return
{
templateName
,
words
,
folder
,
};
}
public
async
mounted
()
{
const
id
=
this
.
id
;
const
ret
=
await
this
.
$api
.
template
.
get
(
id
);
const
detail
=
JSON
.
parse
(
ret
.
detail
);
this
.
words
=
detail
;
}
private
baseInfoNext
(
data
:
any
)
{
console
.
log
(
data
);
this
.
baseInfo
=
{
...
data
};
}
private
cancelCreateTempl
()
{
this
.
$router
.
back
();
}
private
commitTemplate
()
{
if
(
this
.
words
.
length
<=
0
)
{
return
Promise
.
reject
(
'请添加字段'
);
}
/* 更新存证 */
return
this
.
$api
.
template
.
updateCustomize
({
id
:
this
.
id
,
detail
:
JSON
.
stringify
(
this
.
words
),
});
}
private
async
confirm
()
{
try
{
/* 创建存证 */
const
res
=
await
this
.
commitTemplate
();
this
.
$dialog
.
confirm
({
title
:
'提示'
,
message
:
'近保存还是去存证'
,
confirmButtonText
:
'立即存证'
,
cancelButtonText
:
'仅保存'
,
})
.
then
(()
=>
{
this
.
$router
.
push
({
name
:
'ProofDetail'
,
query
:
{
templateId
:
res
.
id
},
});
})
.
catch
(()
=>
{
this
.
$router
.
push
({
path
:
'/'
});
});
}
catch
(
err
)
{
this
.
$toast
(
err
);
}
}
private
async
employ
()
{
try
{
const
res
=
await
this
.
commitTemplate
();
}
catch
(
err
)
{
this
.
$toast
(
err
);
}
}
}
</
script
>
src/views/template/components/WordsManager.vue
View file @
80d03bd1
This diff is collapsed.
Click to expand it.
src/views/viewTemplate/components/TemplateList.vue
View file @
80d03bd1
...
...
@@ -51,7 +51,12 @@ export default class Index extends Vue {
@
Prop
()
loading
!
:
boolean
;
handleClickEditTemplate
(
templateId
:
number
)
{
console
.
log
(
'edit'
,
templateId
);
this
.
$router
.
push
({
name
:
'EditTemplate'
,
query
:
{
id
:
templateId
.
toString
(),
},
});
}
get
noData
()
{
return
this
.
list
.
length
===
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment