|
@@ -26,7 +26,7 @@
|
|
|
class="demo-ruleForm"
|
|
|
>
|
|
|
<el-row>
|
|
|
- <el-col :span="16">
|
|
|
+ <el-col :span="24">
|
|
|
<el-form-item label="平台名称" prop="platform_name">
|
|
|
<el-input
|
|
|
v-model="ruleForm.platform_name"
|
|
@@ -72,16 +72,16 @@
|
|
|
v-show="ruleForm.use_type === '1' && ruleForm.platform_type === '0'"
|
|
|
:span="8"
|
|
|
>
|
|
|
- <el-form-item label="开启渠道" prop="is_pay">
|
|
|
+ <el-form-item label="是否开启支付渠道" prop="is_select_pay_rate" label-width="140px">
|
|
|
<el-select
|
|
|
- v-model="ruleForm.is_pay"
|
|
|
+ v-model="ruleForm.is_select_pay_rate"
|
|
|
style="width: 100%"
|
|
|
:disabled="id == '007' || isUpdate"
|
|
|
placeholder="是否开启"
|
|
|
@change="set_required"
|
|
|
>
|
|
|
<el-option
|
|
|
- v-for="item in is_pay_options"
|
|
|
+ v-for="item in is_select_pay_rate_options"
|
|
|
:key="item.value"
|
|
|
:label="item.label"
|
|
|
:value="item.value"
|
|
@@ -91,84 +91,37 @@
|
|
|
v-show="
|
|
|
ruleForm.use_type === '1' &&
|
|
|
ruleForm.platform_type === '0' &&
|
|
|
- ruleForm.is_pay === '1'
|
|
|
- "
|
|
|
- :span="8"
|
|
|
- >
|
|
|
- <el-form-item label="渠道名称" prop="pay_name">
|
|
|
- <el-input
|
|
|
- v-model="ruleForm.pay_name"
|
|
|
- :disabled="id == '007'"
|
|
|
- placeholder="渠道名称"
|
|
|
- maxlength="20"
|
|
|
- /></el-form-item></el-col>
|
|
|
- <el-col
|
|
|
- v-show="
|
|
|
- ruleForm.use_type === '1' &&
|
|
|
- ruleForm.platform_type === '0' &&
|
|
|
- ruleForm.is_pay === '1'
|
|
|
+ ruleForm.is_select_pay_rate === '1'
|
|
|
"
|
|
|
:span="24"
|
|
|
>
|
|
|
- <el-form-item label="内容配置" prop="pay_rate">
|
|
|
- <el-table size="mini" border :data="ruleForm.pay_rate">
|
|
|
- <el-table-column label="业务公司">
|
|
|
- <template #default="scope">
|
|
|
- <search-work-company
|
|
|
- v-if="scope.row.isEdit"
|
|
|
- :value="scope.row.companyNo"
|
|
|
- :names="''"
|
|
|
- :size="'mini'"
|
|
|
- :is-detail="id !== 'add'"
|
|
|
- :disabled="isUpdate"
|
|
|
- :placeholder="'业务公司'"
|
|
|
- @searchChange="handleCompanyChange($event, scope.$index)"
|
|
|
- />
|
|
|
-
|
|
|
- <span v-else>{{ ruleForm.pay_rate[0].companyName }}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
-
|
|
|
- <el-table-column label="收费点数">
|
|
|
- <template #default="scope">
|
|
|
- <digital-input
|
|
|
- v-if="scope.row.isEdit"
|
|
|
- ref="digitalInput"
|
|
|
- size="mini"
|
|
|
- :values="scope.row.rate"
|
|
|
- :placeholder="'收费点数'"
|
|
|
- :min="0"
|
|
|
- :max="100"
|
|
|
- :position="'right'"
|
|
|
- :precision="2"
|
|
|
- :controls="false"
|
|
|
- :append="'%'"
|
|
|
- @reschange="handleRateChange($event, scope.$index)"
|
|
|
- />
|
|
|
-
|
|
|
- <span
|
|
|
- v-else
|
|
|
- >{{ Number(ruleForm.pay_rate[0].rate).toFixed(2) }}%</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
-
|
|
|
- <el-table-column
|
|
|
- v-if="id === '003' || id === '005'"
|
|
|
- width="60px"
|
|
|
- label="操作"
|
|
|
- >
|
|
|
- <template #default="scope">
|
|
|
+ <el-form-item label="支付渠道" prop="支付渠道属性">
|
|
|
+ <el-table size="mini" border :data="ruleForm.pay_list">
|
|
|
+ <el-table-column label="渠道名称" prop="channel_name" />
|
|
|
+ <el-table-column label="业务公司" prop="companyName" />
|
|
|
+ <el-table-column v-if="id === '005'" label="操作" width="80px">
|
|
|
+ <template slot="header">
|
|
|
+ <span>操作</span>
|
|
|
<el-tooltip
|
|
|
+ style="margin: 3px 0 0 0"
|
|
|
effect="dark"
|
|
|
- :content="scope.row.isEdit ? '完成' : '修改'"
|
|
|
+ class="fr"
|
|
|
+ content="添加"
|
|
|
placement="top"
|
|
|
>
|
|
|
<i
|
|
|
- :class="[
|
|
|
- scope.row.isEdit ? 'el-icon-circle-check' : 'el-icon-edit',
|
|
|
- 'tb-icon',
|
|
|
- ]"
|
|
|
- @click="handleEdit(scope.$index)"
|
|
|
+ class="el-icon-circle-plus-outline tb-icon"
|
|
|
+ style="color: #6954f0; magin: 0 0 0 10px"
|
|
|
+ @click="visible = true"
|
|
|
+ />
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tooltip effect="dark" class="fr" content="删除" placement="top">
|
|
|
+ <i
|
|
|
+ class="el-icon-delete tb-icon"
|
|
|
+ @click="ruleForm.pay_list.splice(scope.$index,1)"
|
|
|
/>
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
@@ -184,6 +137,7 @@
|
|
|
v-if="id !== '007'"
|
|
|
size="mini"
|
|
|
type="primary"
|
|
|
+ :loading="loading"
|
|
|
@click="submitForm"
|
|
|
>保 存
|
|
|
</el-button>
|
|
@@ -193,18 +147,24 @@
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-card>
|
|
|
+
|
|
|
+ <search-company-modal :visible.sync="visible" @updatePaymentChannel="onUpdatePaymentChannel" />
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
<script>
|
|
|
import asyncRequest from '@/apis/service/serviceParam/terrace'
|
|
|
import resToken from '@/mixins/resToken'
|
|
|
+import SearchCompanyModal from './searchCompanyModal.vue'
|
|
|
export default {
|
|
|
name: 'Terrace',
|
|
|
+ components: { SearchCompanyModal },
|
|
|
mixins: [resToken],
|
|
|
props: ['showModel', 'id', 'sitem'],
|
|
|
data() {
|
|
|
return {
|
|
|
loading: false,
|
|
|
+ visible: false,
|
|
|
+ sourcePaymentChannel: [],
|
|
|
title: '添加平台',
|
|
|
showModelThis: this.showModel,
|
|
|
rateBefore: {
|
|
@@ -225,7 +185,7 @@ export default {
|
|
|
{ value: '0', label: '无对接' }, //
|
|
|
{ value: '1', label: '有赞平台' }
|
|
|
],
|
|
|
- is_pay_options: [
|
|
|
+ is_select_pay_rate_options: [
|
|
|
{ value: '0', label: '不选支付渠道' }, //
|
|
|
{ value: '1', label: '选择支付渠道' }
|
|
|
],
|
|
@@ -239,25 +199,17 @@ export default {
|
|
|
platform_type: '0',
|
|
|
use_type: '1',
|
|
|
pay_name: '',
|
|
|
- is_pay: '0',
|
|
|
- pay_rate: [
|
|
|
- {
|
|
|
- companyNo: '',
|
|
|
- companyName: '',
|
|
|
- rate: '',
|
|
|
- isEdit: true
|
|
|
- }
|
|
|
- ]
|
|
|
+ is_select_pay_rate: '0',
|
|
|
+ pay_list: []
|
|
|
},
|
|
|
rules: {
|
|
|
platform_name: [{ required: true, message: '平台名称不能为空', trigger: 'blur' }],
|
|
|
platform_type: [{ required: true, message: '请选择对接平台', trigger: 'change' }],
|
|
|
use_type: [{ required: true, message: '请选择平台类型', trigger: 'change' }],
|
|
|
- is_pay: [
|
|
|
+ is_select_pay_rate: [
|
|
|
{ required: true, message: '请选择是否开启支付渠道', trigger: 'change' }
|
|
|
],
|
|
|
- pay_name: [{ required: true, message: '渠道名称不能为空', trigger: 'blur' }],
|
|
|
- pay_rate: [
|
|
|
+ pay_list: [
|
|
|
{
|
|
|
type: 'array',
|
|
|
required: true,
|
|
@@ -283,6 +235,16 @@ export default {
|
|
|
},
|
|
|
showModelThis(val) {
|
|
|
if (!val) {
|
|
|
+ this.ruleForm = {
|
|
|
+ id: '',
|
|
|
+ platform_name: '',
|
|
|
+ platform_type: '0',
|
|
|
+ use_type: '1',
|
|
|
+ pay_name: '',
|
|
|
+ is_select_pay_rate: '0',
|
|
|
+ pay_list: []
|
|
|
+ }
|
|
|
+ this.sourcePaymentChannel = []
|
|
|
this.$emit('cancel')
|
|
|
}
|
|
|
}
|
|
@@ -316,83 +278,94 @@ export default {
|
|
|
if (isAllowLoadDetail) await this.loadDetail()
|
|
|
this.set_required()
|
|
|
},
|
|
|
+ uniquePaymentChannel(values) {
|
|
|
+ const map = new Map()
|
|
|
+ const pay_list = values.map(value => {
|
|
|
+ const channel_id = value.id
|
|
|
+ delete value['id']
|
|
|
+ return ({ ...value, channel_id })
|
|
|
+ })
|
|
|
+
|
|
|
+ return ([...this.ruleForm.pay_list, ...pay_list]).filter((item) => !map.has(item.channel_id) && map.set(item.channel_id, 1))
|
|
|
+ },
|
|
|
+ onUpdatePaymentChannel(values) {
|
|
|
+ this.ruleForm.pay_list = this.uniquePaymentChannel(values)
|
|
|
+ console.log(this.ruleForm)
|
|
|
+ },
|
|
|
async loadDetail() {
|
|
|
this.loading = true
|
|
|
const platformResponse = await asyncRequest.detail({ id: this.sitem.id })
|
|
|
- const { platform_name, platform_type, is_select_pay_rate, use_type, pay_list, pay_title } = platformResponse.data
|
|
|
- // if (Array.isArray(pay_list) && pay_list.length > 0) {
|
|
|
- // const { companyNoc } = pay_list[pay_list.length - 1]
|
|
|
- // console.log(pay_list[pay_list.length - 1])
|
|
|
-
|
|
|
- // const companyResponse = await asyncRequest.company({ companyNo })
|
|
|
- // const company = companyResponse.data.list.find(({ companyNo: _companyNo }) => _companyNo === companyNo)
|
|
|
- // pay_list[0].companyName = company ? company.company : ''
|
|
|
- // }
|
|
|
-
|
|
|
- let pay_rate = [{ companyNo: '', rate: '', isEdit: true }]
|
|
|
- if (pay_list.length > 0) {
|
|
|
- pay_rate = pay_list.filter(({ companyNo }) => companyNo !== 'KH' && companyNo !== 'GYS')
|
|
|
- }
|
|
|
+ const { platform_name, platform_type, is_select_pay_rate, use_type, pay_list } = platformResponse.data
|
|
|
|
|
|
this.loading = false
|
|
|
this.ruleForm = {
|
|
|
- pay_name: pay_title || '',
|
|
|
platform_name: platform_name || '',
|
|
|
platform_type: String(platform_type) ? String(platform_type) : '0',
|
|
|
use_type: String(use_type) ? String(use_type) : '1',
|
|
|
- is_pay: String(is_select_pay_rate) ? String(is_select_pay_rate) : '',
|
|
|
- pay_rate
|
|
|
+ is_select_pay_rate: String(is_select_pay_rate) ? String(is_select_pay_rate) : '',
|
|
|
+ pay_list
|
|
|
}
|
|
|
- },
|
|
|
- handleEdit(index) {
|
|
|
- const lineData = this.ruleForm.pay_rate[index]
|
|
|
- if (lineData.isEdit) {
|
|
|
- const { companyNo, rate } = lineData
|
|
|
- if (!companyNo) return this.$message.warning('业务公司不能为空')
|
|
|
- if (!rate) return this.$message.warning('收费点数不能为空')
|
|
|
- }
|
|
|
-
|
|
|
- this.$set(this.ruleForm.pay_rate, index, {
|
|
|
- ...this.ruleForm.pay_rate[index],
|
|
|
- ...{ isEdit: !lineData.isEdit }
|
|
|
- })
|
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
- // 手动更新
|
|
|
- this.$refs.digitalInput && this.$refs.digitalInput.manualUpdate(lineData.rate)
|
|
|
- })
|
|
|
+ this.sourcePaymentChannel = JSON.parse(JSON.stringify(pay_list || '[]'))
|
|
|
},
|
|
|
async submitForm() {
|
|
|
- const { pay_rate, is_pay } = this.ruleForm
|
|
|
- const isPayRateSave = pay_rate.every(({ isEdit }) => !isEdit)
|
|
|
- if (!isPayRateSave && is_pay === '1') return this.$message.warning('未完成内容配置编辑')
|
|
|
+ const { pay_list, is_select_pay_rate } = this.ruleForm
|
|
|
+ const isPayRateSave = pay_list.every(({ isEdit }) => !isEdit)
|
|
|
+ if (!isPayRateSave && is_select_pay_rate === '1') return this.$message.warning('未完成内容配置编辑')
|
|
|
|
|
|
await this.$refs.ruleForm.validate(async(valid) => {
|
|
|
if (valid) {
|
|
|
if (this.loading) { return }
|
|
|
this.loading = true
|
|
|
- const { pay_rate, pay_name, platform_type, platform_name, is_pay, use_type } = this.ruleForm
|
|
|
+ const { pay_list, platform_type, platform_name, is_select_pay_rate, use_type } = this.ruleForm
|
|
|
|
|
|
const model = {
|
|
|
id: this.sitem.id,
|
|
|
- pay_list: pay_rate, // 渠道配置集合
|
|
|
- pay_title: pay_name, // 渠道名称
|
|
|
- is_select_pay_rate: is_pay, // 是否开启渠道
|
|
|
+ pay_list: pay_list, // 渠道配置集合
|
|
|
+ is_select_pay_rate, // 是否开启渠道
|
|
|
platform_type, // 对接类型 0 无 1 toB 2 ToC
|
|
|
platform_name, // 平台名称
|
|
|
use_type // 平台性质,0内部使用,1对接有赞平台
|
|
|
}
|
|
|
|
|
|
- model.is_select_pay_rate = use_type === '1' && platform_type === '0' ? is_pay : '0'
|
|
|
-
|
|
|
+ model.is_select_pay_rate = use_type === '1' && platform_type === '0' ? is_select_pay_rate : '0'
|
|
|
+ this.loading = false
|
|
|
if (model.use_type !== '1' || model.platform_type !== '0' || model.is_select_pay_rate !== '1') {
|
|
|
delete model['pay_list']
|
|
|
}
|
|
|
|
|
|
- if (model.pay_list && model.pay_list.length > 0) {
|
|
|
- delete model.pay_list[0].isEdit
|
|
|
- delete model.pay_list[0].is_cgd
|
|
|
- delete model.pay_list[0].is_qrd
|
|
|
+ if (this.id !== '003' && model.pay_list) {
|
|
|
+ const currentPaymentChannelIDSet = model.pay_list.map(({ channel_id }) => channel_id)
|
|
|
+ // 删除的渠道
|
|
|
+ const delChannel = this.sourcePaymentChannel
|
|
|
+ .filter(({ channel_id }) => !currentPaymentChannelIDSet.includes(String(channel_id)))
|
|
|
+ .map(({ channel_id, id }) => ({
|
|
|
+ channel_id,
|
|
|
+ id,
|
|
|
+ is_del: 1
|
|
|
+ }))
|
|
|
+
|
|
|
+ // 原始的渠道
|
|
|
+ const originChannel = this.sourcePaymentChannel
|
|
|
+ .filter(({ channel_id }) => currentPaymentChannelIDSet.includes(String(channel_id)))
|
|
|
+ .map(({ channel_id, id }) => ({
|
|
|
+ channel_id,
|
|
|
+ id,
|
|
|
+ is_del: 0
|
|
|
+ }))
|
|
|
+
|
|
|
+ // 添加的渠道
|
|
|
+ const addChannel = this.ruleForm.pay_list
|
|
|
+ .filter(({ channel_id: _channel_id }) =>
|
|
|
+ !originChannel.find(({ channel_id }) => String(channel_id) === String(_channel_id)) &&
|
|
|
+ !delChannel.find(({ channel_id }) => String(channel_id) === String(_channel_id)))
|
|
|
+ .map(({ channel_id }) => ({
|
|
|
+ channel_id: Number(channel_id),
|
|
|
+ is_del: 0,
|
|
|
+ id: null
|
|
|
+ }))
|
|
|
+
|
|
|
+ model.pay_list = [...delChannel, ...originChannel, ...addChannel]
|
|
|
}
|
|
|
|
|
|
let res = {}
|
|
@@ -424,11 +397,9 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
set_required() {
|
|
|
- const { platform_type, use_type, is_pay } = this.ruleForm
|
|
|
- if (Object.keys(this.rulesThis).length === 0) return
|
|
|
- this.rulesThis.is_pay[0].required = use_type === '1' && platform_type === '0'
|
|
|
- this.rulesThis.pay_name[0].required = use_type === '1' && platform_type === '0' && is_pay === '1'
|
|
|
- this.rulesThis.pay_rate[0].required = use_type === '1' && platform_type === '0' && is_pay === '1'
|
|
|
+ const { platform_type, use_type, is_select_pay_rate } = this.ruleForm
|
|
|
+ this.rulesThis.is_select_pay_rate[0].required = use_type === '1' && platform_type === '0'
|
|
|
+ this.rulesThis.pay_list[0].required = use_type === '1' && platform_type === '0' && is_select_pay_rate === '1'
|
|
|
},
|
|
|
handleCompanyChange(e, index) {
|
|
|
const { code, label } = e
|
|
@@ -438,16 +409,10 @@ export default {
|
|
|
companyName: label
|
|
|
}
|
|
|
|
|
|
- this.$set(this.ruleForm.pay_rate, index, {
|
|
|
- ...this.ruleForm.pay_rate[index],
|
|
|
+ this.$set(this.ruleForm.pay_list, index, {
|
|
|
+ ...this.ruleForm.pay_list[index],
|
|
|
...companyInfo
|
|
|
})
|
|
|
- },
|
|
|
- handleRateChange(rate, index) {
|
|
|
- this.$set(this.ruleForm.pay_rate, index, {
|
|
|
- ...this.ruleForm.pay_rate[index],
|
|
|
- ...{ rate }
|
|
|
- })
|
|
|
}
|
|
|
}
|
|
|
}
|