You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

204 lines
7.2 KiB

7 years ago
<template>
6 years ago
<list-page :data="listPageConfig">
<template v-slot:searchForm>
<el-form-item label="客 户">
7 years ago
<el-input v-model="searchForm.name" clearable maxlength="50"/>
6 years ago
</el-form-item>
<el-form-item label="行政区域">
<region-selector
6 years ago
:value="temp.regionName"
limit
:limit-api="getLimitRegion"
get-children-on-select
@clear="clearSidSearch"
@select="selectRegion"
/>
6 years ago
</el-form-item>
<el-form-item label="地 址">
7 years ago
<el-input v-model="searchForm.address" clearable maxlength="100"/>
6 years ago
</el-form-item>
<el-form-item label="联系人">
7 years ago
<el-input v-model="searchForm.linkman" clearable maxlength="50"/>
6 years ago
</el-form-item>
<el-form-item label="联系电话">
7 years ago
<el-input v-model="searchForm.linkphone" clearable maxlength="20"/>
6 years ago
</el-form-item>
<el-form-item label="状 态">
<el-select v-model="searchForm.enable" clearable @clear="searchForm.enable = null">
<el-option :value="true" label="启用"/>
<el-option :value="false" label="禁用"/>
7 years ago
</el-select>
6 years ago
</el-form-item>
<el-form-item label="创建时间">
7 years ago
<el-date-picker
6 years ago
v-model="temp.ctime"
format="yyyy-MM-dd"
range-separator="-"
type="daterange"
value-format="timestamp"
7 years ago
/>
6 years ago
</el-form-item>
</template>
<template v-slot:tableColumn>
<el-table-column align="center" label="#" type="index" width="80"/>
<el-table-column align="center" label="客 户" prop="name" show-overflow-tooltip/>
<el-table-column align="center" label="行政区域" prop="regionName" show-overflow-tooltip/>
<el-table-column align="center" label="地 址" prop="address" show-overflow-tooltip/>
<el-table-column align="center" label="联系人" prop="linkman" show-overflow-tooltip/>
<el-table-column align="center" label="联系电话" prop="linkphone" show-overflow-tooltip/>
<el-table-column align="center" label="创建时间" width="150">
<template v-slot="{row}">{{ row.ctime | timestamp2Date }}</template>
</el-table-column>
<el-table-column align="center" label="状 态" width="120">
<template v-slot="{row}">
<span :class="row.enable ? 'success' : 'error'" class="dot"/>
<span>{{ row.enable ? '启用' : '禁用' }}</span>
</template>
</el-table-column>
</template>
7 years ago
<edit-dialog v-model="editDialog" :data="row" :type="type" @success="success"/>
6 years ago
</list-page>
7 years ago
</template>
<script>
import tableMixin from '@/mixin/tablePageMixin'
6 years ago
import ListPage from '@/view/app/common/ListPage'
import EditDialog from './EditDialog'
import RegionSelector from "@/component/RegionSelector"
import {add, update, del, search, getLimitRegion} from "@/api/system/customer"
import {isEmpty} from '@/util'
import {wic} from "@/util/auth"
import {elConfirm, elError, elSuccess} from "@/util/message"
6 years ago
export default {
name: "customerManagement",
mixins: [tableMixin],
6 years ago
components: {ListPage, EditDialog, RegionSelector},
6 years ago
data() {
return {
searchForm: {
name: '',
address: '',
linkman: '',
linkphone: '',
region: null,
enable: null
6 years ago
},
temp: {
regionName: null,
ctime: []
},
editDialog: false
}
},
7 years ago
6 years ago
computed: {
...wic({add, update, del}),
listPageConfig() {
return {
pageLoading: this.config.operating,
buttons: [
this.canAdd && {icon: 'el-icon-plus', e: this.add, content: '添 加'},
{icon: 'el-icon-view', e: this.see, content: '查 看'},
this.canUpdate && {icon: 'el-icon-edit', e: this.edit, content: '编 辑'},
this.canDel && {icon: 'el-icon-delete', e: this.del, content: '删 除'}
],
dataLoading: this.config.loading,
search: {
props: {model: this.searchForm},
on: {search: this.search}
},
table: {
props: {data: this.tableData},
on: {'row-click': this.rowClick}
},
pagination: {
props: {model: this.searchForm},
on: {'current-change': this.pageChange}
}
}
}
},
6 years ago
methods: {
getLimitRegion() {
return getLimitRegion.request().then(data => data.data)
7 years ago
},
6 years ago
clearSidSearch() {
this.searchForm.region = null
this.temp.regionName = null
},
6 years ago
selectRegion(obj, ids) {
this.searchForm.region = ids.join(',')
this.temp.regionName = obj.fullname
},
6 years ago
mergeSearchForm() {
return {
...this.searchForm,
startTime: this.temp.ctime ? this.temp.ctime[0] : null,
endTime: this.temp.ctime ? this.temp.ctime[1] + 86400000 : null
7 years ago
}
},
6 years ago
search() {
if (this.config.loading) return
this.config.loading = true
this.row = null
this.type = 'see'
search
.request(this.mergeSearchForm())
.then(({data: {list, total}}) => {
6 years ago
this.searchForm.total = total
this.tableData = list
})
.finally(() => this.config.loading = false)
},
6 years ago
add() {
this.type = 'add'
this.editDialog = true
},
6 years ago
see() {
if (isEmpty(this.row)) return elError('请选择要查看的客户')
this.type = 'see'
this.editDialog = true
},
6 years ago
edit() {
if (isEmpty(this.row)) return elError('请选择要编辑的客户')
this.type = 'edit'
this.editDialog = true
},
6 years ago
del() {
if (isEmpty(this.row)) return elError('请选择要删除的客户')
if (this.row.enable) return elError('已启用的客户不能删除')
6 years ago
if (this.config.operating) return
elConfirm(`确定删除客户【${this.row.name}】?`)
.then(() => {
this.config.operating = true
return del.request({id: this.row.id, name: this.row.name})
6 years ago
})
.then(() => this.success('删除成功'))
.finally(() => this.config.operating = false)
},
6 years ago
success(msg) {
elSuccess(msg)
this.editDialog = false
this.search()
7 years ago
}
}
6 years ago
}
7 years ago
</script>