fanzherong_v пре 4 дана
родитељ
комит
0aadd2b7fe

+ 79 - 0
snowy-admin-web/src/views/biz/bizloaddispatch/form.vue

@@ -0,0 +1,79 @@
+<template>
+	<xn-form-container
+		:title="formData.id ? '编辑起卸点位信息' : '增加起卸点位信息'"
+		:width="700"
+		v-model:open="open"
+		:destroy-on-close="true"
+		@close="onClose"
+	>
+		<a-form ref="formRef" :model="formData" :rules="formRules" :wrapper-col="wrapperCol" :label-col="labelCol">
+			<a-form-item label="起卸点位:" name="loadPoint">
+				<a-input v-model:value="formData.loadPoint" placeholder="请输入装货点位" allow-clear />
+			</a-form-item>
+		</a-form>
+		<template #footer>
+			<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
+			<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
+		</template>
+	</xn-form-container>
+</template>
+
+<script setup name="bizLoadPointForm">
+	import { cloneDeep } from 'lodash-es'
+	import { required } from '@/utils/formRules'
+	import bizLoadPointApi from '@/api/biz/bizLoadPointApi'
+	// 抽屉状态
+	const open = ref(false)
+	const emit = defineEmits({ successful: null })
+	const formRef = ref()
+	// 表单数据
+	const formData = ref({})
+	const submitLoading = ref(false)
+
+	//设置表单样式
+	const labelCol = ref({ span: 4})
+	const wrapperCol = ref({ span: 16})
+
+	// 打开抽屉
+	const onOpen = (record) => {
+		open.value = true
+		if (record) {
+			let recordData = cloneDeep(record)
+			formData.value = Object.assign({}, recordData)
+		}
+	}
+	// 关闭抽屉
+	const onClose = () => {
+		formRef.value.resetFields()
+		formData.value = {}
+		open.value = false
+	}
+	// 默认要校验的
+	const formRules = {
+		loadPoint: [required('请输入装货点位')],
+	}
+	// 验证并提交数据
+	const onSubmit = () => {
+		formRef.value
+			.validate()
+			.then(() => {
+				submitLoading.value = true
+				const formDataParam = cloneDeep(formData.value)
+				formDataParam.loadType = '1'
+				bizLoadPointApi
+					.bizLoadPointSubmitForm(formDataParam, formDataParam.id)
+					.then(() => {
+						onClose()
+						emit('successful')
+					})
+					.finally(() => {
+						submitLoading.value = false
+					})
+			})
+			.catch(() => {})
+	}
+	// 抛出函数
+	defineExpose({
+		onOpen
+	})
+</script>

+ 157 - 0
snowy-admin-web/src/views/biz/bizloaddispatch/index.vue

