Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夜猫逐梦
1024程序员开源挑战赛
提交
0bb31b84
1
1024程序员开源挑战赛
项目概览
夜猫逐梦
/
1024程序员开源挑战赛
与 Fork 源项目一致
Fork自
GitCode / 1024程序员开源挑战赛(10.23-11.14)
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
1
1024程序员开源挑战赛
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
0bb31b84
编写于
7月 07, 2020
作者:
B
baiy
提交者:
ninecents
10月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update package
上级
8011e959
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
411 addition
and
416 deletion
+411
-416
package-lock.json
package-lock.json
+66
-66
package.json
package.json
+17
-56
src/views/tool/qrCode.vue
src/views/tool/qrCode.vue
+207
-148
src/views/tool/time.vue
src/views/tool/time.vue
+121
-146
未找到文件。
package-lock.json
浏览文件 @
0bb31b84
此差异已折叠。
点击以展开。
package.json
浏览文件 @
0bb31b84
{
"name"
:
"c-tool"
,
"version"
:
"1.
9
.1"
,
"version"
:
"1.
0
.1"
,
"private"
:
true
,
"scripts"
:
{
"serve"
:
"vue-cli-service serve --port 8081"
,
"build"
:
"vue-cli-service build"
,
"report"
:
"vue-cli-service build --report"
,
"lint"
:
"vue-cli-service lint"
},
"dependencies"
:
{
"
@babel/parser
"
:
"
^7.16.2
"
,
"
@prettier/plugin-php
"
:
"
^0.17.6
"
,
"
@typescript-eslint/typescript-estree
"
:
"
^5.3.0
"
,
"
angular-html-parser
"
:
"
^1.8.0
"
,
"
axios
"
:
"
^0.21.4
"
,
"
ajax-request
"
:
"
^1.2.3
"
,
"
babel-runtime
"
:
"
^6.26.0
"
,
"
bignumber.js
"
:
"
^9.0.1
"
,
"
code-formatter
"
:
"
0.0.1
"
,
"
codemirror
"
:
"
^5.63.3
"
,
"
codemirror-graphql
"
:
"
^1.1.0
"
,
"
cron-parser
"
:
"
^2.16.3
"
,
"
cronstrue
"
:
"
^1.122.0
"
,
"
cron-parser
"
:
"
^2.15.0
"
,
"
cronstrue
"
:
"
^1.94.0
"
,
"
crypto-js
"
:
"
^3.3.0
"
,
"
diff-match-patch
"
:
"
^1.0.5
"
,
"
file
"
:
"
^0.2.2
"
,
"
graphql
"
:
"
15.5.0
"
,
"
diff
"
:
"
^4.0.2
"
,
"
ipinyinjs
"
:
"
^1.0.0
"
,
"
jian_fan
"
:
"
^1.0.3
"
,
"
jimp
"
:
"
^0.16.1
"
,
"
js-base64
"
:
"
^2.6.4
"
,
"
js-htmlencode
"
:
"
^0.3.0
"
,
"
js-yaml
"
:
"
^3.14.1
"
,
"
jsbarcode
"
:
"
^3.11.5
"
,
"
json-to-properties
"
:
"
^1.1.3
"
,
"
json5
"
:
"
^2.2.0
"
,
"
jsonlint
"
:
"
^1.6.3
"
,
"
jsrsasign
"
:
"
^10.4.1
"
,
"
jsrsasign-util
"
:
"
^1.0.5
"
,
"
jwt-decode
"
:
"
^3.1.2
"
,
"
lodash
"
:
"
^4.17.21
"
,
"
mime-types
"
:
"
^2.1.33
"
,
"
moment
"
:
"
^2.29.1
"
,
"
php-array-reader
"
:
"
^1.3.2
"
,
"
is-url
"
:
"
^1.2.4
"
,
"
iview
"
:
"
^3.5.4
"
,
"
js-base64
"
:
"
^2.6.2
"
,
"
lscache
"
:
"
^1.3.0
"
,
"
moment
"
:
"
^2.27.0
"
,
"
php-array-reader
"
:
"
^1.2.0
"
,
"
phparr
"
:
"
^0.2.0
"
,
"
postcss
"
:
"
^8.3.11
"
,
"
postcss-less
"
:
"
^5.0.0
"
,
"
postcss-scss
"
:
"
^4.0.2
"
,
"
prettier
"
:
"
^2.4.1
"
,
"
prettier-plugin-sql
"
:
"
^0.3.0
"
,
"
properties-to-json
"
:
"
^0.1.7
"
,
"
qrcode
"
:
"
^1.4.4
"
,
"
qrcode-parser
"
:
"
^1.2.0
"
,
"
query-string
"
:
"
^6.14.1
"
,
"
query-string
"
:
"
^6.13.1
"
,
"
radix.js
"
:
"
0.0.1
"
,
"
serialize-php
"
:
"
^1.1.2
"
,
"
sm-crypto
"
:
"
^0.1.4
"
,
"
system
"
:
"
^2.0.1
"
,
"
typescript
"
:
"
^4.4.4
"
,
"
uglify-js
"
:
"
3.14.3
"
,
"
uuid
"
:
"
^8.3.2
"
,
"
view-design
"
:
"
^4.6.1
"
,
"
vue
"
:
"
^2.6.14
"
,
"
vue-i18n
"
:
"
^8.26.7
"
,
"
vue-router
"
:
"
^3.5.3
"
,
"
x2js
"
:
"
github:abdolence/x2js
"
,
"
xml-formatter
"
:
"
^2.5.1
"
"
vue
"
:
"
^2.6.11
"
,
"
vue-prismjs
"
:
"
^1.2.0
"
,
"
vue-router
"
:
"
^3.3.4
"
},
"devDependencies"
:
{
"
@vue/cli-plugin-babel
"
:
"
^3.12.1
"
,
...
...
@@ -72,11 +39,8 @@
"
babel-eslint
"
:
"
^10.1.0
"
,
"
eslint
"
:
"
^5.16.0
"
,
"
eslint-plugin-vue
"
:
"
^5.2.3
"
,
"
less
"
:
"
^2.7.3
"
,
"
less-loader
"
:
"
^5.0.0
"
,
"
utools-api-types
"
:
"
^2.3.0
"
,
"
vue-cli-plugin-iview
"
:
"
^1.0.6
"
,
"
vue-template-compiler
"
:
"
^2.6.1
4
"
"
vue-template-compiler
"
:
"
^2.6.1
1
"
},
"eslintConfig"
:
{
"root"
:
true
,
...
...
@@ -99,9 +63,6 @@
},
"parserOptions"
:
{
"parser"
:
"babel-eslint"
},
"globals"
:
{
"__"
:
"writable"
}
},
"postcss"
:
{
...
...
src/views/tool/qrCode.vue
浏览文件 @
0bb31b84
<
template
>
<div>
<Tabs
v-model=
"current.operation"
>
<TabPane
:label=
"$t('qrCode_generate_title')"
name=
"generate"
>
<Row
:gutter=
"16"
>
<Col
span=
"14"
>
<Input
v-model=
"current.generateInput"
:rows=
"14"
type=
"textarea"
:placeholder=
"$t('qrCode_generate_input')"
></Input>
</Col>
<Col
span=
"10"
style=
"text-align: center;"
>
<img
v-if=
"generateOutput"
@
click=
"()=>$clipboardCopyImages(generateOutput)"
style=
"width:300px;cursor:pointer"
:src=
"generateOutput"
/>
</Col>
</Row>
</TabPane>
<TabPane
:label=
"$t('qrCode_reader_title')"
name=
"reader"
>
<Row
:gutter=
"16"
>
<Col
span=
"14"
>
<input-block
style=
"margin-bottom: 10px"
bottom=
"0px"
right=
"10px"
>
<pasteClipboardFlie
@
on-paste-image=
"handleUpload"
>
<Input
v-model=
"current.readerInput"
:rows=
"3"
type=
"textarea"
:placeholder=
"$t('qrCode_reader_input')"
></Input>
</pasteClipboardFlie>
<Upload
slot=
"extra"
action=
"#"
:before-upload=
"handleUpload"
>
<Button
size=
"small"
type=
"primary"
icon=
"ios-cloud-upload-outline"
>
{{
$t
(
'
qrCode_reader_upload
'
)
}}
</Button>
</Upload>
</input-block>
<Input
v-model=
"readerOutput"
:rows=
"8"
type=
"textarea"
:placeholder=
"$t('qrCode_reader_output')"
></Input>
</Col>
<Col
span=
"10"
style=
"text-align: center"
v-html=
"readerInputImg"
/>
</Row>
</TabPane>
</Tabs>
</div>
<div>
<Tabs
v-model=
"current.operation"
>
<TabPane
label=
"二维码生成"
name=
"generate"
>
<Row
:gutter=
"16"
>
<Col
span=
"14"
>
<Input
v-model=
"current.generateInput"
:rows=
"14"
type=
"textarea"
placeholder=
"内容"
></Input>
<option-block>
<FormItem>
<Button
type=
"primary"
@
click=
"generate()"
>
生成
</Button>
</FormItem>
<FormItem
v-if=
"generateHistory.length() > 0"
>
<Dropdown
placement=
"top-start"
trigger=
"click"
style=
"margin-left: 10px"
@
on-click=
"history"
>
<a
href=
"javascript:void(0)"
>
历史记录
<Icon
type=
"ios-arrow-down"
></Icon>
</a>
<DropdownMenu
slot=
"list"
>
<DropdownItem
v-for=
"(v,i) in generateHistory.lists()"
:key=
"i"
:name=
"i"
>
{{
substr
(
v
.
input
)
}}
</DropdownItem>
<DropdownItem
divided
name=
"clear"
>
清空历史记录
</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
<FormItem>
<Checkbox
v-model=
"current.generateIsShort"
>
生成短连接
</Checkbox>
</FormItem>
<FormItem
v-if=
"current.generateIsShort"
>
<Alert>
短链接API由 t.cn 提供
</Alert>
</FormItem>
</option-block>
</Col>
<Col
span=
"10"
>
<div
style=
"text-align: center"
v-html=
"current.generateOutput"
></div>
<p
style=
"text-align: center"
v-if=
"current.generateIsShort && current.generateShortUrl"
>
短连接:
{{
current
.
generateShortUrl
}}
</p>
</Col>
</Row>
</TabPane>
<TabPane
label=
"二维码解析"
name=
"reader"
>
<Row
:gutter=
"16"
>
<Col
span=
"14"
>
<Input
v-model=
"current.readerInput"
:rows=
"5"
type=
"textarea"
placeholder=
"请输入二维码图片地址或点击下方按钮上传图片"
></Input>
<option-block>
<FormItem>
<Button
type=
"primary"
@
click=
"reader()"
>
解析
</Button>
</FormItem>
<FormItem>
<Upload
action=
"#"
:before-upload=
"handleUpload"
>
<Button
icon=
"ios-cloud-upload-outline"
>
上传图片
</Button>
</Upload>
</FormItem>
</option-block>
<Input
v-model=
"current.readerOutput"
:rows=
"5"
type=
"textarea"
placeholder=
"解析结果"
></Input>
</Col>
<Col
span=
"10"
style=
"text-align: center"
v-html=
"readerInputImg"
></Col>
</Row>
</TabPane>
</Tabs>
</div>
</
template
>
<
script
>
import
generator
from
'
qrcode
'
import
qrcodeParser
from
'
qrcode-parser
'
import
model
from
'
../../tool/model
'
import
Jimp
from
'
jimp
'
;
import
pasteClipboardFlie
from
'
./components/pasteClipboardFlie
'
;
import
generator
from
'
qrcode
'
import
qrcodeParser
from
'
qrcode-parser
'
import
request
from
'
ajax-request
'
import
cache
from
'
../../tool/cache
'
import
isUrl
from
'
is-url
'
import
{
trim
}
from
'
../../helper
'
const
generateHistoryCacheName
=
'
qrCodeGenerateHistoryCacheName
'
const
generateHistoryMaxLength
=
15
class
generateHistory
{
data
=
[]
export
default
{
components
:
{
pasteClipboardFlie
,
},
computed
:
{
readerInputImg
()
{
if
(
this
.
current
.
readerInput
)
{
return
`<img style="width:300px" src="
${
this
.
current
.
readerInput
}
" />`
constructor
()
{
this
.
data
=
cache
.
get
(
generateHistoryCacheName
,
[])
}
find
(
value
)
{
for
(
let
i
=
0
;
i
<
this
.
data
.
length
;
i
++
)
{
if
(
this
.
data
[
i
].
input
===
value
.
input
&&
this
.
data
[
i
].
isShort
===
value
.
isShort
)
{
return
true
}
}
return
''
return
false
}
},
watch
:
{
"
current.generateInput
"
()
{
this
.
generate
()
},
"
current.readerInput
"
()
{
this
.
reader
()
push
(
value
)
{
if
(
this
.
find
(
value
))
{
return
}
if
(
this
.
data
.
length
>
generateHistoryMaxLength
)
{
this
.
data
.
pop
()
}
this
.
data
.
push
(
value
)
cache
.
set
(
generateHistoryCacheName
,
this
.
data
,
86400
)
}
},
created
()
{
let
feature
=
model
.
getToolCurrentFeature
(
'
generate
'
)
if
(
feature
===
'
generate
'
)
{
this
.
current
.
operation
=
feature
;
this
.
$initToolData
(
'
generateInput
'
)
}
else
if
(
feature
===
'
reader
'
)
{
this
.
current
.
operation
=
feature
;
this
.
$initToolData
(
'
readerInput
'
)
}
else
{
this
.
$initToolData
()
getValue
(
index
)
{
return
this
.
data
[
index
]
}
},
methods
:
{
generate
()
{
if
(
!
this
.
current
.
generateInput
)
{
this
.
generateOutput
=
""
;
return
;
}
generator
.
toDataURL
(
this
.
current
.
generateInput
,
(
error
,
url
)
=>
{
if
(
error
)
{
this
.
generateOutput
=
this
.
$t
(
"
qrCode_generate_error
"
,
[
error
]);
return
;
}
this
.
generateOutput
=
url
this
.
$saveToolData
(
this
.
current
)
})
lists
()
{
return
this
.
data
}
length
()
{
return
this
.
data
.
length
}
clear
()
{
this
.
data
=
[]
cache
.
remove
(
generateHistoryCacheName
)
}
}
export
default
{
computed
:
{
readerInputImg
()
{
if
(
this
.
current
.
readerInput
)
{
return
`<img style="width:300px" src="
${
this
.
current
.
readerInput
}
" />`
}
return
''
},
},
reader
()
{
if
(
!
this
.
current
.
readerInput
)
{
this
.
readerOutput
=
""
;
return
}
this
.
getReaderImagePngBase64
(
this
.
current
.
readerInput
).
then
((
result
)
=>
{
this
.
readerOutput
=
result
this
.
$saveToolData
(
this
.
current
)
}).
catch
(
e
=>
{
this
.
readerOutput
=
this
.
$t
(
'
qrCode_reader_error
'
,
[
e
.
message
])
})
created
()
{
this
.
generateHistory
=
new
generateHistory
()
this
.
current
=
Object
.
assign
(
this
.
current
,
this
.
$getToolData
())
},
getReaderImagePngBase64
(
input
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
'
GET
'
,
input
);
xhr
.
responseType
=
'
blob
'
;
xhr
.
onload
=
()
=>
{
if
(
xhr
.
status
>=
200
&&
xhr
.
status
<
300
)
{
let
blob
=
xhr
.
response
;
const
myReader
=
new
FileReader
();
myReader
.
readAsArrayBuffer
(
blob
);
myReader
.
addEventListener
(
'
loadend
'
,
e
=>
{
const
buffer
=
e
.
target
.
result
;
try
{
Jimp
.
read
(
buffer
,
(
err
,
image
)
=>
{
if
(
err
)
{
return
reject
(
err
);
}
image
.
getBase64Async
(
"
image/png
"
).
then
((
img
)
=>
{
return
qrcodeParser
(
img
)
}).
then
((
c
)
=>
{
resolve
(
c
.
data
)
}).
catch
((
e
)
=>
{
reject
(
e
);
})
});
}
catch
(
e
)
{
reject
(
e
);
}
});
}
else
{
reject
(
new
Error
(
this
.
$t
(
'
qrCode_reader_parsing_failure
'
).
toString
()));
methods
:
{
history
(
index
)
{
if
(
index
===
'
clear
'
)
{
this
.
generateHistory
.
clear
()
return
}
let
history
=
this
.
generateHistory
.
getValue
(
index
)
this
.
current
.
generateInput
=
history
.
input
this
.
current
.
generateIsShort
=
history
.
isShort
this
.
generate
(
false
)
},
generate
(
insertHistory
=
true
)
{
if
(
!
this
.
current
.
generateInput
)
return
if
(
this
.
current
.
generateIsShort
)
{
if
(
!
isUrl
(
this
.
current
.
generateInput
))
{
return
this
.
$Message
.
error
(
'
生成短连接的内容是url
'
)
}
};
xhr
.
onerror
=
()
=>
reject
(
new
Error
(
this
.
$t
(
'
qrCode_reader_parsing_failure
'
).
toString
()));
xhr
.
send
();
})
request
({
url
:
'
http://api.t.sina.com.cn/short_url/shorten.json
'
,
data
:
{
'
source
'
:
'
2815391962
'
,
'
url_long
'
:
this
.
current
.
generateInput
},
},
(
err
,
res
,
result
)
=>
{
if
(
err
)
return
this
.
$Message
.
error
(
'
二维码短连接生成错误:
'
+
err
)
result
=
JSON
.
parse
(
result
)
if
(
!
result
[
0
][
'
url_short
'
])
{
return
this
.
$Message
.
error
(
'
短连接生成错误
'
)
}
else
{
this
.
current
.
generateShortUrl
=
result
[
0
][
'
url_short
'
]
this
.
generateHandle
(
this
.
current
.
generateShortUrl
)
}
})
}
else
{
this
.
current
.
generateShortUrl
=
''
this
.
generateHandle
(
this
.
current
.
generateInput
)
}
if
(
insertHistory
)
{
this
.
generateHistory
.
push
({
input
:
this
.
current
.
generateInput
,
isShort
:
this
.
current
.
generateIsShort
,
})
}
this
.
$saveToolData
(
this
.
current
)
},
reader
()
{
if
(
!
this
.
current
.
readerInput
)
{
return
}
qrcodeParser
(
this
.
current
.
readerInput
).
then
((
c
)
=>
{
this
.
current
.
readerOutput
=
c
.
data
this
.
$saveToolData
(
this
.
current
)
this
.
$Message
.
success
(
'
解析成功
'
)
}).
catch
(()
=>
{
return
this
.
$Message
.
error
(
'
图片解析错误
'
)
})
},
generateHandle
(
str
)
{
generator
.
toDataURL
(
str
,
(
error
,
url
)
=>
{
if
(
error
)
return
this
.
$Message
.
error
(
'
二维码生成错误:
'
+
error
)
this
.
$Message
.
success
(
'
生成成功
'
)
this
.
current
.
generateOutput
=
`<img style="width:300px" src="
${
url
}
" />`
})
},
handleUpload
(
file
)
{
let
r
=
new
FileReader
()
r
.
readAsDataURL
(
file
)
r
.
onloadend
=
()
=>
{
this
.
current
.
readerInput
=
r
.
result
this
.
reader
()
}
return
false
},
substr
(
str
)
{
str
=
trim
(
str
.
replace
(
/
[\r\n]
/g
,
''
))
const
strLength
=
100
return
str
.
length
>
strLength
?
str
.
substr
(
0
,
strLength
)
+
'
...
'
:
str
},
},
handleUpload
(
file
)
{
if
(
this
.
current
.
operation
!==
"
reader
"
){
return
;
}
let
r
=
new
FileReader
()
r
.
readAsDataURL
(
file
)
r
.
onloadend
=
()
=>
{
this
.
current
.
readerInput
=
r
.
result
data
()
{
return
{
generateHistory
:
{},
current
:
{
generateInput
:
''
,
generateOutput
:
''
,
generateIsShort
:
false
,
generateShortUrl
:
''
,
readerInput
:
''
,
readerOutput
:
''
,
operation
:
'
generate
'
,
},
}
return
false
}
},
data
()
{
return
{
readerOutput
:
""
,
generateOutput
:
""
,
current
:
{
generateInput
:
''
,
readerInput
:
''
,
operation
:
'
generate
'
,
},
}
},
}
</
script
>
},
}
</
script
>
\ No newline at end of file
src/views/tool/time.vue
浏览文件 @
0bb31b84
<
template
>
<div>
<Tabs
name=
"default"
>
<TabPane
:label=
"$t('time_diff_tool')
"
name=
"default"
>
<option-block>
<FormItem>
<DatePicker
transfer
v-model=
"current.poor.input1"
:options=
"options"
type=
"datetime"
format=
"yyyy-MM-dd HH:mm:ss"
></DatePicker>
</FormItem>
<FormItem>
{{
$t
(
'
time_and
'
)
}}
</FormItem>
<FormItem>
<DatePicker
transfer
v-model=
"current.poor.input2"
:options=
"options"
type=
"datetime"
format=
"yyyy-MM-dd HH:mm:ss"
></DatePicker>
</FormItem>
<FormItem>
{{
$t
(
'
time_diff
'
)
}}
</FormItem>
<FormItem>
<Input
v-model=
"poor"
>
<Select
transfer
v-model=
"current.poor.unit"
slot=
"append"
style=
"width: 8
0px"
>
<Option
v-for=
"v in poorUnit"
:value=
"v.v"
:key=
"v.v"
>
{{
v
.
n
}}
</Option>
</Select>
</Input>
</FormItem>
</option-block>
</TabPane>
</Tabs>
<div>
<Tabs
name=
"default"
>
<TabPane
label=
"差值计算器
"
name=
"default"
>
<option-block>
<FormItem>
<DatePicker
transfer
v-model=
"current.poor.input1"
:options=
"options"
type=
"datetime"
format=
"yyyy-MM-dd HH:mm:ss"
></DatePicker>
</FormItem>
<FormItem>
与
</FormItem>
<FormItem>
<DatePicker
transfer
v-model=
"current.poor.input2"
:options=
"options"
type=
"datetime"
format=
"yyyy-MM-dd HH:mm:ss"
></DatePicker>
</FormItem>
<FormItem>
相差
</FormItem>
<FormItem>
<Input
v-model=
"poor"
>
<Select
transfer
v-model=
"current.poor.unit"
slot=
"append"
style=
"width: 6
0px"
>
<Option
v-for=
"v in poorUnit"
:value=
"v.v"
:key=
"v.v"
>
{{
v
.
n
}}
</Option>
</Select>
</Input>
</FormItem>
</option-block>
</TabPane>
</Tabs>
<Tabs
name=
"default"
>
<TabPane
:label=
"$t('time_operation')
"
name=
"default"
>
<option-block>
<FormItem>
<DatePicker
transfer
v-model=
"current.duration.input"
:options=
"options"
type=
"datetime"
format=
"yyyy-MM-dd HH:mm:ss"
></DatePicker>
</FormItem>
<FormItem>
<Select
transfer
v-model=
"current.duration.type"
style=
"width: 10
0px"
>
<Option
value=
"+"
>
{{
$t
(
'
time_add
'
)
}}
</Option>
<Option
value=
"-"
>
{{
$t
(
'
time_reduce
'
)
}}
</Option>
</Select>
</FormItem>
<FormItem>
<Input
v-model=
"current.duration.length"
type=
"number"
number
>
<Select
transfer
v-model=
"current.duration.unit"
slot=
"append"
style=
"width: 8
0px"
>
<Option
v-for=
"v in poorUnit"
:value=
"v.v"
:key=
"v.v"
>
{{
v
.
n
}}
</Option>
</Select>
</Input>
</FormItem>
<FormItem>
{{
$t
(
'
time_after
'
)
}}
,
{{
$t
(
'
time_is
'
)
}}
<strong>
{{
duration
}}
</strong>
</FormItem>
</option-block>
</TabPane>
</Tabs>
</div>
<Tabs
name=
"default"
>
<TabPane
label=
"时间操作
"
name=
"default"
>
<option-block>
<FormItem>
<DatePicker
transfer
v-model=
"current.duration.input"
:options=
"options"
type=
"datetime"
format=
"yyyy-MM-dd HH:mm:ss"
></DatePicker>
</FormItem>
<FormItem>
<Select
transfer
v-model=
"current.duration.type"
style=
"width: 6
0px"
>
<Option
value=
"+"
>
添加
</Option>
<Option
value=
"-"
>
减少
</Option>
</Select>
</FormItem>
<FormItem>
<Input
v-model=
"current.duration.length"
type=
"number"
number
>
<Select
transfer
v-model=
"current.duration.unit"
slot=
"append"
style=
"width: 6
0px"
>
<Option
v-for=
"v in poorUnit"
:value=
"v.v"
:key=
"v.v"
>
{{
v
.
n
}}
</Option>
</Select>
</Input>
</FormItem>
<FormItem>
后, 为
<strong>
{{
duration
}}
</strong>
</FormItem>
</option-block>
</TabPane>
</Tabs>
</div>
</
template
>
<
script
>
import
moment
from
'
moment
'
import
moment
from
'
moment
'
export
default
{
created
()
{
this
.
$initToolData
()
},
computed
:
{
poor
()
{
let
a
=
moment
(
this
.
current
.
poor
.
input1
)
let
b
=
moment
(
this
.
current
.
poor
.
input2
)
this
.
$saveToolData
(
this
.
current
)
return
b
.
diff
(
a
,
this
.
current
.
poor
.
unit
)
export
default
{
created
()
{
this
.
current
=
Object
.
assign
(
this
.
current
,
this
.
$getToolData
())
},
duration
()
{
if
(
!
this
.
current
.
duration
.
length
){
return
""
;
}
let
rate
=
this
.
getRate
(
this
.
current
.
duration
.
unit
)
let
result
;
if
(
rate
===
0
)
{
if
(
!
Number
.
isInteger
(
this
.
current
.
duration
.
length
)){
return
this
.
$t
(
'
time_error
'
,[
this
.
$t
(
'
time_error_duration_length
'
)])
}
computed
:
{
poor
()
{
let
a
=
moment
(
this
.
current
.
poor
.
input1
)
let
b
=
moment
(
this
.
current
.
poor
.
input2
)
this
.
$saveToolData
(
this
.
current
)
return
b
.
diff
(
a
,
this
.
current
.
poor
.
unit
)
},
duration
()
{
this
.
$saveToolData
(
this
.
current
)
const
type
=
this
.
current
.
duration
.
type
===
'
+
'
?
'
add
'
:
'
subtract
'
result
=
moment
(
this
.
current
.
duration
.
input
)[
type
](
this
.
current
.
duration
.
length
,
this
.
current
.
duration
.
unit
)
}
else
{
result
=
moment
(
moment
(
this
.
current
.
duration
.
input
).
unix
()
*
1000
+
(
rate
*
this
.
current
.
duration
.
length
)
*
(
this
.
current
.
duration
.
type
===
'
+
'
?
1
:
-
1
)
)
}
this
.
$saveToolData
(
this
.
current
)
return
result
.
format
(
'
YYYY-MM-DD HH:mm:ss
'
);
return
moment
(
this
.
current
.
duration
.
input
)[
type
](
this
.
current
.
duration
.
length
,
this
.
current
.
duration
.
unit
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
)
},
},
},
methods
:
{
getRate
(
unit
)
{
for
(
let
item
of
this
.
poorUnit
)
{
if
(
item
.
v
===
unit
)
{
return
parseInt
(
item
.
rate
)
}
}
return
0
;
}
},
data
()
{
return
{
options
:
{
shortcuts
:
[
{
text
:
this
.
$t
(
'
time_current_time
'
),
value
()
{
return
moment
().
toDate
()
data
()
{
return
{
options
:
{
shortcuts
:
[
{
text
:
'
当前时间
'
,
value
()
{
return
moment
().
toDate
()
},
},
},
{
text
:
this
.
$t
(
'
time_current_date
'
),
value
()
{
return
moment
(
moment
().
format
(
'
YYYY-MM-DD
'
)).
toDate
()
{
text
:
'
当前日期
'
,
value
()
{
return
moment
(
moment
().
format
(
'
YYYY-MM-DD
'
)).
toDate
()
},
},
},
{
text
:
this
.
$t
(
'
time_current_month_date
'
),
value
()
{
return
moment
(
moment
().
format
(
'
YYYY-MM-01
'
)).
toDate
()
{
text
:
'
当月日期
'
,
value
()
{
return
moment
(
moment
().
format
(
'
YYYY-MM-01
'
)).
toDate
()
},
},
},
{
text
:
this
.
$t
(
'
time_current_year_date
'
),
value
()
{
return
moment
(
moment
().
format
(
'
YYYY-01-01
'
)).
toDate
()
{
text
:
'
当年日期
'
,
value
()
{
return
moment
(
moment
().
format
(
'
YYYY-01-01
'
)).
toDate
()
},
},
},
],
},
poorUnit
:
[
{
v
:
'
years
'
,
n
:
this
.
$t
(
'
time_year
'
),
rate
:
0
},
{
v
:
'
months
'
,
n
:
this
.
$t
(
'
time_month
'
),
rate
:
0
},
{
v
:
'
weeks
'
,
n
:
this
.
$t
(
'
time_week
'
),
rate
:
1000
*
60
*
60
*
24
*
7
},
{
v
:
'
days
'
,
n
:
this
.
$t
(
'
time_day
'
),
rate
:
1000
*
60
*
60
*
24
},
{
v
:
'
hours
'
,
n
:
this
.
$t
(
'
time_hour
'
),
rate
:
1000
*
60
*
60
},
{
v
:
'
minutes
'
,
n
:
this
.
$t
(
'
time_minute
'
),
rate
:
1000
*
60
},
{
v
:
'
seconds
'
,
n
:
this
.
$t
(
'
time_second
'
),
rate
:
1000
},
],
current
:
{
poor
:
{
input1
:
moment
(
moment
().
format
(
'
YYYY-MM-DD
'
)).
toDate
(),
input2
:
moment
(
moment
().
format
(
'
YYYY-MM-DD
'
)).
add
(
1
,
'
d
'
).
toDate
(),
unit
:
'
seconds
'
,
],
},
duration
:
{
input
:
moment
(
moment
().
format
(
'
YYYY-MM-DD
'
)).
toDate
(),
unit
:
'
days
'
,
type
:
'
+
'
,
length
:
1
,
poorUnit
:
[
{
v
:
'
years
'
,
n
:
'
年
'
},
{
v
:
'
months
'
,
n
:
'
月
'
},
{
v
:
'
weeks
'
,
n
:
'
周
'
},
{
v
:
'
days
'
,
n
:
'
天
'
},
{
v
:
'
hours
'
,
n
:
'
小时
'
},
{
v
:
'
minutes
'
,
n
:
'
分钟
'
},
{
v
:
'
seconds
'
,
n
:
'
秒
'
},
],
current
:
{
poor
:
{
input1
:
moment
(
moment
().
format
(
'
YYYY-MM-DD
'
)).
toDate
(),
input2
:
moment
(
moment
().
format
(
'
YYYY-MM-DD
'
)).
add
(
1
,
'
d
'
).
toDate
(),
unit
:
'
seconds
'
,
},
duration
:
{
input
:
moment
(
moment
().
format
(
'
YYYY-MM-DD
'
)).
toDate
(),
unit
:
'
days
'
,
type
:
'
+
'
,
length
:
1
,
},
},
},
}
},
}
</
script
>
}
},
}
</
script
>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录