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
<template>
<div class="container">
<div class="search-form">
<el-button type="success" size="small" plain icon="el-icon-plus" @click="add">新增</el-button>
</div>
<div class="table-form">
<el-table :data="dataList" size="mini" style="width: 100%">
<el-table-column prop="contract_number" label="合同协议编号"></el-table-column>
<el-table-column prop="contract_name" label="合同协议名称"></el-table-column>
<el-table-column prop="contract_type" label="类型">
<template slot-scope="scope">
<div v-if="scope.row.contract_type == 0">用户协议</div>
<div v-if="scope.row.contract_type == 1">正式课合同</div>
</template>
</el-table-column>
<el-table-column prop="goods_name" label="关联商品">
<template slot-scope="scope">
<div v-for="data in goodsNameFilter(scope.row.goods_name)">{{data}}</div>
</template>
</el-table-column>
<el-table-column prop="created_at" label="创建时间"></el-table-column>
<el-table-column prop="updated_at" label="最后编辑时间"></el-table-column>
<el-table-column prop="operator" label="最后编辑人"></el-table-column>
<el-table-column prop="status" label="状态">
<template slot-scope="scope">
<div v-if="scope.row.status == 0">启用</div>
<div v-if="scope.row.status == 1">停用</div>
</template>
</el-table-column>
<el-table-column width="150" label="操作">
<template slot-scope="scope">
<el-button type="primary" size="mini" plain @click="edit(scope.row)">编辑</el-button>
<el-button v-if="scope.row.status == 0" type="warning" size="mini" plain @click="switchStatus(scope.row)">
停用
</el-button>
<el-button v-if="scope.row.status == 1" type="success" size="mini" plain @click="switchStatus(scope.row)">
启用
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<dialog-com :dialogObj="dialogObj" @reflash="getDataList"/>
</div>
</template>
<script>
import {contractListApi, contractSwitchstatusApi} from "../../service/api";
import dialogCom from './dialog';
export default {
name: "index",
data() {
return {
dataList: [],
dialogObj: {
type: 0,
show: false,
id: '',
title: ''
}
}
},
components: {
dialogCom
},
methods: {
getDataList() {
contractListApi().then(res => {
this.dataList = res;
});
},
goodsNameFilter(val) {
if (val) {
return val.split('--')
}
},
add() {
this.dialogObj = {
type: 0,
show: true,
id: '',
title: '新增合同协议'
}
},
edit(data) {
this.dialogObj = {
type: 1,
show: true,
id: data.id,
title: '编辑合同协议',
contract_name: data.contract_name,
contract_type: data.contract_type,
goods_ids: data.goods_ids,
contract_text: data.contract_text
}
},
switchStatus(data) {
let json = {
status: data.status
};
if (data.status == 0) {
json.status = 1;
}
if (data.status == 1) {
json.status = 0;
}
contractSwitchstatusApi(data.id, json).then(res => {
if (json.status == 0) {
this.$confirm('此操作将启用合同?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '启用成功'
});
this.getDataList();
}).catch(() => {
});
}
if (json.status == 1) {
this.$confirm('此操作将停用合同?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '停用成功'
});
this.getDataList();
}).catch(() => {
});
}
});
},
},
created() {
this.getDataList();
}
}
</script>
<style scoped>
.container {
padding: 20px;
}
.search-form {
margin-bottom: 20px;
}
</style>