This commit is contained in:
parent
c0f356507a
commit
24393f28af
|
|
@ -35,19 +35,19 @@
|
|||
</view>
|
||||
<h4 style="width: 90%; margin: 3vh auto">业务统计</h4>
|
||||
<view class="wait-do">
|
||||
<view class="llsp" @click="jumpUrl('fetchExam')">
|
||||
<view class="llsp">
|
||||
<h4>{{ waitList.leaseNum || 0 }}</h4>
|
||||
<h5>工器具领料</h5>
|
||||
</view>
|
||||
<view class="tlsp" @click="jumpUrl('exitExam')">
|
||||
<view class="tlsp">
|
||||
<h4>{{ waitList.backNum || 0 }}</h4>
|
||||
<h5>工器具退料</h5>
|
||||
</view>
|
||||
<view class="bfsh" @click="jumpUrl('crashExam')">
|
||||
<view class="bfsh">
|
||||
<h4>{{ waitList.scrapNum || 0 }}</h4>
|
||||
<h5>材料退料</h5>
|
||||
</view>
|
||||
<view class="sysh" @click="jumpUrl('testExam')">
|
||||
<view class="sysh">
|
||||
<h4>{{ waitList.trialNum || 0 }}</h4>
|
||||
<h5>材料领料</h5>
|
||||
</view>
|
||||
|
|
@ -167,9 +167,18 @@ function noticeDetail(id) {
|
|||
})
|
||||
}
|
||||
function jumpUrl(path) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/${path}/${path}`,
|
||||
})
|
||||
if (path == 'toolsOut') {
|
||||
const params = {
|
||||
isOut: true,
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pages/toolsLease/toolsLease?params=' + JSON.stringify(params),
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/${path}/${path}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
function extractTextFromHTML(htmlString) {
|
||||
return htmlString.replace(/<[^>]*>/g, '')
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
status-bar
|
||||
left-icon="left"
|
||||
left-text="返回"
|
||||
title="领料出库"
|
||||
:title="title"
|
||||
right-text="新增"
|
||||
@clickLeft="back"
|
||||
@clickRight="add"
|
||||
|
|
@ -23,7 +23,6 @@
|
|||
<uni-easyinput
|
||||
errorMessage
|
||||
v-model="queryParams.keyWord"
|
||||
focus
|
||||
placeholder="请输入内容"
|
||||
style="margin: 0 5px"
|
||||
/>
|
||||
|
|
@ -51,7 +50,7 @@
|
|||
:key="index"
|
||||
@click="(e) => onClickSwipe(e, item)"
|
||||
>
|
||||
<div class="list">
|
||||
<div class="list" @click="leaseOut(item)">
|
||||
<div style="margin-right: 8px">{{ index + 1 }}.</div>
|
||||
<div class="item">
|
||||
<div>申请时间: {{ item.createTime }}</div>
|
||||
|
|
@ -84,10 +83,12 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { getPickingOutboundListAPI, deleteLeaseApplyApi } from '@/services/picking/outbound.js'
|
||||
|
||||
const title = ref('工器具领料')
|
||||
const opts = ref()
|
||||
const queryParams = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
|
|
@ -192,6 +193,14 @@ const onClickSwipe = (e, item) => {
|
|||
}
|
||||
}
|
||||
|
||||
// 出库
|
||||
const leaseOut = (item) => {
|
||||
console.log('🚀 ~ leaseOut ~ item:', item)
|
||||
// uni.navigateTo({
|
||||
// url: `/pages/toolsLease/toolsLeaseOut?params=${JSON.stringify(item)}`,
|
||||
// })
|
||||
}
|
||||
|
||||
// 删除
|
||||
const deleteItem = (item) => {
|
||||
console.log('🚀 ~ deleteItem ~ item:', item)
|
||||
|
|
@ -217,7 +226,13 @@ const deleteItem = (item) => {
|
|||
|
||||
onLoad((options) => {
|
||||
console.log('🚀 ~ onLoad ~ options:', options)
|
||||
getList()
|
||||
opts.value = options.params ? JSON.parse(options.params) : {}
|
||||
title.value = opts.value.isOut ? '工器具出库' : '工器具领料'
|
||||
})
|
||||
onShow(() => {
|
||||
setTimeout(() => {
|
||||
getList()
|
||||
}, 300)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,35 +8,357 @@
|
|||
left-icon="left"
|
||||
left-text="返回"
|
||||
:title="title"
|
||||
right-icon="scan"
|
||||
@clickLeft="back"
|
||||
/>
|
||||
<div>
|
||||
新增
|
||||
<div class="content">
|
||||
<uni-section title="任务信息" type="line"></uni-section>
|
||||
<uni-forms ref="form" :rules="rules" :model="formData" label-width="80px">
|
||||
<uni-forms-item label="领料班组" required name="teamId">
|
||||
<uni-data-select
|
||||
v-model="formData.teamId"
|
||||
:localdata="teamRange"
|
||||
filterable
|
||||
:disabled="opts.isEdit"
|
||||
></uni-data-select>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="领用工程" required name="projectId">
|
||||
<eselect
|
||||
style="width: 100%; height: 90rpx"
|
||||
v-model="formData.projectId"
|
||||
ref="treeSelect"
|
||||
:options="prodRange"
|
||||
:disabled="opts.isEdit"
|
||||
@change="changeProd"
|
||||
@clear="
|
||||
() => {
|
||||
formData.projectId = ''
|
||||
}
|
||||
"
|
||||
></eselect>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="领料人" required name="leasePerson">
|
||||
<uni-easyinput v-model="formData.leasePerson" placeholder="请输入内容"></uni-easyinput>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="联系电话" required name="phone">
|
||||
<uni-easyinput
|
||||
v-model="formData.phone"
|
||||
placeholder="请输入内容"
|
||||
maxlength="11"
|
||||
@blur="checkPhone"
|
||||
></uni-easyinput>
|
||||
</uni-forms-item>
|
||||
<uni-section title="领用工具器" type="line"></uni-section>
|
||||
<eselect
|
||||
v-model="equipmentId"
|
||||
style="width: 100%; height: 90rpx; margin: 10px 0"
|
||||
ref="treeSelect"
|
||||
:options="equipmentList"
|
||||
@change="changeEquipment"
|
||||
></eselect>
|
||||
</uni-forms>
|
||||
|
||||
<uni-table ref="table" border stripe emptyText="暂无更多数据">
|
||||
<uni-tr>
|
||||
<uni-th width="60" align="center">序号</uni-th>
|
||||
<uni-th width="180" align="center">类型名称</uni-th>
|
||||
<uni-th width="180" align="center">规格型号</uni-th>
|
||||
<uni-th align="center">在库数</uni-th>
|
||||
<uni-th width="204" align="center">领用数</uni-th>
|
||||
<uni-th width="120" align="center">操作</uni-th>
|
||||
</uni-tr>
|
||||
<uni-tr v-for="(item, index) in tableData" :key="index">
|
||||
<uni-td align="center">{{ index + 1 }}</uni-td>
|
||||
<uni-td align="center">{{ item.maTypeName }}</uni-td>
|
||||
<uni-td align="center">
|
||||
<view class="name">{{ item.typeName }}</view>
|
||||
</uni-td>
|
||||
<uni-td align="center">{{ item.storageNum }}</uni-td>
|
||||
<uni-td align="center"
|
||||
><uni-easyinput
|
||||
v-model="item.preNum"
|
||||
placeholder="请输入内容"
|
||||
type="number"
|
||||
@blur="checkPerNum(item)"
|
||||
></uni-easyinput
|
||||
></uni-td>
|
||||
<uni-td align="center">
|
||||
<view>
|
||||
<button
|
||||
class="uni-button"
|
||||
size="mini"
|
||||
type="warn"
|
||||
@click="
|
||||
() => {
|
||||
tableData.splice(index, 1)
|
||||
}
|
||||
"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</view>
|
||||
</uni-td>
|
||||
</uni-tr>
|
||||
</uni-table>
|
||||
|
||||
<button style="width: 100%; margin: 50px 0" size="mini" type="primary" @click="submit">
|
||||
确定
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { ref, reactive } from 'vue'
|
||||
import eselect from '@/components/tree-select/eselect.vue'
|
||||
import {
|
||||
getBmTeamList,
|
||||
getProjectList,
|
||||
getTypeTreeList,
|
||||
addLeaseTask,
|
||||
editLeaseTask,
|
||||
detailsLeaseTask
|
||||
} from '@/services/back.js'
|
||||
|
||||
const title = ref('新增领料')
|
||||
const params = ref({})
|
||||
const title = ref('工器具领料申请')
|
||||
const opts = ref({})
|
||||
const form = ref()
|
||||
const formData = reactive({
|
||||
teamId: undefined,
|
||||
projectId: '',
|
||||
leasePerson: '',
|
||||
phone: '',
|
||||
})
|
||||
const equipmentId = ref()
|
||||
const teamRange = ref([]) // 班组
|
||||
const prodRange = ref([]) // 工程
|
||||
const equipmentList = ref([]) // 工器具
|
||||
const rules = {
|
||||
teamId: {
|
||||
rules: [{ required: true, errorMessage: '请选择班组' }],
|
||||
},
|
||||
projectId: {
|
||||
rules: [{ required: true, errorMessage: '请选择工程' }],
|
||||
},
|
||||
leasePerson: {
|
||||
rules: [{ required: true, errorMessage: '请填写领用人' }],
|
||||
},
|
||||
phone: {
|
||||
rules: [{ required: true, errorMessage: '请填写联系电话' }],
|
||||
},
|
||||
}
|
||||
const tableData = ref([])
|
||||
|
||||
// 编辑获取详情
|
||||
const getDetailsById = async () => {
|
||||
try {
|
||||
const res = await detailsLeaseTask(opts.value.id)
|
||||
console.log('🚀 ~ getDetailsById ~ res:', res)
|
||||
tableData.value = res.data.leaseApplyDetailsList
|
||||
Object.assign(formData, res.data.leaseApplyInfo)
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ getDetailsById ~ error:', error)
|
||||
|
||||
}
|
||||
}
|
||||
// 获取班组
|
||||
const getTeamList = async () => {
|
||||
try {
|
||||
const res = await getBmTeamList({ isAll: 0 })
|
||||
// teamRange.value = res.data
|
||||
if (res.data.length > 0) {
|
||||
teamRange.value = res.data.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
value: item.id,
|
||||
text: item.teamName,
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ getTeamList ~ error:', error)
|
||||
}
|
||||
}
|
||||
// 获取工程
|
||||
const getProjectListApi = async () => {
|
||||
try {
|
||||
const res = await getProjectList()
|
||||
prodRange.value = res.data
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ getProjectListApi ~ error:', error)
|
||||
}
|
||||
}
|
||||
// 获取工具器
|
||||
const getEquipmentList = async () => {
|
||||
try {
|
||||
const res = await getTypeTreeList()
|
||||
// machineList.value = res.data
|
||||
if (res.data.length > 0) {
|
||||
equipmentList.value = formatEquipmentTree(res.data)
|
||||
console.log('🚀 ~ getEquipmentList ~ machineList.value:', equipmentList.value)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ getMachineListApi ~ error:', error)
|
||||
}
|
||||
}
|
||||
function formatEquipmentTree(list) {
|
||||
return list.map((item) => {
|
||||
const newItem = {
|
||||
...item,
|
||||
id: item.typeId,
|
||||
name: item.typeName,
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
newItem.children = formatEquipmentTree(item.children)
|
||||
}
|
||||
return newItem
|
||||
})
|
||||
}
|
||||
// 校验电话
|
||||
const checkPhone = (rule, value, callback) => {
|
||||
if (!formData.phone) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '请输入电话号码',
|
||||
})
|
||||
return false
|
||||
}
|
||||
if (!/^1[3-9][0-9]{9}$/.test(formData.phone)) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '请输入正确的电话号码',
|
||||
})
|
||||
// 清空
|
||||
formData.phone = ''
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 检查数量
|
||||
const checkPerNum = (item) => {
|
||||
// 大于1的正整数 正则校验
|
||||
if (!/^[1-9]\d*$/.test(item.preNum)) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '请输入正确的数量',
|
||||
})
|
||||
// 重置为1
|
||||
item.preNum = 1
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 选择工程
|
||||
const changeProd = (e) => {
|
||||
console.log('🚀 ~ changeProd ~ e:', e)
|
||||
formData.projectId = e.id
|
||||
}
|
||||
// 选择工器具
|
||||
const changeEquipment = (e) => {
|
||||
console.log('🚀 ~ changeEquipment ~ e:', e)
|
||||
// 从 equipmentList.value 中获取点击id的上一级的 typeName
|
||||
const equipment = findEquipmentById(equipmentList.value, e.parentId)
|
||||
tableData.value.push({
|
||||
...JSON.parse(JSON.stringify(e)),
|
||||
maTypeName: equipment.typeName,
|
||||
preNum: 1,
|
||||
})
|
||||
setTimeout(() => {
|
||||
equipmentId.value = ''
|
||||
}, 300)
|
||||
}
|
||||
// 递归查找指定 id 的节点
|
||||
function findEquipmentById(list, id) {
|
||||
for (const item of list) {
|
||||
if (item.id === id) {
|
||||
return item
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
const found = findEquipmentById(item.children, id)
|
||||
if (found) return found
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const submit = () => {
|
||||
console.log('🚀 ~ submit ~ submit:', formData)
|
||||
// 校验表单
|
||||
form.value
|
||||
.validate()
|
||||
.then(async (valid) => {
|
||||
console.log('🚀 ~ form.value.validate.then ~ valid:', valid)
|
||||
if (tableData.value.length === 0) {
|
||||
await uni.showToast({
|
||||
title: '请添加领用数据',
|
||||
icon: 'none',
|
||||
duration: 1000,
|
||||
})
|
||||
return
|
||||
}
|
||||
// tableData.value 循环 preNum 不能小于 0, 小于0的提示到具体行
|
||||
for (let i = 0; i < tableData.value.length; i++) {
|
||||
console.log('🚀 ~ .then ~ tableData.value[i].preNum:', tableData.value[i].preNum)
|
||||
if (tableData.value[i].preNum < 1) {
|
||||
await uni.showToast({
|
||||
title: `第${i + 1}行领用数量不能为0`,
|
||||
icon: 'none',
|
||||
duration: 1000,
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const params = {
|
||||
leaseApplyDetailsList: tableData.value,
|
||||
leaseApplyInfo: formData,
|
||||
}
|
||||
console.log('🚀 ~ .then ~ params:', params)
|
||||
try {
|
||||
if (!opts.value.isEdit) {
|
||||
const res = await addLeaseTask(params)
|
||||
console.log('🚀 ~ .then ~ res:', res)
|
||||
back()
|
||||
} else {
|
||||
const res = await editLeaseTask(params)
|
||||
back()
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ .then ~ error:', error)
|
||||
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('🚀 ~ form.value.validate.catch ~ err:', err)
|
||||
})
|
||||
}
|
||||
const back = () => {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
|
||||
onLoad((opt) => {
|
||||
console.log('onLoad', opt)
|
||||
params.value = JSON.parse(opt.params)
|
||||
title.value = params.value.isEdit ? '编辑领料' : '新增领料'
|
||||
console.log('🚀 ~ onLoad ~ params.value:', params.value)
|
||||
opts.value = opt.params ? JSON.parse(opt.params) : {}
|
||||
title.value = opts.value.isEdit ? '编辑工器具领料' : '新增工器具领料'
|
||||
getTeamList()
|
||||
getProjectListApi()
|
||||
getEquipmentList()
|
||||
if (opts.value.isEdit) {
|
||||
getDetailsById()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
.content {
|
||||
padding: 10px;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
.col {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const getBackInfo = (id,keyWord) => {
|
|||
})
|
||||
}
|
||||
// 工程下拉选
|
||||
export const getProjectList = (data) => {
|
||||
export const getProjectList = (data = {}) => {
|
||||
return http({
|
||||
method: 'POST',
|
||||
url: '/material/select/getProjectList',
|
||||
|
|
@ -193,13 +193,29 @@ export const getDetailsByIdApi = (data) => {
|
|||
}
|
||||
|
||||
// 提交
|
||||
export const leaseTask = (data) => {
|
||||
export const addLeaseTask = (data) => {
|
||||
return http({
|
||||
method: 'POST',
|
||||
url: '/material/lease_apply_info',
|
||||
data:data,
|
||||
})
|
||||
}
|
||||
// 编辑
|
||||
export const editLeaseTask = (data) => {
|
||||
return http({
|
||||
method: 'put',
|
||||
url: '/material/lease_apply_info',
|
||||
data:data,
|
||||
})
|
||||
}
|
||||
// 详情
|
||||
export const detailsLeaseTask = (data) => {
|
||||
return http({
|
||||
method: 'get',
|
||||
url: `/material/lease_apply_info/${data}`,
|
||||
// data:data,
|
||||
})
|
||||
}
|
||||
|
||||
// 直转申请下拉选
|
||||
export const getParentType = (data) => {
|
||||
|
|
@ -271,4 +287,13 @@ export const getBmTeamList = (data) => {
|
|||
url: '/material/bmTeam/list',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
// 类型规格-树
|
||||
export const getTypeTreeList = (data) => {
|
||||
return http({
|
||||
method: 'GET',
|
||||
url: '/material/ma_type/equipmentType',
|
||||
data,
|
||||
})
|
||||
}
|
||||
Loading…
Reference in New Issue