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
212
213
214
215
216
217
218
219
220
221
222
<template>
<el-dialog append-to-body :title="$t('设置')" :visible.sync="dialogVisible" width="900px">
<el-form ref="form" :model="form" label-width="150px">
<el-row :gutter="10">
<el-col :span="12">
<el-form-item :label="$t('是否显示提单价格')" prop="isShowTidanPrice">
<el-switch v-model="form.isShowTidanPrice"></el-switch>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('到仓确认')" prop="arrivalConfirm">
<el-switch v-model="form.arrivalConfirm" :active-value="1" :inactive-value="0" />
</el-form-item>
</el-col>
<el-col :span="13">
<el-form-item :label="$t('重货标准')" prop="weightUnit">
<el-switch v-model="showZhong" />
<el-input v-model="form.weightUnit" :placeholder="$t('请输入重货标准')" v-show="showZhong">
<template slot="append">kg/cbm</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="24" v-show="showZhong">
<el-form-item :label="$t('指定线路')" prop="line">
<el-switch v-model="showZhong1"></el-switch>
<customer-line-table v-if="showZhong1" :warehouse-list="warehouseList" :import-city-list="importCityList" v-model="zhongLines" :zhong-pao-type="1"></customer-line-table>
</el-form-item>
</el-col>
<el-col :span="13">
<el-form-item :label="$t('泡货标准')" prop="lightUnit">
<el-switch v-model="showPao" />
<el-input v-model="form.lightUnit" :placeholder="$t('请输入泡货标准')" v-show="showPao">
<template slot="append">kg/cbm</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="24" v-show="showPao">
<el-form-item :label="$t('指定线路')" prop="line">
<el-switch v-model="showPao1"></el-switch>
<customer-line-table v-if="showPao1" :warehouse-list="warehouseList" :import-city-list="importCityList" v-model="paoLines" :zhong-pao-type="2"></customer-line-table>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('控货无收货人')">
<el-switch v-model="form.noConsignee" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('默认付款')">
<el-switch v-model="form.defaultPay" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item :label="$t('默认开票')">
<el-switch v-model="form.defaultBilling" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="warning" @click="handleClose">{{ $t("关 闭") }}</el-button>
<el-button type="primary" @click="handerSubmit">{{ $t("保 存") }}</el-button>
</div>
</el-dialog>
</template>
<script>
import CustomerLineTable from "@/components/CustomerLineTable"
import { getWarehouseList } from "@/api/ecw/warehouse"
import { getTradeCityList } from "@/api/ecw/region"
import { getZhongPaoBest, getZhongPaoPage } from "@/api/ecw/zhongPao"
import { getCustomer, getCustomerLines, customerSettingButton } from "@/api/ecw/customer"
import { DICT_TYPE, getDictDatas } from '@/utils/dict'
import interval from 'echarts/src/scale/Interval'
export default {
name: "CustomerSetting",
components: {
CustomerLineTable
},
data() {
return {
dialogVisible: false,
preferenceTransportType: 0,
form: {
id: 0,
isShowTidanPrice: false,
arrivalConfirm: 0,
weightUnit: null,
lightUnit: null,
customerLines: [],
noConsignee: false,
defaultPay: false,
defaultBilling: false,
},
showZhong: false,
showZhong1: false,
showPao: false,
showPao1: false,
zhongLines: [],
warehouseList: [], // 仓库列表
importCityList: [], // 进口地址
paoLines: [],
preferenceTransportData: getDictDatas(DICT_TYPE.ECW_PREFERENCE_TRANSPORT_TYPE),
}
},
created() {
getWarehouseList().then((r) => {
this.warehouseList = r.data
})
getTradeCityList({ type: 1 }).then((r) => {
this.importCityList = r.data.filter((item) => item.type === "1")
})
},
methods: {
init(id) {
this.customerId = id
this.showZhong = false
this.showPao = false
this.showZhong1 = false
this.showPao1 = false
getCustomer(this.customerId).then((response) => {
const row = response.data
this.form = {
id: row.id,
isShowTidanPrice: row.isShowTidanPrice,
arrivalConfirm: row.arrivalConfirm,
weightUnit: row.weightUnit,
lightUnit: row.lightUnit,
customerLines: [],
noConsignee: row.noConsignee,
defaultPay: row.defaultPay,
defaultBilling: row.defaultBilling,
}
// 打开重泡货开关
if (this.form.weightUnit) {
this.showZhong = true
}
if (this.form.lightUnit) {
this.showPao = true
}
getCustomerLines(this.customerId).then((res) => {
this.zhongLines = res.data.filter((item) => item.zhongPaoType == 1)
this.paoLines = res.data.filter((item) => item.zhongPaoType == 2)
if (this.zhongLines.length) this.showZhong1 = true
if (this.paoLines.length) this.showPao1 = true
})
this.getZhongPao()
})
},
getZhongPao() {
getZhongPaoBest({
customerId: this.customerId
// departureId: this.departureId,
// objectiveId: this.objectiveId
}).then((r) => {
if (!this.form.weightUnit) this.form.weightUnit = r.data.zhongEdge
if (!this.form.lightUnit) this.form.lightUnit = r.data.paoEdge
})
},
handleClose() {
this.resetForm("form")
this.dialogVisible = false
},
handerSubmit() {
this.$refs["form"].validate((valid, err) => {
// 重货标准和泡货标准,未打开就不传,提交前清空一下
if (!this.showZhong) {
this.form.weightUnit = null
this.zhongLines = []
}
if (!this.showZhong1) {
this.zhongLines = []
}
if (!this.showPao) {
this.form.lightUnit = null
this.paoLines = []
}
if (!this.showPao1) {
this.paoLines = []
}
this.updateCustomerLines()
// 检查路线是否启用了但是没选择目的仓
let errors = 0
this.form.customerLines.forEach((line) => {
if (!line.objectiveIds || line.objectiveIds == "") {
errors++
}
})
if (errors) {
return this.$message.error("有两条路线未选择目的地")
}
customerSettingButton(this.form).then((response) => {
this.$modal.msgSuccess(this.$t("操作成功"))
this.dialogVisible = false
const obj = { path: "/customer/customer" }
this.$emit("refresh")
})
})
},
updateCustomerLines() {
let zhongLines = [],
paoLines = []
if (this.zhongLines.length > 0) {
zhongLines = this.zhongLines
}
if (this.paoLines.length > 0) {
paoLines = this.paoLines
}
this.form.customerLines = [...zhongLines, ...paoLines]
}
}
}
</script>