update.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="container">
  3. <cu-custom id="custom"
  4. bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png"
  5. :isBack="true">
  6. <block slot="backText">返回</block>
  7. <block slot="content">
  8. 打卡签到
  9. </block>
  10. </cu-custom>
  11. <view class="box">
  12. <map class="map" :show-location="true" :longitude="longitude" :latitude="latitude" />
  13. </view>
  14. <My_form ref="My_form" @onConfirm="onConfirm" />
  15. <view class="but-box">
  16. <u-button type="primary" text="签到" color="#0054E1" :disabled="disabled" loadingText="执行中..." :loading="loading"
  17. @click="submit" />
  18. <view style="height: 20px;" />
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import { formatTime } from "../../utils/getTime"
  24. export default {
  25. name: "SignIn",
  26. data() {
  27. return {
  28. latitude: "",
  29. longitude: "",
  30. disabled: false,
  31. loading: false
  32. }
  33. },
  34. onLoad() {
  35. this.geoLocation()
  36. },
  37. methods: {
  38. geoLocation() {
  39. uni.showLoading({
  40. title: "获取位置中...",
  41. mask: true,
  42. })
  43. this.getLocation(true).then(res => {
  44. console.log("定位11",res)
  45. uni.hideLoading()
  46. if (res.errMsg != "getLocation:ok") uni.showToast({
  47. title: '定位失败',
  48. icon: "none"
  49. });
  50. let form = [{
  51. label: "打卡位置",
  52. type: 'location',//类型
  53. key: "location",
  54. value: {
  55. address: '',
  56. latitude: '',
  57. longitude: '',
  58. time: '',
  59. result: {}
  60. },
  61. required: true,//是否必填
  62. }, {
  63. label: "设备",
  64. type: 'route',//类型
  65. disabled: false,
  66. path: "/select/device",
  67. showKey: "devicename",
  68. idKey: 'w_deviceid',
  69. extent: 1,//可选数量
  70. param: {
  71. "id": 20230615153202,
  72. "content": {
  73. "pageNumber": 1,
  74. "pageSize": 20,
  75. "where": {
  76. "condition": "",
  77. "status": ""
  78. },
  79. }
  80. },
  81. key: "w_deviceid",
  82. value: {
  83. showList: [],
  84. value: []
  85. },
  86. required: false,
  87. }, {
  88. label: "备注说明",
  89. disabled: false,//禁用
  90. type: 'textarea',//类型
  91. placeholder: "",
  92. value: "",
  93. key: 'remarks',
  94. maxlength: -1,//最大长度
  95. required: false,//是否必填
  96. }, {
  97. label: "附件",
  98. disabled: false,//禁用
  99. type: 'file',//类型
  100. isDelete: true,//是否可以删除附件
  101. fileType: ["image", "video", "file"],//可上传类型
  102. key: "attinfos",
  103. value: [],
  104. required: false,//是否必填
  105. aDeletion: true,//是否为异步删除
  106. }]
  107. if (res.errMsg == "getLocation:ok") {
  108. form[0].value = {
  109. longitude: res.longitude,
  110. latitude: res.latitude,
  111. address: res.result.formatted_address,
  112. time: formatTime(),
  113. result: res.result
  114. };
  115. this.longitude = res.longitude
  116. this.latitude = res.latitude
  117. }
  118. this.$refs.My_form.render(form)
  119. })
  120. },
  121. onConfirm(bool) {
  122. this.disabled = bool;
  123. },
  124. submit() {
  125. let that = this, content = {
  126. ...this.$refs.My_form.onSubmit()
  127. }
  128. content = Object.assign(content, content.location);
  129. content.signdate = content.time || '';
  130. content.province = content.result.addressComponent.province || '';
  131. content.city = content.result.addressComponent.city || '';
  132. content.county = content.result.addressComponent.county || '';
  133. content.w_deviceid = content.w_deviceid.value.length ? content.w_deviceid.value[0] : '';
  134. delete content.location;
  135. delete content.result;
  136. delete content.attinfos;
  137. delete content.time;
  138. uni.showModal({
  139. title: '提示',
  140. content: '是否确定保存签到记录',
  141. success: ({ confirm }) => {
  142. if (confirm) {
  143. that.loading = true;
  144. that.$Http.basic({
  145. id: 20221229145901,
  146. content
  147. }).then(res => {
  148. console.log("签到记录", res)
  149. if (res.msg == '成功') {
  150. Promise.all([this.$refs.My_form.handleFileLink(content.attachmentids, "sys_signin", res.data), this.$refs.My_form.handleDeteleFiles(content.linksids)]).then(s => {
  151. console.log("绑定附件回调", s)
  152. that.loading = false;
  153. uni.showToast({
  154. title: "签到成功",
  155. icon: "none",
  156. mask: true,
  157. duration: 1000
  158. })
  159. setTimeout(() => {
  160. uni.navigateBack();
  161. }, 800);
  162. that.$Http.signInUpdate && that.$Http.signInUpdate()
  163. })
  164. }
  165. })
  166. }
  167. },
  168. })
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss" scoped>
  174. .box {
  175. height: 200px;
  176. width: 355px;
  177. border-radius: 6px;
  178. margin: 10px auto 0;
  179. overflow: hidden;
  180. .map {
  181. width: 100%;
  182. height: 100%;
  183. }
  184. }
  185. .but-box {
  186. width: 355px;
  187. margin: 20px auto 0;
  188. /deep/ .u-button__text,
  189. /deep/.u-button__loading-text {
  190. font-size: 14px !important;
  191. font-weight: bold;
  192. }
  193. /deep/.u-loading-icon__spinner {
  194. width: 17.25px !important;
  195. height: 17.25px !important;
  196. }
  197. }
  198. </style>