| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <template>
- <view class="container">
- <cu-custom id="custom"
- bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png"
- :isBack="true">
- <block slot="backText">返回</block>
- <block slot="content">
- 打卡签到
- </block>
- </cu-custom>
- <view class="box">
- <map class="map" :show-location="true" :longitude="longitude" :latitude="latitude" />
- </view>
- <My_form ref="My_form" @onConfirm="onConfirm" />
- <view class="but-box">
- <u-button type="primary" text="签到" color="#0054E1" :disabled="disabled" loadingText="执行中..." :loading="loading"
- @click="submit" />
- <view style="height: 20px;" />
- </view>
- </view>
- </template>
- <script>
- import { formatTime } from "../../utils/getTime"
- export default {
- name: "SignIn",
- data() {
- return {
- latitude: "",
- longitude: "",
- disabled: false,
- loading: false
- }
- },
- onLoad() {
- this.geoLocation()
- },
- methods: {
- geoLocation() {
- uni.showLoading({
- title: "获取位置中...",
- mask: true,
- })
- this.getLocation(true).then(res => {
- console.log("定位11",res)
- uni.hideLoading()
- if (res.errMsg != "getLocation:ok") uni.showToast({
- title: '定位失败',
- icon: "none"
- });
- let form = [{
- label: "打卡位置",
- type: 'location',//类型
- key: "location",
- value: {
- address: '',
- latitude: '',
- longitude: '',
- time: '',
- result: {}
- },
- required: true,//是否必填
- }, {
- label: "设备",
- type: 'route',//类型
- disabled: false,
- path: "/select/device",
- showKey: "devicename",
- idKey: 'w_deviceid',
- extent: 1,//可选数量
- param: {
- "id": 20230615153202,
- "content": {
- "pageNumber": 1,
- "pageSize": 20,
- "where": {
- "condition": "",
- "status": ""
- },
- }
- },
- key: "w_deviceid",
- value: {
- showList: [],
- value: []
- },
- required: false,
- }, {
- label: "备注说明",
- disabled: false,//禁用
- type: 'textarea',//类型
- placeholder: "",
- value: "",
- key: 'remarks',
- maxlength: -1,//最大长度
- required: false,//是否必填
- }, {
- label: "附件",
- disabled: false,//禁用
- type: 'file',//类型
- isDelete: true,//是否可以删除附件
- fileType: ["image", "video", "file"],//可上传类型
- key: "attinfos",
- value: [],
- required: false,//是否必填
- aDeletion: true,//是否为异步删除
- }]
- if (res.errMsg == "getLocation:ok") {
- form[0].value = {
- longitude: res.longitude,
- latitude: res.latitude,
- address: res.result.formatted_address,
- time: formatTime(),
- result: res.result
- };
- this.longitude = res.longitude
- this.latitude = res.latitude
- }
- this.$refs.My_form.render(form)
- })
- },
- onConfirm(bool) {
- this.disabled = bool;
- },
- submit() {
- let that = this, content = {
- ...this.$refs.My_form.onSubmit()
- }
- content = Object.assign(content, content.location);
- content.signdate = content.time || '';
- content.province = content.result.addressComponent.province || '';
- content.city = content.result.addressComponent.city || '';
- content.county = content.result.addressComponent.county || '';
- content.w_deviceid = content.w_deviceid.value.length ? content.w_deviceid.value[0] : '';
-
- delete content.location;
- delete content.result;
- delete content.attinfos;
- delete content.time;
- uni.showModal({
- title: '提示',
- content: '是否确定保存签到记录',
- success: ({ confirm }) => {
- if (confirm) {
- that.loading = true;
- that.$Http.basic({
- id: 20221229145901,
- content
- }).then(res => {
- console.log("签到记录", res)
- if (res.msg == '成功') {
- Promise.all([this.$refs.My_form.handleFileLink(content.attachmentids, "sys_signin", res.data), this.$refs.My_form.handleDeteleFiles(content.linksids)]).then(s => {
- console.log("绑定附件回调", s)
- that.loading = false;
- uni.showToast({
- title: "签到成功",
- icon: "none",
- mask: true,
- duration: 1000
- })
- setTimeout(() => {
- uni.navigateBack();
- }, 800);
- that.$Http.signInUpdate && that.$Http.signInUpdate()
- })
- }
- })
- }
- },
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .box {
- height: 200px;
- width: 355px;
- border-radius: 6px;
- margin: 10px auto 0;
- overflow: hidden;
- .map {
- width: 100%;
- height: 100%;
- }
- }
- .but-box {
- width: 355px;
- margin: 20px auto 0;
- /deep/ .u-button__text,
- /deep/.u-button__loading-text {
- font-size: 14px !important;
- font-weight: bold;
- }
- /deep/.u-loading-icon__spinner {
- width: 17.25px !important;
- height: 17.25px !important;
- }
- }
- </style>
|