Browse Source

(*) 更换picker组件,自动弹出选择巡检计划

master
liujiangyong 2 years ago
parent
commit
91ade8e3bb
  1. 1
      .gitignore
  2. 15
      weapp/package.json
  3. 35
      weapp/package/startInspection/startInspection.js
  4. 9
      weapp/package/startInspection/startInspection.json
  5. 12
      weapp/package/startInspection/startInspection.wxml
  6. 9
      weapp/package/startInspection/startInspection.wxss

1
.gitignore

@ -148,3 +148,4 @@ web/log
# weapp # weapp
project.private.config.json project.private.config.json
miniprogram_npm

15
weapp/package.json

@ -0,0 +1,15 @@
{
"name": "xunjian-weapp",
"version": "1.0.0",
"description": "",
"main": ".eslintrc.js",
"dependencies": {
"tdesign-miniprogram": "^1.0.0-rc.2"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

35
weapp/package/startInspection/startInspection.js

@ -17,7 +17,7 @@ Page({
data: { data: {
scenePointId: null, scenePointId: null,
planList: null, planList: null,
index: null, planListVisible: true,
dataList: '', dataList: '',
imgs: [], //上传图片 imgs: [], //上传图片
imgUrl: getApp().globalData.imgUrl, imgUrl: getApp().globalData.imgUrl,
@ -28,11 +28,17 @@ Page({
address: '', //当前位置 address: '', //当前位置
}, },
bindPickerChange: function (e) { onPickerChange(e) {
const { key } = e.currentTarget.dataset;
const { value } = e.detail;
this.setData({ this.setData({
index: e.detail.value [`${key}Visible`]: false,
}) [`${key}Value`]: value,
const curPlan = this.data.planList[e.detail.value]; [`${key}Text`]: value.join(' '),
});
const curPlan = this.data.planList[e.detail.columns[0].index];
let points = curPlan.points.map(e => { let points = curPlan.points.map(e => {
return e.name return e.name
}).join('、') }).join('、')
@ -45,6 +51,17 @@ Page({
this.getPatrolRecord(); this.getPatrolRecord();
}, },
onPickerCancel(e) {
const { key } = e.currentTarget.dataset;
this.setData({
[`${key}Visible`]: false,
});
},
onPlanListPicker() {
this.setData({ planListVisible: true });
},
handleChangeTwo(e) { handleChangeTwo(e) {
this.setData({ this.setData({
changeTwo: e.detail.value changeTwo: e.detail.value
@ -398,14 +415,18 @@ Page({
const userInfo = wx.getStorageSync('userInfo'); const userInfo = wx.getStorageSync('userInfo');
Request.get(getPatrolPlan(), { userId: userInfo.id }).then(res => { Request.get(getPatrolPlan(), { userId: userInfo.id }).then(res => {
wx.hideLoading(); wx.hideLoading();
const pointPlan = res.rows.filter(plan => { let pointPlan = res.rows.filter(plan => {
for (const point of plan.points) { for (const point of plan.points) {
if (point.id == scenePointId) { if (point.id == scenePointId) {
return true; return true;
} }
} }
return false; return false;
}) }).map(p => ({
label: p.name,
value: p.name,
...p
}))
if (!pointPlan.length) { if (!pointPlan.length) {
wx.showModal({ wx.showModal({
title: '提示', title: '提示',

9
weapp/package/startInspection/startInspection.json

@ -2,5 +2,12 @@
"navigationBarBackgroundColor": "#1979ff", "navigationBarBackgroundColor": "#1979ff",
"navigationBarTextStyle": "white", "navigationBarTextStyle": "white",
"navigationBarTitleText": "开始巡检", "navigationBarTitleText": "开始巡检",
"enablePullDownRefresh": false "enablePullDownRefresh": false,
"component": true,
"usingComponents": {
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
"t-cell": "tdesign-miniprogram/cell/cell",
"t-picker": "tdesign-miniprogram/picker/picker",
"t-picker-item": "tdesign-miniprogram/picker-item/picker-item"
}
} }

12
weapp/package/startInspection/startInspection.wxml

@ -1,12 +1,10 @@
<!-- package/startInspection/startInspection.wxml --> <!-- package/startInspection/startInspection.wxml -->
<view class="box"> <view class="box">
<view wx:if="{{planList}}"> <view class="plan-list" wx:if="{{planList}}">
<picker bindchange="bindPickerChange" value="{{index}}" range="{{planList}}" range-key="name"> <t-cell class="block" title="选择巡检计划" arrow hover note="{{planListText}}" bind:click="onPlanListPicker" />
<view class="picker" style="{{index===null ? 'color:red' : 'color:black'}}"> <t-picker visible="{{planListVisible}}" value="{{planListValue}}" data-key="planList" title="选择巡检计划" cancelBtn="取消" confirmBtn="确认" bindchange="onPickerChange" bindcancel="onPickerCancel">
{{index===null ? '请选择巡检计划:' : '巡检计划:'}}{{planList[index].name}} <t-picker-item options="{{planList}}" format></t-picker-item>
</view> </t-picker>
</picker>
<view class="line"></view>
</view> </view>
<view class="titleFirst">巡检要求</view> <view class="titleFirst">巡检要求</view>
<view class="txt"> <view class="txt">

9
weapp/package/startInspection/startInspection.wxss

@ -5,8 +5,9 @@
padding: 30rpx 0; padding: 30rpx 0;
} }
.picker { .plan-list {
margin-bottom: 40rpx; margin-bottom: 30rpx;
} }
.titleFirst { .titleFirst {
@ -110,3 +111,7 @@
width: 160rpx; width: 160rpx;
height: 160rpx; height: 160rpx;
} }
.block {
display: block;
}
Loading…
Cancel
Save