页面修改

This commit is contained in:
zmj 2023-11-10 17:20:17 +08:00
parent f775b60a74
commit 91e6961cd4
4 changed files with 472 additions and 319 deletions

27
admin/src/api/common.ts Normal file
View File

@ -0,0 +1,27 @@
import request from '@/utils/request'
// 省列表
export function apiProvinceList() {
return request.get({ url: '/common/province' })
}
// 市列表
export function apiCityList(params: any) {
return request.get({ url: '/common/city', params })
}
// 区列表
export function apiAreaList(params: any) {
return request.get({ url: '/common/area', params })
}
// 镇列表
export function apiStreetList(params: any) {
return request.get({ url: '/common/street', params })
}
// 村列表
export function apiVillageList(params: any) {
return request.get({ url: '/common/village', params })
}
// 队列表
export function apiBrigadeList() {
return request.get({ url: '/common/brigade' })
}

View File

@ -2,7 +2,7 @@ const config = {
terminal: 1, //终端 terminal: 1, //终端
title: '后台管理系统', //网站默认标题 title: '后台管理系统', //网站默认标题
version: '1.6.0', //版本号 version: '1.6.0', //版本号
baseUrl: `${import.meta.env.VITE_APP_BASE_URL || ''}/`, //请求接口域名 baseUrl: `${import.meta.env.VITE_APP_BASE_URL || 'http://192.168.1.16:8081'}/`, //请求接口域名
urlPrefix: 'adminapi', //请求默认前缀 urlPrefix: 'adminapi', //请求默认前缀
timeout: 10 * 1000 //请求超时时长 timeout: 10 * 1000 //请求超时时长
} }

View File

