From cf4787bc8188cd0acc8a42793730b076742f29c1 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 16 四月 2026 17:37:35 +0800
Subject: [PATCH] 新增现场巡查模块(待完成)
---
miniprogram_npm/tdesign-miniprogram/calendar/calendar.js | 168 -------------------------------------------------------
1 files changed, 1 insertions(+), 167 deletions(-)
diff --git a/miniprogram_npm/tdesign-miniprogram/calendar/calendar.js b/miniprogram_npm/tdesign-miniprogram/calendar/calendar.js
index 0b7e2f6..39f1b68 100644
--- a/miniprogram_npm/tdesign-miniprogram/calendar/calendar.js
+++ b/miniprogram_npm/tdesign-miniprogram/calendar/calendar.js
@@ -1,167 +1 @@
-var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
-};
-import { SuperComponent, wxComponent } from '../common/src/index';
-import config from '../common/config';
-import props from './props';
-import TCalendar from '../common/shared/calendar/index';
-const { prefix } = config;
-const name = `${prefix}-calendar`;
-let Calendar = class Calendar extends SuperComponent {
- constructor() {
- super(...arguments);
- this.externalClasses = [`${prefix}-class`];
- this.options = {
- multipleSlots: true,
- styleIsolation: 'apply-shared',
- };
- this.properties = props;
- this.data = {
- prefix,
- classPrefix: name,
- months: [],
- scrollIntoView: '',
- innerConfirmBtn: { content: '纭畾' },
- };
- this.controlledProps = [
- {
- key: 'value',
- event: 'confirm',
- },
- {
- key: 'value',
- event: 'change',
- },
- ];
- this.lifetimes = {
- created() {
- this.base = new TCalendar(this.properties);
- },
- ready() {
- this.initialValue();
- this.setData({
- days: this.base.getDays(),
- });
- this.calcMonths();
- if (!this.data.usePopup) {
- this.scrollIntoView();
- }
- },
- };
- this.observers = {
- type(v) {
- this.base.type = v;
- },
- confirmBtn(v) {
- if (typeof v === 'string') {
- this.setData({ innerConfirmBtn: v === 'slot' ? 'slot' : { content: v } });
- }
- else if (typeof v === 'object') {
- this.setData({ innerConfirmBtn: v });
- }
- },
- 'firstDayOfWeek,minDate,maxDate'(firstDayOfWeek, minDate, maxDate) {
- firstDayOfWeek && (this.base.firstDayOfWeek = firstDayOfWeek);
- minDate && (this.base.minDate = minDate);
- maxDate && (this.base.maxDate = maxDate);
- this.calcMonths();
- },
- value(v) {
- this.base.value = v;
- },
- visible(v) {
- if (v) {
- this.scrollIntoView();
- this.base.value = this.data.value;
- this.calcMonths();
- }
- },
- format(v) {
- this.base.format = v;
- if (!this.data.usePopup) {
- this.calcMonths();
- }
- },
- };
- this.methods = {
- initialValue() {
- const { value, type, minDate } = this.data;
- if (!value) {
- const today = new Date();
- const now = minDate || new Date(today.getFullYear(), today.getMonth(), today.getDate()).getTime();
- const initialValue = type === 'single' ? now : [now];
- if (type === 'range') {
- initialValue[1] = now + 24 * 3600 * 1000;
- }
- this.setData({
- value: initialValue,
- });
- this.base.value = initialValue;
- }
- },
- scrollIntoView() {
- const { value } = this.data;
- if (!value)
- return;
- const date = new Date(Array.isArray(value) ? value[0] : value);
- if (date) {
- this.setData({
- scrollIntoView: `year_${date.getFullYear()}_month_${date.getMonth()}`,
- });
- }
- },
- calcMonths() {
- const months = this.base.getMonths();
- this.setData({
- months,
- });
- },
- close(trigger) {
- if (this.data.autoClose) {
- this.setData({ visible: false });
- }
- this.triggerEvent('close', { trigger });
- },
- onVisibleChange() {
- this.close('overlay');
- },
- handleClose() {
- this.close('close-btn');
- },
- handleSelect(e) {
- const { date, year, month } = e.currentTarget.dataset;
- if (date.type === 'disabled')
- return;
- const rawValue = this.base.select({ cellType: date.type, year, month, date: date.day });
- const value = this.toTime(rawValue);
- this.calcMonths();
- if (this.data.confirmBtn == null) {
- if (this.data.type === 'single' || rawValue.length === 2) {
- this.setData({ visible: false });
- this._trigger('change', { value });
- }
- }
- this.triggerEvent('select', { value });
- },
- onTplButtonTap() {
- const rawValue = this.base.getTrimValue();
- const value = this.toTime(rawValue);
- this.close('confirm-btn');
- this._trigger('confirm', { value });
- },
- toTime(val) {
- if (Array.isArray(val)) {
- return val.map((item) => item.getTime());
- }
- return val.getTime();
- },
- };
- }
-};
-Calendar = __decorate([
- wxComponent()
-], Calendar);
-export default Calendar;
+import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";import TCalendar from"../common/shared/calendar/index";import useCustomNavbar from"../mixins/using-custom-navbar";import{getPrevMonth,getPrevYear,getNextMonth,getNextYear}from"./utils";const{prefix:prefix}=config,name=`${prefix}-calendar`,defaultLocaleText={title:"璇烽�夋嫨鏃ユ湡",weekdays:["鏃�","涓�","浜�","涓�","鍥�","浜�","鍏�"],monthTitle:"{year} 骞� {month}",months:["1 鏈�","2 鏈�","3 鏈�","4 鏈�","5 鏈�","6 鏈�","7 鏈�","8 鏈�","9 鏈�","10 鏈�","11 鏈�","12 鏈�"],confirm:"纭"};let Calendar=class extends SuperComponent{constructor(){super(...arguments),this.behaviors=[useCustomNavbar],this.externalClasses=[`${prefix}-class`],this.options={multipleSlots:!0},this.properties=props,this.data={prefix:prefix,classPrefix:name,months:[],scrollIntoView:"",innerConfirmBtn:{},realLocalText:{},currentMonth:{},actionButtons:{preYearBtnDisable:!1,prevMonthBtnDisable:!1,nextMonthBtnDisable:!1,nextYearBtnDisable:!1}},this.controlledProps=[{key:"value",event:"confirm"},{key:"value",event:"change"}],this.lifetimes={created(){this.base=new TCalendar(this.properties)},ready(){const t=Object.assign(Object.assign({},defaultLocaleText),this.properties.localeText);this.initialValue(),this.setData({days:this.base.getDays(t.weekdays),realLocalText:t}),this.calcMonths(),this.updateCurrentMonth(),this.data.usePopup||this.scrollIntoView()}},this.observers={type(t){this.base.type=t},allowSameDay(t){this.base.allowSameDay=t},confirmBtn(t){"string"==typeof t?this.setData({innerConfirmBtn:"slot"===t?"slot":{content:t}}):"object"==typeof t&&this.setData({innerConfirmBtn:t})},"firstDayOfWeek,minDate,maxDate"(t,e,a){t&&(this.base.firstDayOfWeek=t),e&&(this.base.minDate=e),a&&(this.base.maxDate=a),this.calcMonths()},value(t){this.base.value=t,this.calcMonths(),this.updateCurrentMonth(Array.isArray(t)?t[0]:t)},visible(t){t&&(this.scrollIntoView(),this.base.value=this.data.value,this.calcMonths())},format(t){const{usePopup:e,visible:a}=this.data;this.base.format=t,e&&!a||this.calcMonths()}},this.methods={initialValue(){const{value:t,type:e,minDate:a}=this.data;if(!t){const t=new Date,n=a||new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),s="single"===e?n:[n];"range"===e&&(s[1]=n+864e5),this.setData({value:s}),this.base.value=s}},scrollIntoView(){const{value:t}=this.data;if(!t)return;const e=new Date(Array.isArray(t)?t[0]:t);e&&this.setData({scrollIntoView:`year_${e.getFullYear()}_month_${e.getMonth()}`})},getCurrentYearAndMonth(t){const e=new Date(t);return{year:e.getFullYear(),month:e.getMonth()}},updateActionButton(t){const e=this.getCurrentYearAndMonth(this.base.minDate),a=this.getCurrentYearAndMonth(this.base.maxDate),n=this.getCurrentYearAndMonth(t),s=new Date(e.year,e.month,1).getTime(),r=new Date(a.year,a.month,1).getTime(),i=new Date(n.year,n.month,1),o=getPrevYear(i).getTime(),h=getPrevMonth(i).getTime(),l=getNextMonth(i).getTime(),c=getNextYear(i).getTime(),m=o<s||h<s,u=h<s,g=l>r||c>r,d=l>r;this.setData({actionButtons:{preYearBtnDisable:m,prevMonthBtnDisable:u,nextYearBtnDisable:g,nextMonthBtnDisable:d}})},updateCurrentMonth(t){"none"!==this.data.switchMode&&this.calcCurrentMonth(t)},calcCurrentMonth(t){const e=t||this.getCurrentDate(),{year:a,month:n}=this.getCurrentYearAndMonth(e),s=this.data.months.filter(t=>t.year===a&&t.month===n);this.updateActionButton(e),this.setData({currentMonth:s.length>0?s:[this.data.months[0]]})},calcMonths(){const t=this.base.getMonths();this.setData({months:t})},close(t){this.data.autoClose&&this.setData({visible:!1}),this.triggerEvent("close",{trigger:t})},onVisibleChange(){this.close("overlay")},handleClose(){this.close("close-btn")},handleSelect(t){const{readonly:e}=this.properties,{date:a,year:n,month:s}=t.currentTarget.dataset;if("disabled"===a.type||e)return;const r=this.base.select({cellType:a.type,year:n,month:s,date:a.day}),i=this.toTime(r);this.calcMonths(),this.updateCurrentMonth(),null==this.data.confirmBtn&&("single"!==this.data.type&&2!==r.length||(this.setData({visible:!1}),this._trigger("change",{value:i}))),this.triggerEvent("select",{value:i})},onTplButtonTap(){const t=this.base.getTrimValue(),e=this.toTime(t);this.close("confirm-btn"),this._trigger("confirm",{value:e})},toTime:t=>t?Array.isArray(t)?t.map(t=>t.getTime()):t.getTime():null,onScroll(t){this.triggerEvent("scroll",t.detail)},getCurrentDate(){var t,e;let a=Array.isArray(this.base.value)?this.base.value[0]:this.base.value;if(this.data.currentMonth.length>0){const n=null===(t=this.data.currentMonth[0])||void 0===t?void 0:t.year,s=null===(e=this.data.currentMonth[0])||void 0===e?void 0:e.month;a=new Date(n,s,1).getTime()}return a},handleSwitchModeChange(t){const{type:e,disabled:a}=t.currentTarget.dataset;if(a)return;const n=this.getCurrentDate(),s={"pre-year":()=>getPrevYear(n),"pre-month":()=>getPrevMonth(n),"next-month":()=>getNextMonth(n),"next-year":()=>getNextYear(n)}[e]();if(!s)return;const{year:r,month:i}=this.getCurrentYearAndMonth(s);this.triggerEvent("panel-change",{year:r,month:i+1}),this.calcCurrentMonth(s)}}}};Calendar=__decorate([wxComponent()],Calendar);export default Calendar;
\ No newline at end of file
--
Gitblit v1.9.3