From 1a4d35a08d05e014663c144771976abb0edaa933 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期五, 26 七月 2024 17:41:30 +0800 Subject: [PATCH] 监管场景信息管理 --- behaviors/loading.js | 8 pages/inspection/scene/index.wxml | 5 pages/inspection/scene/info/device-location-proxy.js | 33 +++++ services/inspection/fetchScene.js | 1 pages/inspection/scene/info/components/device-location/index.json | 4 pages/inspection/scene/index.js | 19 +- pages/inspection/scene/info/components/device-location/index.wxml | 50 ++++++++ pages/inspection/scene/info/components/device-location/index.wxss | 9 + pages/inspection/scene/info/deviceinfo.wxml | 21 +++ pages/inspection/scene/info/index.json | 4 pages/inspection/scene/info/components/device-location/index.js | 51 ++++++++ pages/inspection/scene/info/index.js | 44 ------ pages/inspection/scene/info/index.wxml | 38 +++-- pages/inspection/scene/info/deviceinfo-proxy.js | 11 + pages/inspection/scene/info/index.wxss | 4 pages/inspection/scene/info/device-info-items.js | 35 +++++ model/sceneType.js | 3 pages/inspection/scene/info/device-location.wxml | 12 ++ pages/inspection/detail/chart-proxy.js | 8 19 files changed, 284 insertions(+), 76 deletions(-) diff --git a/behaviors/loading.js b/behaviors/loading.js index 68e63f3..5c45ba7 100644 --- a/behaviors/loading.js +++ b/behaviors/loading.js @@ -81,12 +81,12 @@ _fetch() { if (typeof this._fetchData === 'function') { - this._fetchData(this.data.cPage) + const promise = this._fetchData(this.data.cPage); + if (!promise) return; + promise .then(head => { if (head) { - let cPage = head.currentPage - ? parseInt(head.currentPage) - : parseInt(head.page); + let cPage = head.currentPage ? parseInt(head.currentPage) : parseInt(head.page); let tPage = parseInt(head.totalPage); let totalCount = head.totalCount ? parseInt(head.totalCount) : 0; this._setPagination(cPage, tPage, totalCount); diff --git a/model/sceneType.js b/model/sceneType.js index ce6d9ea..450b772 100644 --- a/model/sceneType.js +++ b/model/sceneType.js @@ -21,7 +21,8 @@ */ function transSceneType(value) { const s = sceneMap[value] - return s == undefined ? '-1' : s; + return s + // return s == undefined ? '-1' : s; } export { transSceneType }; diff --git a/pages/inspection/detail/chart-proxy.js b/pages/inspection/detail/chart-proxy.js index c0e86fc..31393c0 100644 --- a/pages/inspection/detail/chart-proxy.js +++ b/pages/inspection/detail/chart-proxy.js @@ -112,8 +112,8 @@ const changes = []; const xAxisMonth = this.getXAxisMonth(); xAxisMonth.forEach(m => { - problems.push('0'); - changes.push('0'); + problems.push(0); + changes.push(0); }); this.data.subtaskSummary.forEach(s => { const month = dayjs(s.stPlanTime).month() + 1 + '鏈�'; @@ -121,8 +121,8 @@ return month == value; }); if (index) { - problems[index] = s.proNum; - changes[index] = s.changeNum; + problems[index] += s.proNum; + changes[index] += s.changeNum; } }); const datas = [problems, changes]; diff --git a/pages/inspection/scene/index.js b/pages/inspection/scene/index.js index cb0c7f3..a74171a 100644 --- a/pages/inspection/scene/index.js +++ b/pages/inspection/scene/index.js @@ -18,8 +18,9 @@ _fetchData(page) { const { area, onlineValue, sceneValue } = this.data; + if (!onlineValue || !sceneValue) return; area.scensetypeid = sceneValue[0]; - area.online = onlineValue; + area.online = onlineValue[0]; return searchScene(area, page).then(res => { if (res.success) { this.setData({ @@ -42,14 +43,14 @@ onLocationChange(e) { const { area } = this.data; - area.provinceName = e.detail.provinceText; - area.cityName = e.detail.cityText; - area.districtName = e.detail.districtText; - area.townName = e.detail.townText; - area.provinceCode = e.detail.provinceValue; - area.cityCode = e.detail.cityValue; - area.districtCode = e.detail.districtValue; - area.townCode = e.detail.townValue; + area.provincename = e.detail.provinceText; + area.cityname = e.detail.cityText; + area.districtname = e.detail.districtText; + area.townname = e.detail.townText; + area.provincecode = e.detail.provinceValue; + area.citycode = e.detail.cityValue; + area.districtcode = e.detail.districtValue; + area.towncode = e.detail.townValue; area.locationValue = e.detail.locationValue; this.setData({ area }); this._startLoad(); diff --git a/pages/inspection/scene/index.wxml b/pages/inspection/scene/index.wxml index f8ea607..7624129 100644 --- a/pages/inspection/scene/index.wxml +++ b/pages/inspection/scene/index.wxml @@ -11,7 +11,8 @@ color="var(--td-font-white-1)" style-mode="picker" picker-class="picker-location" - bind:onChange="onOnlineChange" + bind:onlinePickerChange="onOnlineChange" + bind:onlineInitValue="onOnlineChange" ></online-picker> <location-picker color="var(--td-font-white-1)" @@ -21,7 +22,7 @@ ></location-picker> </view> <view class="filter-wrap-2"> - <scene-picker sceneMode="{{1}}" bind:scenePickerChange="onScenePickerConfirm" /> + <scene-picker sceneMode="{{1}}" bind:scenePickerChange="onScenePickerConfirm" bind:sceneInitValue="onScenePickerConfirm"/> </view> </view> </t-sticky> diff --git a/pages/inspection/scene/info/components/device-location/index.js b/pages/inspection/scene/info/components/device-location/index.js new file mode 100644 index 0000000..e3a42cc --- /dev/null +++ b/pages/inspection/scene/info/components/device-location/index.js @@ -0,0 +1,51 @@ +import dayjs from 'dayjs'; + +Component({ + options: { + addGlobalClass: true, + multipleSlots: true, + }, + properties: { + index: { + type: Number, + value: 0, + }, + readOnly: { + type: Boolean, + value: false, + }, + // 璁惧浣嶇疆淇℃伅 + location: { + type: Object, + value: {}, + observer(value) { + this.setData({ ...value }); + }, + }, + }, + + data: {}, + + methods: { + onStandardChange(e) { + if (!e) { + this.setData({ dlUnstandardReason: '' }); + } + }, + changeEdit() { + this.setData({ readOnly: false, isUpdate: true }); + }, + cancel() { + this.setData({ readOnly: true }); + this.triggerEvent('cancel'); + }, + confirm() { + const date = this.data.dlUpdateTime ? dayjs(this.data.dlUpdateTime) : dayjs(); + const time = date.format('YYYY骞碝M鏈圖D鏃�'); + this.setData({ time, readOnly: true }); + const { readOnly, location, ...rest } = this.data; + this.triggerEvent('confirm', rest); + }, + update() {}, + }, +}); diff --git a/pages/inspection/scene/info/components/device-location/index.json b/pages/inspection/scene/info/components/device-location/index.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/pages/inspection/scene/info/components/device-location/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/inspection/scene/info/components/device-location/index.wxml b/pages/inspection/scene/info/components/device-location/index.wxml new file mode 100644 index 0000000..854451f --- /dev/null +++ b/pages/inspection/scene/info/components/device-location/index.wxml @@ -0,0 +1,50 @@ +<view wx:if="{{time}}" class="flex-h"> + <!-- <t-divider content="鍙樻洿鏃堕棿: {{time}}" align="left" /> --> + <view>{{index}}. 鍙樻洿鏃堕棿: {{time}}</view> + <view wx:if="{{readOnly}}"> + <t-button theme="primary" size="extra-small" bind:tap="changeEdit">淇敼</t-button> + </view> +</view> +<t-input + label="瀹夎浣嶇疆" + placeholder="璇疯緭鍏ュ畨瑁呬綅缃�" + model:value="{{dlLocation}}" + disabled="{{readOnly}}" +/> +<t-input + label="缁忓害" + placeholder="璇疯緭鍏ョ粡搴�" + model:value="{{dlLongitude}}" + disabled="{{readOnly}}" +/> +<t-input + label="缁村害" + placeholder="璇疯緭鍏ョ淮搴�" + model:value="{{dlLatitude}}" + disabled="{{readOnly}}" +/> +<t-cell title="鏄惁瑙勮寖"> + <t-switch + model:value="{{dlStandard}}" + defaultValue="{{true}}" + label="{{['鏄�', '鍚�']}}" + slot="note" + disabled="{{readOnly}}" + bind:change="onStandardChange" + /> +</t-cell> +<t-input + wx:if="{{!dlStandard}}" + label="涓嶈鑼冭鏄�" + placeholder="璇疯緭鍏ヨ鏄�" + model:value="{{dlUnstandardReason}}" + disabled="{{readOnly}}" +/> +<view wx:if="{{!readOnly}}" style="display: flex; gap: 4"> + <t-button theme="light" block size="small" bind:tap="cancel">鍙栨秷</t-button> + <t-button wx:if="{{!isUpdate}}" theme="primary" block block size="small" bind:tap="confirm" + >淇濆瓨</t-button + > + <t-button wx:else theme="primary" block block size="small" bind:tap="update">鏇存柊</t-button> +</view> +<!-- <t-divider /> --> diff --git a/pages/inspection/scene/info/components/device-location/index.wxss b/pages/inspection/scene/info/components/device-location/index.wxss new file mode 100644 index 0000000..51d9aa7 --- /dev/null +++ b/pages/inspection/scene/info/components/device-location/index.wxss @@ -0,0 +1,9 @@ +/* pages/inspection/scene/info/components/device-location/index.wxss */ +.flex-h { + display: flex; + justify-content: space-between; + align-items: center; + /* background-color: blanchedalmond; */ + padding: 0 16px; + margin-top: 8px; +} \ No newline at end of file diff --git a/pages/inspection/scene/info/device-info-items.js b/pages/inspection/scene/info/device-info-items.js new file mode 100644 index 0000000..92f4ff4 --- /dev/null +++ b/pages/inspection/scene/info/device-info-items.js @@ -0,0 +1,35 @@ +export const menuData = [ + { + label: '绔欑偣鍚嶇О', + placeholder: '璇疯緭鍏ョ珯鐐瑰悕绉�', + name: 'diName', + value: '', + status: 'success', + tips: '绔欑偣鍚嶇О涓嶈兘涓虹┖', + onChange:(v)=>{ + this.value = v + } + }, + { + label: 'MN缂栧彿', + placeholder: '璇疯緭鍏N缂栧彿', + name: 'diMnCode', + value: '', + status: 'success', + tips: 'MN缂栧彿涓嶈兘涓虹┖', + onChange:(v)=>{ + this.value = v + } + }, + { + label: '璁惧绫诲瀷', + placeholder: '璇疯緭鍏ヨ澶囩被鍨�', + name: 'diType', + value: '', + status: 'success', + tips: '璁惧绫诲瀷涓嶈兘涓虹┖', + onChange:(v)=>{ + this.value = v + } + }, +]; diff --git a/pages/inspection/scene/info/device-location-proxy.js b/pages/inspection/scene/info/device-location-proxy.js new file mode 100644 index 0000000..8293cac --- /dev/null +++ b/pages/inspection/scene/info/device-location-proxy.js @@ -0,0 +1,33 @@ +/** + * 璁惧瀹夎浣嶇疆淇℃伅绠$悊 + */ +export const useDeviceLocation = Behavior({ + data: { + showNewLocation: false, + newLocation: {}, + deviceLocationList: [], + }, + methods: { + onAddLocation() { + this.setData({ + showNewLocation: true, + newLocation: {}, + }); + }, + + saveNewLocation(e) { + const { deviceLocationList } = this.data; + deviceLocationList.push(e.detail); + debugger + this.setData({ + showNewLocation: false, + deviceLocationList, + }); + }, + cancelNewLocation() { + this.setData({ + showNewLocation: false, + }); + }, + }, +}); diff --git a/pages/inspection/scene/info/device-location.wxml b/pages/inspection/scene/info/device-location.wxml new file mode 100644 index 0000000..57d090d --- /dev/null +++ b/pages/inspection/scene/info/device-location.wxml @@ -0,0 +1,12 @@ +<block wx:for="{{deviceLocationList}}"> + <device-location index="{{index + 1}}" read-only="{{true}}" location="{{item}}"></device-location> +</block> +<t-button wx:if="{{!showNewLocation}}" theme="light" size="small" bind:tap="onAddLocation" + >鏂板浣嶇疆鍙樻洿淇℃伅</t-button +> +<device-location + wx:if="{{showNewLocation}}" + location="{{newLocation}}" + bind:cancel="cancelNewLocation" + bind:confirm="saveNewLocation" +></device-location> diff --git a/pages/inspection/scene/info/deviceinfo-proxy.js b/pages/inspection/scene/info/deviceinfo-proxy.js index e69de29..8a8ea48 100644 --- a/pages/inspection/scene/info/deviceinfo-proxy.js +++ b/pages/inspection/scene/info/deviceinfo-proxy.js @@ -0,0 +1,11 @@ +/** + * 璁惧淇℃伅绠$悊 + */ +export const useDeviceInfo = Behavior({ + data: { + + }, + methods: { + + }, +}); \ No newline at end of file diff --git a/pages/inspection/scene/info/deviceinfo.wxml b/pages/inspection/scene/info/deviceinfo.wxml index e69de29..9593565 100644 --- a/pages/inspection/scene/info/deviceinfo.wxml +++ b/pages/inspection/scene/info/deviceinfo.wxml @@ -0,0 +1,21 @@ +<t-input label="绔欑偣鍚嶇О" placeholder="璇疯緭鍏ョ珯鐐瑰悕绉�" model:value="{{diName}}" /> +<t-input label="MN缂栧彿" placeholder="璇疯緭鍏N缂栧彿" model:value="{{diMnCode}}" /> +<t-input label="璁惧绫诲瀷" placeholder="璇疯緭鍏ヨ澶囩被鍨�" model:value="{{diType}}" /> +<t-input label="渚涘簲鍟�" placeholder="璇疯緭鍏ヤ緵搴斿晢" model:value="{{diSupplier}}" /> +<t-input label="杩愮淮鍟�" placeholder="璇疯緭鍏ヨ繍缁村晢" model:value="{{diMaintainer}}" /> +<t-cell title="鏄惁涓婄嚎"> + <t-switch + model:value="{{diRunningStatus}}" + defaultValue="{{true}}" + label="{{['鏄�', '鍚�']}}" + slot="note" + /> +</t-cell> +<t-cell title="鏄惁鎷嗛櫎"> + <t-switch + model:value="{{diRemoved}}" + defaultValue="{{false}}" + label="{{['鏄�', '鍚�']}}" + slot="note" + /> +</t-cell> diff --git a/pages/inspection/scene/info/index.js b/pages/inspection/scene/info/index.js index 9ec8700..1df3502 100644 --- a/pages/inspection/scene/info/index.js +++ b/pages/inspection/scene/info/index.js @@ -1,13 +1,10 @@ -// pages/inspection/scene/info/index.js +import { useDeviceInfo } from './deviceinfo-proxy.js'; +import { useDeviceLocation } from './device-location-proxy.js'; + Page({ - /** - * 椤甸潰鐨勫垵濮嬫暟鎹� - */ + behaviors: [useDeviceInfo, useDeviceLocation], data: {}, - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 - */ onLoad(options) { this.getOpenerEventChannel().on('acceptSceneData', data => { if (data) { @@ -18,38 +15,5 @@ }); }, - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 - */ - onReady() {}, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず - */ - onShow() {}, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 - */ - onHide() {}, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 - */ - onUnload() {}, - - /** - * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 - */ - onPullDownRefresh() {}, - - /** - * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� - */ onReachBottom() {}, - - /** - * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� - */ - onShareAppMessage() {}, }); diff --git a/pages/inspection/scene/info/index.json b/pages/inspection/scene/info/index.json index d909319..fc4c8b5 100644 --- a/pages/inspection/scene/info/index.json +++ b/pages/inspection/scene/info/index.json @@ -4,5 +4,7 @@ "backgroundTextStyle": "light", "navigationBarTextStyle": "white", "navigationBarBackgroundColor": "#389AFF", - "usingComponents": {} + "usingComponents": { + "device-location": "./components/device-location/index" + } } \ No newline at end of file diff --git a/pages/inspection/scene/info/index.wxml b/pages/inspection/scene/info/index.wxml index bacba27..319b787 100644 --- a/pages/inspection/scene/info/index.wxml +++ b/pages/inspection/scene/info/index.wxml @@ -1,15 +1,23 @@ -<t-tabs - theme="card" - defaultValue="{{0}}" - space-evenly="{{true}}" - t-class="custom-tabs" - t-class-content="custom-panel" -> - <t-tab-panel label="鍩烘湰淇℃伅" value="{{0}}" class="custom-tab-panel"> - <view>鍩烘湰淇℃伅</view> - </t-tab-panel> - <t-tab-panel label="璁惧淇℃伅" value="{{1}}" class="custom-tab-panel"> - <view>璁惧淇℃伅</view> - <include src="./deviceinfo.wxml" /> - </t-tab-panel> -</t-tabs> +<view class="page"> + <view class="page-header"> </view> + <view class="page-container"> + <t-tabs + theme="card" + defaultValue="{{0}}" + space-evenly="{{true}}" + t-class="custom-tabs" + t-class-content="custom-panel" + > + <t-tab-panel label="鍩烘湰淇℃伅" value="{{0}}" class="custom-tab-panel"> + <view>鍩烘湰淇℃伅</view> + </t-tab-panel> + <t-tab-panel label="璁惧淇℃伅" value="{{1}}" class="custom-tab-panel"> + <include src="./deviceinfo.wxml" /> + </t-tab-panel> + <t-tab-panel label="璁惧浣嶇疆" value="{{3}}" class="custom-tab-panel"> + <include src="./device-location.wxml" /> + </t-tab-panel> + </t-tabs> + </view> + <view class="page-footer"></view> +</view> diff --git a/pages/inspection/scene/info/index.wxss b/pages/inspection/scene/info/index.wxss index 4916a36..ab5b1f9 100644 --- a/pages/inspection/scene/info/index.wxss +++ b/pages/inspection/scene/info/index.wxss @@ -1,3 +1,7 @@ +.page .page-container { + padding: 0; +} + .chart-panel { width: 100%; height: 550rpx; diff --git a/services/inspection/fetchScene.js b/services/inspection/fetchScene.js index d23d681..cc16dbb 100644 --- a/services/inspection/fetchScene.js +++ b/services/inspection/fetchScene.js @@ -21,6 +21,7 @@ * 鏌ユ壘鍦烘櫙 */ function searchScene(area, page = 1, perPage = 20) { + area.scensetypeid = transSceneType(area.scensetypeid); return post( { url: `/scense/find`, -- Gitblit v1.9.3