Showing
2 changed files
with
218 additions
and
76 deletions
| ... | ... | @@ -3,9 +3,10 @@ |
| 3 | 3 | <scroll-view class="scroll" scroll-y> |
| 4 | 4 | <uni-list> |
| 5 | 5 | <view class="section"> |
| 6 | - <uni-list-item title="订单编号"> | |
| 7 | - <template v-slot:footer> | |
| 8 | - <view class="readonly-text">{{ form.orderNo }}</view> | |
| 6 | + <uni-list-item class="select-item" :class="form.orderNo ? 'is-filled' : 'is-empty'" clickable | |
| 7 | + @click="openRelate('orderNo')" :rightText="form.orderNo || '请选择订单编号'" showArrow> | |
| 8 | + <template v-slot:body> | |
| 9 | + <view class="item-title"><text class="required">*</text><text>订单编号</text></view> | |
| 9 | 10 | </template> |
| 10 | 11 | </uni-list-item> |
| 11 | 12 | <uni-list-item title="供货单位"> |
| ... | ... | @@ -138,62 +139,64 @@ |
| 138 | 139 | <view class="view-total"> |
| 139 | 140 | <view class="head">合计</view> |
| 140 | 141 | <view class="row"> |
| 141 | - <text class="label">总数量</text><text class="value">{{ form.totalQuantity }}</text> | |
| 142 | + <text class="label">总数量</text><text class="value">{{ form.afterTotalQuantity }}</text> | |
| 142 | 143 | </view> |
| 143 | 144 | </view> |
| 144 | 145 | <button class="btn submit" type="primary" @click="onSubmit">提交</button> |
| 145 | 146 | </view> |
| 146 | 147 | <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value" |
| 147 | 148 | @confirm="onSheetConfirm" /> |
| 149 | + <RelateSelectSheet :visible.sync="relate.visible" :title="relate.title" :source="relate.source" | |
| 150 | + :display-fields="relate.display" :multiple="relate.multiple" :row-key="relate.rowKey" | |
| 151 | + :selectedKeys.sync="relate.selectedKeys" :source-extra="{ queryType: 'CHANGE' }" @confirm="onRelateConfirm" /> | |
| 148 | 152 | </view> |
| 149 | 153 | </template> |
| 150 | 154 | |
| 151 | 155 | <script> |
| 152 | -import { createApi } from '@/api/change_list.js' | |
| 156 | +import { createApi, loadOrderApi } from '@/api/change_list.js' | |
| 153 | 157 | import Product from './product.vue' |
| 154 | 158 | import SingleSelectSheet from '@/components/single-select/index.vue' |
| 159 | +import RelateSelectSheet from '@/components/relate-select/index.vue' | |
| 155 | 160 | import { getDicName } from '@/utils/dic.js' |
| 156 | 161 | import { getDicByCodes } from '@/utils/dic' |
| 157 | 162 | |
| 158 | 163 | export default { |
| 159 | 164 | name: 'ChangeListAdd', |
| 160 | - components: { Product, SingleSelectSheet }, | |
| 165 | + components: { Product, SingleSelectSheet, RelateSelectSheet }, | |
| 161 | 166 | data() { |
| 162 | 167 | return { |
| 163 | 168 | form: { |
| 164 | - code: '', | |
| 165 | - supplier: '', | |
| 166 | - buyer: '', | |
| 167 | - // 默认当前日期 格式为 yyyy-MM-dd | |
| 168 | - orderDate: new Date().toISOString().substring(0, 10), | |
| 169 | - unit: '', | |
| 170 | - totalQuantity: '', | |
| 171 | - totalAmountExcludingTax: '', | |
| 172 | - totalAmountIncludingTax: '', | |
| 173 | - totalAmountCapital: '', | |
| 174 | - depositInfo: '', | |
| 175 | - packagingRequirements: '', | |
| 176 | - paymentTerms: '', | |
| 177 | - transportMode: '', | |
| 178 | - destinationId: [], | |
| 179 | - includesPackagingFee: '', | |
| 180 | - includesTransportFee: '', | |
| 181 | - designatedConsignee: '', | |
| 182 | - specialTerms: '', | |
| 169 | + orderNo: '', | |
| 170 | + orderId: '', | |
| 171 | + supplyUnit: '', | |
| 172 | + orderingUnit: '', | |
| 173 | + orderDate: '', | |
| 174 | + workshopId: '', | |
| 175 | + settlementTerms: '', | |
| 176 | + deliveryMethod: '', | |
| 177 | + priceListNo: '', | |
| 178 | + invoicingStatus: '', | |
| 179 | + shippingCost: '', | |
| 180 | + packagingFee: '', | |
| 183 | 181 | executionStandard: '', |
| 184 | 182 | executionStandardRemarks: '', |
| 185 | - specialInstructions: '', | |
| 186 | - remarks: '', | |
| 187 | - pieceWeightHead: '', | |
| 183 | + totalQuantity: '', | |
| 184 | + afterTotalQuantity: '', | |
| 185 | + pieceWeightHeader: '', | |
| 188 | 186 | surface: '', |
| 189 | 187 | tolerance: '', |
| 190 | 188 | performance: '', |
| 191 | - component: '', | |
| 189 | + element: '', | |
| 192 | 190 | packaging: '', |
| 191 | + remarks: '', | |
| 192 | + // 默认当前日期 格式为 yyyy-MM-dd | |
| 193 | + orderDate: new Date().toISOString().substring(0, 10), | |
| 194 | + | |
| 193 | 195 | }, |
| 194 | 196 | initPurchaseOrderLineList: [], |
| 195 | 197 | dicOptions: { SUPPLIER: [], APPLICABLE_STANDARD: [] }, |
| 196 | - sheet: { visible: false, title: '请选择', options: [], value: '', field: '' } | |
| 198 | + sheet: { visible: false, title: '请选择', options: [], value: '', field: '' }, | |
| 199 | + relate: { visible: false, title: '选择', source: '', display: [], multiple: false, rowKey: 'id', selectedKeys: [], fieldKey: '' } | |
| 197 | 200 | } |
| 198 | 201 | }, |
| 199 | 202 | onLoad() { |
| ... | ... | @@ -242,10 +245,74 @@ export default { |
| 242 | 245 | } |
| 243 | 246 | this.sheet.visible = false |
| 244 | 247 | }, |
| 248 | + openRelate(fieldKey) { | |
| 249 | + let config = {} | |
| 250 | + if (fieldKey === 'orderNo') { | |
| 251 | + config = { | |
| 252 | + title: '订单', | |
| 253 | + source: 'orderAssoc', | |
| 254 | + rowKey: 'id', | |
| 255 | + multiple: false, | |
| 256 | + display: [ | |
| 257 | + { label: '订单编号', field: 'orderNo' }, | |
| 258 | + { label: '订货单位', field: 'orderingUnitName' }, | |
| 259 | + { label: '生产厂', field: 'workshopName' }, | |
| 260 | + { label: '办事处', field: 'deptName' }, | |
| 261 | + { label: '总数量(kg)', field: 'totalQuantity' }, | |
| 262 | + { label: '订货日期', field: 'orderDate' }, | |
| 263 | + { label: '下单人', field: 'contractCreateByName' } | |
| 264 | + ] | |
| 265 | + } | |
| 266 | + } | |
| 267 | + const currentId = this.form && (this.form.id || this.form.code) | |
| 268 | + const selectedKeys = currentId ? [currentId] : [] | |
| 269 | + this.sheet.visible = false | |
| 270 | + this.relate.title = config.title | |
| 271 | + this.relate.source = config.source | |
| 272 | + this.relate.display = config.display | |
| 273 | + this.relate.multiple = config.multiple | |
| 274 | + this.relate.rowKey = config.rowKey | |
| 275 | + this.relate.selectedKeys = selectedKeys | |
| 276 | + this.relate.fieldKey = fieldKey | |
| 277 | + this.$nextTick(() => { this.relate.visible = true }) | |
| 278 | + }, | |
| 279 | + async onRelateConfirm({ items }) { | |
| 280 | + const _fieldKey = this.relate.fieldKey | |
| 281 | + const first = (items && items.length > 0) ? items[0] : null | |
| 282 | + if (_fieldKey === 'orderNo') { | |
| 283 | + const id = first && (first.id || first.code) | |
| 284 | + if (id) { | |
| 285 | + try { | |
| 286 | + const res = await loadOrderApi([id]) | |
| 287 | + const data = res && res.data ? res.data : null | |
| 288 | + const item = Array.isArray(data) ? (data[0] || {}) : (data || {}) | |
| 289 | + const next = { ...this.form, ...item } | |
| 290 | + next.orderNo = next.orderNo || ((first && (first.orderNo || first.code)) || ''); | |
| 291 | + next.orderId = next.id || ''; | |
| 292 | + delete next.id | |
| 293 | + this.form = next | |
| 294 | + const lines = Array.isArray(item.purchaseOrderLineList) ? item.purchaseOrderLineList.map(x => ({ ...x, purchaseOrderId: x.id, id: '' })) : [] | |
| 295 | + this.initPurchaseOrderLineList = lines | |
| 296 | + const sum = lines.reduce((acc, it) => { | |
| 297 | + const v = Number(it && it.quantity) | |
| 298 | + return acc + (isNaN(v) ? 0 : v) | |
| 299 | + }, 0) | |
| 300 | + this.form.afterTotalQuantity = sum | |
| 301 | + this.refreshStandardName() | |
| 302 | + } catch (e) { | |
| 303 | + this.form.orderNo = (first && (first.orderNo || first.code)) || '' | |
| 304 | + } | |
| 305 | + } else { | |
| 306 | + this.form.orderNo = (first && (first.orderNo || first.code)) || '' | |
| 307 | + } | |
| 308 | + } | |
| 309 | + }, | |
| 245 | 310 | getDicName: getDicName, |
| 246 | 311 | async onSubmit() { |
| 247 | 312 | const payload = { ...this.form } |
| 248 | 313 | console.log('onSubmit__payload', payload) |
| 314 | + payload.orderSpecList = payload.purchaseOrderLineList || []; | |
| 315 | + delete payload.purchaseOrderLineList; | |
| 249 | 316 | try { |
| 250 | 317 | await createApi(payload) |
| 251 | 318 | uni.showToast({ title: '保存成功', icon: 'success' }) |
| ... | ... | @@ -256,7 +323,12 @@ export default { |
| 256 | 323 | }, |
| 257 | 324 | purchaseOrderLineListChange(data) { |
| 258 | 325 | const list = Array.isArray(data) ? data : [] |
| 259 | - this.form.purchaseOrderLineList = list; | |
| 326 | + this.form.purchaseOrderLineList = list | |
| 327 | + const sum = list.reduce((acc, it) => { | |
| 328 | + const v = Number(it && it.quantity) | |
| 329 | + return acc + (isNaN(v) ? 0 : v) | |
| 330 | + }, 0) | |
| 331 | + this.form.afterTotalQuantity = sum | |
| 260 | 332 | }, |
| 261 | 333 | } |
| 262 | 334 | } | ... | ... |
| ... | ... | @@ -17,44 +17,89 @@ |
| 17 | 17 | |
| 18 | 18 | <view v-if="mode === 'add'" class="section"> |
| 19 | 19 | <view v-for="(item, idx) in items" :key="'a-' + idx" class="block"> |
| 20 | - <view class="row"><text class="label">行业</text><text class="value">{{ item.industry }}</text></view> | |
| 21 | - <view class="row"><text class="label">品质</text><text class="value">{{ item.quality }}</text></view> | |
| 22 | - <view class="row"><text class="label">牌号</text><text class="value">{{ item.brand }}</text></view> | |
| 23 | - | |
| 24 | - <view v-show="!item.collapsed"> | |
| 25 | - <!-- 厚(公差) * 宽(公差) * 长(公差) --> | |
| 26 | - <view class="row row-spec"><text class="label">规格(mm)</text> | |
| 27 | - <view class="value value-spec"> | |
| 28 | - <view v-if="item.thickness" class="value-spec_val">{{ item.thickness }}</view> | |
| 29 | - <view v-if="item.thickness" class="value-spec_box"> | |
| 30 | - <view v-if="item.thicknessTolPos" class="value-spec_box_1">+{{ item.thicknessTolPos }} | |
| 31 | - </view> | |
| 32 | - <view v-if="item.thicknessTolNeg" class="value-spec_box_2">-{{ item.thicknessTolNeg }} | |
| 33 | - </view> | |
| 34 | - </view> | |
| 35 | - <view v-if="item.width" class="value-spec_val p12">*</view> | |
| 36 | - <view v-if="item.width" class="value-spec_val">{{ item.width }}</view> | |
| 37 | - <view v-if="item.width" class="value-spec_box"> | |
| 38 | - <view v-if="item.widthTolPos" class="value-spec_box_1">+{{ item.widthTolPos }}</view> | |
| 39 | - <view v-if="item.widthTolNeg" class="value-spec_box_2">-{{ item.widthTolNeg }}</view> | |
| 40 | - </view> | |
| 41 | - <view v-if="item.length" class="value-spec_val p12">*</view> | |
| 42 | - <view v-if="item.length" class="value-spec_val">{{ item.length }}</view> | |
| 43 | - <view v-if="item.length" class="value-spec_box"> | |
| 44 | - <view v-if="item.lengthTolPos" class="value-spec_box_1">+{{ item.lengthTolPos }}</view> | |
| 45 | - <view v-if="item.lengthTolNeg" class="value-spec_box_2">-{{ item.lengthTolNeg }}</view> | |
| 46 | - </view> | |
| 47 | - </view> | |
| 48 | - </view> | |
| 49 | - <view class="row"><text class="label">状态</text><text class="value">{{ item.status }}</text></view> | |
| 50 | - <view class="row" :class="{ 'noneStyle': !item.showSalesPrice }"><text | |
| 51 | - class="label">数量kg</text><text class="value">{{ item.quantity }}</text> | |
| 52 | - </view> | |
| 53 | - <view class="row" :class="{ 'noneStyle': item.showSalesPrice }" v-if="item.showSalesPrice"><text | |
| 54 | - class="label">销售价格</text><text class="value">{{ | |
| 55 | - item.salesPrice }}</text></view> | |
| 56 | - | |
| 57 | - <uni-list class="edit-list"> | |
| 20 | + <uni-list class="edit-list"> | |
| 21 | + <uni-list-item title="行业"> | |
| 22 | + <template v-slot:footer> | |
| 23 | + <uni-easyinput v-model="item.industry" placeholder="请输入行业" :inputBorder="false" /> | |
| 24 | + </template> | |
| 25 | + </uni-list-item> | |
| 26 | + <uni-list-item title="品质"> | |
| 27 | + <template v-slot:footer> | |
| 28 | + <uni-easyinput v-model="item.quality" placeholder="请输入品质" :inputBorder="false" /> | |
| 29 | + </template> | |
| 30 | + </uni-list-item> | |
| 31 | + <uni-list-item title="牌号"> | |
| 32 | + <template v-slot:footer> | |
| 33 | + <uni-easyinput v-model="item.brand" placeholder="请输入牌号" :inputBorder="false" /> | |
| 34 | + </template> | |
| 35 | + </uni-list-item> | |
| 36 | + <view v-show="!item.collapsed"> | |
| 37 | + <uni-list-item title="厚度"> | |
| 38 | + <template v-slot:footer> | |
| 39 | + <uni-easyinput v-model="item.thickness" placeholder="请输入厚度" :inputBorder="false" /> | |
| 40 | + </template> | |
| 41 | + </uni-list-item> | |
| 42 | + <uni-list-item title="厚度公差 +"> | |
| 43 | + <template v-slot:footer> | |
| 44 | + <uni-easyinput v-model="item.thicknessTolPos" placeholder="请输入厚度公差 +" | |
| 45 | + :inputBorder="false" /> | |
| 46 | + </template> | |
| 47 | + </uni-list-item> | |
| 48 | + <uni-list-item title="厚度公差 -"> | |
| 49 | + <template v-slot:footer> | |
| 50 | + <uni-easyinput v-model="item.thicknessTolNeg" placeholder="请输入厚度公差 -" | |
| 51 | + :inputBorder="false" /> | |
| 52 | + </template> | |
| 53 | + </uni-list-item> | |
| 54 | + <uni-list-item title="宽度"> | |
| 55 | + <template v-slot:footer> | |
| 56 | + <uni-easyinput v-model="item.width" placeholder="请输入宽度" :inputBorder="false" /> | |
| 57 | + </template> | |
| 58 | + </uni-list-item> | |
| 59 | + <uni-list-item title="宽度公差 +"> | |
| 60 | + <template v-slot:footer> | |
| 61 | + <uni-easyinput v-model="item.widthTolPos" placeholder="请输入宽度公差 +" | |
| 62 | + :inputBorder="false" /> | |
| 63 | + </template> | |
| 64 | + </uni-list-item> | |
| 65 | + <uni-list-item title="宽度公差 -"> | |
| 66 | + <template v-slot:footer> | |
| 67 | + <uni-easyinput v-model="item.widthTolNeg" placeholder="请输入宽度公差 -" | |
| 68 | + :inputBorder="false" /> | |
| 69 | + </template> | |
| 70 | + </uni-list-item> | |
| 71 | + <uni-list-item title="长度"> | |
| 72 | + <template v-slot:footer> | |
| 73 | + <uni-easyinput v-model="item.length" placeholder="请输入长度" :inputBorder="false" /> | |
| 74 | + </template> | |
| 75 | + </uni-list-item> | |
| 76 | + <uni-list-item title="长度公差 +"> | |
| 77 | + <template v-slot:footer> | |
| 78 | + <uni-easyinput v-model="item.lengthTolPos" placeholder="请输入长度公差 +" | |
| 79 | + :inputBorder="false" /> | |
| 80 | + </template> | |
| 81 | + </uni-list-item> | |
| 82 | + <uni-list-item title="长度公差 -"> | |
| 83 | + <template v-slot:footer> | |
| 84 | + <uni-easyinput v-model="item.lengthTolNeg" placeholder="请输入长度公差 -" | |
| 85 | + :inputBorder="false" /> | |
| 86 | + </template> | |
| 87 | + </uni-list-item> | |
| 88 | + <uni-list-item title="状态"> | |
| 89 | + <template v-slot:footer> | |
| 90 | + <uni-easyinput v-model="item.status" placeholder="请输入状态" :inputBorder="false" /> | |
| 91 | + </template> | |
| 92 | + </uni-list-item> | |
| 93 | + <uni-list-item title="数量kg"> | |
| 94 | + <template v-slot:footer> | |
| 95 | + <uni-easyinput v-model="item.quantity" placeholder="请输入数量kg" :inputBorder="false" /> | |
| 96 | + </template> | |
| 97 | + </uni-list-item> | |
| 98 | + <uni-list-item v-if="item.showSalesPrice" title="销售价格"> | |
| 99 | + <template v-slot:footer> | |
| 100 | + <uni-easyinput v-model="item.salesPrice" placeholder="请输入销售价格" :inputBorder="false" /> | |
| 101 | + </template> | |
| 102 | + </uni-list-item> | |
| 58 | 103 | <uni-list-item title="发货日期"> |
| 59 | 104 | <template v-slot:footer> |
| 60 | 105 | <uni-datetime-picker type="date" v-model="item.deliveryDate" /> |
| ... | ... | @@ -66,11 +111,11 @@ |
| 66 | 111 | :inputBorder="false" /> |
| 67 | 112 | </template> |
| 68 | 113 | </uni-list-item> |
| 69 | - </uni-list> | |
| 70 | - </view> | |
| 114 | + </view> | |
| 115 | + </uni-list> | |
| 71 | 116 | |
| 72 | 117 | <view class="block-ops"> |
| 73 | - <div class="del" @click="onRemove(item.personId)"> | |
| 118 | + <div class="del" @click="onRemove(item.purchaseOrderId)"> | |
| 74 | 119 | <image src="/static/images/delete.png" class="icon" /> |
| 75 | 120 | 删除 |
| 76 | 121 | </div> |
| ... | ... | @@ -188,7 +233,29 @@ export default { |
| 188 | 233 | }, |
| 189 | 234 | methods: { |
| 190 | 235 | defaultItem() { |
| 191 | - return { personId: uuid(), name: '', sex: '', sexName: '', nativePlace: '', age: '', position: '', mobile: '', phone: '', email: '', address: '', collapsed: false } | |
| 236 | + return { | |
| 237 | + id: '', | |
| 238 | + purchaseOrderId: uuid(), | |
| 239 | + collapsed: false, | |
| 240 | + industry: '', | |
| 241 | + quality: '', | |
| 242 | + brand: '', | |
| 243 | + thickness: '', | |
| 244 | + thicknessTolPos: '', | |
| 245 | + thicknessTolNeg: '', | |
| 246 | + width: '', | |
| 247 | + widthTolPos: '', | |
| 248 | + widthTolNeg: '', | |
| 249 | + length: '', | |
| 250 | + lengthTolPos: '', | |
| 251 | + lengthTolNeg: '', | |
| 252 | + status: '', | |
| 253 | + quantity: '', | |
| 254 | + salesPrice: '', | |
| 255 | + showSalesPrice: false, | |
| 256 | + deliveryDate: '', | |
| 257 | + assessmentExceedsAgreement: '' | |
| 258 | + } | |
| 192 | 259 | }, |
| 193 | 260 | getSexName(item) { |
| 194 | 261 | const opts = this.selectOptions |
| ... | ... | @@ -235,7 +302,7 @@ export default { |
| 235 | 302 | cancelText: '取消', |
| 236 | 303 | success: (res) => { |
| 237 | 304 | if (res && res.confirm) { |
| 238 | - const i = this.items.findIndex(it => String(it.personId) === String(id)) | |
| 305 | + const i = this.items.findIndex(it => String(it.purchaseOrderId) === String(id)) | |
| 239 | 306 | if (i >= 0) { |
| 240 | 307 | this.items.splice(i, 1) |
| 241 | 308 | this.emitChange() |
| ... | ... | @@ -316,10 +383,13 @@ export default { |
| 316 | 383 | margin-right: 16rpx; |
| 317 | 384 | } |
| 318 | 385 | |
| 319 | - | |
| 320 | 386 | ::v-deep .uni-list { |
| 321 | 387 | background: transparent; |
| 322 | 388 | |
| 389 | + .uni-list--border-top { | |
| 390 | + background-color: transparent !important; | |
| 391 | + } | |
| 392 | + | |
| 323 | 393 | &-item { |
| 324 | 394 | &__extra-text { |
| 325 | 395 | font-size: 32rpx; |
| ... | ... | @@ -487,7 +557,7 @@ export default { |
| 487 | 557 | |
| 488 | 558 | .block { |
| 489 | 559 | background: #ffffff; |
| 490 | - padding: 32rpx 0; | |
| 560 | + // padding: 32rpx 0; | |
| 491 | 561 | margin-bottom: 20rpx; |
| 492 | 562 | |
| 493 | 563 | &:last-child { | ... | ... |