Commit 82ed78cffc3f360c5e14fef3426b816bf585ffe0

Authored by 史婷婷
1 parent c153bb81

feat: 订货单代码优化

Showing 1 changed file with 1 additions and 29 deletions
... ... @@ -136,24 +136,15 @@ export default {
136 136 mode: { type: String, default: 'add' },
137 137 list: { type: Array, default: () => [] },
138 138 max: { type: Number, default: 8 },
139   - options: { type: Array, default: () => [] },
140 139 totalQuantity: { type: Number, default: 0 }
141 140 },
142 141 data() {
143 142 return {
144 143 items: [],
145 144 collapsedView: false,
146   - sheet: { visible: false, title: '请选择性别', options: [], value: '', idx: -1 }
147 145 }
148 146 },
149 147 computed: {
150   - selectOptions() {
151   - const list = Array.isArray(this.options) ? this.options : []
152   - return list.map(o => ({
153   - label: o.label != null ? o.label : (o.text != null ? o.text : (o.name != null ? o.name : '')),
154   - value: o.value != null ? o.value : (o.code != null ? o.code : (o.id != null ? o.id : o.productId))
155   - }))
156   - }
157 148 },
158 149 watch: {
159 150 items: {
... ... @@ -163,19 +154,13 @@ export default {
163 154 list: {
164 155 handler(v) {
165 156 const arr = Array.isArray(v) ? v : []
166   - const opts = this.selectOptions
167 157 this.items = arr.map(x => {
168 158 const it = { ...this.defaultItem(), ...x, collapsed: true }
169   - const m = opts.find(o => String(o.value) === String(it.sex))
170   - it.sexName = m ? (m.label || '') : it.sexName
171 159 return it
172 160 })
173 161 },
174 162 deep: true
175 163 },
176   - options: {
177   - handler() { this.refreshSexNames() }
178   - }
179 164 },
180 165 created() {
181 166 const init = Array.isArray(this.list) && this.list.length > 0 ? this.list.map(v => ({ ...this.defaultItem(), ...v, collapsed: false })) : [{ ...this.defaultItem(), collapsed: false }]
... ... @@ -183,20 +168,7 @@ export default {
183 168 },
184 169 methods: {
185 170 defaultItem() {
186   - return { personId: uuid(), name: '', sex: '', sexName: '', nativePlace: '', age: '', position: '', mobile: '', phone: '', email: '', address: '', collapsed: false }
187   - },
188   - getSexName(item) {
189   - const opts = this.selectOptions
190   - const v = item && item.sex
191   - const m = opts.find(o => String(o.value) === String(v))
192   - return m ? (m.label || '') : ((item && item.sexName) || '')
193   - },
194   - refreshSexNames() {
195   - const opts = this.selectOptions
196   - this.items = (this.items || []).map(it => {
197   - const m = opts.find(o => String(o.value) === String(it.sex))
198   - return { ...it, sexName: m ? (m.label || '') : it.sexName }
199   - })
  171 + return { collapsed: false }
200 172 },
201 173 toggleItem(idx) {
202 174 const it = this.items[idx]
... ...