提交 c10f4b12 作者: 方治民
...@@ -4,7 +4,7 @@ import { otherHttp } from '/@/utils/http/axios' ...@@ -4,7 +4,7 @@ import { otherHttp } from '/@/utils/http/axios'
enum Api { enum Api {
purchaseList = '/purchaseSell/bizPurchase/list', // 采购需求列表 purchaseList = '/purchaseSell/bizPurchase/list', // 采购需求列表
supplyList = '/purchaseSell/bizSupply/list', // 供应需求列表 supplyList = '/purchaseSell/bizSupply/list', // 供应需求列表
purchaseSellDetails = '/purchaseSell/bizPurchase/queryByld', // 产销详情 purchaseSellDetails = '/purchaseSell/bizPurchase/queryById', // 产销详情
purchaseSell = '/purchaseSell/bizPurchase/add', // 发布采购需求 purchaseSell = '/purchaseSell/bizPurchase/add', // 发布采购需求
supplyAdd = '/purchaseSell/bizSupply/add', // 发布供应需求 supplyAdd = '/purchaseSell/bizSupply/add', // 发布供应需求
bizPurchaseSupplyRecord = '/purchaseSell/bizPurchaseSupplyRecord/add', // 报价 bizPurchaseSupplyRecord = '/purchaseSell/bizPurchaseSupplyRecord/add', // 报价
......
// 上传请求
import { otherHttp } from '/@/utils/http/axios'
enum Api {
cascaderHn = '/region/cascader/hn', // 获取湖南省内 市/区县/乡镇级联数据
}
/**
* 查询湖南省 市/区县/乡镇
* @returns 市/区县/乡镇
*/
export function cascaderHn() {
return otherHttp.get({
url: Api.cascaderHn,
})
}
\ No newline at end of file
...@@ -8,7 +8,6 @@ enum Api { ...@@ -8,7 +8,6 @@ enum Api {
farmMachineAddFarm = '/farmMachine/machineWork/app/addFarm', // 发布农活服务 farmMachineAddFarm = '/farmMachine/machineWork/app/addFarm', // 发布农活服务
farmMachineEdit = '/farmMachine/machineWork/edit', // 编辑农机服务 farmMachineEdit = '/farmMachine/machineWork/edit', // 编辑农机服务
farmMachineRegister = '/farmMachine/machineWork/app/register', // 参与服务 farmMachineRegister = '/farmMachine/machineWork/app/register', // 参与服务
cascaderHn = '/region/cascader/hn',
} }
/** /**
...@@ -81,13 +80,3 @@ export function farmMachineRegister(params = {}) { ...@@ -81,13 +80,3 @@ export function farmMachineRegister(params = {}) {
params, params,
}) })
} }
\ No newline at end of file
/**
* 查询湖南省 市/区县/乡镇
* @returns 市/区县/乡镇
*/
export function cascaderHn() {
return otherHttp.get({
url: Api.cascaderHn,
})
}
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import PriceDialog from './components/price-dialog.vue' import PriceDialog from './components/price-dialog.vue'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import * as ChanxiaoAPI from '@/api/model/chanxiao' import * as ChanxiaoAPI from '@/api/model/chanxiao'
import { getText } from '@/utils/dict/area'
// 下拉刷新 // 下拉刷新
onPullDownRefresh(() => { onPullDownRefresh(() => {
...@@ -92,7 +93,7 @@ ...@@ -92,7 +93,7 @@
pageData.purchaseDemands = [...pageData.purchaseDemands, ...records] pageData.purchaseDemands = [...pageData.purchaseDemands, ...records]
pageData.purchaseDemands = pageData.purchaseDemands.map((item) => ({ pageData.purchaseDemands = pageData.purchaseDemands.map((item) => ({
...item, ...item,
location: `${item.province}${item.city}`, location: getText(`${item.province},${item.city},${item.country}`, ' / '),
})) }))
pageData.total = total pageData.total = total
}) })
...@@ -109,7 +110,7 @@ ...@@ -109,7 +110,7 @@
pageData.supplyInfos = [...pageData.supplyInfos, ...records] pageData.supplyInfos = [...pageData.supplyInfos, ...records]
pageData.supplyInfos = pageData.supplyInfos.map((item) => ({ pageData.supplyInfos = pageData.supplyInfos.map((item) => ({
...item, ...item,
location: `${item.province}${item.city}`, location: getText(`${item.province},${item.city},${item.country}`, ' / '),
})) }))
pageData.total = total pageData.total = total
}) })
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as ChanxiaoAPI from '@/api/model/chanxiao' import * as ChanxiaoAPI from '@/api/model/chanxiao'
import * as UserInfoAPI from '@/api/model/userInfo' import * as UserInfoAPI from '@/api/model/userInfo'
import { areaTree, getCodeByText, getTextByCode } from '@/utils/areaData' import { getDictData, getText } from '@/utils/dict/area'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore() const dictStore = useDictStore()
...@@ -123,9 +123,8 @@ ...@@ -123,9 +123,8 @@
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
function initDict() { async function initDict() {
pageData.options.address = areaTree pageData.options.address = await getDictData()
console.log(dictStore.getDictList.purchase_status)
pageData.options.status = dictStore.getDictList.purchase_status.map((item) => { pageData.options.status = dictStore.getDictList.purchase_status.map((item) => {
return { return {
...@@ -159,7 +158,7 @@ ...@@ -159,7 +158,7 @@
function getDetails(id) { function getDetails(id) {
ChanxiaoAPI.purchaseSellDetails({ id }).then((res) => { ChanxiaoAPI.purchaseSellDetails({ id }).then((res) => {
pageData.form = res pageData.form = res
pageData.form.address = `${getTextByCode(res.province)}/${getTextByCode(res.city)}/${getTextByCode(res.country)}` pageData.form.address = `${res.province}/${res.city}/${res.country}`
pageData.form.statusText = pageData.options.status.find((item) => item.value == res.status).text pageData.form.statusText = pageData.options.status.find((item) => item.value == res.status).text
pageData.form.classifyText = pageData.options.classify.find((item) => item.value == res.classify).text pageData.form.classifyText = pageData.options.classify.find((item) => item.value == res.classify).text
pageData.form.imageObj = pageData.form.image && parseUrlInfo(pageData.form.image) pageData.form.imageObj = pageData.form.image && parseUrlInfo(pageData.form.image)
...@@ -196,7 +195,7 @@ ...@@ -196,7 +195,7 @@
pageData.show.classify = false pageData.show.classify = false
} }
function handleChangeAddress(e) { function handleChangeAddress(e) {
pageData.form.address = e.text.join('/') pageData.form.address = e.value.join(',')
pageData.show.address = false pageData.show.address = false
} }
function handleChangeStatus(e) { function handleChangeStatus(e) {
...@@ -268,11 +267,11 @@ ...@@ -268,11 +267,11 @@
* @param formData 表单数据 * @param formData 表单数据
*/ */
function changeAddressValue(formData) { function changeAddressValue(formData) {
const addressValue = formData.address.split('/') const addressValue = formData.address.split(',')
if (addressValue.length === 3) { if (addressValue.length === 3) {
formData.province = getCodeByText(addressValue[0]) formData.province = addressValue[0]
formData.city = getCodeByText(addressValue[1]) formData.city = addressValue[1]
formData.country = getCodeByText(addressValue[2]) formData.country = addressValue[2]
} }
} }
...@@ -315,7 +314,7 @@ ...@@ -315,7 +314,7 @@
<text class="label" style="font-size: 28rpx">请选择区域</text> <text class="label" style="font-size: 28rpx">请选择区域</text>
<view class="select-input" @click="show.address = true"> <view class="select-input" @click="show.address = true">
<text class="time-text" :class="{ placeholder: !form.address }"> <text class="time-text" :class="{ placeholder: !form.address }">
{{ form.address || '请选择区域' }} {{ getText(form.address, ' / ') || '请选择省/市/区县' }}
</text> </text>
</view> </view>
</view> </view>
...@@ -327,12 +326,16 @@ ...@@ -327,12 +326,16 @@
<text class="label" style="font-size: 28rpx">供应时间</text> <text class="label" style="font-size: 28rpx">供应时间</text>
<view class="time-range"> <view class="time-range">
<view class="time-input" @click="show.time1 = true"> <view class="time-input" @click="show.time1 = true">
<text class="time-text" :class="{ placeholder: !form.supplyStartDate }">
{{ form.supplyStartDate || '开始时间' }}
<text class="time-text" :class="{ placeholder: !form.supplyStartDate }" style="font-size: 26rpx"> <text class="time-text" :class="{ placeholder: !form.supplyStartDate }" style="font-size: 26rpx">
{{ form.supplyStartDate || '开始时间' }} {{ form.supplyStartDate || '开始时间' }}
</text> </text>
</view> </view>
<text class="time-separator">-</text> <text class="time-separator">-</text>
<view class="time-input" @click="show.time2 = true"> <view class="time-input" @click="show.time2 = true">
<text class="time-text" :class="{ placeholder: !form.supplyEndDate }">
{{ form.supplyEndDate || '结束时间' }}
<text class="time-text" :class="{ placeholder: !form.supplyEndDate }" style="font-size: 26rpx"> <text class="time-text" :class="{ placeholder: !form.supplyEndDate }" style="font-size: 26rpx">
{{ form.supplyEndDate || '结束时间' }} {{ form.supplyEndDate || '结束时间' }}
</text> </text>
...@@ -380,6 +383,7 @@ ...@@ -380,6 +383,7 @@
background-color: #e6f5e8; background-color: #e6f5e8;
width: 750rpx; width: 750rpx;
overflow-x: hidden; overflow-x: hidden;
.mt20 { .mt20 {
margin-top: 30rpx; margin-top: 30rpx;
background: #fff; background: #fff;
...@@ -392,7 +396,7 @@ ...@@ -392,7 +396,7 @@
margin: 30rpx auto; margin: 30rpx auto;
} }
.supply-form { .purchase-form {
background: transparent; background: transparent;
} }
...@@ -422,6 +426,8 @@ ...@@ -422,6 +426,8 @@
// 添加点击区域样式 // 添加点击区域样式
.select-input { .select-input {
position: relative; position: relative;
}
}
.form-row { .form-row {
display: flex; display: flex;
...@@ -587,6 +593,7 @@ ...@@ -587,6 +593,7 @@
} }
} }
} }
::v-deep .uni-input-placeholder { ::v-deep .uni-input-placeholder {
font-size: 28rpx !important; font-size: 28rpx !important;
color: #999999 !important; color: #999999 !important;
...@@ -609,6 +616,4 @@ ...@@ -609,6 +616,4 @@
margin-bottom: 0; margin-bottom: 0;
padding: 0; padding: 0;
} }
}
}
</style> </style>
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
], ],
}) })
function open(params) { function open(params) {
reset()
pageData.form.employmentId = params.id pageData.form.employmentId = params.id
pageData.form.userId = getUserInfo.id pageData.form.userId = getUserInfo.id
pageData.show = true pageData.show = true
...@@ -72,15 +73,10 @@ ...@@ -72,15 +73,10 @@
</view> </view>
<view class="text-left"> <view class="text-left">
<fui-form ref="formRef"> <fui-form ref="formRef">
<fui-input marginTop="30" size="28" placeholder="请填写预留姓名" v-model="pageData.form.reservedname" /> <fui-input marginTop="30" size="28" placeholder="请填写姓名" v-model="pageData.form.reservedname" required maxlength="16" placeholderStyle="margin-left: 10rpx"/>
<fui-input <fui-input marginTop="30" size="28" placeholder="请填写预留手机" v-model="pageData.form.reservedmobile" required type="number" maxlength="11" placeholderStyle="margin-left: 10rpx"/>
marginTop="30"
size="28"
placeholder="请填写预留手机"
v-model="pageData.form.reservedmobile"
/>
<view style="margin-top: 30rpx"> <view style="margin-top: 30rpx">
<fui-button text="确定" bold radius="96rpx" @click="submit" /> <fui-button text="提交" bold radius="96rpx" @click="submit" />
</view> </view>
</fui-form> </fui-form>
</view> </view>
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import * as UserInfoAPI from '@/api/model/userInfo' import * as UserInfoAPI from '@/api/model/userInfo'
import { areaTree, getCodeByText, getTextByCode } from '@/utils/areaData' import { areaTree, getCodeByText, getTextByCode } from '@/utils/areaData'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
import { getDictData } from '@/utils/dict/area'
const dictStore = useDictStore() const dictStore = useDictStore()
const userStore = useUserStore() const userStore = useUserStore()
...@@ -63,56 +64,46 @@ ...@@ -63,56 +64,46 @@
}, },
rules: [ rules: [
{ {
name: 'name', name: 'type',
rule: ['required'], rule: ['required'],
msg: ['请输入名称'], msg: ['请选择用工类型'],
}, },{
{ name: 'name',
name: 'workers',
rule: ['required'], rule: ['required'],
msg: ['请输入工作内容'], msg: ['请输入标题'],
}, }, {
{
name: 'workers', name: 'workers',
rule: ['required'], rule: ['required'],
msg: ['请输入工人数量'], msg: ['请输入工人数量'],
}, }, {
{
name: 'price', name: 'price',
rule: ['required'], rule: ['required'],
msg: ['请输入价钱'], msg: ['请输入用工单价'],
}, }, {
{ name: 'starttime',
name: 'type',
rule: ['required'], rule: ['required'],
msg: ['请选择类型'], msg: ['请选择开始时间'],
}, }, {
{ name: 'estimatedendtime',
rule: ['required'],
msg: ['请选择预计结束时间'],
}, {
name: 'content',
rule: ['required'],
msg: ['请输入工作内容'],
}, {
name: 'area', name: 'area',
rule: ['required'], rule: ['required'],
msg: ['请选择地区'], msg: ['请选择地区'],
}, }, {
{
name: 'address', name: 'address',
rule: ['required'], rule: ['required'],
msg: ['请选择详细地址'], msg: ['请输入详细地址'],
}, }, {
{
name: 'urgentdegree', name: 'urgentdegree',
rule: ['required'], rule: ['required'],
msg: ['请选择紧急程度'], msg: ['请选择紧急程度'],
}, }, {
{
name: 'starttime',
rule: ['required'],
msg: ['请选择开始时间'],
},
{
name: 'estimatedendtime',
rule: ['required'],
msg: ['请选择预计结束时间'],
},
{
name: 'picture', name: 'picture',
rule: ['required'], rule: ['required'],
msg: ['请上传图片'], msg: ['请上传图片'],
...@@ -122,10 +113,8 @@ ...@@ -122,10 +113,8 @@
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
function initDict() { async function initDict() {
pageData.options.area = areaTree pageData.options.area = await getDictData()
console.log(dictStore.getDictList.purchase_status)
pageData.options.urgentdegree = dictStore.getDictList.employment_urgent.map((item) => { pageData.options.urgentdegree = dictStore.getDictList.employment_urgent.map((item) => {
return { return {
value: item.value, value: item.value,
...@@ -142,7 +131,7 @@ ...@@ -142,7 +131,7 @@
function getCurrentAddressInfo() { function getCurrentAddressInfo() {
if (!uni.getStorageSync('location')) if (!uni.getStorageSync('location'))
return return
const { lon, lat } = uni.getStorageSync('location') const { lon, lat } = uni.getStorageSync('location')
UserInfoAPI.location({ UserInfoAPI.location({
...@@ -288,18 +277,16 @@ return ...@@ -288,18 +277,16 @@ return
<view class="formBox"> <view class="formBox">
<fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false"> <fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false">
<view class="mt20"> <view class="mt20">
<fui-input required label="名称" placeholder="请输入名称" v-model="form.name" labelSize="28" label-width="180" /> <fui-input required label="用工类型" placeholder="请选择用工类型" v-model="form.typeText" labelSize="28" size="28" label-width="180" @click="show.type = true" />
<fui-input required label="工作内容" placeholder="请输入工作内容" v-model="form.content" labelSize="28" label-width="180" /> <fui-input required label="标题" placeholder="请输入标题" v-model="form.name" labelSize="28" label-width="180" maxlength="16" size="28"/>
</view> </view>
<view class="mt20"> <view class="mt20">
<fui-input required type="number" :min="0" label="工人数量" placeholder="请输入工人数量" v-model="form.workers" labelSize="28" label-width="180" /> <fui-input required type="number" :min="0" label="工人数量" placeholder="请输入工人数量" v-model="form.workers" labelSize="28" label-width="180" maxlength="4" size="28">
<fui-input required type="number" label="价钱" :min="0" placeholder="请输入价钱" v-model="form.price" labelSize="28" label-width="180" /> <view slot="suffix" class="unit-slot"></view>
<fui-input required label="类型" placeholder="请选择类型" v-model="form.typeText" labelSize="28" label-width="180" @click="show.type = true" /> </fui-input>
</view> <fui-input required type="number" label="用工单价" :min="0" placeholder="请输入用工单价" v-model="form.price" labelSize="28" label-width="180" maxlength="6" size="28">
<view class="mt20"> <view slot="suffix" class="unit-slot">元/人</view>
<fui-input required label="地区" placeholder="请选择地区" v-model="form.areaText" labelSize="28" label-width="180" @click="show.area = true" /> </fui-input>
<fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.address" labelSize="28" label-width="180" />
<fui-input required label="紧急程度" placeholder="请选择紧急程度" v-model="form.urgentdegreeText" labelSize="28" label-width="180" @click="show.urgentdegree = true" />
<!-- 时间范围 --> <!-- 时间范围 -->
<view class="form-section" style="padding: 0 30rpx"> <view class="form-section" style="padding: 0 30rpx">
<view class="form-item flex align-center"> <view class="form-item flex align-center">
...@@ -310,7 +297,7 @@ return ...@@ -310,7 +297,7 @@ return
{{ form.starttime || '开始时间' }} {{ form.starttime || '开始时间' }}
</text> </text>
</view> </view>
<text class="time-separator">-</text> <text class="time-separator"></text>
<view class="time-input" @click="show.time2 = true"> <view class="time-input" @click="show.time2 = true">
<text class="time-text" :class="{ placeholder: !form.estimatedendtime }"> <text class="time-text" :class="{ placeholder: !form.estimatedendtime }">
{{ form.estimatedendtime || '结束时间' }} {{ form.estimatedendtime || '结束时间' }}
...@@ -319,17 +306,16 @@ return ...@@ -319,17 +306,16 @@ return
</view> </view>
</view> </view>
</view> </view>
<fui-input required label="工作内容" placeholder="请输入工作内容" v-model="form.content" labelSize="28" label-width="180" maxlength="32" size="28" />
</view>
<view class="mt20">
<fui-input required label="地区" placeholder="请选择地区" v-model="form.areaText" labelSize="28" label-width="180" @click="show.area = true" size="28"/>
<fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.address" labelSize="28" label-width="180" size="28"/>
<fui-input required label="紧急程度" placeholder="请选择紧急程度" v-model="form.urgentdegreeText" labelSize="28" label-width="180" size="28" @click="show.urgentdegree = true" />
</view> </view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem"> <view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start"><span style="color: red;">*&nbsp;</span> 图片 </view> <view class="mb-1 flex justify-start" style="font-size: 28rpx;"><span style="color: red;">*&nbsp;</span> 图片 </view>
<uni-file-picker <uni-file-picker :value="form.pictureObj" ref="uploadRef" limit="1" :auto-upload="false" @select="handleUpload" @delete="handleDelete"/>
:value="form.pictureObj"
ref="uploadRef"
limit="1"
:auto-upload="false"
@select="handleUpload"
@delete="handleDelete"
/>
</view> </view>
<view class="fui-btn__box" v-if="!form.id" style="margin-top: 30rpx"> <view class="fui-btn__box" v-if="!form.id" style="margin-top: 30rpx">
<fui-button text="发布用工" bold radius="96rpx" @click="submit" /> <fui-button text="发布用工" bold radius="96rpx" @click="submit" />
...@@ -517,4 +503,9 @@ return ...@@ -517,4 +503,9 @@ return
margin-bottom: 0; margin-bottom: 0;
padding: 0; padding: 0;
} }
.unit-slot {
padding: 0 16rpx;
color: #333;
font-size: 28rpx;
}
</style> </style>
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
getCommonToolsList() getCommonToolsList()
// 农技课堂 // 农技课堂
getAgricultureClassList() getAgricultureClassList()
// 智能设备
getDeviceList()
}) })
// 下拉刷新 // 下拉刷新
...@@ -176,28 +178,11 @@ ...@@ -176,28 +178,11 @@
], ],
// 智能设备 // 智能设备
smartDevices: [ smartDevices: [],
{
id: 1, smartDeviceIcon: [
name: '土壤监测仪', '/static/images/codefun/8bd62352939b47e71f09a93a6ab344b2.png',
image: '/static/images/codefun/8bd62352939b47e71f09a93a6ab344b2.png', '/static/images/codefun/81937c2666c800cf5966c29c2891b7c4.png',
status: '在线',
statusColor: '#13e000',
},
{
id: 2,
name: '监测仪A',
image: '/static/images/codefun/81937c2666c800cf5966c29c2891b7c4.png',
status: '掉线',
statusColor: '#75777c',
},
{
id: 3,
name: '监测仪B',
image: '/static/images/codefun/8bd62352939b47e71f09a93a6ab344b2.png',
status: '在线',
statusColor: '#13e000',
},
], ],
// 信用中心 // 信用中心
...@@ -272,6 +257,12 @@ ...@@ -272,6 +257,12 @@
}) })
} }
function getDeviceList() {
NongChangAPI.getDeviceList({}).then((res) => {
pageData.smartDevices = res.records
})
}
// 菜单点击事件 // 菜单点击事件
function onMenuItemClick(item: any) { function onMenuItemClick(item: any) {
console.log('点击菜单项:', item) console.log('点击菜单项:', item)
...@@ -738,9 +729,12 @@ ...@@ -738,9 +729,12 @@
:key="device.id" :key="device.id"
class="section_16 codefun-flex-row codefun-justify-center codefun-items-center codefun-shrink-0 codefun-relative" class="section_16 codefun-flex-row codefun-justify-center codefun-items-center codefun-shrink-0 codefun-relative"
> >
<image class="image_13" :src="device.image" /> <image
class="image_13"
:src="device.isOnline === 1 ? pageData.smartDeviceIcon[0] : pageData.smartDeviceIcon[1]"
/>
<view class="codefun-ml-8 codefun-flex-col"> <view class="codefun-ml-8 codefun-flex-col">
<text class="font_14" :class="`text_${58 + index}`">{{ device.name }}</text> <text class="font_10">{{ device.deviceName }}</text>
<view class="codefun-mt-10 codefun-flex-row codefun-items-center"> <view class="codefun-mt-10 codefun-flex-row codefun-items-center">
<view class="section_17" v-if="index !== 1" /> <view class="section_17" v-if="index !== 1" />
<view class="section_18" v-if="index === 1" /> <view class="section_18" v-if="index === 1" />
...@@ -749,7 +743,7 @@ ...@@ -749,7 +743,7 @@
:class="index !== 1 ? 'text_59' : 'text_60'" :class="index !== 1 ? 'text_59' : 'text_60'"
:style="{ color: device.statusColor }" :style="{ color: device.statusColor }"
> >
{{ device.status }} {{ device.isOnline_dictText }}
</text> </text>
</view> </view>
</view> </view>
...@@ -1773,8 +1767,8 @@ ...@@ -1773,8 +1767,8 @@
.image_13 { .image_13 {
border-radius: 24rpx; border-radius: 24rpx;
width: 92rpx; width: 75rpx;
height: 92rpx; height: 75rpx;
} }
.font_14 { .font_14 {
......
...@@ -2,11 +2,19 @@ ...@@ -2,11 +2,19 @@
import { reactive } from 'vue' import { reactive } from 'vue'
import * as NongjifuwuAPI from '@/api/model/nongjifuwu' import * as NongjifuwuAPI from '@/api/model/nongjifuwu'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { getDictData, getText } from '@/utils/dict/area'
const { getUserInfo } = useUserStore() const { getUserInfo } = useUserStore()
const pageData = reactive({ const pageData = reactive({
show: false, show: false,
areaShow: {
time: false,
classify: false,
address: false,
},
options: null,
scopeText: null,
content: '', content: '',
form: { form: {
machineId: '', machineId: '',
...@@ -65,6 +73,7 @@ ...@@ -65,6 +73,7 @@
} }
function open(params) { function open(params) {
reset()
pageData.form.machineId = params.id pageData.form.machineId = params.id
pageData.form.serviceType = params.serviceType pageData.form.serviceType = params.serviceType
pageData.form.userId = getUserInfo.id pageData.form.userId = getUserInfo.id
...@@ -72,6 +81,7 @@ ...@@ -72,6 +81,7 @@
} }
function close() { function close() {
pageData.show = false pageData.show = false
pageData.areaShow.address = false
} }
function reset() { function reset() {
pageData.form = { pageData.form = {
...@@ -86,6 +96,7 @@ ...@@ -86,6 +96,7 @@
phone: '', phone: '',
demand: '', demand: '',
} }
pageData.scopeText = null
} }
const formRef = ref() const formRef = ref()
function submit() { function submit() {
...@@ -102,6 +113,14 @@ ...@@ -102,6 +113,14 @@
} }
}) })
} }
function handleChangeAddress(e) {
pageData.form.scope = e.value.join(',')
pageData.scopeText = getText(pageData.form.scope, ' / ')
pageData.areaShow.address = false
}
onShow(() => {
pageData.options = getDictData()
})
defineExpose({ defineExpose({
open, open,
close, close,
...@@ -111,23 +130,31 @@ ...@@ -111,23 +130,31 @@
<template> <template>
<fui-dialog title="" :buttons="[]" :show="pageData.show" maskClosable> <fui-dialog title="" :buttons="[]" :show="pageData.show" maskClosable>
<view class="title flex justify-center"> <view class="title flex justify-center">
<view class="flex-1">我有需要</view> <view class="flex-1">预约表单</view>
<fui-icon class="close flex-basis" name="close" size="46" color="#999999" @click="close" /> <fui-icon class="close flex-basis" name="close" size="46" color="#999999" @click="close" />
</view> </view>
<view class="text-left"> <view class="text-left">
<fui-form ref="formRef"> <fui-form ref="formRef">
<fui-input marginTop="30" size="24" placeholder="请填写手机号码" v-model="pageData.form.phone" required /> <fui-input marginTop="30" size="24" type="number" maxlength="11" placeholder="请填写手机号码" v-model="pageData.form.phone" required placeholderStyle="margin-left: 10rpx;"/>
<fui-input marginTop="30" size="24" placeholder="请选择作业区域" v-model="pageData.form.scope" required /> <fui-input marginTop="30" size="24" disabled @click="pageData.areaShow.address = true" placeholder="请选择作业区域" v-model="pageData.scopeText" required placeholderStyle="margin-left: 10rpx;"/>
<fui-input marginTop="30" size="24" placeholder="请填写详细地址" v-model="pageData.form.address" required /> <fui-input marginTop="30" size="24" placeholder="请填写详细地址" v-model="pageData.form.address" required placeholderStyle="margin-left: 10rpx;"/>
<fui-input marginTop="30" size="24" placeholder="请选择作业时间" v-model="pageData.form.time" @click="dict.show.time = true" required /> <fui-input marginTop="30" size="24" placeholder="请选择作业时间" v-model="pageData.form.time" @click="dict.show.time = true" required placeholderStyle="margin-left: 10rpx;"/>
<fui-textarea v-model="pageData.form.demand" :marginTop="30" size="24" placeholder="简要说明作业需求" required /> <fui-textarea v-model="pageData.form.demand" :marginTop="30" size="24" placeholder="简要说明作业要求" flexStart required placeholderStyle="margin-left: 10rpx;" height="100rpx" />
<view style="margin-top: 30rpx"> <view style="margin-top: 30rpx">
<fui-button type="warning" text="确定" bold radius="96rpx" @click="submit" /> <fui-button type="warning" text="提交" bold radius="96rpx" @click="submit" />
</view> </view>
</fui-form> </fui-form>
</view> </view>
</fui-dialog> </fui-dialog>
<fui-date-picker :show="dict.show.time" type="3" range @change="handleTimeChange" @cancel="handleTimeCancel" /> <fui-date-picker :show="dict.show.time" type="3" range @change="handleTimeChange" @cancel="handleTimeCancel" />
<fui-picker
:show="pageData.areaShow.address"
:options="pageData.options"
:linkage="true"
:layer="3"
@change="handleChangeAddress"
@cancel="pageData.areaShow.address = false"
/>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as nongjifuwu from '@/api/model/nongjifuwu' import * as nongjifuwu from '@/api/model/nongjifuwu'
import { getDictData, getText } from '@/utils/dict/area'
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
...@@ -91,42 +92,8 @@ ...@@ -91,42 +92,8 @@
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
function initDict() { async function initDict() {
nongjifuwu.cascaderHn().then((res) => { pageData.options.address = await getDictData()
pageData.options.address = JSON.parse(JSON.stringify(res[0].children).replaceAll('label', 'text'))
})
}
function getScope(scope: any) {
if (!scope || !pageData.options.address) {
return ''
}
const values = scope.split(',')
const labels = []
// 递归查找label
const findLabel = (nodes, value) => {
for (const node of nodes) {
if (node.value === value) {
return node.text
}
if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value)
if (found) {
return found
}
}
}
return null // 如果没找到,返回原始value
}
for (const value of values) {
const text = findLabel(pageData.options.address, value.trim())
labels.push(text)
}
return labels ? labels.join(' / ') : ''
} }
function getDetails(id) { function getDetails(id) {
...@@ -244,50 +211,20 @@ ...@@ -244,50 +211,20 @@
<view class="formBox"> <view class="formBox">
<fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false"> <fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false">
<view class="mt20"> <view class="mt20">
<fui-input <fui-input required label="服务名称" placeholder="请输入服务名称" v-model="form.name" labelSize="28" label-width="180" maxlength="16" />
required
label="服务名称"
placeholder="请输入服务名称"
v-model="form.name"
labelSize="28"
label-width="180"
/>
<view class="form-item required flex align-center" style="padding: 20rpx 10rpx"> <view class="form-item required flex align-center" style="padding: 20rpx 10rpx">
<text class="label">服务范围</text> <text class="label">服务范围</text>
<view class="time-input" @click="show.address = true"> <view class="time-input" @click="show.address = true">
<text class="select-text" :class="{ placeholder: !pageData.form.scope }"> <text class="select-text" :class="{ placeholder: !pageData.form.scope }">
{{ getScope(pageData.form.scope) || '请选择市/区县/乡镇' }} {{ getText(pageData.form.scope, ' / ') || '请选择市/区县/乡镇' }}
</text> </text>
</view> </view>
</view> </view>
<fui-input <fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.address" labelSize="28" label-width="180" size="28"/>
required <fui-input required type="number" label="联系方式" placeholder="请填写联系方式" v-model="form.phone" labelSize="28" label-width="180" :maxlength="11" />
label="详细地址"
placeholder="请输入详细地址"
v-model="form.address"
labelSize="28"
label-width="180"
/>
<fui-input
required
type="number"
label="联系方式"
placeholder="请填写联系方式"
v-model="form.phone"
labelSize="28"
label-width="180"
:maxlength="11"
/>
</view> </view>
<view class="mt20"> <view class="mt20">
<fui-input <fui-textarea flexStart required label="作业需求" placeholder="请输入作业需求" v-model="form.demand" labelSize="28" label-width="180" placeholder-style="font-size: 28rpx;"/>
required
label="作业需求"
placeholder="请输入作业需求"
v-model="form.demand"
labelSize="28"
label-width="180"
/>
<!-- 作业时间 --> <!-- 作业时间 -->
<view class="form-section" style="padding: 0 10rpx"> <view class="form-section" style="padding: 0 10rpx">
<view class="form-item flex align-center"> <view class="form-item flex align-center">
...@@ -310,46 +247,18 @@ ...@@ -310,46 +247,18 @@
</view> </view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem"> <view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start"> 图片 </view> <view class="mb-1 flex justify-start" style="font-size:28rpx;"><span class="text-red">*&nbsp;</span> 图片 </view>
<uni-file-picker <uni-file-picker :value="form.pictureObj" ref="uploadRef" limit="1" :auto-upload="false" @select="handleUpload" @delete="handleDelete" />
:value="form.pictureObj"
ref="uploadRef"
limit="1"
:auto-upload="false"
@select="handleUpload"
@delete="handleDelete"
/>
</view> </view>
<view class="fui-btn__box" v-if="!form.id" style="margin-top: 30rpx"> <view class="fui-btn__box" v-if="!form.id" style="margin-top: 30rpx">
<fui-button text="发布作业" bold radius="96rpx" @click="submit" /> <fui-button text="发布作业" bold radius="96rpx" @click="submit" />
</view> </view>
</fui-form> </fui-form>
<fui-date-picker :show="show.time1" type="3" @change="handleChangeTime1" @cancel="show.time1 = false" :minDate="getCurrentDate()" />
<fui-date-picker <fui-date-picker :show="show.time2" type="3" @change="handleChangeTime2" @cancel="show.time2 = false" :minDate="getCurrentDate()" />
:show="show.time1"
type="3"
@change="handleChangeTime1"
@cancel="show.time1 = false"
:minDate="getCurrentDate()"
/>
<fui-date-picker
:show="show.time2"
type="3"
@change="handleChangeTime2"
@cancel="show.time2 = false"
:minDate="getCurrentDate()"
/>
<fui-toast ref="toastRef" /> <fui-toast ref="toastRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" /> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
<fui-picker <fui-picker :show="show.address" :options="options.address" :linkage="true" :layer="3" @change="handleChangeAddress" @cancel="show.address = false" />
:show="show.address"
:options="options.address"
:linkage="true"
:layer="3"
@change="handleChangeAddress"
@cancel="show.address = false"
/>
</view> </view>
</view> </view>
</template> </template>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as nongjifuwu from '@/api/model/nongjifuwu' import * as nongjifuwu from '@/api/model/nongjifuwu'
import { getDictData, getText } from '@/utils/dict/area'
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
...@@ -52,7 +53,7 @@ ...@@ -52,7 +53,7 @@
{ {
name: 'name', name: 'name',
rule: ['required'], rule: ['required'],
msg: ['请填写农机名称'], msg: ['请填写作业标题'],
}, },
{ {
name: 'name', name: 'name',
...@@ -78,42 +79,8 @@ ...@@ -78,42 +79,8 @@
}) })
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
function initDict() { async function initDict() {
nongjifuwu.cascaderHn().then((res) => { pageData.options.address = await getDictData()
pageData.options.address = JSON.parse(JSON.stringify(res[0].children).replaceAll('label', 'text'))
})
}
function getScope(scope: any) {
if (!scope || !pageData.options.address) {
return ''
}
const values = scope.split(',')
const labels = []
// 递归查找label
const findLabel = (nodes, value) => {
for (const node of nodes) {
if (node.value === value) {
return node.text
}
if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value)
if (found) {
return found
}
}
}
return null // 如果没找到,返回原始value
}
for (const value of values) {
const text = findLabel(pageData.options.address, value.trim())
labels.push(text)
}
return labels ? labels.join(' / ') : ''
} }
function getDetails(id) { function getDetails(id) {
...@@ -217,11 +184,13 @@ ...@@ -217,11 +184,13 @@
<view class="mt20"> <view class="mt20">
<fui-input <fui-input
required required
label="农机名称" label="作业标题"
placeholder="请输入农机名称" placeholder="请输入作业标题"
v-model="form.name" v-model="form.name"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
maxlength="16"
size="28"
/> />
<fui-input <fui-input
required required
...@@ -230,38 +199,37 @@ ...@@ -230,38 +199,37 @@
v-model="form.phone" v-model="form.phone"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
type="number"
maxlength="11"
size="28"
/> />
<view class="form-item required flex align-center" style="padding: 20rpx 10rpx"> <view class="form-item required flex align-center" style="padding: 20rpx 10rpx">
<text class="label">服务范围</text> <text class="label">服务范围</text>
<view class="time-input" @click="show.address = true"> <view class="time-input" @click="show.address = true">
<text class="select-text" :class="{ placeholder: !pageData.form.scope }"> <text class="select-text" :class="{ placeholder: !pageData.form.scope }">
{{ getScope(pageData.form.scope) || '请选择市/区县/乡镇' }} {{ getText(pageData.form.scope, ' / ') || '请选择市/区县/乡镇' }}
</text> </text>
</view> </view>
</view> </view>
<!-- <fui-input
required
label="服务范围"
placeholder="请输入服务范围"
v-model="form.scope"
labelSize="28"
label-width="180"
></fui-input> -->
<fui-input <fui-input
required required
type="number" type="number"
label="价格(元/亩)" label="价格"
placeholder="请输入价格" placeholder="请输入价格"
number number
v-model="form.price" v-model="form.price"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
/> maxlength="6"
>
<view slot="suffix" class="unit-slot">元/亩</view>
<!-- <slot name="right" style="font-size:28rpx;"></slot> -->
</fui-input>
</view> </view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem"> <view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start"> 图片 </view> <view class="mb-1 flex justify-start" style="font-size:28rpx;"><span class="text-red">*&nbsp;</span> 图片 </view>
<uni-file-picker <uni-file-picker
:value="form.pictureObj" :value="form.pictureObj"
:max-size="1024" :max-size="1024"
...@@ -505,4 +473,9 @@ ...@@ -505,4 +473,9 @@
color: #999999; color: #999999;
} }
} }
.unit-slot {
padding: 0 16rpx;
color: #333;
font-size: 28rpx;
}
</style> </style>
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import * as NongjifuwuAPI from '@/api/model/nongjifuwu' import * as NongjifuwuAPI from '@/api/model/nongjifuwu'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import { s } from 'vite/dist/node/types.d-aGj9QkWt' import { s } from 'vite/dist/node/types.d-aGj9QkWt'
import { getDictData, getText } from '@/utils/dict/area'
onLoad((option) => { onLoad((option) => {
pageData.search.serviceType = Number(option.type) || 1 pageData.search.serviceType = Number(option.type) || 1
...@@ -67,10 +68,8 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt' ...@@ -67,10 +68,8 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt'
}) })
} }
function getCascader() { async function getCascader() {
NongjifuwuAPI.cascaderHn().then((res) => { pageData.options = await getDictData()
pageData.options = JSON.parse(JSON.stringify(res[0].children).replaceAll('label', 'text'))
})
} }
// 分类标签点击事件 // 分类标签点击事件
...@@ -106,37 +105,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt' ...@@ -106,37 +105,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt'
applyDialogRef.value.open(item) applyDialogRef.value.open(item)
} }
function getScope(scope: any) {
if (!scope || !pageData.options || pageData.options.length === 0) {
return ''
}
const values = scope.split(',')
const labels = []
// 递归查找label
const findLabel = (nodes, value) => {
for (const node of nodes) {
if (node.value === value) {
return node.text
}
if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value)
if (found) {
return found
}
}
}
return null // 如果没找到,返回原始value
}
for (const value of values) {
const text = findLabel(pageData.options, value.trim())
labels.push(text)
}
return labels ? labels.join(' / ') : ''
}
function handleChangeAddress(e) { function handleChangeAddress(e) {
pageData.search.scope = e.value.join(',') pageData.search.scope = e.value.join(',')
...@@ -165,7 +134,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt' ...@@ -165,7 +134,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt'
<view class="codefun-flex-row codefun-justify-between section_2"> <view class="codefun-flex-row codefun-justify-between section_2">
<text class="font_2 text_2">服务区域</text> <text class="font_2 text_2">服务区域</text>
<view class="codefun-flex-row codefun-items-center" @click="pageData.show.address = true"> <view class="codefun-flex-row codefun-items-center" @click="pageData.show.address = true">
<text class="font_2 text_3">{{ getScope(pageData.search.scope) || '选择区域' }}</text> <text class="font_2 text_3">{{ getText(pageData.search.scope, ' / ') || '选择区域' }}</text>
<image <image
class="codefun-shrink-0 image_7 codefun-ml-4" class="codefun-shrink-0 image_7 codefun-ml-4"
src="/static/images/codefun/774cfe989f8417dc655fb301635f5893.png" src="/static/images/codefun/774cfe989f8417dc655fb301635f5893.png"
...@@ -206,7 +175,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt' ...@@ -206,7 +175,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt'
> >
<text class="font text_6">{{ item.name }}</text> <text class="font text_6">{{ item.name }}</text>
<text class="font_3 text_7 ellipsis" style="width: 100%; margin: 26rpx 0" <text class="font_3 text_7 ellipsis" style="width: 100%; margin: 26rpx 0"
>服务范围:{{ getScope(item.scope) }}</text >服务范围:{{ getText(item.scope, ' / ') }}</text
> >
</view> </view>
<view class="flex justify-between" style="width: 100%"> <view class="flex justify-between" style="width: 100%">
...@@ -219,7 +188,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt' ...@@ -219,7 +188,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt'
class="codefun-flex-col codefun-justify-start codefun-items-center codefun-shrink-0 codefun-self-start text-wrapper_2" class="codefun-flex-col codefun-justify-start codefun-items-center codefun-shrink-0 codefun-self-start text-wrapper_2"
@click="handleApply(item)" @click="handleApply(item)"
> >
<text class="font_5">我有需要</text> <text class="font_5">去预约</text>
</view> </view>
</view> </view>
</view> </view>
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import * as UserAPI from '@/api/model/userInfo' import * as UserAPI from '@/api/model/userInfo'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import * as AreaDict from '@/utils/dict/area'
const dictStore = useDictStore() const dictStore = useDictStore()
const model = reactive({ const model = reactive({
...@@ -127,6 +128,7 @@ ...@@ -127,6 +128,7 @@
// 获取字典列表 // 获取字典列表
dictStore.setDictList() dictStore.setDictList()
AreaDict.refreshDictData()
// 查询金刚区数据 // 查询金刚区数据
getServiceItems() getServiceItems()
......
import { cascaderHn } from '/@/api/model/dict'
const storageKey = 'app_dict_data_area_cascaderHn';
export const getDictData = async () => {
// 先从本地加载数据
let dictData = getLocalDict();
if (!dictData) {
// 如果本地没有数据,则从接口获取
const res = await cascaderHn();
const data = JSON.stringify(res[0].children).replaceAll('label', 'text');
uni.setStorageSync(storageKey, data);
dictData = JSON.parse(data);
}
return dictData;
}
/**
* 获取本地数据
*/
export const getLocalDict = () => {
const data = uni.getStorageSync(storageKey);
if (data) {
return data ? JSON.parse(data) : null;
}
return null;
}
/**
* 刷新数据
*/
export const refreshDictData = () => {
// 删除本地数据
uni.removeStorageSync(storageKey);
// 重新获取数据
getDictData();
}
const areaOptions = await getDictData();
export const getText = (scope: string, spliced: string) => {
if (!scope || !areaOptions || areaOptions.length === 0) {
return ''
}
const values = scope.split(',')
const labels = []
// 递归查找label
const findLabel = (nodes, value) => {
for (const node of nodes) {
if (node.value === value) {
return node.text
}
if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value)
if (found) {
return found
}
}
}
return null // 如果没找到,返回原始value
}
for (const value of values) {
const text = findLabel(areaOptions, value.trim())
labels.push(text)
}
if (spliced) {
return labels ? labels.join(spliced) : ''
} else {
return labels ? labels.join('') : ''
}
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论