+
@@ -66,8 +75,8 @@ export default {
return {
formModal: false,
btnOptionList: [
- { label: '新增', icon: 'icon-tianjia', type: 'add' },
- { label: '删除', icon: 'icon-tianjia', type: 'del' }
+ { label: '新增', icon: 'icon-tianjia', type: 'add' }
+ // { label: '删除', icon: 'icon-tianjia', type: 'del' }
],
columns: [
{
@@ -125,15 +134,17 @@ export default {
}
],
tableData: [],
- tableOption: {},
+ tableOption: {
+ select:false
+ },
pageOption: {
- page: 0,
+ page: 1,
pageSize: 10,
- total: 0
+ count: 0
},
tableH: '',
formState: {},
- formStatus:'add',//表单状态辑状态 add:新增 edit:编辑
+ formStatus: 'add' //表单状态辑状态 add:新增 edit:编辑
}
},
mounted() {
@@ -148,13 +159,12 @@ export default {
})
console.log(res)
this.tableData = res.data
- this.total = res.count
+ this.pageOption.count = res.count
} catch (error) {
console.log(error)
}
},
getPolicyType(type) {
-
return policyTypes.find((item) => item.value == type)?.label || ''
},
@@ -162,7 +172,8 @@ export default {
console.log(data)
},
operateForm(type, record = {}) {
-
+ console.log(type, record)
+
this.formStatus = type
switch (type) {
case 'add':
@@ -173,16 +184,45 @@ export default {
this.formModal = true
this.formState = record
break
-
+ case 'del':
+ this.handleDelete(record)
+ break
+ case 'edit':
+ this.formModal = true
+ this.formState = record
+ break
default:
break
}
},
- closeModal(){
+ async handleDelete(record) {
+ try {
+ const res = await getReq('/deletePolicy', {
+ policy_id: record['policy_id']
+ })
+ if (res.errcode == 0) {
+ this.$message.success('删除成功')
+ this.getTableList()
+ }
+ } catch (error) {
+ this.$message.success(error)
+ }
+ },
+ closeModal(flag = false) {
this.formModal = false
+ if (flag) {
+ this.pageOption.page = 1
+ this.getTableList()
+ }
},
handlePagesizeChange(data) {
- console.log(data)
+ if (data.pageSize !== this.pageOption.pageSize) {
+ this.pageOption.page = 1
+ } else {
+ this.pageOption.page = data.page
+ }
+ this.pageOption.pageSize = data.pageSize
+ this.getTableList()
}
}
}