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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
| <template>
| <div>
| <basic-container>
| <avue-crud
| :data="list"
| style="width:98%"
| :option="option"
| :page="page"
| @row-save="saveTemplate"
| @current-change="currentChange"
| @size-change="sizeChange">
| <template slot="state" slot-scope="scope">
| <el-tag :type="scope.row.state ? 'success':'danger'">{{scope.row.state ? '启用':'禁用'}}</el-tag>
| </template>
| <template slot="stateForm" slot-scope="scope">
| <el-switch
| v-model="scope.row.state"
| active-color="#13ce66"
| :active-value="true"
| :inactive-value="false">
| </el-switch>
| </template>
| <template #menu="{size,row,index}">
| <el-button class="menu-button" :size="size" @click="showInspectDialog(size,row,index)" type="text" icon="el-icon-set-up">检验项</el-button>
| <el-button class="menu-button" :size="size" @click="updateTemplate(size,row,index)" type="text" icon="el-icon-edit">编辑</el-button>
| <el-button class="menu-button" :size="size" @click="deleteTemplate(size,row,index)" type="text" icon="el-icon-delete">删除</el-button>
| </template>
| </avue-crud>
| </basic-container>
| <el-dialog
| title="编辑模板信息"
| :visible.sync="updateDialog"
| width="40%">
| <el-form :model="updateData" label-width="100px" :inline="true"
| label-position="right" ref="updateTemplate" :rules="updateRules">
| <el-form-item label="模板名称" prop="templateName">
| <el-input v-model="updateData.templateName" placeholder="请输入模板名称"></el-input>
| </el-form-item>
| <el-form-item label="是否启用" prop="state">
| <el-switch
| v-model="updateData.state"
| active-color="#13ce66"
| :active-value="true"
| :inactive-value="false">
| </el-switch>
| </el-form-item>
| </el-form>
| <span slot="footer" class="dialog-footer">
| <el-button type="primary" icon="el-icon-circle-plus-outline" @click="confirmUpdate">保 存</el-button>
| <el-button icon="el-icon-remove-outline" @click="updateDialog = false">取 消</el-button>
| </span>
| </el-dialog>
| <inspectDetail v-if="isShow" :paramObj="paramObj" :currshowlist.sync="showDetail"></inspectDetail>
| </div>
| </template>
| <script>
| import inspectDetail from './inspect-detail'
| import {getList,addTemplate,updateTemplate,delTemplate} from '@/api/quality/packageInspectTemp'
| export default {
| data(){
| return {
| isShow: false,
| paramObj:{
| id: null,
| },
| showDetail: false,
| updateData:{
| templateName: null,
| state: null,
| },
| updateRules:{
| templateName:[{required:true,message:'请输入模板名称',trigger:'blur'}]
| },
| updateDialog: false,
| list: [],
| page:{
| currentPage: 1,
| pageSize: 20,
| total: 0
| },
| option: {
| dialogWidth: '40%',
| menu: true,
| addBtn: true,
| editBtn: false,
| delBtn: false,
| border: true,
| index: true,
| height: 400,
| indexLabel: '序号',
| align: 'center',
| refreshBtn: false,
| columnBtn: false, // 是否显示显影按钮H
| headerAlign: 'center',
| column: [{
| label: '模板名称',
| prop: 'templateName',
| overHidden: true,
| rules:[{required:true,message:'模板名称不能为空',trigger:'blur'}]
| }, {
| label: '是否启用',
| prop: 'state',
| overHidden: true,
| slot: true,
| formslot: true,
| value: true,
| }]
| }
| }
| },
| created(){
| this.getDataList()
| },
| components:{
| inspectDetail
| },
| methods:{
| deleteTemplate(size,row,index){
| const _than = this
| this.$confirm('此操作将永久删除该模板, 是否继续?', '提示', {
| confirmButtonText: '确定',
| cancelButtonText: '取消',
| type: 'warning'
| }).then(() => {
| delTemplate(row.id).then(res=>{
| if(res.status===200){
| _than.$message.success("删除成功")
| _than.getDataList()
| }
| }).catch(error=>{
| console.error(error)
| })
| }).catch(() => {});
| },
| showInspectDialog(size,row,index){
| this.paramObj.id = row.id
| this.isShow = true
| this.$nextTick(()=>{
| this.showDetail = true
| })
| },
| updateTemplate(size,row,index){
| console.log(row);
| this.updateData = JSON.parse(JSON.stringify(row))
| this.updateDialog =true
| },
| confirmUpdate(){
| const _than = this
| this.$refs.updateTemplate.validate(valid=>{
| if(valid){
| let data = {
| id:this.updateData.id,
| templateName:this.updateData.templateName,
| state:this.updateData.state
| }
| updateTemplate(data).then(res=>{
| if(res.status===200){
| _than.$message.success("更新成功")
| _than.getDataList()
| _than.updateDialog = false
| }
| }).catch(error=>{
| console.error(error)
| })
| }
| })
| },
| saveTemplate(row, done, loading){
| addTemplate(row).then(res=>{
| if(res.status===200){
| this.$message.success("添加成功")
| this.getDataList()
| }
| }).catch(error=>{
| console.error(error)
| })
| setTimeout(()=>{
| done()
| },1000)
| },
| sizeChange(pageSize) {
| this.page.pageSize = pageSize;
| this.getList();
| },
| currentChange(currentPage) {
| this.page.currentPage = currentPage;
| this.getList();
| },
| getDataList() {
| getList({
| current: this.page.currentPage,
| size: this.page.pageSize,
| templateType: '0'
| }).then(res=>{
| if(res.status===200){
| this.list = res.data.data.records
| this.page.total = res.data.data.total
| }
| }).catch(error=>{
| console.error(error)
| })
| },
| }
| }
| </script>
|
| <style scoped>
| .menu-button{
| margin: 0px 5px;
| }
| </style>
|
|