فهرست منبع

物料数据去重和供应商选择

AlanWong 2 سال پیش
والد
کامیت
5400016a14
3فایلهای تغییر یافته به همراه64 افزوده شده و 41 حذف شده
  1. 5 1
      src/benyun/components/byBill/byBill.vue
  2. 15 4
      src/views/audit/orderTask/components/focus.vue
  3. 44 36
      src/views/audit/orderTask/index.vue

+ 5 - 1
src/benyun/components/byBill/byBill.vue

@@ -32,7 +32,7 @@
           <by-tool ref="billTool" :propConfig="billConfig.tool" @clickHandle="clickHandle($event,'bill')" />
         </div>
         <div class="form" v-if="billConfig.form">
-          <by-form ref="billForm" :propConfig="billConfig.form" />
+          <by-form ref="billForm" :propConfig="billConfig.form" @getSupplierModal="getSupplierModal" />
         </div>
         <template v-if="billConfig.tableConfig && billConfig.tableConfig.length > 0">
           <div class="bill-table" v-for="(item,index) of billConfig.tableConfig" :key="index">
@@ -360,6 +360,10 @@ export default class ByBill extends VueViews {
   detail(row:any,n:string){
     this.$emit('detail',{row,type:n})
   }
+	
+	getSupplierModal(e:any){
+		this.$emit('getSupplierModal',e);
+	}
 }
 </script>
 

+ 15 - 4
src/views/audit/orderTask/components/focus.vue

@@ -1,15 +1,26 @@
 <template>
 	<div>
-		<el-input placeholder="请选择机构名称" @focus="getFocus($event)"></el-input>
+		<el-input placeholder="请选择供应商" v-model="propValue" class="input-organizationName" clearable :readonly="true">
+			<el-button slot="append" icon="el-icon-more" @click="handleSupplier"></el-button>
+		</el-input>
+		<!-- 选择机构名称 -->
+		<supplierModal ref="supplierModal" @confirm="confirm" />
 	</div>
 </template>
 
 <script lang="ts">
 	import { Component, Prop, Vue, Watch } from "vue-property-decorator";
