|
@@ -0,0 +1,140 @@
|
|
|
+<template>
|
|
|
+ <div class="form">
|
|
|
+ <van-nav-bar :title="'设备管理'" :left-text="$t('common.back')" left-arrow @click-left="onClickLeft">
|
|
|
+ </van-nav-bar>
|
|
|
+
|
|
|
+ <testForm v-model="formData.data" :formOption="formOption" :formConfig="formConfig" :rules="rules" @onSubmit="onSubmit" ref="formDom"></testForm>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { ref, getCurrentInstance, onMounted, reactive } from "vue";
|
|
|
+import { showSuccessToast, showToast } from "vant";
|
|
|
+import { useRoute } from "vue-router";
|
|
|
+import { getUserInfo } from "@/utils/auth";
|
|
|
+import testForm from "@/components/testForm/index.vue";
|
|
|
+const proxy = getCurrentInstance().proxy;
|
|
|
+const route = useRoute();
|
|
|
+const show = ref(false);
|
|
|
+const typeModal = ref(false);
|
|
|
+const unitModal = ref(false);
|
|
|
+const classification = ref([]);
|
|
|
+const formData = reactive({
|
|
|
+ data: {},
|
|
|
+});
|
|
|
+const formDom = ref(null);
|
|
|
+const formOption = reactive({
|
|
|
+ readonly: false, //用于控制整个表单是否只读
|
|
|
+ disabled: false,
|
|
|
+ labelAlign: "top",
|
|
|
+ scroll: true,
|
|
|
+ labelWidth: "62pk",
|
|
|
+ // hiddenSubmitBtn: true,
|
|
|
+});
|
|
|
+const formConfig = reactive([
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "text",
|
|
|
+ label: "设备编码",
|
|
|
+ prop: "deviceCode",
|
|
|
+ clearable: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "text",
|
|
|
+ label: "设备名称",
|
|
|
+ prop: "deviceName",
|
|
|
+ clearable: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "text",
|
|
|
+ label: "规格型号",
|
|
|
+ prop: "deviceSpec",
|
|
|
+ clearable: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "text",
|
|
|
+ label: "制造商",
|
|
|
+ prop: "makerName",
|
|
|
+ clearable: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "text",
|
|
|
+ label: "制造商电话",
|
|
|
+ prop: "makerPhone",
|
|
|
+ clearable: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "picker",
|
|
|
+ label: "出厂日期",
|
|
|
+ prop: "deviceDeliveryTime",
|
|
|
+ itemType: "datePicker",
|
|
|
+ showPicker: false,
|
|
|
+ split: "-",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "textarea",
|
|
|
+ label: "备注",
|
|
|
+ prop: "remark",
|
|
|
+ },
|
|
|
+]);
|
|
|
+const rules = {
|
|
|
+ deviceCode: [{ required: true, message: "请输入设备编码" }],
|
|
|
+ deviceName: [{ required: true, message: "请输入设备名称" }],
|
|
|
+};
|
|
|
+const unitList = ref([]);
|
|
|
+
|
|
|
+const getUserList = () => {
|
|
|
+ proxy.get("/system/user/list?pageNum=1&pageSize=10000", {}).then((res) => {
|
|
|
+ formConfig[3].data = res.rows;
|
|
|
+ });
|
|
|
+};
|
|
|
+const getWorkshopList = () => {
|
|
|
+ proxy
|
|
|
+ .post("/workshop/page", {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10000,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ formConfig[0].data = res.data.rows;
|
|
|
+ });
|
|
|
+};
|
|
|
+// getUserList();
|
|
|
+// getWorkshopList();
|
|
|
+const fileList = ref([]);
|
|
|
+const onOversize = () => {
|
|
|
+ showToast("文件大小不能超过 5MB");
|
|
|
+};
|
|
|
+const onClickLeft = () => history.back();
|
|
|
+const onSubmit = () => {
|
|
|
+ proxy.post("/tdaDevice/" + route.query.type, formData.data).then(() => {
|
|
|
+ showSuccessToast("操作成功");
|
|
|
+ setTimeout(() => {
|
|
|
+ history.back();
|
|
|
+ }, 500);
|
|
|
+ });
|
|
|
+};
|
|
|
+const treeToList = (arr) => {
|
|
|
+ let res = []; // 用于存储递归结果(扁平数据)
|
|
|
+ // 递归函数
|
|
|
+ let fn = (source) => {
|
|
|
+ source.forEach((el) => {
|
|
|
+ res.push(el);
|
|
|
+ el.children && el.children.length > 0 ? fn(el.children) : ""; // 子级递归
|
|
|
+ });
|
|
|
+ };
|
|
|
+ fn(arr);
|
|
|
+ return res;
|
|
|
+};
|
|
|
+onMounted(() => {
|
|
|
+ if (route.query.id) {
|
|
|
+ proxy.post("/tdaDevice/detail", { id: route.query.id }).then((res) => {
|
|
|
+ formData.data = res.data;
|
|
|
+ });
|
|
|
+ }
|
|
|
+});
|
|
|
+</script>
|