@zscreate/zhxy-app-component 1.0.105 → 1.0.106

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -508,7 +508,25 @@
508
508
  </view>
509
509
  </view>
510
510
 
511
+ <!-- location 定位 -->
512
+ <view v-if="widget.type ==='location'" class="evan-form-item-container" :class="'evan-form-item-container--top'"
513
+ :style="{borderWidth:border?'1upx':0}">
514
+ <view class="evan-form-item-container__label"
515
+ :class="{showAsteriskRect:hasRequiredAsterisk,isRequired:showRequiredAsterisk}" :style="mLabelStyle">
516
+ {{widget.name}}
517
+ </view>
518
+ <view class="evan-form-item-container__main" :style="mContentStyle">
519
+ <view class="location-form-item">
520
+ <view class="form-input cover-text" >
521
+ <view class="address">{{ dataModel }}</view>
522
+ <view @click="openDZWT" v-if="!widget.options.disabled && widget.options.enableDZWT && dataModel" style="color: #6f9bdd">地址微调</view>
523
+ </view>
524
+ <u-button type="primary" size="mini" v-if="!widget.options.disabled" @click="handleLocation">{{ widget.options.buttonText }}</u-button>
525
+ </view>
526
+ </view>
527
+ </view>
511
528
  <view class="error-message" v-if="showFalse">{{ showFalseMsg }}</view>
529
+ <u-toast ref="uToast" />
512
530
  </view>
513
531
  </template>
514
532
 
