index.vue
3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<template>
<el-drawer title="常用字段管理" :visible.sync="drawer" :wrapperClosable="false" size="700px"
class="NCC-common-drawer">
<div class="NCC-flex-main">
<div class="NCC-common-head">
<topOpts @add="addOrUpdateHandle()"></topOpts>
<div class="NCC-common-head-right">
<el-tooltip effect="dark" :content="$t('common.refresh')" placement="top">
<el-link icon="icon-ym icon-ym-Refresh
NCC-common-head-icon" :underline="false" @click="initData()" />
</el-tooltip>
</div>
</div>
<NCC-table v-loading="listLoading" :data="list">
<el-table-column prop="field" label="列名" />
<el-table-column prop="fieldName" label="说明" width="110px" />
<el-table-column prop="dataType" label="类型" width="80px">
<template slot-scope="scope">
{{ scope.row.dataType | getTypeText(options) }}
</template>
</el-table-column>
<el-table-column prop="dataLength" label="长度" width="60px" />
<el-table-column prop="allowNull" label="允许空" width="60px" align="center">
<template slot-scope="scope">
<el-checkbox :value='scope.row.allowNull===1' />
</template>
</el-table-column>
<el-table-column label="操作" width="100">
<template slot-scope="scope">
<tableOpts @edit="addOrUpdateHandle(scope.row.id)"
@del="handleDel(scope.row.id,scope.$index)">
</tableOpts>
</template>
</el-table-column>
</NCC-table>
<Form v-if="formVisible" ref="Form" @refreshDataList="initData" />
</div>
</el-drawer>
</template>
<script>
import { getList, Delete } from '@/api/systemData/commonFields'
import Form from './Form'
export default {
components: { Form },
data() {
return {
drawer: false,
listLoading: false,
formVisible: false,
list: [],
options: [
{ label: '字符串', value: 'varchar' },
{ label: '整型', value: 'int' },
{ label: '日期时间', value: 'datetime' },
{ label: '浮点', value: 'decimal' },
{ label: '长整型', value: 'bigint' },
{ label: '文本', value: 'text' }
]
}
},
filters: {
getTypeText(type, options) {
let item = options.filter(o => o.value == type)[0]
return item && item.label ? item.label : ''
}
},
methods: {
init() {
this.drawer = true
this.$nextTick(() => {
this.initData()
})
},
initData() {
this.list = []
this.listLoading = true
getList().then(res => {
this.list = res.data.list
this.listLoading = false
}).catch(() => {
this.listLoading = false
})
},
addOrUpdateHandle(id) {
this.formVisible = true
this.$nextTick(() => {
this.$refs.Form.init(id)
})
},
handleDel(id, index) {
Delete(id).then(res => {
this.$message({
type: 'success',
message: res.msg,
duration: 1000,
onClose: () => {
this.list.splice(index, 1);
}
})
})
}
}
}
</script>