Browse Source

SBBJ-971组件封装

master
张立 2 months 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) { export function findList(data) {
console.log('findList.data',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"> <u-popup v-model="isShowSelectItem" mode="center" border-radius="14">
<view class="popup-title">成本中心</view> <view class="popup-title">成本中心</view>
<view class="popup"> <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"> <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)"> <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> <u-checkbox v-model="item.checked" shape="circle" style="margin-top: 8rpx"></u-checkbox>
@ -28,23 +28,10 @@
</scroll-view> </scroll-view>
</view> </view>
<view class="popup-footer"> <view class="popup-footer">
<view @click="chooseItem1(0)">取消</view> <view @click="isShowSelectItem = false">取消</view>
<view class="sure" @click="chooseItem1(1)">确认</view> <view class="sure" @click="sure">确认</view>
</view> </view>
</u-popup> </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> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -60,32 +47,13 @@ const props = defineProps({
require: false 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 type = ref('')
const isShowSelectItem = ref(false) const isShowSelectItem = ref(false)
const selectVal = ref(null) const selectVal = ref(null)
const emits = defineEmits(['searchItem', 'chooseItem1']) const singleColumnList = ref(props.singleColumnList)
const form1 = ref({ const emits = defineEmits(['searchItem', 'sure'])
ccAccount: '', const form1 = ref({})
creditAccount: '', const keyword = ref('')
department: '',
moveCode: '',
warehouseArea: ''
})
// //
const isImagePopupVisible = ref(false) const isImagePopupVisible = ref(false)
@ -101,7 +69,10 @@ function closeImagePopup() {
uni.hideLoading() uni.hideLoading()
isImagePopupVisible.value = false isImagePopupVisible.value = false
} }
function open(list) {
isShowSelectItem.value = true
singleColumnList.value = list
}
// //
function showFullText(text) { function showFullText(text) {
tooltipContent.value = text tooltipContent.value = text
@ -110,42 +81,26 @@ function showFullText(text) {
tooltipPosition.value = { top: '50px', left: '50px' } 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) { function sure() {
if (type == 1) { isShowSelectItem.value = false
// form1.value.number = form1.value.temporarilyNumber emits('sure', form1.value)
// form1.value.name = form1.value.temporarilyName
// form1.value.specifications = form1.value.temporarilySpecifications
// form1.value.specifications = form1.value.temporarilySpecifications
}
emits('chooseItem1', type, form1)
} }
function searchItem() { function searchItem() {
emits('searchItem', form1.value.moveCode) emits('searchItem', keyword.value)
} }
function chooseItem(item) { function chooseItem(item) {
let arr = props.singleColumnList.filter((cur) => cur.warehouseArea != item.warehouseArea) singleColumnList.value.forEach((item) => {
arr.forEach((item) => {
item.checked = false item.checked = false
}) })
item.checked = !item.checked item.checked = true
let arr1 = props.singleColumnList.filter((cur) => cur.warehouseArea == item.warehouseArea) form1.value = item
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
} }
defineExpose({ defineExpose({
isShowSelectItem isShowSelectItem,
open
}) })
</script> </script>

34
src/pages/outLocation/addForm.vue

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

Loading…
Cancel
Save