From 97eeda5eeb1d0fe6163120ce3a05a1a3b3253f59 Mon Sep 17 00:00:00 2001 From: joylink_cuiweidong <364937672@qq.com> Date: Mon, 9 Dec 2019 14:51:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=9B=E5=BB=BA=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/QueryListPage/DataForm.vue | 39 ++++++- src/views/orderauthor/order/addGoods.vue | 37 +++++-- src/views/orderauthor/order/draft.vue | 121 +++++++++++++++++----- 3 files changed, 161 insertions(+), 36 deletions(-) diff --git a/src/components/QueryListPage/DataForm.vue b/src/components/QueryListPage/DataForm.vue index 3ca61721e..0eb2f62b0 100644 --- a/src/components/QueryListPage/DataForm.vue +++ b/src/components/QueryListPage/DataForm.vue @@ -232,6 +232,35 @@ + + @@ -286,8 +315,16 @@ export default { } }; - diff --git a/src/views/orderauthor/order/addGoods.vue b/src/views/orderauthor/order/addGoods.vue index 536496141..3a50fff64 100644 --- a/src/views/orderauthor/order/addGoods.vue +++ b/src/views/orderauthor/order/addGoods.vue @@ -90,7 +90,7 @@ export default { title: this.$t('orderAuthor.belongsToMap'), prop: 'mapName', type: 'tag', - columnValue: (row) => { return row.mapName }, + columnValue: (row) => { return row.mapName; }, tagType: (row) => { return ''; } }, { @@ -119,10 +119,22 @@ export default { width: '250', buttons: [ { - name: this.$t('orderAuthor.select'), - type: 'primary', - handleClick: this.handleAdd + name: this.$t('global.append'), + handleClick: this.handlePut, + type: '', + showControl: (row) => { return !row.isPut; } + }, + { + name: this.$t('global.delete'), + handleClick: this.handlePop, + type: 'warning', + showControl: (row) => { return row.isPut; } } + // { + // name: this.$t('orderAuthor.select'), + // type: 'primary', + // handleClick: this.handleAdd + // } ] } ], @@ -163,9 +175,20 @@ export default { } }, - handleAdd(index, row) { - this.$emit('selectGoods', row); - this.doClose(); + // handleAdd(index, row) { + // this.$emit('selectGoods', row); + // // this.doClose(); + // }, + + handlePut(index, row) { + row.isPut = true; + this.$emit('addGoods', index, row); + // this.queryList.reload(); + }, + handlePop(index, row) { + row.isPut = false; + this.$emit('deleteGoods', index, row); + // this.queryList.reload(); }, reloadTable() { diff --git a/src/views/orderauthor/order/draft.vue b/src/views/orderauthor/order/draft.vue index 669fd009c..f943bf7eb 100644 --- a/src/views/orderauthor/order/draft.vue +++ b/src/views/orderauthor/order/draft.vue @@ -19,7 +19,8 @@ - + + @@ -51,6 +52,9 @@ export default { WhetherTypeList: [], OrgzList: [], PermissionTypeList: [], + isShowTable:false, + errorTip:'请输入商品数量', + errorIntTip:'数量必须为整数', formModel: { organizationId: '', goodsId: '', @@ -66,7 +70,8 @@ export default { payWays: '01', payStatus: '02', startTime: '', - sellerId: '' + sellerId: '', + detailCreateVOList:[] }, DatePicker: { shortcuts: [{ @@ -150,12 +155,41 @@ export default { labelWidth: this.$i18n.locale == 'en' ? '200px' : '145px', items: [ { prop: 'organizationId', label: this.$t('orderAuthor.organizationOrEnterprise'), type: 'select', required: false, disabled: this.isDisabled, options: this.OrganizationList, allowCreate: true, onChange: this.onChange }, - { prop: 'goodsName', label: this.$t('orderAuthor.commodityName'), type: 'text', required: false, disabled: true, rightWidth: true, buttontip: this.$t('orderAuthor.selectGoods'), buttonClick: this.buttonClick }, - { prop: 'price', label: this.$t('orderAuthor.itemPricing'), type: 'number', required: false, disabled: true, min: 0, message: this.$t('orderAuthor.yuan') }, + + // { prop: 'goodsName', label: this.$t('orderAuthor.commodityName'), type: 'text', required: false, disabled: true, rightWidth: true, buttontip: this.$t('orderAuthor.selectGoods'), buttonClick: this.buttonClick }, + { prop:'detailCreateVOList', + buttontip: this.$t('orderAuthor.selectGoods'), + buttonClick: this.buttonClick, + type:'table', + tableList:[ + {prop:'goodsName', label:'商品名称' }, + {prop:'goodsAmount', label:'商品数量', isEdit:true, min:0, + rules:{ + goodsAmount:[ + { + validator:this.validateChoose, + trigger: 'blur' + }, + { + validator:this.validateChoose, + trigger: 'change' + } + ] + } + }, + {prop:'goodsPrice', label:'商品单价'} + ], + operate:'操作', + operateButton:[ + {name:'删除', clickFunc:this.removeGoods} + ] + }, + // { prop: 'price', label: this.$t('orderAuthor.itemPricing'), type: 'number', required: false, disabled: true, min: 0, message: this.$t('orderAuthor.yuan') }, + { prop: 'orderType', label: this.$t('orderAuthor.orderType'), type: 'select', required: false, disabled: this.isDisabled, options: this.OrderTypeList }, { prop: 'sellerId', label: this.$t('orderAuthor.salesman'), type: 'select', required: false, show: this.isShowSeller, disabled: this.isDisabled, options: this.SellerList }, { prop: 'contractNo', label: this.$t('orderAuthor.contractNumber'), type: 'text', required: false, show: this.isShowContractNo }, - { prop: 'amount', label: this.totalTitle, type: 'number', required: false, show: true, min: 0 }, + // { prop: 'amount', label: this.totalTitle, type: 'number', required: false, show: true, min: 0 }, { prop: 'forever', label: this.$t('orderAuthor.permanenceOrNot'), type: 'radio', required: false, options: this.$ConstSelect.Whether, disabled: this.foreverIsDisabled }, { prop: 'startTime', label: this.$t('orderAuthor.startDate'), type: 'datetime', required: false, show: this.isShowStartDate, viewFormat: 'yyyy-MM-dd HH:mm:ss', valueFormat: 'yyyy-MM-dd HH:mm:ss', picker: this.DatePicker }, { prop: 'monthAmount', label: this.monthsTitle, type: 'number', required: false, show: this.isShowMonths, min: 0, message: this.$t('orderAuthor.month') }, @@ -265,10 +299,31 @@ export default { buttonClick() { this.$refs.addGoods.doShow(); }, - selectGoods(data) { - this.formModel.goodsId = data.id; - this.formModel.goodsName = data.name; - this.formModel.price = data.price; + validateChoose(rule, value, callback) { + if (value || value === 0) { + if (Number.isInteger(value)) { + callback(); + } else { + callback(new Error(this.errorIntTip)); + } + } else { + callback(new Error(this.errorTip)); + } + }, + addGoods(index, row) { + const data = { + 'goodsId':row.id, + 'goodsName':row.name, + 'goodsAmount':0, + 'goodsPrice':row.price + }; + this.formModel.detailCreateVOList.push(data); + }, + removeGoods(data) { + this.formModel.detailCreateVOList = this.formModel.detailCreateVOList.filter(({ goodsId }) => goodsId !== data.goodsId); + }, + deleteGoods(index, row) { + this.formModel.detailCreateVOList = this.formModel.detailCreateVOList.filter(({ goodsId }) => goodsId !== row.id); }, initLoadPage() { // 加载字典数据 @@ -314,7 +369,7 @@ export default { this.$Dictionary.payStatus().then(list => { this.$convertList(list, this.PayStatusTypeList, elem => { - return elem.code !== '03'; // 过滤取消状态 + return elem.code !== '03' && elem.code !== '04'; // 过滤取消和无需支付状态 }); }); @@ -417,17 +472,12 @@ export default { // 构造基础数据 const model = { - organizationId: orgzId, - goodsId: this.formModel.goodsId, + organizationId: orgzId, // ok orderType: this.formModel.orderType, - amount: this.formModel.amount, // permissionType: this.formModel.permissionType, forever: this.formModel.forever, bizType: this.formModel.bizType, - price: this.formModel.price - // monthAmount: this.formModel.monthAmount, - // startTime: this.formModel.startTime, - // payWays: this.formModel.payWays, + detailCreateVOList:[] }; // 根据界面是否显示,序列对应的数据到model中 @@ -441,26 +491,41 @@ export default { if (this.isShowPayType) { model.payWays = this.formModel.payWays; } - if (this.isShowPayStatus) { model.payStatus = this.formModel.payStatus; } + if (this.isShowPayStatus) { model.payStatus = this.formModel.payStatus; } else { model.payStatus = '04'; } if (this.isShowSeller) { model.sellerId = this.formModel.sellerId; } // 如果是续费类型,则需要将权限ID一并返回回去 if (this.isReNew) { model.permissionId = this.$route.params.orderId; } - return model; + let count = 0; + this.formModel.detailCreateVOList.forEach(data=>{ + if (data.goodsAmount > 0) { + count++; + model.detailCreateVOList.push({'goodsId':data.goodsId, 'goodsAmount':data.goodsAmount}); + } + }); + + if (count <= 0) { + this.$messageBox('至少有一个商品的数量大于0'); + return false; + } else { + return model; + } }, create() { this.$refs.dataform.validateForm(() => { - this.loading = true; - createOrder(this.buildModel()).then(response => { - this.turnback(); - this.loading = false; - this.$message.success(this.$t('tip.creatingSuccessful')); - }).catch(() => { - this.loading = false; - this.$messageBox(this.$t('tip.creatingFailed')); - }); + if (this.buildModel()) { + this.loading = true; + createOrder(this.buildModel()).then(response => { + this.turnback(); + this.loading = false; + this.$message.success(this.$t('tip.creatingSuccessful')); + }).catch(() => { + this.loading = false; + this.$messageBox(this.$t('tip.creatingFailed')); + }); + } }); }, update() {