index.vue
4.96 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!-- 车辆管理 -->
<template>
<d2-container class="trafficManagement">
<el-form
:inline="true"
:model="searchForm"
label-width="85px"
slot="header"
>
<el-form-item label="车辆编号">
<el-input v-model="searchForm.trafficCode" placeholder="请输入车辆编号" clearable></el-input>
</el-form-item>
<el-form-item label="归属车辆段">
<el-select v-model="searchForm.stationCode" placeholder="请选择归属车辆段" clearable filterable>
<el-option v-for="(item, index) in baseData.station"
:key="index"
:value="item.confCode"
:label="item.confValue"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="维修承包商">
<el-input v-model="searchForm.merchantName" placeholder="请输入维修承包商" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" :id="tableParams.btnId">查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="车辆列表"><auth-button category="Button" :data="editFormReset"></auth-button></d2-table-header>
<d2-table
:searchForm="searchForm"
:tableParams="tableParams"
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
</d2-table>
<edit-dialog
:isVisible="editVisible"
:editForm="editForm"
:station="baseData.station"
@closeDialog="handleEditClose"
@confirmDialog="handleEditConfirm"
></edit-dialog>
</d2-container>
</template>
<script>
import EditDialog from './editDialog'
import { BaseData } from '@/common/constants'
import { getListApi, methods, editApi, removeApi } from '@api/trafficManagement'
import notice from '@/common/notice'
export default {
name: 'fimsTrafficManagement',
components: {
EditDialog
},
data() {
return {
// 新增/编辑弹窗
editVisible: false,
editFormReset: {
id: '',
trafficCode: '',
stationCode: '',
stationName: '',
merchantName: '',
openType: ''
},
editForm: {
id: '',
trafficCode: '',
stationCode: '',
stationName: '',
merchantName: '',
openType: ''
},
// 搜索
searchForm: {
trafficCode: '',
stationCode: '',
merchantName: '',
openType: ''
},
// 表格
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'trafficList',
tableOption: true,
tableColumns: [{
label: '车辆编号',
prop: 'trafficCode',
width: '120'
}, {
label: '归属车辆段',
prop: 'stationName',
minWidth: '220'
}, {
label: '维修承包商',
prop: 'merchantName',
minWidth: '220'
}, {
label: '接口开放',
prop: 'openType',
width: '80px',
formatter: (cellValue) => {
if (cellValue.openType) {
return {
1: '是',
2: '否'
}[cellValue.openType]
}
}
}]
},
baseData: {
station: []
},
getListApi: getListApi
}
},
mounted() {
this.loadBaseData()
},
methods: {
async loadBaseData() {
const data = await this.$store.dispatch('d2admin/base/get', BaseData.STATION.KEY)
this.baseData.station = data
},
editTraffic(value) {
// console.log(value)
const params = _.cloneDeep(this.editFormReset)
Object.keys(params).map(key => (params[key] = value[key]))
params.stationName = this.baseData.station.find(item => item.confCode === params.stationCode).confValue
!value.id ? delete params.id : delete params.trafficCode
params.method = value.id ? methods.Edit : methods.Add
// console.log(params)
editApi(params).then(res => {
this.handleEditClose()
notice.okTips()
}).catch(() => {
notice.errorTips()
})
},
/* 接口请求-end */
handleEditClose() {
this.editVisible = !this.editVisible
},
handleEditConfirm() {
var editParams = _.cloneDeep(this.editForm)
this.editTraffic(editParams)
},
// 表格-编辑
handleEdit(row) {
this.editForm = _.cloneDeep(row)
this.handleEditClose()
},
handleDelete(row) {
this.$confirm('确认删除?', '删除', {
comfirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
removeApi({
id: row.id,
usedStatus: 2
}).then(res => {
notice.okTips()
}).catch(() => {
notice.errorTips()
})
}).catch(() => {})
}
}
}
</script>
<style scoped>
</style>