statementOfAccountDialog.vue
4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!-- 库存对账单弹窗 -->
<template>
<d2-dialog title="库存对账单" :is-visible="dialogVisible" mode="mid" class="statementOfAccountDialog" width="720px" @closeDialog="handleClose" @confirmDialog="handleConfirm">
<el-form ref="statementOfAccountForm" :model="dataForm" :rules="formRules" label-width="154px" size="small">
<el-form-item label="时间:" prop="dataMonthStr">
<el-date-picker
v-model="dataForm.dataMonthStr"
type="month"
:clearable="false"
value-format="yyyy-MM"
:append-to-body="false"
format="yyyy-MM"
class="form-node"
placeholder="选择时间"
popper-class="statement-of-account-month-picker"
:picker-options="beforeRangePickerOptions">
</el-date-picker>
</el-form-item>
<el-form-item label="仓库:" prop="yqMerchantId">
<el-select v-model="dataForm.yqMerchantId" class="form-node" filterable @change="yqMerchantIdChange" placeholder="请选择仓库">
<el-option v-for="(subItem, subIndex) in stockList" :key="subIndex" :value="subItem.merchantNo" :label="subItem.merchantName"></el-option>
</el-select>
</el-form-item>
<el-form-item label="门店:" prop="merchantId">
<el-select v-model="dataForm.merchantId" class="form-node" filterable @focus="merchantSelectFocus" placeholder="请选择门店">
<el-option v-for="(subItem, subIndex) in merchantList" :key="subIndex" :value="subItem.merchantId" :label="subItem.merchantName"></el-option>
</el-select>
</el-form-item>
</el-form>
</d2-dialog>
</template>
<script>
import { deepClone } from '@/common/util'
import { getServicemerchantrefList } from '@api/stockManage'
export default {
name: 'StatementOfAccountDialog',
props: {
visible: {
type: Boolean,
default: false
},
yqMerchantList: {
type: Array,
default: () => []
}
},
data() {
return {
beforeRangePickerOptions: {
disabledDate(date) {
if (date > new Date()) {
return true
}
return false
}
},
dataForm: {
dataMonthStr: '',
yqMerchantId: '',
merchantId: ''
},
formRules: {
dataMonthStr: [{ required: true, message: '请选择时间', trigger: 'change' }],
yqMerchantId: [{ required: true, message: '请选择仓库', trigger: 'change' }],
merchantId: [
{ required: true, message: '请选择门店', trigger: 'change' }
]
},
merchantList: []
}
},
computed: {
dialogVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
},
stockList: {
get() {
const list = deepClone(this.yqMerchantList)
if (list[0]?.merchantName == '全部') {
list.shift()
}
return list
}
}
},
mounted() {
this.$nextTick(() => {
this.$refs.statementOfAccountForm && this.$refs.statementOfAccountForm.resetFields()
})
},
methods: {
// 门店
merchantSelectFocus() {
if (!this.dataForm?.yqMerchantId) return this.$message.error('请先选择仓库')
},
// 仓库
yqMerchantIdChange(e) {
this.dataForm.merchantId = ''
this.merchantList = []
this.$nextTick(() => {
this.$refs.statementOfAccountForm.clearValidate()
})
// 总店
const _headOffice = this.stockList.find(item => item.merchantNo === e)
_headOffice.merchantId = _headOffice.merchantNo
// 获取仓库下的门店列表
getServicemerchantrefList({
yqMerchantId: e
}).then(res => {
this.merchantList = res || []
this.merchantList.push(_headOffice) // 园区店可选择自己
})
},
handleClose() {
this.dialogVisible = false
},
handleConfirm() {
this.$refs.statementOfAccountForm.validate(valid => {
if (valid) {
this.$emit('handleRelateProConfirm', this.dataForm)
}
})
}
}
}
</script>
<style scoped lang="scss">
.statementOfAccountDialog{
.form-node{
width: 432px;
}
}
</style>
<style lang="scss">
.statement-of-account-month-picker {
.el-picker-panel__body-wrapper .el-picker-panel__body .el-picker-panel__content .el-month-table td.current:not(.disabled) .cell {
color: #fff;
background: #2A58AD;
border-radius: 18px;
}
.el-month-table td.today .cell{
color: #2A58AD;
}
}
</style>