瀏覽代碼

表单优化

xiaohaizhao 1 年之前
父節點
當前提交
14427daa35
共有 6 個文件被更改,包括 140 次插入66 次删除
  1. 2 4
      components/My_form.vue
  2. 2 0
      main.js
  3. 1 3
      packageA/signIn/index.vue
  4. 48 30
      packageA/workOrder/modules/nodes.vue
  5. 14 3
      packageA/workOrder/setNode.vue
  6. 73 26
      utils/tool.js

+ 2 - 4
components/My_form.vue

@@ -126,11 +126,10 @@ let form示例 = [{
     required: false,//是否必填
 }];
 import upload from "./my-upload.vue";
-import My_Files from "./My_Files.vue";
 import { formatTime } from "../utils/getTime.js"
 export default {
     name: "My_form",
-    components: { upload, My_Files },
+    components: { upload },
     computed: {
         uploadIsShow() {
             return function (name, list) {
@@ -366,9 +365,8 @@ export default {
                 if (v.type == "radio") {
                     v.value = v.options.find(s => s[v.showKey] == v.value);
                     if (v.selectKey) v.value = v.value[v.selectKey]
-                } else {
-                    if (v.key) res[v.key] = v.value;
                 }
+                if (v.key) res[v.key] = v.value;
             })
             return res
         }

+ 2 - 0
main.js

@@ -23,6 +23,8 @@ import My_search from './components/My_search';
 Vue.component('My_search', My_search);
 import My_form from './components/My_form';
 Vue.component('My_form', My_form);
+import My_Files from './components/My_Files';
+Vue.component('My_Files', My_Files);
 
 //挂载接口
 let isDev = process.env.NODE_ENV === 'development';

+ 1 - 3
packageA/signIn/index.vue

@@ -28,7 +28,7 @@
                 </view>
                 <block v-if="item.attinfos">
                     <view style="height: 6px;" />
-                    <my_files :attinfos="item.attinfos" />
+                    <My_Files :attinfos="item.attinfos" />
                 </block>
             </view>
             <view style="height: 22vw;" />
@@ -42,11 +42,9 @@
 </template>
 
 <script>
-import my_files from "../../components/My_Files.vue";
 import { formatTime } from "../../utils/getTime"
 export default {
     name: "SignInIndex",
-    components: { my_files },
     data() {
         return {
             signindate: '',

+ 48 - 30
packageA/workOrder/modules/nodes.vue

@@ -3,9 +3,27 @@
         <view class="label">进度</view>
         <view class="step-box">
             <view class="workorder" v-for="(item, index) in nodes" :key="item.sa_workorder_nodeid">
-                <view class="workorder-title">
+
+                <view class="workorder-title" :hover-class="item.child.length == 0 ? 'navigator-hover' : ''"
+                    @click="item.child.length == 0 ? onClick(item) : ''">
                     {{ index + 1 }}.{{ item.workpresetjson.workname }}
                 </view>
+
+                <view class="child-result" v-if="item.child.length == 0">
+                    <view class="have-not-begun tag" v-if="item.status == 0">
+                        未开始
+                    </view>
+                    <block v-else>
+                        <view class="time">{{ item.changedate }}</view>
+                        <view class="done tag" v-if="item.status == 1">
+                            完成
+                        </view>
+                        <view class="underway tag" v-else>
+                            进行中
+                        </view>
+                    </block>
+                </view>
+
                 <navigator url="#" class="child" v-for="(child, childIndex) in item.child" @click="onClick(child)"
                     :key="child.sa_workorder_nodeid">
                     <view class="child-title">
@@ -88,36 +106,36 @@ export default {
             &-title {
                 font-size: 14px;
             }
+        }
+
+        .child-result {
+            margin-top: 4px;
+            display: flex;
+            align-items: center;
+
+            .have-not-begun {
+                background: #E34D59;
+            }
 
-            &-result {
-                margin-top: 4px;
-                display: flex;
-                align-items: center;
-
-                .have-not-begun {
-                    background: #E34D59;
-                }
-
-                .done {
-                    background: #4BA574;
-                }
-
-                .underway {
-                    background: #2151D1;
-                }
-
-                .tag {
-                    font-size: 10px;
-                    padding: 4px;
-                    border-radius: 4px;
-                    color: #fff;
-                    margin-left: 6px;
-                }
-
-                .time {
-                    font-size: 14px;
-                    color: #999;
-                }
+            .done {
+                background: #4BA574;
+            }
+
+            .underway {
+                background: #2151D1;
+            }
+
+            .tag {
+                font-size: 10px;
+                padding: 4px;
+                border-radius: 4px;
+                color: #fff;
+                margin-left: 6px;
+            }
+
+            .time {
+                font-size: 14px;
+                color: #999;
             }
         }
     }

+ 14 - 3
packageA/workOrder/setNode.vue

@@ -75,6 +75,14 @@ export default {
                 if (this.cutoff(res.msg)) return;
                 this.detail = res.data[0]
                 this.isReadOnly = this.isReadOnly || this.detail.status == 1;
+                try {
+                    this.detail.params = this.detail.params[0];
+                } catch (error) {
+                    this.detail.params = {
+                        value: [],
+                        showList: []
+                    };
+                }
                 let form = [{
                     label: "工序说明",//标题
                     disabled: true,//禁用
@@ -155,8 +163,11 @@ export default {
                             "where": { "condition": "" }
                         }
                     },
-                    key: "param",
-                    value: [],
+                    key: "params",
+                    value: {
+                        value: [],
+                        showList: []
+                    },
                     required: workpresetjson.paramcheck == 11,
                 });
 
@@ -180,11 +191,11 @@ export default {
                 "sa_workorderid": this.sa_workorderid,
                 "sa_workorder_nodeid": this.sa_workorder_nodeid,
                 isconfirm,
-                params: [],
                 ...this.$refs.My_form.onSubmit()
             }
             content = Object.assign(content, content.location);
             content.signdate = content.time || '';
+            content.params = [content.params] || [];
             delete content.location;
             delete content.time;
             if (isconfirm == 1) {

+ 73 - 26
utils/tool.js

@@ -30,33 +30,80 @@ function setBar() {
 function mount() {
     Vue.prototype.getLocation = (isReverseGeocoder = false) => {
         return new Promise((resolve, reject) => {
-            uni.getLocation({
-                altitude: true,
-                highAccuracyExpireTime: 5000,
-                isHighAccuracy: true,
-                success: res => {
-                    if (isReverseGeocoder) {
-                        const QQMapWX = require("./qqmap-wx-jssdk.min");
-                        let qqmapsdk = new QQMapWX({
-                            key: 'UVVBZ-UOGWZ-ZUWXC-TJQMT-TUWLO-IVFTN'
-                        });
-                        qqmapsdk.reverseGeocoder({
-                            location: {
-                                latitude: res.latitude,
-                                longitude: res.longitude
-                            },
-                            success(s) {
-                                console.log("逆解析结果", s.result)
-                                res.result = s.result;
-                                resolve(res)
-                            },
-                            fail: err => console.error(err)
-                        });
-                    } else {
-                        resolve(res)
+            let that = this;
+            handle()
+
+            function handle() {
+                uni.getLocation({
+                    altitude: true,
+                    highAccuracyExpireTime: 8000,
+                    isHighAccuracy: true,
+                    success: res => {
+                        console.log("获取定位", res)
+                        if (isReverseGeocoder) {
+                            const QQMapWX = require("./qqmap-wx-jssdk.min");
+                            let qqmapsdk = new QQMapWX({
+                                key: 'UVVBZ-UOGWZ-ZUWXC-TJQMT-TUWLO-IVFTN'
+                            });
+                            qqmapsdk.reverseGeocoder({
+                                location: {
+                                    latitude: res.latitude,
+                                    longitude: res.longitude
+                                },
+                                success(s) {
+                                    console.log("逆解析结果", s.result)
+                                    res.result = s.result;
+                                    resolve(res)
+                                },
+                                fail: err => console.error(err)
+                            });
+                        } else {
+                            resolve(res)
+                        }
+                    },
+                    fail: err => {
+                        uni.hideLoading();
+                        query()
                     }
-                }
-            })
+                })
+            }
+
+            function query() {
+                uni.getSetting({
+                    success({
+                        authSetting
+                    }) {
+                        if (authSetting['scope.userLocation']) {
+                            handle()
+                        } else {
+                            uni.showModal({
+                                title: '提示',
+                                content: '您未开启地理位置授权',
+                                cancelText: '下次再说',
+                                confirmText: '前去授权',
+                                success: ({
+                                    confirm
+                                }) => {
+                                    if (confirm) {
+                                        uni.openSetting({
+                                            success(res) {
+                                                if (res.authSetting['scope.userLocation']) handle();
+                                            }
+                                        })
+                                    } else {
+                                        uni.showToast({
+                                            title: "已拒绝地理位置授权",
+                                            icon: "none",
+                                        })
+                                    }
+                                }
+                            })
+                        }
+
+
+                    }
+                })
+            }