|
@@ -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);
|