فهرست منبع

feat: "生产部员工录入设备出厂信息"

Ritchie 1 سال پیش
والد
کامیت
c5e3d5a293
3فایلهای تغییر یافته به همراه135 افزوده شده و 0 حذف شده
  1. 7 0
      src/router/index.js
  2. 6 0
      src/service/fife/index.js
  3. 122 0
      src/views/fife/index.vue

+ 7 - 0
src/router/index.js

@@ -14,6 +14,13 @@ const router = createRouter({
       component: () => import("@/views/home/index.vue"),
       meta: { index: 1 },
     },
+    // 生产部员工录入信息
+    {
+      path: "/fife",
+      name: "fife",
+      component: () => import("@/views/fife/index.vue"),
+      meta: { index: 1, noLogin: true }
+    },
     // 登录页面
     {
       path: "/login",

+ 6 - 0
src/service/fife/index.js

@@ -0,0 +1,6 @@
+import axios from '@/utils/axios';
+
+export function saveLocation(locationCheck) {
+    return axios.post(`/SZWL-SERVER/tLocationCheck/saveLocation`, locationCheck);
+    // return axios.post(`/tLocationCheck/saveLocation`, locationCheck);
+}

+ 122 - 0
src/views/fife/index.vue

@@ -0,0 +1,122 @@
+<template>
+    <!-- 生产部录入信息Factory information -->
+    <div class="fife" style="background-color:#ebedf0">
+        <s-header :name="'设备出厂信息录入'" :noback="false"></s-header>
+        <br>
+        <van-form @submit="onSubmit">
+            <van-cell-group inset>
+                <van-field v-model="name" name="姓名" label="姓名" placeholder="姓名"
+                    :rules="[{ required: true, message: '请填写真实姓名' }]" />
+                <van-field v-model="phone" name="电话" label="电话" placeholder="手机号码"
+                    :rules="[{ required: true, message: '请填写联系电话' }]" />
+                <van-field v-model="username" name="用户名" label="用户名" placeholder="用户名/登录账号"
+                    :rules="[{ required: true, message: '请填写用户名' }]" />
+                <van-field v-model="clientId" name="设备唯一码" label="设备唯一码" placeholder="设备唯一码" readonly 
+                    :rules="[{ required: true, message: '设备唯一码不能为空' }]" />
+
+                <van-field v-model="country" is-link readonly name="发往国家" label="发往国家" placeholder="发往国家"
+                    :rules="[{ required: true, message: '请填写发往国家' }]" @click="showPicker = true" />
+                <van-popup v-model:show="showPicker" round position="bottom">
+                    <van-picker :columns="columns" @confirm="onConfirm" @cancel="showPicker = false" />
+                </van-popup>
+
+                <van-field v-model="location" name="地区名称" label="地区名称" placeholder="城市/地区名称" />
+            </van-cell-group>
+            <div style="margin: 16px; display: flex; justify-content: center; align-items: center;">
+                <van-button round class="custom-button" type="primary" size="small" native-type="submit" block>
+                    提交
+                </van-button>
+            </div>
+        </van-form>
+
+    </div>
+</template>
+
+<script>
+import sHeader from "@/components/SimpleHeader";
+import { saveLocation } from "../../service/fife/index";
+import { ref, onMounted } from "vue";
+import { Toast } from "vant";
+
+export default {
+    components: { sHeader },
+    setup: function () {
+
+        const phone = ref('');
+        const name = ref('');
+        const username = ref('');
+        const country = ref('');
+        const location = ref('');
+        const clientId = ref('');
+        const showPicker = ref(false);
+        const columns = [
+            { text: '中国', value: '中国' },
+            { text: '美国', value: '美国' },
+            { text: '英国', value: '英国' },
+            { text: '法国', value: '法国' },
+            { text: '德国', value: '德国' },
+            { text: '意大利', value: '意大利' },
+            { text: '西班牙', value: '西班牙' },
+            { text: '俄罗斯', value: '俄罗斯' },
+            { text: '澳大利亚', value: '澳大利亚' },
+        ];
+
+        const onConfirm = ({ selectedOptions }) => {
+            if (selectedOptions[0] != null) {
+                showPicker.value = false;
+                country.value = selectedOptions[0].text;
+            }
+        }
+
+        const getClientId = () => {
+            // const urlParams = new URLSearchParams(window.location.hash);
+            const urlParams = new URLSearchParams(window.location.href.split('?')[1]);
+            clientId.value = urlParams.get('clientId');
+        }
+        onMounted(() => {
+            getClientId();
+        })
+        // 提交表单
+        const locationCheck = {
+            name: name.value,
+            phone: phone.value,
+            username: username.value,
+            clientId: clientId.value,
+            country: country.value,
+            location: location.value
+        }
+
+        const onSubmit = async () => {
+            const { data } = await saveLocation(locationCheck);
+
+            if (data.code === "00000") {
+                // 成功
+                // ElMessage.success("保存成功");
+                Toast(data.message);
+            } else {
+                Toast(data.message);
+            }
+        }
+
+        return {
+            onSubmit,
+            clientId,
+            locationCheck,
+            onConfirm,
+            columns,
+            showPicker,
+            country,
+            name,
+            location,
+            username,
+            phone,
+        };
+    }
+}
+</script>
+
+<style>
+.custom-button {
+    width: 120px;
+}
+</style>