haiwei-module-common 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +2 -0
- package/.eslintrc.js +18 -0
- package/.prettierrc +6 -0
- package/.vscode/settings.json +10 -0
- package/babel.config.js +10 -0
- package/package.json +41 -0
- package/postcss.config.js +5 -0
- package/script/npm_install.bat +4 -0
- package/script/npm_install.ps1 +10 -0
- package/script/npm_publish.bat +4 -0
- package/script/npm_publish.ps1 +10 -0
- package/script/npm_update.bat +4 -0
- package/script/npm_update.ps1 +10 -0
- package/src/api/components/area.js +22 -0
- package/src/api/components/attachment.js +30 -0
- package/src/api/components/dict.js +24 -0
- package/src/api/components/dictGroup.js +17 -0
- package/src/api/components/dictItem.js +10 -0
- package/src/api/components/mediaType.js +10 -0
- package/src/api/index.js +11 -0
- package/src/components/area-select/index.vue +147 -0
- package/src/components/area-select/item.vue +85 -0
- package/src/components/attachment-download/index.vue +70 -0
- package/src/components/attachment-img/index.vue +58 -0
- package/src/components/attachment-upload-img/index.vue +244 -0
- package/src/components/attachment-upload-single/index.vue +143 -0
- package/src/components/ccdieet-upload/index_.vue +51 -0
- package/src/components/config-common/index.vue +41 -0
- package/src/components/dict-checkbox/index.vue +29 -0
- package/src/components/dict-radio/index.vue +29 -0
- package/src/components/dict-select/index.vue +29 -0
- package/src/components/dict-tree/index.vue +97 -0
- package/src/components/index.js +10 -0
- package/src/components/upload-mixins.js +118 -0
- package/src/config/index.js +11 -0
- package/src/index.js +23 -0
- package/src/main.js +9 -0
- package/src/module.js +10 -0
- package/src/routes/index.js +3 -0
- package/src/store/index.js +3 -0
- package/src/views/area/components/cascader/index.vue +16 -0
- package/src/views/area/components/save/index.vue +96 -0
- package/src/views/area/index/cols.js +47 -0
- package/src/views/area/index/index.vue +126 -0
- package/src/views/area/index/page.js +42 -0
- package/src/views/attachment/index/cols.js +59 -0
- package/src/views/attachment/index/index.vue +60 -0
- package/src/views/attachment/index/page.js +36 -0
- package/src/views/dict/components/save/index.vue +63 -0
- package/src/views/dict/index/cols.js +35 -0
- package/src/views/dict/index/index.vue +79 -0
- package/src/views/dict/index/page.js +49 -0
- package/src/views/dictGroup/components/save/index.vue +57 -0
- package/src/views/dictGroup/components/select/index.vue +14 -0
- package/src/views/dictGroup/index/cols.js +36 -0
- package/src/views/dictGroup/index/index.vue +67 -0
- package/src/views/dictGroup/index/page.js +42 -0
- package/src/views/dictItem/components/extend-editor/index.vue +57 -0
- package/src/views/dictItem/components/index/cols.js +40 -0
- package/src/views/dictItem/components/index/index.vue +86 -0
- package/src/views/dictItem/components/save/index.vue +94 -0
- package/src/views/dictItem/components/tree/index.vue +133 -0
- package/src/views/dictItem/index.vue +51 -0
- package/src/views/mediaType/components/save/index.vue +45 -0
- package/src/views/mediaType/index/cols.js +16 -0
- package/src/views/mediaType/index/index.vue +55 -0
- package/src/views/mediaType/index/page.js +42 -0
- package/vue.config.js +108 -0
package/.browserslistrc
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
node: true
|
|
5
|
+
},
|
|
6
|
+
extends: ['plugin:vue/essential', '@vue/prettier'],
|
|
7
|
+
rules: {
|
|
8
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
9
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
|
|
10
|
+
},
|
|
11
|
+
parserOptions: {
|
|
12
|
+
parser: 'babel-eslint'
|
|
13
|
+
},
|
|
14
|
+
globals: {
|
|
15
|
+
$http: 'readonly',
|
|
16
|
+
$api: 'readonly'
|
|
17
|
+
}
|
|
18
|
+
}
|
package/.prettierrc
ADDED
package/babel.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": 1,
|
|
3
|
+
"name": "haiwei-module-common",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"code": "common",
|
|
6
|
+
"title": "通用模块",
|
|
7
|
+
"description": "通用模块",
|
|
8
|
+
"main": "src/index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"serve": "vue-cli-service serve",
|
|
11
|
+
"build": "vue-cli-service build",
|
|
12
|
+
"lint": "vue-cli-service lint",
|
|
13
|
+
"dev": "cd ../../WebHost && dotnet watch run",
|
|
14
|
+
"cm": "rimraf node_modules",
|
|
15
|
+
"cc": "rimraf node_modules/.cache",
|
|
16
|
+
"i": "cd ./script && npm_install.bat",
|
|
17
|
+
"up": "cd ./script && npm_update.bat",
|
|
18
|
+
"pub": "cd ./script && npm_publish.bat"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"haiwei-module-admin": "^1.0.1",
|
|
22
|
+
"haiwei-ui": "^1.0.2"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@vue/cli-plugin-babel": "^4.4.1",
|
|
26
|
+
"@vue/cli-plugin-eslint": "^4.4.1",
|
|
27
|
+
"@vue/cli-plugin-router": "^4.4.1",
|
|
28
|
+
"@vue/cli-plugin-vuex": "^4.4.1",
|
|
29
|
+
"@vue/cli-service": "^4.4.1",
|
|
30
|
+
"@vue/eslint-config-prettier": "^5.0.0",
|
|
31
|
+
"babel-eslint": "^10.1.0",
|
|
32
|
+
"eslint": "^5.16.0",
|
|
33
|
+
"eslint-plugin-prettier": "^3.1.3",
|
|
34
|
+
"eslint-plugin-vue": "^5.0.0",
|
|
35
|
+
"prettier": "^1.18.2",
|
|
36
|
+
"rimraf": "^3.0.2",
|
|
37
|
+
"sass": "^1.26.8",
|
|
38
|
+
"sass-loader": "^8.0.2",
|
|
39
|
+
"vue-template-compiler": "^2.6.11"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# 切换到项目根目录
|
|
2
|
+
Set-Location ..
|
|
3
|
+
|
|
4
|
+
# 使用淘宝镜像安装依赖(加速下载)
|
|
5
|
+
Write-Host "Installing dependencies using Taobao mirror..." -ForegroundColor Green
|
|
6
|
+
npm --registry https://registry.npmmirror.com/ install
|
|
7
|
+
|
|
8
|
+
# 等待用户按键
|
|
9
|
+
Write-Host "Dependencies installation completed. Press any key to continue..." -ForegroundColor Green
|
|
10
|
+
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# 切换到项目根目录
|
|
2
|
+
Set-Location ..
|
|
3
|
+
|
|
4
|
+
# 发布到 npm 官方仓库
|
|
5
|
+
Write-Host "Publishing to npm official registry..." -ForegroundColor Green
|
|
6
|
+
npm --registry https://registry.npmjs.org/ publish
|
|
7
|
+
|
|
8
|
+
# 等待用户按键
|
|
9
|
+
Write-Host "Publishing completed. Press any key to continue..." -ForegroundColor Green
|
|
10
|
+
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# 切换到项目根目录
|
|
2
|
+
Set-Location ..
|
|
3
|
+
|
|
4
|
+
# 使用淘宝镜像更新依赖(加速下载)
|
|
5
|
+
Write-Host "Updating dependencies using Taobao mirror..." -ForegroundColor Green
|
|
6
|
+
npm --registry https://registry.npmmirror.com/ update
|
|
7
|
+
|
|
8
|
+
# 等待用户按键
|
|
9
|
+
Write-Host "Dependencies update completed. Press any key to continue..." -ForegroundColor Green
|
|
10
|
+
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import module from '../../module'
|
|
2
|
+
|
|
3
|
+
export default name => {
|
|
4
|
+
const root = `${module.code}/${name}/`
|
|
5
|
+
const crud = $http.crud(root)
|
|
6
|
+
|
|
7
|
+
const urls = {
|
|
8
|
+
queryChildren: root + 'QueryChildren'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description 查询子节点
|
|
13
|
+
*/
|
|
14
|
+
const queryChildren = parentCode => {
|
|
15
|
+
return $http.get(urls.queryChildren, { parentCode })
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
...crud,
|
|
20
|
+
queryChildren
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import module from '../../module'
|
|
2
|
+
|
|
3
|
+
export default name => {
|
|
4
|
+
const root = `${module.code}/${name}/`
|
|
5
|
+
const crud = $http.crud(root)
|
|
6
|
+
const urls = {
|
|
7
|
+
upload: root + 'Upload',
|
|
8
|
+
download: root + 'Download/'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const getUploadUrl = () => {
|
|
12
|
+
return $http.axios.defaults.baseURL + urls.upload
|
|
13
|
+
}
|
|
14
|
+
// 下载
|
|
15
|
+
const download = id => {
|
|
16
|
+
return $http.download(urls.download + id)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 预览
|
|
20
|
+
const preview = id => {
|
|
21
|
+
return $http.preview(urls.download + id)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
...crud,
|
|
26
|
+
getUploadUrl,
|
|
27
|
+
download,
|
|
28
|
+
preview
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import module from '../../module'
|
|
2
|
+
|
|
3
|
+
export default name => {
|
|
4
|
+
const root = `${module.code}/${name}/`
|
|
5
|
+
const crud = $http.crud(root)
|
|
6
|
+
const urls = {
|
|
7
|
+
select: root + 'Select',
|
|
8
|
+
tree: root + 'Tree'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const select = params => {
|
|
12
|
+
return $http.get(urls.select, params)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const tree = params => {
|
|
16
|
+
return $http.get(urls.tree, params)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
...crud,
|
|
21
|
+
select,
|
|
22
|
+
tree
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import module from '../../module'
|
|
2
|
+
|
|
3
|
+
export default name => {
|
|
4
|
+
const root = `${module.code}/${name}/`
|
|
5
|
+
const crud = $http.crud(root)
|
|
6
|
+
const urls = {
|
|
7
|
+
select: root + 'Select'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const select = () => {
|
|
11
|
+
return $http.get(urls.select)
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
...crud,
|
|
15
|
+
select
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/api/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import module from '../module'
|
|
2
|
+
|
|
3
|
+
let apis = {}
|
|
4
|
+
const requireComponent = require.context('./components', true, /\.*\.js$/)
|
|
5
|
+
requireComponent.keys().map(fileName => {
|
|
6
|
+
const name = fileName.replace('./', '').replace('.js', '')
|
|
7
|
+
const func = requireComponent(fileName).default
|
|
8
|
+
apis[name] = func(name)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
$api[module.code] = apis
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section class="nm-area-select-box">
|
|
3
|
+
<el-row :gutter="gutter">
|
|
4
|
+
<item ref="l1" :level="1" :show="province.show" :disabled="province.disabled" v-model="value_.province" :span="span" parent-code="0" />
|
|
5
|
+
<item ref="l2" :level="2" :show="city.show" :disabled="city.disabled" v-model="value_.city" :span="span" :parent-code="value_.province.code" />
|
|
6
|
+
<item ref="l3" :level="3" :show="area.show" :disabled="area.disabled" v-model="value_.area" :span="span" :parent-code="value_.city.code" />
|
|
7
|
+
<item ref="l4" :level="4" :show="town.show" :disabled="town.disabled" v-model="value_.town" :span="span" :parent-code="value_.area.code" />
|
|
8
|
+
</el-row>
|
|
9
|
+
</section>
|
|
10
|
+
</template>
|
|
11
|
+
<script>
|
|
12
|
+
import assist from 'haiwei-ui/packages/utils/assist'
|
|
13
|
+
import Item from './item'
|
|
14
|
+
// 默认值
|
|
15
|
+
const defaultValue = {
|
|
16
|
+
province: {
|
|
17
|
+
name: '',
|
|
18
|
+
code: ''
|
|
19
|
+
},
|
|
20
|
+
city: {
|
|
21
|
+
name: '',
|
|
22
|
+
code: ''
|
|
23
|
+
},
|
|
24
|
+
area: {
|
|
25
|
+
name: '',
|
|
26
|
+
code: ''
|
|
27
|
+
},
|
|
28
|
+
town: {
|
|
29
|
+
name: '',
|
|
30
|
+
code: ''
|
|
31
|
+
},
|
|
32
|
+
/** 完整名称 */
|
|
33
|
+
fullName: ''
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
components: { Item },
|
|
38
|
+
data() {
|
|
39
|
+
return {
|
|
40
|
+
levelList: ['province', 'city', 'area', 'town'],
|
|
41
|
+
value_: [],
|
|
42
|
+
initValue: []
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
props: {
|
|
46
|
+
value: {
|
|
47
|
+
type: Object,
|
|
48
|
+
default() {
|
|
49
|
+
return defaultValue
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
level: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: '1234',
|
|
55
|
+
validator(val) {
|
|
56
|
+
return ['1234', '123', '12', '1', '234', '23', '2', '34', '3', '4'].indexOf(val) !== -1
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
disabledList: {
|
|
60
|
+
type: String
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* 下拉框的间隔
|
|
64
|
+
*/
|
|
65
|
+
gutter: {
|
|
66
|
+
type: Number,
|
|
67
|
+
default: 10
|
|
68
|
+
},
|
|
69
|
+
/** 是否可搜索 */
|
|
70
|
+
filterable: Boolean,
|
|
71
|
+
/** 完整名称中间的分隔符 */
|
|
72
|
+
separator: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: ''
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
computed: {
|
|
78
|
+
province() {
|
|
79
|
+
return this.getOptions('1')
|
|
80
|
+
},
|
|
81
|
+
city() {
|
|
82
|
+
return this.getOptions('2')
|
|
83
|
+
},
|
|
84
|
+
area() {
|
|
85
|
+
return this.getOptions('3')
|
|
86
|
+
},
|
|
87
|
+
town() {
|
|
88
|
+
return this.getOptions('4')
|
|
89
|
+
},
|
|
90
|
+
// 间隔
|
|
91
|
+
span() {
|
|
92
|
+
return 24 / this.level.length
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
methods: {
|
|
96
|
+
init() {
|
|
97
|
+
this.initValue = Object.assign({}, assist.deepCopy(defaultValue), assist.deepCopy(this.value))
|
|
98
|
+
},
|
|
99
|
+
getOptions(level) {
|
|
100
|
+
return {
|
|
101
|
+
show: this.level.indexOf(level) > -1,
|
|
102
|
+
disabled: this.disabledList ? this.disabledList.indexOf(level) > -1 : false
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
reset() {
|
|
106
|
+
// 重置为默认值
|
|
107
|
+
this.value_ = Object.assign({}, assist.deepCopy(this.initValue))
|
|
108
|
+
},
|
|
109
|
+
resetChild(level) {
|
|
110
|
+
this.$refs['l' + level].reset_()
|
|
111
|
+
},
|
|
112
|
+
onChange() {
|
|
113
|
+
let val = { fullName: '' }
|
|
114
|
+
for (let i = 0; i < this.level.length; i++) {
|
|
115
|
+
let prop = this.levelList[i]
|
|
116
|
+
if (this[prop].show) {
|
|
117
|
+
val[prop] = this.value_[prop]
|
|
118
|
+
}
|
|
119
|
+
if (val[prop].name) {
|
|
120
|
+
val.fullName += val[prop].name + this.separator
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (val.fullName) {
|
|
124
|
+
val.fullName = val.fullName.substring(0, val.fullName.length)
|
|
125
|
+
}
|
|
126
|
+
this.$emit('input', val)
|
|
127
|
+
this.$emit('change', val)
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
mounted() {
|
|
131
|
+
this.init()
|
|
132
|
+
},
|
|
133
|
+
watch: {
|
|
134
|
+
value: {
|
|
135
|
+
immediate: true,
|
|
136
|
+
handler() {
|
|
137
|
+
this.value_ = Object.assign({}, assist.deepCopy(defaultValue), assist.deepCopy(this.value))
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
</script>
|
|
143
|
+
<style lang="scss">
|
|
144
|
+
.nm-area-select-box {
|
|
145
|
+
overflow: hidden;
|
|
146
|
+
}
|
|
147
|
+
</style>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-col v-if="show" :span="span">
|
|
3
|
+
<el-select v-model="value_.code" :size="fontSize" :filterable="filterable" :disabled="disabled" @change="onChange">
|
|
4
|
+
<el-option v-for="item in list" :key="item.value" :label="item.label" :value="item.value"></el-option>
|
|
5
|
+
</el-select>
|
|
6
|
+
</el-col>
|
|
7
|
+
</template>
|
|
8
|
+
<script>
|
|
9
|
+
export default {
|
|
10
|
+
data() {
|
|
11
|
+
return {
|
|
12
|
+
value_: this.value,
|
|
13
|
+
list: []
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
props: {
|
|
17
|
+
value: Object,
|
|
18
|
+
level: Number,
|
|
19
|
+
parentCode: String,
|
|
20
|
+
show: Boolean,
|
|
21
|
+
filterable: Boolean,
|
|
22
|
+
disabled: Boolean,
|
|
23
|
+
span: Number
|
|
24
|
+
},
|
|
25
|
+
methods: {
|
|
26
|
+
async query() {
|
|
27
|
+
this.list = []
|
|
28
|
+
|
|
29
|
+
if (this.parentCode) {
|
|
30
|
+
let data = await $api.common.area.queryChildren(this.parentCode)
|
|
31
|
+
this.list = data.map(item => {
|
|
32
|
+
return {
|
|
33
|
+
label: item.name,
|
|
34
|
+
value: item.code
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// 重新查询数据后,设置下当前选中地区的名称
|
|
39
|
+
this.setName()
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
onChange(code) {
|
|
43
|
+
const option = this.list.find(m => m.value === code)
|
|
44
|
+
if (option) {
|
|
45
|
+
this.value_ = { name: option.label, code: option.value }
|
|
46
|
+
} else {
|
|
47
|
+
this.value_ = { name: '', code: '' }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
this.$emit('input', this.value_)
|
|
51
|
+
|
|
52
|
+
if (this.level === 4) {
|
|
53
|
+
this.$parent.$parent.onChange()
|
|
54
|
+
} else {
|
|
55
|
+
this.$parent.$parent.resetChild(this.level + 1)
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
reset_() {
|
|
59
|
+
this.value_ = { name: '', code: '' }
|
|
60
|
+
this.onChange()
|
|
61
|
+
},
|
|
62
|
+
// 设置名称
|
|
63
|
+
setName() {
|
|
64
|
+
if (this.value_.code) {
|
|
65
|
+
const option = this.list.find(m => m.value === this.value_.code)
|
|
66
|
+
if (option) {
|
|
67
|
+
this.value_.name = option.label
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
watch: {
|
|
73
|
+
'value.code'(val) {
|
|
74
|
+
this.value_.code = val
|
|
75
|
+
this.setName()
|
|
76
|
+
},
|
|
77
|
+
parentCode() {
|
|
78
|
+
this.query()
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
mounted() {
|
|
82
|
+
this.query()
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
</script>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-button
|
|
3
|
+
class="nm-button"
|
|
4
|
+
:type="type"
|
|
5
|
+
:size="size || fontSize"
|
|
6
|
+
:plain="plain"
|
|
7
|
+
:round="round"
|
|
8
|
+
:circle="circle"
|
|
9
|
+
:loading="loading"
|
|
10
|
+
:disabled="disabled"
|
|
11
|
+
:autofocus="autofocus"
|
|
12
|
+
:native-type="nativeType"
|
|
13
|
+
v-nm-has="code"
|
|
14
|
+
@click="onClick"
|
|
15
|
+
>
|
|
16
|
+
<nm-icon v-if="!loading && icon" :name="icon" />
|
|
17
|
+
<slot>
|
|
18
|
+
<span v-if="!circle && text" class="nm-button-text" v-html="text" />
|
|
19
|
+
</slot>
|
|
20
|
+
</el-button>
|
|
21
|
+
</template>
|
|
22
|
+
<script>
|
|
23
|
+
const { download } = $api.common.attachment
|
|
24
|
+
|
|
25
|
+
export default {
|
|
26
|
+
name: 'Button',
|
|
27
|
+
props: {
|
|
28
|
+
/** 尺寸,默认按照框架的字号设置 */
|
|
29
|
+
size: String,
|
|
30
|
+
/** 类型 primary/success/warning/danger/info/text */
|
|
31
|
+
type: String,
|
|
32
|
+
/** 是否朴素按钮 */
|
|
33
|
+
plain: Boolean,
|
|
34
|
+
/** 是否圆角按钮 */
|
|
35
|
+
round: Boolean,
|
|
36
|
+
/** 是否圆形按钮 */
|
|
37
|
+
circle: Boolean,
|
|
38
|
+
/** 是否加载中状态 */
|
|
39
|
+
loading: Boolean,
|
|
40
|
+
/** 是否禁用状态 */
|
|
41
|
+
disabled: Boolean,
|
|
42
|
+
/** 是否默认聚焦 */
|
|
43
|
+
autofocus: Boolean,
|
|
44
|
+
/** 原生 type 属性 button/submit/reset */
|
|
45
|
+
nativeType: String,
|
|
46
|
+
/** 图标 */
|
|
47
|
+
icon: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: 'download'
|
|
50
|
+
},
|
|
51
|
+
// 文本
|
|
52
|
+
text: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: '下载'
|
|
55
|
+
},
|
|
56
|
+
// 按钮编码,用于按钮权限控制
|
|
57
|
+
code: String,
|
|
58
|
+
//附件ID
|
|
59
|
+
id: {
|
|
60
|
+
type: String,
|
|
61
|
+
required: true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
methods: {
|
|
65
|
+
onClick() {
|
|
66
|
+
download(this.id)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
</script>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :style="{ width, height }" class="nm-attachment-img-preview">
|
|
3
|
+
<img v-if="url" :src="url" />
|
|
4
|
+
<nm-icon class="no-picture" v-else name="photo" />
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
<script>
|
|
8
|
+
// 接口
|
|
9
|
+
const api = $api.common.attachment
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
data() {
|
|
13
|
+
return {
|
|
14
|
+
url: ''
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
id: {
|
|
19
|
+
type: String
|
|
20
|
+
},
|
|
21
|
+
width: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: 'auto'
|
|
24
|
+
},
|
|
25
|
+
height: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: 'auto'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
methods: {
|
|
31
|
+
get() {
|
|
32
|
+
if (this.id) {
|
|
33
|
+
api.preview(this.id).then(url => {
|
|
34
|
+
this.url = url
|
|
35
|
+
})
|
|
36
|
+
} else {
|
|
37
|
+
this.url = ''
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
mounted() {
|
|
42
|
+
this.get()
|
|
43
|
+
},
|
|
44
|
+
watch: {
|
|
45
|
+
id() {
|
|
46
|
+
this.get()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
<style lang="scss">
|
|
52
|
+
.nm-attachment-img-preview {
|
|
53
|
+
display: block;
|
|
54
|
+
img {
|
|
55
|
+
width: 100%;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
</style>
|