@@ -0,0 +1,157 @@
+<template>
+	<a-card :bordered="false" style="margin-bottom: 10px" class="mb-2">
+		<a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
+			<a-row :gutter="24">
+				<a-col :span="6">
+					<a-form-item label="点位名称" name="loadPoint">
+						<a-input v-model:value="searchFormState.loadPoint" placeholder="查询点位名称" allow-clear  />
+					</a-form-item>
+				</a-col>
+				<a-col :span="6">
+					<a-button type="primary" @click="tableRef.refresh()">查询</a-button>
+					<a-button style="margin: 0 8px" @click="reset">重置</a-button>
+
+					<a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('bizLoadPointAdd')">
+						<template #icon><plus-outlined /></template>
+						新增
+					</a-button>
+				</a-col>
+			</a-row>
+		</a-form>
+	</a-card>
+	<a-card :bordered="false" style="margin-bottom: 10px" class="mb-2">
+		<s-table
+			ref="tableRef"
+			:columns="columns"
+			:data="loadData"
+			bordered
+			:row-key="(record) => record.id"
+		>
+			<template #bodyCell="{ column, record, index }">
+				<template v-if="column.dataIndex === 'serial'">
+					{{ index + 1 }}
+				</template>
+				<template v-if="column.dataIndex === 'action'">
+					<a-space>
+						<a @click="formRef.onOpen(record)" v-if="hasPerm('bizLoadPointEdit')">编辑</a>
+						<a-divider type="vertical" v-if="hasPerm(['bizLoadPointEdit', 'bizLoadPointDelete'], 'and')" />
+						<a-button type="link" danger size="small" v-if="hasPerm('bizLoadPointDelete')" @click="deleteConfig(record)">删除</a-button>
+
+						<a-divider type="vertical" v-if="hasPerm(['bizLoadPointEdit', 'bizLoadPointDelete'], 'or') && hasPerm('bizLoadUser')" />
+						<a @click="userIndexRef.onOpen(record)" v-if="hasPerm('bizLoadUser')">起卸员</a>
+
+						<a-divider type="vertical" v-if="hasPerm(['bizLoadPointEdit', 'bizLoadPointDelete', 'bizLoadUser'], 'or') && hasPerm('bizLoadTime')" />
+						<a @click="timeIndexRef.onOpen(record)" v-if="hasPerm('bizLoadTime')">起卸时间</a>
+					</a-space>
+				</template>
+			</template>
+		</s-table>
+	</a-card>
+
+	<Form ref="formRef" @successful="tableRef.refresh()" />
+	<UserIndex ref="userIndexRef" @successful="tableRef.refresh()" />
+	<TimeIndex ref="timeIndexRef" @successful="tableRef.refresh()" />
+</template>
+
+<script setup name="bizloadpoint">
+	import { cloneDeep } from 'lodash-es'
+	import Form from './form.vue'
+	import UserIndex from './userIndex.vue'
+	import TimeIndex from './timeIndex.vue'
+	import bizLoadPointApi from '@/api/biz/bizLoadPointApi'
+	import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
+	import {Modal} from 'ant-design-vue';
+	import {createVNode} from 'vue';
+
+	const submitLoading = ref(false)
+	const searchFormState = ref({})
+	const searchFormRef = ref()
+	const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
+
+	const tableRef = ref()
+	const formRef = ref()
+	const userIndexRef = ref()
+	const timeIndexRef = ref()
+
+	const columns = [
+		{
+			title: '序号',
+			width: 50,
+			dataIndex: 'serial',
+			align:'center'
+		},
+		{
+			title: '起卸点位',
+			dataIndex: 'loadPoint',
+			align: 'center'
+		},
+		{
+			title: '创建时间',
+			dataIndex: 'createTime',
+			align: 'center'
+		},
+	]
+	// 操作栏通过权限判断是否显示
+	if (hasPerm(['bizLoadPointEdit', 'bizLoadPointDelete', 'bizLoadUser', 'bizLoadTime'], 'or')) {
+		columns.push({
+			title: '操作',
+			dataIndex: 'action',
+			align: 'center',
+			width: 320
+		})
+	}
+	const selectedRowKeys = ref([])
+	// 列表选择配置
+	const options = {
+		// columns数字类型字段加入 needTotal: true 可以勾选自动算账
+		alert: {
+			show: true,
+			clear: () => {
+				selectedRowKeys.value = ref([])
+			}
+		},
+		rowSelection: {
+			onChange: (selectedRowKey, selectedRows) => {
+				selectedRowKeys.value = selectedRowKey
+			}
+		}
+	}
+	const loadData = (parameter) => {
+		const searchFormParam = cloneDeep(searchFormState.value)
+		searchFormParam.loadType = '1'
+		return bizLoadPointApi.bizLoadPointPage(Object.assign(parameter, searchFormParam)).then((data) => {
+			return data
+		})
+	}
+	// 重置
+	const reset = () => {
+		searchFormRef.value.resetFields()
+		tableRef.value.refresh(true)
+	}
+	// 删除
+	const deleteConfig = (record) => {
+		Modal.confirm({
+			title: '确定删除该数据吗?',
+			icon: createVNode(ExclamationCircleOutlined),
+			content: '',
+			onOk() {
+				submitLoading.value = true
+				let params = [
+					{
+						id: record.id
+					}
+				]
+
+				bizLoadPointApi
+					.bizLoadPointDelete(params)
+					.then(() => {
+						tableRef.value.refresh(true)
+					})
+					.finally(() => {
+						submitLoading.value = false
+					})
+			},
+			onCancel() {}
+		})
+	}
+</script>