-	@Component
+	import SupplierModal from "@/components/supplierModal/supplierModal.vue";
+	@Component({ components: { SupplierModal } })
 	export default class Focus extends Vue {
-		getFocus(e : any) {
-			console.log(e,'666');
+		@Prop()
+		propValue : any
+		handleSupplier() {
+			(this.$refs.supplierModal as any).setShow(true);
+		}
+		// 确定机构名称
+		confirm(e : any) {
+			this.$emit('getSupplierModal', e[0])
 		}
 	}
 </script>

+ 44 - 36
src/views/audit/orderTask/index.vue

@@ -2,12 +2,10 @@
 	<div>
 		<by-bill ref="bill" :propConfig="config" @search="search" @onSmt="onSmt" @onAdd="onAdd" @onDelete="onDelete"
 			@onDispatch="onDispatch" @onRefresh="onRefresh" @detail="openEdit" @onSave="onSave" @clickTab="clickTab"
-			@onChangeRow="onChangeRow" @pagination="pagination">
+			@onChangeRow="onChangeRow" @pagination="pagination" @getSupplierModal="getSupplierModal">
 		</by-bill>
 		<!-- 选择物料 -->
 		<productModal ref="product" :mulit="true" @confirm="confirmProduct" />
-		<!-- 选择机构名称 -->
-		<!-- <supplierModal /> -->
 	</div>
 </template>
 
@@ -17,12 +15,13 @@
 	import Assembly from "@/components/Assembly/order.vue";
 	import productModal from "./components/productModal.vue";
 	import Focus from "./components/focus.vue";
-	@Component({ components: { productModal,Focus } })
+	@Component({ components: { productModal } })
 	export default class OrderTask extends Vue {
 		// 左边
-		tabType : any = 'bill';
+		tabType : any = 'all';
 		isAdd : any = false
 		// 右边
+		supplierInfo : any = {} // 机构信息
 		tableData : any = []
 		mergeObj : any = []
 		setStatusData : any = ''
@@ -30,7 +29,7 @@
 		timer : any = null
 		config : any = {
 			attr: {
-				activeName: 'bill'
+				activeName: 'all'
 			},
 			// 单据
 			bill: {
@@ -44,9 +43,6 @@
 						size: 'small',
 						readonly: false,
 						rules: {
-							organizationName: [{
-								required: true, message: '请输入机构名称', trigger: 'blur'
-							}],
 							orderNumber: [{
 								required: true, message: '请输入单据编号', trigger: 'blur'
 							}]
@@ -801,8 +797,9 @@
 				this.getDataList()
 			}, 500)
 		}
-		getFocus(e:any){
-			console.log(e);
+		// 获取机构数据
+		getSupplierModal(e : any) {
+			this.supplierInfo = e;
 		}
 		// 监听表格数据变化
 		onChangeRow(e : any) {
@@ -811,7 +808,7 @@
 		}
 		// 确定商品新增
 		confirmProduct(e : any) {
-			let contents = '', goodsData = e;
+			let contents : any = [], goodsData = e, newArr : any = [],obj:any={};
 			goodsData = goodsData.map((item : any) => {
 				item.materialName = item.skuTitle
 				item.prePrice = 0
@@ -823,22 +820,49 @@
 				return newData
 			})
 			this.tableData = this.tableData.concat(goodsData);
-			console.log('this.tableData ==> ', this.tableData);
+			newArr = this.tableData.reduce((prev : any, current : any) => {
+				// console.log('prev ==> ', prev);
+				// console.log('current ==> ', current);
+				obj[current.materialSku] ? contents.push(current.materialName) : (obj[current.materialSku] = true && prev.push(current))
+				return prev
+			}, []);
+			this.tableData = newArr;
 			this.tableData.map((v : any, i : any) => {
 				v.dataIndex = i
 			});
-			if (contents) {
-				this.$alert('商品id' + contents + '已存在!', '提示', {
+			if (contents.length > 0) {
+				this.$alert('商品 “' + contents + '” 已存在!', '提示', {
 					confirmButtonText: '确定',
 				});
 			};
 			(this.$refs.bill as any).setBillTableValue(this.tableData, 0);// 设置第1张单据表格数据
 		}
+		// 提交
+		onSmt(e : any) {
+			console.log('提交 ==>', e);
+			(this as any).$refs.bill.$refs.billForm.validate().then(() => {
+				let query = (this.$refs.bill as any).getBillFormValue(); // 获取单据数据
+				if (this.tabType === 'all') {
+					// api.saveList(query, 'supplyTaskOrder').then((res : any) => {
+					// 	if (res.code === 200) {
+					// 		this.$message.success('提交成功');
+					// 		this.getDataList();
+					// 		(this.$refs.bill as any).showTab = 'all';
+					// 		(this.$refs.bill as any).setBillFormValue({});
+					// 	} else this.failHandle(res)
+					// })
+				}
+			})
+		}
 		// 保存
 		onSave(e : any) {
 			console.log('保存 ==>', this.tabType);
 			(this as any).$refs.bill.$refs.billForm.validate().then(() => {
 				let query = (this.$refs.bill as any).getBillFormValue(); // 获取单据数据
+				// 供应商数据
+				if (!query.organizationName) query.organizationName = this.supplierInfo.name;
+				if (!query.organizationId) query.organizationId = this.supplierInfo.id;
+				if (!query.organizationName) return this.$message.warning('请选择机构名称');
 				// 子表数据
 				query.suborderList = this.tableData;
 				if (query.suborderList.length > 0) {
@@ -853,6 +877,8 @@
 					}
 				});
 				if (query.deliveryData) query.deliveryData = query.deliveryData + ' 00:00:00';
+				console.log('保存参数query ==> ', query);
+
 				if (this.isAdd) {
 					query.submitState = 0
 					console.log('保存进草稿箱 ==>', query);
@@ -865,7 +891,6 @@
 						} else this.$message.error(res.msg);
 					})
 				} else if (this.tabType === 'all' || this.tabType === 'draftsBox') {
-
 					if (this.tabType === 'draftsBox') query.submitState = 0;
 					console.log('保存 ==>', query);
 					api.updateList(query, 'supplyTaskOrder').then((res : any) => {
@@ -876,10 +901,9 @@
 							(this.$refs.bill as any).setBillFormValue({});
 						} else this.$message.error(res.msg);
 					})
-
 				};
-			})
 
+			})
 		}
 		// 打开新增
 		onAdd(e : any) {
@@ -912,6 +936,7 @@
 			if (this.tabType === 'all' || this.tabType === 'draftsBox') {
 				e = e.row ? e.row : e;
 				console.log('编辑 ==>', e);
+				if (this.tabType === 'all' && e.submitState === 1) return this.setReadonly(e);
 				let data = e.suborderList
 				data.map((v : any, i : any) => {
 					v.dataIndex = i
@@ -919,7 +944,7 @@
 				let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
 				billConfig.form.attr.readonly = false; // 设置只读
 				billConfig.tool.tools = { save: true, };
-				if (this.tabType === 'draftsBox') billConfig.tool.tools = { save: true, smt: true };
+				if (this.tabType === 'draftsBox' || e.submitState === 0) billConfig.tool.tools = { save: true, smt: true };
 				billConfig.tableConfig[0].tool.tools = { add: true };
 				this.tableData = data;
 				(this.$refs.bill as any).setBillConfig(billConfig);
@@ -951,23 +976,6 @@
 		onDispatch(e : any) {
 			console.log('派单 ==>', e);
 		}
-		// 提交
-		onSmt(e : any) {
-			console.log('提交 ==>', e);
-			(this as any).$refs.bill.$refs.billForm.validate().then(() => {
-				let query = (this as any).$refs.bill.$refs.billForm.getValue();
-				if (this.tabType === 'all') {
-					// api.saveList(query, 'supplyTaskOrder').then((res : any) => {
-					// 	if (res.code === 200) {
-					// 		this.$message.success('提交成功');
-					// 		this.getDataList();
-					// 		(this.$refs.bill as any).showTab = 'all';
-					// 		(this.$refs.bill as any).setBillFormValue({});
-					// 	} else this.failHandle(res)
-					// })
-				}
-			})
-		}
 		// 切换tab栏
 		clickTab(e : any) {
 			console.log('切换tab ==> ', e);