ContractParameterModal.vue
4.33 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
<template>
<a-modal :title="title" :width="1000" :centered='true' :visible="visible" :confirmLoading="confirmLoading" @ok="handleSubmit" @cancel="handleCancel" :maskClosable="false" cancelText="关闭" style="top:20px;">
<a-table rowKey="id" v-if="lookShow==1" :columns="columns" :dataSource="dataSource" :pagination="false" :disabled="true" />
<a-table rowKey="id" v-else-if="lookShow==2" :rowSelection="rowSelection" :columns="columns" :dataSource="dataSource" :pagination="false" :disabled="true" />
</a-modal>
</template>
<script>
import { postAction,getAction } from '@/api/configApi'
export default {
name: "PasswordModal",
data () {
return {
lookShow: 3, // 解决缓存
visible: false,
title: '',
confirmLoading: false,
columns: [
{
title: '参数编号',
dataIndex: 'contractParamNo',
},
{
title: '参数描述',
dataIndex: 'deacription',
},
{
title: '参数替代符标识',
dataIndex: 'dynamicVariable',
},
],
model: {},
dataSource: [],
selectData: [],
selectedRows: [],
selectedRowKeys: [],
concatData: [],
}
},
created () {
console.log("created");
},
computed: {
rowSelection () {
const { selectedRowKeys } = [];
return {
onChange: (selectedRowKeys, selectedRows) => {
this.selectedRowKeys = selectedRowKeys;
this.selectedRows = selectedRows;
},
onSelect: (record) => {
this.selectData.map(v => {
if (record.select && v.id == record.id) {
v.deleteFlag = !v.deleteFlag
}
})
this.concatData = this.setArrObj(this.selectedRows.concat(this.selectData))
console.log(this.concatData)
},
onSelectAll: (selected) => {
this.selectData.map(v => {
v.deleteFlag = !selected
})
this.concatData = this.setArrObj(this.selectedRows.concat(this.selectData))
console.log(this.concatData)
},
onSelectInvert: (selected) => {
this.selectData.map(v => {
v.deleteFlag = !selected
})
this.concatData = this.setArrObj(this.selectedRows.concat(this.selectData))
console.log(this.concatData)
},
getCheckboxProps: record => (
console.log(record.select), {
props: {
defaultChecked: record.select === true,
},
}),
};
},
},
watch: {
lookShow (val) {
this.lookShow = val
}
},
methods: {
edit (record, type, recordNo) { // recordType => 类型 type 1.查看 2.增加 3.修改 recordNo =>编号
console.log(record)
this.lookShow = 2
this.dataSource = record
this.selectData = this.dataSource.filter((item) => { // 修改已选中带过来的数据
return item.select
})
this.concatData = this.selectData
if (type == 1) {
this.lookShow = 1
let _p = '/config/admin/queryContractParam?contractTemplateNo=' + recordNo;
getAction(_p).then(res => {
console.log(res)
if (res.status.statusCode == 0) {
this.dataSource = res.result
console.log(this.selectData)
} else {
this.$message.warning(res.status.statusReason);
}
})
}
type == 1 ? this.lookShow = true : false;
this.visible = true;
},
close () {
this.$emit('close');
this.visible = false;
this.disableSubmit = false;
this.selectedRole = [];
},
handleSubmit () {
let contractParamList = [];
this.concatData.map(v => {
if (v.deleteFlag) {
contractParamList.push({ 'contractParamNo': v.contractParamNo, 'deleteFlag': 1 })
} else {
contractParamList.push({ 'contractParamNo': v.contractParamNo })
}
})
console.log(contractParamList)
this.lookShow = 3;
this.$emit('transmitData', contractParamList);
this.visible = false;
},
handleCancel () {
this.lookShow = 3;
this.close()
},
setArrObj (data) {
let obj = {};
return data.reduce((cur, next) => {
obj[next.id] ? "" : obj[next.id] = true && cur.push(next);
return cur;
}, [])
},
}
}
</script>