Commit f3dbb20f by 张立顺

feat 接口替换

1 parent 2c927d90
<!-- 关联门店弹窗 --> <!-- 关联门店弹窗 -->
<template> <template>
<d2-dialog title="关联门店" <d2-dialog
title="关联门店"
:is-visible.sync="relateStoreVisible" :is-visible.sync="relateStoreVisible"
width="70%" width="70%"
btn-ok-label="关联" btn-ok-label="关联"
@confirmDialog="handleRelateStoreConfirm" @confirmDialog="handleRelateStoreConfirm"
@closeDialog="handleRelateStoreClose" @closeDialog="handleRelateStoreClose"
class="relateStore"> class="relateStore"
>
<slot /> <slot />
<el-row class="tableCon"> <el-row class="tableCon">
<!-- <el-col :span="12"> --> <!-- <el-col :span="12"> -->
<div class="tableBox"> <div class="tableBox">
<el-table ref="seletingTable" <el-table
ref="seletingTable"
:data="selectingData" :data="selectingData"
height="464px" height="464px"
class="table" class="table"
border border
@select="handleChange" @select="handleChange"
@select-all="handleAll"> @select-all="handleAll"
<el-table-column type="selection" >
<el-table-column
type="selection"
width="55" width="55"
align="center" align="center"
:selectable="selectable" /> :selectable="selectable"
<el-table-column v-if="sourcePage != 'serviceStore'" />
<el-table-column
v-if="sourcePage != 'serviceStore'"
prop="yqMerchantName" prop="yqMerchantName"
label="园区店名称" label="园区店名称"
align="center"> align="center"
>
<template slot-scope="scope"> <template slot-scope="scope">
<span <span
:class="{'red': !scope.row.isSetUpgradeSettleRule && needTip.includes(sourcePage)}">{{ scope.row.yqMerchantName }}</span> :class="{
red:
!scope.row.isSetUpgradeSettleRule &&
needTip.includes(sourcePage)
}"
>{{ scope.row.yqMerchantName }}</span
>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="merchantName" <el-table-column prop="merchantName" label="4S店名称" align="center">
label="4S店名称"
align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<span <span
:class="{'red': !scope.row.isSetUpgradeSettleRule && needTip.includes(sourcePage)}">{{ scope.row.merchantName }}</span> :class="{
<el-tooltip v-if="!scope.row.isSetUpgradeSettleRule" red:
!scope.row.isSetUpgradeSettleRule &&
needTip.includes(sourcePage)
}"
>{{ scope.row.merchantName }}</span
>
<el-tooltip
v-if="!scope.row.isSetUpgradeSettleRule"
popper-class="tooltip-class" popper-class="tooltip-class"
effect="dark" effect="dark"
content="该门店无配置财务分润规则,无法关联!" content="该门店无配置财务分润规则,无法关联!"
placement="top"> placement="top"
<span v-if="!scope.row.isSetUpgradeSettleRule && needTip.includes(sourcePage)" >
class="tip-icon">?</span> <span
v-if="
!scope.row.isSetUpgradeSettleRule &&
needTip.includes(sourcePage)
"
class="tip-icon"
>?</span
>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-pagination small <el-pagination
small
background background
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
:current-page.sync="currentPage" :current-page.sync="currentPage"
:page-size="pageSize" :page-size="pageSize"
layout="total, prev, pager, next" layout="total, prev, pager, next"
:total="total" /> :total="total"
/>
</div> </div>
<!-- </el-col> --> <!-- </el-col> -->
<!-- <el-col :span="12"> --> <!-- <el-col :span="12"> -->
<el-table :data="selectedData" <el-table
:data="selectedData"
class="table tableBox" class="table tableBox"
border border
height="464px"> height="464px"
<el-table-column v-if="sourcePage != 'serviceStore'" >
<el-table-column
v-if="sourcePage != 'serviceStore'"
prop="yqMerchantName" prop="yqMerchantName"
label="园区店名称" label="园区店名称"
align="center" />
<el-table-column prop="merchantName"
label="4S店名称"
align="center" />
<el-table-column label="删除"
align="center" align="center"
width="50px"> />
<el-table-column prop="merchantName" label="4S店名称" align="center" />
<el-table-column label="删除" align="center" width="50px">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button class="el-icon-delete" <el-button
class="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
type="text" /> type="text"
/>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -86,12 +116,12 @@ ...@@ -86,12 +116,12 @@
<script> <script>
export default { export default {
name: 'RelateStoreDialog', name: "RelateStoreDialog",
data() { data() {
return { return {
selectedData: [], selectedData: [],
selectingData: [], selectingData: [],
needTip: ['editProduct'], needTip: ["editProduct"],
// 分页 // 分页
total: 0, total: 0,
currentPage: 1, currentPage: 1,
...@@ -107,11 +137,11 @@ export default { ...@@ -107,11 +137,11 @@ export default {
// 页面来源 // 页面来源
sourcePage: { sourcePage: {
type: String, type: String,
default: '' default: ""
}, },
storeApi: { storeApi: {
type: Function, type: Function,
default: () => { } default: () => {}
}, },
storeSelected: { storeSelected: {
type: Array, type: Array,
...@@ -119,7 +149,7 @@ export default { ...@@ -119,7 +149,7 @@ export default {
}, },
storeSearchForm: { storeSearchForm: {
type: Object, type: Object,
default: () => { } default: () => {}
} }
// 去掉表格中某些字段 // 去掉表格中某些字段
// noTableField: { // noTableField: {
...@@ -135,8 +165,8 @@ export default { ...@@ -135,8 +165,8 @@ export default {
methods: { methods: {
selectable(row, index) { selectable(row, index) {
var isSelect = row.hasOwnProperty('beServed') ? !row.beServed : true var isSelect = row.hasOwnProperty("beServed") ? !row.beServed : true
if (this.sourcePage === 'editProduct') { if (this.sourcePage === "editProduct") {
// 不能选的判断 // 不能选的判断
// console.log('??') // console.log('??')
isSelect = row.isSetUpgradeSettleRule isSelect = row.isSetUpgradeSettleRule
...@@ -144,9 +174,10 @@ export default { ...@@ -144,9 +174,10 @@ export default {
return isSelect return isSelect
}, },
recoverySelection() { recoverySelection() {
var exitIds = this.selectedData.map(item => item.merchantId) var exitIds = this.selectedData.map((item) => item.merchantId)
this.selectingData.forEach(item => { this.selectingData.forEach((item) => {
exitIds.includes(item.merchantId) && this.$refs.seletingTable.toggleRowSelection(item, true) exitIds.includes(item.merchantId) &&
this.$refs.seletingTable.toggleRowSelection(item, true)
}) })
}, },
getSelectingList() { getSelectingList() {
...@@ -154,7 +185,23 @@ export default { ...@@ -154,7 +185,23 @@ export default {
...this.storeSearchForm, ...this.storeSearchForm,
currentPage: this.currentPage, currentPage: this.currentPage,
pageSize: this.pageSize pageSize: this.pageSize
}).then(res => { }).then((res) => {
console.log(this.storeApi, "storeApi")
// if (this.storeApi == "getList") {
res.list = res.list.map((item) => {
// item.merchantId = item.id
let yqMerchant = item?.sceneList[0]?.yqMerchant || {}
console.log(yqMerchant)
item = {
// ...yqMerchant,
yqMerchantName: yqMerchant?.merchantName,
yqMerchantId: yqMerchant?.merchantId,
...item
}
return item
})
console.log("res.list", res.list)
// }
this.selectingData = res.list this.selectingData = res.list
this.total = res.total this.total = res.total
this.$nextTick(() => { this.$nextTick(() => {
...@@ -163,24 +210,32 @@ export default { ...@@ -163,24 +210,32 @@ export default {
}) })
}, },
handleChange(selection, row) { handleChange(selection, row) {
var addOrDelete = !!selection.find(item => item.merchantId === row.merchantId) var addOrDelete = !!selection.find(
(item) => item.merchantId === row.merchantId
)
addOrDelete addOrDelete
? this.selectedData.push(row) ? this.selectedData.push(row)
: (this.selectedData = this.selectedData.filter(item => item.merchantId !== row.merchantId)) : (this.selectedData = this.selectedData.filter(
(item) => item.merchantId !== row.merchantId
))
}, },
handleAll(selection) { handleAll(selection) {
this.selectingData.forEach(item => { this.selectingData.forEach((item) => {
var isExit = this.selectedData.findIndex(subItem => subItem.merchantId === item.merchantId) var isExit = this.selectedData.findIndex(
var isServed = item.hasOwnProperty('beServed') ? item.beServed : false (subItem) => subItem.merchantId === item.merchantId
if (selection.length && (isExit === -1) && !isServed) { )
var isServed = item.hasOwnProperty("beServed") ? item.beServed : false
if (selection.length && isExit === -1 && !isServed) {
this.selectedData.push(item) this.selectedData.push(item)
} else if (!selection.length && (isExit !== -1)) { } else if (!selection.length && isExit !== -1) {
this.selectedData.splice(isExit, 1) this.selectedData.splice(isExit, 1)
} }
}) })
}, },
handleDelete(row) { handleDelete(row) {
this.selectedData = this.selectedData.filter(item => item.merchantId !== row.merchantId) this.selectedData = this.selectedData.filter(
(item) => item.merchantId !== row.merchantId
)
this.$refs.seletingTable.toggleRowSelection(row) this.$refs.seletingTable.toggleRowSelection(row)
}, },
handleCurrentChange(val) { handleCurrentChange(val) {
...@@ -188,14 +243,13 @@ export default { ...@@ -188,14 +243,13 @@ export default {
this.getSelectingList() this.getSelectingList()
}, },
handleRelateStoreConfirm() { handleRelateStoreConfirm() {
this.$emit('handleRelateStoreConfirm', this.selectedData) this.$emit("handleRelateStoreConfirm", this.selectedData)
}, },
handleRelateStoreClose() { handleRelateStoreClose() {
this.$emit('handleRelateStoreClose') this.$emit("handleRelateStoreClose")
} }
} }
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.relateStore .table { .relateStore .table {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!