From ef4fcaa6915f218348491a721e0e996d803cb18c Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Tue, 4 Apr 2023 17:34:27 +0800 Subject: [PATCH] 2023-4-4 --- src/components/XyTable/index.vue | 3 ++ src/views/schedule/component/addSchedule.vue | 10 ++++- src/views/schedule/component/timeSelect.vue | 46 +++++++++++++------- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/components/XyTable/index.vue b/src/components/XyTable/index.vue index 7d143a5..5af4460 100644 --- a/src/components/XyTable/index.vue +++ b/src/components/XyTable/index.vue @@ -138,6 +138,9 @@ export default { cellClick(row, column, cell) { this.$emit('cellClick', row, column, cell) }, + getSelection(){ + return this.$refs.table?.store?.states?.selection ?? [] + }, createPage() { if (this.isPage) diff --git a/src/views/schedule/component/addSchedule.vue b/src/views/schedule/component/addSchedule.vue index 3dcd816..7b34f90 100644 --- a/src/views/schedule/component/addSchedule.vue +++ b/src/views/schedule/component/addSchedule.vue @@ -177,6 +177,7 @@ export default { this.$refs['timeSelect'].form.nurse_id = this.nurseId if(data.type === 'current-month'){ if(type === 1){ + this.$refs['timeSelect'].isDelete = false this.$refs['timeSelect'].form.id = '' this.isShowTime = true } @@ -186,6 +187,8 @@ export default { this.$refs['timeSelect'].form.nurse_id = schedule.nurse_id this.$refs['timeSelect'].form.start_time = schedule.start_time this.$refs['timeSelect'].form.end_time = schedule.end_time + this.$refs['timeSelect'].form.status = schedule.status + this.$refs['timeSelect'].form.address_id = schedule.address_id this.$refs['timeSelect'].form.schedule_list_skus = schedule.sku.map(item => item.sku_id) this.isShowTime = true } @@ -197,11 +200,14 @@ export default { const res = await customerDetail({ id: this.id }) - this.flag = true this.detail = res.detail - + if(!this.detail?.product_type?.product_skus){ + throw new Error('skus is empty') + } + this.flag = true }catch (err){ this.flag = false + console.error(err) } }, diff --git a/src/views/schedule/component/timeSelect.vue b/src/views/schedule/component/timeSelect.vue index e16859e..74c6221 100644 --- a/src/views/schedule/component/timeSelect.vue +++ b/src/views/schedule/component/timeSelect.vue @@ -46,6 +46,12 @@ + + + + + + { + if (value.length <= 0) { + callback(new Error('请选择护理项目')); + } else { + callback(); + } + }; return { nurses:[], nurseSelect:{ @@ -131,6 +144,7 @@ export default { address: '', start_time: '', end_time: '', + status: 0, schedule_list_skus: [] }, rules: { @@ -144,10 +158,13 @@ export default { {required: true, message: '请选择结束时间'} ], address_id: [ - {required: true, message: '请选择护工'} + {required: true, message: '请选择地址'} + ], + status: [ + {required: true, message: '请选择状态'} ], schedule_list_skus: [ - {required: true, message: '请选择护理项目'} + {validator: skuCheck} ] }, @@ -189,6 +206,7 @@ export default { address_id:'', start_time: '', end_time: '', + status: 0, schedule_list_skus: [] } }, @@ -220,12 +238,6 @@ export default { this.form.end_time = `${this.date} ${e}` }, - // handleCheckAllChange(val){ - // this.form.schedule_list_skus = val ? this.skus.map(item => { - // return item.sku.id - // }) : [] - // this.indeterminate =! this.indeterminate - // }, skuSelect(selection){ this.form.schedule_list_skus = selection.map(item => { return item.id @@ -254,10 +266,11 @@ export default { this.form.customer_id = this.customerId this.form.product_id = this.productId this.form.order_id = this.orderId - let temp = this.form.schedule_list_skus.map(item => { - return {sku_id: item} + this.form.schedule_list_skus = this.$refs['table'].getSelection().map(item => { + return { + sku_id:item.id + } }) - this.form.schedule_list_skus = temp this.$refs['elForm'].validate().then(valid => { if (valid) { scheduleSave(this.form).then(res => { @@ -283,21 +296,24 @@ export default { isShow(val) { if (val) { console.log(this.skus) - this.form.address_id = this.addresses.filter(item => { - return item.default === 1 - })[0]?.id || '' //默认选择 if(this.form.schedule_list_skus.length > 0){ this.toggleRow(this.form.schedule_list_skus) }else{ - this.toggleAll() + if(!this.form.id){ + this.toggleAll() + this.form.address_id = this.addresses.filter(item => { + return item.default === 1 + })[0]?.id || '' + } } } else { this.$emit('update:date','') this.$refs['table'].clearSelection() this.initForm() + this.$refs['elForm'].clearValidate() } } },