This commit is contained in:
mkm 2024-08-08 15:56:33 +08:00
parent e16a5b1010
commit 1e44cee1f1
7 changed files with 474 additions and 40 deletions

View File

@ -0,0 +1,26 @@
import request from '@/utils/request'
// 配送员表列表
export function apiDeliveryServiceLists(params: any) {
return request.get({ url: '/delivery_service/deliveryservice/lists', params })
}
// 添加配送员表
export function apiDeliveryServiceAdd(params: any) {
return request.post({ url: '/delivery_service/deliveryservice/add', params })
}
// 编辑配送员表
export function apiDeliveryServiceEdit(params: any) {
return request.post({ url: '/delivery_service/deliveryservice/edit', params })
}
// 删除配送员表
export function apiDeliveryServiceDelete(params: any) {
return request.post({ url: '/delivery_service/deliveryservice/delete', params })
}
// 配送员表详情
export function apiDeliveryServiceDetail(params: any) {
return request.get({ url: '/delivery_service/deliveryservice/detail', params })
}

View File

@ -52,3 +52,8 @@ export function apiStoreRefundOrderDetail(params: any) {
export function apiStoreOrderRefund(params: any) {
return request.get({ url: '/store_order/storeOrder/refund', params })
}
// 设置配送员
export function apiStoreOrderSetDelivery(params: any) {
return request.post({ url: '/store_order/storeorder/set_delivery', params })
}

View File

@ -0,0 +1,103 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
title="详情"
:async="true"
width="550px"
:cancelButtonText="false"
:confirmButtonText="false"
>
<el-form ref="formRef" :model="formData" label-width="90px">
<el-form-item label="配送员uid" prop="uid">
<el-input v-model="formData.uid" clearable placeholder="请输入配送员uid" :readonly="true"/>
</el-form-item>
<el-form-item label="配送员名称" prop="nickname">
<el-input v-model="formData.nickname" clearable placeholder="请输入配送员名称" :readonly="true"/>
</el-form-item>
<el-form-item label="手机号码" prop="phone">
<el-input v-model="formData.phone" clearable placeholder="请输入手机号码" :readonly="true"/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status" placeholder="请选择状态" :disabled="true">
<el-radio
v-for="(item, index) in dictData.show_status"
:key="index"
:label="parseInt(item.value)"
>
{{ item.name }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="deliveryServiceDETAILS">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiDeliveryServiceAdd, apiDeliveryServiceEdit, apiDeliveryServiceDetail } from '@/api/delivery_service'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const formData = reactive({
id: '',
uid: '',
nickname: '',
phone: '',
status: '',
})
//
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]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiDeliveryServiceDetail({
id: row.id
})
setFormData(data)
}
//
const open = () => {
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,139 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="配送员uid" prop="uid">
<el-input v-model="formData.uid" clearable placeholder="请输入配送员uid" :readonly="false"/>
</el-form-item>
<el-form-item label="配送员名称" prop="nickname">
<el-input v-model="formData.nickname" clearable placeholder="请输入配送员名称" :readonly="false"/>
</el-form-item>
<el-form-item label="手机号码" prop="phone">
<el-input v-model="formData.phone" clearable placeholder="请输入手机号码" :readonly="false"/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status" placeholder="请选择状态" :disabled="false">
<el-radio
v-for="(item, index) in dictData.show_status"
:key="index"
:label="parseInt(item.value)"
>
{{ item.name }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="deliveryServiceEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiDeliveryServiceAdd, apiDeliveryServiceEdit, apiDeliveryServiceDetail } from '@/api/delivery_service'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑配送员表' : '新增配送员表'
})
//
const formData = reactive({
id: '',
uid: '',
nickname: '',
phone: '',
status: '',
})
//
const formRules = reactive<any>({
uid: [{
required: true,
message: '请输入配送员uid',
trigger: ['blur']
}],
nickname: [{
required: true,
message: '请输入配送员名称',
trigger: ['blur']
}],
phone: [{
required: true,
message: '请输入手机号码',
trigger: ['blur']
}]
})
//
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]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiDeliveryServiceDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiDeliveryServiceEdit(data)
: await apiDeliveryServiceAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,154 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form
class="mb-[-16px]"
:model="queryParams"
inline
>
<el-form-item label="配送员uid" prop="uid">
<el-input class="w-[280px]" v-model="queryParams.uid" clearable placeholder="请输入配送员uid" />
</el-form-item>
<el-form-item label="配送员名称" prop="nickname">
<el-input class="w-[280px]" v-model="queryParams.nickname" clearable placeholder="请输入配送员名称" />
</el-form-item>
<el-form-item label="手机号码" prop="phone">
<el-input class="w-[280px]" v-model="queryParams.phone" clearable placeholder="请输入手机号码" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select
v-model="queryParams.status" clearable placeholder="请选择状态">
<el-option label="全部" value=""></el-option>
<el-option
v-for="(item, index) in dictData.show_status"
:key="index"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<el-button v-perms="['delivery_service.delivery_service/add']" type="primary" @click="handleAdd">
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
<el-button
v-perms="['delivery_service.delivery_service/delete']"
:disabled="!selectData.length"
@click="handleDelete(selectData)"
>
删除
</el-button>
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="id" prop="id" show-overflow-tooltip />
<el-table-column label="配送员uid" prop="uid" show-overflow-tooltip />
<el-table-column label="配送员名称" prop="nickname" show-overflow-tooltip />
<el-table-column label="手机号码" prop="phone" show-overflow-tooltip />
<el-table-column label="状态" prop="status">
<template #default="{ row }">
<dict-value :options="dictData.show_status" :value="row.status" />
</template>
</el-table-column>
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['delivery_service.delivery_service/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['delivery_service.delivery_service/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
</template>
<script lang="ts" setup name="deliveryServiceLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiDeliveryServiceLists, apiDeliveryServiceDelete } from '@/api/delivery_service'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
//
const queryParams = reactive({
uid: '',
nickname: '',
phone: '',
status: ''
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('show_status')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiDeliveryServiceLists,
params: queryParams
})
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
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 apiDeliveryServiceDelete({ id })
getLists()
}
getLists()
</script>