+ 101 - 0
snowy-admin-web/src/views/biz/bizloaddispatch/timeAddForm.vue

@@ -0,0 +1,101 @@
+<template>
+	<xn-form-container
+		title="增加起卸时间配置"
+		:width="700"
+		v-model:open="open"
+		:destroy-on-close="true"
+		@close="onClose"
+	>
+		<a-form ref="formRef" :model="formData" :rules="formRules" :wrapper-col="wrapperCol" :label-col="labelCol">
+			<a-form-item label="起卸时间段:" name="loadStartEndTime">
+				<a-range-picker v-model:value="formData.loadStartEndTime" value-format="YYYY-MM-DD HH:mm" show-time :disabled-date="disabledDate" style="width: 100%" />
+			</a-form-item>
+<!--			<a-form-item label="可约次数:" name="availableNumber">
+				<a-input-number v-model:value="formData.availableNumber" style="width: 100%;" placeholder="请输入可约次数" allow-clear />
+			</a-form-item>-->
+		</a-form>
+		<template #footer>
+			<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
+			<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
+		</template>
+	</xn-form-container>
+</template>
+
+<script setup name="bizLoadTimeForm">
+	import { cloneDeep } from 'lodash-es'
+	import { message } from 'ant-design-vue'
+	import { required } from '@/utils/formRules'
+	import bizLoadTimeApi from '@/api/biz/bizLoadTimeApi'
+	import dayjs from 'dayjs'
+
+	// 抽屉状态
+	const open = ref(false)
+	const emit = defineEmits({ successful: null })
+	const formRef = ref()
+	// 表单数据
+	const formData = ref({})
+	const submitLoading = ref(false)
+
+	//设置表单样式
+	const labelCol = ref({ span: 4})
+	const wrapperCol = ref({ span: 16})
+
+	// 当前时间
+	const nowTime = ref(new Date())
+	// 禁用时间范围
+	const disabledDate = (current) => {
+		return (
+			(current && current < dayjs(nowTime.value).startOf('time'))
+		)
+	}
+
+	// 打开抽屉
+	const onOpen = (record, pointId) => {
+		open.value = true
+		formData.value = {
+			confStartEndTime: '',
+			goodsJson: []
+		}
+		formData.value.pointId = pointId
+		if (record) {
+			let recordData = cloneDeep(record)
+			formData.value = Object.assign({}, recordData)
+		}
+	}
+	// 关闭抽屉
+	const onClose = () => {
+		formRef.value.resetFields()
+		formData.value = {}
+		open.value = false
+	}
+	// 默认要校验的
+	const formRules = {
+		loadStartEndTime: [required('请选择装货时间段')],
+		availableNumber: [required('请输入可预约次数')],
+	}
+	// 验证并提交数据
+	const onSubmit = () => {
+		formRef.value
+			.validate()
+			.then(() => {
+				submitLoading.value = true
+				const formDataParam = cloneDeep(formData.value)
+				formDataParam.beginTime = formDataParam.loadStartEndTime[0]+":00"
+				formDataParam.endTime = formDataParam.loadStartEndTime[1]+":00"
+				bizLoadTimeApi
+					.bizLoadTimeSubmitForm(formDataParam, formDataParam.id)
+					.then(() => {
+						onClose()
+						emit('successful')
+					})
+					.finally(() => {
+						submitLoading.value = false
+					})
+			})
+			.catch(() => {})
+	}
+	// 抛出函数
+	defineExpose({
+		onOpen
+	})
+</script>

+ 92 - 0
snowy-admin-web/src/views/biz/bizloaddispatch/timeAlreadyForm.vue

