Browse Source

Merge branch 'master' of http://36.137.93.232:3000/hf/byte-sailing-mobile

cz 1 năm trước cách đây
mục cha
commit
1355f80868

+ 9 - 3
src/components/testForm/index.vue

@@ -255,7 +255,7 @@
           <van-button
             plain
             type="primary"
-            @click="handleRemove(index)"
+            @click="handleRemove(index,item)"
             size="mini"
             style="border: none; background: #ecebeb"
             v-if="
@@ -725,8 +725,14 @@ const handlePush = () => {
   }
 };
 // remove
-const handleRemove = (index) => {
-  formData.value[btnConfigCopy.prop].splice(index, 1);
+const handleRemove = (index,item) => {
+  console.log(item)
+  if(item.deleteFn) {
+    item.deleteFn(index,item)
+  }else{
+    formData.value[btnConfigCopy.prop].splice(index, 1);
+  }
+  
 };
 // 拉去城市最近数据及处理
 const getAreaInfo = (selectedOptions, item, index) => {

+ 1 - 1
src/router/index.js

@@ -102,7 +102,7 @@ const routes = [{
 			//生产管理模块
 			{
 				path: 'bomAdd',
-				name: 'BOM管理',
+				name: 'BOM新增',
 				component: () => import('../views/production/bom/add.vue')
 			},
 			{

+ 187 - 91
src/views/production/bom/add.vue

@@ -1,13 +1,6 @@
 <template>
-	<div class="form">
-		<van-nav-bar
-			title="工序管理"
-			left-text="返回"
-			left-arrow
-			@click-left="onClickLeft"
-		>
-		</van-nav-bar>
-
+	<div style="padding-bottom: 60px">
+		<van-nav-bar title="bom管理" left-text="" left-arrow @click-left="onClickLeft"> </van-nav-bar>
 		<testForm
 			v-model="formData.data"
 			:formOption="formOption"
@@ -16,24 +9,43 @@
 			@onSubmit="onSubmit"
 			ref="formDom"
 		></testForm>
+		<van-popup
+			v-model:show="show"
+			closeable
+			position="bottom"
+			:style="{ height: '60%' }"
+			@close="onClose"
+		>
+			<div style="height: 50px; width: 100px"></div>
+			<van-checkbox-group v-model="formData.data.applicableProductsList">
+				<van-cell-group inset v-for="i in productInfoData" :key="i.id">
+					<van-cell clickable :title="i.name">
+						<template #right-icon>
+							<van-checkbox :name="i.id"></van-checkbox>
+						</template>
+					</van-cell>
+				</van-cell-group>
+			</van-checkbox-group>
+		</van-popup>
 	</div>
 </template>
-
 <script setup>
 import { ref, getCurrentInstance, onMounted, reactive } from 'vue'
-import { showSuccessToast, showToast } from 'vant'
+import { showSuccessToast, showFailToast,showConfirmDialog } from 'vant'
+import commonList from '@/components/common-list.vue'
 import { useRoute } from 'vue-router'
-import { getUserInfo } from '@/utils/auth'
 import testForm from '@/components/testForm/index.vue'
-const proxy = getCurrentInstance().proxy
+import { getUserInfo } from '@/utils/auth'
+const loading = ref(false)
 const route = useRoute()
-const show = ref(false)
-const typeModal = ref(false)
-const unitModal = ref(false)
-const classification = ref([])
-const formData = reactive({
-	data: {},
+const req = ref({
+	pageNum: 1,
+	keyword: null,
 })
+let show = ref(false)
+const finished = ref(false)
+const classification = ref([])
+const proxy = getCurrentInstance().proxy
 const formDom = ref(null)
 const formOption = reactive({
 	readonly: false, //用于控制整个表单是否只读
@@ -42,92 +54,176 @@ const formOption = reactive({
 	scroll: true,
 	labelWidth: '62pk',
 	// hiddenSubmitBtn: true,
+	btnConfig: {
+		isNeed: true,
+		label: '明细',
+		prop: 'bomDetailList',
+		plain: true,
+		// itemType: "default",
+		listConfig: [
+			{
+				type: 'input',
+				itemType: 'text',
+				label: '物料编码',
+				prop: 'code',
+				clearable: true,
+				readonly: true,
+			},
+			{
+				type: 'input',
+				label: '物料名称',
+				prop: 'name',
+				itemType: 'text',
+				readonly: true,
+			},
+			{
+				type: 'picker',
+				label: '单位',
+				prop: 'unit',
+				itemType: 'onePicker',
+				showPicker: false,
+				fieldNames: {
+					text: 'dictValue',
+					value: 'dictKey',
+				},
+				data: [],
+                readonly: true,
+			},
+			{
+				type: 'input',
+				label: '数量',
+				prop: 'quantity',
+				itemType: 'number',
+			},
+			{
+				type: 'input',
+				label: '成本',
+				prop: 'cost',
+				itemType: 'number',
+			},
+		],
+		clickFn: () => {
+			show.value = true
+		},
+	},
 })
+const onClickLeft = () => history.go(-1)
+const onClose = () => {
+	formData.data.bomDetailList = []
+    if(formData.data.applicableProductsList.length == 0) return
+	formData.data.applicableProductsList.map((id) => {
+		productInfoData.value.forEach((item) => {
+			if (item.id === id) {
+				formData.data.bomDetailList.push({
+					productId: item.id,
+					name: item.name,
+					code: item.code,
+					quantity: null,
+					cost: null,
+					unit: item.unit,
+                    deleteFn:function(index,item){
+                        //删除对应索引的数据
+                        formData.data.bomDetailList.splice(index,1)
+                        formData.data.applicableProductsList.splice(index,1)
+                    },
+				})
+			}
+		})
+	})
+    formData.data.bomDetailList.map (item=>{
+        for (let i = 0; i < formOption.btnConfig.listConfig[2].data.length; i++) {
+            const element = formOption.btnConfig.listConfig[2].data[i];
+            if(item.unit == element.dictKey){
+                item.unitName = element.dictValue
+            }
+        }
+    })
+}
+
+const getDict = () => {
+	proxy
+		.post('/dictTenantData/page', {
+			pageNum: 1,
+			pageSize: 999,
+			tenantId: getUserInfo().tenantId,
+			dictCode: 'unit',
+		})
+		.then((res) => {
+			formOption.btnConfig.listConfig[2].data = res.data.rows
+		})
+}
+getDict()
 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: 'picker',
+		label: '产品名称',
+		prop: 'productId',
+		itemType: 'onePicker',
+		showPicker: false,
+		fieldNames: {
+			text: 'name',
+			value: 'id',
+		},
+		data: [],
 	},
-	
 ])
 const rules = {
-	name: [{ required: true, message: '车间类型不能为空' }],
-	fileList: [{ required: true, message: '请上传工序文件' }],
+	quantity: [{ required: true, message: '请填写数量' }],
+    cost: [{ required: true, message: '请填写成本' }],
 }
-const unitList = ref([])
-
-const getUserList = () => {
+const formData = reactive({
+	data: {
+        addType:1,
+    },
+})
+let productInfoData = ref([])
+const getDtl = (id) => {
+	proxy
+		.post('/productInfo/page', { pageNum: 1, pageSize: 10000 })
+		.then((resDetail) => {
+			productInfoData.value = resDetail.data.rows
+		})
     proxy
-        .get('/system/user/list?pageNum=1&pageSize=10000', {
-        })
-        .then((res) => {
-            formConfig[2].data = res.rows
-        })
-}
-getUserList()
-const fileList = ref([])
-const onOversize = () => {
-	showToast('文件大小不能超过 5MB')
+		.post('/productInfo/page', { pageNum: 1, pageSize: 10000,definition:'1', })
+		.then((resDetail) => {
+			formConfig[0].data = resDetail.data.rows
+		})
 }
-const onClickLeft = () => history.back()
+getDtl()
 const onSubmit = () => {
-	console.log(formData)
-
-	proxy.post('/productionProcesses/' + route.query.type, formData.data).then(() => {
-		showSuccessToast(route.query.type === 'add' ? '添加成功' : '修改成功')
-		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
+    formData.data.addType = route.query.addType
+	proxy
+		.post('/bomInfo/' + route.query.type, formData.data)
+		.then(() => {
+			showSuccessToast(
+				route.query.type === 'add' ? '添加成功' : '修改成功'
+			)
+			setTimeout(() => {
+				history.back()
+			}, 500)
+		}).catch(err=>{
+            showFailToast(err.message)
+        })
 }
+// getList();
+
 onMounted(() => {
-	if (route.query.id) {
+    if (route.query.type === 'edit') {
+        loading.value = true
         proxy
-            .post('/productionProcesses/detail', { id: route.query.id })
-            .then((resDetail) => {
-                formData.data = resDetail.data
+            .post('/bomInfo/detail', { id: route.query.id })
+            .then((res) => {
+                formData.data = res.data
+                formData.data.bomDetailList = res.data.bomDetailVoList
+                loading.value = false
             })
-		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>
+
+<style lang="scss" scoped>
+.list {
+	min-height: 70vh;
+}
+</style>

+ 42 - 18
src/views/production/bom/index.vue

@@ -6,7 +6,7 @@
 		@click-left="onClickLeft"
 		@click-right="onClickRight"
 	>
-		<template #right> 添加 </template>
+		<template #right> 新建版本 </template>
 	</van-nav-bar>
 	<van-search
 		v-model="req.keyword"
@@ -35,7 +35,7 @@
 import { ref, getCurrentInstance } from 'vue'
 import commonList from '@/components/common-list.vue'
 import { useRoute } from 'vue-router'
-
+import { showSuccessToast, showFailToast, showConfirmDialog } from 'vant'
 const loading = ref(false)
 const router = useRoute()
 const req = ref({
@@ -49,16 +49,16 @@ const listData = ref([])
 const classification = ref([])
 const listConfig = ref([
 	{
-		label: '工序名称',
-		prop: 'name',
+		label: '产品名称',
+		prop: 'productName',
 	},
 	{
-		label: '工序说明',
-		prop: 'remarks',
+		label: '产品编码',
+		prop: 'productCode',
 	},
 	{
-		label: '工序文件',
-		prop: 'fileName',
+		label: '版本号',
+		prop: 'versionNumber',
 	},
 ])
 //车间类型
@@ -87,21 +87,47 @@ const onLoad = () => {
 const onClickLeft = () => proxy.$router.push('/main/working')
 const onClickRight = () => {
 	proxy.$router.push({
-		path: 'workingProcedureAdd',
+		path: 'bomAdd',
 		query: {
 			type: 'add',
+			addType: 1,
 		},
 	})
 }
-proxy.uploadDdRightBtn(onClickRight,'添加')
+proxy.uploadDdRightBtn(onClickRight, '新建版本')
 const toDtl = (row) => {
-	proxy.$router.push({
-		path: 'workingProcedureAdd',
-		query: {
-			id: row.id,
-			type: 'edit',
-		},
+	showConfirmDialog({
+		title: '提示',
+		message: '新选择进入详情后的功能',            
+		cancelButtonText: '新建版本',
+		confirmButtonText: '修改',
 	})
+		.then(() => {
+			proxy.$router.push({
+				path: 'bomAdd',
+				query: {
+					id: row.id,
+					type: 'edit',
+				},
+			})
+		})
+		.catch(() => {
+			proxy.$router.push({
+				path: 'bomAdd',
+				query: {
+					id: row.id,
+					type: 'add',
+					addType: 2,
+				},
+			})
+		})
+	// proxy.$router.push({
+	// 	path: 'bomAdd',
+	// 	query: {
+	// 		id: row.id,
+	// 		type: 'edit',
+	// 	},
+	// })
 }
 const treeToList = (arr) => {
 	let res = [] // 用于存储递归结果(扁平数据)
@@ -136,7 +162,6 @@ const getList = (type) => {
 	proxy
 		.post('/bomInfo/page', req.value)
 		.then((res) => {
-			
 			listData.value =
 				type === 'refresh'
 					? res.data.rows
@@ -146,7 +171,6 @@ const getList = (type) => {
 			}
 			req.value.pageNum++
 			loading.value = false
-            
 		})
 		.catch((err) => {
 			loading.value = false