Commit 2ef49aa6 by 胡悦

feat: 更新表单组件和样式

- 在 GlCell 组件中,添加输入框失去焦点事件处理
- 修改表单数据结构,更新字段名称以更好地反映数据含义
- 在 CreateOrder 组件中,增强弹窗功能,支持外部数据传递
- 更新样式以改善用户体验,确保输入框和按钮的宽度适应性
- 更新图标样式,添加新的删除图标并调整背景位置
1 parent b4400548

2.54 MB | W: | H:

2.54 MB | W: | H:

assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -18,7 +18,7 @@
<!-- 输入框 -->
<template v-if="item.type === 'input'">
<view class="input-box">
<input class="input-value" v-model="formData[item.value]" :placeholder="item.placeholder || '请输入'"
<input class="input-value" v-model="formData[item.value]" :type="item.inputType || 'text'" @blur="handleBlur($event, item)" :placeholder="item.placeholder || '请输入'"
:maxlength="item.maxlength || 500" />
<view v-if="item.valueIcon" :class="['sprite-icon', `icon-${item.valueIcon}`]"
@click="onValueClick(item)"></view>
......@@ -27,11 +27,11 @@
<!-- 下拉选择 -->
<template v-else-if="item.type === 'select'">
<view class="value">
<template v-if="formData[item.value] && formData[item.value][item.key]">
<template v-if="formData[item.value] && formData[item.value]">
<template v-if="item.showText && userInfo && userInfo[item.showText]">
{{ userInfo[item.showText] }}<text>|</text>
</template>
{{ formData[item.value][item.key] }}
{{ formData[item.value] }}
</template>
<template v-else>
<span class="placeholder">请选择</span>
......@@ -109,6 +109,9 @@ export default {
},
onValueClick(item) {
this.$emit('handleValue', item)
},
handleBlur(e, item) {
this.$emit('inputBlur', e, item)
}
}
};
......@@ -205,6 +208,7 @@ export default {
align-items: center;
justify-content: flex-end;
height: 100%;
width: 100%;
.sprite-icon {
margin-left: toRpx(8);
......@@ -214,6 +218,7 @@ export default {
.input-value {
height: 100%;
text-align: right;
width: 100%;
}
.input-bottom {
......
......@@ -4,7 +4,7 @@
<view class="box">
<scroll-view class="scroll-view" scroll-y="true">
<view class="box-content">
<GlCell :formList="formList" :formData="orderObj" @radioChange="radioChange" @handleCell="handleCell">
<GlCell :formList="formList" :formData="orderObj" @radioChange="radioChange" @inputBlur="inputBlur" @handleCell="handleCell">
<template slot="product">
<view class="shop-list">
<view class="shop-item">
......@@ -87,11 +87,11 @@
</template>
</GlCell>
</view>
<view @click="submit">直接下单</view>
<view @click="submit" class="btn">直接下单</view>
</scroll-view>
</view>
<!-- 弹窗 -->
<order-popup ref="orderPopup" :data="popData" @onConfirm="onConfirm" :popupType="popupType" />
<order-popup ref="orderPopup" :data="orderObj" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" />
</view>
</template>
......@@ -107,7 +107,7 @@ export default {
},
data() {
return {
orderObj: {
formObj: {
userInfo: {},
deliveryUserInfo: {},
subShopMerchantInfo: {},
......@@ -117,16 +117,23 @@ export default {
experienceFlag: 'Y',
payeeType: 0,
selectPayType: '3',
carBrand: {}
carBrand: {},
customerPhone: ''
},
formList: FORM_LIST,
userInfo: {},
requiredList: [], // 录单设置的必填项
popData: {
customer: {}
},
orderObj: {
customer: {},
customerSex: '1',
experienceFlag: 'Y',
payeeType: 0
}, // 弹窗传入的数据},
popupType: 0,
popupTypeEnum,
externalData: [], //弹窗接口数据
subShopMerchantList: [], // 二级流量方列表
employeeList: []
}
},
computed: {
......@@ -135,9 +142,22 @@ export default {
else return false
}
},
onload(options) {
console.log(options, 'options')
},
mounted() {
console.log('mounted')
this.userInfo = uni.$storage.get('userInfo') || {}
const { userInfo } = this
// 在原有的 orderObj 对象上新增这些属性
Object.assign(this.orderObj, {
sellerMerchantNam: userInfo.merchantName,
sellerName: userInfo.name,
sellerMerchantId: userInfo.merchantId,
sellerUserId: userInfo.uuid,
merchantId: userInfo.shopMerchantId,
merchantName: userInfo.shopMerchantName
})
this.initData()
},
methods: {
......@@ -146,20 +166,22 @@ export default {
this.getShopMerchantPointConfig(userInfo.shopMerchantId)
this.getSubShopMerchantList(userInfo.shopMerchantId)
this.getSetting()
// this.orderObj.userInfo = {
// id: 1,
// name: '测试'
// }
this.orderObj.sellerMerchant = {
sellerUserId: userInfo.uuid,
sellerName: userInfo.name
}
this.getConfig()
this.getEmployeeList()
},
// 选择行事件
handleCell(val) {
console.log(val)
this.popupType = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key] === val.value) * 1;
console.log(this.popupType)
console.log(val, this.orderObj)
// 获取当前选中的popupType
this.popupType = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key].key === val.value) * 1;
// 获取对应的list字段
const popupConfig = this.popupTypeEnum[this.popupType];
if (popupConfig && popupConfig.list) {
this.externalData = this[popupConfig.list] || [];
} else {
this.externalData = [];
}
console.log(this.popupType, this.externalData, '-------------')
this.$refs.orderPopup.open();
},
// 单选框change事件
......@@ -169,13 +191,40 @@ export default {
},
onConfirm(val) {
console.log(val, 'onConfirm')
const {chooseContent} = val
// 根据popupTypeEnum优化处理
const typeKey = this.popupTypeEnum[this.popupType];
if (typeKey) this.orderObj[typeKey] = val;
if (typeKey == 'carBrand') {
this.orderObj[typeKey].carInfo = `${val.carBrand}-${val.carChildsBrandName}-${val.carSeriesName}`
const _typeValue = this.popupTypeEnum[this.popupType];
console.log(_typeValue)
if (_typeValue.key == 'carBrand') {
// 车型
this.$set(this.orderObj, _typeValue.key, `${chooseContent.carBrand}-${chooseContent.carChildsBrandName}-${chooseContent.carSeriesName}`)
this.orderObj.customer = {
...(this.orderObj.customer || {}),
...chooseContent
}
} else if (_typeValue.key == 'couponInfo') {
// 礼券
const {couponName, merchantCouponId, customerCouponCode } = chooseContent
Object.assign(this.orderObj, {
couponName: couponName,
merchantCouponId: merchantCouponId,
customerCouponCode: customerCouponCode
})
this.$set(this.orderObj, 'couponInfo', couponName + customerCouponCode)
} else if (_typeValue.key) {
// this.formObj[_typeValue.key] = chooseContent;
this.orderObj[_typeValue.targetIdKey] = chooseContent[_typeValue.sourceIdKey]
this.$set(this.orderObj, _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey])
}
},
// 输入框失去焦点事件
inputBlur(e, val) {
console.log(e, val)
this.orderObj.customer[val.value] = this.orderObj[val.value]
},
checkRequired() {
},
// 提交
submit() {
console.log(this.orderObj)
......@@ -195,6 +244,7 @@ export default {
const res = await uni.$api.boutiqueApi.getSubShopMerchantList({ merchantId })
console.log(res, '流量方')
if (res && res.length) {
this.subShopMerchantList = res
const cell = this.formList[0].find(item => item.label === '二级流量方');
if (cell) {
cell.hidden = false;
......@@ -233,7 +283,25 @@ export default {
}
},
async getConfig() {
const res = await uni.$api.boutiqueApi.getYqStoreConfig({
yqMerchantId: this.orderObj.sellerMerchantId
})
console.log(res)
},
// 获取 销售顾问列表
async getEmployeeList() {
const { userInfo, orderObj } = this
const { shopMerchantId, sceneType, merchantId } = userInfo,
data = await uni.$api.popupApi.getEmployeeList({
merchantId: orderObj.idKey == 'sellerUserId' ? merchantId : shopMerchantId,
sceneList: orderObj.idKey == 'sellerUserId' ? '' : [sceneType]
})
if (data && data.length) {
this.employeeList = data
this.formObj.userInfo = data[0]
this.$set(this.orderObj, 'employeeName', data[0].staffName)
this.orderObj.userId = data[0].uuid
}
}
}
}
......@@ -246,7 +314,7 @@ export default {
.box {
height: calc(100% - #{toRpx(120)});
padding-bottom: toRpx(24);
.scroll-view {
height: 100%;
}
......@@ -375,9 +443,7 @@ export default {
justify-content: space-between;
align-items: center;
border-bottom: toRpx(1.6) solid #dce1e6;
padding: toRpx(24);
&-left {
padding: toRpx(24); &-left {
display: flex;
align-items: center;
font-size: toRpx(28);
......@@ -419,4 +485,15 @@ export default {
font-size: toRpx(24);
color: #999;
}
.btn {
display: flex;
align-items: center;
justify-content: center;
margin: toRpx(88) auto 0;
width: toRpx(1130);
height: toRpx(80);
color: #fff;
border-radius: toRpx(48);
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
}
</style>
\ No newline at end of file
......@@ -2,34 +2,34 @@ const FORM_LIST = [
[
{
label: '销售顾问',
value: 'userInfo',
value: 'employeeName',
type: 'select',
key: 'staffName',
// key: 'staffName',
required: true,
showText: 'shopMerchantName'
},
{
label: '交付专员',
value: 'deliveryUserInfo',
value: 'deliveryEmployeeName',
type: 'select',
required: true,
key: 'staffName',
// key: 'staffName',
hidden: true,
showText: 'shopMerchantName'
},
{
label: '二级流量方',
value: 'subShopMerchantInfo',
value: 'subShopMerchantName',
type: 'select',
required: true,
key: 'subMerchantName',
// key: 'subMerchantName',
hidden: true
},
{
label: '转化人员',
value: 'sellerUserInfo',
value: 'sellerName',
type: 'select',
key: 'staffName',
// key: 'staffName',
required: true,
showText: 'merchantName'
},
......@@ -37,7 +37,7 @@ const FORM_LIST = [
[
{
label: '车主姓名',
value: 'customer',
value: 'customerName',
maxlength: '16',
type: 'input',
required: true
......@@ -80,7 +80,8 @@ const FORM_LIST = [
value: 'customerPhone',
maxlength: '11',
type: 'input',
required: true
required: true,
inputType: 'number'
},
{
label: '选择车型',
......@@ -180,7 +181,7 @@ const FORM_LIST = [
addHtml: 'package'
},
{
label: '精品礼券',
label: '其他精品',
value: 'couponInfo',
type: 'select',
key: 'name',
......@@ -271,11 +272,46 @@ const payType = [
]
const popupTypeEnum = {
0: 'userInfo',
1: 'deliveryUserInfo',
2: 'subShopMerchantInfo',
3: 'sellerUserInfo',
4: 'carBrand'
0: {
key: 'employeeName',
list: 'employeeList',
targetIdKey: 'userId',
targetNameKey: 'employeeName',
sourceIdKey: 'uuid',
sourceNameKey: 'staffName'
},
1: {
key: 'deliveryEmployeeName',
list: 'employeeList',
targetIdKey: 'deliveryUserId',
targetNameKey: 'deliveryEmployeeName',
sourceIdKey: 'uuid',
sourceNameKey: 'staffName'
},
2: {
key: 'subShopMerchantName',
list: 'subShopMerchantList',
targetIdKey: 'subShopMerchantId',
targetNameKey: 'subShopMerchantName',
sourceIdKey: 'subMerchantId',
sourceNameKey: 'subMerchantName'
},
3: {
key: 'sellerName',
list: '',
targetIdKey: 'sellerUserId',
targetNameKey: 'sellerName',
sourceIdKey: 'uuid',
sourceNameKey: 'staffName'
},
4: {
key: 'carBrand',
list: ''
},
5: {
key: 'couponInfo',
list: '',
}
}
export {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!