@@ -0,0 +1,92 @@
+<template>
+	<xn-form-container
+		:title="formData.id ? '编辑装货时间配置' : '增加装货时间配置'"
+		:width="700"
+		v-model:open="open"
+		:destroy-on-close="true"
+		@close="onClose"
+	>
+		<a-descriptions :column="4" size="middle" bordered class="mb-2" :label-style="labelStyle" :contentStyle="contentStyle">
+			<a-descriptions-item label="装货点位" :span="4">{{ formData.pointId }}</a-descriptions-item>
+			<a-descriptions-item label="装货段" :span="4">{{ formData.beginTime }} ~ {{ formData.endTime }}</a-descriptions-item>
+			<a-descriptions-item label="原可约次数" :span="4">{{ availableNumber }}</a-descriptions-item>
+			<a-descriptions-item label="已约次数" :span="4">{{ alreadyNumber }} </a-descriptions-item>
+			<a-descriptions-item label="剩余可约次数" :span="4">{{ lastNumber }} </a-descriptions-item>
+		</a-descriptions>
+
+		<a-form ref="formRef" :model="formData" :rules="formRules" :wrapper-col="wrapperCol" :label-col="labelCol">
+			<a-form-item label="可约次数:" name="availableNumber">
+				<a-input-number v-model:value="formData.availableNumber" :min="alreadyNumber" style="width: 100%;" placeholder="请输入可约次数" allow-clear />
+			</a-form-item>
+		</a-form>
+
+		<div style="color: red;">提示:不得小于当前已约次数 {{ alreadyNumber }} </div>
+
+		<template #footer>
+			<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
+			<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
+		</template>
+	</xn-form-container>
+</template>
+
+<script setup name="bizLoadTimeForm">
+	import { cloneDeep } from 'lodash-es'
+	import { required } from '@/utils/formRules'
+	import bizLoadTimeApi from '@/api/biz/bizLoadTimeApi'
+	// 抽屉状态
+	const open = ref(false)
+	const emit = defineEmits({ successful: null })
+	const formRef = ref()
+	// 表单数据
+	const formData = ref({})
+	const submitLoading = ref(false)
+	const availableNumber = ref("")
+	const alreadyNumber = ref("")
+	const lastNumber = ref("")	
+
+	// 打开抽屉
+	const onOpen = (record, pointId) => {
+		open.value = true
+		formData.value.pointId = pointId
+		if (record) {
+			let recordData = cloneDeep(record)
+			formData.value = Object.assign({}, recordData)
+			availableNumber.value = Number(formData.value.availableNumber)
+			alreadyNumber.value = Number(formData.value.alreadyNumber)
+			lastNumber.value = availableNumber.value - alreadyNumber.value
+		}
+	}
+	// 关闭抽屉
+	const onClose = () => {
+		formRef.value.resetFields()
+		formData.value = {}
+		open.value = false
+	}
+	// 默认要校验的
+	const formRules = {
+		availableNumber: [required("请输入可约次数")]
+	}
+	// 验证并提交数据
+	const onSubmit = () => {
+		formRef.value
+			.validate()
+			.then(() => {
+				submitLoading.value = true
+				const formDataParam = cloneDeep(formData.value)
+				bizLoadTimeApi
+					.bizLoadTimeSubmitForm(formDataParam, formDataParam.id)
+					.then(() => {
+						onClose()
+						emit('successful')
+					})
+					.finally(() => {
+						submitLoading.value = false
+					})
+			})
+			.catch(() => {})
+	}
+	// 抛出函数
+	defineExpose({
+		onOpen
+	})
+</script>

+ 108 - 0
snowy-admin-web/src/views/biz/bizloaddispatch/timeEditForm.vue

