Browse Source

SBBJ-971组件封装

master
张立 1 month ago
parent
commit
b68176d860
  1. 2
      src/api/costCenterMapping/index.ts
  2. 85
      src/components/costCenter/index.vue
  3. 34
      src/pages/outLocation/addForm.vue

2
src/api/costCenterMapping/index.ts

@ -12,5 +12,5 @@ export interface CostCenterMappingVO {
// 根据库区编号获取成本中心
export function findList(data) {
console.log('findList.data',data)
return http.get({ url: `/eam/cost-center-mapping/findList`, data })
return http.get( `/eam/cost-center-mapping/findList`, data )
}

85
src/components/costCenter/index.vue

@ -3,7 +3,7 @@
<u-popup v-model="isShowSelectItem" mode="center" border-radius="14">
<view class="popup-title">成本中心</view>
<view class="popup">
<u-search placeholder="搜索" v-model="form1.warehouseArea" @change="searchItem" clearabled="false"></u-search>
<u-search placeholder="搜索" v-model="keyword" @custom="searchItem" @search="searchItem" clearabled="false"></u-search>
<scroll-view class="list" scroll-y="true" style="max-height: 800rpx">
<view class="item" v-for="(item, index) in singleColumnList" :key="index" @click="chooseItem(item)">
<u-checkbox v-model="item.checked" shape="circle" style="margin-top: 8rpx"></u-checkbox>
@ -28,23 +28,10 @@
</scroll-view>
</view>
<view class="popup-footer">
<view @click="chooseItem1(0)">取消</view>
<view class="sure" @click="chooseItem1(1)">确认</view>
<view @click="isShowSelectItem = false">取消</view>
<view class="sure" @click="sure">确认</view>
</view>
</u-popup>
<!-- 全屏图片弹窗 -->
<u-popup v-model="isImagePopupVisible" mode="center" border-radius="0">
<view class="image-popup">
<view class="close-btn" @click="closeImagePopup">X</view>
<img :src="currentImagePath" class="full-image" />
</view>
</u-popup>
<!-- 长按显示完整内容的浮窗 -->
<div v-if="showTooltip" class="tooltip" :style="{ top: tooltipPosition.top, left: tooltipPosition.left }">
{{ tooltipContent }}
</div>
</template>
<script setup lang="ts">
@ -60,32 +47,13 @@ const props = defineProps({
require: false
}
})
// isShowSelectItem
// watch(
// () => props.isShowSelectItem,
// (newValue, oldValue) => {
// if (newValue) {
// form1.value.ccAccount = ''
// form1.value.creditAccount = ''
// form1.value.department = ''
// form1.value.moveCode = ''
// form1.value.warehouseArea = ''
// }
// }
// )
const type = ref('')
const isShowSelectItem = ref(false)
const selectVal = ref(null)
const emits = defineEmits(['searchItem', 'chooseItem1'])
const form1 = ref({
ccAccount: '',
creditAccount: '',
department: '',
moveCode: '',
warehouseArea: ''
})
const singleColumnList = ref(props.singleColumnList)
const emits = defineEmits(['searchItem', 'sure'])
const form1 = ref({})
const keyword = ref('')
//
const isImagePopupVisible = ref(false)
@ -101,7 +69,10 @@ function closeImagePopup() {
uni.hideLoading()
isImagePopupVisible.value = false
}
function open(list) {
isShowSelectItem.value = true
singleColumnList.value = list
}
//
function showFullText(text) {
tooltipContent.value = text
@ -110,42 +81,26 @@ function showFullText(text) {
tooltipPosition.value = { top: '50px', left: '50px' }
}
// onLoad((option) => {
// if (option.type) type.value = option.type
// if (option.type) isShowSelectItem.value = option.isShowSelectItem
// if (option.selectVal) selectVal.value = option.selectVal
// })
//
function chooseItem1(type) {
if (type == 1) {
// form1.value.number = form1.value.temporarilyNumber
// form1.value.name = form1.value.temporarilyName
// form1.value.specifications = form1.value.temporarilySpecifications
// form1.value.specifications = form1.value.temporarilySpecifications
}
emits('chooseItem1', type, form1)
function sure() {
isShowSelectItem.value = false
emits('sure', form1.value)
}
function searchItem() {
emits('searchItem', form1.value.moveCode)
emits('searchItem', keyword.value)
}
function chooseItem(item) {
let arr = props.singleColumnList.filter((cur) => cur.warehouseArea != item.warehouseArea)
arr.forEach((item) => {
singleColumnList.value.forEach((item) => {
item.checked = false
})
item.checked = !item.checked
let arr1 = props.singleColumnList.filter((cur) => cur.warehouseArea == item.warehouseArea)
form1.value.ccAccount = arr1[0].ccAccount
form1.value.creditAccount = arr1[0].creditAccount
form1.value.department = arr1[0].department
form1.value.moveCode = arr1[0].moveCode
form1.value.warehouseArea = arr1[0].warehouseArea
item.checked = true
form1.value = item
}
defineExpose({
isShowSelectItem
isShowSelectItem,
open
})
</script>

34
src/pages/outLocation/addForm.vue

@ -149,7 +149,7 @@
</view>
</u-popup>
</view>
<CostCenter ref="costCenterRef" :singleColumnList="singleColumnList" @searchItem="searchItem" />
<CostCenter ref="costCenterRef" :singleColumnList="singleColumnList" @searchItem="searchItem" @sure="sure" />
</template>
<script setup lang="ts">
@ -163,7 +163,7 @@ import * as costCenterMappingApi from '@/api/costCenterMapping'
const { proxy } = getCurrentInstance()
const loading = ref(false)
const orderList = ref([]) //
const orderList = ref([]) //
const costCenterRef = ref(false)
//
const isPopupShow = ref(false)
@ -286,7 +286,7 @@ function addSpare() {
}
if (!form1.value.qty) {
proxy.$modal.showToast(`请输入数量`)
proxy.$modal.showToast('请输入数量')
return
}
if (Number(form1.value.qty) + Number(form1.value.receiveQty) > Number(form1.value.applyQty)) {
@ -298,12 +298,12 @@ function addSpare() {
return
}
if (form.value.itemNumbers && form.value.itemNumbers.length > 0) {
let arr = form.value.itemNumbers.filter((item) => item.locationNumber == form1.value.locationNumber)
const arr = form.value.itemNumbers.filter((item) => item.locationNumber == form1.value.locationNumber)
if (arr && arr.length > 0) {
proxy.$modal.showToast('该库位已添加')
return
}
let arr1 = form.value.subList.filter((item) => item.itemNumber == form1.value.itemNumber)
const arr1 = form.value.subList.filter((item) => item.itemNumber == form1.value.itemNumber)
if (!arr1 || (arr1 && arr1.length == 0)) {
proxy.$modal.showToast('申领信息没有该备件')
return
@ -315,7 +315,7 @@ function addSpare() {
//
function delSpareParts(item, index) {
let bol = form.value.itemNumbers.some((cur) => cur.itemNumber == item.itemNumber && item.isInAccount == 'FALSE' && cur.isInAccount == 'TRUE')
const bol = form.value.itemNumbers.some((cur) => cur.itemNumber == item.itemNumber && item.isInAccount == 'FALSE' && cur.isInAccount == 'TRUE')
if (bol) {
proxy.$modal.showToast('请先删除该备件得帐内库')
return
@ -324,7 +324,7 @@ function delSpareParts(item, index) {
}
function getLocation() {
let itemNumbers = form.value.itemNumbers.map((item) => {
const itemNumbers = form.value.itemNumbers.map((item) => {
return {
itemNumber: item.itemNumber,
qty: item.qty,
@ -335,7 +335,7 @@ function getLocation() {
.getOutLocation({
number: form1.value.locationNumber,
id: form.value.id,
itemNumbers: itemNumbers
itemNumbers
})
.then((res) => {
if (!res.data) {
@ -387,7 +387,7 @@ function handelScanMsg() {
onLoad(async (option) => {
if (option.data && JSON.parse(decodeURIComponent(option.data)) && JSON.parse(decodeURIComponent(option.data)).id) {
let formData = JSON.parse(decodeURIComponent(option.data))
const formData = JSON.parse(decodeURIComponent(option.data))
form.value.supplierName = formData.supplierName
form.value.number = formData.number
form.value.id = formData.id
@ -402,7 +402,7 @@ const isShowSelectItem = ref(false)
const sparePartsList = ref([])
//
function openSingleNewColumn(fieldName, val, list) {
async function openSingleNewColumn(fieldName, val, list) {
if (!form1.value.areaNumber) {
proxy.$modal.showToast('请选择库位信息')
return
@ -414,19 +414,20 @@ function openSingleNewColumn(fieldName, val, list) {
} else {
singleColumnDefaultValue.value = []
}
costCenterRef.value.isShowSelectItem = true
await getSparePartsList()
costCenterRef.value.open(singleColumnList.value)
}
async function searchItem(warehouseArea) {
async function searchItem(keywords) {
proxy.$modal.loading('加载中')
await getSparePartsList(warehouseArea)
await getSparePartsList(keywords)
}
//
async function getSparePartsList(warehouseArea) {
let param = {
const param = {
ccAccount: form.value.costCenter,
warehouseArea: warehouseArea ? warehouseArea : form1.value.areaNumber
warehouseArea: warehouseArea || form1.value.areaNumber
}
await costCenterMappingApi
.findList(param)
@ -443,6 +444,9 @@ async function getSparePartsList(warehouseArea) {
proxy.$modal.closeLoading()
})
}
function sure(data) {
form1.value.moveCode = data.warehouseArea
}
</script>
<style lang="scss" scoped>

Loading…
Cancel
Save