Commit e9fd7dac by 胡悦

添加公共方法 resetSearch

1 parent 57978827
......@@ -23,6 +23,13 @@ function jumpLink(url, params, _this) {
// document.getElementById('child_iframe_1192').src=url + urlEncode(params)
}
function resetSearch(obj) {
for (var item in obj) {
obj[item] = ''
}
}
export {
jumpLink
jumpLink,
resetSearch
}
......@@ -108,6 +108,7 @@
import Vue from 'vue'
import { groupDetailMethods, request } from '@/api'
import AddBusiness from './addBusiness'
import { resetSearch } from '@/common/common'
import { CityArea } from '../components'
export default {
name: 'detail',
......@@ -128,10 +129,10 @@ export default {
searchParams: {
groupId: null,
merchantName: '',
merchantId: null,
merchantType: null,
provinceId: null,
cityId: null,
merchantId: '',
merchantType: '',
provinceId: '',
cityId: '',
startTime: '',
endTime: ''
},
......@@ -217,8 +218,8 @@ export default {
getParams() {
return Object.assign(
{
pageCount: this.pageNum,
pageSize: this.pageSize
pageCount: this.pageSize,
pageSize: this.pageNum
},
this.searchParams
)
......@@ -284,9 +285,11 @@ export default {
},
// 重置搜索
searchReset() {
this.$refs['searchParams'].resetFields()
// this.$refs['searchParams'].resetFields()
this.eventBus.$emit('reset')
this.times = []
// this.times = []
resetSearch(this.searchParams)
console.log(this.getParams())
},
addDialog() {
this.addDialogVisible = !this.addDialogVisible
......
<template>
<div>
<gl-dialog
title="添加商户"
:visible.sync="addDialogVisible"
width="400px"
:before-close="showAddDialog">
<gl-form
ref="addForm" :model="addForm"
label-width="100px"
:rules="rules">
<gl-form-item label="商户:" prop="merchant">
<gl-select
v-model="addForm.merchant"
filterable
remote
clearable
name="merchant"
placeholder="请输入商户名称/商户号"
data-vv-as="商户名称/商户号"
v-validate="'required'"
:remote-method="remoteList"
:loading="loading">
<gl-option
v-for="item in businessList"
:key="item.merchantId"
:label="item.merchantName"
:value="item.merchantId">
</gl-option>
</gl-select>
<span v-show="errorBags.has('merchant')" class="error">{{ errorBags.first('merchant') }}</span>
</gl-form-item>
<gl-form-item label="商户类型:" prop="merchantType">
<gl-select v-model="addForm.merchantType"
name="merchantType"
data-vv-as="商户类型"
v-validate="'required'"
placeholder="请搜索">
<gl-option
v-for="item in merchantTypeList"
:key="item.confId"
:label="item.confKey"
:value="item.confId">
</gl-option>
</gl-select>
<span v-show="errorBags.has('merchantType')" class="error">{{ errorBags.first('merchantType') }}</span>
</gl-form-item>
<div v-for="(item, idx) in addList" :key="idx">
<gl-form-item :label="item.label + ':'">
<gl-select
v-model="item.merchant"
filterable
remote
:name="`item.merchant${idx+1}`"
v-validate="item.merchant || item.merchantType ? 'required' : ''"
:data-vv-as="`子商户${idx+1}`"
clearable
placeholder="请输入商户名称/商户号"
:remote-method="remoteChildList"
:loading="childLoading">
<gl-option
v-for="item in businessChildList"
:key="item.merchantId"
:label="item.merchantName"
:value="item.merchantId">
</gl-option>
</gl-select>
<i v-show="item.show" class="el-icon-delete delete" @click="deleteBusiness(idx)"></i>
<span v-show="errorBags.has(`item.merchant${idx+1}`)" class="error">{{ errorBags.first(`item.merchant${idx+1}`) }}</span>
<!-- <span v-show="item.merchant? !item.merchant : !!item.merchantType" class="error">{{ `请填写子商户${idx+1}的商户名称/商户号` }}</span> -->
</gl-form-item>
<gl-form-item label="商户类型:">
<gl-select v-model="item.merchantType"
:name="`item.merchantType${idx+1}`"
v-validate="item.merchant || item.merchantType ? 'required' : ''"
:data-vv-as="`子商户${idx+1}类型`"
clearable
placeholder="请选择">
<gl-option
v-for="item in merchantTypeList"
:key="item.confId"
:label="item.confKey"
:value="item.confId">
</gl-option>
</gl-select>
<span v-show="errorBags.has(`item.merchantType${idx+1}`)" class="error">{{ errorBags.first(`item.merchantType${idx+1}`) }}</span>
<!-- <span v-show="item.merchantType? !item.merchantType : !!item.merchant" class="error">{{ `请填写子商户${idx+1}的商户类型` }}</span> -->
</gl-form-item>
</div>
<span v-show="tip" class="error" style="float:right; margin-right: 43px;">{{ '请填写上一条子商户数据' }}</span>
<gl-button @click="addMore">添加更多</gl-button>
</gl-form>
<div slot="footer" class="dialog-footer">
<gl-button @click="showAddDialog">取 消</gl-button>
<gl-button type="primary" @click="ok">确 定</gl-button>
</div>
</gl-dialog>
</div>
</template>
<script>
import notice from '@/common/notice'
import { businessManagenMethods, groupDetailMethods, request } from '@/api'
export default {
name: 'AddBusiness',
props: {
addDialogVisible: Boolean
},
data() {
return {
tip: false,
addForm: {
merchant: '',
merchantType: ''
},
merchantTypeList: [],
rules: {
merchant: [{ required: true }],
merchantType: [{ required: true }]
},
// 远程搜索
loading: false,
childLoading: false,
businessList: [],
businessChildList: [],
addList: [
{
label: '子商户1',
merchant: '',
merchantType: ''
}
]
}
},
watch: {
addDialogVisible(val) {
this.$validator.errors.clear()
}
},
mounted() {
this.getBusinessType()
},
methods: {
// 确定按钮
ok() {
this.tip = false
this.$validator.validateAll().then((result) => {
if (result) {
this.addList.forEach(item => {
delete item.label
})
if (this.addList[0].merchantId) {
this.addForm.merchantRelationAdds = this.addList
}
console.log(this.addForm)
const params = this.$deep_clone(this.addForm)
params.method = groupDetailMethods.Create
request.req(params).then(res => {
notice.okTips()
this.showAddDialog()
}).catch(err => {
notice.errorTips(err)
})
}
})
},
// 显示隐藏添加商户按钮
showAddDialog() {
this.$emit('addData')
setTimeout(() => {
this.addList = [{ label: '子商户1', merchant: '', merchantType: '' }]
this.addForm = { merchant: '', merchantType: '' }
}, 400)
},
// 添加更多按钮
addMore() {
console.log(this.addList)
const len = this.addList.length - 1
if (this.addList[len].merchant == '' || this.addList[len].merchantType == '') {
console.log('请填写完上一条数据')
this.tip = true
} else {
this.tip = false
this.addList.push({
label: '子商户' + (this.addList.length + 1),
merchant: '',
merchantType: '',
show: true
})
}
},
deleteBusiness(idx) {
this.addList.splice(idx, 1)
},
// 父商户搜索
remoteList(query) {
if (query !== '') {
this.loading = true
const params = {}
params.groupId = 1
params.searchWrod = query
params.method = groupDetailMethods.SearchList
request.req(params).then(res => {
console.log(res.merchantParams)
this.loading = false
this.businessList = res.merchantParams
}).catch(err => {
notice.errorTips(err)
})
} else {
this.businessList = []
}
},
// 子商户远程搜索
remoteChildList(query) {
if (query !== '') {
this.childLoading = true
const params = {}
params.groupId = 1
params.searchWrod = query
params.method = groupDetailMethods.SearchChildList
request.req(params).then(res => {
console.log(res.merchantParams)
this.childLoading = false
this.businessChildList = res.merchantParams
}).catch(err => {
notice.errorTips(err)
})
} else {
this.businessChildList = []
}
},
// 获取商户类型列表
getBusinessType() {
const params = {}
params.method = businessManagenMethods.Type
request.req(params).then(res => {
console.log(res)
this.merchantTypeList = res.merchantDictList
}).catch(err => {
notice.errorTips(err)
})
}
}
}
</script>
<style>
.delete {
color: red;
margin-left: 20px;
font-size: 18px;
}
</style>
......@@ -66,22 +66,14 @@
>确 定</gl-button>
</div>
</gl-dialog>
<!-- <add-business
:addDialogVisible="addDialogVisible"
@addData="add"
></add-business> -->
</div>
</template>
<script>
import Vue from 'vue'
import addBusiness from './addBusiness'
import notice from '@/common/notice'
import { businessManagenMethods, request } from '@/api'
export default {
name: 'BusinessManagement',
components: {
addBusiness
},
data() {
return {
tableData: {
......@@ -115,9 +107,7 @@ export default {
rules: {
confKey: [{ required: true }],
memo: [{ required: true }]
},
// 商户分组组件数据
// addDialogVisible: false,
}
}
},
watch: {
......@@ -145,12 +135,6 @@ export default {
}
})
},
// add() {
// this.addDialogVisible = !this.addDialogVisible
// },
// handleAddData() {
// this.addDialogVisible = !this.addDialogVisible
// },
// 接口请求
getList() {
const params = {}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!