@@ -0,0 +1,108 @@
+<template>
+	<xn-form-container
+		title="编辑起卸时间配置"
+		:width="700"
+		v-model:open="open"
+		:destroy-on-close="true"
+		@close="onClose"
+	>
+		<a-form ref="formRef" :model="formData" :rules="formRules" :wrapper-col="wrapperCol" :label-col="labelCol">
+			<a-form-item label="开始时间:" name="beginTime">
+				<a-date-picker v-model:value="formData.beginTime" value-format="YYYY-MM-DD HH:mm" show-time placeholder="请选择开始时间" :disabled-date="disabledDate" style="width: 100%" />
+			</a-form-item>
+			<a-form-item label="结束时间:" name="endTime">
+				<a-date-picker v-model:value="formData.endTime" value-format="YYYY-MM-DD HH:mm" show-time placeholder="请选择结束时间" :disabled-date="disabledDate" style="width: 100%" />
+			</a-form-item>
+<!--			<a-form-item label="可约次数:" name="availableNumber">
+				<a-input-number v-model:value="formData.availableNumber" style="width: 100%;" placeholder="请输入可约次数" allow-clear />
+			</a-form-item>-->
+		</a-form>
+		<template #footer>
+			<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
+			<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
+		</template>
+	</xn-form-container>
+</template>
+
+<script setup name="bizLoadTimeForm">
+	import { cloneDeep } from 'lodash-es'
+	import { required } from '@/utils/formRules'
+	import bizLoadTimeApi from '@/api/biz/bizLoadTimeApi'
+	import dayjs from 'dayjs'
+
+	// 抽屉状态
+	const open = ref(false)
+	const emit = defineEmits({ successful: null })
+	const formRef = ref()
+	// 表单数据
+	const formData = ref({})
+	const submitLoading = ref(false)
+
+	//设置表单样式
+	const labelCol = ref({ span: 4})
+	const wrapperCol = ref({ span: 16})
+
+	// 当前时间
+	const nowTime = ref(new Date())
+	// 禁用时间范围
+	const disabledDate = (current) => {
+		return (
+			(current && current < dayjs(nowTime.value).startOf('time'))
+		)
+	}
+
+	// 打开抽屉
+	const onOpen = (record, pointId) => {
+		open.value = true
+		formData.value.pointId = pointId
+		if (record) {
+			let recordData = cloneDeep(record)
+			formData.value = Object.assign({}, recordData)
+		}
+	}
+	// 关闭抽屉
+	const onClose = () => {
+		formRef.value.resetFields()
+		formData.value = {}
+		open.value = false
+	}
+	// 默认要校验的
+	const formRules = {
+		beginTime: [required('请选择提货开始时间')],
+		endTime: [required('请选择提货结束时间')],
+		availableNumber: [required('请输入可预约次数')],
+	}
+	// 验证并提交数据
+	const onSubmit = () => {
+		formRef.value
+			.validate()
+			.then(() => {
+				submitLoading.value = true
+				const formDataParam = cloneDeep(formData.value)
+				// 判断开始和结束时间
+				let beginTime = new Date(formDataParam.beginTime+":00")
+				let endTime = new Date(formDataParam.endTime+":00")
+				if(beginTime > endTime){
+					message.error('结束时间不得小于开始时间!')
+					return
+				}else{
+					formDataParam.beginTime = beginTime
+					formDataParam.endTime = endTime
+					bizLoadTimeApi
+						.bizLoadTimeSubmitForm(formDataParam, formDataParam.id)
+						.then(() => {
+							onClose()
+							emit('successful')
+						})
+						.finally(() => {
+							submitLoading.value = false
+						})
+				}
+			})
+			.catch(() => {})
+	}
+	// 抛出函数
+	defineExpose({
+		onOpen
+	})
+</script>

+ 148 - 0
snowy-admin-web/src/views/biz/bizloaddispatch/timeIndex.vue