View File

@ -9,7 +9,20 @@
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="配送员">
<el-select
v-model="formData.delivery_uid"
placeholder="请选择配送人员"
size="large"
style="width: 240px"
>
<el-option
v-for="item in delivery_list"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-form>
</popup>
</div>
@ -18,9 +31,10 @@
<script lang="ts" setup name="storeOrderEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiStoreOrderAdd, apiStoreOrderEdit, apiStoreOrderDetail } from '@/api/store_order'
import { apiStoreOrderSetDelivery } from '@/api/store_order'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
import { apiDeliveryServiceLists } from '@/api/delivery_service'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
@ -32,56 +46,38 @@ const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑订单表' : '新增订单表'
return (mode.value = '设置配送人员')
})
const delivery_list = ref([])
//
const formData = reactive({
id: '',
delivery_uid: ''
})
//
const formRules = reactive<any>({
const formRules = reactive<any>({})
const getDetail = () => {
apiDeliveryServiceLists({}).then((res) => {
delivery_list.value = res.lists
})
//
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]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiStoreOrderDetail({
id: row.id
})
setFormData(data)
}
getDetail()
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiStoreOrderEdit(data)
: await apiStoreOrderAdd(data)
const data = { ...formData }
await apiStoreOrderSetDelivery(data)
popupRef.value?.close()
emit('success')
}
const setFormData = async (data: Record<any, any>) => {
formData.id = data.id
}
//
const open = (type = 'add') => {
mode.value = type
@ -93,11 +89,8 @@ const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
setFormData
})
</script>

View File

@ -156,6 +156,9 @@
<el-button type="primary" link @click="handleDetai(row)"
>详情</el-button
>
<el-button type="primary" link @click="handleDelivery(row)"
>设置配送人员</el-button
>
</template>
</el-table-column>
</el-table>
@ -164,7 +167,13 @@
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<!-- <edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" /> -->
<edit-popup
v-if="showEdit"
ref="editRef"
:dict-data="dictData"
@success="getLists"
@close="showEdit = false"
/>
<details-popup
v-if="showDetails"
ref="detailsRef"
@ -320,7 +329,7 @@ const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
// editRef.value?.setFormData(data)
}
//
@ -337,6 +346,11 @@ const handleDelete = async (id: number | any[]) => {
await apiStoreOrderDelete({ id })
getLists()
}
const handleDelivery = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
getLists()
</script>