Commit 1b8c4d00 by 张立顺

feat 功能开发

1 parent 6e118926
// tabRepairOrder/components/servicePopup/index.js // tabRepairOrder/components/servicePopup/index.js
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/' const IMG_URL =
'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
import api from '../../api' import api from '../../api'
Component({ Component({
/** /**
* 组件的属性列表 * 组件的属性列表
*/ */
properties: { properties: {
show: { show: {
type: Boolean, type: Boolean,
observer: function(n) { observer: function (n) {
if (n) { if (n) {
let { selected } = this.data let { selected } = this.data
this.setData({ this.setData(
{
searchValue: '', searchValue: '',
selectedData: wx.$util.deepClone(selected) selectedData: wx.$util.deepClone(selected)
}, () => { },
() => {
this.getList(true) this.getList(true)
}) }
)
} }
} }
}, },
selected: { selected: {
type: Array, type: Array,
observer: function(n) { observer: function (n) {}
} },
selectGoodsList: {
type: Array,
observer: function (n) {}
} }
}, },
...@@ -50,7 +56,7 @@ Component({ ...@@ -50,7 +56,7 @@ Component({
updateNumber(id, value, isBlur = false) { updateNumber(id, value, isBlur = false) {
let { servicesList, copyServicesList } = this.data let { servicesList, copyServicesList } = this.data
const finalValue = isBlur ? (value < 1 ? 1 : value) : value const finalValue = isBlur ? (value < 1 ? 1 : value) : value
const updateList = (list) => { const updateList = list => {
return list?.map(item => ({ return list?.map(item => ({
...item, ...item,
detailList: item?.detailList?.map(child => detailList: item?.detailList?.map(child =>
...@@ -77,28 +83,39 @@ Component({ ...@@ -77,28 +83,39 @@ Component({
}, },
// 获取服务项目数据 // 获取服务项目数据
getList(firstFlag) { getList(firstFlag) {
let { searchValue } = this.data let { searchValue, selectGoodsList } = this.data
api.getServiceItemList({serviceItemsName: searchValue}).then(res => { const subOrderCodeList =
selectGoodsList?.map(item => item.subOrderCode) || []
api
.getServiceItemList({ serviceItemsName: searchValue, subOrderCodeList })
.then(res => {
let { code, data, message } = res let { code, data, message } = res
if (code == 0) { if (code == 0) {
let {selectedData} = this.data let { selectedData } = this.data
const selectedIds = selectedData?.reduce((set, item) => { const selectedIds =
item?.detailList?.forEach(({ serviceItemsId }) => set.add(serviceItemsId)) selectedData?.reduce((set, item) => {
item?.detailList?.forEach(({ serviceItemsId }) =>
set.add(serviceItemsId)
)
return set return set
}, new Set()) ?? new Set() }, new Set()) ?? new Set()
const selectedItems = selectedData?.reduce((arr, item) => { const selectedItems =
selectedData?.reduce((arr, item) => {
item?.detailList?.forEach(({ serviceItemsId, useNum }) => { item?.detailList?.forEach(({ serviceItemsId, useNum }) => {
// 检查是否已存在相同的id // 检查是否已存在相同的id
const existingItem = arr.find(obj => obj.id === serviceItemsId); const existingItem = arr.find(
obj => obj.id === serviceItemsId
)
if (!existingItem) { if (!existingItem) {
arr.push({ arr.push({
id: serviceItemsId, id: serviceItemsId,
useNum: useNum useNum: useNum
}); })
} }
}); })
return arr; return arr
}, []) ?? []; }, []) ?? []
data?.forEach(val => { data?.forEach(val => {
val.title = `${val.categoryName}-${val.itemName}` val.title = `${val.categoryName}-${val.itemName}`
val.detailList = val.serviceItemList?.map(item => ({ val.detailList = val.serviceItemList?.map(item => ({
...@@ -148,13 +165,16 @@ Component({ ...@@ -148,13 +165,16 @@ Component({
}) })
return val return val
}) })
const filteredServicesList = copyServicesList?.map(val => { const filteredServicesList =
copyServicesList
?.map(val => {
if (!val?.detailList) return null if (!val?.detailList) return null
return { return {
...val, ...val,
detailList: val.detailList.filter(v => v.active === true) detailList: val.detailList.filter(v => v.active === true)
} }
}).filter(val => val && val.detailList.length > 0) || [] })
.filter(val => val && val.detailList.length > 0) || []
this.setData({ this.setData({
servicesList, servicesList,
copyServicesList, copyServicesList,
...@@ -163,27 +183,31 @@ Component({ ...@@ -163,27 +183,31 @@ Component({
}, },
// 展开收起服务项目 // 展开收起服务项目
handleShowItem(e) { handleShowItem(e) {
let {index} = e.currentTarget.dataset let { index } = e.currentTarget.dataset
let {servicesList} = this.data let { servicesList } = this.data
this.setData({ this.setData({
[`servicesList[${index}].showItemFlag`]: !servicesList[index].showItemFlag [`servicesList[${index}].showItemFlag`]:
!servicesList[index].showItemFlag
}) })
}, },
cancel() { cancel() {
this.triggerEvent('cancel') this.triggerEvent('cancel')
}, },
confirm() { confirm() {
let {servicesList, copyServicesList} = this.data let { servicesList, copyServicesList } = this.data
const result = copyServicesList.map(item => ({ const result = copyServicesList
.map(item => ({
...item, ...item,
detailList: item?.detailList.filter(child => child.active) detailList: item?.detailList.filter(child => child.active)
})).filter(item => item.detailList?.length > 0).map(val => ({ }))
.filter(item => item.detailList?.length > 0)
.map(val => ({
...val, ...val,
useNum: val.useNum < 1 ? 1 : val.useNum // 兜底处理 当输入框为空值或0时默认赋值1 ,防止失去焦点赋值导致数据错误 useNum: val.useNum < 1 ? 1 : val.useNum // 兜底处理 当输入框为空值或0时默认赋值1 ,防止失去焦点赋值导致数据错误
})) }))
const activeNum = result.reduce((total, item) => { const activeNum = result.reduce((total, item) => {
return total + (item?.detailList?.length || 0); return total + (item?.detailList?.length || 0)
}, 0); }, 0)
if (activeNum <= 0) return wx.$util.showToast('请选择服务项目') if (activeNum <= 0) return wx.$util.showToast('请选择服务项目')
this.triggerEvent('confirm', result) this.triggerEvent('confirm', result)
} }
......
...@@ -60,7 +60,17 @@ ...@@ -60,7 +60,17 @@
<view class="title"> <view class="title">
<view class="box">施工单信息</view> <view class="box">施工单信息</view>
</view> </view>
<gl-cell border valueAlign="right" label="主技师" requiredAfter labelWidth="var(--fontSize140)" required haveArrow bindclick="showPopup" placeholder="请选择"> <gl-cell
border
valueAlign="right"
label="主技师"
requiredAfter
labelWidth="var(--fontSize140)"
required
haveArrow
bindclick="showPopup"
placeholder="请选择"
>
<block wx:if="{{ mainSelected.length }}"> <block wx:if="{{ mainSelected.length }}">
<view class="techic-value text-hide"> <view class="techic-value text-hide">
{{mainSelected[0] && mainSelected[0].staffName}} {{mainSelected[0] && mainSelected[0].staffName}}
...@@ -68,7 +78,16 @@ ...@@ -68,7 +78,16 @@
</view> </view>
</block> </block>
</gl-cell> </gl-cell>
<gl-cell border valueAlign="right" label="副手技师" labelWidth="var(--fontSize140)" haveArrow bindclick="showPopup" data-type="deputy" placeholder="请选择"> <gl-cell
border
valueAlign="right"
label="副手技师"
labelWidth="var(--fontSize140)"
haveArrow
bindclick="showPopup"
data-type="deputy"
placeholder="请选择"
>
<block wx:if="{{ deputySelected.length }}"> <block wx:if="{{ deputySelected.length }}">
<view class="techic-value text-hide"> <view class="techic-value text-hide">
<view class="text-hide" wx:if="{{ deputySelected[0] }}"> <view class="text-hide" wx:if="{{ deputySelected[0] }}">
...@@ -123,7 +142,13 @@ ...@@ -123,7 +142,13 @@
<view class="title text-hide">{{item.title}}</view> <view class="title text-hide">{{item.title}}</view>
<block wx:for="{{ item.detailList }}" wx:key="sindex" wx:for-item="i" wx:for-index="sindex"> <block wx:for="{{ item.detailList }}" wx:key="sindex" wx:for-item="i" wx:for-index="sindex">
<view class="service-item edit-item"> <view class="service-item edit-item">
<image bindtap="handleDelServices" data-index="{{ index }}" data-sindex="{{ sindex }}" src="{{ IMG_URL }}repair-order/del-goods.png" mode="" /> <image
bindtap="handleDelServices"
data-index="{{ index }}"
data-sindex="{{ sindex }}"
src="{{ IMG_URL }}repair-order/del-goods.png"
mode=""
/>
<view style="flex: 1;display: flex;align-items: center;justify-content: space-between;"> <view style="flex: 1;display: flex;align-items: center;justify-content: space-between;">
<view class="left"> <view class="left">
<view class="name">{{i.serviceItemsName}}</view> <view class="name">{{i.serviceItemsName}}</view>
...@@ -146,11 +171,37 @@ ...@@ -146,11 +171,37 @@
</view> </view>
</view> </view>
</view> </view>
<view class="btns {{ isFullSucreen?'isFullSucreen-btn':'' }}" wx:if="{{ filter.btnPermissions(userPermissions, 'SHIGONGQUEREN') }}"> <view
class="btns {{ isFullSucreen?'isFullSucreen-btn':'' }}"
wx:if="{{ filter.btnPermissions(userPermissions, 'SHIGONGQUEREN') }}"
>
<view class="btns-con"> <view class="btns-con">
<view class="confirm text-center" bindtap="submit">提交电子施工单</view> <view class="confirm text-center" bindtap="submit">提交电子施工单</view>
</view> </view>
</view> </view>
<relate-goods-popup show="{{ relateGoodsVisable }}" goodsList="{{ goodsList }}" bindconfirm="handelRelateGoodsConfirm" selected="{{ editGoodsList }}" bindcancel="handelRelateGoodsCancel" baseConfigData="{{ baseConfigData }}"></relate-goods-popup>
<technician-select-popup show="{{ artificerSelectPopup }}" title="选择技师" copyArtificerList="{{ artificerList }}" multiple="{{ technicianMultiple }}" artificerSelectObj="{{ technicianMultiple ? deputySelected : mainSelected }}" disabledSelectObj="{{ technicianMultiple ? mainSelected : deputySelected }}" bindconfirm="changeArtificer" bindcancel="cancelTechnician" deputyFlag="{{ technicianMultiple }}" />
<select-service-popup show="{{ selectServiceVisable }}" bindconfirm="handleSelectServiceConfirm" selected="{{ editServicesList }}" bindcancel="handleSelectServiceCancel"></select-service-popup>
\ No newline at end of file \ No newline at end of file
<relate-goods-popup
show="{{ relateGoodsVisable }}"
goodsList="{{ goodsList }}"
bindconfirm="handelRelateGoodsConfirm"
selected="{{ editGoodsList }}"
bindcancel="handelRelateGoodsCancel"
baseConfigData="{{ baseConfigData }}"
></relate-goods-popup>
<technician-select-popup
show="{{ artificerSelectPopup }}"
title="选择技师"
copyArtificerList="{{ artificerList }}"
multiple="{{ technicianMultiple }}"
artificerSelectObj="{{ technicianMultiple ? deputySelected : mainSelected }}"
disabledSelectObj="{{ technicianMultiple ? mainSelected : deputySelected }}"
bindconfirm="changeArtificer"
bindcancel="cancelTechnician"
deputyFlag="{{ technicianMultiple }}"
/>
<select-service-popup
show="{{ selectServiceVisable }}"
bindconfirm="handleSelectServiceConfirm"
selectGoodsList="{{ confirmInfo.subOrderList }}"
selected="{{ editServicesList }}"
bindcancel="handleSelectServiceCancel"
></select-service-popup>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!