@@ -0,0 +1,148 @@
+<template>
+	<a-drawer :title="title" :width="850" :open="visible" :destroy-on-close="true" @close="onClose">
+		<a-card :bordered="false" class="mb-2">
+			<s-table
+				ref="tableRef"
+				:columns="columns"
+				:data="loadData"
+				bordered
+				:row-key="(record) => record.id"
+			>
+				<template #operator `class="table-operator">
+					<a-button type="primary" v-if="hasPerm('bizLoadTimeAdd')" @click="addFormRef.onOpen(null, pointId)">
+						<template #icon><plus-outlined /></template> 新增
+					</a-button>
+				</template>`
+				<template #bodyCell="{ column, record, index }">
+					<template v-if="column.dataIndex === 'serial'">
+						{{ index + 1 }}
+					</template>
+					<template v-if="column.dataIndex === 'beginEndTime'">
+						{{ record.beginTime + '~' + record.endTime }}
+					</template>
+					<template v-if="column.dataIndex === 'action'">
+						<a-space>
+							<a @click="editFormRef.onOpen(record, pointId)" v-if="hasPerm('bizLoadTimeEdit') && Number(record.alreadyNumber) == 0">编辑</a>
+
+							<a-divider type="vertical" v-if="hasPerm(['bizLoadTimeEdit', 'bizLoadTimeDelete'], 'and') && Number(record.alreadyNumber) == 0" />
+							<a-button type="link" danger size="small" v-if="hasPerm('bizLoadTimeDelete') && Number(record.alreadyNumber) == 0" @click="deleteConfig(record)">删除</a-button>
+
+							<a @click="alreadyFormRef.onOpen(record, pointId)" v-if="hasPerm('bizLoadTimeAlready') && Number(record.alreadyNumber) != 0">次数</a>
+						</a-space>
+					</template>
+				</template>
+			</s-table>
+		</a-card>
+	</a-drawer>
+
+	<TimeAddForm ref="addFormRef" @successful="tableRef.refresh()" />
+	<TimeEditForm ref="editFormRef" @successful="tableRef.refresh()" />
+	<TimeAlreadyForm ref="alreadyFormRef" @successful="tableRef.refresh()" />
+</template>
+
+<script setup name="bizloadtime">
+	import { cloneDeep } from 'lodash-es'
+	import TimeAddForm from './timeAddForm.vue'
+	import TimeEditForm from './timeEditForm.vue'
+	import TimeAlreadyForm from './timeAlreadyForm.vue'
+	import bizLoadTimeApi from '@/api/biz/bizLoadTimeApi'
+	import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
+	import {Modal} from 'ant-design-vue';
+	import {createVNode} from 'vue';
+
+	const submitLoading = ref(false)
+	const toolConfig = { refresh: true, height: false, columnSetting: false, striped: false }
+	// 默认是关闭状态
+	const visible = ref(false)
+	const searchFormState = ref({})
+	const tableRef = ref()
+	const addFormRef = ref()
+	const editFormRef = ref()
+	const alreadyFormRef = ref()
+	const recordData = ref()
+	const title = ref()
+	const pointId = ref()
+
+	const columns = [
+		{
+			title: '序号',
+			width: 50,
+			dataIndex: 'serial',
+			align:'center'
+		},
+		{
+			title: '起卸时间段',
+			dataIndex: 'beginEndTime',
+			align:'center'
+		},
+		/*{
+			title: '可预约次数',
+			dataIndex: 'availableNumber',
+			align:'center'
+		},
+		{
+			title: '已预约次数',
+			dataIndex: 'alreadyNumber',
+			align:'center'
+		},*/
+	]
+	// 操作栏通过权限判断是否显示
+	if (hasPerm(['bizLoadTimeEdit', 'bizLoadTimeDelete'])) {
+		columns.push({
+			title: '操作',
+			dataIndex: 'action',
+			align: 'center',
+			width: 150
+		})
+	}
+	// 打开抽屉
+	const onOpen = (record) => {
+		recordData.value = record
+		title.value = "【" + record.loadPoint + "】-起卸时间配置"
+		searchFormState.value = {
+			pointId: record.id
+		}
+		pointId.value = record.id
+		visible.value = true
+	}
+	// 加载字段数据
+	const loadData = (parameter) => {
+		return bizLoadTimeApi.bizLoadTimePage(Object.assign(parameter, searchFormState.value)).then((res) => {
+			return res
+		})
+	}
+	// 关闭抽屉
+	const onClose = () => {
+		visible.value = false
+	}
+	// 删除
+	const deleteConfig = (record) => {
+		Modal.confirm({
+			title: '确定删除该数据吗?',
+			icon: createVNode(ExclamationCircleOutlined),
+			content: '',
+			onOk() {
+				submitLoading.value = true
+				let params = [
+					{
+						id: record.id
+					}
+				]
+
+				bizLoadTimeApi
+					.bizLoadTimeDelete(params)
+					.then(() => {
+						tableRef.value.refresh(true)
+					})
+					.finally(() => {
+						submitLoading.value = false
+					})
+			},
+			onCancel() {}
+		})
+	}
+	// 调用这个函数将子组件的一些数据和方法暴露出去
+	defineExpose({
+		onOpen
+	})
+</script>

+ 101 - 0
snowy-admin-web/src/views/biz/bizloaddispatch/userForm.vue

@@ -0,0 +1,101 @@
+<template>
+	<xn-form-container
+		:title="formData.id ? '编辑起卸点人员信息' : '增加起卸点人员信息'"
+		:width="700"
+		v-model:open="open"
+		:destroy-on-close="true"
+		@close="onClose"
+	>
+		<a-form ref="formRef" :model="formData" :rules="formRules" :wrapper-col="wrapperCol" :label-col="labelCol">
+			<a-form-item label="点位人员信息:" name="userId">
+				<xn-user-selector
+					:org-tree-api="selectorApiFunction.orgTreeApi"
+					:user-page-api="selectorApiFunction.userPageApi"
+					:radio-model="true"
+					placeholder="请选择装货员"
+					v-model:value="formData.userId"
+				/>
+			</a-form-item>
+		</a-form>
+		<template #footer>
+			<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
+			<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
+		</template>
+	</xn-form-container>
+</template>
+
+<script setup name="bizLoadUserForm">
+	import { cloneDeep } from 'lodash-es'
+	import { required } from '@/utils/formRules'
+	import bizLoadUserApi from '@/api/biz/bizLoadUserApi'
+	import userApi from '@/api/biz/bizUserApi'
+
+	// 抽屉状态
+	const open = ref(false)
+	const emit = defineEmits({ successful: null })
+	const formRef = ref()
+	// 表单数据
+	const formData = ref({})
+	const submitLoading = ref(false)
+
+	//设置表单样式
+	const labelCol = ref({ span: 4})
+	const wrapperCol = ref({ span: 16})
+
+	// 打开抽屉
+	const onOpen = (record, pointId) => {
+		open.value = true
+		formData.value.pointId = pointId
+		if (record) {
+			let recordData = cloneDeep(record)
+			formData.value = Object.assign({}, recordData)
+		}
+	}
+	// 关闭抽屉
+	const onClose = () => {
+		formRef.value.resetFields()
+		formData.value = {}
+		open.value = false
+	}
+	// 默认要校验的
+	const formRules = {
+		userId: [required('请选择人员')],
+	}
+	// 传递设计器需要的API
+	const selectorApiFunction = {
+		orgTreeApi: (param) => {
+			return userApi.userOrgTreeSelector(param).then((data) => {
+				return Promise.resolve(data)
+			})
+		},
+		userPageApi: (param) => {
+			param.roleName = '发货'
+			return userApi.userSelectorByRole(param).then((data) => {
+				return Promise.resolve(data)
+			})
+		}
+	}
+	// 验证并提交数据
+	const onSubmit = () => {
+		formRef.value
+			.validate()
+			.then(() => {
+				submitLoading.value = true
+				const formDataParam = cloneDeep(formData.value)
+				bizLoadUserApi
+					.bizLoadUserSubmitForm(formDataParam, formDataParam.id)
+					.then(() => {
+						onClose()
+						emit('successful')
+					})
+					.finally(() => {
+						submitLoading.value = false
+					})
+			})
+			.catch(() => {})
+	}
+	// 抛出函数
+	defineExpose({
+		onOpen
+	})
+</script>

+ 120 - 0
snowy-admin-web/src/views/biz/bizloaddispatch/userIndex.vue

@@ -0,0 +1,120 @@
+<template>
+	<a-drawer :title="title" :width="850" :open="visible" :destroy-on-close="true" @close="onClose">
+		<a-card :bordered="false">
+			<s-table
+				ref="tableRef"
+				:columns="columns"
+				:data="loadData"
+				bordered
+				:row-key="(record) => record.id"
+			>
+				<template #operator `class="table-operator">
+					<a-button type="primary" @click="userFormRef.onOpen(null, pointId)" v-if="hasPerm('bizLoadTimeAdd') && recordDataNumber == 0">
+						<template #icon><plus-outlined /></template>
+						新增
+					</a-button>
+				</template>
+				<template #bodyCell="{ column, record, index }">
+					<template v-if="column.dataIndex === 'serial'">
+						{{ index + 1 }}
+					</template>
+					<template v-if="column.dataIndex === 'action'">
+						<a-space>
+							<a @click="userFormRef.onOpen(record, pointId)" v-if="hasPerm('bizLoadUserEdit')">编辑</a>
+							<a-divider type="vertical" v-if="hasPerm(['bizLoadUserEdit', 'bizLoadUserDelete'], 'and')" />
+							<a-button type="link" danger size="small" v-if="hasPerm('bizLoadUserDelete')" @click="deleteConfig(record)">删除</a-button>
+						</a-space>
+					</template>
+				</template>
+			</s-table>
+		</a-card>
+	</a-drawer>
+
+	<UserForm ref="userFormRef" @successful="tableRef.refresh()" />
+</template>
+
+<script setup name="bizloaduser">
+	import { cloneDeep } from 'lodash-es'
+	import UserForm from './userForm.vue'
+	import bizLoadUserApi from '@/api/biz/bizLoadUserApi'
+
+	const submitLoading = ref(false)
+	const toolConfig = { refresh: true, height: false, columnSetting: false, striped: false }
+	// 默认是关闭状态
+	const visible = ref(false)
+	const searchFormState = ref({})
+	const tableRef = ref()
+	const userFormRef = ref()
+	const recordData = ref()
+	const recordDataNumber = ref(0)
+	const title = ref()
+	const pointId = ref()
+
+	const columns = [
+		{
+			title: '序号',
+			width: 50,
+			dataIndex: 'serial',
+			align:'center'
+		},
+		// {
+		// 	title: '装货点位',
+		// 	dataIndex: 'loadPoint',
+		// 	align:'center'
+		// },
+		{
+			title: '起卸员账号',
+			dataIndex: 'account',
+			align:'center'
+		},
+		{
+			title: '起卸员姓名',
+			dataIndex: 'name',
+			align:'center'
+		},
+		{
+			title: '起卸员手机',
+			dataIndex: 'phone',
+			align:'center'
+		},
+		{
+			title: '创建时间',
+			dataIndex: 'createTime',
+			align:'center'
+		},
+	]
+	// 操作栏通过权限判断是否显示
+	if (hasPerm(['bizLoadUserEdit', 'bizLoadUserDelete'])) {
+		columns.push({
+			title: '操作',
+			dataIndex: 'action',
+			align: 'center',
+			width: 150
+		})
+	}
+	// 打开抽屉
+	const onOpen = (record) => {
+		recordData.value = record
+		title.value = "【" + record.loadPoint + "】-起卸员配置"
+		searchFormState.value = {
+			loadPointId: record.id
+		}
+		pointId.value = record.id
+		visible.value = true
+	}
+	// 加载字段数据
+	const loadData = (parameter) => {
+		return bizLoadUserApi.bizLoadUserPage(Object.assign(parameter, searchFormState.value)).then((res) => {
+			recordDataNumber.value = res.total
+			return res
+		})
+	}
+	// 关闭抽屉
+	const onClose = () => {
+		visible.value = false
+	}
+	// 调用这个函数将子组件的一些数据和方法暴露出去
+	defineExpose({
+		onOpen
+	})
+</script>