@ -1,163 +1,305 @@
<template> <template>
<div class="edit-popup"> <div class="edit-popup">
<popup <popup ref="popupRef" :title="popupTitle" :async="true" width="550px" @confirm="handleSubmit" @close="handleClose">
ref="popupRef" <el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
:title="popupTitle" <el-form-item label="子商户名" prop="sub_merchant_name">
:async="true" <el-input v-model="formData.sub_merchant_name" clearable placeholder="请输入子商户名" />
width="550px" </el-form-item>
@confirm="handleSubmit" <el-form-item label="子商户号" prop="sub_mch_id">
@close="handleClose" <el-input v-model="formData.sub_mch_id" clearable placeholder="请输入子商户号" />
> </el-form-item>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules"> <el-form-item label="省" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]" prop="province">
<el-form-item label="子商户名" prop="sub_merchant_name"> <el-select v-model="formData.province" placeholder="请选择省" clearable @change="province_change"
<el-input v-model="formData.sub_merchant_name" clearable placeholder="请输入子商户名" /> :style="{ width: '100%' }">
</el-form-item> <el-option v-for="(item, index) in provinceOptions" :key="index" :label="item.province_name"
<el-form-item label="子商户号" prop="sub_mch_id"> :value="item.province_code"></el-option>
<el-input v-model="formData.sub_mch_id" clearable placeholder="请输入子商户号" /> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="省" prop="province">
<el-input v-model="formData.province" clearable placeholder="请输入省" /> <el-form-item label="市" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]" prop="city">
</el-form-item> <el-select v-model="formData.city" placeholder="请选择市" clearable @change="city_change"
<el-form-item label="市" prop="city"> :style="{ width: '100%' }">
<el-input v-model="formData.city" clearable placeholder="请输入市" /> <el-option v-for="(item, index) in cityOptions" :key="index" :label="item.city_name"
</el-form-item> :value="item.city_code"></el-option>
<el-form-item label="区/县" prop="area"> </el-select>
<el-input v-model="formData.area" clearable placeholder="请输入区/县" /> </el-form-item>
</el-form-item> <el-form-item label="区/县" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]" prop="area">
<el-form-item label="镇" prop="street"> <el-select v-model="formData.area" placeholder="请选择区/县" clearable @change="area_change"
<el-input v-model="formData.street" clearable placeholder="请输入镇" /> :style="{ width: '100%' }">
</el-form-item> <el-option v-for="(item, index) in areaOptions" :key="index" :label="item.area_name"
<el-form-item label="村" prop="village"> :value="item.area_code"></el-option>
<el-input v-model="formData.village" clearable placeholder="请输入村" /> </el-select>
</el-form-item> </el-form-item>
</el-form> <el-form-item label="镇" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]" prop="street">
</popup> <el-select v-model="formData.street" placeholder="请选择镇" clearable @change="street_change"
</div> :style="{ width: '100%' }">
</template> <el-option v-for="(item, index) in streetOptions" :key="index" :label="item.street_name"
:value="item.street_code"></el-option>
<script lang="ts" setup name="subMerchantEdit"> </el-select>
import type { FormInstance } from 'element-plus' </el-form-item>
import Popup from '@/components/popup/index.vue' <!-- <el-form-item label="村" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]" prop="village">
import { apiSubMerchantAdd, apiSubMerchantEdit, apiSubMerchantDetail } from '@/api/sub_merchant' <el-select v-model="formData.village" placeholder="请选择村" clearable @change="village_change"
import { timeFormat } from '@/utils/util' :style="{ width: '100%' }">
import type { PropType } from 'vue' <el-option v-for="(item, index) in villageOptions" :key="index" :label="item.village_name"
defineProps({ :value="item.village_code"></el-option>
dictData: { </el-select>
type: Object as PropType<Record<string, any[]>>, </el-form-item> -->
default: () => ({}) <!-- <el-form-item label="省" prop="province">
} <el-input v-model="formData.province" clearable placeholder="请输入省" />
}) </el-form-item>
const emit = defineEmits(['success', 'close']) <el-form-item label="市" prop="city">
const formRef = shallowRef<FormInstance>() <el-input v-model="formData.city" clearable placeholder="请输入市" />
const popupRef = shallowRef<InstanceType<typeof Popup>>() </el-form-item>
const mode = ref('add') <el-form-item label="区/县" prop="area">
<el-input v-model="formData.area" clearable placeholder="请输入区/县" />
</el-form-item>
// <el-form-item label="镇" prop="street">
const popupTitle = computed(() => { <el-input v-model="formData.street" clearable placeholder="请输入镇" />
return mode.value == 'edit' ? '编辑微信支付子商户表' : '新增微信支付子商户表' </el-form-item>
}) <el-form-item label="村" prop="village">
<el-input v-model="formData.village" clearable placeholder="请输入村" />
// </el-form-item> -->
const formData = reactive({
id: '', </el-form>
sub_merchant_name: '', </popup>
sub_mch_id: '', </div>
province: '', </template>
city: '',
area: '', <script lang="ts" setup name="subMerchantEdit">
street: '', import type { FormInstance } from 'element-plus'
village: '', import Popup from '@/components/popup/index.vue'
}) import { apiSubMerchantAdd, apiSubMerchantEdit, apiSubMerchantDetail } from '@/api/sub_merchant'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
// import {
const formRules = reactive<any>({ apiCityList,
sub_merchant_name: [{ apiAreaList,
required: true, apiStreetList,
message: '请输入子商户名', apiProvinceList,
trigger: ['blur'] apiVillageList,
}], } from "@/api/common";
sub_mch_id: [{ defineProps({
required: true, dictData: {
message: '请输入子商户号', type: Object as PropType<Record<string, any[]>>,
trigger: ['blur'] default: () => ({})
}], }
province: [{ })
required: true, const emit = defineEmits(['success', 'close'])
message: '请输入省', const formRef = shallowRef<FormInstance>()
trigger: ['blur'] const popupRef = shallowRef<InstanceType<typeof Popup>>()
}], const mode = ref('add')
city: [{
required: true,
message: '请输入市', //
trigger: ['blur'] const popupTitle = computed(() => {
}], return mode.value == 'edit' ? '编辑微信支付子商户表' : '新增微信支付子商户表'
area: [{ })
required: true,
message: '请输入区/县', //
trigger: ['blur'] const formData = reactive({
}], id: '',
street: [{ sub_merchant_name: '',
required: true, sub_mch_id: '',
message: '请输入镇', province: '',
trigger: ['blur'] city: '',
}], area: '',
village: [{ street: '',
required: true, village: '',
message: '请输入村',
trigger: ['blur'] })
}], const addressList = reactive(['province', 'city', 'area', 'street', 'village'])
})
//
const formRules = reactive<any>({
// sub_merchant_name: [{
const setFormData = async (data: Record<any, any>) => { required: true,
for (const key in formData) { message: '请输入子商户名',
if (data[key] != null && data[key] != undefined) { trigger: ['blur']
//@ts-ignore }],
formData[key] = data[key] sub_mch_id: [{
} required: true,
} message: '请输入子商户号',
trigger: ['blur']
}],
} province: [{
required: true,
const getDetail = async (row: Record<string, any>) => { message: '请输入省',
const data = await apiSubMerchantDetail({ trigger: ['blur']
id: row.id }],
}) city: [{
setFormData(data) required: true,
} message: '请输入市',
trigger: ['blur']
}],
// area: [{
const handleSubmit = async () => { required: true,
await formRef.value?.validate() message: '请输入区/县',
const data = { ...formData, } trigger: ['blur']
mode.value == 'edit' }],
? await apiSubMerchantEdit(data) street: [{
: await apiSubMerchantAdd(data) required: true,
popupRef.value?.close() message: '请输入镇',
emit('success') trigger: ['blur']
} }],
village: [{
// required: true,
const open = (type = 'add') => { message: '请输入村',
mode.value = type trigger: ['blur']
popupRef.value?.open() }],
} })
//
const handleClose = () => { //
emit('close') const setFormData = async (data: Record<any, any>) => {
} for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
defineExpose({ }
open, }
setFormData,
getDetail
}) }
</script>
const getDetail = async (row: Record<string, any>) => {
const data = await apiSubMerchantDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiSubMerchantEdit(data)
: await apiSubMerchantAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = async (type = 'add') => {
console.log(formData)
mode.value = type
popupRef.value?.open()
if (type == 'add') {
addressFn()
}
if (type == 'edit') {
await nextTick()
for (let key in formData) {
if (addressList.includes(key)) {
formData[key] = String(formData[key])
}
}
await addressFn()
await province_change()
await city_change()
await area_change()
await street_change()
}
}
//
const handleClose = () => {
emit('close')
}
//
const provinceOptions = reactive([])
const cityOptions = reactive([])
const areaOptions = reactive([])
const Options = reactive([])
const streetOptions = reactive([])
const villageOptions = reactive([])
const addressFn = () => {
apiProvinceList().then(res => {
res.forEach((item: any) => {
provinceOptions.push(
// @ts-ignore
{
province_name: item.province_name,
province_code: item.province_code
})
});
})
}
const province_change = async () => {
cityOptions.splice(0, cityOptions.length)
let res = await apiCityList({ city: formData.province })
res.forEach((item: any) => {
cityOptions.push(
// @ts-ignore
{
city_name: item.city_name,
city_code: item.city_code
})
});
}
const city_change = async () => {
areaOptions.splice(0, areaOptions.length)
let res = await apiAreaList({ area: formData.city })
res.forEach((item: any) => {
areaOptions.push(
// @ts-ignore
{
area_name: item.area_name,
area_code: item.area_code
})
});
}
const area_change = async () => {
streetOptions.splice(0, streetOptions.length)
let res = await apiStreetList({ street: formData.area })
res.forEach((item: any) => {
streetOptions.push(
// @ts-ignore
{
street_name: item.street_name,
street_code: item.street_code
})
});
}
const street_change = async () => {
villageOptions.splice(0, villageOptions.length)
let res = await apiVillageList({ village: formData.street })
res.forEach((item: any) => {
villageOptions.push(
// @ts-ignore
{
village_name: item.village_name,
village_code: item.village_code
})
});
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -1,155 +1,139 @@
<template> <template>
<div> <div>
<el-card class="!border-none mb-4" shadow="never"> <el-card class="!border-none mb-4" shadow="never">
<el-form <el-form class="mb-[-16px]" :model="queryParams" inline>
class="mb-[-16px]" <el-form-item label="子商户名" prop="sub_merchant_name">
:model="queryParams" <el-input class="w-[280px]" v-model="queryParams.sub_merchant_name" clearable placeholder="请输入子商户名" />
inline </el-form-item>
> <el-form-item label="子商户号" prop="sub_mch_id">
<el-form-item label="子商户名" prop="sub_merchant_name"> <el-input class="w-[280px]" v-model="queryParams.sub_mch_id" clearable placeholder="请输入子商户号" />
<el-input class="w-[280px]" v-model="queryParams.sub_merchant_name" clearable placeholder="请输入子商户名" /> </el-form-item>
</el-form-item> <!-- <el-form-item label="省" prop="province">
<el-form-item label="子商户号" prop="sub_mch_id"> <el-input class="w-[280px]" v-model="queryParams.province" clearable placeholder="请输入省" />
<el-input class="w-[280px]" v-model="queryParams.sub_mch_id" clearable placeholder="请输入子商户号" /> </el-form-item>
</el-form-item> <el-form-item label="市" prop="city">
<el-form-item label="省" prop="province"> <el-input class="w-[280px]" v-model="queryParams.city" clearable placeholder="请输入市" />
<el-input class="w-[280px]" v-model="queryParams.province" clearable placeholder="请输入省" /> </el-form-item>
</el-form-item> <el-form-item label="区/县" prop="area">
<el-form-item label="市" prop="city"> <el-input class="w-[280px]" v-model="queryParams.area" clearable placeholder="请输入区/县" />
<el-input class="w-[280px]" v-model="queryParams.city" clearable placeholder="请输入市" /> </el-form-item>
</el-form-item> <el-form-item label="镇" prop="street">
<el-form-item label="区/县" prop="area"> <el-input class="w-[280px]" v-model="queryParams.street" clearable placeholder="请输入镇" />
<el-input class="w-[280px]" v-model="queryParams.area" clearable placeholder="请输入区/县" /> </el-form-item>
</el-form-item> <el-form-item label="村" prop="village">
<el-form-item label="镇" prop="street"> <el-input class="w-[280px]" v-model="queryParams.village" clearable placeholder="请输入村" />
<el-input class="w-[280px]" v-model="queryParams.street" clearable placeholder="请输入镇" /> </el-form-item> -->
</el-form-item>
<el-form-item label="村" prop="village"> <el-form-item>
<el-input class="w-[280px]" v-model="queryParams.village" clearable placeholder="请输入村" /> <el-button type="primary" @click="resetPage">查询</el-button>
</el-form-item> <el-button @click="resetParams">重置</el-button>
<el-form-item> </el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button> </el-form>
<el-button @click="resetParams">重置</el-button> </el-card>
</el-form-item> <el-card class="!border-none" v-loading="pager.loading" shadow="never">
</el-form> <el-button v-perms="['sub_merchant/add']" type="primary" @click="handleAdd">
</el-card> <template #icon>
<el-card class="!border-none" v-loading="pager.loading" shadow="never"> <icon name="el-icon-Plus" />
<el-button v-perms="['sub_merchant/add']" type="primary" @click="handleAdd"> </template>
<template #icon> 新增
<icon name="el-icon-Plus" /> </el-button>
</template> <el-button v-perms="['sub_merchant/delete']" :disabled="!selectData.length" @click="handleDelete(selectData)">
新增 删除
</el-button> </el-button>
<el-button <div class="mt-4">
v-perms="['sub_merchant/delete']" <el-table :data="pager.lists" @selection-change="handleSelectionChange">
:disabled="!selectData.length" <el-table-column type="selection" width="55" />
@click="handleDelete(selectData)" <el-table-column label="子商户名" prop="sub_merchant_name" show-overflow-tooltip />
> <el-table-column label="子商户号" prop="sub_mch_id" show-overflow-tooltip />
删除 <el-table-column label="省" prop="province" show-overflow-tooltip />
</el-button> <el-table-column label="市" prop="city" show-overflow-tooltip />
<div class="mt-4"> <el-table-column label="区/县" prop="area" show-overflow-tooltip />
<el-table :data="pager.lists" @selection-change="handleSelectionChange"> <el-table-column label="镇" prop="street" show-overflow-tooltip />
<el-table-column type="selection" width="55" /> <!-- <el-table-column label="村" prop="village" show-overflow-tooltip /> -->
<el-table-column label="子商户名" prop="sub_merchant_name" show-overflow-tooltip />
<el-table-column label="子商户号" prop="sub_mch_id" show-overflow-tooltip /> <el-table-column label="操作" width="120" fixed="right">
<el-table-column label="省" prop="province" show-overflow-tooltip /> <template #default="{ row }">
<el-table-column label="市" prop="city" show-overflow-tooltip /> <el-button v-perms="['sub_merchant/edit']" type="primary" link @click="handleEdit(row)">
<el-table-column label="区/县" prop="area" show-overflow-tooltip /> 编辑
<el-table-column label="镇" prop="street" show-overflow-tooltip /> </el-button>
<el-table-column label="村" prop="village" show-overflow-tooltip /> <el-button v-perms="['sub_merchant/delete']" type="danger" link @click="handleDelete(row.id)">
<el-table-column label="操作" width="120" fixed="right"> 删除
<template #default="{ row }"> </el-button>
<el-button </template>
v-perms="['sub_merchant/edit']" </el-table-column>
type="primary" </el-table>
link </div>
@click="handleEdit(row)" <div class="flex justify-end mt-4">
> <pagination v-model="pager" @change="getLists" />
编辑 </div>
</el-button> </el-card>
<el-button <edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
v-perms="['sub_merchant/delete']" </div>
type="danger" </template>
link
@click="handleDelete(row.id)" <script lang="ts" setup name="subMerchantLists">
> import { usePaging } from '@/hooks/usePaging'
删除 import { useDictData } from '@/hooks/useDictOptions'
</el-button> import { apiSubMerchantLists, apiSubMerchantDelete } from '@/api/sub_merchant'
</template> import { timeFormat } from '@/utils/util'
</el-table-column> import feedback from '@/utils/feedback'
</el-table> import EditPopup from './edit.vue'
</div>
<div class="flex mt-4 justify-end"> const editRef = shallowRef<InstanceType<typeof EditPopup>>()
<pagination v-model="pager" @change="getLists" /> //
</div> const showEdit = ref(false)
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div> //
</template> const queryParams = reactive({
sub_merchant_name: '',
<script lang="ts" setup name="subMerchantLists"> sub_mch_id: '',
import { usePaging } from '@/hooks/usePaging' province: '',
import { useDictData } from '@/hooks/useDictOptions' city: '',
import { apiSubMerchantLists, apiSubMerchantDelete } from '@/api/sub_merchant' area: '',
import { timeFormat } from '@/utils/util' street: '',
import feedback from '@/utils/feedback' village: '',
import EditPopup from './edit.vue' })
const editRef = shallowRef<InstanceType<typeof EditPopup>>() //
// const selectData = ref<any[]>([])
const showEdit = ref(false)
//
const handleSelectionChange = (val: any[]) => {
// selectData.value = val.map(({ id }) => id)
const queryParams = reactive({ }
sub_merchant_name: '',
sub_mch_id: '', //
province: '', const { dictData } = useDictData('')
city: '',
area: '', //
street: '', const { pager, getLists, resetParams, resetPage } = usePaging({
village: '', fetchFun: apiSubMerchantLists,
}) params: queryParams
})
//
const selectData = ref<any[]>([]) //
const handleAdd = async () => {
// showEdit.value = true
const handleSelectionChange = (val: any[]) => { await nextTick()
selectData.value = val.map(({ id }) => id) editRef.value?.open('add')
} }
// //
const { dictData } = useDictData('') const handleEdit = async (data: any) => {
showEdit.value = true
// await nextTick()
const { pager, getLists, resetParams, resetPage } = usePaging({ editRef.value?.open('edit')
fetchFun: apiSubMerchantLists, editRef.value?.setFormData(data)
params: queryParams }
})
//
// const handleDelete = async (id: number | any[]) => {
const handleAdd = async () => { await feedback.confirm('确定要删除?')
showEdit.value = true await apiSubMerchantDelete({ id })
await nextTick() getLists()
editRef.value?.open('add') }
}
getLists()
// </script>
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiSubMerchantDelete({ id })
getLists()
}
getLists()
</script>