Browse Source

bug解决

cz 1 year ago
parent
commit
1667d38f93

+ 2 - 1
src/views/production/factory/add.vue

@@ -169,9 +169,10 @@ const treeToList = (arr) => {
 onMounted(() => {
 	if (route.query.id) {
         proxy
-            .post('/workshop/detail', { id: route.query.id })
+            .post('/assemblyLine/detail', { id: route.query.id })
             .then((resDetail) => {
                 formData.data = resDetail.data
+								formData.data.type = formData.data.type+''
             })
     }
 })

+ 119 - 117
src/views/production/workingProcedure/add.vue

@@ -1,133 +1,135 @@
 <template>
-	<div class="form">
-		<van-nav-bar
-			title="工序管理"
-			left-text="返回"
-			left-arrow
-			@click-left="onClickLeft"
-		>
-		</van-nav-bar>
+  <div class="form">
+    <van-nav-bar
+      title="工序管理"
+      left-text="返回"
+      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>
+    <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([])
+import { ref, getCurrentInstance, onMounted, reactive } from "vue";
+import { showSuccessToast, showToast, showFailToast } 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)
+  data: {},
+});
+const formDom = ref(null);
 const formOption = reactive({
-	readonly: false, //用于控制整个表单是否只读
-	disabled: false,
-	labelAlign: 'top',
-	scroll: true,
-	labelWidth: '62pk',
-	// hiddenSubmitBtn: true,
-})
+  readonly: false, //用于控制整个表单是否只读
+  disabled: false,
+  labelAlign: "top",
+  scroll: true,
+  labelWidth: "62pk",
+  // hiddenSubmitBtn: true,
+});
 const formConfig = reactive([
-	
-	{
-		type: 'input',
-		itemType: 'text',
-		label: '车间名称',
-		prop: 'name',
-		clearable: true,
-	},
-	{
-		type: 'input',
-		itemType: 'textarea',
-		label: '备注',
-		prop: 'remarks',
-	},
-	{
-		type: 'upload',
-		label: '文件上传',
-		prop: 'fileList',
-	},
-	
-])
+  {
+    type: "input",
+    itemType: "text",
+    label: "工序名称",
+    prop: "name",
+    clearable: true,
+  },
+  {
+    type: "input",
+    itemType: "textarea",
+    label: "工序说明",
+    prop: "remarks",
+  },
+  {
+    type: "upload",
+    label: "工序文件",
+    prop: "fileList",
+  },
+]);
 const rules = {
-	name: [{ required: true, message: '车间类型不能为空' }],
-	fileList: [{ required: true, message: '请上传工序文件' }],
-}
-const unitList = ref([])
+  name: [{ required: true, message: "车间类型不能为空" }],
+  fileList: [{ required: true, message: "请上传工序文件" }],
+};
+const unitList = ref([]);
 
 const getUserList = () => {
-    proxy
-        .get('/system/user/list?pageNum=1&pageSize=10000', {
-        })
-        .then((res) => {
-            formConfig[2].data = res.rows
-        })
-}
-getUserList()
-const fileList = ref([])
+  proxy.get("/system/user/list?pageNum=1&pageSize=10000", {}).then((res) => {
+    formConfig[2].data = res.rows;
+  });
+};
+getUserList();
+const fileList = ref([]);
 const onOversize = () => {
-	showToast('文件大小不能超过 5MB')
-}
-const onClickLeft = () => history.back()
+  showToast("文件大小不能超过 5MB");
+};
+const onClickLeft = () => history.back();
 const onSubmit = () => {
-	console.log(formData)
-
-	proxy.post('/productionProcesses/' + route.query.type, formData.data).then(() => {
-		showSuccessToast(route.query.type === 'add' ? '添加成功' : '修改成功')
-		setTimeout(() => {
-			history.back()
-		}, 500)
-	})
-}
+  console.log(formData);
+  if (formData.data.fileList.length > 0) {
+    proxy
+      .post("/productionProcesses/" + route.query.type, formData.data)
+      .then(() => {
+        showSuccessToast(route.query.type === "add" ? "添加成功" : "修改成功");
+        setTimeout(() => {
+          history.back();
+        }, 500);
+      });
+  } else {
+    return showFailToast("请上传工序文件");
+  }
+};
 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
-}
+  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('/productionProcesses/detail', { id: route.query.id })
-            .then((resDetail) => {
-                formData.data = resDetail.data
-            })
-		proxy.post("/fileInfo/getList", { businessIdList: [route.query.id] }).then((res) => {
-			if (res.data[route.query.id] && res.data[route.query.id].length > 0) {
-				formData.data.fileList = res.data[route.query.id];
-				formData.data.fileList = formData.data.fileList.map((item) => {
-					return {
-						...item,
-						url: item.fileUrl,
-					};
-				});
-			} else {
-				formData.data.fileList = [];
-				fileList.value = [];
-			}
-		});
-    }
-})
+  if (route.query.id) {
+    proxy
+      .post("/productionProcesses/detail", { id: route.query.id })
+      .then((resDetail) => {
+        formData.data = resDetail.data;
+      });
+    proxy
+      .post("/fileInfo/getList", { businessIdList: [route.query.id] })
+      .then((res) => {
+        if (res.data[route.query.id] && res.data[route.query.id].length > 0) {
+          formData.data.fileList = res.data[route.query.id];
+          formData.data.fileList = formData.data.fileList.map((item) => {
+            return {
+              ...item,
+              url: item.fileUrl,
+            };
+          });
+        } else {
+          formData.data.fileList = [];
+          fileList.value = [];
+        }
+      });
+  }
+});
 </script>

+ 1 - 1
src/views/production/workshop/add.vue

@@ -97,7 +97,7 @@ const formConfig = reactive([
 		type: 'input',
 		itemType: 'textarea',
 		label: '备注',
-		prop: 'remark',
+		prop: 'remarks',
 	},
 ])
 const rules = {