Browse Source

修改直接完工功能2024/7/18 17:24:08

hella_vue3
zhang_li 3 months ago
parent
commit
5a00aaf5c8
  1. 4
      src/api/request2.js
  2. 54
      src/common/style/new_style.css
  3. 2
      src/mycomponents/balance/location.vue
  4. 30
      src/mycomponents/balance/toLocation.vue
  5. 4
      src/mycomponents/item/itemCompareQty.vue
  6. 2
      src/mycomponents/job/jobComMainDetailCard.vue
  7. 108
      src/mycomponents/qty/recommendQty.vue
  8. 85
      src/pages/fg/coms/comReceiptPopup.vue
  9. 781
      src/uni_modules/vk-uview-ui/components/u-select/u-select.vue

4
src/api/request2.js

@ -2647,4 +2647,8 @@ export function getPlaneInfoByproductLine(productionLine,planDate) {
export function planReceiptSubmit(data) {
return http.post("/wms/production-main/getPlanProductionByProductionLineAndPlanDate",data)
}
export function getProductionlineAndWorkStation() {
return http.get("/wms/production-main/getProductionlineAndWorkStation")
}

54
src/common/style/new_style.css

@ -2076,6 +2076,11 @@ button::after {
color:#2E3A63;
margin-left:20rpx
}
.card_big_content {
font-size: 40rpx;
font-weight: bold;
padding: 5px;
}
.card_icon_normal {
width: 30rpx;
@ -2084,22 +2089,24 @@ button::after {
margin-right:12rpx
}
.card_packing_code {
color: #1677FF;
font-size: 26rpx;
font-style: italic;
}
.card_batch {
color: #9747FF;
font-size: 26rpx;
font-style: italic;
}
.card_packing_code {
color: #3315EB;
padding: 5px;
font-size: 30rpx;
}
.card_batch {
color: #9747FF;
padding: 5px;
font-size: 30rpx;
}
.card_container {
color: #0076F6;
padding: 5px;
font-size: 30rpx;
}
.card_container {
color: #0076F6;
padding: 5px;
}
.card_container_content {
@ -2495,11 +2502,18 @@ button[disabled] {
justify-content: space-between;
}
.text_recommend {
color: #0A84FF;
font-size: 38rpx;
font-weight:bold
}
.text_recommend {
color: #0A84FF;
font-size: 34rpx;
font-weight: bold;
}
.text_packQty {
color: #3315EB;
font-size: 40rpx;
font-weight: bold;
}
.text_balance {
font-size: 36rpx;

2
src/mycomponents/balance/location.vue

@ -1,7 +1,7 @@
<template>
<view class="card_view">
<text class="card_location">{{ title }}</text>
<text class="card_content" style="font-size: 37rpx">{{ locationCode }}</text>
<text class="card_big_content" style="font-size: 40rpx">{{ locationCode }}</text>
</view>
</template>

30
src/mycomponents/balance/toLocation.vue

@ -1,21 +1,19 @@
<template>
<view class="card_view ">
<text class="card_to_location">{{title}}</text>
<text class="card_content ">{{locationCode}}</text>
</view>
<view class="card_view">
<text class="card_to_location">{{ title }}</text>
<text class="card_content">{{ locationCode }}</text>
</view>
</template>
<script setup lang="ts">
const props = defineProps({
locationCode: {
type: String,
},
title: {
type: String,
default: '库位'
},
})
const props = defineProps({
locationCode: {
type: String
},
title: {
type: String,
default: '库位'
}
})
</script>
<style>
</style>
<style></style>

4
src/mycomponents/item/itemCompareQty.vue

@ -3,8 +3,8 @@
<view style="flex: 1">
<item :dataContent="dataContent"></item>
</view>
<view style="width: 30%; display: flex; justify-content: flex-end; margin-right: 10rpx">
<recommend-qty v-if="handleQty == 0" :dataContent="dataContent" :isShowStatus="false" :isShowStdPack="true" :objTextStyle="objTextStyle"></recommend-qty>
<view style="width: 40%; display: flex; justify-content: flex-end; margin-right: 10rpx">
<recommend-qty v-if="handleQty == 0" :dataContent="dataContent" :isShowStatus="false" :isShowStdPack="true"></recommend-qty>
<compare-qty v-else :dataContent="dataContent" :recommendQty="Number(dataContent.qty)" :handleQty="Number(handleQty)" :isShowStatus="false" :isShowPackUnit="isShowPackUnit"> </compare-qty>
</view>
</view>

2
src/mycomponents/job/jobComMainDetailCard.vue

@ -1,7 +1,7 @@
<template>
<view class="">
<view class="task_text" style="border-top: 1px solid #dedede; padding-top: 20rpx">
<itemCompareQty :dataContent="dataContent" :handleQty="dataContent.handleQty" :isShowPackUnit="false" :objTextStyle="{ fontWeight: 'bold', fontSize: '40rpx' }"></itemCompareQty>
<itemCompareQty :dataContent="dataContent" :handleQty="dataContent.handleQty" :isShowPackUnit="false"></itemCompareQty>
<div>
<pack v-if="isShowPack && dataContent.packingNumber != null" :packingCode="dataContent.packingNumber"> </pack>
<batch v-if="isShowBatch && dataContent.batch != null" :batch="dataContent.batch"></batch>

108
src/mycomponents/qty/recommendQty.vue

@ -1,58 +1,64 @@
<template>
<view>
<status v-if="isShowStatus" :status='dataContent.inventoryStatus'></status>
<view>
<status v-if="isShowStatus" :status="dataContent.inventoryStatus"></status>
<view class="u-flex u-row center">
<view class="text_recommend " :style='objTextStyle'>
{{Number(dataContent.qty)}}
</view>
<uom :uom="dataContent.uom"></uom>
</view>
<view>
<pack-unit :dataContent="dataContent"></pack-unit>
</view>
</view>
<view class="u-flex u-row center">
<view class="text_recommend">
{{ Number(dataContent.qty) }}
</view>
<uom :uom="dataContent.uom"></uom>
<view v-if="dataContent.packQty != undefined" class="uni-flex uni-row">
<view class="uom">/</view>
<view class="text_packQty">{{ calc(dataContent.qty, dataContent.packQty) }} </view>
</view>
</view>
<view>
<pack-unit :dataContent="dataContent"></pack-unit>
</view>
</view>
</template>
<script setup lang="ts">
import packUnit from '@/mycomponents/qty/packUnit.vue'
import uom from '@/mycomponents/qty/uom.vue'
import status from '@/mycomponents/status/status.vue'
const props = defineProps({
type: {
type: String,
default: 'default' //recommend: compare:
},
dataContent: {
type: Object,
default: {}
},
recommendQty: {
type: Number,
default: 0
},
handleQty: {
type: Number,
default: 0
},
isShowStatus: {
type: Boolean,
default: true
},
isShowStdPack: {
type: Boolean,
default: true
},
objTextStyle:{
type: Object,
default: null
}
})
<script setup lang="ts">
import packUnit from '@/mycomponents/qty/packUnit.vue'
import uom from '@/mycomponents/qty/uom.vue'
import status from '@/mycomponents/status/status.vue'
const props = defineProps({
type: {
type: String,
default: 'default' // recommend: compare:
},
dataContent: {
type: Object,
default: {}
},
recommendQty: {
type: Number,
default: 0
},
handleQty: {
type: Number,
default: 0
},
isShowStatus: {
type: Boolean,
default: true
},
isShowStdPack: {
type: Boolean,
default: true
},
objTextStyle: {
type: Object,
default: null
}
})
const calc = (qty, packQty) => {
return Math.ceil(Number(qty) / Number(packQty))
}
</script>
<style lang="scss">
</style>
<style lang="scss"></style>

85
src/pages/fg/coms/comReceiptPopup.vue

@ -17,13 +17,12 @@
<view class="customerBorder" @click="showSelectLine">
{{ productionLineName }}
</view>
<u-select v-model="showProductLineSelect" mode="single-column" :list="productLineList" @confirm="confirmSelectLine"></u-select>
<u-select v-model="showProductLineSelect" mode="mutil-column-auto" :list="productLineList" @confirm="confirmSelectLine"></u-select>
<view class="">
<image src="/static/icons/down.svg" mode="" style="width: 40rpx; height: 40rpx; margin-left: 20rpx" @click="showSelectLine"> </image>
</view>
</view>
<view class="split_line"></view>
<view class="title" style="display: flex; align-items: center; padding: 10rpx">
@ -31,6 +30,7 @@
<view class="customerBorder">
{{ itemCode }}
</view>
<view v-if="planQty > 0">{{ planQty }}({{ getUomInfo(uom) }})</view>
<u-select v-model="showItemCodeSelect" mode="single-column" :list="itemCodeList" @confirm="confirmSelectItem"></u-select>
<view class="">
<image src="/static/icons/down.svg" mode="" style="width: 40rpx; height: 40rpx; margin-left: 20rpx" @click="showSelectItemCode"> </image>
@ -46,22 +46,23 @@
</view>
</view>
<view class="split_line"></view>
<view class="title" style="display: flex; align-items: center; padding: 10rpx">
<text style="flex-shrink: 0; width: 25%">计划数量</text>
<view class="customerBorder">
{{ planQty }}
</view>
<view class="">
<image src="" mode="" style="width: 40rpx; height: 40rpx; margin-left: 20rpx"> </image>
</view>
</view>
<!-- <view class="title " style="display: flex;align-items: center;padding: 10rpx;">
<text style=" flex-shrink: 0; width: 25%;">计划数量</text>
<view class="customerBorder">
{{planQty}}
</view>
<view class="">
<image src="" mode="" style=" width: 40rpx;height: 40rpx;margin-left: 20rpx;">
</image>
</view>
</view> -->
<view class="split_line"></view>
<view class="title" style="display: flex; align-items: center; padding: 10rpx">
<text style="flex-shrink: 0; width: 25%">包装规格</text>
<view class="customerBorder">
{{ packUnit }}
</view>
<u-select v-model="showPackUnitSelect" mode="mutil-column-auto" :list="packUnitList" @confirm="confirmSelectPackUnit"></u-select>
<u-select v-model="showPackUnitSelect" mode="mutil-column" :list="packUnitList" @confirm="confirmSelectPackUnit"></u-select>
<view class="">
<image src="/static/icons/down.svg" mode="" style="width: 40rpx; height: 40rpx; margin-left: 20rpx" @click="showSelectPackUnit"> </image>
</view>
@ -82,7 +83,7 @@
</template>
<script>
import { getIssueJobByProductionline, getPlaneInfoByproductLine, getPackUnitByItemCode } from '@/api/request2.js'
import { getIssueJobByProductionline, getPlaneInfoByproductLine, getPackUnitByItemCode, getProductionlineAndWorkStation } from '@/api/request2.js'
import { getPackUnitName, getUomInfo } from '@/common/directory.js'
import { getCurrDate, getBatch8 } from '@/common/basic.js'
@ -115,36 +116,7 @@ export default {
showPackUnitSelect: false,
itemCodeList: [],
showItemCodeSelect: false,
packUnitList: [
{
value: 1,
label: '中国',
children: [
{
value: 2,
label: '广东'
},
{
value: 5,
label: '广西'
}
]
},
{
value: 8,
label: '美国',
children: [
{
value: 9,
label: '纽约'
},
{
value: 10,
label: '华盛顿'
}
]
}
]
packUnitList: []
}
},
props: {
@ -247,13 +219,13 @@ export default {
title: '加载中',
mask: true
})
getIssueJobByProductionline()
getProductionlineAndWorkStation()
.then((res) => {
uni.hideLoading()
if (res.data && res.data.length > 0) {
res.data.forEach((item) => {
item.label = item.name
})
// res.data.forEach(item => {
// item.label = item.name
// })
this.productLineList = res.data
this.showProductLineSelect = true
} else {
@ -285,7 +257,8 @@ export default {
uni.hideLoading()
if (res.data && res.data.length > 0) {
res.data.forEach((item) => {
item.label = item.itemCode
item.label = `${item.itemCode}${item.planQty}${item.uom})`
item.value = item
})
this.itemCodeList = res.data
this.showItemCodeSelect = true
@ -302,11 +275,17 @@ export default {
}
},
confirmSelectItem(data) {
this.itemCode = data[0].label
const item = this.itemCodeList.find((res) => res.itemCode == this.itemCode)
this.uom = item.uom
this.planQty = item.planQty
this.number = item.number
const productionPlan = data[0].value
this.itemCode = productionPlan.itemCode
// var item = this.itemCodeList.find(res => res.itemCode == this.itemCode)
this.uom = productionPlan.uom
this.planQty = productionPlan.planQty
this.number = productionPlan.number
// this.itemCode = data[0].label
// var item = this.itemCodeList.find(res => res.itemCode == this.itemCode)
// this.uom = item.uom
// this.planQty = item.planQty
// this.number = item.number
},
showSelectPackUnit() {

781
src/uni_modules/vk-uview-ui/components/u-select/u-select.vue

@ -1,6 +1,6 @@
<template>
<view class="u-select">
<!-- <view class="u-select__action" :class="{
<view class="u-select">
<!-- <view class="u-select__action" :class="{
'u-select--border': border
}" @tap.stop="selectHandler">
<view class="u-select__action__icon" :class="{
@ -9,429 +9,414 @@
<u-icon name="arrow-down-fill" size="26" color="#c0c4cc"></u-icon>
</view>
</view> -->
<u-popup :blur="blur" :maskCloseAble="maskCloseAble" mode="bottom" :popup="false" v-model="popupValue" length="auto" :safeAreaInsetBottom="safeAreaInsetBottom" @close="close" :z-index="uZIndex">
<view class="u-select">
<view class="u-select__header" @touchmove.stop.prevent="">
<view
class="u-select__header__cancel u-select__header__btn"
:style="{ color: cancelColor }"
hover-class="u-hover-class"
:hover-stay-time="150"
@tap.stop="getResult('cancel')"
>
{{cancelText}}
</view>
<view class="u-select__header__title">
{{title}}
</view>
<view
class="u-select__header__confirm u-select__header__btn"
:style="{ color: moving ? cancelColor : confirmColor }"
hover-class="u-hover-class"
:hover-stay-time="150"
@touchmove.stop=""
@tap.stop="getResult('confirm')"
>
{{confirmText}}
</view>
</view>
<view class="u-select__body">
<picker-view @change="columnChange" class="u-select__body__picker-view" :value="defaultSelector" @pickstart="pickstart" @pickend="pickend">
<picker-view-column v-for="(item, index) in columnData" :key="index">
<view class="u-select__body__picker-view__item" v-for="(item1, index1) in item" :key="index1">
<view class="u-line-1">{{ item1[labelName] }}</view>
</view>
</picker-view-column>
</picker-view>
</view>
</view>
</u-popup>
</view>
<u-popup :blur="blur" :maskCloseAble="maskCloseAble" mode="bottom" :popup="false" v-model="popupValue" length="auto" :safeAreaInsetBottom="safeAreaInsetBottom" @close="close" :z-index="uZIndex">
<view class="u-select">
<view class="u-select__header" @touchmove.stop.prevent="">
<view class="u-select__header__cancel u-select__header__btn" :style="{ color: cancelColor }" hover-class="u-hover-class" :hover-stay-time="150" @tap.stop="getResult('cancel')">
{{ cancelText }}
</view>
<view class="u-select__header__title">
{{ title }}
</view>
<view class="u-select__header__confirm u-select__header__btn" :style="{ color: moving ? cancelColor : confirmColor }" hover-class="u-hover-class" :hover-stay-time="150" @touchmove.stop="" @tap.stop="getResult('confirm')">
{{ confirmText }}
</view>
</view>
<view class="u-select__body">
<picker-view @change="columnChange" class="u-select__body__picker-view" :value="defaultSelector" @pickstart="pickstart" @pickend="pickend">
<picker-view-column v-for="(item, index) in columnData" :key="index">
<view class="u-select__body__picker-view__item" v-for="(item1, index1) in item" :key="index1">
<view class="u-line-1">{{ item1[labelName] }}</view>
</view>
</picker-view-column>
</picker-view>
</view>
</view>
</u-popup>
</view>
</template>
<script>
/**
* select 列选择器
* @description 此选择器用于单列多列多列联动的选择场景(从1.3.0版本起不建议使用Picker组件的单列和多列模式Select组件是专门为列选择而构造的组件更简单易用)
* @tutorial http://uviewui.com/components/select.html
* @property {String} mode 模式选择"single-column"-单列模式"mutil-column"-多列模式"mutil-column-auto"-多列联动模式
* @property {Array} list 列数据数组形式见官网说明
* @property {Boolean} v-model 布尔值变量用于控制选择器的弹出与收起
* @property {Boolean} safe-area-inset-bottom 是否开启底部安全区适配(默认false)
* @property {String} cancel-color 取消按钮的颜色默认#606266
* @property {String} confirm-color 确认按钮的颜色(默认#2979ff)
* @property {String} confirm-text 确认按钮的文字
* @property {String} cancel-text 取消按钮的文字
* @property {String} default-value 提供的默认选中的下标见官网说明
* @property {Boolean} mask-close-able 是否允许通过点击遮罩关闭Picker(默认true)
* @property {String Number} z-index 弹出时的z-index值(默认10075)
* @property {String} value-name 自定义list数据的value属性名 1.3.6
* @property {String} label-name 自定义list数据的label属性名 1.3.6
* @property {String} child-name 自定义list数据的children属性名只对多列联动模式有效 1.3.7
* @event {Function} confirm 点击确定按钮返回当前选择的值
* @example <u-select v-model="show" :list="list"></u-select>
*/
/**
* select 列选择器
* @description 此选择器用于单列多列多列联动的选择场景(从1.3.0版本起不建议使用Picker组件的单列和多列模式Select组件是专门为列选择而构造的组件更简单易用)
* @tutorial http://uviewui.com/components/select.html
* @property {String} mode 模式选择"single-column"-单列模式"mutil-column"-多列模式"mutil-column-auto"-多列联动模式
* @property {Array} list 列数据数组形式见官网说明
* @property {Boolean} v-model 布尔值变量用于控制选择器的弹出与收起
* @property {Boolean} safe-area-inset-bottom 是否开启底部安全区适配(默认false)
* @property {String} cancel-color 取消按钮的颜色默认#606266
* @property {String} confirm-color 确认按钮的颜色(默认#2979ff)
* @property {String} confirm-text 确认按钮的文字
* @property {String} cancel-text 取消按钮的文字
* @property {String} default-value 提供的默认选中的下标见官网说明
* @property {Boolean} mask-close-able 是否允许通过点击遮罩关闭Picker(默认true)
* @property {String Number} z-index 弹出时的z-index值(默认10075)
* @property {String} value-name 自定义list数据的value属性名 1.3.6
* @property {String} label-name 自定义list数据的label属性名 1.3.6
* @property {String} child-name 自定义list数据的children属性名只对多列联动模式有效 1.3.7
* @event {Function} confirm 点击确定按钮返回当前选择的值
* @example <u-select v-model="show" :list="list"></u-select>
*/
export default {
emits: ["update:modelValue", "input", "confirm","cancel"],
props: {
emits: ['update:modelValue', 'input', 'confirm', 'cancel'],
props: {
//
value: {
type: Boolean,
default: false
type: Boolean,
default: false
},
modelValue: {
type: Boolean,
default: false
},
//
list: {
type: Array,
default() {
return [];
}
},
//
border: {
type: Boolean,
default: true
},
// ""
cancelColor: {
type: String,
default: '#606266'
},
// ""
confirmColor: {
type: String,
default: '#2979ff'
},
// z-index
zIndex: {
type: [String, Number],
default: 0
},
safeAreaInsetBottom: {
type: Boolean,
default: false
},
// Picker
maskCloseAble: {
type: Boolean,
default: true
},
//
defaultValue: {
type: Array,
default() {
return [0];
}
},
// single-column-mutil-column-mutil-column-auto-
mode: {
type: String,
default: 'single-column'
},
// value
valueName: {
type: String,
default: 'value'
},
// label
labelName: {
type: String,
default: 'label'
},
// children
childName: {
type: String,
default: 'children'
},
//
title: {
type: String,
default: ''
},
//
cancelText: {
type: String,
default: '取消'
},
//
confirmText: {
type: String,
default: '确认'
},
//
blur: {
type: [Number, String],
default: 0
},
},
data() {
return {
//
list: {
type: Array,
default() {
return []
}
},
//
border: {
type: Boolean,
default: true
},
// ""
cancelColor: {
type: String,
default: '#606266'
},
// ""
confirmColor: {
type: String,
default: '#2979ff'
},
// z-index
zIndex: {
type: [String, Number],
default: 0
},
safeAreaInsetBottom: {
type: Boolean,
default: false
},
// Picker
maskCloseAble: {
type: Boolean,
default: true
},
//
defaultValue: {
type: Array,
default() {
return [0]
}
},
// single-column-mutil-column-mutil-column-auto-
mode: {
type: String,
default: 'single-column'
},
// value
valueName: {
type: String,
default: 'value'
},
// label
labelName: {
type: String,
default: 'label'
},
// children
childName: {
type: String,
default: 'children'
},
//
title: {
type: String,
default: ''
},
//
cancelText: {
type: String,
default: '取消'
},
//
confirmText: {
type: String,
default: '确认'
},
//
blur: {
type: [Number, String],
default: 0
}
},
data() {
return {
popupValue: false,
//
defaultSelector: [0],
// picker-view
columnData: [],
//
selectValue: [],
// index
lastSelectIndex: [],
//
columnNum: 0,
//
moving: false
};
},
watch: {
// select
value: {
immediate: true,
handler(val) {
if(val) setTimeout(() => this.init(), 10);
this.popupValue = val;
}
},
//
defaultSelector: [0],
// picker-view
columnData: [],
//
selectValue: [],
// index
lastSelectIndex: [],
//
columnNum: 0,
//
moving: false
}
},
watch: {
// select
value: {
immediate: true,
handler(val) {
if (val) setTimeout(() => this.init(), 10)
this.popupValue = val
}
},
modelValue: {
immediate: true,
handler(val) {
if(val) setTimeout(() => this.init(), 10);
this.popupValue = val;
}
immediate: true,
handler(val) {
if (val) setTimeout(() => this.init(), 10)
this.popupValue = val
}
}
},
computed: {
uZIndex() {
// z-index使
return this.zIndex ? this.zIndex : this.$u.zIndex.popup
}
},
methods: {
//
pickstart() {
// #ifdef MP-WEIXIN
this.moving = true
// #endif
},
},
computed: {
uZIndex() {
// z-index使
return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
},
},
methods: {
//
pickstart() {
// #ifdef MP-WEIXIN
this.moving = true;
// #endif
},
//
pickend() {
// #ifdef MP-WEIXIN
this.moving = false;
// #endif
},
init() {
this.setColumnNum();
this.setDefaultSelector();
this.setColumnData();
this.setSelectValue();
},
//
setDefaultSelector() {
// columnNum0
this.defaultSelector = this.defaultValue.length == this.columnNum ? this.defaultValue : Array(this.columnNum).fill(0);
this.lastSelectIndex = this.$u.deepClone(this.defaultSelector);
},
//
setColumnNum() {
// 1
if(this.mode == 'single-column') this.columnNum = 1;
// this.list
else if(this.mode == 'mutil-column') this.columnNum = this.list.length;
// this.list
else if(this.mode == 'mutil-column-auto') {
let num = 1;
let column = this.list;
// children
while(column[0][this.childName]) {
column = column[0] ? column[0][this.childName] : {};
num ++;
}
this.columnNum = num;
}
},
// picker
setColumnData() {
let data = [];
this.selectValue = [];
if(this.mode == 'mutil-column-auto') {
//
let column = this.list[this.defaultSelector.length ? this.defaultSelector[0] : 0];
//
for (let i = 0; i < this.columnNum; i++) {
// list
if (i == 0) {
data[i] = this.list;
column = column[this.childName];
} else {
//
data[i] = column;
column = column[this.defaultSelector[i]][this.childName];
}
}
} else if(this.mode == 'single-column') {
data[0] = this.list;
} else {
data = this.list;
}
this.columnData = data;
},
// defaultValue
setSelectValue() {
let tmp = null;
for(let i = 0; i < this.columnNum; i++) {
tmp = this.columnData[i][this.defaultSelector[i]];
let data = {
value: tmp ? tmp[this.valueName] : null,
label: tmp ? tmp[this.labelName] : null
};
//
if(tmp && tmp.extra) data.extra = tmp.extra;
this.selectValue.push(data)
}
},
//
columnChange(e) {
let index = null;
let columnIndex = e.detail.value;
// push
this.selectValue = [];
if(this.mode == 'mutil-column-auto') {
//
this.lastSelectIndex.map((val, idx) => {
if (val != columnIndex[idx]) index = idx;
});
this.defaultSelector = columnIndex;
for (let i = index + 1; i < this.columnNum; i++) {
// children
//
this.columnData[i] = this.columnData[i - 1][i - 1 == index ? columnIndex[index] : 0][this.childName];
//
this.defaultSelector[i] = 0;
}
// this.columnDatacolumnChange
// undefined
columnIndex.map((item, index) => {
let data = this.columnData[index][columnIndex[index]];
let tmp = {
value: data ? data[this.valueName] : null,
label: data ? data[this.labelName] : null,
};
//
if(data && data.extra !== undefined) tmp.extra = data.extra;
this.selectValue.push(tmp);
})
//
this.lastSelectIndex = columnIndex;
} else if(this.mode == 'single-column') {
let data = this.columnData[0][columnIndex[0]];
//
let tmp = {
value: data ? data[this.valueName] : null,
label: data ? data[this.labelName] : null,
};
//
if(data && data.extra !== undefined) tmp.extra = data.extra;
this.selectValue.push(tmp);
} else if(this.mode == 'mutil-column') {
//
columnIndex.map((item, index) => {
let data = this.columnData[index][columnIndex[index]];
//
let tmp = {
value: data ? data[this.valueName] : null,
label: data ? data[this.labelName] : null,
};
//
if(data && data.extra !== undefined) tmp.extra = data.extra;
this.selectValue.push(tmp);
})
}
},
close() {
this.$emit('input', false);
this.$emit("update:modelValue", false);
},
//
getResult(event = null) {
// #ifdef MP-WEIXIN
if (this.moving) return;
// #endif
if (event) this.$emit(event, this.selectValue);
this.close();
},
selectHandler() {
this.$emit('click');
}
}
};
//
pickend() {
// #ifdef MP-WEIXIN
this.moving = false
// #endif
},
init() {
this.setColumnNum()
this.setDefaultSelector()
this.setColumnData()
this.setSelectValue()
},
//
setDefaultSelector() {
// columnNum0
this.defaultSelector = this.defaultValue.length == this.columnNum ? this.defaultValue : Array(this.columnNum).fill(0)
this.lastSelectIndex = this.$u.deepClone(this.defaultSelector)
},
//
setColumnNum() {
// 1
if (this.mode == 'single-column') this.columnNum = 1
// this.list
else if (this.mode == 'mutil-column') this.columnNum = this.list.length
// this.list
else if (this.mode == 'mutil-column-auto') {
let num = 1
let column = this.list
// children
while (column[0][this.childName]) {
column = column[0] ? column[0][this.childName] : {}
num++
}
this.columnNum = num
}
},
// picker
setColumnData() {
let data = []
this.selectValue = []
if (this.mode == 'mutil-column-auto') {
//
let column = this.list[this.defaultSelector.length ? this.defaultSelector[0] : 0]
//
for (let i = 0; i < this.columnNum; i++) {
// list
if (i == 0) {
data[i] = this.list
column = column[this.childName]
} else {
//
data[i] = column
column = column[this.defaultSelector[i]][this.childName]
}
}
} else if (this.mode == 'single-column') {
data[0] = this.list
} else {
data = this.list
}
this.columnData = data
},
// defaultValue
setSelectValue() {
let tmp = null
for (let i = 0; i < this.columnNum; i++) {
tmp = this.columnData[i][this.defaultSelector[i]]
const data = {
value: tmp ? tmp[this.valueName] : null,
label: tmp ? tmp[this.labelName] : null
}
//
if (tmp && tmp.extra) data.extra = tmp.extra
this.selectValue.push(data)
}
},
//
columnChange(e) {
let index = null
const columnIndex = e.detail.value
// push
this.selectValue = []
if (this.mode == 'mutil-column-auto') {
//
this.lastSelectIndex.map((val, idx) => {
if (val != columnIndex[idx]) index = idx
})
this.defaultSelector = columnIndex
for (let i = index + 1; i < this.columnNum; i++) {
// children
//
this.columnData[i] = this.columnData[i - 1][i - 1 == index ? columnIndex[index] : 0][this.childName]
//
this.defaultSelector[i] = 0
}
// this.columnDatacolumnChange
// undefined
columnIndex.map((item, index) => {
const data = this.columnData[index][columnIndex[index]]
const tmp = {
value: data ? data[this.valueName] : null,
label: data ? data[this.labelName] : null
}
//
if (data && data.extra !== undefined) tmp.extra = data.extra
this.selectValue.push(tmp)
})
//
this.lastSelectIndex = columnIndex
} else if (this.mode == 'single-column') {
const data = this.columnData[0][columnIndex[0]]
//
const tmp = {
value: data ? data[this.valueName] : null,
label: data ? data[this.labelName] : null
}
//
if (data && data.extra !== undefined) tmp.extra = data.extra
this.selectValue.push(tmp)
} else if (this.mode == 'mutil-column') {
//
columnIndex.map((item, index) => {
const data = this.columnData[index][columnIndex[index]]
//
const tmp = {
value: data ? data[this.valueName] : null,
label: data ? data[this.labelName] : null
}
//
if (data && data.extra !== undefined) tmp.extra = data.extra
this.selectValue.push(tmp)
})
}
},
close() {
this.$emit('input', false)
this.$emit('update:modelValue', false)
},
//
getResult(event = null) {
// #ifdef MP-WEIXIN
if (this.moving) return
// #endif
if (event) this.$emit(event, this.selectValue)
this.close()
},
selectHandler() {
this.$emit('click')
}
}
}
</script>
<style scoped lang="scss">
@import "../../libs/css/style.components.scss";
@import '../../libs/css/style.components.scss';
.u-select {
&__action {
position: relative;
line-height: $u-form-item-height;
height: $u-form-item-height;
&__action {
position: relative;
line-height: $u-form-item-height;
height: $u-form-item-height;
&__icon {
position: absolute;
right: 20rpx;
top: 50%;
transition: transform .4s;
transform: translateY(-50%);
z-index: 1;
&__icon {
position: absolute;
right: 20rpx;
top: 50%;
transition: transform 0.4s;
transform: translateY(-50%);
z-index: 1;
&--reverse {
transform: rotate(-180deg) translateY(50%);
}
}
}
&--reverse {
transform: rotate(-180deg) translateY(50%);
}
}
}
&__hader {
&__title {
color: $u-content-color;
}
}
&__hader {
&__title {
color: $u-content-color;
}
}
&--border {
border-radius: 6rpx;
border-radius: 4px;
border: 1px solid $u-form-item-border-color;
}
&--border {
border-radius: 6rpx;
border-radius: 4px;
border: 1px solid $u-form-item-border-color;
}
&__header {
@include vue-flex;
align-items: center;
justify-content: space-between;
height: 80rpx;
padding: 0 40rpx;
}
&__header {
@include vue-flex;
align-items: center;
justify-content: space-between;
height: 80rpx;
padding: 0 40rpx;
}
&__body {
width: 100%;
height: 300rpx;
overflow: hidden;
background-color: #fff;
&__body {
width: 100%;
height: 500rpx;
overflow: hidden;
background-color: #fff;
&__picker-view {
height: 100%;
box-sizing: border-box;
&__picker-view {
height: 100%;
box-sizing: border-box;
&__item {
@include vue-flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
color: $u-main-color;
padding: 0 8rpx;
}
}
}
&__item {
@include vue-flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
color: $u-main-color;
padding: 0 8rpx;
}
}
}
}
</style>

Loading…
Cancel
Save