@@ -544,6 +562,7 @@ import {
544
562
  import {downloadFile} from "../../utils/util";
545
563
  import XpPicker from "../xp-picker/xp-picker.vue";
546
564
  import signatrueWrite from "../signatrue-write/signatrue-write.vue";
565
+ import {toAwait} from "../../common/util";
547
566
 
548
567
  export default {
549
568
  options: { styleIsolation: 'shared' },
@@ -652,7 +671,8 @@ export default {
652
671
  actionUrl: this.uniEnv.uploadUrl,
653
672
  correntArray: ['input', 'textarea'],
654
673
  checkboxAndRadioOptions: [],
655
- selectedData: []
674
+ selectedData: [],
675
+ locationInfo: {},
656
676
  }
657
677
  },
658
678
  mounted() {
@@ -1348,7 +1368,62 @@ export default {
1348
1368
  getBase64(base64) {
1349
1369
  this.signatrueImage = this.dataModel = base64
1350
1370
  this.signatrueFlag = false
1351
- }
1371
+ },
1372
+ // 合并代码之定位
1373
+ location() {
1374
+ uni.showLoading({
1375
+ title: "定位中",
1376
+ });
1377
+ uni.getLocation({
1378
+ type: "gcj02", //返回可以用于uni.openLocation的经纬度
1379
+ isHighAccuracy: this.widget.options.isHighAccuracy,
1380
+ highAccuracyExpireTime: this.widget.options.timeout,
1381
+ success: async (result) => {
1382
+ console.log(result);
1383
+ const { longitude: lng, latitude: lat } = result;
1384
+ this.locationInfo = result;
1385
+ const [err, res] = await toAwait(
1386
+ this.$u.get("/form/formdesiger/getLocalDetail", { lat, lng })
1387
+ );
1388
+ uni.hideLoading();
1389
+ if (err || !res.success) {
1390
+ this.$refs.uToast.show({
1391
+ title: "地址获取失败",
1392
+ duration: 2000,
1393
+ });
1394
+ return;
1395
+ }
1396
+ const { address, formatted_addresses = {} } = res.result;
1397
+ const { recommend = "", rough = "" } = formatted_addresses;
1398
+ this.dataModel = recommend || rough || address;
1399
+ },
1400
+ fail: (err) => {
1401
+ console.log(err);
1402
+ uni.hideLoading();
1403
+ const { errMsg } = err;
1404
+ if (errMsg.includes("system permission denied")) {
1405
+ this.$refs.uToast.show({
1406
+ title: "微信无定位权限,请在手机设置中开启",
1407
+ duration: 2000,
1408
+ });
1409
+ return;
1410
+ }
1411
+ if (errMsg.includes("LOCATIONSWITCHOFF")) {
1412
+ this.$refs.uToast.show({
1413
+ title: "手机定位未开启,请在手机设置中开启",
1414
+ duration: 2000,
1415
+ });
1416
+ return;
1417
+ }
1418
+
1419
+ this.$refs.uToast.show({
1420
+ title: "小程序获取定位失败",
1421
+ duration: 2000,
1422
+ });
1423
+ console.log(err);
1424
+ },
1425
+ });
1426
+ },
1352
1427
  },
1353
1428
  watch: {
1354
1429
  models: {
@@ -1678,4 +1753,20 @@ checkbox-group label {
1678
1753
  ::v-deep .uni-calendar__mask {
1679
1754
  z-index: 999;
1680
1755
  }
1756
+ .location-form-item {
1757
+ width: 100%;
1758
+ display: flex;
1759
+ align-items: center;
1760
+ box-sizing: border-box;
1761
+ padding: 10rpx 10rpx 10rpx 0;
1762
+ .address {
1763
+ font-size: 32rpx;
1764
+ width: 100%;
1765
+ color: #555;
1766
+ }
1767
+ u-button {
1768
+ flex: auto 0 0;
1769
+ margin: 0 10rpx;
1770
+ }
1771
+ }
1681
1772
  </style>
@@ -302,7 +302,15 @@ export default {
302
302
  immediate: true
303
303
  },
304
304
  suggest(v) {
305
- this.selectList = v
305
+ this.selectList = v;
306
+ const item = this.dataObj.list.find(obj => obj.model === this.verifyNode)
307
+ if (item
308
+ && !this.models[this.verifyNode].operation
309
+ && item.options.operationChooseFirst) {
310
+ this.models[this.verifyNode].operation = this.suggestType = this.suggest[0]
311
+ ? this.suggest[0].value
312
+ : "";
313
+ }
306
314
  },
307
315
  // linkage:{
308
316
  // deep: true,
@@ -786,7 +794,25 @@ export default {
786
794
  }
787
795
  }
788
796
  // console.log(promiseArr)
789
-
797
+ // 校验审核表单
798
+ promiseArr.push(new Promise((resolve, reject) => {
799
+ const item = this.models[this.verifyNode]
800
+ const widget = this.dataObj.list.find(obj => obj.model === this.verifyNode)
801
+ if (item && widget) {
802
+ const rules = {
803
+ comments: [{ required: widget.options.opinionRequire, message: '请输入审批意见' }]
804
+ }
805
+ utils.validateField(item, rules , Object.keys(rules), (success, errors) => {
806
+ if (success) {
807
+ resolve()
808
+ } else {
809
+ reject(errors)
810
+ }
811
+ },{
812
+ showMessage: true
813
+ })
814
+ }
815
+ }))
790
816
  }
791
817
  Promise.all(promiseArr).then((result) => {
792
818
  console.log(result, promiseArr.length)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zscreate/zhxy-app-component",
3
- "version": "1.0.105",
3
+ "version": "1.0.106",
4
4
  "private": false,
5
5
  "description": "zhxy-app-component",
6
6
  "main": "index.js",
package/utils/util.js CHANGED
@@ -176,10 +176,18 @@ function downloadFile(downLoadUrl, { path, name }) {
176
176
  })
177
177
  }
178
178
 
179
+ /**
180
+ * async...await 优雅的处理错误方法
181
+ * @param promise
182
+ * @returns {*}
183
+ */
184
+ const toAwait = promise => promise.then( res => [null, res ]).catch(error => [error])
185
+
179
186
  module.exports = {
180
187
  formatTime: formatTime,
181
188
  formatLocation: formatLocation,
182
189
  dateUtils: dateUtils,
190
+ toAwait,
183
191
  cloneObj: cloneObj,
184
192
  _debounce:_debounce,
185
193
  downloadFile